Skip to content

Commit

Permalink
Couple bug fixes (#147)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Snolandia authored Jan 15, 2025
1 parent b349f07 commit a275fb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/jkqtplotter/jkqtpbaseplotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
9 changes: 7 additions & 2 deletions lib/jkqtplotter/jkqtplotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit a275fb7

Please sign in to comment.