2019-04-22 19:27:50 +08:00
/*
2024-02-06 21:50:49 +08:00
Copyright ( c ) 2008 - 2024 Jan W . Krieger ( < jan @ jkrieger . de > )
2019-04-22 19:27:50 +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 ( LGPL ) 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 ( LGPL ) for more details .
You should have received a copy of the GNU Lesser General Public License ( LGPL )
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2022-04-25 04:07:39 +08:00
# ifndef jkqtpgraphsbasestylingmixins_H
# define jkqtpgraphsbasestylingmixins_H
2019-04-22 19:27:50 +08:00
# include <QString>
# include <QPainter>
# include <QPen>
# include <QBrush>
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"
2020-09-26 21:58:58 +08:00
# include "jkqtplotter/jkqtpbaseplotter.h"
2019-05-30 04:40:02 +08:00
# include "jkqtcommon/jkqtpdrawingtools.h"
2022-07-19 16:24:52 +08:00
# include "jkqtplotter/jkqtplotter_configmacros.h"
2019-04-22 19:27:50 +08:00
class JKQTPlotter ; // forward
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for the graph line style
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- line color
- line width
- line style ( including custom dash patterns , as in QPen )
- line color , when graph is highlighted
.
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphLineStyleMixin {
2022-08-25 21:17:50 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
Q_GADGET
# endif
2019-04-22 19:27:50 +08:00
public :
/** \brief class constructor */
JKQTPGraphLineStyleMixin ( ) ;
/** \brief initiaize the line style (from the parent plotter) */
2020-09-26 21:58:58 +08:00
void initLineStyle ( JKQTBasePlotter * parent , int & parentPlotStyle , JKQTPPlotStyleType styletype = JKQTPPlotStyleType : : Default ) ;
2019-04-22 19:27:50 +08:00
virtual ~ JKQTPGraphLineStyleMixin ( ) ;
/** \brief set the color of the graph line */
void setLineColor ( const QColor & __value ) ;
2022-09-25 21:23:52 +08:00
/** \brief set the color of the graph line */
void setLineColor ( const QColor & __value , double alpha ) ;
2019-04-22 19:27:50 +08:00
/** \brief get the color of the graph line */
QColor getLineColor ( ) const ;
2024-02-11 21:18:50 +08:00
/** \brief sets the line-color as an inverted version of the given color */
void setLineColorInvertedFrom ( QColor __noninvertedColor ) ;
2019-04-22 19:27:50 +08:00
/** \brief set the style of the graph line */
void setLineStyle ( Qt : : PenStyle __value ) ;
/** \brief get the style of the graph line */
Qt : : PenStyle getLineStyle ( ) const ;
/** \brief set the line width of the graph line (in pt) */
void setLineWidth ( double __value ) ;
/** \brief get the line width of the graph line (in pt) */
double getLineWidth ( ) const ;
/** \brief sets the dash offset for a custom dash style
* \ see https : //doc.qt.io/qt-5/qpen.html#setDashOffset
*/
void setLineDashOffset ( qreal offset ) ;
/** \brief returns the dash offset for a custom dash style
* \ see https : //doc.qt.io/qt-5/qpen.html#setDashOffset
*/
qreal getLineDashOffset ( ) const ;
/** \brief sets the dash pattern for a custom dash style
* \ see https : //doc.qt.io/qt-5/qpen.html#setDashPattern
*/
void setLineDashPattern ( const QVector < qreal > & pattern ) ;
/** \brief gets the dash pattern for a custom dash style
* \ see https : //doc.qt.io/qt-5/qpen.html#setDashPattern
*/
QVector < qreal > getLineDashPattern ( ) const ;
/** \brief sets the join style
* \ see https : //doc.qt.io/qt-5/qpen.html#setJoinStyle
*/
void setLineJoinStyle ( Qt : : PenJoinStyle style ) ;
/** \brief returns the join style
* \ see https : //doc.qt.io/qt-5/qpen.html#setJoinStyle
*/
Qt : : PenJoinStyle getLineJoinStyle ( ) const ;
/** \brief sets the cap style
* \ see https : //doc.qt.io/qt-5/qpen.html#setCapStyle
*/
void setLineCapStyle ( Qt : : PenCapStyle style ) ;
/** \brief gets the cap style
* \ see https : //doc.qt.io/qt-5/qpen.html#setCapStyle
*/
Qt : : PenCapStyle getLineCapStyle ( ) const ;
2019-04-24 05:50:06 +08:00
/** \brief sets the brush used to fill the line area
* \ see https : //doc.qt.io/qt-5/qpen.html#setBrush
*/
void setLineBrush ( const QBrush & style ) ;
/** \brief gets the brush used to fill the line area
* \ see https : //doc.qt.io/qt-5/qpen.html#setBrush
*/
QBrush getLineBrush ( ) const ;
2019-04-22 19:27:50 +08:00
/** \brief set the color of the graph line when highlighted */
void setHighlightingLineColor ( const QColor & __value ) ;
2022-09-25 21:23:52 +08:00
/** \brief set the color of the graph line when highlighted */
void setHighlightingLineColor ( const QColor & __value , double alpha ) ;
2019-04-22 19:27:50 +08:00
/** \brief get the color of the graph line when highlighted */
QColor getHighlightingLineColor ( ) const ;
2022-11-01 03:34:01 +08:00
/** \brief returns the linewidth for drawing lines in a key entry with \a keyRect for the symbol, using \a painter and \a parent . */
double getKeyLineWidthPx ( JKQTPEnhancedPainter & painter , const QRectF & keyRect , const JKQTBasePlotter * parent ) const ;
/** \brief constructs a QPen from the line styling properties */
QPen getLinePen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief constructs a QPen from the line styling properties, suitable for drawing rectangles with sharp edges */
QPen getLinePenForRects ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief constructs a QPen from the line styling properties */
QPen getHighlightingLinePen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief constructs a QPen from the line styling properties, suitable for drawing rectangle with sharp corners */
QPen getHighlightingLinePenForRects ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
/** \brief constructs a QPen from the line styling properties, but uses getKeyLineWidthPx() for the width, i.e. constructs a pen for drawing lines in key-symbols */
QPen getKeyLinePen ( JKQTPEnhancedPainter & painter , const QRectF & rect , JKQTBasePlotter * parent ) const ;
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2019-04-22 19:27:50 +08:00
Q_PROPERTY ( QColor highlightingLineColor MEMBER m_highlightingLineColor READ getHighlightingLineColor WRITE setHighlightingLineColor )
Q_PROPERTY ( QColor lineColor MEMBER m_lineColor READ getLineColor WRITE setLineColor )
Q_PROPERTY ( Qt : : PenStyle lineStyle MEMBER m_lineStyle READ getLineStyle WRITE setLineStyle )
Q_PROPERTY ( double lineWidth MEMBER m_lineWidth READ getLineWidth WRITE setLineWidth )
2022-07-19 16:24:52 +08:00
# endif
2019-04-22 19:27:50 +08:00
private :
2019-05-06 01:31:20 +08:00
/** \brief graph line pen */
2019-04-22 19:27:50 +08:00
QPen m_linePen ;
2019-05-06 01:31:20 +08:00
/** \brief width of the graph lines, given in pt */
2019-04-22 19:27:50 +08:00
double m_lineWidth ;
/** \brief line pen for the highlighted look */
QColor m_highlightingLineColor ;
protected :
} ;
2022-08-25 21:17:50 +08:00
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for a line-graph compression algorithm
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- activate compression ( improves plotting speed , but decreases detail level )
- level of retained details
.
\ image html JKQTPSimplifyPolyLines_agressive . png
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphLinesCompressionMixin {
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
Q_GADGET
# endif
public :
/** \brief class constructor */
JKQTPGraphLinesCompressionMixin ( ) ;
virtual ~ JKQTPGraphLinesCompressionMixin ( ) ;
/** \copydoc useNonvisibleLineCompression */
void setUseNonvisibleLineCompression ( bool _useNonvisibleLineCompression ) ;
/** \copydoc useNonvisibleLineCompression */
bool getUseNonvisibleLineCompression ( ) const ;
/** \copydoc useNonvisibleLineCompression */
void setNonvisibleLineCompressionAgressiveness ( double Agressiveness ) ;
/** \copydoc useNonvisibleLineCompression */
double getNonvisibleLineCompressionAgressiveness ( ) const ;
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
Q_PROPERTY ( bool useNonvisibleLineCompression MEMBER useNonvisibleLineCompression READ getUseNonvisibleLineCompression WRITE setUseNonvisibleLineCompression )
Q_PROPERTY ( double nonvisibleLineCompressionAgressiveness MEMBER nonvisibleLineCompressionAgressiveness READ getNonvisibleLineCompressionAgressiveness WRITE setNonvisibleLineCompressionAgressiveness )
# endif
private :
/** \brief use an optimization algorithm that tries to reduce the number of lines that
* overlap each other ( i . e . for noisy data or a low zoom ) and thus improves
* drawing speed
*
* When the property useNonvisibleLineCompression is activated ( \ c true ) , the graph class
* uses the algorithm implemented in JKQTPSimplifyPolyLines ( ) to simplify the task of plotting .
*
* \ image html JKQTPSimplifyPolyLines . png
*
* \ note This option is designed to not alter the plot representation significantly ,
* but of course it may . . .
*
* \ see JKQTPSimplifyPolyLines ( ) setUseNonvisibleLineCompression ( ) , getUseNonvisibleLineCompression ( )
*/
bool m_useNonvisibleLineCompression ;
/** \brief this sets the agressiveness of the option useNonvisibleLineCompression
*
* Basically the compressed groups will have a size of nonvisibleLineCompressionAgressiveness * pen . linewidth
*
* The default setting is \ c 1.0 , larger settings will lead to better compression ( and faster plotting ) , but less detailed
* plots , whereas smaller settings will increase the detail - level , but also increase plotting time .
*
* \ image html JKQTPSimplifyPolyLines_agressive . png
*
* \ note This option is designed to not alter the plot representation significantly ,
* but of course it may . . .
*
* \ see JKQTPSimplifyPolyLines ( ) setUseNonvisibleLineCompression ( ) , getUseNonvisibleLineCompression ( )
*/
double m_nonvisibleLineCompressionAgressiveness ;
protected :
} ;
2019-04-22 19:27:50 +08:00
2020-08-23 19:13:53 +08:00
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for the graph line style of lines
with a decorator ( i . e . an arrow ) at their head . It extends JKQTPGraphLineStyleMixin
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- head / arrow style
.
\ see JKQTPGraphDecoratedLineStyleMixin for a Mix - In for both ends
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphDecoratedHeadLineStyleMixin : public JKQTPGraphLineStyleMixin {
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2022-07-19 16:24:52 +08:00
Q_GADGET
# endif
2020-08-23 19:13:53 +08:00
public :
/** \brief class constructor */
JKQTPGraphDecoratedHeadLineStyleMixin ( ) ;
/** \brief initiaize the line style (from the parent plotter) */
2020-09-26 21:58:58 +08:00
void initDecoratedHeadLineStyle ( JKQTBasePlotter * parent , int & parentPlotStyle , JKQTPPlotStyleType styletype = JKQTPPlotStyleType : : Default ) ;
2020-08-23 19:13:53 +08:00
virtual ~ JKQTPGraphDecoratedHeadLineStyleMixin ( ) ;
/** \brief set the head decorator style */
void setHeadDecoratorStyle ( const JKQTPLineDecoratorStyle & __value ) ;
/** \brief get the head decorator style */
JKQTPLineDecoratorStyle getHeadDecoratorStyle ( ) const ;
/** \copydoc m_headDecoratorSizeFactor */
void setHeadDecoratorSizeFactor ( const double & __value ) ;
/** \copydoc m_headDecoratorSizeFactor */
double getHeadDecoratorSizeFactor ( ) const ;
/** \brief calculates the tail decorator size from the line width \a line_width, using m_headDecoratorSizeFactor and a non-linear scaling function
*
* \ see JKQTPLineDecoratorStyleCalcDecoratorSize ( )
*/
double calcHeadDecoratorSize ( double line_width ) const ;
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2020-08-23 19:13:53 +08:00
Q_PROPERTY ( JKQTPLineDecoratorStyle headDecoratorStyle MEMBER m_headDecoratorStyle READ getHeadDecoratorStyle WRITE setHeadDecoratorStyle )
Q_PROPERTY ( double headDecoratorSizeFactor MEMBER m_headDecoratorSizeFactor READ getHeadDecoratorSizeFactor WRITE setHeadDecoratorSizeFactor )
2022-07-19 16:24:52 +08:00
# endif
2020-08-23 19:13:53 +08:00
private :
/** \brief head decorator style */
JKQTPLineDecoratorStyle m_headDecoratorStyle ;
/** \brief head decorator size-factor, used to calculate the size of the arrow from the line width */
double m_headDecoratorSizeFactor ;
} ;
2020-08-22 00:31:58 +08:00
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for the graph line style of lines
with decorators ( i . e . arrows ) at their ends . It extends JKQTPGraphLineStyleMixin
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- head / tail arrow style
.
2020-08-23 19:13:53 +08:00
\ see JKQTPGraphDecoratedHeadLineStyleMixin for a Mix - In for one end ( head ) only
2020-08-22 00:31:58 +08:00
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphDecoratedLineStyleMixin : public JKQTPGraphLineStyleMixin {
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2022-07-19 16:24:52 +08:00
Q_GADGET
# endif
2020-08-22 00:31:58 +08:00
public :
/** \brief class constructor */
JKQTPGraphDecoratedLineStyleMixin ( ) ;
/** \brief initiaize the line style (from the parent plotter) */
2020-09-26 21:58:58 +08:00
void initDecoratedLineStyle ( JKQTBasePlotter * parent , int & parentPlotStyle , JKQTPPlotStyleType styletype = JKQTPPlotStyleType : : Default ) ;
2020-08-22 00:31:58 +08:00
virtual ~ JKQTPGraphDecoratedLineStyleMixin ( ) ;
/** \brief set the head decorator style */
void setHeadDecoratorStyle ( const JKQTPLineDecoratorStyle & __value ) ;
/** \brief get the head decorator style */
JKQTPLineDecoratorStyle getHeadDecoratorStyle ( ) const ;
/** \brief set the tail decorator style */
void setTailDecoratorStyle ( const JKQTPLineDecoratorStyle & __value ) ;
/** \brief get the tail decorator style */
JKQTPLineDecoratorStyle getTailDecoratorStyle ( ) const ;
/** \copydoc m_headDecoratorSizeFactor */
void setHeadDecoratorSizeFactor ( const double & __value ) ;
/** \copydoc m_headDecoratorSizeFactor */
double getHeadDecoratorSizeFactor ( ) const ;
/** \copydoc m_tailDecoratorSizeFactor */
void setTailDecoratorSizeFactor ( const double & __value ) ;
/** \copydoc m_tailDecoratorSizeFactor */
double getTailDecoratorSizeFactor ( ) const ;
2020-08-23 19:13:53 +08:00
/** \brief calculates the tail decorator size from the line width \a line_width, using m_tailDecoratorSizeFactor and a non-linear scaling function
*
* \ see JKQTPLineDecoratorStyleCalcDecoratorSize ( )
*/
double calcTailDecoratorSize ( double line_width ) const ;
/** \brief calculates the tail decorator size from the line width \a line_width, using m_headDecoratorSizeFactor and a non-linear scaling function
*
* \ see JKQTPLineDecoratorStyleCalcDecoratorSize ( )
*/
double calcHeadDecoratorSize ( double line_width ) const ;
2020-08-22 00:31:58 +08:00
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2020-08-22 00:31:58 +08:00
Q_PROPERTY ( JKQTPLineDecoratorStyle headDecoratorStyle MEMBER m_headDecoratorStyle READ getHeadDecoratorStyle WRITE setHeadDecoratorStyle )
Q_PROPERTY ( JKQTPLineDecoratorStyle tailDecoratorStyle MEMBER m_tailDecoratorStyle READ getTailDecoratorStyle WRITE setTailDecoratorStyle )
Q_PROPERTY ( double headDecoratorSizeFactor MEMBER m_headDecoratorSizeFactor READ getHeadDecoratorSizeFactor WRITE setHeadDecoratorSizeFactor )
Q_PROPERTY ( double tailDecoratorSizeFactor MEMBER m_tailDecoratorSizeFactor READ getTailDecoratorSizeFactor WRITE setTailDecoratorSizeFactor )
2022-07-19 16:24:52 +08:00
# endif
2020-08-22 00:31:58 +08:00
private :
/** \brief head decorator style */
JKQTPLineDecoratorStyle m_headDecoratorStyle ;
/** \brief tail decorator style */
JKQTPLineDecoratorStyle m_tailDecoratorStyle ;
/** \brief head decorator size-factor, used to calculate the size of the arrow from the line width */
double m_headDecoratorSizeFactor ;
/** \brief tail decorator size-factor, used to calculate the size of the arrow from the line width */
double m_tailDecoratorSizeFactor ;
} ;
2019-04-22 19:27:50 +08:00
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for the graph symbols style
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- symbol style
- symbol size
- symbol ( outline ) color
- symbol fill color ( not required for all symbols )
- symbol ( line ) width
2022-09-02 20:19:47 +08:00
- symbol font name ( family ) for character symbols \ c JKQTPCharacterSymbol + QChar ( ' ' ) . unicode ( )
2019-04-22 19:27:50 +08:00
.
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphSymbolStyleMixin {
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2022-07-19 16:24:52 +08:00
Q_GADGET
# endif
2019-04-22 19:27:50 +08:00
public :
/** \brief class constructor */
JKQTPGraphSymbolStyleMixin ( ) ;
/** \brief initiaize the symbol style (from the parent plotter) */
2020-09-26 21:58:58 +08:00
void initSymbolStyle ( JKQTBasePlotter * parent , int & parentPlotStyle , JKQTPPlotStyleType styletype = JKQTPPlotStyleType : : Default ) ;
2019-04-22 19:27:50 +08:00
virtual ~ JKQTPGraphSymbolStyleMixin ( ) ;
/** \brief set the type of the graph symbol */
void setSymbolType ( JKQTPGraphSymbols __value ) ;
/** \brief get the type of the graph symbol */
JKQTPGraphSymbols getSymbolType ( ) const ;
/** \brief set the size (=diameter in pt) of the graph symbol (in pt) */
void setSymbolSize ( double __value ) ;
/** \brief get the size (=diameter in pt) of the graph symbol (in pt) */
double getSymbolSize ( ) const ;
/** \brief set the color of the graph symbols */
void setSymbolColor ( const QColor & __value ) ;
/** \brief set the color of the graph symbols */
2022-09-25 21:23:52 +08:00
void setSymbolColor ( const QColor & __value , double alpha ) ;
/** \brief set the color of the graph symbols */
2019-04-22 19:27:50 +08:00
QColor getSymbolColor ( ) const ;
/** \brief set the color of filling of the graph symbols */
void setSymbolFillColor ( const QColor & __value ) ;
/** \brief set the color of filling of the graph symbols */
2022-09-25 21:23:52 +08:00
void setSymbolFillColor ( const QColor & __value , double alpha ) ;
/** \brief set the color of filling of the graph symbols */
2019-04-22 19:27:50 +08:00
QColor getSymbolFillColor ( ) const ;
2022-09-25 21:23:52 +08:00
/** \brief set alpha-value of symbol outline and filling */
void setSymbolAlpha ( double alpha ) ;
2019-04-22 19:27:50 +08:00
/** \brief set the line width of the graph symbol outline (in pt) */
void setSymbolLineWidth ( double __value ) ;
/** \brief get the line width of the graph symbol outline (in pt) */
double getSymbolLineWidth ( ) const ;
2022-09-02 20:19:47 +08:00
/** \brief set the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
void setSymbolFontName ( const QString & __value ) ;
/** \brief get the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
QString getSymbolFontName ( ) const ;
2019-04-22 19:27:50 +08:00
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2019-04-22 19:27:50 +08:00
Q_PROPERTY ( JKQTPGraphSymbols symbolType MEMBER m_symbolType READ getSymbolType WRITE setSymbolType )
Q_PROPERTY ( QColor symbolColor MEMBER m_symbolColor READ getSymbolColor WRITE setSymbolColor )
Q_PROPERTY ( QColor symbolFillColor MEMBER m_symbolFillColor READ getSymbolFillColor WRITE setSymbolFillColor )
Q_PROPERTY ( double symbolSize MEMBER m_symbolSize READ getSymbolSize WRITE setSymbolSize )
Q_PROPERTY ( double symbolLineWidth MEMBER m_symbolLineWidth READ getSymbolLineWidth WRITE setSymbolLineWidth )
2022-09-02 20:19:47 +08:00
Q_PROPERTY ( QString symbolFontName MEMBER m_symbolFontName READ getSymbolFontName WRITE setSymbolFontName )
2022-07-19 16:24:52 +08:00
# endif
2022-09-02 20:19:47 +08:00
private :
2019-04-22 19:27:50 +08:00
/** \brief which symbol to use for the datapoints */
JKQTPGraphSymbols m_symbolType ;
/** \brief size (diameter in pt) of the symbol for the data points, given in pt */
double m_symbolSize ;
/** \brief (outline) color of the symbol */
QColor m_symbolColor ;
/** \brief color of the symbol filling */
QColor m_symbolFillColor ;
/** \brief width (in pt) of the lines used to plot the symbol for the data points, given in pt */
double m_symbolLineWidth ;
2022-09-02 20:19:47 +08:00
/** \brief font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
QString m_symbolFontName ;
2019-04-22 19:27:50 +08:00
protected :
2019-05-06 01:31:20 +08:00
/** \brief constructs a QPen from the line styling properties */
2019-04-22 19:27:50 +08:00
QPen getSymbolPen ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
2019-05-06 01:31:20 +08:00
/** \brief constructs a QPen from the line styling properties */
2019-04-22 19:27:50 +08:00
QBrush getSymbolBrush ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
2022-09-02 20:19:47 +08:00
/** \brief generate a QFont for darwing symbols */
QFont getSymbolFont ( ) const ;
2019-04-22 19:27:50 +08:00
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
2019-05-11 21:56:11 +08:00
\ param parent parent JKQTBasePlotter of the graph that uses this mix - in ( used e . g . for line - width transformation )
2019-04-22 19:27:50 +08:00
\ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to draw to
\ param x x - coordinate of the symbol center
\ param y y - coordinate of the symbol center
*/
2022-09-02 20:19:47 +08:00
inline void plotStyledSymbol ( JKQTBasePlotter * parent , JKQTPEnhancedPainter & painter , double x , double y ) const
{
JKQTPPlotSymbol ( painter , x , y , m_symbolType , parent - > pt2px ( painter , m_symbolSize ) , parent - > pt2px ( painter , m_symbolLineWidth * parent - > getLineWidthMultiplier ( ) ) , m_symbolColor , m_symbolFillColor , getSymbolFont ( ) ) ;
}
2019-04-22 19:27:50 +08:00
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
2019-05-11 21:56:11 +08:00
\ param parent parent JKQTBasePlotter of the graph that uses this mix - in ( used e . g . for line - width transformation )
2019-04-22 19:27:50 +08:00
\ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to draw to
\ param x x - coordinate of the symbol center
\ param y y - coordinate of the symbol center
\ param symbolSize size of the symbol
*/
2022-09-02 20:19:47 +08:00
inline void plotStyledSymbol ( JKQTBasePlotter * parent , JKQTPEnhancedPainter & painter , double x , double y , double symbolSize ) const
{
JKQTPPlotSymbol ( painter , x , y , m_symbolType , symbolSize , parent - > pt2px ( painter , m_symbolLineWidth * parent - > getLineWidthMultiplier ( ) ) , m_symbolColor , m_symbolFillColor , getSymbolFont ( ) ) ;
}
2019-04-22 19:27:50 +08:00
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
2019-05-11 21:56:11 +08:00
\ param parent parent JKQTBasePlotter of the graph that uses this mix - in ( used e . g . for line - width transformation )
2019-04-22 19:27:50 +08:00
\ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to draw to
\ param x x - coordinate of the symbol center
\ param y y - coordinate of the symbol center
\ param type type of the symbol
*/
2022-09-02 20:19:47 +08:00
inline void plotStyledSymbol ( JKQTBasePlotter * parent , JKQTPEnhancedPainter & painter , double x , double y , JKQTPGraphSymbols type ) const
{
JKQTPPlotSymbol ( painter , x , y , type , parent - > pt2px ( painter , m_symbolSize ) , parent - > pt2px ( painter , m_symbolLineWidth * parent - > getLineWidthMultiplier ( ) ) , m_symbolColor , m_symbolFillColor , getSymbolFont ( ) ) ;
}
2019-04-22 19:27:50 +08:00
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
2019-05-11 21:56:11 +08:00
\ param parent parent JKQTBasePlotter of the graph that uses this mix - in ( used e . g . for line - width transformation )
2019-04-22 19:27:50 +08:00
\ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to draw to
\ param x x - coordinate of the symbol center
\ param y y - coordinate of the symbol center
\ param color color of the symbol
\ param fillColor fill color of the symbol
*/
2022-09-02 20:19:47 +08:00
inline void plotStyledSymbol ( JKQTBasePlotter * parent , JKQTPEnhancedPainter & painter , double x , double y , QColor color , QColor fillColor ) const
{
JKQTPPlotSymbol ( painter , x , y , m_symbolType , parent - > pt2px ( painter , m_symbolSize ) , parent - > pt2px ( painter , m_symbolLineWidth * parent - > getLineWidthMultiplier ( ) ) , color , fillColor , getSymbolFont ( ) ) ;
}
2022-08-30 15:44:40 +08:00
/** \brief returns the symbol linewidth for drawing symbols in a key entry with \a keyRect for the symbol, using \a painter and \a parent . \a maxSymbolSizeFracton specifies the maximum fraction of \a keyRect to be used for the symbol. */
double getKeySymbolLineWidthPx ( JKQTPEnhancedPainter & painter , const QRectF & keyRect , const JKQTBasePlotter * parent , double maxSymbolSizeFracton = 0.9 ) const ;
/** \brief returns the symbol size for drawing symbols in a key entry with \a keyRect for the symbol, using \a painter and \a parent . \a maxSymbolSizeFracton specifies the maximum fraction of \a keyRect to be used for the symbol. */
double getKeySymbolSizePx ( JKQTPEnhancedPainter & painter , const QRectF & keyRect , const JKQTBasePlotter * parent , double maxSymbolSizeFracton = 0.9 ) const ;
2019-04-22 19:27:50 +08:00
} ;
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for the graph filling (NOT the symbol filling though!)
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- fill style
- fill color
- fill texture / gradient / matrix ( if required by fill style )
.
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphFillStyleMixin {
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2022-07-19 16:24:52 +08:00
Q_GADGET
# endif
2019-04-22 19:27:50 +08:00
public :
/** \brief class constructor */
JKQTPGraphFillStyleMixin ( ) ;
/** \brief initiaize the fill style (from the parent plotter) */
2020-09-26 21:58:58 +08:00
void initFillStyle ( JKQTBasePlotter * parent , int & parentPlotStyle , JKQTPPlotStyleType styletype = JKQTPPlotStyleType : : Default ) ;
2022-05-12 04:55:23 +08:00
/** \brief initiaize the fill style from another JKQTPGraphFillStyleMixin \a other by inverting its fill color */
void initFillStyleInvertedColor ( JKQTPGraphFillStyleMixin * other ) ;
2019-04-22 19:27:50 +08:00
virtual ~ JKQTPGraphFillStyleMixin ( ) ;
/** \brief set the fill style of the graph */
void setFillStyle ( Qt : : BrushStyle __value ) ;
/** \brief get the fill style of the graph */
Qt : : BrushStyle getFillStyle ( ) const ;
/** \brief set the color of the graph filling */
void setFillColor ( const QColor & __value ) ;
/** \brief set the color of the graph filling */
2022-09-25 21:23:52 +08:00
void setFillColor ( const QColor & __value , double alpha ) ;
/** \brief set the color of the graph filling */
2019-04-22 19:27:50 +08:00
QColor getFillColor ( ) const ;
/** \brief set the color of the graph filling and sets fill style to Qt::TexturePattern */
void setFillTexture ( const QPixmap & __value ) ;
/** \brief set the color of the graph filling and sets fill style to Qt::TexturePattern */
void setFillTexture ( const QImage & __value ) ;
/** \brief set the color of the graph filling */
QPixmap getFillTexture ( ) const ;
/** \brief set the color of the graph filling */
QImage getFillTextureImage ( ) const ;
/** \brief set the filling of the graph to a gradient and sets fill style to a gradient setting */
void setFillGradient ( const QGradient & __value ) ;
/** \brief get the gradient object of the graph filling */
const QGradient * getFillGradient ( ) const ;
/** \brief sets a fill brush (overwrites all internal properties!) */
void setFillBrush ( const QBrush & b ) ;
/** \brief sets a fill transformation */
void setFillTransform ( const QTransform & b ) ;
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2019-04-22 19:27:50 +08:00
Q_PROPERTY ( Qt : : BrushStyle fillStyle MEMBER m_fillStyle READ getFillStyle WRITE setFillStyle )
Q_PROPERTY ( QColor fillColor MEMBER m_fillColor READ getFillColor WRITE setFillColor )
2022-07-19 16:24:52 +08:00
# endif
2022-05-12 04:55:23 +08:00
/** \brief constructs a QBrush from the graph fill styling properties */
QBrush getFillBrush ( JKQTPEnhancedPainter & painter , JKQTBasePlotter * parent ) const ;
2019-04-22 19:27:50 +08:00
private :
/** \brief fill style of the graph */
QBrush m_fillBrush ;
/** \brief last fill color of the graph */
QColor m_fillColor ;
protected :
} ;
2020-09-19 20:41:53 +08:00
/** \brief This Mix-In class provides setter/getter methods, storage and other facilities for the graph line and fill style
* \ ingroup jkqtplotter_basegraphs_stylemixins
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphLineAndFillStyleMixin : public JKQTPGraphFillStyleMixin , public JKQTPGraphLineStyleMixin {
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2022-07-19 16:24:52 +08:00
Q_GADGET
# endif
2020-09-19 20:41:53 +08:00
public :
/** \brief class constructor */
JKQTPGraphLineAndFillStyleMixin ( ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc m_drawLine */
2020-09-19 20:41:53 +08:00
void setDrawLine ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc m_drawLine */
2020-09-19 20:41:53 +08:00
bool getDrawLine ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc m_drawLine */
2020-09-19 20:41:53 +08:00
bool doDrawLine ( ) const ;
2020-09-19 20:55:46 +08:00
2020-09-21 19:47:54 +08:00
/** \copydoc m_fillCurve */
2020-09-19 20:55:46 +08:00
void setFillCurve ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc m_fillCurve */
2020-09-19 20:55:46 +08:00
bool getFillCurve ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc m_fillCurve */
2020-09-19 20:55:46 +08:00
bool doFillCurve ( ) const ;
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2020-09-19 20:41:53 +08:00
Q_PROPERTY ( bool drawLine MEMBER m_drawLine READ getDrawLine WRITE setDrawLine )
2020-09-19 20:55:46 +08:00
Q_PROPERTY ( bool fillCurve MEMBER m_fillCurve READ getFillCurve WRITE setFillCurve )
2022-07-19 16:24:52 +08:00
# endif
2020-09-19 20:41:53 +08:00
private :
/** \brief indicates whether to draw a line on the circumference of the described area (i.e. along the data points from \c xColumn and \c yColumn as well as \c xColumn and \c yColumn2 or not */
bool m_drawLine ;
2020-09-19 20:55:46 +08:00
/** \brief indicates whether to fill the space between the curve and the x-axis */
bool m_fillCurve ;
2020-09-19 20:41:53 +08:00
} ;
2019-04-22 19:27:50 +08:00
/*! \brief This Mix-In class provides setter/getter methods, storage and other facilities for text in graphs
\ ingroup jkqtplotter_basegraphs_stylemixins
supported properties :
- font name
- font size
- text color
.
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphTextStyleMixin {
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2022-07-19 16:24:52 +08:00
Q_GADGET
# endif
2019-04-22 19:27:50 +08:00
public :
/** \brief class constructor */
JKQTPGraphTextStyleMixin ( JKQTBasePlotter * parent ) ;
/** \brief initiaize the fill style (from the parent plotter) */
2020-09-26 21:58:58 +08:00
void initTextStyle ( JKQTBasePlotter * parent , int & parentPlotStyle , JKQTPPlotStyleType styletype = JKQTPPlotStyleType : : Default ) ;
2019-04-22 19:27:50 +08:00
virtual ~ JKQTPGraphTextStyleMixin ( ) ;
/** \brief set the base font size of text */
void setTextFontSize ( double __value ) ;
/** \brief get the base font size of text */
double getTextFontSize ( ) const ;
/** \brief set the base font name of text */
void setTextFontName ( const QString & __value ) ;
/** \brief get the base font name of text */
QString getTextFontName ( ) const ;
/** \brief set the color of the text */
void setTextColor ( const QColor & __value ) ;
/** \brief set the color of the text */
2022-09-25 21:23:52 +08:00
void setTextColor ( const QColor & __value , double alpha ) ;
/** \brief set the color of the text */
2019-04-22 19:27:50 +08:00
QColor getTextColor ( ) const ;
2022-07-19 19:40:43 +08:00
# ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
2019-04-22 19:27:50 +08:00
Q_PROPERTY ( QColor textColor MEMBER m_textColor READ getTextColor WRITE setTextColor )
Q_PROPERTY ( double textFontSize MEMBER m_textFontSize READ getTextFontSize WRITE setTextFontSize )
Q_PROPERTY ( QString textFontName MEMBER m_textFontName READ getTextFontName WRITE setTextFontName )
2022-07-19 16:24:52 +08:00
# endif
2019-04-22 19:27:50 +08:00
private :
/** \brief color of the text */
QColor m_textColor ;
/** \brief base font size of text */
double m_textFontSize ;
/** \brief name of the font to be used for the text */
QString m_textFontName ;
protected :
} ;
# endif // jkqtpgraphsbasestylingmixins_H