2015-07-11 18:56:02 +08:00
/*
2019-05-19 04:41:38 +08:00
Copyright ( c ) 2008 - 2019 Jan W . Krieger
2015-07-11 18:56:02 +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
2019-02-08 00:24:46 +08:00
the Free Software Foundation , either version 2.1 of the License , or
2015-07-11 18:56:02 +08:00
( 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/>.
*/
2018-12-19 00:13:18 +08:00
# ifndef jkqtpgraphsimage_H
# define jkqtpgraphsimage_H
2015-07-11 18:56:02 +08:00
# 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"
2018-11-26 03:25:44 +08:00
# include "jkqtplotter/jkqtpbaseelements.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"
2015-07-11 18:56:02 +08:00
/*! \brief base class for plotting an image
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_imagelots_elements
2015-07-11 18:56:02 +08:00
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPImageBase : public JKQTPGraph {
2015-07-11 18:56:02 +08:00
Q_OBJECT
public :
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 17:49:29 +08:00
JKQTPImageBase ( JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param parent parent plotter object
*
*/
2019-01-20 17:49:29 +08:00
JKQTPImageBase ( double x , double y , double width , double height , JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 23:15:10 +08:00
JKQTPImageBase ( JKQTPlotter * parent ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param parent parent plotter object
*
*/
2019-01-20 23:15:10 +08:00
JKQTPImageBase ( double x , double y , double width , double height , JKQTPlotter * parent ) ;
2015-07-11 18:56:02 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2015-07-11 18:56:02 +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 !
*/
2018-12-28 05:52:00 +08:00
virtual bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
2015-07-11 18:56:02 +08:00
/** \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 !
*/
2018-12-28 05:52:00 +08:00
virtual bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
2015-07-11 18:56:02 +08:00
/** \brief returns the color to be used for the key label */
2019-04-22 19:27:50 +08:00
virtual QColor getKeyLabelColor ( ) const override ;
2015-07-11 18:56:02 +08:00
2019-05-19 04:41:38 +08:00
/*! \copydoc x */
2019-04-22 19:27:50 +08:00
void setX ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc x */
2019-04-22 19:27:50 +08:00
double getX ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc y */
2019-04-22 19:27:50 +08:00
void setY ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc y */
2019-04-22 19:27:50 +08:00
double getY ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc width */
2019-04-22 19:27:50 +08:00
void setWidth ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc width */
2019-04-22 19:27:50 +08:00
double getWidth ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc height */
2019-04-22 19:27:50 +08:00
void setHeight ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc height */
2019-04-22 19:27:50 +08:00
double getHeight ( ) const ;
2015-07-11 18:56:02 +08:00
protected :
/** \brief x coordinate of lower left corner */
double x ;
/** \brief y coordinate of lower left corner */
double y ;
/** \brief width of image */
double width ;
/** \brief height of image */
double height ;
/*! \brief plot the given QImage onto the widget where the QImage fills the area defined by x, y (lower left corner) and width, height
in the simplest case your implementation of draw ( ) will call
< code > plotImage ( painter , image , this - > x , this - > y , this - > width , this - > height ) ; < / code >
*/
virtual void plotImage ( JKQTPEnhancedPainter & painter , QImage & image , double x , double y , double width , double height ) ;
} ;
/*! \brief base class to hold an image from an 2-dimensional array of values
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_imagelots_elements
2019-06-21 04:24:47 +08:00
\ image html imageplot . png
2015-07-11 18:56:02 +08:00
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase : public JKQTPImageBase {
2015-07-11 18:56:02 +08:00
Q_OBJECT
public :
/** \brief possible datatypes of the data array, plotted by this class. */
enum DataType {
2019-01-26 20:00:40 +08:00
FloatArray , /*!< Data is of type \c float */
DoubleArray , /*!< Data is of type \c double */
UInt8Array , /*!< Data is of type \c uint8_t */
UInt16Array , /*!< Data is of type \c uint16_t */
UInt32Array , /*!< Data is of type \c uint32_t */
UInt64Array , /*!< Data is of type \c uint8_t */
Int8Array , /*!< Data is of type \c int8_t */
Int16Array , /*!< Data is of type \c int16_t */
Int32Array , /*!< Data is of type \c int32_t */
Int64Array /*!< Data is of type \c int64_t */
2015-07-11 18:56:02 +08:00
} ;
2019-01-26 20:00:40 +08:00
/** \brief describes how to modify a rendered image with a second data array \see ModifierModeToString(), StringToModifierMode(), JKQTPImageModifierModeComboBox */
2015-07-11 18:56:02 +08:00
enum ModifierMode {
2019-01-26 20:00:40 +08:00
ModifyNone = 0 , /*!< no modification \image html JKQTPMathImageBaseModifyNone.png */
ModifyValue = 1 , /*!< modify the VALUE-channel from the HSV color space \image html JKQTPMathImageBaseModifyValue.png */
ModifySaturation = 2 , /*!< modify the SATURATION-channel from the HSV color space \image html JKQTPMathImageBaseModifySaturation.png */
ModifyAlpha = 3 , /*!< modify the ALPHA/TRANSPARENCY-channel from the RGBA color space \image html JKQTPMathImageBaseModifyAlpha.png */
ModifyTransparency = ModifyAlpha , /*!< \see ModifyAlpha */
ModifyLuminance = 4 , /*!< modify the LUMINANCE-channel from the HSL color space \image html JKQTPMathImageBaseModifyLuminance.png */
ModifyHue = 5 , /*!< modify the VALUE-channel from the HSV color space \image html JKQTPMathImageBaseModifyHue.png */
2015-07-11 18:56:02 +08:00
} ;
2019-01-26 20:00:40 +08:00
/** \brief convert a ModifierMode to a string \see ModifierModeToString(), ModifierMode */
static ModifierMode StringToModifierMode ( const QString & mode ) ;
2015-07-11 18:56:02 +08:00
2019-01-26 20:00:40 +08:00
/** \brief convert a string to a ModifierMode \see StringToModifierMode(), ModifierMode */
static QString ModifierModeToString ( const ModifierMode & mode ) ;
2015-07-11 18:56:02 +08:00
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 17:49:29 +08:00
JKQTPMathImageBase ( JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param parent parent plotter object
*
*/
2019-01-20 17:49:29 +08:00
JKQTPMathImageBase ( double x , double y , double width , double height , JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param datatype datatype of the image given in \ a data
* \ param data points to an image to be plotted ( of size \ a Nx * \ a Ny )
* \ param Nx width ( in number of pixels ) of \ a data
* \ param Ny height ( in number of pixels ) of \ a data
* \ param parent parent plotter object
*
*/
2019-01-26 19:28:44 +08:00
JKQTPMathImageBase ( double x , double y , double width , double height , DataType datatype , void * data , int Nx , int Ny , JKQTBasePlotter * parent = nullptr ) ;
2015-07-11 18:56:02 +08:00
2015-08-02 19:36:54 +08:00
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 23:15:10 +08:00
JKQTPMathImageBase ( JKQTPlotter * parent ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param parent parent plotter object
*
*/
2019-01-20 23:15:10 +08:00
JKQTPMathImageBase ( double x , double y , double width , double height , JKQTPlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param datatype datatype of the image given in \ a data
* \ param data points to an image to be plotted ( of size \ a Nx * \ a Ny )
* \ param Nx width ( in number of pixels ) of \ a data
* \ param Ny height ( in number of pixels ) of \ a data
* \ param parent parent plotter object
*
*/
2019-01-26 19:28:44 +08:00
JKQTPMathImageBase ( double x , double y , double width , double height , DataType datatype , void * data , int Nx , int Ny , JKQTPlotter * parent ) ;
2015-08-02 19:36:54 +08:00
2015-07-11 18:56:02 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2015-07-11 18:56:02 +08:00
2019-06-22 20:21:32 +08:00
/*! \copydoc Nx */
void setNx ( int __value ) ;
/*! \copydoc Nx */
void setNx ( size_t __value ) ;
/*! \copydoc Nx */
2019-04-22 19:27:50 +08:00
int getNx ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc Ny */
2019-04-22 19:27:50 +08:00
void setNy ( int __value ) ;
2019-06-22 20:21:32 +08:00
/*! \copydoc Ny */
void setNy ( size_t __value ) ;
/*! \copydoc Ny */
2019-04-22 19:27:50 +08:00
int getNy ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc data */
2019-04-22 19:27:50 +08:00
virtual void setData ( void * __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc data */
2019-04-22 19:27:50 +08:00
virtual void * getData ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc datatype */
2019-04-22 19:27:50 +08:00
virtual void setDatatype ( DataType __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc datatype */
2019-04-22 19:27:50 +08:00
virtual DataType getDatatype ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc dataModifier */
2019-04-22 19:27:50 +08:00
virtual void setDataModifier ( void * __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc dataModifier */
2019-04-22 19:27:50 +08:00
virtual void * getDataModifier ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc datatypeModifier */
2019-04-22 19:27:50 +08:00
virtual void setDatatypeModifier ( DataType __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc datatypeModifier */
2019-04-22 19:27:50 +08:00
virtual DataType getDatatypeModifier ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierMode */
2019-04-22 19:27:50 +08:00
void setModifierMode ( const ModifierMode & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierMode */
2019-04-22 19:27:50 +08:00
ModifierMode getModifierMode ( ) const ;
2015-07-11 18:56:02 +08:00
2019-05-30 17:19:56 +08:00
/** \brief sets dataModifier (\copybrief dataModifier ) and datatypeModifier (\copybrief datatypeModifier ) */
2019-01-26 20:00:40 +08:00
virtual void setDataModifier ( void * data , DataType datatype ) ;
2019-05-30 17:19:56 +08:00
/** \brief sets data (\copybrief data ) and datatype (\copybrief datatype ), as well as the size of data (Nx: \copybrief Nx and Ny: \copybrief Ny ) */
2019-01-26 20:00:40 +08:00
virtual void setData ( void * data , int Nx , int Ny , DataType datatype ) ;
2019-05-30 17:19:56 +08:00
/** \brief sets data (\copybrief data ), as well as the size of data (Nx: \copybrief Nx and Ny: \copybrief Ny ) */
2019-01-26 20:00:40 +08:00
virtual void setData ( void * data , int Nx , int Ny ) ;
2015-07-11 18:56:02 +08:00
/** \brief determine min/max data value of the image */
virtual void getDataMinMax ( double & imin , double & imax ) ;
/** \brief determine min/max data value of the image */
virtual void getModifierMinMax ( double & imin , double & imax ) ;
2019-05-19 22:40:02 +08:00
/** \brief returns the contents of the internal data image as a QVector<double> */
2015-07-11 18:56:02 +08:00
QVector < double > getDataAsDoubleVector ( ) const ;
2019-05-19 22:40:02 +08:00
/** \brief returns the contents of the internal modifier image as a QVector<double> */
2015-07-11 18:56:02 +08:00
QVector < double > getDataModifierAsDoubleVector ( ) const ;
protected :
/** \brief points to the data array, holding the image */
void * data ;
/** \brief datatype of the data array data */
DataType datatype ;
2019-01-20 23:15:10 +08:00
/** \brief width of the data array data in pt */
2019-01-26 19:28:44 +08:00
int Nx ;
2019-01-20 23:15:10 +08:00
/** \brief height of the data array data in pt */
2019-01-26 19:28:44 +08:00
int Ny ;
2015-07-11 18:56:02 +08:00
/** \brief points to the data array, holding the modifier image */
void * dataModifier ;
/** \brief datatype of the data array data */
DataType datatypeModifier ;
2019-05-19 22:40:02 +08:00
/** \brief how to apply the modifier column dataModifier
* \ see ModifierMode
*/
2015-07-11 18:56:02 +08:00
ModifierMode modifierMode ;
2019-05-19 22:40:02 +08:00
/** \brief internal storage for minimum of the image value range
*
* This is set e . g . when calling drawImage ( ) or draw ( )
*/
2015-07-11 18:56:02 +08:00
double internalDataMin ;
2019-05-19 22:40:02 +08:00
/** \brief internal storage for maximum of the image value range
*
* This is set e . g . when calling drawImage ( ) or draw ( )
*/
2015-07-11 18:56:02 +08:00
double internalDataMax ;
2019-05-19 22:40:02 +08:00
/** \brief internal storage for minimum of the modifier image value range
*
* This is set e . g . when calling modifyImage ( ) or draw ( )
*/
2015-07-11 18:56:02 +08:00
double internalModifierMin ;
2019-05-19 22:40:02 +08:00
/** \brief internal storage for maximum of the modifier image value range
*
* This is set e . g . when calling modifyImage ( ) or draw ( )
*/
2015-07-11 18:56:02 +08:00
double internalModifierMax ;
/** \brief overwrite this to fill the data poiters before they are accessed (e.g. to load data from a column in the datastore */
virtual void ensureImageData ( ) ;
2019-05-19 22:40:02 +08:00
/** \brief modify the given image \a img, using the internally set modifier data
* \ see dataModifier , datatypeModifier
*/
2015-07-11 18:56:02 +08:00
void modifyImage ( QImage & img ) ;
2019-05-19 22:40:02 +08:00
/** \brief modify the given image \a img, using modifier image \a dataModifier (of type \a datatypeModifier and size \a Nx * \a Ny), using values in the range \a internalModifierMin ... \a internalModifierMax
*/
2019-01-26 19:28:44 +08:00
void modifyImage ( QImage & img , void * dataModifier , DataType datatypeModifier , int Nx , int Ny , double internalModifierMin , double internalModifierMax ) ;
2015-07-11 18:56:02 +08:00
} ;
/*! \brief class to plot an image from a QImage object
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_imagelots_elements
2015-07-11 18:56:02 +08:00
2019-06-21 04:24:47 +08:00
\ image html rgbimageplot_qt . png
2019-06-13 16:27:06 +08:00
\ see \ ref JKQTPlotterImagePlotQImageRGB
2015-07-11 18:56:02 +08:00
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPImage : public JKQTPImageBase {
2015-07-11 18:56:02 +08:00
Q_OBJECT
public :
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 17:49:29 +08:00
JKQTPImage ( JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 23:15:10 +08:00
JKQTPImage ( JKQTPlotter * parent ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param image points to a QImage that shall be plotted ( the constructed object does not take ownership ! )
* \ param parent parent plotter object
*
*/
2019-01-20 17:49:29 +08:00
JKQTPImage ( double x , double y , double width , double height , QImage * image , JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param image points to a QImage that shall be plotted ( the constructed object does not take ownership ! )
* \ param parent parent plotter object
*
*/
2019-01-20 23:15:10 +08:00
JKQTPImage ( double x , double y , double width , double height , QImage * image , JKQTPlotter * parent ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param image a QImage that shall be plotted ( the constructed object copies the contents into an internally owned variable )
* \ param parent parent plotter object
*
*/
2019-01-20 17:49:29 +08:00
JKQTPImage ( double x , double y , double width , double height , const QImage & image , JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param image a QImage that shall be plotted ( the constructed object copies the contents into an internally owned variable )
* \ param parent parent plotter object
*
*/
2019-01-20 23:15:10 +08:00
JKQTPImage ( double x , double y , double width , double height , const QImage & image , JKQTPlotter * parent ) ;
2018-12-07 01:19:02 +08:00
2018-12-28 05:52:00 +08:00
virtual ~ JKQTPImage ( ) override ;
2015-07-11 18:56:02 +08:00
/** \brief plots the graph to the plotter object specified as parent */
2018-12-28 05:52:00 +08:00
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
2015-07-11 18:56:02 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2015-07-11 18:56:02 +08:00
2018-12-07 01:19:02 +08:00
/** \brief copy an external image into an internally owned copy */
2019-01-26 20:00:40 +08:00
virtual void setImage ( const QImage & image ) ;
2018-12-07 01:19:02 +08:00
/** \brief set an external image to be plotted, the image will NOT BE OWNED by the graph-object */
2019-01-26 20:00:40 +08:00
virtual void setImage ( QImage * image ) ;
2015-07-11 18:56:02 +08:00
2018-12-07 01:19:02 +08:00
/** \brief deletes the internal image */
void clear_image ( ) ;
2015-07-11 18:56:02 +08:00
2019-05-19 04:41:38 +08:00
/*! \copydoc image */
2019-01-26 20:00:40 +08:00
inline QImage * getImage ( ) const { return this - > image ; }
2015-07-11 18:56:02 +08:00
protected :
2018-12-07 01:19:02 +08:00
/** \brief the image to be plotted. This is freed by the destructor, iff \a image_owned is set to \c true (.e.g by QImage-copy-constructors) */
2015-07-11 18:56:02 +08:00
QImage * image ;
2018-12-07 01:19:02 +08:00
/** \brief indicates that the image \a image is owned by this object (i.e. freed, when the object is destroyed) */
bool image_owned ;
2015-07-11 18:56:02 +08:00
2019-05-19 22:40:02 +08:00
/** \brief create QActions that are shown in the context menu of the JKQTPlotter
*
* \ see actSaveImage , actCopyImage , saveImagePlotAsImage ( ) , copyImagePlotAsImage ( )
*/
2015-08-02 19:36:54 +08:00
void createImageActions ( ) ;
2015-07-11 18:56:02 +08:00
protected :
2019-05-19 22:40:02 +08:00
/** \brief QActions that saves the image (asking the user for a filename)
*
* \ see actSaveImage , saveImagePlotAsImage ( )
*/
2015-07-11 18:56:02 +08:00
QAction * actSaveImage ;
2019-05-19 22:40:02 +08:00
/** \brief QActions that copies the image into the clipboard
*
* \ see actCopyImage , copyImagePlotAsImage ( )
*/
2015-07-11 18:56:02 +08:00
QAction * actCopyImage ;
public :
2019-05-19 22:40:02 +08:00
/** \copydoc JKQTPImageBase::setParent() */
2019-01-20 17:49:29 +08:00
virtual void setParent ( JKQTBasePlotter * parent ) override ;
2019-05-19 22:40:02 +08:00
/** \copydoc JKQTPImageBase::setTitle() */
2019-01-26 20:00:40 +08:00
virtual void setTitle ( const QString & title ) override ;
2015-07-11 18:56:02 +08:00
public slots :
2019-05-19 22:40:02 +08:00
/** \brief saves the image (asking the user for a filename, if \a filename is empty)
*
* \ param filename name of the file that should be create ( if empty , a file save dialog is shown )
* \ param outputFormat format of the output file , see < a href = " https://doc.qt.io/qt-5/qimage.html#save " > QImage : : save ( ) < / a >
*
* \ see actSaveImage , saveImagePlotAsImage ( ) , < a href = " https://doc.qt.io/qt-5/qimage.html#save " > QImage : : save ( ) < / a >
*/
2015-07-11 18:56:02 +08:00
void saveImagePlotAsImage ( const QString & filename = QString ( " " ) , const QByteArray & outputFormat = QByteArray ( ) ) ;
2019-05-19 22:40:02 +08:00
/** \brief copies the image into the clipboard
*
* \ see actCopyImage , copyImagePlotAsImage ( )
*/
2015-07-11 18:56:02 +08:00
void copyImagePlotAsImage ( ) ;
} ;
/*! \brief class to plot an image from an 2-dimensional array of values
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_imagelots_elements
2015-07-11 18:56:02 +08:00
2019-06-21 04:24:47 +08:00
\ image html imageplot . png
\ image html imageplot_modifier . png
\ image html imageplot__smallscaletransparent . png
2019-06-13 16:27:06 +08:00
\ see \ ref JKQTPlotterImagePlotNoDatastore
2015-07-11 18:56:02 +08:00
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage : public JKQTPMathImageBase {
2015-07-11 18:56:02 +08:00
Q_OBJECT
public :
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 17:49:29 +08:00
JKQTPMathImage ( JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param datatype datatype of the image given in \ a data
* \ param data points to an image to be plotted ( of size \ a Nx * \ a Ny )
* \ param Nx width ( in number of pixels ) of \ a data
* \ param Ny height ( in number of pixels ) of \ a data
* \ param palette color palette to use for plotting
* \ param parent parent plotter object
*
*/
JKQTPMathImage ( double x , double y , double width , double height , DataType datatype , void * data , int Nx , int Ny , JKQTPMathImageColorPalette palette = JKQTPMathImageGRAY , JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param datatype datatype of the image given in \ a data
* \ param data points to an image to be plotted ( of size \ a Nx * \ a Ny )
* \ param Nx width ( in number of pixels ) of \ a data
* \ param Ny height ( in number of pixels ) of \ a data
* \ param palette color palette to use for plotting
* \ param parent parent plotter object
*
*/
2019-01-26 19:28:44 +08:00
JKQTPMathImage ( double x , double y , double width , double height , DataType datatype , void * data , int Nx , int Ny , JKQTPMathImageColorPalette palette , JKQTPlotter * parent ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 23:15:10 +08:00
JKQTPMathImage ( JKQTPlotter * parent ) ;
2015-07-11 18:56:02 +08:00
/** \brief plots the graph to the plotter object specified as parent */
2018-12-28 05:52:00 +08:00
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
2015-07-11 18:56:02 +08:00
2019-01-20 17:49:29 +08:00
virtual void setParent ( JKQTBasePlotter * parent ) override ;
2015-07-11 18:56:02 +08:00
/*! \brief get list with all available palettes */
static QStringList getPalettes ( ) ;
/*! \brief get list with all available palettes */
static int getPalettesCount ( ) ;
/*! \brief get QIcon representing the given palette */
static QIcon getPaletteIcon ( int i ) ;
/*! \brief get QIcon representing the given palette */
static QIcon getPaletteIcon ( JKQTPMathImageColorPalette palette ) ;
2018-11-29 06:10:14 +08:00
/*! \brief get QImage representing the given palette */
2015-08-05 20:27:09 +08:00
static QImage getPaletteImage ( int i , int width , int height = 1 ) ;
2018-11-29 06:10:14 +08:00
/*! \brief get QImage representing the given palette */
2015-08-05 20:27:09 +08:00
static QImage getPaletteImage ( JKQTPMathImageColorPalette palette , int width , int height = 1 ) ;
2015-07-11 18:56:02 +08:00
/*! \brief get QIcon representing the given palette */
static QIcon getPaletteKeyIcon ( int i ) ;
/*! \brief get QIcon representing the given palette */
static QIcon getPaletteKeyIcon ( JKQTPMathImageColorPalette palette ) ;
2018-11-29 06:10:14 +08:00
/*! \brief get QImage representing the given palette */
2015-07-11 18:56:02 +08:00
static QImage getPaletteKeyImage ( int i , int width , int height ) ;
2018-11-29 06:10:14 +08:00
/*! \brief get QImage representing the given palette */
2015-07-11 18:56:02 +08:00
static QImage getPaletteKeyImage ( JKQTPMathImageColorPalette palette , int width , int height ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc palette */
2019-04-22 19:27:50 +08:00
void setPalette ( const JKQTPMathImageColorPalette & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc palette */
2019-04-22 19:27:50 +08:00
JKQTPMathImageColorPalette getPalette ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMinFailAction */
2019-04-22 19:27:50 +08:00
void setRangeMinFailAction ( const JKQTPMathImageColorRangeFailAction & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMinFailAction */
2019-04-22 19:27:50 +08:00
JKQTPMathImageColorRangeFailAction getActionRangeMinFail ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMaxFailAction */
2019-04-22 19:27:50 +08:00
void setRangeMaxFailAction ( const JKQTPMathImageColorRangeFailAction & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMaxFailAction */
2019-04-22 19:27:50 +08:00
JKQTPMathImageColorRangeFailAction getActionRangeMaxFail ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMinFailColor */
2019-04-22 19:27:50 +08:00
void setRangeMinFailColor ( const QColor & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMinFailColor */
2019-04-22 19:27:50 +08:00
QColor getRangeMinFailColor ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMaxFailColor */
2019-04-22 19:27:50 +08:00
void setRangeMaxFailColor ( const QColor & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc rangeMaxFailColor */
2019-04-22 19:27:50 +08:00
QColor getRangeMaxFailColor ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc nanColor */
2019-04-22 19:27:50 +08:00
void setNanColor ( const QColor & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc nanColor */
2019-04-22 19:27:50 +08:00
QColor getNanColor ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc infColor */
2019-04-22 19:27:50 +08:00
void setInfColor ( const QColor & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc infColor */
2019-04-22 19:27:50 +08:00
QColor getInfColor ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc showColorBar */
2019-04-22 19:27:50 +08:00
void setShowColorBar ( bool __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc showColorBar */
2019-04-22 19:27:50 +08:00
bool getShowColorBar ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarWidth */
2019-04-22 19:27:50 +08:00
void setColorBarWidth ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarWidth */
2019-04-22 19:27:50 +08:00
double getColorBarWidth ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarModifiedWidth */
2019-04-22 19:27:50 +08:00
void setColorBarModifiedWidth ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarModifiedWidth */
2019-04-22 19:27:50 +08:00
double getColorBarModifiedWidth ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarOffset */
2019-04-22 19:27:50 +08:00
void setColorBarOffset ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarOffset */
2019-04-22 19:27:50 +08:00
double getColorBarOffset ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarRelativeHeight */
2019-04-22 19:27:50 +08:00
void setColorBarRelativeHeight ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarRelativeHeight */
2019-04-22 19:27:50 +08:00
double getColorBarRelativeHeight ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageMin */
2019-04-22 19:27:50 +08:00
void setImageMin ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageMin */
2019-04-22 19:27:50 +08:00
double getImageMin ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageMax */
2019-04-22 19:27:50 +08:00
void setImageMax ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageMax */
2019-04-22 19:27:50 +08:00
double getImageMax ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc autoImageRange */
2019-04-22 19:27:50 +08:00
void setAutoImageRange ( bool __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc autoImageRange */
2019-04-22 19:27:50 +08:00
bool getAutoImageRange ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageName */
2019-04-22 19:27:50 +08:00
void setImageName ( const QString & __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageName */
2019-04-22 19:27:50 +08:00
QString getImageName ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageNameFontSize */
2019-04-22 19:27:50 +08:00
void setImageNameFontSize ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageNameFontSize */
2019-04-22 19:27:50 +08:00
double getImageNameFontSize ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarRightAxis */
2019-04-22 19:27:50 +08:00
JKQTPVerticalIndependentAxis * getColorBarRightAxis ( ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarTopAxis */
2019-04-22 19:27:50 +08:00
JKQTPHorizontalIndependentAxis * getColorBarTopAxis ( ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierColorBarTopAxis */
2019-04-22 19:27:50 +08:00
JKQTPVerticalIndependentAxis * getModifierColorBarTopAxis ( ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierColorBarRightAxis */
2019-04-22 19:27:50 +08:00
JKQTPHorizontalIndependentAxis * getModifierColorBarRightAxis ( ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarRightAxis */
2019-04-22 19:27:50 +08:00
const JKQTPVerticalIndependentAxis * getColorBarRightAxis ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarTopAxis */
2019-04-22 19:27:50 +08:00
const JKQTPHorizontalIndependentAxis * getColorBarTopAxis ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierColorBarTopAxis */
2019-04-22 19:27:50 +08:00
const JKQTPVerticalIndependentAxis * getModifierColorBarTopAxis ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierColorBarRightAxis */
2019-04-22 19:27:50 +08:00
const JKQTPHorizontalIndependentAxis * getModifierColorBarRightAxis ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarTopVisible */
2019-04-22 19:27:50 +08:00
void setColorBarTopVisible ( bool __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarTopVisible */
2019-04-22 19:27:50 +08:00
bool getColorBarTopVisible ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarRightVisible */
2019-04-22 19:27:50 +08:00
void setColorBarRightVisible ( bool __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc colorBarRightVisible */
2019-04-22 19:27:50 +08:00
bool getColorBarRightVisible ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc autoModifierRange */
2019-04-22 19:27:50 +08:00
void setAutoModifierRange ( bool __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc autoModifierRange */
2019-04-22 19:27:50 +08:00
bool getAutoModifierRange ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierMin */
2019-04-22 19:27:50 +08:00
void setModifierMin ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierMin */
2019-04-22 19:27:50 +08:00
double getModifierMin ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierMax */
2019-04-22 19:27:50 +08:00
void setModifierMax ( double __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierMax */
2019-04-22 19:27:50 +08:00
double getModifierMax ( ) const ;
2015-07-11 18:56:02 +08:00
2019-01-26 20:00:40 +08:00
void setPalette ( int pal ) ;
2015-07-11 18:56:02 +08:00
/*! \brief if the graph plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
\ note If you want to draw outside , then you ' ll also have to implement drawOutside ( )
*/
2018-12-28 05:52:00 +08:00
virtual void getOutsideSize ( JKQTPEnhancedPainter & painter , int & leftSpace , int & rightSpace , int & topSpace , int & bottomSpace ) override ;
2015-07-11 18:56:02 +08:00
/*! \brief plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
\ note If you want to draw outside , then you ' ll also have to implement getOutsideSize ( ) , so enough space is reserved
The four value supplied tell the method where to draw ( inside one of the rectangles ) .
*/
2018-12-28 05:52:00 +08:00
virtual void drawOutside ( JKQTPEnhancedPainter & painter , QRect leftSpace , QRect rightSpace , QRect topSpace , QRect bottomSpace ) override ;
2015-07-11 18:56:02 +08:00
2015-08-05 20:27:09 +08:00
/*! \brief returns a QImage, which contains the plaette drawn outside the plot. \a steps is the number of data-setps (and the size of the output image) used for the palette image. */
2019-01-26 20:00:40 +08:00
virtual QImage drawOutsidePalette ( uint8_t steps = 200 ) ;
2015-08-05 20:27:09 +08:00
2015-07-11 18:56:02 +08:00
/*! \brief return the plotted image only as a QImage */
virtual QImage drawImage ( ) ;
/** \brief determine min/max data value of the image */
2018-12-28 05:52:00 +08:00
virtual void getDataMinMax ( double & imin , double & imax ) override ;
2015-07-11 18:56:02 +08:00
/** \brief determine min/max data value of the image */
2018-12-28 05:52:00 +08:00
virtual void getModifierMinMax ( double & imin , double & imax ) override ;
2015-07-11 18:56:02 +08:00
/** \brief return the value (raw data!) of the contained image at the given coordinate */
2019-05-19 04:41:38 +08:00
inline double getValueAt ( double x , double y ) ;
/** \brief retrieve size of a single sample in the image data (i.e. size of the datatype) */
inline int getSampleSize ( ) const ;
/** \brief retrieve image data at a given position as double */
inline double getPixelValue ( int xIdx , int yIdx ) const ;
/** \brief return the value (raw data!) of the contained modifier image at the given coordinate */
inline double getModifierValueAt ( double x , double y ) ;
/** \brief retrieve size of a single sample in the modifier image data (i.e. size of the datatype) */
inline int getModifierSampleSize ( ) const ;
/** \brief retrieve modifier image data at a given position as double */
inline double getModifierPixelValue ( int xIdx , int yIdx ) const ;
2015-07-11 18:56:02 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2015-07-11 18:56:02 +08:00
protected :
2015-08-02 19:36:54 +08:00
void initJKQTPMathImage ( ) ;
2015-07-11 18:56:02 +08:00
/** \brief top color bar visible */
bool colorBarTopVisible ;
/** \brief right color bar visible */
bool colorBarRightVisible ;
/** \brief name of the image displayed above color bar (may contain LaTeX markup!) */
QString imageName ;
/** \brief font size in points when displaying imageName */
double imageNameFontSize ;
/** \brief palette for plotting an image */
JKQTPMathImageColorPalette palette ;
/** \brief indicate whether to display a color bar */
bool showColorBar ;
2019-02-08 00:24:46 +08:00
/** \brief width of the color bar [pt] */
double colorBarWidth ;
2015-07-11 18:56:02 +08:00
/** \brief width of the color bar when modifier is on */
2019-02-08 00:24:46 +08:00
double colorBarModifiedWidth ;
2015-07-11 18:56:02 +08:00
/** \brief height of the color bar, as multiple of plotHeight */
double colorBarRelativeHeight ;
/** \brief indicates whether to estimate min/max of the image automatically */
bool autoImageRange ;
/** \brief image value range minimum */
double imageMin ;
/** \brief image value range maximum */
double imageMax ;
/** \brief indicates whether to estimate min/max of the modifier automatically */
bool autoModifierRange ;
/** \brief modifier value range minimum */
double modifierMin ;
/** \brief modifier value range maximum */
double modifierMax ;
2019-02-08 00:24:46 +08:00
/** \brief offset between outside space border and color bar [pt] */
double colorBarOffset ;
2015-07-11 18:56:02 +08:00
/** \brief which action to take if a color is below \a imageMin and \a autoImageRange \c ==false */
JKQTPMathImageColorRangeFailAction rangeMinFailAction ;
/** \brief which action to take if a color is above \a imageMax and \a autoImageRange \c ==false */
JKQTPMathImageColorRangeFailAction rangeMaxFailAction ;
/** \brief color to use for some settings of \a rangeMinFailAction */
QColor rangeMinFailColor ;
/** \brief color to use for some settings of \a rangeMaxFailAction */
QColor rangeMaxFailColor ;
/** \brief color to use for a not-a-number value */
QColor nanColor ;
/** \brief color to use for an infinity value */
QColor infColor ;
2019-05-19 22:40:02 +08:00
/** \brief object used for color bar axes (right border, image data)
2015-07-11 18:56:02 +08:00
*
* \ note this axis has some kind of a special role . It is used to format color bar axes
*/
2019-01-20 17:49:29 +08:00
JKQTPVerticalIndependentAxis * colorBarRightAxis ;
2019-05-19 22:40:02 +08:00
/** \brief object used for color bar axes (top border, image data)
*
* \ note this axis has some kind of a special role . It is used to format color bar axes
*/
2019-01-20 17:49:29 +08:00
JKQTPHorizontalIndependentAxis * colorBarTopAxis ;
2019-05-19 22:40:02 +08:00
/** \brief object used for color bar axes (right border, modifier image data)
*
* \ note this axis has some kind of a special role . It is used to format color bar axes
*/
2019-01-20 17:49:29 +08:00
JKQTPVerticalIndependentAxis * modifierColorBarTopAxis ;
2019-05-19 22:40:02 +08:00
/** \brief object used for color bar axes (top border, modifier image data)
*
* \ note this axis has some kind of a special role . It is used to format color bar axes
*/
2019-01-20 17:49:29 +08:00
JKQTPHorizontalIndependentAxis * modifierColorBarRightAxis ;
2015-07-11 18:56:02 +08:00
protected :
2019-05-19 22:40:02 +08:00
/** \brief QActions that saves the image (asking the user for a filename)
*
* \ see actSaveImage , saveImagePlotAsImage ( )
*/
2015-07-11 18:56:02 +08:00
QAction * actSaveImage ;
2019-05-19 22:40:02 +08:00
/** \brief QActions that copies the image into the clipboard
*
* \ see actCopyImage , copyImagePlotAsImage ( )
*/
2015-07-11 18:56:02 +08:00
QAction * actCopyImage ;
2019-05-19 22:40:02 +08:00
/** \brief QActions that saves the current palette
*
* \ see actSaveImage , saveColorbarPlotAsImage ( )
*/
2015-08-05 20:27:09 +08:00
QAction * actSavePalette ;
2019-05-19 22:40:02 +08:00
/** \brief QActions that copies the current palette
*
* \ see actCopyImage , copyColorbarPlotAsImage ( )
*/
2015-08-05 20:27:09 +08:00
QAction * actCopyPalette ;
2015-07-11 18:56:02 +08:00
public :
2019-05-19 22:40:02 +08:00
/** \copydoc JKQTPImageBase::setTitle() */
2019-01-26 20:00:40 +08:00
virtual void setTitle ( const QString & title ) override ;
2015-07-11 18:56:02 +08:00
public slots :
2019-05-19 22:40:02 +08:00
/** \brief saves the image (asking the user for a filename, if \a filename is empty)
*
* \ param filename name of the file that should be create ( if empty , a file save dialog is shown )
* \ param outputFormat format of the output file , see < a href = " https://doc.qt.io/qt-5/qimage.html#save " > QImage : : save ( ) < / a >
*
* \ see actSaveImage , saveImagePlotAsImage ( ) , < a href = " https://doc.qt.io/qt-5/qimage.html#save " > QImage : : save ( ) < / a >
*/
2015-07-11 18:56:02 +08:00
void saveImagePlotAsImage ( const QString & filename = QString ( " " ) , const QByteArray & outputFormat = QByteArray ( ) ) ;
2019-05-19 22:40:02 +08:00
/** \brief copies the image into the clipboard
*
* \ see actCopyImage , copyImagePlotAsImage ( )
*/
2015-07-11 18:56:02 +08:00
void copyImagePlotAsImage ( ) ;
2019-05-19 22:40:02 +08:00
/** \brief saves an image of the current palette (asking the user for a filename, if \a filename is empty)
*
* \ param filename name of the file that should be create ( if empty , a file save dialog is shown )
* \ param outputFormat format of the output file , see < a href = " https://doc.qt.io/qt-5/qimage.html#save " > QImage : : save ( ) < / a >
*
* \ see actSavePalette , saveColorbarPlotAsImage ( ) , < a href = " https://doc.qt.io/qt-5/qimage.html#save " > QImage : : save ( ) < / a >
*/
2015-08-05 20:27:09 +08:00
void saveColorbarPlotAsImage ( const QString & filename = QString ( " " ) , const QByteArray & outputFormat = QByteArray ( ) ) ;
2019-05-19 22:40:02 +08:00
/** \brief copies an image of the current palette into the clipboard
*
* \ see actCopyPalette , copyColorbarPlotAsImage ( )
*/
2015-08-05 20:27:09 +08:00
void copyColorbarPlotAsImage ( ) ;
2015-07-11 18:56:02 +08:00
} ;
2019-05-19 04:41:38 +08:00
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getValueAt ( double x , double y )
{
ensureImageData ( ) ;
int xx = trunc ( ( x - this - > x ) / width * double ( Nx ) ) ;
int yy = trunc ( ( y - this - > y ) / height * double ( Ny ) ) ;
if ( xx > = 0 & & xx < ( int64_t ) Nx & & yy > = 0 & & yy < ( int64_t ) Ny ) {
switch ( datatype ) {
case JKQTPMathImageBase : : DoubleArray : return ( static_cast < double * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : FloatArray : return ( static_cast < float * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt8Array : return ( static_cast < uint8_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt16Array : return ( static_cast < uint16_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt32Array : return ( static_cast < uint32_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt64Array : return ( static_cast < uint64_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int8Array : return ( static_cast < int8_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int16Array : return ( static_cast < int16_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int32Array : return ( static_cast < int32_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int64Array : return ( static_cast < int64_t * > ( data ) ) [ yy * Nx + xx ] ; break ;
} }
return 0.0 ;
}
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getPixelValue ( int xIdx , int yIdx ) const {
// row-major in datastore
//ensureImageData();
if ( ! data ) return 0 ;
switch ( datatype ) {
case JKQTPMathImageBase : : DoubleArray :
return ( static_cast < double * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : FloatArray :
return ( static_cast < float * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt8Array :
return ( static_cast < uint8_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt16Array :
return ( static_cast < uint16_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt32Array :
return ( static_cast < uint32_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt64Array :
return ( static_cast < uint64_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int8Array :
return ( static_cast < int8_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int16Array :
return ( static_cast < int16_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int32Array :
return ( static_cast < int32_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int64Array :
return ( static_cast < int64_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
default :
return 0 ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
int JKQTPMathImage : : getSampleSize ( ) const {
switch ( datatype ) {
case JKQTPMathImageBase : : DoubleArray :
return sizeof ( double ) ;
case JKQTPMathImageBase : : FloatArray :
return sizeof ( float ) ;
case JKQTPMathImageBase : : UInt8Array :
return sizeof ( uint8_t ) ;
case JKQTPMathImageBase : : UInt16Array :
return sizeof ( uint16_t ) ;
case JKQTPMathImageBase : : UInt32Array :
return sizeof ( uint32_t ) ;
case JKQTPMathImageBase : : UInt64Array :
return sizeof ( uint64_t ) ;
case JKQTPMathImageBase : : Int8Array :
return sizeof ( int8_t ) ;
case JKQTPMathImageBase : : Int16Array :
return sizeof ( int16_t ) ;
case JKQTPMathImageBase : : Int32Array :
return sizeof ( int32_t ) ;
case JKQTPMathImageBase : : Int64Array :
return sizeof ( int64_t ) ;
default :
return 0 ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getModifierValueAt ( double x , double y )
{
ensureImageData ( ) ;
int xx = trunc ( ( x - this - > x ) / width * double ( Nx ) ) ;
int yy = trunc ( ( y - this - > y ) / height * double ( Ny ) ) ;
if ( xx > = 0 & & xx < ( int64_t ) Nx & & yy > = 0 & & yy < ( int64_t ) Ny ) {
switch ( datatypeModifier ) {
case JKQTPMathImageBase : : DoubleArray : return ( static_cast < double * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : FloatArray : return ( static_cast < float * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt8Array : return ( static_cast < uint8_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt16Array : return ( static_cast < uint16_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt32Array : return ( static_cast < uint32_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : UInt64Array : return ( static_cast < uint64_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int8Array : return ( static_cast < int8_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int16Array : return ( static_cast < int16_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int32Array : return ( static_cast < int32_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
case JKQTPMathImageBase : : Int64Array : return ( static_cast < int64_t * > ( dataModifier ) ) [ yy * Nx + xx ] ; break ;
} }
return 0.0 ;
}
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getModifierPixelValue ( int xIdx , int yIdx ) const {
// row-major in datastore
//ensureImageData();
if ( ! dataModifier ) return 0 ;
switch ( datatypeModifier ) {
case JKQTPMathImageBase : : DoubleArray :
return ( static_cast < double * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : FloatArray :
return ( static_cast < float * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt8Array :
return ( static_cast < uint8_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt16Array :
return ( static_cast < uint16_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt32Array :
return ( static_cast < uint32_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : UInt64Array :
return ( static_cast < uint64_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int8Array :
return ( static_cast < int8_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int16Array :
return ( static_cast < int16_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int32Array :
return ( static_cast < int32_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
case JKQTPMathImageBase : : Int64Array :
return ( static_cast < int64_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
default :
return 0 ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
int JKQTPMathImage : : getModifierSampleSize ( ) const {
switch ( datatypeModifier ) {
case JKQTPMathImageBase : : DoubleArray :
return sizeof ( double ) ;
case JKQTPMathImageBase : : FloatArray :
return sizeof ( float ) ;
case JKQTPMathImageBase : : UInt8Array :
return sizeof ( uint8_t ) ;
case JKQTPMathImageBase : : UInt16Array :
return sizeof ( uint16_t ) ;
case JKQTPMathImageBase : : UInt32Array :
return sizeof ( uint32_t ) ;
case JKQTPMathImageBase : : UInt64Array :
return sizeof ( uint64_t ) ;
case JKQTPMathImageBase : : Int8Array :
return sizeof ( int8_t ) ;
case JKQTPMathImageBase : : Int16Array :
return sizeof ( int16_t ) ;
case JKQTPMathImageBase : : Int32Array :
return sizeof ( int32_t ) ;
case JKQTPMathImageBase : : Int64Array :
return sizeof ( int64_t ) ;
default :
return 0 ;
}
}
2015-07-11 18:56:02 +08:00
/*! \brief class to plot an image from an 2-dimensional array of values stored in a column of the datastore
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_imagelots_elements
2019-06-21 04:24:47 +08:00
\ image html imageplot . png
\ image html imageplot_modifier . png
\ image html imageplot__smallscaletransparent . png
2015-07-11 18:56:02 +08:00
2019-06-13 16:27:06 +08:00
\ see jkqtpstatAddKDE2DImage ( ) , jkqtpstatAddHistogram2DImage ( ) , \ ref JKQTPlotterImagePlot , \ ref JKQTPlotterImagePlotModifier , \ ref JKQTPlotterImagePlotOpenCV
2015-07-11 18:56:02 +08:00
*/
2019-06-22 20:21:32 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPColumnMathImage : public JKQTPMathImage {
2015-07-11 18:56:02 +08:00
Q_OBJECT
public :
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 17:49:29 +08:00
JKQTPColumnMathImage ( JKQTBasePlotter * parent = nullptr ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param parent parent plotter object
*
*/
JKQTPColumnMathImage ( double x , double y , double width , double height , JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param imageColumn column to be plotted
* \ param palette color palette to use for the plotting
* \ param parent parent plotter object
*
*/
JKQTPColumnMathImage ( double x , double y , double width , double height , int imageColumn , JKQTPMathImageColorPalette palette = JKQTPMathImageGRAY , JKQTBasePlotter * parent = nullptr ) ;
/** \brief class constructor
*
* \ param parent parent plotter object
*/
2019-01-20 23:15:10 +08:00
JKQTPColumnMathImage ( JKQTPlotter * parent ) ;
2019-05-19 22:40:02 +08:00
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param parent parent plotter object
*
*/
JKQTPColumnMathImage ( double x , double y , double width , double height , JKQTPlotter * parent ) ;
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param imageColumn column to be plotted
* \ param palette color palette to use for the plotting
* \ param parent parent plotter object
*
*/
JKQTPColumnMathImage ( double x , double y , double width , double height , int imageColumn , JKQTPMathImageColorPalette palette , JKQTPlotter * parent ) ;
/** \brief class constructor
*
* \ param x origin of the image ( x - direction ) in system coordinates
* \ param y origin of the image ( y - direction ) in system coordinates
* \ param width width of the image in system coordinates
* \ param height height of the image in system coordinates
* \ param imageColumn column to be plotted
* \ param parent parent plotter object
*
*/
JKQTPColumnMathImage ( double x , double y , double width , double height , int imageColumn , JKQTPlotter * parent ) ;
2015-07-11 18:56:02 +08:00
2019-05-19 04:41:38 +08:00
/*! \copydoc imageColumn */
2019-04-22 19:27:50 +08:00
virtual void setImageColumn ( int __value ) ;
2019-06-22 20:21:32 +08:00
/*! \copydoc imageColumn */
virtual void setImageColumn ( size_t __value ) ;
2019-05-19 04:41:38 +08:00
/*! \copydoc imageColumn */
2019-04-22 19:27:50 +08:00
int getImageColumn ( ) const ;
2019-05-19 04:41:38 +08:00
/*! \copydoc modifierColumn */
2019-04-22 19:27:50 +08:00
virtual void setModifierColumn ( int __value ) ;
2019-06-22 20:21:32 +08:00
/*! \copydoc modifierColumn */
virtual void setModifierColumn ( size_t __value ) ;
/*! \copydoc modifierColumn */
2019-04-22 19:27:50 +08:00
int getModifierColumn ( ) const ;
2015-07-11 18:56:02 +08:00
2019-01-20 17:49:29 +08:00
/** \copydoc JKQTPGraph::usesColumn() */
2018-12-28 05:52:00 +08:00
virtual bool usesColumn ( int c ) const override ;
2015-07-11 18:56:02 +08:00
protected :
/** \brief column containing the displayed image */
int imageColumn ;
/** \brief column containing the modifier image */
int modifierColumn ;
2019-05-19 22:40:02 +08:00
/** \copydoc JKQTPMathImage::ensureImageData() */
2018-12-28 05:52:00 +08:00
virtual void ensureImageData ( ) override ;
2019-05-19 22:40:02 +08:00
private :
using JKQTPMathImage : : setData ;
using JKQTPMathImage : : setDatatype ;
using JKQTPMathImage : : setDataModifier ;
using JKQTPMathImage : : setDatatypeModifier ;
2015-07-11 18:56:02 +08:00
} ;
2018-12-19 00:13:18 +08:00
# endif // jkqtpgraphsimage_H
2015-07-11 18:56:02 +08:00