From 34fa59ebf493cb52929eb6b477b2a4dbb111dc2e Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sat, 19 Sep 2020 14:55:46 +0200 Subject: [PATCH] using new JKQTPGraphLineAndFillStyleMixin where appropriate --- .../graphs/jkqtpevaluatedfunction.cpp | 35 +- .../graphs/jkqtpevaluatedfunction.h | 13 +- lib/jkqtplotter/graphs/jkqtpfilledcurve.cpp | 18 +- lib/jkqtplotter/graphs/jkqtpspecialline.cpp | 545 +++++++++--------- lib/jkqtplotter/graphs/jkqtpspecialline.h | 16 +- .../jkqtpgraphsbasestylingmixins.cpp | 17 +- .../jkqtpgraphsbasestylingmixins.h | 12 + 7 files changed, 315 insertions(+), 341 deletions(-) diff --git a/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp b/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp index d8a75f10df..a8175101c6 100644 --- a/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp +++ b/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp @@ -33,13 +33,12 @@ JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase(JKQTBasePlotter* parent): JKQTPEvaluatedFunctionWithErrorsGraphBase(parent), - drawLine(true), - fillCurve(false), drawErrorPolygons(false), drawErrorLines(false) { initLineStyle(parent, parentPlotStyle); initFillStyle(parent, parentPlotStyle); + setFillCurve(false); errorColor=getLineColor().lighter(); errorFillColor=getLineColor().lighter(); @@ -71,16 +70,6 @@ JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::~JKQTPEvaluatedFunctionWithErr } -void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::setDrawLine(bool __value) -{ - this->drawLine = __value; -} - -bool JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::getDrawLine() const -{ - return this->drawLine; -} - void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=getLinePen(painter, parent); @@ -90,10 +79,10 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhanc QBrush b=getFillBrush(painter, parent); const double y=rect.top()+rect.height()/2.0; painter.setPen(np); - if (drawLine) painter.setPen(p); + if (getDrawLine()) painter.setPen(p); painter.setBrush(b); - if (fillCurve) painter.drawRect(rect); - if (!fillCurve && drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); + if (getFillCurve()) painter.drawRect(rect); + if (!getFillCurve() && getDrawLine()) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); } @@ -262,7 +251,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawXGraph(JKQTPEnhancedP y=qBound(yami, y, yama); - if (fillCurve) { + if (getFillCurve()) { if (!first) filledPolygon<m_drawLine = __value; -} - -bool JKQTPSpecialLineHorizontalGraph::getDrawLine() const -{ - return this->m_drawLine; -} - void JKQTPSpecialLineHorizontalGraph::setDrawSymbols(bool __value) { m_drawSymbols=__value; @@ -99,15 +88,6 @@ bool JKQTPSpecialLineHorizontalGraph::getDrawSymbols() const return m_drawSymbols; } -void JKQTPSpecialLineHorizontalGraph::setFillCurve(bool __value) -{ - this->m_fillCurve = __value; -} - -bool JKQTPSpecialLineHorizontalGraph::getFillCurve() const -{ - return this->m_fillCurve; -} void JKQTPSpecialLineHorizontalGraph::setSpecialLineType(const JKQTPSpecialLineType &__value) { @@ -155,164 +135,159 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { QPen np(Qt::NoPen); QBrush b=getFillBrush(painter, parent); - int imax=static_cast(qMin(datastore->getRows(static_cast(xColumn)), datastore->getRows(static_cast(yColumn)))); + int imax=0; int imin=0; - if (imax ps; - double xold=-1; - double yold=-1; -// double xstart=-1; -// double ystart=-1; - //double x0=transformX(0); - //if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); - double y0=transformY(m_baseline); - if (parent->getYAxis()->isLogAxis()) { - y0=transformY(parent->getYAxis()->getMin()); - if (m_baseline>0 && m_baseline>parent->getYAxis()->getMin()) y0=transformY(m_baseline); - else y0=transformY(parent->getYAxis()->getMin()); - } - bool subsequentItem=false; - intSortData(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - //std::cout<<"(xv, yv) = ( "< ps; - if (m_specialLineType==JKQTPStepCenter) { - // x/y - // |--------* - // | - // *--------| - // xold/yold - const double d=(x-xold); - pf.lineTo(xold+d/2.0, yold); - pf.lineTo(xold+d/2.0, y); + double xold=-1; + double yold=-1; + // double xstart=-1; + // double ystart=-1; + //double x0=transformX(0); + //if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); + double y0=transformY(m_baseline); + if (parent->getYAxis()->isLogAxis()) { + y0=transformY(parent->getYAxis()->getMin()); + if (m_baseline>0 && m_baseline>parent->getYAxis()->getMin()) y0=transformY(m_baseline); + else y0=transformY(parent->getYAxis()->getMin()); + } + bool subsequentItem=false; + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + const double yv=datastore->get(static_cast(yColumn),static_cast(i)); + //std::cout<<"(xv, yv) = ( "<(qMin(datastore->getRows(static_cast(xColumn)), datastore->getRows(static_cast(yColumn)))); + int imax=0; int imin=0; - if (imax ps; - double xold=-1; - double yold=-1; - double x0=transformX(m_baseline); - if (parent->getXAxis()->isLogAxis()) { - if (m_baseline>0 && m_baseline>parent->getXAxis()->getMin()) x0=transformX(m_baseline); - else x0=transformX(parent->getXAxis()->getMin()); - } - bool first=false; - intSortData(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - //std::cout<<"(xv, yv) = ( "< ps; - if (m_specialLineType==JKQTPStepCenter) { - double d=(y-yold); - pf.lineTo(xold, yold+d/2.0); - pf.lineTo(x, yold+d/2.0); + double xold=-1; + double yold=-1; + double x0=transformX(m_baseline); + if (parent->getXAxis()->isLogAxis()) { + if (m_baseline>0 && m_baseline>parent->getXAxis()->getMin()) x0=transformX(m_baseline); + else x0=transformX(parent->getXAxis()->getMin()); + } + bool first=false; + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + const double yv=datastore->get(static_cast(yColumn),static_cast(i)); + //std::cout<<"(xv, yv) = ( "<