2019-02-08 00:24:46 +08:00
/*
2024-02-06 21:50:49 +08:00
Copyright ( c ) 2008 - 2024 Jan W . Krieger ( < jan @ jkrieger . de > )
2019-02-08 00:24:46 +08:00
This software is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation , either version 2.1 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef JKQTPCOORDINATEAXESSTYLE_H
# define JKQTPCOORDINATEAXESSTYLE_H
# include <QSettings>
# include <QString>
# include <QColor>
2019-05-30 04:40:02 +08:00
# include "jkqtplotter/jkqtptools.h"
2019-06-22 20:21:32 +08:00
# include "jkqtplotter/jkqtplotter_imexport.h"
2022-07-19 16:24:52 +08:00
# include "jkqtplotter/jkqtplotter_configmacros.h"
2022-09-28 06:59:57 +08:00
# if __cplusplus >= 202002L
# include <version>
# ifdef __cpp_lib_format
# include <format>
# endif
# endif
2019-02-08 00:24:46 +08:00
class JKQTBasePlotterStyle ; // forward
2020-09-29 19:19:04 +08:00
/** \brief Support Class for JKQTPCoordinateAxis, and summarizes all properties that define the visual styling of a grid (minor or major), associated with a JKQTPCoordinateAxis
2022-09-25 02:18:08 +08:00
* \ ingroup jkqtpplotter_styling_classes
2020-09-29 19:19:04 +08:00
*
* \ see JKQTPCoordinateAxis , \ ref jkqtpplotter_styling
*
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPGridStyle {
Q_GADGET
public :
JKQTPGridStyle ( bool isMajor = true ) ;
/** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object
*
* \ param settings QSettings - object to read from
* \ param group Group in the QSettings - object to read from
* \ param defaultStyle If a setting cannot be found in \ a settings , default values are taken from this object
* By default , this is a default - constructed object
*/
void loadSettings ( const QSettings & settings , const QString & group = QString ( " grid/ " ) , const JKQTPGridStyle & defaultStyle = JKQTPGridStyle ( ) ) ;
/** \brief saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object.
*
* \ param settings QSettings - object to save to
* \ param group Group in the QSettings - object to save to
*/
void saveSettings ( QSettings & settings , const QString & group = QString ( " grid/ " ) ) const ;
/** \brief indicates whether to draw the major grid lines */
bool enabled ;
/** \brief color of the grid*/
QColor lineColor ;
/** \brief width of the grid lines (in pixel) */
double lineWidth ;
/** \brief line stye of the grid lines */
Qt : : PenStyle lineStyle ;
} ;
2020-09-26 21:58:58 +08:00
/** \brief Support Class for JKQTPCoordinateAxis, which summarizes all properties that define the visual styling of a JKQTPCoordinateAxis
2022-09-25 02:18:08 +08:00
* \ ingroup jkqtpplotter_styling_classes
2019-02-08 00:24:46 +08:00
*
2022-09-25 21:34:05 +08:00
* \ image html jkqtpcoordinateaxis1 . png
*
* \ see JKQTPCoordinateAxis , \ ref jkqtpplotter_styling
2019-02-08 00:24:46 +08:00
*
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxisStyle {
2019-02-08 00:24:46 +08:00
Q_GADGET
public :
JKQTPCoordinateAxisStyle ( ) ;
2022-11-03 22:48:48 +08:00
explicit JKQTPCoordinateAxisStyle ( const JKQTBasePlotterStyle & baseStyle ) ;
2019-02-08 00:24:46 +08:00
/** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object
*
* \ param settings QSettings - object to read from
* \ param group Group in the QSettings - object to read from
* \ param defaultStyle If a setting cannot be found in \ a settings , default values are taken from this object
* By default , this is a default - constructed object
*/
void loadSettings ( const QSettings & settings , const QString & group = QString ( " axis/ " ) , const JKQTPCoordinateAxisStyle & defaultStyle = JKQTPCoordinateAxisStyle ( ) ) ;
/** \brief saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object.
*
* \ param settings QSettings - object to save to
* \ param group Group in the QSettings - object to save to
*/
void saveSettings ( QSettings & settings , const QString & group = QString ( " axis/ " ) ) const ;
/** \brief digits used for tick labels */
int labelDigits ;
/** \brief when \c true, the digits of the labels are calculated automatically */
bool autoLabelDigits ;
/** \brief if \c true, the plotter displays minor axis labels as number between 1 and 10 in some cases */
bool minorTickLabelsEnabled ;
/** \brief indicates how to draw the labels */
2022-09-24 02:43:53 +08:00
JKQTPCALabelType tickLabelType ;
2019-02-08 00:24:46 +08:00
/** \brief mode of the major ticks */
JKQTPLabelTickMode tickMode ;
/** \brief position of the axis label */
JKQTPLabelPosition labelPosition ;
/** \brief fontsize of the axis labels */
double labelFontSize ;
2022-09-24 02:43:53 +08:00
/** \brief color of the axis label */
QColor labelColor ;
2019-02-08 00:24:46 +08:00
/** \brief fontsize of the axis tick labels */
double tickLabelFontSize ;
/** \brief fontsize of the minor axis tick labels */
double minorTickLabelFontSize ;
/** \brief indicates whether to draw a thick axis line at x=0 (zero axis) */
bool showZeroAxis ;
/** \brief indicates whether the minor tick labels should be full numbers, or just a number between 0..10 */
bool minorTickLabelFullNumber ;
/** \brief draw mode of the main (left/bottom) axis */
JKQTPCADrawMode drawMode1 ;
/** \brief draw mode of the secondary (right/top) axis */
JKQTPCADrawMode drawMode2 ;
2022-09-25 21:34:05 +08:00
/** \brief draw mode of the zero axis
*
* \ image html JKQTPCoordinateAxisStyleDrawMode0 . png
*
* \ see \ ref JKQTPlotterGeometricCoordinateAxis0
*/
JKQTPCADrawMode drawMode0 ;
2022-09-24 02:43:53 +08:00
/** \brief color of minor ticks */
QColor minorTickColor ;
/** \brief color of minor tick labels */
QColor minorTickLabelColor ;
2019-02-08 00:24:46 +08:00
/** \brief line width of minor ticks in pt */
double minorTickWidth ;
2022-09-24 02:43:53 +08:00
/** \brief color of axis ticks */
QColor tickColor ;
/** \brief color of axis tick labels */
QColor tickLabelColor ;
2019-02-08 00:24:46 +08:00
/** \brief line width of ticks in pt */
double tickWidth ;
/** \brief line width of axis in pt */
double lineWidth ;
2022-09-24 02:43:53 +08:00
/** \brief factor used to calculate the size of line arrows */
double arrowSizeFactor ;
2019-02-08 00:24:46 +08:00
/** \brief line width of 0-line in pt */
double lineWidthZeroAxis ;
2022-09-24 06:16:57 +08:00
/** \brief format string for time tick labels, see QDateTime::toString() documentation for details on format strings */
2019-02-08 00:24:46 +08:00
QString tickTimeFormat ;
2022-09-24 06:16:57 +08:00
/** \brief format string for date tick labels, see QDateTime::toString() documentation for details on format strings */
2019-02-08 00:24:46 +08:00
QString tickDateFormat ;
2022-09-24 06:16:57 +08:00
/** \brief format string for datetime tick labels, see QDateTime::toString() documentation for details on format strings */
2019-02-08 00:24:46 +08:00
QString tickDateTimeFormat ;
2022-09-28 06:59:57 +08:00
/** \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 */
2022-09-24 06:16:57 +08:00
QString tickPrintfFormat ;
2022-09-28 06:59:57 +08:00
# if __cplusplus >= 202002L || DOXYGEN
# if defined(__cpp_lib_format) || DOXYGEN
/** \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
\ 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 . */
QString tickFormatFormat ;
# endif
# endif
2019-02-08 00:24:46 +08:00
/** \brief minimum number of axis ticks */
unsigned int minTicks ;
2024-10-09 04:00:45 +08:00
/** \brief number of minor grid lines per (major) axis tick interval
2019-02-08 00:24:46 +08:00
*
* \ image html docu_logaxis_set_minorticks . png
* */
unsigned int minorTicks ;
/** \brief length of an axis tick outside the plot border in pt */
double tickOutsideLength ;
/** \brief length of a minor axis tick outside the plot border in pt */
double minorTickOutsideLength ;
/** \brief length of an axis tick inside the plot border in pt */
double tickInsideLength ;
/** \brief length of a minor axis tick inside the plot border in pt */
double minorTickInsideLength ;
/** \brief color of the axis (labels, ticks, axis itself ...) */
QColor axisColor ;
/** \brief distance between tick end and label start in pt */
double tickLabelDistance ;
/** \brief distance between tick label and axis label in pt */
double labelDistance ;
2023-08-22 23:34:50 +08:00
/** \brief rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)
*
* These images show some example rotations :
*
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle - 75 Degree . png
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle - 45 Degree . png
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle - 15 Degree . png
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle0Degree . png
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle15Degree . png
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle45Degree . png
* \ image html axisstyle / JKQTPCoordinateAxisTickLabelAngle75Degree . png
*
*/
2019-02-08 00:24:46 +08:00
double tickLabelAngle ;
2020-09-29 19:19:04 +08:00
/** \brief styling of the major/primary grid */
JKQTPGridStyle majorGridStyle ;
/** \brief styling of the minor/secondary grid */
JKQTPGridStyle minorGridStyle ;
2019-02-08 00:24:46 +08:00
/** \brief color of 0-line */
QColor colorZeroAxis ;
/** \brief pen style of 0-line */
Qt : : PenStyle styleZeroAxis ;
2020-09-29 19:19:04 +08:00
/** \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! */
2019-02-08 00:24:46 +08:00
double axisLineOffset ;
2022-09-24 02:43:53 +08:00
/** \brief returns a QPen that can be used for drawing zero axis lines */
QPen getZeroAxisPen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief returns a QPen that can be used for drawing axis lines */
QPen getAxisPen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief returns a QPen that can be used for drawing axis tick lines */
QPen getTickPen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief returns a QPen that can be used for drawing minor axis tick lines */
QPen getMinorTickPen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief calculates the size of an arrow in pixels */
double getArrowSize ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
2019-02-08 00:24:46 +08:00
} ;
2022-05-24 04:41:57 +08:00
/** \brief Support Class for JKQTPCoordinateAxis, which summarizes all properties that define the visual styling of a JKQTPCoordinateAxis
* used for colorbars outside the plot
2022-09-25 02:18:08 +08:00
* \ ingroup jkqtpplotter_styling_classes
2022-05-24 04:41:57 +08:00
*
* The major difference between this dervied version and the base JKQTPCoordinateAxisStyle are differently initialized members .
* \ see JKQTPCoordinateAxis , \ ref jkqtpplotter_styling
*
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPColorbarCoordinateAxisStyle : public JKQTPCoordinateAxisStyle {
Q_GADGET
public :
/** \copydoc JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle() */
JKQTPColorbarCoordinateAxisStyle ( ) ;
/** \copydoc JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle&) */
2022-11-03 22:48:48 +08:00
explicit JKQTPColorbarCoordinateAxisStyle ( const JKQTBasePlotterStyle & baseStyle ) ;
2022-05-24 04:41:57 +08:00
private :
/** \brief modifies the members to match the requirements of colorbar axes */
void initMembersForColorbars ( ) ;
} ;
2019-02-08 00:24:46 +08:00
# endif // JKQTPCOORDINATEAXESSTYLE_H