2019-02-08 00:24:46 +08:00
/*
2022-07-19 19:40:43 +08:00
Copyright ( c ) 2008 - 2022 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 ( 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/>.
*/
# ifndef JKQTPGRAPHSIMAGEOVERLAYS_H
# define JKQTPGRAPHSIMAGEOVERLAYS_H
# include <QString>
# include <QPainter>
# include <QImage>
# include <QIcon>
2019-06-20 22:06:31 +08:00
# include "jkqtplotter/graphs/jkqtpscatter.h"
2019-05-30 04:40:02 +08:00
# include "jkqtplotter/jkqtptools.h"
2019-02-08 00:24:46 +08:00
# include "jkqtplotter/jkqtpbaseelements.h"
2019-06-20 22:06:31 +08:00
# include "jkqtplotter/graphs/jkqtpimage.h"
2019-06-22 20:21:32 +08:00
# include "jkqtplotter/jkqtplotter_imexport.h"
2019-05-30 04:40:02 +08:00
# include "jkqtplotter/jkqtpimagetools.h"
2019-02-08 00:24:46 +08:00
/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent)
\ ingroup jkqtplotter_imagelots_overlays
\ image html overlayimage . png
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayImage : public JKQTPImageBase {
2019-02-08 00:24:46 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2020-09-29 01:24:17 +08:00
JKQTPOverlayImage ( double x , double y , double width , double height , const bool * data , int Nx , int Ny , QColor colTrue , JKQTBasePlotter * parent = nullptr ) ;
2019-02-08 00:24:46 +08:00
JKQTPOverlayImage ( JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor */
2020-09-29 01:24:17 +08:00
JKQTPOverlayImage ( double x , double y , double width , double height , const bool * data , int Nx , int Ny , QColor colTrue , JKQTPlotter * parent ) ;
2019-02-08 00:24:46 +08:00
JKQTPOverlayImage ( JKQTPlotter * parent ) ;
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
2020-09-21 19:47:54 +08:00
/** \brief return the plotted image only as a QImage */
2019-02-08 00:24:46 +08:00
virtual QImage drawImage ( ) ;
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
/** \brief returns the color to be used for the key label */
2019-04-22 19:27:50 +08:00
virtual QColor getKeyLabelColor ( ) const override ;
2019-02-08 00:24:46 +08:00
2020-09-21 19:47:54 +08:00
/** \copydoc trueColor */
2019-04-22 19:27:50 +08:00
void setTrueColor ( const QColor & __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc trueColor */
2019-04-22 19:27:50 +08:00
QColor getTrueColor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc falseColor */
2019-04-22 19:27:50 +08:00
void setFalseColor ( const QColor & __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc falseColor */
2019-04-22 19:27:50 +08:00
QColor getFalseColor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc Nx */
2019-04-22 19:27:50 +08:00
void setNx ( int __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc Nx */
2019-06-22 20:21:32 +08:00
void setNx ( size_t __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc Nx */
2019-04-22 19:27:50 +08:00
int getNx ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc Ny */
2019-04-22 19:27:50 +08:00
void setNy ( int __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc Ny */
2019-06-22 20:21:32 +08:00
void setNy ( size_t __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc Ny */
2019-04-22 19:27:50 +08:00
int getNy ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc data */
2020-09-29 01:24:17 +08:00
virtual void setData ( const bool * __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc data */
2020-09-29 01:24:17 +08:00
const bool * getData ( ) const ;
2019-02-08 00:24:46 +08:00
2019-04-22 19:27:50 +08:00
/** \brief set the plot-data to a given array \a data with size \a Nx * \a Ny in row-major ordering */
2020-09-29 01:24:17 +08:00
virtual void setData ( const bool * data , int Nx , int Ny ) ;
2019-02-08 00:24:46 +08:00
2019-04-22 19:27:50 +08:00
/** \brief return the data used for plotting as a QVector<double> in row-major data-ordering */
2019-02-08 00:24:46 +08:00
QVector < double > getDataAsDoubleVector ( ) const ;
protected :
/** \brief points to the data array, holding the image */
2020-09-29 01:24:17 +08:00
const bool * data ;
2019-02-08 00:24:46 +08:00
/** \brief width of the data array data in pt */
int Nx ;
/** \brief height of the data array data in pt */
int Ny ;
/** \brief color for \c true pixels */
QColor trueColor ;
/** \brief color for \c false pixels */
QColor falseColor ;
protected :
2019-04-22 19:27:50 +08:00
/** \brief action that calls saveImagePlotAsImage() */
2019-02-08 00:24:46 +08:00
QAction * actSaveImage ;
2019-04-22 19:27:50 +08:00
/** \brief action that calls copyImagePlotAsImage() */
2019-02-08 00:24:46 +08:00
QAction * actCopyImage ;
public :
2019-04-22 19:27:50 +08:00
/** \copydoc JKQTPImageBase::setTitle() */
2019-02-08 00:24:46 +08:00
virtual void setTitle ( const QString & title ) override ;
2019-04-22 19:27:50 +08:00
/** \copydoc JKQTPImageBase::setParent() */
2019-02-08 00:24:46 +08:00
virtual void setParent ( JKQTBasePlotter * parent ) override ;
2023-07-22 20:26:02 +08:00
public Q_SLOTS :
2019-04-22 19:27:50 +08:00
/** \brief save the plotted image as a file with \a filename and format \a outputFormat */
2019-02-08 00:24:46 +08:00
void saveImagePlotAsImage ( const QString & filename = QString ( " " ) , const QByteArray & outputFormat = QByteArray ( ) ) ;
2019-04-22 19:27:50 +08:00
/** \brief copy the plotted image as an image into the clipboard */
2019-02-08 00:24:46 +08:00
void copyImagePlotAsImage ( ) ;
} ;
/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent)
\ ingroup jkqtplotter_imagelots_overlays
In contrast to JKQTPOverlayImage this class draws ist contents as rectangles , not as semi - transparent image . This may lead to nicer results , but could be slower .
Also it is possible to draw other types of markers ( cross , circles , . . . )
\ image html overlayimageenhanced . png
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayImageEnhanced : public JKQTPOverlayImage {
2019-02-08 00:24:46 +08:00
Q_OBJECT
public :
2019-04-22 19:27:50 +08:00
enum OverlayImageEnhancedDrawMode {
DrawAsRectangles ,
DrawAsImage ,
DrawAsSymbols
} ;
2019-02-08 00:24:46 +08:00
/** \brief class constructor */
JKQTPOverlayImageEnhanced ( double x , double y , double width , double height , bool * data , int Nx , int Ny , QColor colTrue , JKQTBasePlotter * parent = nullptr ) ;
JKQTPOverlayImageEnhanced ( JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor */
JKQTPOverlayImageEnhanced ( double x , double y , double width , double height , bool * data , int Nx , int Ny , QColor colTrue , JKQTPlotter * parent ) ;
JKQTPOverlayImageEnhanced ( 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 */
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2020-09-21 19:47:54 +08:00
/** \copydoc symbol */
2019-04-22 19:27:50 +08:00
void setSymbolType ( JKQTPGraphSymbols __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc symbol */
2019-04-22 19:27:50 +08:00
JKQTPGraphSymbols getSymbol ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc symbolLineWidth */
2019-04-22 19:27:50 +08:00
void setSymbolLineWidth ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc symbolLineWidth */
2019-04-22 19:27:50 +08:00
double getSymbolLineWidth ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc drawMode */
2019-04-22 19:27:50 +08:00
void setDrawMode ( OverlayImageEnhancedDrawMode __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc drawMode */
2019-04-22 19:27:50 +08:00
OverlayImageEnhancedDrawMode getDrawMode ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc symbolSizeFactor */
2019-04-22 19:27:50 +08:00
void setSymbolSizeFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc symbolSizeFactor */
2019-04-22 19:27:50 +08:00
double getSymbolSizeFactor ( ) 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-02-08 00:24:46 +08:00
protected :
/** \brief which symbol to use for the datapoints */
JKQTPGraphSymbols symbol ;
/** \brief width (in pt) of the lines used to plot the symbol for the data points */
2019-04-22 19:27:50 +08:00
double symbolLineWidth ;
2019-02-08 00:24:46 +08:00
2019-04-22 19:27:50 +08:00
/** \brief indicates whether to draw filled rectangles, or symbols */
OverlayImageEnhancedDrawMode drawMode ;
2019-02-08 00:24:46 +08:00
/** \brief a rescaling factor for the symbols */
double symbolSizeFactor ;
2022-09-02 20:19:47 +08:00
/** \brief font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
QString m_symbolFontName ;
2019-02-08 00:24:46 +08:00
} ;
/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent)
\ ingroup jkqtplotter_imagelots_overlays
In contrast to JKQTPOverlayImage this class draws ist contents as rectangles , not as semi - transparent image . This may lead to nicer results , but could be slower .
Also it is possible to draw other types of markers ( cross , circles , . . . )
\ image html overlayimageenhanced . png
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPColumnOverlayImageEnhanced : public JKQTPOverlayImageEnhanced {
2019-02-08 00:24:46 +08:00
Q_OBJECT
public :
JKQTPColumnOverlayImageEnhanced ( JKQTBasePlotter * parent = nullptr ) ;
JKQTPColumnOverlayImageEnhanced ( JKQTPlotter * parent ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc imageColumn */
2019-04-22 19:27:50 +08:00
virtual void setImageColumn ( int __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc imageColumn */
2019-04-22 19:27:50 +08:00
int getImageColumn ( ) const ;
2019-02-08 00:24:46 +08:00
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
/** \copydoc JKQTPGraph::usesColumn() */
virtual bool usesColumn ( int c ) const override ;
protected :
2019-04-22 19:27:50 +08:00
/** \brief column to read overlay image from */
2019-02-08 00:24:46 +08:00
int imageColumn ;
} ;
# endif // JKQTPGRAPHSIMAGEOVERLAYS_H