commit no. 4
This commit is contained in:
@@ -649,14 +649,12 @@ void Application::renderWaterfallPanel() {
|
|||||||
float availW = ImGui::GetContentRegionAvail().x;
|
float availW = ImGui::GetContentRegionAvail().x;
|
||||||
float availH = ImGui::GetContentRegionAvail().y;
|
float availH = ImGui::GetContentRegionAvail().y;
|
||||||
|
|
||||||
// Fixed history depth — independent of screen height, so resizing the
|
// History depth must be >= panel height for 1:1 pixel mapping.
|
||||||
// splitter doesn't recreate the texture every frame.
|
// Only recreate when bin count or needed height actually changes.
|
||||||
constexpr int kHistoryRows = 1024;
|
int neededH = std::max(1024, static_cast<int>(availH) + 1);
|
||||||
|
|
||||||
// Only recreate when the bin count (FFT size) changes.
|
|
||||||
int binCount = std::max(1, analyzer_.spectrumSize());
|
int binCount = std::max(1, analyzer_.spectrumSize());
|
||||||
if (binCount != waterfall_.width() || waterfall_.height() != kHistoryRows) {
|
if (binCount != waterfall_.width() || waterfall_.height() < neededH) {
|
||||||
waterfall_.resize(binCount, kHistoryRows);
|
waterfall_.resize(binCount, neededH);
|
||||||
waterfall_.setColorMap(colorMap_);
|
waterfall_.setColorMap(colorMap_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,19 +716,19 @@ void Application::renderWaterfallPanel() {
|
|||||||
|
|
||||||
// From newestRow, walk forward (increasing index mod h) for
|
// From newestRow, walk forward (increasing index mod h) for
|
||||||
// screenRows steps to cover newest→oldest.
|
// screenRows steps to cover newest→oldest.
|
||||||
|
// Use availH for the screen extent so there's no fractional pixel gap.
|
||||||
|
float pxPerRow = availH / static_cast<float>(screenRows);
|
||||||
|
|
||||||
if (newestRow + screenRows <= h) {
|
if (newestRow + screenRows <= h) {
|
||||||
// No wrap: rows [newestRow .. newestRow+screenRows)
|
drawSpan(newestRow, screenRows, screenY, availH);
|
||||||
drawSpan(newestRow, screenRows, screenY, static_cast<float>(screenRows));
|
|
||||||
} else {
|
} else {
|
||||||
// Wraps: [newestRow .. h), then [0 .. remainder)
|
|
||||||
int firstCount = h - newestRow;
|
int firstCount = h - newestRow;
|
||||||
float firstH = static_cast<float>(firstCount);
|
float firstH = firstCount * pxPerRow;
|
||||||
drawSpan(newestRow, firstCount, screenY, firstH);
|
drawSpan(newestRow, firstCount, screenY, firstH);
|
||||||
|
|
||||||
int secondCount = screenRows - firstCount;
|
int secondCount = screenRows - firstCount;
|
||||||
float secondH = static_cast<float>(secondCount);
|
|
||||||
if (secondCount > 0)
|
if (secondCount > 0)
|
||||||
drawSpan(0, secondCount, screenY + firstH, secondH);
|
drawSpan(0, secondCount, screenY + firstH, availH - firstH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Frequency axis labels ──
|
// ── Frequency axis labels ──
|
||||||
@@ -1011,9 +1009,9 @@ void Application::updateAnalyzerSettings() {
|
|||||||
|
|
||||||
// Re-init waterfall texture so the old image from a different FFT
|
// Re-init waterfall texture so the old image from a different FFT
|
||||||
// size doesn't persist.
|
// size doesn't persist.
|
||||||
constexpr int kHistoryRows = 1024;
|
int reinitH = std::max(1024, waterfall_.height());
|
||||||
int binCount2 = std::max(1, analyzer_.spectrumSize());
|
int binCount2 = std::max(1, analyzer_.spectrumSize());
|
||||||
waterfall_.init(binCount2, kHistoryRows);
|
waterfall_.init(binCount2, reinitH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user