From 27aa7a544fef077958caaa0d7198204b8adc11bb Mon Sep 17 00:00:00 2001 From: fredzo Date: Sun, 3 Nov 2024 19:29:00 +0100 Subject: [PATCH] Added rbw to TimebasePropertiesDialog. Fixed potential id issues on StreamBrowserDialog. Added support for specan properties display in StreamBrowserDialog. --- src/ngscopeclient/StreamBrowserDialog.cpp | 59 +++++++++++++++---- .../TimebasePropertiesDialog.cpp | 18 +++++- src/ngscopeclient/TimebasePropertiesDialog.h | 4 ++ 3 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/ngscopeclient/StreamBrowserDialog.cpp b/src/ngscopeclient/StreamBrowserDialog.cpp index 3d81801b..78666007 100644 --- a/src/ngscopeclient/StreamBrowserDialog.cpp +++ b/src/ngscopeclient/StreamBrowserDialog.cpp @@ -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(); } /** @@ -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)) @@ -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(); } /** @@ -725,21 +731,48 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr 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; iShowTimebaseProperties(); + if (hovered) + m_parent->AddStatusHelp("mouse_lmb", "Open timebase properties"); + for(size_t i = 0; iIsChannelEnabled(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; iIsChannelEnabled(i)) + lastEnabledChannelIndex = i; + } } ImGui::EndChild(); diff --git a/src/ngscopeclient/TimebasePropertiesDialog.cpp b/src/ngscopeclient/TimebasePropertiesDialog.cpp index fdbd0a34..f38973ee 100644 --- a/src/ngscopeclient/TimebasePropertiesDialog.cpp +++ b/src/ngscopeclient/TimebasePropertiesDialog.cpp @@ -82,6 +82,10 @@ TimebasePropertiesPage::TimebasePropertiesPage(shared_ptr 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); @@ -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)) diff --git a/src/ngscopeclient/TimebasePropertiesDialog.h b/src/ngscopeclient/TimebasePropertiesDialog.h index 86c2a5a5..c7f0e74a 100644 --- a/src/ngscopeclient/TimebasePropertiesDialog.h +++ b/src/ngscopeclient/TimebasePropertiesDialog.h @@ -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;