commit no. 11

This commit is contained in:
2026-03-25 19:48:45 +01:00
parent 586328a38b
commit f1f58168f3
2 changed files with 48 additions and 20 deletions

View File

@@ -580,16 +580,22 @@ void Application::renderControlPanel() {
bool isMulti = waterfallMultiCh_ && nCh > 1; bool isMulti = waterfallMultiCh_ && nCh > 1;
// Header with inline Single/Multi toggle // Header with inline Single/Multi toggle
float widgetW = (nCh > 1) ? 60.0f : 0.0f;
float gap = ImGui::GetStyle().ItemSpacing.x * 0.25f;
ImVec2 hdrMin = ImGui::GetCursorScreenPos();
float winLeft = ImGui::GetWindowPos().x;
float hdrRight = hdrMin.x + ImGui::GetContentRegionAvail().x;
ImGui::PushClipRect({winLeft, hdrMin.y}, {hdrRight - widgetW - gap, hdrMin.y + 200}, true);
bool headerOpen = ImGui::CollapsingHeader("##channels_hdr", bool headerOpen = ImGui::CollapsingHeader("##channels_hdr",
ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_DefaultOpen |
ImGuiTreeNodeFlags_AllowOverlap); ImGuiTreeNodeFlags_AllowOverlap);
ImGui::PopClipRect();
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Channels"); ImGui::Text("Channels");
if (nCh > 1) { if (nCh > 1) {
ImGui::SameLine(); ImGui::SameLine();
float btnW = 60.0f; ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x - widgetW + ImGui::GetStyle().FramePadding.x);
ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x - btnW); if (ImGui::Button(isMulti ? " Multi " : "Single ", {widgetW, 0})) {
if (ImGui::Button(isMulti ? " Multi " : "Single ", {btnW, 0})) {
waterfallMultiCh_ = !waterfallMultiCh_; waterfallMultiCh_ = !waterfallMultiCh_;
} }
} }
@@ -632,8 +638,35 @@ void Application::renderControlPanel() {
// ── Math ── // ── Math ──
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::CollapsingHeader("Math")) { {
renderMathPanel(); float btnW = ImGui::GetFrameHeight();
float gap = ImGui::GetStyle().ItemSpacing.x * 0.25f;
ImVec2 hdrMin = ImGui::GetCursorScreenPos();
float winLeft = ImGui::GetWindowPos().x;
float hdrRight = hdrMin.x + ImGui::GetContentRegionAvail().x;
ImGui::PushClipRect({winLeft, hdrMin.y}, {hdrRight - btnW - gap, hdrMin.y + 200}, true);
bool mathOpen = ImGui::CollapsingHeader("##math_hdr",
ImGuiTreeNodeFlags_DefaultOpen |
ImGuiTreeNodeFlags_AllowOverlap);
ImGui::PopClipRect();
ImGui::SameLine();
ImGui::Text("Math");
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x - btnW + ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("+##addmath", {btnW, 0})) {
int nPhys = analyzer_.numSpectra();
MathChannel mc;
mc.op = MathOp::Subtract;
mc.sourceX = 0;
mc.sourceY = std::min(1, nPhys - 1);
mc.color = {1.0f, 1.0f, 0.5f, 1.0f};
mathChannels_.push_back(mc);
}
if (ImGui::IsItemHovered()) ImGui::SetTooltip("Add math channel");
if (mathOpen) {
renderMathPanel();
}
} }
// ── Cursors ── // ── Cursors ──
@@ -645,13 +678,20 @@ void Application::renderControlPanel() {
// ── Measurements ── // ── Measurements ──
ImGui::Spacing(); ImGui::Spacing();
{ {
float cbW = ImGui::GetFrameHeight();
float gap = ImGui::GetStyle().ItemSpacing.x * 0.25f;
ImVec2 hdrMin = ImGui::GetCursorScreenPos();
float winLeft = ImGui::GetWindowPos().x;
float hdrRight = hdrMin.x + ImGui::GetContentRegionAvail().x;
ImGui::PushClipRect({winLeft, hdrMin.y}, {hdrRight - cbW - gap, hdrMin.y + 200}, true);
bool headerOpen = ImGui::CollapsingHeader("##meas_hdr", bool headerOpen = ImGui::CollapsingHeader("##meas_hdr",
ImGuiTreeNodeFlags_DefaultOpen |
ImGuiTreeNodeFlags_AllowOverlap); ImGuiTreeNodeFlags_AllowOverlap);
ImGui::PopClipRect();
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Measurements"); ImGui::Text("Measurements");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x - cbW + ImGui::GetStyle().FramePadding.x);
- ImGui::GetFrameHeight());
ImGui::Checkbox("##meas_en", &measurements_.enabled); ImGui::Checkbox("##meas_en", &measurements_.enabled);
if (ImGui::IsItemHovered()) ImGui::SetTooltip("Enable measurements"); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Enable measurements");
@@ -1267,15 +1307,6 @@ void Application::renderMathPanel() {
if (toRemove >= 0) if (toRemove >= 0)
mathChannels_.erase(mathChannels_.begin() + toRemove); mathChannels_.erase(mathChannels_.begin() + toRemove);
if (ImGui::Button("+ Add Math Channel")) {
MathChannel mc;
mc.op = MathOp::Subtract;
mc.sourceX = 0;
mc.sourceY = std::min(1, nPhys - 1);
mc.color = {1.0f, 1.0f, 0.5f, 1.0f};
mathChannels_.push_back(mc);
}
} }
void Application::loadConfig() { void Application::loadConfig() {

View File

@@ -157,10 +157,7 @@ void Measurements::drawWaterfall(const SpectrumDisplay& specDisplay,
} }
void Measurements::drawPanel() { void Measurements::drawPanel() {
if (!enabled) { if (!enabled) return;
ImGui::TextDisabled("Disabled");
return;
}
ImGui::SetNextItemWidth(-1); ImGui::SetNextItemWidth(-1);
ImGui::SliderInt("##maxpeaks", &maxPeaks, 1, 20, "Peaks: %d"); ImGui::SliderInt("##maxpeaks", &maxPeaks, 1, 20, "Peaks: %d");