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.
This commit is contained in:
Snolandia 2025-01-15 12:21:39 -08:00 committed by GitHub
parent b349f07118
commit a275fb73c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -916,20 +916,20 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
auto s=xAxis->getSize1(painter); auto s=xAxis->getSize1(painter);
internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s.requiredSize; internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s.requiredSize;
if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin); 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); s=xAxis->getSize2(painter);
if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin); 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; internalPlotMargins[PlotMarginUse::muAxesOutside].top+=s.requiredSize;
double elongateBottom=0,elongateTop=0; double elongateBottom=0,elongateTop=0;
s=yAxis->getSize1(painter); s=yAxis->getSize1(painter);
if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin); 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; internalPlotMargins[PlotMarginUse::muAxesOutside].left+=s.requiredSize;
s=yAxis->getSize2(painter); s=yAxis->getSize2(painter);
if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin); 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; internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s.requiredSize;

View File

@ -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);
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,10 +1416,12 @@ void JKQTPlotter::resizeEvent(QResizeEvent *event) {
// Do this now // Do this now
delayedResizeEvent(); delayedResizeEvent();
} else { } else {
if(!resizeTimer.isActive()){
resizeTimer.setSingleShot(true); resizeTimer.setSingleShot(true);
resizeTimer.start(jkqtp_RESIZE_DELAY); resizeTimer.start(jkqtp_RESIZE_DELAY);
} }
} }
}
//updateGeometry(); //updateGeometry();
//qDebug()<<"resize DONE width()="<<width()<<" height()="<<height()<<" plotImageWidth="<<plotImageWidth<<" plotImageHeight="<<plotImageHeight<<" sizeChanged="<<sizeChanged<<"\n"; //qDebug()<<"resize DONE width()="<<width()<<" height()="<<height()<<" plotImageWidth="<<plotImageWidth<<" plotImageHeight="<<plotImageHeight<<" sizeChanged="<<sizeChanged<<"\n";