2019-04-22 19:27:50 +08:00
/*
2022-07-19 19:40:43 +08:00
Copyright ( c ) 2008 - 2022 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 jkqtpgraphsrange_H
# define jkqtpgraphsrange_H
2019-04-22 19:27:50 +08:00
# include <QString>
# include <QPainter>
# include <QPair>
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"
2019-05-30 04:40:02 +08:00
# include "jkqtcommon/jkqtpdrawingtools.h"
2019-04-22 19:27:50 +08:00
# include "jkqtplotter/jkqtpgraphsbase.h"
2019-05-30 04:40:02 +08:00
# include "jkqtcommon/jkqtpenhancedpainter.h"
2019-04-22 19:27:50 +08:00
# include "jkqtplotter/jkqtpgraphsbaseerrors.h"
# include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
// forward declarations
class JKQTBasePlotter ;
class JKQTPlotter ;
class JKQTPCoordinateAxis ;
class JKQTPDatastore ;
2019-05-30 04:40:02 +08:00
//class JKQTPColorPaletteStyleAndToolsMixin;
2019-04-22 19:27:50 +08:00
2020-09-20 01:58:50 +08:00
/** \brief simply marks a range (and possibly a centerline) in a plot. This may be used to display e.g. mean +/- stddev
* or a range of interest , or the range of good values , . . .
* \ ingroup jkqtplotter_annotations
*
* \ image html JKQTPRangeBase . png
*
* You can also invert the range , i . e . everything outside the range will be filled ( \ c setInvertedRange ( ) ) :
*
* \ image html JKQTPRangeBase_Inverted . png
2019-04-22 19:27:50 +08:00
*/
2020-09-20 01:58:50 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPRangeBase : public JKQTPPlotElement , public JKQTPGraphLineStyleMixin , public JKQTPGraphFillStyleMixin {
2019-04-22 19:27:50 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2020-09-20 01:58:50 +08:00
JKQTPRangeBase ( JKQTBasePlotter * parent = nullptr ) ;
2019-04-22 19:27:50 +08:00
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor ( ) const override ;
2020-09-21 19:47:54 +08:00
/** \copydoc centerColor */
2019-04-22 19:27:50 +08:00
QColor getCenterColor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc centerStyle */
2019-04-22 19:27:50 +08:00
Qt : : PenStyle getCenterStyle ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc centerLineWidth */
2019-04-22 19:27:50 +08:00
void setCenterLineWidth ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc centerLineWidth */
2019-04-22 19:27:50 +08:00
double getCenterLineWidth ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc rangeMin */
2019-04-22 19:27:50 +08:00
double getRangeMin ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc rangeMax */
2019-04-22 19:27:50 +08:00
double getRangeMax ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc sizeMin */
2019-04-22 19:27:50 +08:00
double getSizeMin ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc sizeMax */
2019-04-22 19:27:50 +08:00
double getSizeMax ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc unlimitedSizeMin */
2019-04-22 19:27:50 +08:00
bool getUnlimitedSizeMin ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc unlimitedSizeMax */
2019-04-22 19:27:50 +08:00
bool getUnlimitedSizeMax ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc rangeCenter */
2019-04-22 19:27:50 +08:00
double getRangeCenter ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc plotCenterLine */
2019-04-22 19:27:50 +08:00
bool getPlotCenterLine ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc invertedRange */
2019-04-22 19:27:50 +08:00
bool getInvertedRange ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc plotRange */
2019-04-22 19:27:50 +08:00
bool getPlotRange ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc fillRange */
2019-04-22 19:27:50 +08:00
bool getFillRange ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc plotRangeLines */
2019-04-22 19:27:50 +08:00
bool getPlotRangeLines ( ) const ;
2023-07-22 20:26:02 +08:00
public Q_SLOTS :
2020-09-21 19:47:54 +08:00
/** \brief set the color of the graph (all lines and filling) */
2020-09-20 01:58:50 +08:00
virtual void setColor ( QColor c ) ;
/** \brief disables all drawing features except the centerline */
void setDrawCenterLineOnly ( ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc centerColor */
2020-09-20 01:58:50 +08:00
void setCenterColor ( const QColor & __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc centerStyle */
2020-09-20 01:58:50 +08:00
void setCenterStyle ( Qt : : PenStyle __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc plotRangeLines */
2020-09-20 01:58:50 +08:00
void setPlotRangeLines ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc fillRange */
2020-09-20 01:58:50 +08:00
void setFillRange ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc plotRange */
2020-09-20 01:58:50 +08:00
void setPlotRange ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc invertedRange */
2020-09-20 01:58:50 +08:00
void setInvertedRange ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc rangeCenter */
2020-09-20 01:58:50 +08:00
void setRangeCenter ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc plotCenterLine */
2020-09-20 01:58:50 +08:00
void setPlotCenterLine ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc unlimitedSizeMax */
2020-09-20 01:58:50 +08:00
void setUnlimitedSizeMax ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc unlimitedSizeMin */
2020-09-20 01:58:50 +08:00
void setUnlimitedSizeMin ( bool __value ) ;
/** \copydoc sizeMax
*
* \ note this also sets unlimitedSizeMax to \ c true
* \ see unlimitedSizeMax
*/
void setSizeMax ( double __value ) ;
/** \copydoc sizeMin
*
* \ note this also sets unlimitedSizeMin to \ c true
* \ see unlimitedSizeMin
*/
void setSizeMin ( double __value ) ;
/** \copydoc rangeMax*/
void setRangeMax ( double __value ) ;
/** \copydoc rangeMin*/
void setRangeMin ( double __value ) ;
2019-04-22 19:27:50 +08:00
protected :
2020-09-20 01:58:50 +08:00
/** \brief min-value of range
* \ image html JKQTPRangeBase . png
*/
2019-04-22 19:27:50 +08:00
double rangeMin ;
2020-09-20 01:58:50 +08:00
/** \brief max-value of range
* \ image html JKQTPRangeBase . png
*/
2019-04-22 19:27:50 +08:00
double rangeMax ;
2020-09-20 01:58:50 +08:00
/** \brief where to plot the center line
* \ image html JKQTPRangeBase . png
*/
2019-04-22 19:27:50 +08:00
double rangeCenter ;
2020-09-20 01:58:50 +08:00
/** \brief if \c unlimitedSizeMin==false, then the range rectangle only extends to this value on the axis perpendicular to the range axis (towards smaller numbers)
*
* \ image html JKQTPRangeBase . png
* \ see unlimitedSizeMin
*/
2019-04-22 19:27:50 +08:00
double sizeMin ;
2020-09-20 01:58:50 +08:00
/** \brief if \c unlimitedSizeMax==false, then the range rectangle only extends to this value on the axis perpendicular to the range axis (towards larger numbers)
*
* \ image html JKQTPRangeBase . png
* \ see unlimitedSizeMax
*/
2019-04-22 19:27:50 +08:00
double sizeMax ;
2020-09-20 01:58:50 +08:00
/** \brief if \c true, the range elongates infinitely in the direction perpendicular to the range axis and towards smaller numbers, otherwise the range rectangle stops at rangeMin
*
* \ image html JKQTPRangeBase . png
* \ see sizeMin
*/
2019-04-22 19:27:50 +08:00
bool unlimitedSizeMin ;
2020-09-20 01:58:50 +08:00
/** \brief if \c true, the range elongates infinitely in the direction perpendicular to the range axis and towards larger numbers, otherwise the range rectangle stops at rangeMin
*
* \ image html JKQTPRangeBase . png
* \ see sizeMax
*/
2019-04-22 19:27:50 +08:00
bool unlimitedSizeMax ;
/** \brief indicates whether to plot a center line */
bool plotCenterLine ;
2020-09-20 01:58:50 +08:00
/** \brief if \c true, fills the parts outside the given range
*
* \ image html JKQTPRangeBase_Inverted . png
*/
2019-04-22 19:27:50 +08:00
bool invertedRange ;
/** \brief if \c true, the range is plotted, if \c false, only the center line is plotted (if \a plotCenterLine is \c true ) */
bool plotRange ;
/** \brief if \c true, draws lines at the range borders \a color */
bool plotRangeLines ;
/** \brief if \c true, this fills the range with \a fillColor */
bool fillRange ;
/** \brief color of the center line graph */
QColor centerColor ;
/** \brief linestyle of the center line graph lines */
Qt : : PenStyle centerStyle ;
/** \brief width (pt) of the center line graph, given in pt */
double centerLineWidth ;
} ;
2020-09-20 01:58:50 +08:00
/** \brief simply marks a range (and possibly a centerline) in a plot. This may be used to display e.g. mean +/- stddev
* or a range of interest , or the range of good values , . . .
* \ ingroup jkqtplotter_annotations
*
* \ image html JKQTPHorizontalRange . png
*
* \ see JKQTPVerticalRange
*
* < b > Explanation of basic features : < / b >
*
* \ copydetails JKQTPRangeBase
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPHorizontalRange : public JKQTPRangeBase {
Q_OBJECT
public :
/** \brief class constructor */
JKQTPHorizontalRange ( JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor */
JKQTPHorizontalRange ( JKQTPlotter * parent ) ;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
/** \brief plots a key marker inside the specified rectangle \a rect */
2023-12-19 05:24:59 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , const QRectF & rect ) override ;
2020-09-20 01:58:50 +08:00
/** \brief get the maximum and minimum x-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
/** \brief get the maximum and minimum y-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
} ;
2019-04-22 19:27:50 +08:00
2020-09-20 01:58:50 +08:00
/** \brief simply marks a range (and possibly a centerline) in a plot. This may be used to display e.g. mean +/- stddev
* or a range of interest , or the range of good values , . . .
* \ ingroup jkqtplotter_annotations
*
* \ image html JKQTPVerticalRange . png
*
* \ see JKQTPHorizontalRange
*
* < b > Explanation of basic features ( using the example of JKQTPHorizontalRange ) : < / b >
*
* \ copydetails JKQTPRangeBase
2019-04-22 19:27:50 +08:00
*/
2020-09-20 01:58:50 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPVerticalRange : public JKQTPRangeBase {
2019-04-22 19:27:50 +08:00
Q_OBJECT
public :
/** \brief class constructor */
JKQTPVerticalRange ( JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor */
JKQTPVerticalRange ( JKQTPlotter * parent ) ;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
/** \brief plots a key marker inside the specified rectangle \a rect */
2023-12-19 05:24:59 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , const QRectF & rect ) override ;
2019-04-22 19:27:50 +08:00
/** \brief get the maximum and minimum x-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
/** \brief get the maximum and minimum y-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
} ;
# endif // jkqtpgraphsrange_H