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)  

CartesianPlot.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  File : CartesianPlot.h
4  Project : LabPlot
5  Description : Cartesian plot
6  --------------------------------------------------------------------
7  Copyright : (C) 2011-2020 Alexander Semke (alexander.semke@web.de)
8  Copyright : (C) 2012-2019 Stefan Gerlach (stefan.gerlach@uni.kn)
9 
10  ***************************************************************************/
11 
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the Free Software *
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27  * Boston, MA 02110-1301 USA *
28  * *
29  ***************************************************************************/
30 
31 #ifndef CARTESIANPLOT_H
32 #define CARTESIANPLOT_H
33 
37 
38 #include <cmath>
39 
40 class QToolBar;
43 class AbstractColumn;
44 class XYCurve;
45 class XYEquationCurve;
48 class XYIntegrationCurve;
50 class XYSmoothCurve;
51 class XYFitCurve;
54 class XYConvolutionCurve;
55 class XYCorrelationCurve;
56 class KConfig;
57 
58 class CartesianPlot : public AbstractPlot {
59  Q_OBJECT
60 
61 public:
62  explicit CartesianPlot(const QString &name);
63  ~CartesianPlot() override;
64 
65  enum class Scale {Linear, Log10, Log2, Ln, Log10Abs, Log2Abs, LnAbs, Sqrt, X2};
67  enum class RangeFormat {Numeric, DateTime};
68  enum class RangeType {Free, Last, First};
73  };
74 
75  struct RangeBreak {
76  RangeBreak() : start(NAN), end(NAN), position(0.5), style(RangeBreakStyle::Sloped) {}
77  bool isValid() const {
78  return (!std::isnan(start) && !std::isnan(end));
79  }
80  double start;
81  double end;
82  double position;
84  };
85 
86  //simple wrapper for QList<RangeBreaking> in order to get our macros working
87  struct RangeBreaks {
89  RangeBreak b;
90  list << b;
91  };
94  };
95 
96  void setType(Type type);
97  Type type() const;
98 
99  QIcon icon() const override;
100  QMenu* createContextMenu() override;
101  QMenu* analysisMenu();
102  QVector<AbstractAspect*> dependsOn() const override;
103  void setRect(const QRectF&) override;
104  QRectF dataRect() const;
105  void setMouseMode(MouseMode);
106  void setLocked(bool);
107  bool isLocked() const;
108  MouseMode mouseMode() const;
110  void setSuppressDataChangedSignal(bool);
111  const QList<QColor>& themeColorPalette() const;
112  void processDropEvent(const QVector<quintptr>&) override;
113  bool isPanningActive() const;
114  bool isHovered() const;
115  bool isPrinted() const;
116  bool isSelected() const;
118  int curveCount();
119  const XYCurve* getCurve(int index);
120  double cursorPos(int cursorNumber);
121 
122  void save(QXmlStreamWriter*) const override;
123  bool load(XmlStreamReader*, bool preview) override;
124  void loadThemeConfig(const KConfig&) override;
125  void saveTheme(KConfig& config);
126  void mousePressZoomSelectionMode(QPointF logicPos);
127  void mousePressCursorMode(int cursorNumber, QPointF logicPos);
128  void mouseMoveZoomSelectionMode(QPointF logicPos);
129  void mouseMoveCursorMode(int cursorNumber, QPointF logicPos);
131  void mouseHoverZoomSelectionMode(QPointF logicPos);
133 
134  BASIC_D_ACCESSOR_DECL(CartesianPlot::RangeFormat, xRangeFormat, XRangeFormat)
135  BASIC_D_ACCESSOR_DECL(CartesianPlot::RangeFormat, yRangeFormat, YRangeFormat)
136  const QString& xRangeDateTimeFormat() const;
137  const QString& yRangeDateTimeFormat() const;
139  BASIC_D_ACCESSOR_DECL(int, rangeLastValues, RangeLastValues)
140  BASIC_D_ACCESSOR_DECL(int, rangeFirstValues, RangeFirstValues)
141  BASIC_D_ACCESSOR_DECL(bool, autoScaleX, AutoScaleX)
142  BASIC_D_ACCESSOR_DECL(bool, autoScaleY, AutoScaleY)
143  BASIC_D_ACCESSOR_DECL(double, xMin, XMin)
144  BASIC_D_ACCESSOR_DECL(double, xMax, XMax)
145  BASIC_D_ACCESSOR_DECL(double, yMin, YMin)
146  BASIC_D_ACCESSOR_DECL(double, yMax, YMax)
149  BASIC_D_ACCESSOR_DECL(bool, xRangeBreakingEnabled, XRangeBreakingEnabled)
150  BASIC_D_ACCESSOR_DECL(bool, yRangeBreakingEnabled, YRangeBreakingEnabled)
151  CLASS_D_ACCESSOR_DECL(RangeBreaks, xRangeBreaks, XRangeBreaks)
152  CLASS_D_ACCESSOR_DECL(RangeBreaks, yRangeBreaks, YRangeBreaks)
153  CLASS_D_ACCESSOR_DECL(QPen, cursorPen, CursorPen);
154  CLASS_D_ACCESSOR_DECL(bool, cursor0Enable, Cursor0Enable);
155  CLASS_D_ACCESSOR_DECL(bool, cursor1Enable, Cursor1Enable);
156 
157  QString theme() const;
158 
160 
161 public slots:
162  void setTheme(const QString&);
163 
164 private:
165  void init();
166  void initActions();
167  void initMenus();
168  void setColorPalette(const KConfig&);
169  const XYCurve* currentCurve() const;
170  void shift(bool x, bool leftOrDown);
171  void zoom(bool x, bool in);
173  void calculateCurvesXMinMax(bool completeRange = true);
174  void calculateCurvesYMinMax(bool completeRange = true);
175 
177  double m_zoomFactor{1.2};
179  bool m_menusInitialized{false};
180 
182 
183  //"add new" actions
184  QAction* addCurveAction;
197 
200  QAction* addLegendAction;
202  QAction* addImageAction;
205 
206  //scaling, zooming, navigation actions
209  QAction* scaleAutoAction;
210  QAction* zoomInAction;
211  QAction* zoomOutAction;
212  QAction* zoomInXAction;
213  QAction* zoomOutXAction;
214  QAction* zoomInYAction;
215  QAction* zoomOutYAction;
218  QAction* shiftUpYAction;
220 
221  //analysis menu actions
227  QAction* addSmoothAction;
233 
234  QMenu* addNewMenu{nullptr};
235  QMenu* addNewAnalysisMenu{nullptr};
236  QMenu* zoomMenu{nullptr};
237  QMenu* dataAnalysisMenu{nullptr};
238  QMenu* themeMenu{nullptr};
239 
240  Q_DECLARE_PRIVATE(CartesianPlot)
241 
242 public slots:
243  void addHorizontalAxis();
244  void addVerticalAxis();
245  void addCurve();
246  void addHistogram();
247  void addEquationCurve();
248  void addDataReductionCurve();
250  void addIntegrationCurve();
251  void addInterpolationCurve();
252  void addSmoothCurve();
253  void addFitCurve();
254  void addFourierFilterCurve();
256  void addConvolutionCurve();
257  void addCorrelationCurve();
258 
259  void addLegend();
260  void addTextLabel();
261  void addImage();
262  void addCustomPoint();
263  void addReferenceLine();
264 
265  void scaleAutoTriggered();
266  bool scaleAuto();
267  bool scaleAutoX();
268  bool scaleAutoY();
269 
270  void zoomIn();
271  void zoomOut();
272  void zoomInX();
273  void zoomOutX();
274  void zoomInY();
275  void zoomOutY();
276 
277  void shiftLeftX();
278  void shiftRightX();
279  void shiftUpY();
280  void shiftDownY();
281 
282  void cursor();
283 
284  void dataChanged();
285 
286 private slots:
287  void updateLegend();
288  void childAdded(const AbstractAspect*);
289  void childRemoved(const AbstractAspect* parent, const AbstractAspect* before, const AbstractAspect* child);
290  void childHovered();
291 
292  void xDataChanged();
293  void yDataChanged();
294  void curveLinePenChanged(QPen);
295  void curveVisibilityChanged();
296 
297  //SLOTs for changes triggered via QActions in the context menu
298  void visibilityChanged();
299  void loadTheme(const QString&);
300 
301 protected:
302  CartesianPlot(const QString &name, CartesianPlotPrivate *dd);
303 
304 signals:
310  void rectChanged(QRectF&);
311  void xAutoScaleChanged(bool);
312  void xMinChanged(double);
313  void xMaxChanged(double);
315  void yAutoScaleChanged(bool);
316  void yMinChanged(double);
317  void yMaxChanged(double);
323  void themeChanged(const QString&);
324  void mousePressZoomSelectionModeSignal(QPointF logicPos);
325  void mousePressCursorModeSignal(int cursorNumber, QPointF logicPos);
326  void mouseMoveZoomSelectionModeSignal(QPointF logicPos);
327  void mouseMoveCursorModeSignal(int cursorNumber, QPointF logicPos);
330  void mouseHoverZoomSelectionModeSignal(QPointF logicalPoint);
332  void curveNameChanged(const AbstractAspect* curve);
333  void cursorPosChanged(int cursorNumber, double xPos);
334  void curveAdded(const XYCurve*);
335  void curveRemoved(const XYCurve*);
336  void curveLinePenChanged(QPen, QString curveName);
337  void cursorPenChanged(QPen);
338  void curveDataChanged(const XYCurve*);
341  void cursor0EnableChanged(bool enable);
342  void cursor1EnableChanged(bool enable);
343 };
344 
345 #endif
Base class of all persistent objects in a Project.
AbstractAspect * parent(AspectType type) const
In the parent-child hierarchy, return the first parent of type.
QString name() const
T * child(int index, ChildIndexFlags flags={}) const
Interface definition for data with column logic.
Second level container in a Worksheet for logical grouping.
Definition: AbstractPlot.h:41
Axis for cartesian coordinate systems.
Definition: Axis.h:42
Legend for the cartesian plot.
A xy-plot.
Definition: CartesianPlot.h:58
bool isPanningActive() const
void curveLinePenChanged(QPen)
void setType(Type type)
QMenu * createContextMenu() override
Return a new context menu.
QAction * zoomOutYAction
QAction * addIntegrationCurveAction
void addHorizontalAxis()
void mouseMoveZoomSelectionModeSignal(QPointF logicPos)
QAction * addLegendAction
void setMouseMode(MouseMode)
void checkAxisFormat(const AbstractColumn *, Axis::Orientation)
QAction * addCurveAction
QAction * addFitCurveAction
void yScaleChanged(CartesianPlot::Scale)
void xScaleChanged(CartesianPlot::Scale)
QIcon icon() const override
const QString & yRangeDateTimeFormat() const
QAction * addEquationCurveAction
QMenu * analysisMenu()
void mouseMoveCursorModeSignal(int cursorNumber, QPointF logicPos)
QAction * addCorrelationAction
void save(QXmlStreamWriter *) const override
Save as XML.
QRectF dataRect() const
QVector< QAction * > addFitAction
QAction * addDataReductionAction
void cursor1EnableChanged(bool enable)
void addIntegrationCurve()
QAction * addConvolutionAction
void curveRemoved(const XYCurve *)
const QList< QColor > & themeColorPalette() const
void rangeLastValuesChanged(int)
QAction * addHorizontalAxisAction
double cursorPos(int cursorNumber)
void childRemoved(const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
void addCorrelationCurve()
bool m_menusInitialized
QAction * addConvolutionCurveAction
~CartesianPlot() override
QMenu * zoomMenu
void rangeTypeChanged(CartesianPlot::RangeType)
void addFourierTransformCurve()
QAction * addDataReductionCurveAction
QAction * addFourierFilterCurveAction
void yRangeFormatChanged(CartesianPlot::RangeFormat)
QAction * zoomInAction
void mouseHoverOutsideDataRect()
void addInterpolationCurve()
QAction * addFourierTransformAction
void loadThemeConfig(const KConfig &) override
void mouseReleaseZoomSelectionMode()
CartesianPlot(const QString &name)
void mousePressCursorMode(int cursorNumber, QPointF logicPos)
bool load(XmlStreamReader *, bool preview) override
Load from XML.
void visibilityChanged()
void setRect(const QRectF &) override
void mouseHoverZoomSelectionModeSignal(QPointF logicalPoint)
void scaleAutoTriggered()
void yMinChanged(double)
QAction * addCorrelationCurveAction
void zoom(bool x, bool in)
void navigate(NavigationOperation)
QAction * addInterpolationCurveAction
QAction * addReferenceLineAction
void setColorPalette(const KConfig &)
void mouseMoveZoomSelectionMode(QPointF logicPos)
void calculateCurvesYMinMax(bool completeRange=true)
QAction * addInterpolationAction
QAction * shiftUpYAction
QAction * zoomInYAction
bool isHovered() const
QString theme() const
void setTheme(const QString &)
void addDifferentiationCurve()
double m_zoomFactor
const XYCurve * currentCurve() const
QAction * addSmoothCurveAction
void setLocked(bool)
void curveAdded(const XYCurve *)
QAction * visibilityAction
void curveNameChanged(const AbstractAspect *curve)
void curveVisibilityChanged()
void yRangeBreaksChanged(const CartesianPlot::RangeBreaks &)
QAction * addVerticalAxisAction
const XYCurve * getCurve(int index)
void mouseModeChanged(CartesianPlot::MouseMode)
void mouseReleaseZoomSelectionModeSignal()
QAction * addImageAction
QAction * addTextLabelAction
QAction * addIntegrationAction
void xRangeFormatChanged(CartesianPlot::RangeFormat)
void mousePressZoomSelectionMode(QPointF logicPos)
void loadTheme(const QString &)
void mouseHoverOutsideDataRectSignal()
QAction * shiftLeftXAction
QAction * shiftRightXAction
void mousePressZoomSelectionModeSignal(QPointF logicPos)
QAction * scaleAutoAction
bool isPrinted() const
QAction * addSmoothAction
void setSuppressDataChangedSignal(bool)
void childHovered()
CartesianPlot::childHovered Unhover all curves, when another child is hovered. The hover handling for...
QAction * addDataOperationAction
void xMinChanged(double)
QAction * addCustomPointAction
void xRangeBreakingEnabledChanged(bool)
QMenu * addNewAnalysisMenu
void yAutoScaleChanged(bool)
QAction * addHistogramAction
void mouseHoverZoomSelectionMode(QPointF logicPos)
void processDropEvent(const QVector< quintptr > &) override
bool isLocked() const
CartesianPlotLegend * m_legend
MouseMode mouseMode() const
void addConvolutionCurve()
void shift(bool x, bool leftOrDown)
bool isSelected() const
void childAdded(const AbstractAspect *)
void xAutoScaleChanged(bool)
void mouseMoveCursorMode(int cursorNumber, QPointF logicPos)
Type type() const
void cursorPenChanged(QPen)
void yMaxChanged(double)
void saveTheme(KConfig &config)
void yRangeBreakingEnabledChanged(bool)
void xMaxChanged(double)
void addFourierFilterCurve()
const QString & xRangeDateTimeFormat() const
QAction * shiftDownYAction
void curveLinePenChanged(QPen, QString curveName)
QAction * addDifferentiationAction
void xRangeBreaksChanged(const CartesianPlot::RangeBreaks &)
void cursorPosChanged(int cursorNumber, double xPos)
QAction * scaleAutoXAction
QList< QColor > m_themeColorPalette
QMenu * addNewMenu
CLASS_D_ACCESSOR_DECL(QPen, cursorPen, CursorPen)
void rangeFirstValuesChanged(int)
void cursor0EnableChanged(bool enable)
QAction * addFourierFilterAction
QAction * zoomOutXAction
QAction * zoomInXAction
void addDataReductionCurve()
QVector< AbstractAspect * > dependsOn() const override
void mouseReleaseCursorModeSignal()
void curveVisibilityChangedSignal()
QAction * scaleAutoYAction
QMenu * dataAnalysisMenu
void curveDataChanged(const XYCurve *)
void rectChanged(QRectF &)
QAction * zoomOutAction
void mousePressCursorModeSignal(int cursorNumber, QPointF logicPos)
void calculateCurvesXMinMax(bool completeRange=true)
QAction * addFourierTransformCurveAction
QAction * addDifferentiationCurveAction
QMenu * themeMenu
void themeChanged(const QString &)
A xy-curve defined by a convolution.
A xy-curve defined by a correlation.
A 2D-curve, provides an interface for editing many properties of the curve.
Definition: XYCurve.h:46
A xy-curve defined by a data reduction.
A xy-curve defined by an differentiation.
A xy-curve defined by a mathematical equation.
A xy-curve defined by a fit model.
Definition: XYFitCurve.h:43
A xy-curve defined by a Fourier filter.
A xy-curve defined by a Fourier transform.
A xy-curve defined by an integration.
A xy-curve defined by an interpolation.
A xy-curve defined by a smooth.
Definition: XYSmoothCurve.h:41
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...
#define BASIC_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:107
QList< RangeBreak > list
Definition: CartesianPlot.h:91