Fix #630 improvement on Zoom(s) functions:

- Right-drag now does the same thing on both Spectrum and Waterfall, i.e change and hold vertical scale,
- So Right-drag on Waterfall no longer zoom bandwidth, there are already much more practical ways to do it (up/down, wheel)
- Right-click to reset vertical scale stays only enabled on Spectrum.
- Adapted mouse cursors to reflect the possible moves on Spectrum and Waterfall.
- Updated both Waterfall and Spectrum tooltips to match those features.
This commit is contained in:
vsonnier 2018-03-11 08:14:44 +01:00
parent 7f732735ce
commit 10a4e391d7
3 changed files with 35 additions and 21 deletions

View File

@ -215,6 +215,21 @@ void SpectrumCanvas::updateScaleFactor(float factor) {
wp->setScaleFactor(factor);
}
void SpectrumCanvas::updateScaleFactorFromYMove(float yDeltaMouseMove) {
scaleFactor += yDeltaMouseMove * 2.0;
if (scaleFactor < 0.25) {
scaleFactor = 0.25;
}
if (scaleFactor > 10.0) {
scaleFactor = 10.0;
}
resetScaleFactor = false;
updateScaleFactor(scaleFactor);
}
void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseMoved(event);
if (mouseTracker.mouseDown()) {
@ -226,21 +241,11 @@ void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
}
else if (scaleFactorEnabled && mouseTracker.mouseRightDown()) {
float yDelta = mouseTracker.getDeltaMouseY();
updateScaleFactorFromYMove(mouseTracker.getDeltaMouseY());
scaleFactor += yDelta*2.0;
if (scaleFactor < 0.25) {
scaleFactor = 0.25;
}
if (scaleFactor > 10.0) {
scaleFactor = 10.0;
}
resetScaleFactor = false;
updateScaleFactor(scaleFactor);
} else {
if (scaleFactorEnabled) {
setStatusText("Drag horizontal to adjust center frequency. Right-drag or SHIFT+UP/DOWN to adjust vertical scale; right-click to reset. 'B' to toggle decibels display.");
setStatusText("Drag horizontal to adjust center frequency. Arrow keys or wheel to navigate/zoom bandwith. Right-drag or SHIFT+UP/DOWN to adjust vertical scale, right-click to reset. 'B' to toggle decibels display.");
} else {
setStatusText("Displaying spectrum of active demodulator.");
}
@ -248,9 +253,9 @@ void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
}
void SpectrumCanvas::OnMouseDown(wxMouseEvent& event) {
SetCursor(wxCURSOR_SIZEWE);
mouseTracker.setVertDragLock(true);
InteractiveCanvas::OnMouseDown(event);
SetCursor(wxCURSOR_CROSS);
}
void SpectrumCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
@ -263,12 +268,12 @@ void SpectrumCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
void SpectrumCanvas::OnMouseReleased(wxMouseEvent& event) {
mouseTracker.setVertDragLock(false);
InteractiveCanvas::OnMouseReleased(event);
SetCursor(wxCURSOR_SIZEWE);
SetCursor(wxCURSOR_CROSS);
}
void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
InteractiveCanvas::OnMouseEnterWindow(event);
SetCursor(wxCURSOR_SIZEWE);
SetCursor(wxCURSOR_CROSS);
#ifdef _WIN32
if (wxGetApp().getAppFrame()->canFocus()) {
this->SetFocus();
@ -278,7 +283,7 @@ void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
void SpectrumCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
InteractiveCanvas::OnMouseLeftWindow(event);
SetCursor(wxCURSOR_SIZEWE);
SetCursor(wxCURSOR_CROSS);
}
void SpectrumCanvas::attachWaterfallCanvas(WaterfallCanvas* canvas_in) {
@ -290,15 +295,19 @@ SpectrumVisualDataQueuePtr SpectrumCanvas::getVisualDataQueue() {
}
void SpectrumCanvas::OnMouseRightDown(wxMouseEvent& event) {
SetCursor(wxCURSOR_SIZENS);
mouseTracker.setHorizDragLock(true);
mouseTracker.OnMouseRightDown(event);
scaleFactor = wxGetApp().getSpectrumProcessor()->getScaleFactor();
}
void SpectrumCanvas::OnMouseRightReleased(wxMouseEvent& event) {
SetCursor(wxCURSOR_CROSS);
mouseTracker.setHorizDragLock(false);
if (!mouseTracker.getOriginDeltaMouseY()) {
resetScaleFactor = true;
wxGetApp().getSpectrumProcessor()->setPeakHold(wxGetApp().getSpectrumProcessor()->getPeakHold());
//make the peak hold act on the current dmod also, like a zoomed-in version.
@ -306,6 +315,7 @@ void SpectrumCanvas::OnMouseRightReleased(wxMouseEvent& event) {
wxGetApp().getDemodSpectrumProcessor()->setPeakHold(wxGetApp().getSpectrumProcessor()->getPeakHold());
}
}
mouseTracker.OnMouseRightReleased(event);
}

View File

@ -47,6 +47,9 @@ public:
SpectrumVisualDataQueuePtr getVisualDataQueue();
// called by Waterfall to forward the update of the vertical scale.
void updateScaleFactorFromYMove(float yDeltaMouseMove);
private:
void OnPaint(wxPaintEvent& event);
@ -61,7 +64,6 @@ private:
void OnMouseRightDown(wxMouseEvent& event);
void OnMouseRightReleased(wxMouseEvent& event);
void updateScaleFactor(float factor);
PrimaryGLContext *glContext;

View File

@ -583,7 +583,7 @@ void WaterfallCanvas::updateHoverState() {
}
else {
setStatusText(
"Click to set demodulator frequency or hold ALT to drag range; hold SHIFT to create new. Right drag or wheel to Zoom. Arrow keys to navigate/zoom, C to center. Shift-R record/stop all.");
"Click to set demodulator frequency or hold ALT to drag range; hold SHIFT to create new. Arrow keys or wheel to navigate/zoom bandwith, C to center. Right-drag or SHIFT+UP/DOWN to adjust vertical scale. Shift-R record/stop all.");
}
}
}
@ -637,8 +637,11 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
demod->updateLabel(currentFreq);
}
}
} else if (mouseTracker.mouseRightDown()) {
mouseZoom = mouseZoom + ((1.0 - (mouseTracker.getDeltaMouseY() * 4.0)) - mouseZoom) * 0.1;
} else if (mouseTracker.mouseRightDown() && spectrumCanvas) {
//Right-drag has the same effect on both Waterfall and Spectrum.
spectrumCanvas->updateScaleFactorFromYMove(mouseTracker.getDeltaMouseY());
} else {
updateHoverState();
}
@ -879,7 +882,6 @@ void WaterfallCanvas::OnMouseRightReleased(wxMouseEvent& event) {
SetCursor(wxCURSOR_CROSS);
mouseTracker.setVertDragLock(false);
mouseTracker.setHorizDragLock(false);
mouseZoom = 1.0;
}
SpectrumVisualDataQueuePtr WaterfallCanvas::getVisualDataQueue() {