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)  

Axis.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Axis.h
3  Project : LabPlot
4  Description : Axis for cartesian coordinate systems.
5  --------------------------------------------------------------------
6  Copyright : (C) 2009 Tilman Benkert (thzs@gmx.net)
7  Copyright : (C) 2011-2018 Alexander Semke (alexander.semke@web.de)
8  Copyright : (C) 2013 Stefan Gerlach (stefan.gerlach@uni.kn)
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 AXISNEW_H
31 #define AXISNEW_H
32 
34 #include "backend/lib/macros.h"
35 
36 class CartesianPlot;
37 class TextLabel;
38 class AxisPrivate;
39 class AbstractColumn;
40 class QActionGroup;
41 
42 class Axis: public WorksheetElement {
43  Q_OBJECT
44 
45 public:
48  enum TicksFlags {
49  noTicks = 0x00,
50  ticksIn = 0x01,
51  ticksOut = 0x02,
52  ticksBoth = 0x03,
53  };
54  Q_DECLARE_FLAGS(TicksDirection, TicksFlags)
55 
56  enum class TicksType {TotalNumber, Spacing, CustomColumn, CustomValues};
58  enum class ArrowPosition {Left, Right, Both};
59  enum class Scale {Linear, Log10, Log2, Ln, Sqrt, X2};
60  enum class LabelsPosition {NoLabels, In, Out};
62 
63  explicit Axis(const QString&, Orientation orientation = Orientation::Horizontal);
64  ~Axis() override;
65 
66  void finalizeAdd() override;
67  QIcon icon() const override;
68  QMenu* createContextMenu() override;
69 
70  QGraphicsItem* graphicsItem() const override;
71  void setZValue(qreal) override;
72 
73  void save(QXmlStreamWriter*) const override;
74  bool load(XmlStreamReader*, bool preview) override;
75  void loadThemeConfig(const KConfig&) override;
76  void saveThemeConfig(const KConfig&) override;
77 
78  BASIC_D_ACCESSOR_DECL(bool, autoScale, AutoScale)
82  BASIC_D_ACCESSOR_DECL(double, start, Start)
83  BASIC_D_ACCESSOR_DECL(double, end, End)
84  void setOffset(const double, const bool=true);
85  double offset() const;
86  BASIC_D_ACCESSOR_DECL(qreal, scalingFactor, ScalingFactor)
87  BASIC_D_ACCESSOR_DECL(qreal, zeroOffset, ZeroOffset)
88 
89  POINTER_D_ACCESSOR_DECL(TextLabel, title, Title)
90  BASIC_D_ACCESSOR_DECL(double, titleOffsetX, TitleOffsetX)
91  BASIC_D_ACCESSOR_DECL(double, titleOffsetY, TitleOffsetY)
92 
93  CLASS_D_ACCESSOR_DECL(QPen, linePen, LinePen)
94  BASIC_D_ACCESSOR_DECL(qreal, lineOpacity, LineOpacity)
97  BASIC_D_ACCESSOR_DECL(double, arrowSize, ArrowSize)
98 
99  BASIC_D_ACCESSOR_DECL(TicksDirection, majorTicksDirection, MajorTicksDirection)
100  BASIC_D_ACCESSOR_DECL(TicksType, majorTicksType, MajorTicksType)
101  BASIC_D_ACCESSOR_DECL(int, majorTicksNumber, MajorTicksNumber)
102  BASIC_D_ACCESSOR_DECL(qreal, majorTicksSpacing, MajorTicksSpacing)
103  POINTER_D_ACCESSOR_DECL(const AbstractColumn, majorTicksColumn, MajorTicksColumn)
104  QString& majorTicksColumnPath() const;
105  CLASS_D_ACCESSOR_DECL(QPen, majorTicksPen, MajorTicksPen)
106  BASIC_D_ACCESSOR_DECL(qreal, majorTicksLength, MajorTicksLength)
107  BASIC_D_ACCESSOR_DECL(qreal, majorTicksOpacity, MajorTicksOpacity)
108 
109  BASIC_D_ACCESSOR_DECL(TicksDirection, minorTicksDirection, MinorTicksDirection)
110  BASIC_D_ACCESSOR_DECL(TicksType, minorTicksType, MinorTicksType)
111  BASIC_D_ACCESSOR_DECL(int, minorTicksNumber, MinorTicksNumber)
112  BASIC_D_ACCESSOR_DECL(qreal, minorTicksSpacing, MinorTicksSpacing)
113  POINTER_D_ACCESSOR_DECL(const AbstractColumn, minorTicksColumn, MinorTicksColumn)
114  QString& minorTicksColumnPath() const;
115  CLASS_D_ACCESSOR_DECL(QPen, minorTicksPen, MinorTicksPen)
116  BASIC_D_ACCESSOR_DECL(qreal, minorTicksLength, MinorTicksLength)
117  BASIC_D_ACCESSOR_DECL(qreal, minorTicksOpacity, MinorTicksOpacity)
118 
120  BASIC_D_ACCESSOR_DECL(bool, labelsAutoPrecision, LabelsAutoPrecision)
121  BASIC_D_ACCESSOR_DECL(int, labelsPrecision, LabelsPrecision)
122  CLASS_D_ACCESSOR_DECL(QString, labelsDateTimeFormat, LabelsDateTimeFormat)
124  BASIC_D_ACCESSOR_DECL(qreal, labelsOffset, LabelsOffset)
125  BASIC_D_ACCESSOR_DECL(qreal, labelsRotationAngle, LabelsRotationAngle)
126  CLASS_D_ACCESSOR_DECL(QColor, labelsColor, LabelsColor)
127  CLASS_D_ACCESSOR_DECL(QFont, labelsFont, LabelsFont)
129  CLASS_D_ACCESSOR_DECL(QColor, labelsBackgroundColor, LabelsBackgroundColor)
130  CLASS_D_ACCESSOR_DECL(QString, labelsPrefix, LabelsPrefix)
131  CLASS_D_ACCESSOR_DECL(QString, labelsSuffix, LabelsSuffix)
132  BASIC_D_ACCESSOR_DECL(qreal, labelsOpacity, LabelsOpacity)
133 
134  CLASS_D_ACCESSOR_DECL(QPen, majorGridPen, MajorGridPen)
135  BASIC_D_ACCESSOR_DECL(qreal, majorGridOpacity, MajorGridOpacity)
136  CLASS_D_ACCESSOR_DECL(QPen, minorGridPen, MinorGridPen)
137  BASIC_D_ACCESSOR_DECL(qreal, minorGridOpacity, MinorGridOpacity)
138 
139  void setDefault(bool);
140  bool isDefault() const;
141 
142  void setVisible(bool) override;
143  bool isVisible() const override;
144 
145  void setPrinting(bool) override;
146  bool isHovered() const;
147  void setSuppressRetransform(bool);
148  void retransform() override;
150  void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
151 
153 
154 protected:
156  Axis(const QString&, Orientation, AxisPrivate*);
158 
159 private:
160  Q_DECLARE_PRIVATE(Axis)
161  void init();
162  void initActions();
163  void initMenus();
164 
165  QAction* visibilityAction{nullptr};
166  QAction* orientationHorizontalAction{nullptr};
167  QAction* orientationVerticalAction{nullptr};
168 
169  QActionGroup* orientationActionGroup{nullptr};
170  QActionGroup* lineStyleActionGroup{nullptr};
171  QActionGroup* lineColorActionGroup{nullptr};
172 
173  QMenu* orientationMenu{nullptr};
174  QMenu* lineMenu{nullptr};
175  QMenu* lineStyleMenu{nullptr};
176  QMenu* lineColorMenu{nullptr};
177 
178 private slots:
179  void labelChanged();
180  void retransformTicks();
183 
184  //SLOTs for changes triggered via QActions in the context menu
185  void orientationChangedSlot(QAction*);
186  void lineStyleChanged(QAction*);
187  void lineColorChanged(QAction*);
188  void visibilityChangedSlot();
189 
190 signals:
193  void positionChanged(double);
195  void startChanged(double);
196  void autoScaleChanged(bool);
197  void endChanged(double);
198  void zeroOffsetChanged(qreal);
199  void scalingFactorChanged(qreal);
200 
201  //title
202  void titleOffsetXChanged(qreal);
203  void titleOffsetYChanged(qreal);
204 
205  // line
206  void linePenChanged(const QPen&);
207  void lineOpacityChanged(qreal);
210  void arrowSizeChanged(qreal);
211 
212  // major ticks
213  void majorTicksDirectionChanged(Axis::TicksDirection);
221 
222  // minor ticks
223  void minorTicksDirectionChanged(Axis::TicksDirection);
231 
232  //labels
236  void labelsDateTimeFormatChanged(const QString&);
238  void labelsOffsetChanged(double);
240  void labelsColorChanged(QColor);
241  void labelsFontChanged(QFont);
244  void labelsPrefixChanged(QString);
245  void labelsSuffixChanged(QString);
246  void labelsOpacityChanged(qreal);
247 
252 
253  void visibilityChanged(bool);
254 };
255 
256 Q_DECLARE_OPERATORS_FOR_FLAGS(Axis::TicksDirection)
257 
258 #endif
Base class of all persistent objects in a Project.
Interface definition for data with column logic.
Axis for cartesian coordinate systems.
Definition: Axis.h:42
LabelsPosition
Definition: Axis.h:60
void setDefault(bool)
Definition: Axis.cpp:486
Position
Definition: Axis.h:46
QMenu * lineColorMenu
Definition: Axis.h:176
QMenu * orientationMenu
Definition: Axis.h:173
void labelsBackgroundColorChanged(QColor)
void labelsPositionChanged(Axis::LabelsPosition)
void labelsPrecisionChanged(int)
Scale
Definition: Axis.h:59
void minorTicksLengthChanged(qreal)
void minorTicksTypeChanged(Axis::TicksType)
QMenu * lineMenu
Definition: Axis.h:174
void majorTicksLengthChanged(qreal)
void minorTicksDirectionChanged(Axis::TicksDirection)
QIcon icon() const override
Definition: Axis.cpp:314
ArrowPosition
Definition: Axis.h:58
QGraphicsItem * graphicsItem() const override
Return the graphics item representing this element.
Definition: Axis.cpp:337
void majorTicksDirectionChanged(Axis::TicksDirection)
void labelsColorChanged(QColor)
void labelsFormatChanged(Axis::LabelsFormat)
void init()
Definition: Axis.cpp:136
TicksFlags
Definition: Axis.h:48
@ ticksOut
Definition: Axis.h:51
@ noTicks
Definition: Axis.h:49
@ ticksIn
Definition: Axis.h:50
@ ticksBoth
Definition: Axis.h:52
AxisPrivate *const d_ptr
Definition: Axis.h:155
QAction * orientationHorizontalAction
Definition: Axis.h:166
void majorTicksNumberChanged(int)
void scaleChanged(Scale)
LabelsFormat
Definition: Axis.h:47
void majorGridPenChanged(QPen)
QMenu * lineStyleMenu
Definition: Axis.h:175
void majorTicksColumnAboutToBeRemoved(const AbstractAspect *)
Definition: Axis.cpp:900
void minorTicksColumnChanged(const AbstractColumn *)
void zeroOffsetChanged(qreal)
void minorTicksPenChanged(QPen)
LabelsBackgroundType
Definition: Axis.h:61
~Axis() override
Definition: Axis.cpp:325
void labelsPrefixChanged(QString)
void retransform() override
Tell the element to newly transform its graphics item into its coordinate system.
Definition: Axis.cpp:352
void labelsSuffixChanged(QString)
void saveThemeConfig(const KConfig &) override
Definition: Axis.cpp:2540
void minorTicksOpacityChanged(qreal)
void labelChanged()
Definition: Axis.cpp:890
QString & majorTicksColumnPath() const
Definition: Axis.cpp:414
void orientationChangedSlot(QAction *)
Definition: Axis.cpp:919
void majorTicksColumnChanged(const AbstractColumn *)
bool isVisible() const override
Return whether the element is (at least) partially visible.
Definition: Axis.cpp:481
AxisPrivate Private
Definition: Axis.h:152
TicksType
Definition: Axis.h:56
bool isHovered() const
Definition: Axis.cpp:501
void titleOffsetYChanged(qreal)
void labelsOpacityChanged(qreal)
Axis(const QString &, Orientation orientation=Orientation::Horizontal)
Definition: Axis.cpp:117
double offset() const
void titleOffsetXChanged(qreal)
void minorTicksNumberChanged(int)
void startChanged(double)
void arrowTypeChanged(Axis::ArrowType)
void minorTicksIncrementChanged(qreal)
QActionGroup * lineStyleActionGroup
Definition: Axis.h:170
void setOffset(const double, const bool=true)
Definition: Axis.cpp:528
ArrowType
Definition: Axis.h:57
void labelsAutoPrecisionChanged(bool)
void positionChanged(Position)
void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override
Definition: Axis.cpp:367
void autoScaleChanged(bool)
void positionChanged(double)
void majorTicksSpacingChanged(qreal)
void majorTicksPenChanged(QPen)
void minorTicksColumnAboutToBeRemoved(const AbstractAspect *)
Definition: Axis.cpp:908
void labelsBackgroundTypeChanged(Axis::LabelsBackgroundType)
void endChanged(double)
void initActions()
Definition: Axis.cpp:228
void setPrinting(bool) override
Switches the printing mode on/off.
Definition: Axis.cpp:496
void finalizeAdd() override
Definition: Axis.cpp:129
void initMenus()
Definition: Axis.cpp:257
void save(QXmlStreamWriter *) const override
Save as XML.
Definition: Axis.cpp:2246
void scalingFactorChanged(qreal)
void visibilityChanged(bool)
void retransformTickLabelStrings()
Definition: Axis.cpp:357
void setZValue(qreal) override
Definition: Axis.cpp:345
void labelsDateTimeFormatChanged(const QString &)
void minorGridPenChanged(QPen)
QActionGroup * lineColorActionGroup
Definition: Axis.h:171
void setVisible(bool) override
Show/hide the element.
Definition: Axis.cpp:476
void arrowSizeChanged(qreal)
void minorGridOpacityChanged(qreal)
void retransformTicks()
Definition: Axis.cpp:895
void visibilityChangedSlot()
Definition: Axis.cpp:940
void labelsFontChanged(QFont)
void lineOpacityChanged(qreal)
QMenu * createContextMenu() override
Return a new context menu.
Definition: Axis.cpp:280
void loadThemeConfig(const KConfig &) override
Definition: Axis.cpp:2467
void lineColorChanged(QAction *)
Definition: Axis.cpp:933
void majorTicksTypeChanged(Axis::TicksType)
QAction * visibilityAction
Definition: Axis.h:165
void lineStyleChanged(QAction *)
Definition: Axis.cpp:926
void linePenChanged(const QPen &)
QString & minorTicksColumnPath() const
Definition: Axis.cpp:424
void labelsOffsetChanged(double)
void majorTicksOpacityChanged(qreal)
QActionGroup * orientationActionGroup
Definition: Axis.h:169
void orientationChanged(Orientation)
void setSuppressRetransform(bool)
Definition: Axis.cpp:362
void majorGridOpacityChanged(qreal)
void labelsRotationAngleChanged(qreal)
QAction * orientationVerticalAction
Definition: Axis.h:167
TextLabel * m_title
Definition: Axis.h:157
bool load(XmlStreamReader *, bool preview) override
Load from XML.
Definition: Axis.cpp:2342
void arrowPositionChanged(Axis::ArrowPosition)
bool isDefault() const
Definition: Axis.cpp:491
A xy-plot.
Definition: CartesianPlot.h:58
A label supporting rendering of html- and tex-formatted texts.
Definition: TextLabel.h:44
Base class for all Worksheet children.
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...
#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