labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

XYCurve.h
Go to the documentation of this file.
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 
37 #include "backend/lib/macros.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;
59  };
62  enum class ValuesPosition {Above, Under, 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 
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 
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 
111  POINTER_D_ACCESSOR_DECL(const AbstractColumn, valuesColumn, ValuesColumn)
112  CLASS_D_ACCESSOR_DECL(QString, valuesColumnPath, ValuesColumnPath)
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 
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 
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);
156 
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();
173  void xColumnNameChanged();
174  void yColumnNameChanged();
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);
187 
188 private:
189  Q_DECLARE_PRIVATE(XYCurve)
190  void init();
191  void initActions();
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();
214  void visibilityChanged(bool);
215 
218 
219  //Line-Tab
224  void linePenChanged(const QPen&);
225  void lineOpacityChanged(qreal);
227  void dropLinePenChanged(const QPen&);
229 
230  //Symbol-Tab
232  void symbolsSizeChanged(qreal);
235  void symbolsBrushChanged(QBrush);
236  void symbolsPenChanged(const QPen&);
237 
238  //Values-Tab
244  void valuesOpacityChanged(qreal);
248  void valuesPrefixChanged(QString);
249  void valuesSuffixChanged(QString);
250  void valuesFontChanged(QFont);
251  void valuesColorChanged(QColor);
252 
253  //Filling
258  void fillingBrushStyleChanged(Qt::BrushStyle);
261  void fillingFileNameChanged(QString&);
263 
264  //Error bars
275 };
276 
277 #endif
AspectType
Base class of all persistent objects in a Project.
AspectType type() const
QString name() const
Interface definition for data with column logic.
Definition: Curve.h:34
BackgroundColorStyle
Definition: PlotArea.h:46
BackgroundImageStyle
Definition: PlotArea.h:48
BackgroundType
Definition: PlotArea.h:45
Style
Definition: Symbol.h:38
Base class for all Worksheet children.
A 2D-curve, provides an interface for editing many properties of the curve.
Definition: XYCurve.h:46
void valuesPrefixChanged(QString)
void valuesDataChanged()
void yErrorPlusColumnChanged(const AbstractColumn *)
void fillingFileNameChanged(QString &)
void valuesFontChanged(QFont)
void yColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:810
void valuesSuffixChanged(QString)
bool isVisible() const override
Return whether the element is (at least) partially visible.
Definition: XYCurve.cpp:216
void yErrorMinusDataChanged()
void symbolsPenChanged(const QPen &)
void setPrinting(bool on) override
Switches the printing mode on/off.
Definition: XYCurve.cpp:221
friend class XYCurveSetValuesColumnCmd
Definition: XYCurve.h:56
QIcon icon() const override
Definition: XYCurve.cpp:202
bool activateCurve(QPointF mouseScenePos, double maxDist=-1) override
XYCurve::activateCurve Checks if the mousepos distance to the curve is less than maxDist mouseScenePo...
Definition: XYCurve.cpp:233
void fillingImageStyleChanged(PlotArea::BackgroundImageStyle)
void xErrorMinusColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:837
void navigateTo()
Definition: XYCurve.cpp:907
void errorBarsTypeChanged(XYCurve::ErrorBarsType)
void yDataChanged()
QAction * visibilityAction
Definition: XYCurve.h:200
void finalizeAdd() override
Definition: XYCurve.cpp:82
void valuesColumnNameChanged()
Definition: XYCurve.cpp:894
LineType
Definition: XYCurve.h:57
void fillingSecondColorChanged(QColor &)
bool isSourceDataChangedSinceLastRecalc() const
Definition: XYCurve.cpp:329
void dataChanged()
void dropLineTypeChanged(XYCurve::DropLineType)
void errorBarsOpacityChanged(qreal)
void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override
Definition: XYCurve.cpp:781
void fillingTypeChanged(PlotArea::BackgroundType)
void errorBarsCapSizeChanged(qreal)
void lineOpacityChanged(qreal)
void xErrorPlusColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:828
ErrorType
Definition: XYCurve.h:63
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
Definition: XYCurve.cpp:2207
ValuesType
Definition: XYCurve.h:61
void valuesTypeChanged(XYCurve::ValuesType)
QMenu * createContextMenu() override
Return a new context menu.
Definition: XYCurve.cpp:164
void yErrorPlusDataChanged()
bool minMaxY(int indexMin, int indexMax, double &yMin, double &yMax, bool includeErrorBars=true) const
Definition: XYCurve.cpp:2185
void valuesColumnChanged(const AbstractColumn *)
void valuesPrecisionChanged(int)
void setVisible(bool on) override
Show/hide the element.
Definition: XYCurve.cpp:211
void xDataChanged()
void errorBarsPenChanged(QPen)
void symbolsBrushChanged(QBrush)
void visibilityChanged()
Definition: XYCurve.cpp:902
void xColumnNameChanged()
Definition: XYCurve.cpp:864
QGraphicsItem * graphicsItem() const override
Return the graphics item representing this element.
Definition: XYCurve.cpp:206
friend class XYCurveSetXColumnCmd
Definition: XYCurve.h:50
void fillingBrushStyleChanged(Qt::BrushStyle)
void xErrorPlusColumnChanged(const AbstractColumn *)
void valuesDateTimeFormatChanged(QString)
friend class XYCurveSetYErrorPlusColumnCmd
Definition: XYCurve.h:54
void symbolsStyleChanged(Symbol::Style)
void updateErrorBars()
Definition: XYCurve.cpp:775
void symbolsSizeChanged(qreal)
void xErrorMinusColumnChanged(const AbstractColumn *)
friend class XYCurveSetXErrorMinusColumnCmd
Definition: XYCurve.h:53
void yErrorTypeChanged(XYCurve::ErrorType)
void fillingColorStyleChanged(PlotArea::BackgroundColorStyle)
XYCurvePrivate Private
Definition: XYCurve.h:157
friend class XYCurveSetYColumnCmd
Definition: XYCurve.h:51
void lineIncreasingXOnlyChanged(bool)
void fillingFirstColorChanged(QColor &)
void yErrorMinusColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:855
void fillingOpacityChanged(float)
void lineInterpolationPointsCountChanged(int)
void yErrorPlusColumnNameChanged()
Definition: XYCurve.cpp:884
~XYCurve() override
void saveThemeConfig(const KConfig &) override
Definition: XYCurve.cpp:3270
void dropLinePenChanged(const QPen &)
bool load(XmlStreamReader *, bool preview) override
Load from XML.
Definition: XYCurve.cpp:3048
void retransform() override
Tell the element to newly transform its graphics item into its coordinate system.
Definition: XYCurve.cpp:760
void xErrorTypeChanged(XYCurve::ErrorType)
void initActions()
Definition: XYCurve.cpp:153
void yErrorMinusColumnNameChanged()
Definition: XYCurve.cpp:889
ValuesPosition
Definition: XYCurve.h:62
bool minMaxX(int indexMin, int indexMax, double &yMin, double &yMax, bool includeErrorBars=true) const
Definition: XYCurve.cpp:2189
void valuesOpacityChanged(qreal)
void xColumnChanged(const AbstractColumn *)
void valuesRotationAngleChanged(qreal)
QAction * navigateToAction
Definition: XYCurve.h:201
void valuesPositionChanged(XYCurve::ValuesPosition)
void fillingPositionChanged(XYCurve::FillingPosition)
void valuesDistanceChanged(qreal)
void symbolsRotationAngleChanged(qreal)
friend class XYCurveSetXErrorPlusColumnCmd
Definition: XYCurve.h:52
bool m_menusInitialized
Definition: XYCurve.h:202
void xErrorMinusDataChanged()
void xErrorMinusColumnNameChanged()
Definition: XYCurve.cpp:879
void save(QXmlStreamWriter *) const override
Save as XML.
Definition: XYCurve.cpp:2955
QDateTime yDateTime(double x, bool &valueFound) const
Definition: XYCurve.cpp:2162
void suppressRetransform(bool)
Definition: XYCurve.cpp:752
void xErrorPlusDataChanged()
void yColumnChanged(const AbstractColumn *)
void valuesColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:819
double y(double x, bool &valueFound) const
Definition: XYCurve.cpp:2132
void yErrorPlusColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:846
void init()
Definition: XYCurve.cpp:88
XYCurvePrivate *const d_ptr
Definition: XYCurve.h:186
void visibilityChanged(bool)
XYCurve(const QString &name, AspectType type=AspectType::XYCurve)
Definition: XYCurve.cpp:66
void loadThemeConfig(const KConfig &) override
Definition: XYCurve.cpp:3203
FillingPosition
Definition: XYCurve.h:64
void setHover(bool on) override
XYCurve::setHover Will be called in CartesianPlot::hoverMoveEvent() See d->setHover(on) for more docu...
Definition: XYCurve.cpp:244
void lineTypeChanged(XYCurve::LineType)
void linePenChanged(const QPen &)
void xErrorPlusColumnNameChanged()
Definition: XYCurve.cpp:874
void yErrorMinusColumnChanged(const AbstractColumn *)
ErrorBarsType
Definition: XYCurve.h:65
void yColumnNameChanged()
Definition: XYCurve.cpp:869
void dropLineOpacityChanged(qreal)
void xColumnAboutToBeRemoved(const AbstractAspect *)
Definition: XYCurve.cpp:801
void lineSkipGapsChanged(bool)
friend class XYCurveSetYErrorMinusColumnCmd
Definition: XYCurve.h:55
void valuesColorChanged(QColor)
void symbolsOpacityChanged(qreal)
void recalcLogicalPoints()
Definition: XYCurve.cpp:765
DropLineType
Definition: XYCurve.h:60
void updateValues()
Definition: XYCurve.cpp:770
void valuesNumericFormatChanged(char)
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...
#define XYCURVE_COLUMN_CONNECT(column_prefix)
Definition: macrosXYCurve.h:46
#define CLASS_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:134
#define POINTER_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:161
#define BASIC_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:107