diff --git a/src/ui/Application.cpp b/src/ui/Application.cpp index 52fb892..119fbe2 100644 --- a/src/ui/Application.cpp +++ b/src/ui/Application.cpp @@ -797,14 +797,6 @@ void Application::renderControlPanel() { ImGui::TextDisabled("Mode: %s", settings_.isIQ ? "I/Q" : (settings_.numChannels > 1 ? "Multi-ch" : "Real")); - int pkCh2 = std::clamp(waterfallChannel_, 0, analyzer_.numSpectra() - 1); - auto [peakBin, peakDB] = analyzer_.findPeak(pkCh2); - double peakFreq = analyzer_.binToFreq(peakBin); - { - char peakBuf[128]; - fmtFreqDB(peakBuf, sizeof(peakBuf), "Peak", peakFreq, peakDB); - ImGui::TextDisabled("%s", peakBuf); - } } void Application::renderSpectrumPanel() { diff --git a/src/ui/Cursors.cpp b/src/ui/Cursors.cpp index a6d1787..95bfbeb 100644 --- a/src/ui/Cursors.cpp +++ b/src/ui/Cursors.cpp @@ -123,7 +123,7 @@ void Cursors::draw(const SpectrumDisplay& specDisplay, fmtFreqDB(deltaBuf, sizeof(deltaBuf), "D", dFreq, dDB); ImVec2 dSz = ImGui::CalcTextSize(deltaBuf); - float tx = posX + sizeX - dSz.x - 178; + float tx = posX + sizeX - dSz.x - 168; float lineH = ImGui::GetTextLineHeight(); float ty = posY + 4; ImU32 col = IM_COL32(255, 200, 100, 255); diff --git a/src/ui/Measurements.cpp b/src/ui/Measurements.cpp index 1052849..5029320 100644 --- a/src/ui/Measurements.cpp +++ b/src/ui/Measurements.cpp @@ -63,6 +63,15 @@ void Measurements::findPeaks(const std::vector& spectrumDB, int maxN, void Measurements::update(const std::vector& spectrumDB, double sampleRate, bool isIQ, int fftSize) { + // Always track global peak (for the readout label). + if (!spectrumDB.empty()) { + auto it = std::max_element(spectrumDB.begin(), spectrumDB.end()); + int bin = static_cast(std::distance(spectrumDB.begin(), it)); + globalPeak_.bin = bin; + globalPeak_.dB = *it; + globalPeak_.freq = binToFreq(bin, sampleRate, isIQ, fftSize); + } + if (!enabled) { peaks_.clear(); return; } findPeaks(spectrumDB, maxPeaks, minPeakDist, peakThreshold); @@ -78,6 +87,16 @@ void Measurements::draw(const SpectrumDisplay& specDisplay, double sampleRate, bool isIQ, FreqScale freqScale, float minDB, float maxDB, float viewLo, float viewHi) const { + // Global peak readout (always shown, left of cursor delta) + { + char pkBuf[128]; + fmtFreqDB(pkBuf, sizeof(pkBuf), "Peak", globalPeak_.freq, globalPeak_.dB); + ImVec2 pkSz = ImGui::CalcTextSize(pkBuf); + float pkX = posX + sizeX - pkSz.x - 8 - 350; + float pkY = posY + 4; + ImGui::GetWindowDrawList()->AddText({pkX, pkY}, IM_COL32(180, 180, 200, 200), pkBuf); + } + if (!enabled || !showOnSpectrum || peaks_.empty()) return; ImDrawList* dl = ImGui::GetWindowDrawList(); diff --git a/src/ui/Measurements.h b/src/ui/Measurements.h index 3228818..d10d61c 100644 --- a/src/ui/Measurements.h +++ b/src/ui/Measurements.h @@ -46,6 +46,7 @@ public: bool showOnWaterfall = false; // draw vertical lines on waterfall private: + PeakInfo globalPeak_; // always-tracked highest peak std::vector peaks_; // Find top-N peaks with minimum bin separation.