JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtpcoordinateaxesstyle.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3
4
5
6 This software is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef JKQTPCOORDINATEAXESSTYLE_H
21#define JKQTPCOORDINATEAXESSTYLE_H
22
23#include <QSettings>
24#include <QString>
25#include <QColor>
26#include "jkqtplotter/jkqtptools.h"
27#include "jkqtplotter/jkqtplotter_imexport.h"
28#include "jkqtplotter/jkqtplotter_configmacros.h"
29#if __cplusplus >= 202002L
30# include <version>
31# ifdef __cpp_lib_format
32# include <format>
33# endif
34#endif
35
36class JKQTBasePlotterStyle; // forward
37
38
39/** \brief Support Class for JKQTPCoordinateAxis, and summarizes all properties that define the visual styling of a grid (minor or major), associated with a JKQTPCoordinateAxis
40 * \ingroup jkqtpplotter_styling_classes
41 *
42 * \see JKQTPCoordinateAxis, \ref jkqtpplotter_styling
43 *
44 */
46 Q_GADGET
47public:
48 JKQTPGridStyle(bool isMajor=true);
49
50
51 /** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object
52 *
53 * \param settings QSettings-object to read from
54 * \param group Group in the QSettings-object to read from
55 * \param defaultStyle If a setting cannot be found in \a settings, default values are taken from this object
56 * By default, this is a default-constructed object
57 */
58 void loadSettings(const QSettings &settings, const QString& group=QString("grid/"), const JKQTPGridStyle &defaultStyle=JKQTPGridStyle());
59
60 /** \brief saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object.
61 *
62 * \param settings QSettings-object to save to
63 * \param group Group in the QSettings-object to save to
64 */
65 void saveSettings(QSettings& settings, const QString& group=QString("grid/")) const;
66
67 /** \brief indicates whether to draw the major grid lines */
68 bool enabled;
69 /** \brief color of the grid*/
70 QColor lineColor;
71 /** \brief width of the grid lines (in pixel) */
72 double lineWidth;
73 /** \brief line stye of the grid lines */
74 Qt::PenStyle lineStyle;
75};
76
77
78
79/** \brief Support Class for JKQTPCoordinateAxis, which summarizes all properties that define the visual styling of a JKQTPCoordinateAxis
80 * \ingroup jkqtpplotter_styling_classes
81 *
82 * \image html jkqtpcoordinateaxis1.png
83 *
84 * \see JKQTPCoordinateAxis, \ref jkqtpplotter_styling
85 *
86 */
88 Q_GADGET
89 public:
91
93
94
95 /** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object
96 *
97 * \param settings QSettings-object to read from
98 * \param group Group in the QSettings-object to read from
99 * \param defaultStyle If a setting cannot be found in \a settings, default values are taken from this object
100 * By default, this is a default-constructed object
101 */
102 void loadSettings(const QSettings &settings, const QString& group=QString("axis/"), const JKQTPCoordinateAxisStyle &defaultStyle=JKQTPCoordinateAxisStyle());
103
104 /** \brief saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object.
105 *
106 * \param settings QSettings-object to save to
107 * \param group Group in the QSettings-object to save to
108 */
109 void saveSettings(QSettings& settings, const QString& group=QString("axis/")) const;
110
111 /** \brief digits used for tick labels */
113 /** \brief when \c true, the digits of the labels are calculated automatically */
115 /** \brief if \c true, the plotter displays minor axis labels as number between 1 and 10 in some cases */
117 /** \brief indicates how to draw the labels */
119
120 /** \brief mode of the major ticks */
122
123 /** \brief position of the axis label */
125 /** \brief fontsize of the axis labels */
127 /** \brief color of the axis label */
129 /** \brief fontsize of the axis tick labels */
131 /** \brief fontsize of the minor axis tick labels */
133 /** \brief indicates whether to draw a thick axis line at x=0 (zero axis) */
135 /** \brief indicates whether the minor tick labels should be full numbers, or just a number between 0..10 */
137
138
139 /** \brief draw mode of the main (left/bottom) axis */
141 /** \brief draw mode of the secondary (right/top) axis */
143 /** \brief draw mode of the zero axis
144 *
145 * \image html JKQTPCoordinateAxisStyleDrawMode0.png
146 *
147 * \see \ref JKQTPlotterGeometricCoordinateAxis0
148 */
150 /** \brief color of minor ticks */
152 /** \brief color of minor tick labels */
154 /** \brief line width of minor ticks in pt */
156 /** \brief color of axis ticks */
157 QColor tickColor;
158 /** \brief color of axis tick labels */
160 /** \brief line width of ticks in pt */
161 double tickWidth;
162 /** \brief line width of axis in pt */
163 double lineWidth;
164 /** \brief factor used to calculate the size of line arrows */
166 /** \brief line width of 0-line in pt */
168
169
170 /** \brief format string for time tick labels, see QDateTime::toString() documentation for details on format strings */
172 /** \brief format string for date tick labels, see QDateTime::toString() documentation for details on format strings */
174 /** \brief format string for datetime tick labels, see QDateTime::toString() documentation for details on format strings */
176 /** \brief format string for printf tick labels, see https://en.wikipedia.org/wiki/Printf_format_string documentation for details on format strings The first data parameter is the tick value as \c double an the second is tickUnitName as string. The following image shows an example for \c "y=%+.2f": \image html axisstyle/JKQTPCALTprintf.png */
178#if __cplusplus >= 202002L || DOXYGEN
179#if defined(__cpp_lib_format) || DOXYGEN
180 /** \brief format string for std::format tick labels, (see e.g. https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification ). The first data parameter is the tick value as \c double an the second is tickUnitName as string. The following image shows an example for \c "\\texttt{{ y={:*^+8.1f}}}": \image html axisstyle/JKQTPCALTformat.png
181 \note This option is only available for C++20 and above, use the CMake option \c JKQtPlotter_ENABLED_CXX20=ON if your compiler supports this.*/
183# endif
184#endif
185
186
187
188 /** \brief minimum number of axis ticks */
189 unsigned int minTicks;
190 /** \brief number of minor grid lines per axis tick interval
191 *
192 * \image html docu_logaxis_set_minorticks.png
193 **/
194 unsigned int minorTicks;
195 /** \brief length of an axis tick outside the plot border in pt */
197 /** \brief length of a minor axis tick outside the plot border in pt */
199 /** \brief length of an axis tick inside the plot border in pt */
201 /** \brief length of a minor axis tick inside the plot border in pt */
203 /** \brief color of the axis (labels, ticks, axis itself ...) */
204 QColor axisColor;
205 /** \brief distance between tick end and label start in pt */
207 /** \brief distance between tick label and axis label in pt */
209 /** \brief rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)
210 *
211 * These images show some example rotations:
212 *
213 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle-75Degree.png
214 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle-45Degree.png
215 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle-15Degree.png
216 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle0Degree.png
217 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle15Degree.png
218 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle45Degree.png
219 * \image html axisstyle/JKQTPCoordinateAxisTickLabelAngle75Degree.png
220 *
221 */
223
224 /** \brief styling of the major/primary grid */
226 /** \brief styling of the minor/secondary grid */
228
229 /** \brief color of 0-line */
231 /** \brief pen style of 0-line */
232 Qt::PenStyle styleZeroAxis;
233 /** \brief if non-zero, the line of the coordinate axis is moved outside the plot by this amount [pt]. This does not apply to the zero-axis! */
235
236
237 /** \brief returns a QPen that can be used for drawing zero axis lines */
239 /** \brief returns a QPen that can be used for drawing axis lines */
240 QPen getAxisPen(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
241 /** \brief returns a QPen that can be used for drawing axis tick lines */
242 QPen getTickPen(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent) const;
243 /** \brief returns a QPen that can be used for drawing minor axis tick lines */
245 /** \brief calculates the size of an arrow in pixels */
246 double getArrowSize(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
247};
248
249
250/** \brief Support Class for JKQTPCoordinateAxis, which summarizes all properties that define the visual styling of a JKQTPCoordinateAxis
251 * used for colorbars outside the plot
252 * \ingroup jkqtpplotter_styling_classes
253 *
254 * The major difference between this dervied version and the base JKQTPCoordinateAxisStyle are differently initialized members.
255 * \see JKQTPCoordinateAxis, \ref jkqtpplotter_styling
256 *
257 */
259 Q_GADGET
260 public:
261 /** \copydoc JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle() */
263
264 /** \copydoc JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle&) */
266 private:
267 /** \brief modifies the members to match the requirements of colorbar axes */
269
270};
271
272#endif // JKQTPCOORDINATEAXESSTYLE_H
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of ...
Definition jkqtpbaseplotterstyle.h:47
Support Class for JKQTPCoordinateAxis, which summarizes all properties that define the visual styling...
Definition jkqtpcoordinateaxesstyle.h:258
void initMembersForColorbars()
modifies the members to match the requirements of colorbar axes
JKQTPColorbarCoordinateAxisStyle(const JKQTBasePlotterStyle &baseStyle)
Support Class for JKQTPCoordinateAxis, which summarizes all properties that define the visual styling...
Definition jkqtpcoordinateaxesstyle.h:87
unsigned int minTicks
minimum number of axis ticks
Definition jkqtpcoordinateaxesstyle.h:189
Qt::PenStyle styleZeroAxis
pen style of 0-line
Definition jkqtpcoordinateaxesstyle.h:232
JKQTPLabelPosition labelPosition
position of the axis label
Definition jkqtpcoordinateaxesstyle.h:124
JKQTPCADrawMode drawMode2
draw mode of the secondary (right/top) axis
Definition jkqtpcoordinateaxesstyle.h:142
int labelDigits
digits used for tick labels
Definition jkqtpcoordinateaxesstyle.h:112
void saveSettings(QSettings &settings, const QString &group=QString("axis/")) const
saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings object.
double tickWidth
line width of ticks in pt
Definition jkqtpcoordinateaxesstyle.h:161
double minorTickOutsideLength
length of a minor axis tick outside the plot border in pt
Definition jkqtpcoordinateaxesstyle.h:198
QString tickPrintfFormat
format string for printf tick labels, see https://en.wikipedia.org/wiki/Printf_format_string document...
Definition jkqtpcoordinateaxesstyle.h:177
double getArrowSize(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
calculates the size of an arrow in pixels
JKQTPGridStyle minorGridStyle
styling of the minor/secondary grid
Definition jkqtpcoordinateaxesstyle.h:227
QColor axisColor
color of the axis (labels, ticks, axis itself ...)
Definition jkqtpcoordinateaxesstyle.h:204
QString tickDateFormat
format string for date tick labels, see QDateTime::toString() documentation for details on format str...
Definition jkqtpcoordinateaxesstyle.h:173
JKQTPGridStyle majorGridStyle
styling of the major/primary grid
Definition jkqtpcoordinateaxesstyle.h:225
double tickLabelDistance
distance between tick end and label start in pt
Definition jkqtpcoordinateaxesstyle.h:206
double lineWidthZeroAxis
line width of 0-line in pt
Definition jkqtpcoordinateaxesstyle.h:167
unsigned int minorTicks
number of minor grid lines per axis tick interval
Definition jkqtpcoordinateaxesstyle.h:194
bool minorTickLabelsEnabled
if true, the plotter displays minor axis labels as number between 1 and 10 in some cases
Definition jkqtpcoordinateaxesstyle.h:116
QPen getZeroAxisPen(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
returns a QPen that can be used for drawing zero axis lines
QString tickFormatFormat
format string for std::format tick labels, (see e.g. https://en.cppreference.com/w/cpp/utility/format...
Definition jkqtpcoordinateaxesstyle.h:182
double minorTickInsideLength
length of a minor axis tick inside the plot border in pt
Definition jkqtpcoordinateaxesstyle.h:202
double tickOutsideLength
length of an axis tick outside the plot border in pt
Definition jkqtpcoordinateaxesstyle.h:196
bool showZeroAxis
indicates whether to draw a thick axis line at x=0 (zero axis)
Definition jkqtpcoordinateaxesstyle.h:134
double labelDistance
distance between tick label and axis label in pt
Definition jkqtpcoordinateaxesstyle.h:208
QColor colorZeroAxis
color of 0-line
Definition jkqtpcoordinateaxesstyle.h:230
double minorTickWidth
line width of minor ticks in pt
Definition jkqtpcoordinateaxesstyle.h:155
QColor tickColor
color of axis ticks
Definition jkqtpcoordinateaxesstyle.h:157
QColor minorTickLabelColor
color of minor tick labels
Definition jkqtpcoordinateaxesstyle.h:153
JKQTPLabelTickMode tickMode
mode of the major ticks
Definition jkqtpcoordinateaxesstyle.h:121
double minorTickLabelFontSize
fontsize of the minor axis tick labels
Definition jkqtpcoordinateaxesstyle.h:132
QString tickDateTimeFormat
format string for datetime tick labels, see QDateTime::toString() documentation for details on format...
Definition jkqtpcoordinateaxesstyle.h:175
QColor tickLabelColor
color of axis tick labels
Definition jkqtpcoordinateaxesstyle.h:159
bool autoLabelDigits
when true, the digits of the labels are calculated automatically
Definition jkqtpcoordinateaxesstyle.h:114
JKQTPCALabelType tickLabelType
indicates how to draw the labels
Definition jkqtpcoordinateaxesstyle.h:118
JKQTPCADrawMode drawMode1
draw mode of the main (left/bottom) axis
Definition jkqtpcoordinateaxesstyle.h:140
double axisLineOffset
if non-zero, the line of the coordinate axis is moved outside the plot by this amount [pt]....
Definition jkqtpcoordinateaxesstyle.h:234
JKQTPCADrawMode drawMode0
draw mode of the zero axis
Definition jkqtpcoordinateaxesstyle.h:149
double tickLabelFontSize
fontsize of the axis tick labels
Definition jkqtpcoordinateaxesstyle.h:130
QString tickTimeFormat
format string for time tick labels, see QDateTime::toString() documentation for details on format str...
Definition jkqtpcoordinateaxesstyle.h:171
JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle &baseStyle)
QPen getMinorTickPen(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
returns a QPen that can be used for drawing minor axis tick lines
double arrowSizeFactor
factor used to calculate the size of line arrows
Definition jkqtpcoordinateaxesstyle.h:165
double tickLabelAngle
rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)
Definition jkqtpcoordinateaxesstyle.h:222
double tickInsideLength
length of an axis tick inside the plot border in pt
Definition jkqtpcoordinateaxesstyle.h:200
QPen getTickPen(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
returns a QPen that can be used for drawing axis tick lines
QColor labelColor
color of the axis label
Definition jkqtpcoordinateaxesstyle.h:128
QColor minorTickColor
color of minor ticks
Definition jkqtpcoordinateaxesstyle.h:151
QPen getAxisPen(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
returns a QPen that can be used for drawing axis lines
double lineWidth
line width of axis in pt
Definition jkqtpcoordinateaxesstyle.h:163
bool minorTickLabelFullNumber
indicates whether the minor tick labels should be full numbers, or just a number between 0....
Definition jkqtpcoordinateaxesstyle.h:136
void loadSettings(const QSettings &settings, const QString &group=QString("axis/"), const JKQTPCoordinateAxisStyle &defaultStyle=JKQTPCoordinateAxisStyle())
loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings object
double labelFontSize
fontsize of the axis labels
Definition jkqtpcoordinateaxesstyle.h:126
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
Support Class for JKQTPCoordinateAxis, and summarizes all properties that define the visual styling o...
Definition jkqtpcoordinateaxesstyle.h:45
Qt::PenStyle lineStyle
line stye of the grid lines
Definition jkqtpcoordinateaxesstyle.h:74
double lineWidth
width of the grid lines (in pixel)
Definition jkqtpcoordinateaxesstyle.h:72
void saveSettings(QSettings &settings, const QString &group=QString("grid/")) const
saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings object.
bool enabled
indicates whether to draw the major grid lines
Definition jkqtpcoordinateaxesstyle.h:68
QColor lineColor
color of the grid
Definition jkqtpcoordinateaxesstyle.h:70
void loadSettings(const QSettings &settings, const QString &group=QString("grid/"), const JKQTPGridStyle &defaultStyle=JKQTPGridStyle())
loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings object
JKQTPGridStyle(bool isMajor=true)
QFlags< JKQTPCADrawModeElements > JKQTPCADrawMode
drawing mode for a coordinate axis
Definition jkqtptools.h:430
JKQTPLabelPosition
position of the axis labels
Definition jkqtptools.h:508
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89
JKQTPCALabelType
display mode for the (axis) labels
Definition jkqtptools.h:449
JKQTPLabelTickMode
mode of the axis ticks
Definition jkqtptools.h:476