From 586548c7d626538af911efc69493074fb3d2ce06 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Thu, 25 Aug 2022 17:34:12 +0200 Subject: [PATCH] change parent-chld relationships of scatter graphs --- lib/jkqtplotter/graphs/jkqtpscatter.cpp | 36 +++++++++++++++++++------ lib/jkqtplotter/graphs/jkqtpscatter.h | 12 ++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/jkqtplotter/graphs/jkqtpscatter.cpp b/lib/jkqtplotter/graphs/jkqtpscatter.cpp index 1fbbac55d0..daff3e53b2 100644 --- a/lib/jkqtplotter/graphs/jkqtpscatter.cpp +++ b/lib/jkqtplotter/graphs/jkqtpscatter.cpp @@ -313,8 +313,9 @@ void JKQTPXYLineErrorGraph::drawErrorsBefore(JKQTPEnhancedPainter &painter) JKQTPXYParametrizedScatterGraph::JKQTPXYParametrizedScatterGraph(JKQTBasePlotter *parent): - JKQTPXYLineGraph(parent), - JKQTPColorPaletteStyleAndToolsMixin(parent) + JKQTPXYGraph(parent), + JKQTPColorPaletteStyleAndToolsMixin(parent), + drawLine(false) { sizeColumn=-1; colorColumn=-1; @@ -748,19 +749,19 @@ void JKQTPXYParametrizedScatterGraph::setSymbolFillDerivationMode(JKQTPColorDeri void JKQTPXYParametrizedScatterGraph::setParent(JKQTBasePlotter *parent) { - JKQTPXYLineGraph::setParent(parent); + JKQTPXYGraph::setParent(parent); cbSetParent(parent); } void JKQTPXYParametrizedScatterGraph::getOutsideSize(JKQTPEnhancedPainter &painter, int &leftSpace, int &rightSpace, int &topSpace, int &bottomSpace) { - JKQTPXYLineGraph::getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); + JKQTPXYGraph::getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); if (showColorBar&& colorColumn>=0 && !colorColumnContainsRGB) cbGetOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); } void JKQTPXYParametrizedScatterGraph::drawOutside(JKQTPEnhancedPainter &painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) { - JKQTPXYLineGraph::drawOutside(painter, leftSpace, rightSpace, topSpace, bottomSpace); + JKQTPXYGraph::drawOutside(painter, leftSpace, rightSpace, topSpace, bottomSpace); if (showColorBar&& colorColumn>=0 && !colorColumnContainsRGB) cbDrawOutside(painter, leftSpace, rightSpace, topSpace, bottomSpace); } @@ -803,7 +804,26 @@ void JKQTPXYParametrizedScatterGraph::cbGetDataMinMax(double &dmin, double &dmax bool JKQTPXYParametrizedScatterGraph::usesColumn(int c) const { - return (c==colorColumn) || (c==sizeColumn) || (c==symbolColumn) || (c==linewidthColumn) || JKQTPXYLineGraph::usesColumn(c); + return (c==colorColumn) || (c==sizeColumn) || (c==symbolColumn) || (c==linewidthColumn) || JKQTPXYGraph::usesColumn(c); +} + +void JKQTPXYParametrizedScatterGraph::setDrawLine(bool __value) +{ + drawLine=__value; +} + +bool JKQTPXYParametrizedScatterGraph::getDrawLine() const +{ + return drawLine; +} + +void JKQTPXYParametrizedScatterGraph::setColor(QColor c) +{ + setLineColor(c); + setSymbolColor(c); + setSymbolFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphsStyle.defaultGraphStyle.fillColorDerivationMode, c)); + c.setAlphaF(0.5); + setHighlightingLineColor(c); } @@ -884,7 +904,7 @@ JKQTPXYParametrizedErrorScatterGraph::JKQTPXYParametrizedErrorScatterGraph(JKQTP bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) { if (xErrorColumn<0 || xErrorStyle==JKQTPNoError) { - return JKQTPXYLineGraph::getXMinMax(minx, maxx, smallestGreaterZero); + return JKQTPXYGraph::getXMinMax(minx, maxx, smallestGreaterZero); } else { bool start=true; minx=0; @@ -922,7 +942,7 @@ bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) { if (yErrorColumn<0 || yErrorStyle==JKQTPNoError) { - return JKQTPXYLineGraph::getYMinMax(miny, maxy, smallestGreaterZero); + return JKQTPXYGraph::getYMinMax(miny, maxy, smallestGreaterZero); } else { bool start=true; miny=0; diff --git a/lib/jkqtplotter/graphs/jkqtpscatter.h b/lib/jkqtplotter/graphs/jkqtpscatter.h index 12f87aff8d..695aed95e9 100644 --- a/lib/jkqtplotter/graphs/jkqtpscatter.h +++ b/lib/jkqtplotter/graphs/jkqtpscatter.h @@ -123,7 +123,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXYLineGraph: public JKQTPXYGraph, public JKQTP \see JKQTPXYParametrizedErrorScatterGraph, \ref JKQTPlotterParamScatter , \ref JKQTPlotterParamScatterImage, \ref JKQTPlotterParametricCurves */ -class JKQTPLOTTER_LIB_EXPORT JKQTPXYParametrizedScatterGraph: public JKQTPXYLineGraph, public JKQTPColorPaletteStyleAndToolsMixin { +class JKQTPLOTTER_LIB_EXPORT JKQTPXYParametrizedScatterGraph: public JKQTPXYGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphSymbolStyleMixin, public JKQTPColorPaletteStyleAndToolsMixin { Q_OBJECT public: /** \brief functor, which converts the value of the symbol column (at a location x,y) into a JKQTPGraphSymbols */ @@ -312,8 +312,18 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXYParametrizedScatterGraph: public JKQTPXYLine virtual void cbGetDataMinMax(double& imin, double& imax) override; /** \copydoc JKQTPGraph::usesColumn() */ virtual bool usesColumn(int c) const override; + /** \copydoc drawLine */ + void setDrawLine(bool __value); + /** \copydoc drawLine */ + bool getDrawLine() const; + + /** \brief set color of line and symbol */ + void setColor(QColor c); protected: + + /** \brief indicates whether to draw a line or not */ + bool drawLine; /** \brief this column contains the symbol size in pt */ int sizeColumn; /** \brief this column contains the symbol color */