"Fossies" - the Fresh Open Source Software Archive

Member "labplot-2.8.2/src/backend/worksheet/plots/cartesian/XYCurve.h" (24 Feb 2021, 12506 Bytes) of package /linux/privat/labplot-2.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "XYCurve.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.8.1_vs_2.8.2.

    1 /***************************************************************************
    2     File                 : XYCurve.h
    3     Project              : LabPlot
    4     Description          : A xy-curve
    5     --------------------------------------------------------------------
    6     Copyright            : (C) 2010-2020 Alexander Semke (alexander.semke@web.de)
    7     Copyright            : (C) 2013 Stefan Gerlach (stefan.gerlach@uni.kn)
    8 
    9  ***************************************************************************/
   10 
   11 /***************************************************************************
   12  *                                                                         *
   13  *  This program is free software; you can redistribute it and/or modify   *
   14  *  it under the terms of the GNU General Public License as published by   *
   15  *  the Free Software Foundation; either version 2 of the License, or      *
   16  *  (at your option) any later version.                                    *
   17  *                                                                         *
   18  *  This program is distributed in the hope that it will be useful,        *
   19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
   20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
   21  *  GNU General Public License for more details.                           *
   22  *                                                                         *
   23  *   You should have received a copy of the GNU General Public License     *
   24  *   along with this program; if not, write to the Free Software           *
   25  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
   26  *   Boston, MA  02110-1301  USA                                           *
   27  *                                                                         *
   28  ***************************************************************************/
   29 
   30 #ifndef XYCURVE_H
   31 #define XYCURVE_H
   32 
   33 #include "backend/worksheet/WorksheetElement.h"
   34 #include "backend/worksheet/plots/cartesian/Curve.h"
   35 #include "backend/worksheet/plots/cartesian/Symbol.h"
   36 #include "backend/worksheet/plots/PlotArea.h"
   37 #include "backend/lib/macros.h"
   38 #include "backend/lib/macrosXYCurve.h"
   39 #include "backend/core/AbstractColumn.h"
   40 
   41 #include <QFont>
   42 #include <QPen>
   43 
   44 class XYCurvePrivate;
   45 
   46 class XYCurve: public WorksheetElement, public Curve {
   47     Q_OBJECT
   48 
   49 public:
   50     friend class XYCurveSetXColumnCmd;
   51     friend class XYCurveSetYColumnCmd;
   52     friend class XYCurveSetXErrorPlusColumnCmd;
   53     friend class XYCurveSetXErrorMinusColumnCmd;
   54     friend class XYCurveSetYErrorPlusColumnCmd;
   55     friend class XYCurveSetYErrorMinusColumnCmd;
   56     friend class XYCurveSetValuesColumnCmd;
   57     enum class LineType {NoLine, Line, StartHorizontal, StartVertical, MidpointHorizontal, MidpointVertical, Segments2, Segments3,
   58                    SplineCubicNatural, SplineCubicPeriodic, SplineAkimaNatural, SplineAkimaPeriodic
   59                   };
   60     enum class DropLineType {NoDropLine, X, Y, XY, XZeroBaseline, XMinBaseline, XMaxBaseline};
   61     enum class ValuesType {NoValues, X, Y, XY, XYBracketed, CustomColumn};
   62     enum class ValuesPosition {Above, Under, Left, Right};
   63     enum class ErrorType {NoError, Symmetric, Asymmetric};
   64     enum class FillingPosition {NoFilling, Above, Below, ZeroBaseline, Left, Right};
   65     enum class ErrorBarsType {Simple, WithEnds};
   66 
   67     explicit XYCurve(const QString &name, AspectType type = AspectType::XYCurve);
   68     ~XYCurve() override;
   69 
   70     void finalizeAdd() override;
   71     QIcon icon() const override;
   72     QMenu* createContextMenu() override;
   73     QGraphicsItem* graphicsItem() const override;
   74     void save(QXmlStreamWriter*) const override;
   75     bool load(XmlStreamReader*, bool preview) override;
   76     void loadThemeConfig(const KConfig&) override;
   77     void saveThemeConfig(const KConfig&) override;
   78     double y(double x, bool &valueFound) const;
   79     QDateTime yDateTime(double x, bool &valueFound) const;
   80     bool minMax(const AbstractColumn *column1, const AbstractColumn *column2, const ErrorType errorType, const AbstractColumn *errorPlusColumn, const AbstractColumn *errorMinusColumn, int indexMin, int indexMax, double& yMin, double& yMax, bool includeErrorBars) const;
   81     bool minMaxX(int indexMin, int indexMax, double& yMin, double& yMax, bool includeErrorBars = true) const;
   82     bool minMaxY(int indexMin, int indexMax, double& yMin, double& yMax, bool includeErrorBars = true) const;
   83 
   84     bool activateCurve(QPointF mouseScenePos, double maxDist = -1) override;
   85     void setHover(bool on) override;
   86 
   87     POINTER_D_ACCESSOR_DECL(const AbstractColumn, xColumn, XColumn)
   88     POINTER_D_ACCESSOR_DECL(const AbstractColumn, yColumn, YColumn)
   89     CLASS_D_ACCESSOR_DECL(QString, xColumnPath, XColumnPath)
   90     CLASS_D_ACCESSOR_DECL(QString, yColumnPath, YColumnPath)
   91 
   92     BASIC_D_ACCESSOR_DECL(LineType, lineType, LineType)
   93     BASIC_D_ACCESSOR_DECL(bool, lineSkipGaps, LineSkipGaps)
   94     BASIC_D_ACCESSOR_DECL(bool, lineIncreasingXOnly, LineIncreasingXOnly)
   95     BASIC_D_ACCESSOR_DECL(int, lineInterpolationPointsCount, LineInterpolationPointsCount)
   96     CLASS_D_ACCESSOR_DECL(QPen, linePen, LinePen)
   97     BASIC_D_ACCESSOR_DECL(qreal, lineOpacity, LineOpacity)
   98 
   99     BASIC_D_ACCESSOR_DECL(DropLineType, dropLineType, DropLineType)
  100     CLASS_D_ACCESSOR_DECL(QPen, dropLinePen, DropLinePen)
  101     BASIC_D_ACCESSOR_DECL(qreal, dropLineOpacity, DropLineOpacity)
  102 
  103     BASIC_D_ACCESSOR_DECL(Symbol::Style, symbolsStyle, SymbolsStyle)
  104     BASIC_D_ACCESSOR_DECL(qreal, symbolsOpacity, SymbolsOpacity)
  105     BASIC_D_ACCESSOR_DECL(qreal, symbolsRotationAngle, SymbolsRotationAngle)
  106     BASIC_D_ACCESSOR_DECL(qreal, symbolsSize, SymbolsSize)
  107     CLASS_D_ACCESSOR_DECL(QBrush, symbolsBrush, SymbolsBrush)
  108     CLASS_D_ACCESSOR_DECL(QPen, symbolsPen, SymbolsPen)
  109 
  110     BASIC_D_ACCESSOR_DECL(ValuesType, valuesType, ValuesType)
  111     POINTER_D_ACCESSOR_DECL(const AbstractColumn, valuesColumn, ValuesColumn)
  112     CLASS_D_ACCESSOR_DECL(QString, valuesColumnPath, ValuesColumnPath)
  113     BASIC_D_ACCESSOR_DECL(ValuesPosition, valuesPosition, ValuesPosition)
  114     BASIC_D_ACCESSOR_DECL(qreal, valuesDistance, ValuesDistance)
  115     BASIC_D_ACCESSOR_DECL(qreal, valuesRotationAngle, ValuesRotationAngle)
  116     BASIC_D_ACCESSOR_DECL(qreal, valuesOpacity, ValuesOpacity)
  117     BASIC_D_ACCESSOR_DECL(char, valuesNumericFormat, ValuesNumericFormat)
  118     BASIC_D_ACCESSOR_DECL(int, valuesPrecision, ValuesPrecision)
  119     CLASS_D_ACCESSOR_DECL(QString, valuesDateTimeFormat, ValuesDateTimeFormat)
  120     CLASS_D_ACCESSOR_DECL(QString, valuesPrefix, ValuesPrefix)
  121     CLASS_D_ACCESSOR_DECL(QString, valuesSuffix, ValuesSuffix)
  122     CLASS_D_ACCESSOR_DECL(QColor, valuesColor, ValuesColor)
  123     CLASS_D_ACCESSOR_DECL(QFont, valuesFont, ValuesFont)
  124 
  125     BASIC_D_ACCESSOR_DECL(FillingPosition, fillingPosition, FillingPosition)
  126     BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundType, fillingType, FillingType)
  127     BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundColorStyle, fillingColorStyle, FillingColorStyle)
  128     BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundImageStyle, fillingImageStyle, FillingImageStyle)
  129     BASIC_D_ACCESSOR_DECL(Qt::BrushStyle, fillingBrushStyle, FillingBrushStyle)
  130     CLASS_D_ACCESSOR_DECL(QColor, fillingFirstColor, FillingFirstColor)
  131     CLASS_D_ACCESSOR_DECL(QColor, fillingSecondColor, FillingSecondColor)
  132     CLASS_D_ACCESSOR_DECL(QString, fillingFileName, FillingFileName)
  133     BASIC_D_ACCESSOR_DECL(qreal, fillingOpacity, FillingOpacity)
  134 
  135     BASIC_D_ACCESSOR_DECL(ErrorType, xErrorType, XErrorType)
  136     POINTER_D_ACCESSOR_DECL(const AbstractColumn, xErrorPlusColumn, XErrorPlusColumn)
  137     POINTER_D_ACCESSOR_DECL(const AbstractColumn, xErrorMinusColumn, XErrorMinusColumn)
  138     BASIC_D_ACCESSOR_DECL(ErrorType, yErrorType, YErrorType)
  139     POINTER_D_ACCESSOR_DECL(const AbstractColumn, yErrorPlusColumn, YErrorPlusColumn)
  140     POINTER_D_ACCESSOR_DECL(const AbstractColumn, yErrorMinusColumn, YErrorMinusColumn)
  141     CLASS_D_ACCESSOR_DECL(QString, xErrorPlusColumnPath, XErrorPlusColumnPath)
  142     CLASS_D_ACCESSOR_DECL(QString, xErrorMinusColumnPath, XErrorMinusColumnPath)
  143     CLASS_D_ACCESSOR_DECL(QString, yErrorPlusColumnPath, YErrorPlusColumnPath)
  144     CLASS_D_ACCESSOR_DECL(QString, yErrorMinusColumnPath, YErrorMinusColumnPath)
  145 
  146     BASIC_D_ACCESSOR_DECL(ErrorBarsType, errorBarsType, ErrorBarsType)
  147     BASIC_D_ACCESSOR_DECL(qreal, errorBarsCapSize, ErrorBarsCapSize)
  148     CLASS_D_ACCESSOR_DECL(QPen, errorBarsPen, ErrorBarsPen)
  149     BASIC_D_ACCESSOR_DECL(qreal, errorBarsOpacity, ErrorBarsOpacity)
  150 
  151     void setVisible(bool on) override;
  152     bool isVisible() const override;
  153     void setPrinting(bool on) override;
  154     void suppressRetransform(bool);
  155     bool isSourceDataChangedSinceLastRecalc() const;
  156 
  157     typedef XYCurvePrivate Private;
  158 
  159     void retransform() override;
  160     void recalcLogicalPoints();
  161     void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
  162 
  163 private slots:
  164     void updateValues();
  165     void updateErrorBars();
  166     void xColumnAboutToBeRemoved(const AbstractAspect*);
  167     void yColumnAboutToBeRemoved(const AbstractAspect*);
  168     void valuesColumnAboutToBeRemoved(const AbstractAspect*);
  169     void xErrorPlusColumnAboutToBeRemoved(const AbstractAspect*);
  170     void xErrorMinusColumnAboutToBeRemoved(const AbstractAspect*);
  171     void yErrorPlusColumnAboutToBeRemoved(const AbstractAspect*);
  172     void yErrorMinusColumnAboutToBeRemoved(const AbstractAspect*);
  173     void xColumnNameChanged();
  174     void yColumnNameChanged();
  175     void xErrorPlusColumnNameChanged();
  176     void xErrorMinusColumnNameChanged();
  177     void yErrorPlusColumnNameChanged();
  178     void yErrorMinusColumnNameChanged();
  179     void valuesColumnNameChanged();
  180     //SLOTs for changes triggered via QActions in the context menu
  181     void visibilityChanged();
  182     void navigateTo();
  183 
  184 protected:
  185     XYCurve(const QString& name, XYCurvePrivate* dd, AspectType type);
  186     XYCurvePrivate* const d_ptr;
  187 
  188 private:
  189     Q_DECLARE_PRIVATE(XYCurve)
  190     void init();
  191     void initActions();
  192     XYCURVE_COLUMN_CONNECT(x)
  193     XYCURVE_COLUMN_CONNECT(y)
  194     XYCURVE_COLUMN_CONNECT(xErrorPlus)
  195     XYCURVE_COLUMN_CONNECT(xErrorMinus)
  196     XYCURVE_COLUMN_CONNECT(yErrorPlus)
  197     XYCURVE_COLUMN_CONNECT(yErrorMinus)
  198     XYCURVE_COLUMN_CONNECT(values)
  199 
  200     QAction* visibilityAction{nullptr};
  201     QAction* navigateToAction{nullptr};
  202     bool m_menusInitialized{false};
  203 
  204 signals:
  205     //General-Tab
  206     void dataChanged(); //emitted when the actual curve data to be plotted was changed to re-adjust the plot
  207     void xDataChanged();
  208     void yDataChanged();
  209     void xErrorPlusDataChanged();
  210     void xErrorMinusDataChanged();
  211     void yErrorPlusDataChanged();
  212     void yErrorMinusDataChanged();
  213     void valuesDataChanged();
  214     void visibilityChanged(bool);
  215 
  216     void xColumnChanged(const AbstractColumn*);
  217     void yColumnChanged(const AbstractColumn*);
  218 
  219     //Line-Tab
  220     void lineTypeChanged(XYCurve::LineType);
  221     void lineSkipGapsChanged(bool);
  222     void lineIncreasingXOnlyChanged(bool);
  223     void lineInterpolationPointsCountChanged(int);
  224     void linePenChanged(const QPen&);
  225     void lineOpacityChanged(qreal);
  226     void dropLineTypeChanged(XYCurve::DropLineType);
  227     void dropLinePenChanged(const QPen&);
  228     void dropLineOpacityChanged(qreal);
  229 
  230     //Symbol-Tab
  231     void symbolsStyleChanged(Symbol::Style);
  232     void symbolsSizeChanged(qreal);
  233     void symbolsRotationAngleChanged(qreal);
  234     void symbolsOpacityChanged(qreal);
  235     void symbolsBrushChanged(QBrush);
  236     void symbolsPenChanged(const QPen&);
  237 
  238     //Values-Tab
  239     void valuesTypeChanged(XYCurve::ValuesType);
  240     void valuesColumnChanged(const AbstractColumn*);
  241     void valuesPositionChanged(XYCurve::ValuesPosition);
  242     void valuesDistanceChanged(qreal);
  243     void valuesRotationAngleChanged(qreal);
  244     void valuesOpacityChanged(qreal);
  245     void valuesNumericFormatChanged(char);
  246     void valuesPrecisionChanged(int);
  247     void valuesDateTimeFormatChanged(QString);
  248     void valuesPrefixChanged(QString);
  249     void valuesSuffixChanged(QString);
  250     void valuesFontChanged(QFont);
  251     void valuesColorChanged(QColor);
  252 
  253     //Filling
  254     void fillingPositionChanged(XYCurve::FillingPosition);
  255     void fillingTypeChanged(PlotArea::BackgroundType);
  256     void fillingColorStyleChanged(PlotArea::BackgroundColorStyle);
  257     void fillingImageStyleChanged(PlotArea::BackgroundImageStyle);
  258     void fillingBrushStyleChanged(Qt::BrushStyle);
  259     void fillingFirstColorChanged(QColor&);
  260     void fillingSecondColorChanged(QColor&);
  261     void fillingFileNameChanged(QString&);
  262     void fillingOpacityChanged(float);
  263 
  264     //Error bars
  265     void xErrorTypeChanged(XYCurve::ErrorType);
  266     void xErrorPlusColumnChanged(const AbstractColumn*);
  267     void xErrorMinusColumnChanged(const AbstractColumn*);
  268     void yErrorTypeChanged(XYCurve::ErrorType);
  269     void yErrorPlusColumnChanged(const AbstractColumn*);
  270     void yErrorMinusColumnChanged(const AbstractColumn*);
  271     void errorBarsCapSizeChanged(qreal);
  272     void errorBarsTypeChanged(XYCurve::ErrorBarsType);
  273     void errorBarsPenChanged(QPen);
  274     void errorBarsOpacityChanged(qreal);
  275 };
  276 
  277 #endif