From 696ce115148bf4dcc387e0372e2509f5f9c6b4b2 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Wed, 26 Aug 2020 11:00:25 +0200 Subject: [PATCH] improved code style --- lib/jkqtfastplotter/jkqtfastplotter.cpp | 2 +- lib/jkqtmathtext/jkqtmathtext.cpp | 2 +- .../graphs/jkqtpboxplotstylingmixins.cpp | 2 +- lib/jkqtplotter/graphs/jkqtpgeolines.cpp | 2 +- lib/jkqtplotter/graphs/jkqtpimpulses.cpp | 4 +- .../graphs/jkqtpsinglecolumnsymbols.cpp | 4 +- lib/jkqtplotter/graphs/jkqtpspecialline.cpp | 2 +- lib/jkqtplotter/jkqtpbaseplotter.cpp | 42 ++++++++----- lib/jkqtplotter/jkqtpcoordinateaxes.cpp | 60 ++++++++++++------- 9 files changed, 76 insertions(+), 44 deletions(-) diff --git a/lib/jkqtfastplotter/jkqtfastplotter.cpp b/lib/jkqtfastplotter/jkqtfastplotter.cpp index 9cb3049255..694c8f192d 100644 --- a/lib/jkqtfastplotter/jkqtfastplotter.cpp +++ b/lib/jkqtfastplotter/jkqtfastplotter.cpp @@ -456,7 +456,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) { painter.drawText(QPointF(internalPlotBorderLeft+plotWidth-fmLabels.width(xAxisLabel), internalPlotBorderTop+plotHeight+fmTicks.height()+fmTicks.width("x")/2.0+fmLabels.ascent()+tickLength), xAxisLabel); } if (yAxisLabelVisible) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(fmLabels.ascent(), internalPlotBorderTop+fmLabels.width(yAxisLabel)); painter.rotate(-90); painter.drawText(QPointF(0, 0), yAxisLabel); diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index cfbafa35a8..f3f416fc3f 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -916,7 +916,7 @@ double JKQTMathText::MTfracNode::draw(QPainter& painter, double x, double y, JKQ double ybrace=y-ascent1-bw/2.0; { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(x+xw/2.0+(width1)/2.0, ybrace); painter.rotate(180); QPainterPath path=makeHBracePath(0,0, width, bw); diff --git a/lib/jkqtplotter/graphs/jkqtpboxplotstylingmixins.cpp b/lib/jkqtplotter/graphs/jkqtpboxplotstylingmixins.cpp index cba3d240cf..236da42636 100644 --- a/lib/jkqtplotter/graphs/jkqtpboxplotstylingmixins.cpp +++ b/lib/jkqtplotter/graphs/jkqtpboxplotstylingmixins.cpp @@ -760,7 +760,7 @@ void JKQTPGraphBoxplotStyleMixin::plotVerticalKeyMarker(JKQTBasePlotter *parent, painter.setPen(p); { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintrect=JKQTPFinally([&painter]() {painter.restore();}); painter.setBrush(b); if (getDrawBox()) painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); } diff --git a/lib/jkqtplotter/graphs/jkqtpgeolines.cpp b/lib/jkqtplotter/graphs/jkqtpgeolines.cpp index d3f1967850..4891e611a5 100644 --- a/lib/jkqtplotter/graphs/jkqtpgeolines.cpp +++ b/lib/jkqtplotter/graphs/jkqtpgeolines.cpp @@ -326,7 +326,7 @@ void JKQTPGeoInfiniteLine::draw(JKQTPEnhancedPainter& painter) { addHitTestData(x2, y2); if (two_sided==false && x>=xmin && x<=xmax && y>=ymin && y<=ymax) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpainttwosided=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getLinePen(painter, parent)); painter.setBrush(getLineColor()); QPointF xx1(transformX(x),transformY(y)); diff --git a/lib/jkqtplotter/graphs/jkqtpimpulses.cpp b/lib/jkqtplotter/graphs/jkqtpimpulses.cpp index 9c19a5eccc..5a741336e5 100644 --- a/lib/jkqtplotter/graphs/jkqtpimpulses.cpp +++ b/lib/jkqtplotter/graphs/jkqtpimpulses.cpp @@ -110,7 +110,7 @@ void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { painter.setPen(p); if (lines.size()>0) painter.drawLines(lines); if (drawSymbols && points.size()>0) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();}); for (auto& p: points) { plotStyledSymbol(parent, painter, p.x(), p.y()); } @@ -247,7 +247,7 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) { painter.setPen(p); if (lines.size()>0) painter.drawLines(lines); if (drawSymbols && points.size()>0) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();}); for (auto& p: points) { plotStyledSymbol(parent, painter, p.x(), p.y()); } diff --git a/lib/jkqtplotter/graphs/jkqtpsinglecolumnsymbols.cpp b/lib/jkqtplotter/graphs/jkqtpsinglecolumnsymbols.cpp index a09d71e08a..6f34140287 100644 --- a/lib/jkqtplotter/graphs/jkqtpsinglecolumnsymbols.cpp +++ b/lib/jkqtplotter/graphs/jkqtpsinglecolumnsymbols.cpp @@ -171,7 +171,7 @@ void JKQTPSingleColumnSymbolsGraph::draw(JKQTPEnhancedPainter &painter) if (positionScatterStyle!=RugPlot) { plotStyledSymbol(parent, painter, x, y); } else { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(p); painter.drawLine(QLineF(x, y-symSize,x,y+symSize)); } @@ -203,7 +203,7 @@ void JKQTPSingleColumnSymbolsGraph::draw(JKQTPEnhancedPainter &painter) if (positionScatterStyle!=RugPlot) { plotStyledSymbol(parent, painter, x, y); } else { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(p); painter.drawLine(QLineF(x-symSize, y,x+symSize,y)); } diff --git a/lib/jkqtplotter/graphs/jkqtpspecialline.cpp b/lib/jkqtplotter/graphs/jkqtpspecialline.cpp index e4e5d781ed..516b7656d1 100644 --- a/lib/jkqtplotter/graphs/jkqtpspecialline.cpp +++ b/lib/jkqtplotter/graphs/jkqtpspecialline.cpp @@ -307,7 +307,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { if (m_drawSymbols) { painter.save(); - auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();}); for (auto& p: ps) { plotStyledSymbol(parent, painter, p.x(), p.y()); } diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index 7d322549b2..5043929a05 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -1422,7 +1422,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, { // plot this plotter - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); int t_x=0; int t_y=0; //std::cout<<"printing this ...\n"; @@ -1437,7 +1437,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, // plot all the other plotters for (int i=0; i< gridPrintingList.size(); i++) { //std::cout<<"printing "<(widgetWidth)/paintMagnification>static_cast(rect.width())) || (scale*static_cast(widgetHeight)/paintMagnification>static_cast(rect.height()))) { scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; } - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); // scale the plot so it fits on the page painter.scale(scale, scale); #ifdef JKQTBP_DEBUGTIMING @@ -2461,7 +2461,7 @@ void JKQTBasePlotter::drawNonGridOverlays(JKQTPEnhancedPainter& painter, const Q scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; } { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); // scale the plot so it fits on the page painter.scale(scale, scale); drawOverlaysWithHints(painter); @@ -2480,15 +2480,25 @@ bool JKQTBasePlotter::isEmittingPlotSignalsEnabled() const return this->emitPlotSignals; } -int JKQTBasePlotter::getPlotBorderTop() const { return this->plotterStyle.plotBorderTop; } +int JKQTBasePlotter::getPlotBorderTop() const { + return this->plotterStyle.plotBorderTop; +} -int JKQTBasePlotter::getPlotBorderLeft() const { return this->plotterStyle.plotBorderLeft; } +int JKQTBasePlotter::getPlotBorderLeft() const { + return this->plotterStyle.plotBorderLeft; +} -int JKQTBasePlotter::getPlotBorderBottom() const { return this->plotterStyle.plotBorderBottom; } +int JKQTBasePlotter::getPlotBorderBottom() const { + return this->plotterStyle.plotBorderBottom; +} -int JKQTBasePlotter::getPlotBorderRight() const { return this->plotterStyle.plotBorderRight; } +int JKQTBasePlotter::getPlotBorderRight() const { + return this->plotterStyle.plotBorderRight; +} -bool JKQTBasePlotter::doesMaintainAspectRatio() const { return this->maintainAspectRatio; } +bool JKQTBasePlotter::doesMaintainAspectRatio() const { + return this->maintainAspectRatio; +} void JKQTBasePlotter::setAspectRatio(double __value) { @@ -2503,7 +2513,9 @@ double JKQTBasePlotter::getAspectRatio() const return this->aspectRatio; } -bool JKQTBasePlotter::doesMaintainAxisAspectRatio() const { return this->maintainAxisAspectRatio; } +bool JKQTBasePlotter::doesMaintainAxisAspectRatio() const { + return this->maintainAxisAspectRatio; +} double JKQTBasePlotter::getAxisAspectRatio() const { @@ -4304,7 +4316,7 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d //y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height(); y=y+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); if (plotterStyle.debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); QPen p("orange"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(plotterStyle.debugRegionLineWidth/2.0); @@ -4338,7 +4350,7 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, fs.width(), itheight); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); if (plotterStyle.debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); QPen p("orange"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(plotterStyle.debugRegionLineWidth/2.0); @@ -4386,7 +4398,7 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); if (plotterStyle.debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); QPen p("orange"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(plotterStyle.debugRegionLineWidth/2.0); diff --git a/lib/jkqtplotter/jkqtpcoordinateaxes.cpp b/lib/jkqtplotter/jkqtpcoordinateaxes.cpp index 08b4a8a182..07b83b6232 100644 --- a/lib/jkqtplotter/jkqtpcoordinateaxes.cpp +++ b/lib/jkqtplotter/jkqtpcoordinateaxes.cpp @@ -1515,7 +1515,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { QRectF rect(0,0, getParentPlotWidth(), ascent+descent);//plotBorderLeft-30); - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintiner=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(QPointF(left-parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)-descent-labelMax.width()-labelMax.height(), bottom)); painter.rotate(-90); //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); @@ -1533,7 +1533,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { break; } if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinnerif=JKQTPFinally([&painter]() {painter.restore();}); QPen p("magenta"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); @@ -1555,7 +1555,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { QRectF rect(0,0, getParentPlotWidth(), getParentMathText()->getSize(painter).height());//plotBorderLeft-30); - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(QPointF(right+parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)+labelMax.width(), bottom)); painter.rotate(-90); //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); @@ -1573,7 +1573,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { break; } if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinnerif=JKQTPFinally([&painter]() {painter.restore();}); QPen p("magenta"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); @@ -1588,7 +1588,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintif=JKQTPFinally([&painter]() {painter.restore();}); QPen p("cyan"); p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); @@ -1659,15 +1659,25 @@ void JKQTPVerticalIndependentAxis::setOtherAxisInverted(bool __value) { redrawPlot(); } -double JKQTPVerticalIndependentAxis::getParentPlotWidth() const { return axisWidth; } +double JKQTPVerticalIndependentAxis::getParentPlotWidth() const { + return axisWidth; +} -double JKQTPVerticalIndependentAxis::getParentPlotOffset() const { return axisOffset; } +double JKQTPVerticalIndependentAxis::getParentPlotOffset() const { + return axisOffset; +} -double JKQTPVerticalIndependentAxis::getParentOtheraxisWidth() const { return otherAxisWidth; } +double JKQTPVerticalIndependentAxis::getParentOtheraxisWidth() const { + return otherAxisWidth; +} -bool JKQTPVerticalIndependentAxis::getParentOtheraxisInverted() const { return otherAxisInverted; } +bool JKQTPVerticalIndependentAxis::getParentOtheraxisInverted() const { + return otherAxisInverted; +} -double JKQTPVerticalIndependentAxis::getParentOtheraxisOffset() const { return otherAxisOffset; } +double JKQTPVerticalIndependentAxis::getParentOtheraxisOffset() const { + return otherAxisOffset; +} @@ -2102,7 +2112,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) { QRectF rect(0,0, getParentPlotWidth(), ascent+descent);//plotBorderLeft-30); - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(QPointF(left, bottom+parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)+labelMax.height())); //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); //painter.drawRect(rect); @@ -2119,7 +2129,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) { break; } if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinnerif=JKQTPFinally([&painter]() {painter.restore();}); QPen p("magenta"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); @@ -2141,7 +2151,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) { QRectF rect(0,0, getParentPlotWidth(), getParentMathText()->getSize(painter).height());//plotBorderLeft-30); - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(QPointF(left, top-parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)-labelMax.height()-rect.height())); //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); //painter.drawRect(rect); @@ -2158,7 +2168,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) { break; } if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintinnerif=JKQTPFinally([&painter]() {painter.restore();}); QPen p("magenta"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); @@ -2172,7 +2182,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) { } if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { - painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.save(); auto __finalpaintif=JKQTPFinally([&painter]() {painter.restore();}); QPen p("cyan"); QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth); @@ -2240,14 +2250,24 @@ void JKQTPHorizontalIndependentAxis::setOtherAxisInverted(bool __value) { redrawPlot(); } -double JKQTPHorizontalIndependentAxis::getParentPlotWidth() const { return axisWidth; } +double JKQTPHorizontalIndependentAxis::getParentPlotWidth() const { + return axisWidth; +} -double JKQTPHorizontalIndependentAxis::getParentPlotOffset() const { return axisOffset; } +double JKQTPHorizontalIndependentAxis::getParentPlotOffset() const { + return axisOffset; +} -double JKQTPHorizontalIndependentAxis::getParentOtheraxisWidth() const { return otherAxisWidth; } +double JKQTPHorizontalIndependentAxis::getParentOtheraxisWidth() const { + return otherAxisWidth; +} -bool JKQTPHorizontalIndependentAxis::getParentOtheraxisInverted() const { return otherAxisInverted; } +bool JKQTPHorizontalIndependentAxis::getParentOtheraxisInverted() const { + return otherAxisInverted; +} -double JKQTPHorizontalIndependentAxis::getParentOtheraxisOffset() const { return otherAxisOffset; } +double JKQTPHorizontalIndependentAxis::getParentOtheraxisOffset() const { + return otherAxisOffset; +}