From a275fb73c3489bd0768a3669518c256c14cb4cdb Mon Sep 17 00:00:00 2001 From: Snolandia <64045395+Snolandia@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:21:39 -0800 Subject: [PATCH] Couple bug fixes (#147) * BugFix * Resolve several issues 1: Allow mouse scroll events to pass through to parent if the plot has not mouse scroll events to do. i.e. if scroll to zoom is disabled, and the graph is part of a scroll area, this allows scrolling the scroll area while the mouse is over the plot. 2: Fixed bug with resize timer resetting itself every time, rather than actually performing the countdown and calling the function. 3. Fixed bug with margins being calculated incorrectly, preventing the complete removal of margins from a plot. --- lib/jkqtplotter/jkqtpbaseplotter.cpp | 8 ++++---- lib/jkqtplotter/jkqtplotter.cpp | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index 63c95fc29d..a3d849bafc 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -916,20 +916,20 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ auto s=xAxis->getSize1(painter); internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s.requiredSize; if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin); - if (s.elongateMax>0) elongateRight=qMax(elongateRight,s.elongateMax); + if (s.elongateMax>0) elongateRight=qMin(elongateRight,s.elongateMax); s=xAxis->getSize2(painter); if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin); - if (s.elongateMax>0) elongateRight=qMax(elongateRight,s.elongateMax); + if (s.elongateMax>0) elongateRight=qMin(elongateRight,s.elongateMax); internalPlotMargins[PlotMarginUse::muAxesOutside].top+=s.requiredSize; double elongateBottom=0,elongateTop=0; s=yAxis->getSize1(painter); if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin); - if (s.elongateMax>0) elongateTop=qMax(elongateTop,s.elongateMax); + if (s.elongateMax>0) elongateTop=qMin(elongateTop,s.elongateMax); internalPlotMargins[PlotMarginUse::muAxesOutside].left+=s.requiredSize; s=yAxis->getSize2(painter); if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin); - if (s.elongateMax>0) elongateTop=qMax(elongateTop,s.elongateMax); + if (s.elongateMax>0) elongateTop=qMin(elongateTop,s.elongateMax); internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s.requiredSize; diff --git a/lib/jkqtplotter/jkqtplotter.cpp b/lib/jkqtplotter/jkqtplotter.cpp index 20573adc97..78dfbd1b35 100644 --- a/lib/jkqtplotter/jkqtplotter.cpp +++ b/lib/jkqtplotter/jkqtplotter.cpp @@ -1140,6 +1140,9 @@ void JKQTPlotter::wheelEvent ( QWheelEvent * event ) { if (d.y()>=1 && d.y()<10) d.setY(10); if (d.y()<=-1 && d.y()>-10) d.setY(-10); } + }else{ + event->ignore(); + return; } @@ -1413,8 +1416,10 @@ void JKQTPlotter::resizeEvent(QResizeEvent *event) { // Do this now delayedResizeEvent(); } else { - resizeTimer.setSingleShot(true); - resizeTimer.start(jkqtp_RESIZE_DELAY); + if(!resizeTimer.isActive()){ + resizeTimer.setSingleShot(true); + resizeTimer.start(jkqtp_RESIZE_DELAY); + } } }