Skip to content

Commit

Permalink
Added rbw to TimebasePropertiesDialog.
Browse files Browse the repository at this point in the history
Fixed potential id issues on StreamBrowserDialog.
Added support for specan properties display in StreamBrowserDialog.
  • Loading branch information
fredzo committed Nov 3, 2024
1 parent 239e5ac commit 27aa7a5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 14 deletions.
59 changes: 46 additions & 13 deletions src/ngscopeclient/StreamBrowserDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ StreamBrowserDialog::~StreamBrowserDialog()
*/
void StreamBrowserDialog::renderInfoLink(const char *label, const char *linktext, bool &clicked, bool &hovered)
{
ImGui::PushID(label); // Prevent collision if several sibling links have the same linktext
ImGui::Text("%s: ", label);
ImGui::SameLine(0, 0);
clicked |= ImGui::TextLink(linktext);
hovered |= ImGui::IsItemHovered();
ImGui::PopID();
}

/**
Expand Down Expand Up @@ -478,8 +480,10 @@ void StreamBrowserDialog::renderPsuRows(bool isVoltage, bool cc, PowerSupplyChan
DoItemHelp();
ImGui::PopID();
ImGui::TableSetColumnIndex(2);
ImGui::PushID(isVoltage ? "sV" : "sC");
clicked |= ImGui::TextLink(setValue);
hovered |= ImGui::IsItemHovered();
ImGui::PopID();
// Row 2
ImGui::TableNextRow();
if((isVoltage && !cc) || (!isVoltage && cc))
Expand All @@ -506,8 +510,10 @@ void StreamBrowserDialog::renderPsuRows(bool isVoltage, bool cc, PowerSupplyChan
DoItemHelp();
ImGui::PopID();
ImGui::TableSetColumnIndex(2);
ImGui::PushID(isVoltage ? "mV" : "mC");
clicked |= ImGui::TextLink(measuredValue);
hovered |= ImGui::IsItemHovered();
ImGui::PopID();
}

/**
Expand Down Expand Up @@ -725,21 +731,48 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
{
ImGui::BeginChild("sample_params", ImVec2(0, 0), ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_Border);

auto srate_txt = Unit(Unit::UNIT_SAMPLERATE).PrettyPrint(scope->GetSampleRate());
auto sdepth_txt = Unit(Unit::UNIT_SAMPLEDEPTH).PrettyPrint(scope->GetSampleDepth());
if(scope->HasTimebaseControls())
{
auto srate_txt = Unit(Unit::UNIT_SAMPLERATE).PrettyPrint(scope->GetSampleRate());
auto sdepth_txt = Unit(Unit::UNIT_SAMPLEDEPTH).PrettyPrint(scope->GetSampleDepth());

bool clicked = false;
bool hovered = false;
renderInfoLink("Sample rate", srate_txt.c_str(), clicked, hovered);
renderInfoLink("Sample depth", sdepth_txt.c_str(), clicked, hovered);
if (clicked)
m_parent->ShowTimebaseProperties();
if (hovered)
m_parent->AddStatusHelp("mouse_lmb", "Open timebase properties");
for(size_t i = 0; i<channelCount; i++)
bool clicked = false;
bool hovered = false;
renderInfoLink("Sample rate", srate_txt.c_str(), clicked, hovered);
renderInfoLink("Sample depth", sdepth_txt.c_str(), clicked, hovered);
if (clicked)
m_parent->ShowTimebaseProperties();
if (hovered)
m_parent->AddStatusHelp("mouse_lmb", "Open timebase properties");
for(size_t i = 0; i<channelCount; i++)
{
if(scope->IsChannelEnabled(i))
lastEnabledChannelIndex = i;
}
}
if(scope->HasFrequencyControls())
{
if(scope->IsChannelEnabled(i))
lastEnabledChannelIndex = i;
auto sdepth_txt = Unit(Unit::UNIT_SAMPLEDEPTH).PrettyPrint(scope->GetSampleDepth());
auto rbw_txt = Unit(Unit::UNIT_HZ).PrettyPrint(scope->GetResolutionBandwidth());
auto centerFreq_txt = Unit(Unit::UNIT_HZ).PrettyPrint(scope->GetCenterFrequency(0));
auto span_txt = Unit(Unit::UNIT_HZ).PrettyPrint(scope->GetSpan());

bool clicked = false;
bool hovered = false;
if(!scope->HasTimebaseControls()) // Only render sample depth if it has not already been shown in timebase controls
renderInfoLink("Points", sdepth_txt.c_str(), clicked, hovered);
renderInfoLink("Rbw", rbw_txt.c_str(), clicked, hovered);
renderInfoLink("Center freq.", centerFreq_txt.c_str(), clicked, hovered);
renderInfoLink("Span", span_txt.c_str(), clicked, hovered);
if (clicked)
m_parent->ShowTimebaseProperties();
if (hovered)
m_parent->AddStatusHelp("mouse_lmb", "Open timebase properties");
for(size_t i = 0; i<channelCount; i++)
{
if(scope->IsChannelEnabled(i))
lastEnabledChannelIndex = i;
}
}

ImGui::EndChild();
Expand Down
18 changes: 17 additions & 1 deletion src/ngscopeclient/TimebasePropertiesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ TimebasePropertiesPage::TimebasePropertiesPage(shared_ptr<Oscilloscope> scope)
}

Unit hz(Unit::UNIT_HZ);

m_rbw = scope->GetResolutionBandwidth();
m_rbwText = hz.PrettyPrint(m_rbw);

m_span = scope->GetSpan();
m_spanText = hz.PrettyPrint(m_span);

Expand Down Expand Up @@ -237,9 +241,21 @@ bool TimebasePropertiesDialog::DoRender()
HelpMarker("Number of points in the sweep");
}

Unit hz(Unit::UNIT_HZ);

// Resolution Bandwidh
ImGui::SetNextItemWidth(width);
if(UnitInputWithImplicitApply("Rbw", p->m_rbwText, p->m_rbw, hz))
{
scope->SetResolutionBandwidth(p->m_rbw);
// Update with values from the device
p->m_rbw = scope->GetResolutionBandwidth();
p->m_rbwText = hz.PrettyPrint(p->m_rbw);
}
HelpMarker("Resolution Bandwidth");

//Frequency
bool changed = false;
Unit hz(Unit::UNIT_HZ);

ImGui::SetNextItemWidth(width);
if(UnitInputWithImplicitApply("Start", p->m_startText, p->m_start, hz))
Expand Down
4 changes: 4 additions & 0 deletions src/ngscopeclient/TimebasePropertiesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class TimebasePropertiesPage
//(only valid if both RT and equivalent are available)
int m_samplingMode;

//Resolution Bandwidth
std::string m_rbwText;
int64_t m_rbw;

//Frequency domain controls
std::string m_centerText;
double m_center;
Expand Down

0 comments on commit 27aa7a5

Please sign in to comment.