Skip to content

Commit

Permalink
Merge pull request #1250 from LevitatingBusinessMan/ctrl-zoom
Browse files Browse the repository at this point in the history
Zoom the plotter faster with Ctrl
  • Loading branch information
argilo authored Oct 9, 2023
2 parents 154bbe6 + 896d3df commit 5517fb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions resources/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

NEW: Delete key clears the waterfall.
NEW: I/Q tool can save recordings in SigMF format.
NEW: Holding Ctrl speeds up mouse wheel zoom.
IMPROVED: Reduced CPU utilization of waterfall display.
CHANGED: DMG release requires macOS 12.7 or later.

Expand Down
6 changes: 4 additions & 2 deletions src/qtgui/plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,14 @@ void CPlotter::wheelEvent(QWheelEvent * event)
// delta is in eigths of a degree, 15 degrees is one step
int delta = m_InvertScrolling? -event->angleDelta().y() : event->angleDelta().y();
double numSteps = delta / (8.0 * 15.0);
// zoom faster when Ctrl is held
double zoomBase = (event->modifiers() & Qt::ControlModifier) ? 0.7 : 0.9;

if (m_CursorCaptured == YAXIS)
{
// Vertical zoom. Wheel down: zoom out, wheel up: zoom in
// During zoom we try to keep the point (dB or kHz) under the cursor fixed
float zoom_fac = pow(0.9, numSteps);
float zoom_fac = pow(zoomBase, numSteps);
float ratio = (float) py / (float) h;
float db_range = m_PandMaxdB - m_PandMindB;
float y_range = (float) h;
Expand All @@ -957,7 +959,7 @@ void CPlotter::wheelEvent(QWheelEvent * event)
}
else if (m_CursorCaptured == XAXIS)
{
zoomStepX(pow(0.9, numSteps), px);
zoomStepX(pow(zoomBase, numSteps), px);
}
else if (event->modifiers() & Qt::ControlModifier)
{
Expand Down

0 comments on commit 5517fb3

Please sign in to comment.