global peak label moved to the spectrogram
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -63,6 +63,15 @@ void Measurements::findPeaks(const std::vector<float>& spectrumDB, int maxN,
|
||||
|
||||
void Measurements::update(const std::vector<float>& 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<int>(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();
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
bool showOnWaterfall = false; // draw vertical lines on waterfall
|
||||
|
||||
private:
|
||||
PeakInfo globalPeak_; // always-tracked highest peak
|
||||
std::vector<PeakInfo> peaks_;
|
||||
|
||||
// Find top-N peaks with minimum bin separation.
|
||||
|
||||
Reference in New Issue
Block a user