2015-07-11 18:56:02 +08:00
/*
2022-07-19 19:40:43 +08:00
Copyright ( c ) 2008 - 2022 Jan W . Krieger ( jan @ jkrieger . de )
2019-05-19 04:41:38 +08:00
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 */
2023-12-19 05:24:59 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , const 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
2020-09-21 19:47:54 +08:00
/** \copydoc x */
2019-04-22 19:27:50 +08:00
double getX ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc y */
2019-04-22 19:27:50 +08:00
double getY ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc width */
2019-04-22 19:27:50 +08:00
double getWidth ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc height */
2019-04-22 19:27:50 +08:00
double getHeight ( ) const ;
2023-07-22 20:26:02 +08:00
public Q_SLOTS :
2015-07-11 18:56:02 +08:00
2020-09-29 01:24:17 +08:00
/** \copydoc x */
void setX ( double __value ) ;
/** \copydoc y */
void setY ( double __value ) ;
/** \copydoc width */
void setWidth ( double __value ) ;
/** \copydoc height */
void setHeight ( double __value ) ;
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 ;
2020-09-29 01:24:17 +08:00
/** \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 >
*
* \ param painter the Painter to use for drawing
* \ param image the image to draw
* \ param x x - coordinate of lower - left corner in coordinate space
* \ param y y - coordinate of lower - left corner in coordinate space
* \ param width width of image in coordinate space
* \ param height height of image in coordinate space
2015-07-11 18:56:02 +08:00
*/
2020-09-29 01:24:17 +08:00
void plotImage ( JKQTPEnhancedPainter & painter , QImage & image , double x , double y , double width , double height ) ;
2015-07-11 18:56:02 +08:00
} ;
/*! \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 :
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
*
*/
2020-09-29 01:24:17 +08:00
JKQTPMathImageBase ( double x , double y , double width , double height , JKQTPMathImageDataType datatype , const 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
*
*/
2020-09-29 01:24:17 +08:00
JKQTPMathImageBase ( double x , double y , double width , double height , JKQTPMathImageDataType datatype , const 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 */
2023-12-19 05:24:59 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , const QRectF & rect ) override ;
2015-07-11 18:56:02 +08:00
2020-09-21 19:47:54 +08:00
/** \copydoc Nx */
2019-06-22 20:21:32 +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-29 01:24:17 +08:00
/** \copydoc Ny */
2019-06-22 20:21:32 +08:00
void setNy ( size_t __value ) ;
2020-09-29 01:24:17 +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 void * __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc data */
2020-09-29 01:24:17 +08:00
virtual const void * getData ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc datatype */
2019-08-01 04:10:26 +08:00
virtual void setDatatype ( JKQTPMathImageDataType __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc datatype */
2019-08-01 04:10:26 +08:00
virtual JKQTPMathImageDataType getDatatype ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc dataModifier */
2020-09-29 01:24:17 +08:00
virtual void setDataModifier ( const void * __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc dataModifier */
2020-09-29 01:24:17 +08:00
virtual const void * getDataModifier ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc datatypeModifier */
2019-08-01 04:10:26 +08:00
virtual void setDatatypeModifier ( JKQTPMathImageDataType __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc datatypeModifier */
2019-08-01 04:10:26 +08:00
virtual JKQTPMathImageDataType getDatatypeModifier ( ) const ;
2019-05-30 17:19:56 +08:00
/** \brief sets dataModifier (\copybrief dataModifier ) and datatypeModifier (\copybrief datatypeModifier ) */
2020-09-29 01:24:17 +08:00
virtual void setDataModifier ( const void * data , JKQTPMathImageDataType 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 ) */
2020-09-29 01:24:17 +08:00
virtual void setData ( const void * data , int Nx , int Ny , JKQTPMathImageDataType 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 ) */
2020-09-29 01:24:17 +08:00
virtual void setData ( const 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 */
2020-09-29 01:24:17 +08:00
const void * data ;
2015-07-11 18:56:02 +08:00
/** \brief datatype of the data array data */
2019-08-01 04:10:26 +08:00
JKQTPMathImageDataType 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 */
2020-09-29 01:24:17 +08:00
const void * dataModifier ;
2015-07-11 18:56:02 +08:00
/** \brief datatype of the data array data */
2019-08-01 04:10:26 +08:00
JKQTPMathImageDataType datatypeModifier ;
2015-07-11 18:56:02 +08:00
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 ( ) ;
} ;
/*! \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 */
2023-12-19 05:24:59 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , const 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
2020-09-21 19:47:54 +08:00
/** \copydoc image */
2020-09-29 01:24:17 +08:00
inline QImage * getImage ( ) { return this - > image ; }
/** \copydoc image */
inline const 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 ;
2023-07-22 20:26:02 +08:00
public Q_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-08-01 04:10:26 +08:00
class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage : public JKQTPMathImageBase , public JKQTPColorPaletteWithModifierStyleAndToolsMixin {
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
*
*/
2020-09-29 01:24:17 +08:00
JKQTPMathImage ( double x , double y , double width , double height , JKQTPMathImageDataType datatype , const void * data , int Nx , int Ny , JKQTPMathImageColorPalette palette = JKQTPMathImageGRAY , 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
*
*/
2020-09-29 01:24:17 +08:00
JKQTPMathImage ( double x , double y , double width , double height , JKQTPMathImageDataType datatype , const 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
* reworked color-palette-system:
1. added several new (JKQTPMathImageBone, JKQTPMathImageCool, JKQTPMathImageCopper, JKQTPMathImageAutumn, JKQTPMathImageSeismic, JKQTPMathImageTerrain, JKQTPMathImageViridis, JKQTPMathImageMagma, JKQTPMathImageInferno, JKQTPMathImagePlasma)
2. reworked LUT-types (now a QVector, instead of a C-array, suing malloc)
3. reworked available functions to build LUTs (cleanup, more options, clearer names)
4. added functions to load palettes from files
5. Improved documentation
* added example for user-controlled color palettes
2019-07-28 20:59:09 +08:00
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
2020-09-21 19:47:54 +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
2020-09-21 19:47:54 +08:00
/** \brief return the plotted image only as a QImage */
2015-07-11 18:56:02 +08:00
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 */
2023-12-19 05:24:59 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , const QRectF & rect ) override ;
2019-08-01 04:10:26 +08:00
/** \brief determine min/max data value of the image */
virtual void cbGetDataMinMax ( double & imin , double & imax ) override ;
/** \brief determine min/max data value of the modifier image */
virtual void cbGetModifierDataMinMax ( double & imin , double & imax ) 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
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 ;
2023-07-22 20:26:02 +08:00
public Q_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 ( ) ;
2020-09-29 01:24:17 +08:00
const int xx = jkqtp_truncTo < int > ( ( x - this - > x ) / width * double ( Nx ) ) ;
const int yy = jkqtp_truncTo < int > ( ( y - this - > y ) / height * double ( Ny ) ) ;
2019-08-01 04:10:26 +08:00
if ( xx > = 0 & & xx < static_cast < int64_t > ( Nx ) & & yy > = 0 & & yy < static_cast < int64_t > ( Ny ) ) {
2019-05-19 04:41:38 +08:00
switch ( datatype ) {
2020-09-29 01:24:17 +08:00
case JKQTPMathImageDataType : : DoubleArray : return static_cast < double > ( ( static_cast < const double * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : FloatArray : return static_cast < double > ( ( static_cast < const float * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt8Array : return static_cast < double > ( ( static_cast < const uint8_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt16Array : return static_cast < double > ( ( static_cast < const uint16_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt32Array : return static_cast < double > ( ( static_cast < const uint32_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt64Array : return static_cast < double > ( ( static_cast < const uint64_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int8Array : return static_cast < double > ( ( static_cast < const int8_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int16Array : return static_cast < double > ( ( static_cast < const int16_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int32Array : return static_cast < double > ( ( static_cast < const int32_t * > ( data ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int64Array : return static_cast < double > ( ( static_cast < const int64_t * > ( data ) ) [ yy * Nx + xx ] ) ;
2019-05-19 04:41:38 +08:00
} }
return 0.0 ;
}
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getPixelValue ( int xIdx , int yIdx ) const {
// row-major in datastore
//ensureImageData();
if ( ! data ) return 0 ;
switch ( datatype ) {
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : DoubleArray :
2020-09-29 01:24:17 +08:00
return ( static_cast < const double * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : FloatArray :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const float * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt8Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint8_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt16Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint16_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt32Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint32_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt64Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint64_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int8Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int8_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int16Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int16_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int32Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int32_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int64Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int64_t * > ( data ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-05-19 04:41:38 +08:00
default :
return 0 ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
int JKQTPMathImage : : getSampleSize ( ) const {
switch ( datatype ) {
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : DoubleArray :
2019-05-19 04:41:38 +08:00
return sizeof ( double ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : FloatArray :
2019-05-19 04:41:38 +08:00
return sizeof ( float ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt8Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint8_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt16Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint16_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt32Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint32_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt64Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint64_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int8Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int8_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int16Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int16_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int32Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int32_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int64Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int64_t ) ;
default :
return 0 ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getModifierValueAt ( double x , double y )
{
ensureImageData ( ) ;
2020-09-29 01:24:17 +08:00
const int xx = jkqtp_truncTo < int > ( ( x - this - > x ) / width * double ( Nx ) ) ;
const int yy = jkqtp_truncTo < int > ( ( y - this - > y ) / height * double ( Ny ) ) ;
2019-05-19 04:41:38 +08:00
if ( xx > = 0 & & xx < ( int64_t ) Nx & & yy > = 0 & & yy < ( int64_t ) Ny ) {
switch ( datatypeModifier ) {
2020-09-29 01:24:17 +08:00
case JKQTPMathImageDataType : : DoubleArray : return ( static_cast < const double * > ( dataModifier ) ) [ yy * Nx + xx ] ;
case JKQTPMathImageDataType : : FloatArray : return static_cast < double > ( ( static_cast < const float * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt8Array : return static_cast < double > ( ( static_cast < const uint8_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt16Array : return static_cast < double > ( ( static_cast < const uint16_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt32Array : return static_cast < double > ( ( static_cast < const uint32_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : UInt64Array : return static_cast < double > ( ( static_cast < const uint64_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int8Array : return static_cast < double > ( ( static_cast < const int8_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int16Array : return static_cast < double > ( ( static_cast < const int16_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int32Array : return static_cast < double > ( ( static_cast < const int32_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
case JKQTPMathImageDataType : : Int64Array : return static_cast < double > ( ( static_cast < const int64_t * > ( dataModifier ) ) [ yy * Nx + xx ] ) ;
2019-05-19 04:41:38 +08:00
} }
return 0.0 ;
}
////////////////////////////////////////////////////////////////////////////////////////////////
double JKQTPMathImage : : getModifierPixelValue ( int xIdx , int yIdx ) const {
// row-major in datastore
//ensureImageData();
if ( ! dataModifier ) return 0 ;
switch ( datatypeModifier ) {
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : DoubleArray :
2020-09-29 01:24:17 +08:00
return ( static_cast < const double * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : FloatArray :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const float * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt8Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint8_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt16Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint16_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt32Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint32_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt64Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const uint64_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int8Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int8_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int16Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int16_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int32Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int32_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int64Array :
2020-09-29 01:24:17 +08:00
return static_cast < double > ( ( static_cast < const int64_t * > ( dataModifier ) ) [ yIdx * getNx ( ) + xIdx ] ) ;
2019-05-19 04:41:38 +08:00
default :
return 0 ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
int JKQTPMathImage : : getModifierSampleSize ( ) const {
switch ( datatypeModifier ) {
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : DoubleArray :
2019-05-19 04:41:38 +08:00
return sizeof ( double ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : FloatArray :
2019-05-19 04:41:38 +08:00
return sizeof ( float ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt8Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint8_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt16Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint16_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt32Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint32_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : UInt64Array :
2019-05-19 04:41:38 +08:00
return sizeof ( uint64_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int8Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int8_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int16Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int16_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int32Array :
2019-05-19 04:41:38 +08:00
return sizeof ( int32_t ) ;
2019-08-01 04:10:26 +08:00
case JKQTPMathImageDataType : : Int64Array :
2019-05-19 04:41:38 +08:00
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
2020-09-21 19:47:54 +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
2020-09-21 19:47:54 +08:00
/** \copydoc imageColumn */
2019-06-22 20:21:32 +08:00
virtual void setImageColumn ( size_t __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc imageColumn */
2019-04-22 19:27:50 +08:00
int getImageColumn ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc modifierColumn */
2019-04-22 19:27:50 +08:00
virtual void setModifierColumn ( int __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc modifierColumn */
2019-06-22 20:21:32 +08:00
virtual void setModifierColumn ( size_t __value ) ;
2020-09-21 19:47:54 +08:00
/** \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