VFOs are now visible in waterfall

This commit is contained in:
Ryzerth 2021-02-09 02:11:40 +01:00
parent 35d079beb1
commit 9e410e3856
2 changed files with 26 additions and 7 deletions

View File

@ -181,8 +181,19 @@ namespace ImGui {
waterfallUpdate = false; waterfallUpdate = false;
updateWaterfallTexture(); updateWaterfallTexture();
} }
window->DrawList->AddImage((void*)(intptr_t)textureId, ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 51), window->DrawList->AddImage((void*)(intptr_t)textureId, wfMin, wfMax);
ImVec2(widgetPos.x + 50 + dataWidth, widgetPos.y + fftHeight + 51 + waterfallHeight)); ImVec2 mPos = ImGui::GetMousePos();
if (IS_IN_AREA(mPos, wfMin, wfMax)) {
for (auto const& [name, vfo] : vfos) {
ImVec2 nVfoRectMin(vfo->rectMin.x, wfMin.y);
ImVec2 nVfoRectMax(vfo->rectMax.x, wfMax.y);
ImVec2 nVfoLineMin(vfo->lineMin.x, wfMin.y);
ImVec2 nVfoLineMax(vfo->lineMin.x, wfMax.y);
window->DrawList->AddRectFilled(nVfoRectMin, nVfoRectMax, IM_COL32(255, 255, 255, 50));
window->DrawList->AddLine(nVfoLineMin, nVfoLineMax, (name == selectedVFO) ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255));
}
}
} }
void WaterFall::drawVFOs() { void WaterFall::drawVFOs() {
@ -219,10 +230,14 @@ namespace ImGui {
bool mouseHovered, mouseHeld; bool mouseHovered, mouseHeld;
bool mouseClicked = ImGui::ButtonBehavior(ImRect(fftAreaMin, fftAreaMax), GetID("WaterfallID"), &mouseHovered, &mouseHeld, bool mouseClicked = ImGui::ButtonBehavior(ImRect(fftAreaMin, fftAreaMax), GetID("WaterfallID"), &mouseHovered, &mouseHeld,
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick); ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick);
mouseClicked |= ImGui::ButtonBehavior(ImRect(wfMin, wfMax), GetID("WaterfallID2"), &mouseHovered, &mouseHeld,
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick);
bool draging = ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowFocused(); bool draging = ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowFocused();
bool mouseInFreq = IS_IN_AREA(dragOrigin, freqAreaMin, freqAreaMax); bool mouseInFreq = IS_IN_AREA(dragOrigin, freqAreaMin, freqAreaMax);
bool mouseInFFT = IS_IN_AREA(dragOrigin, fftAreaMin, fftAreaMax); bool mouseInFFT = IS_IN_AREA(dragOrigin, fftAreaMin, fftAreaMax);
bool mouseInWaterfall = IS_IN_AREA(dragOrigin, wfMin, wfMax);
// If mouse was clicked on a VFO, select VFO and return // If mouse was clicked on a VFO, select VFO and return
@ -232,7 +247,9 @@ namespace ImGui {
if (name == selectedVFO) { if (name == selectedVFO) {
continue; continue;
} }
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax)) { ImVec2 nVfoRectMin(_vfo->rectMin.x, wfMin.y);
ImVec2 nVfoRectMax(_vfo->rectMax.x, wfMax.y);
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, nVfoRectMin, nVfoRectMax)) {
selectedVFO = name; selectedVFO = name;
selectedVFOChanged = true; selectedVFOChanged = true;
return; return;
@ -240,7 +257,7 @@ namespace ImGui {
} }
if (vfo != NULL) { if (vfo != NULL) {
int refCenter = mousePos.x - (widgetPos.x + 50); int refCenter = mousePos.x - (widgetPos.x + 50);
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) { if (refCenter >= 0 && refCenter < dataWidth /* && ( (mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) || (IS_IN_AREA(mousePos, nVfoRectMin, nVfoRectMax)) ) */ ) {
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset; double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
off += centerFreq; off += centerFreq;
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq; off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
@ -250,7 +267,7 @@ namespace ImGui {
} }
// Draging VFO // Draging VFO
if (draging && mouseInFFT) { if (draging && (mouseInFFT || mouseInWaterfall)) {
int refCenter = mousePos.x - (widgetPos.x + 50); int refCenter = mousePos.x - (widgetPos.x + 50);
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y) && vfo != NULL) { if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y) && vfo != NULL) {
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset; double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
@ -450,6 +467,8 @@ namespace ImGui {
fftAreaMax = ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10); fftAreaMax = ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10);
freqAreaMin = ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 11); freqAreaMin = ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 11);
freqAreaMax = ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 50); freqAreaMax = ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 50);
wfMin = ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 51);
wfMax = ImVec2(widgetPos.x + 50 + dataWidth, widgetPos.y + fftHeight + 51 + waterfallHeight);
maxHSteps = dataWidth / (ImGui::CalcTextSize("000.000").x + 10); maxHSteps = dataWidth / (ImGui::CalcTextSize("000.000").x + 10);
maxVSteps = fftHeight / (ImGui::CalcTextSize("000.000").y); maxVSteps = fftHeight / (ImGui::CalcTextSize("000.000").y);

View File

@ -145,8 +145,8 @@ namespace ImGui {
ImVec2 fftAreaMax; ImVec2 fftAreaMax;
ImVec2 freqAreaMin; ImVec2 freqAreaMin;
ImVec2 freqAreaMax; ImVec2 freqAreaMax;
ImVec2 waterfallAreaMin; ImVec2 wfMin;
ImVec2 waterfallAreaMax; ImVec2 wfMax;
ImGuiWindow* window; ImGuiWindow* window;