diff --git a/lib/jkqtplotter/jkqtpgraphsimage.cpp b/lib/jkqtplotter/jkqtpgraphsimage.cpp index 9249f6db1a..2568c3477c 100644 --- a/lib/jkqtplotter/jkqtpgraphsimage.cpp +++ b/lib/jkqtplotter/jkqtpgraphsimage.cpp @@ -889,18 +889,13 @@ JKQTPMathImage::JKQTPMathImage(JKQTBasePlotter *parent): JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent): - JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) + JKQTPMathImage(x, y, width, height, datatype, data, Nx, Ny, palette, parent->getPlotter()) { - initJKQTPMathImage(); - this->palette=palette; } JKQTPMathImage::JKQTPMathImage(JKQTPlotter *parent): - JKQTPMathImageBase(0, 0, 1, 1, JKQTPMathImageBase::UInt8Array, nullptr, 0, 0, parent) + JKQTPMathImage(parent->getPlotter()) { - initJKQTPMathImage(); - if (parent) this->palette=parent->getPlotter()->getCurrentPlotterStyle().defaultPalette; - } void JKQTPMathImage::setParent(JKQTBasePlotter* parent) { @@ -1661,19 +1656,23 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(JKQTBasePlotter *parent): this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,JKQTPMathImageGRAY,parent) +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, JKQTBasePlotter *parent): + JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,0,0,JKQTPMathImageGRAY,parent) { this->modifierColumn=-1; this->imageColumn=-1; this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter *parent): - JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,palette,parent) +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, JKQTPMathImageColorPalette palette, JKQTBasePlotter *parent): + JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,0,0,palette,parent) { this->modifierColumn=-1; this->imageColumn=imageColumn; + if (parent && imageColumn>=0 && parent->getDatastore()) { + Nx=parent->getDatastore()->getColumnImageWidth(imageColumn); + Ny=parent->getDatastore()->getColumnImageHeight(imageColumn); + } this->datatype=JKQTPMathImageBase::DoubleArray; } @@ -1682,27 +1681,19 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(JKQTPlotter *parent): { } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): - JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,JKQTPMathImageGRAY,parent) +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, JKQTPlotter *parent): + JKQTPColumnMathImage(x,y,width,height,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter *parent): - JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,palette,parent) +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, JKQTPMathImageColorPalette palette, JKQTPlotter *parent): + JKQTPColumnMathImage(x,y,width,height,imageColumn,palette,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageColumn=imageColumn; - this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPMathImage(x,y,width,height,JKQTPMathImageBase::DoubleArray,nullptr,Nx,Ny,JKQTPMathImageGRAY,parent) + +JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, JKQTPlotter *parent): + JKQTPColumnMathImage(x,y,width,height,imageColumn,JKQTPMathImageGRAY,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageColumn=imageColumn; - this->datatype=JKQTPMathImageBase::DoubleArray; } void JKQTPColumnMathImage::setImageColumn(int __value) diff --git a/lib/jkqtplotter/jkqtpgraphsimage.h b/lib/jkqtplotter/jkqtpgraphsimage.h index cb78aecfc8..6a820ea3fc 100644 --- a/lib/jkqtplotter/jkqtpgraphsimage.h +++ b/lib/jkqtplotter/jkqtpgraphsimage.h @@ -40,13 +40,35 @@ class JKQTP_LIB_EXPORT JKQTPImageBase: public JKQTPGraph { Q_OBJECT public: - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPImageBase(JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \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 + * + */ JKQTPImageBase(double x, double y, double width, double height, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPImageBase(JKQTPlotter* parent); - /** \brief class constructor */ + /** \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 + * + */ JKQTPImageBase(double x, double y, double width, double height, JKQTPlotter* parent); /** \brief plots a key marker inside the specified rectangle \a rect */ virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; @@ -144,15 +166,65 @@ class JKQTP_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPMathImageBase(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 parent parent plotter object + * + */ JKQTPMathImageBase(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 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 + * + */ JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPMathImageBase(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 parent parent plotter object + * + */ JKQTPMathImageBase(double x, double y, double width, double height, JKQTPlotter* 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 parent parent plotter object + * + */ JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); /** \brief plots a key marker inside the specified rectangle \a rect */ @@ -187,15 +259,20 @@ class JKQTP_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { /*! \copydoc modifierMode */ ModifierMode getModifierMode() const; + /** \brief sets dataModifier (\copybrief dataModifier) and datatypeModifier (\copybrief datatypeModifier) */ virtual void setDataModifier(void* data, DataType datatype); + /** \brief sets data (\copybrief data) and datatype (\copybrief datatype), as well as the size of data (Nx: \copybrief Nx and Ny: \copybrief Ny) */ virtual void setData(void* data, int Nx, int Ny, DataType datatype); + /** \brief sets data (\copybrief data), as well as the size of data (Nx: \copybrief Nx and Ny: \copybrief Ny) */ virtual void setData(void* data, int Nx, int Ny); /** \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); + /** \brief returns the contents of the internal data image as a QVector */ QVector getDataAsDoubleVector() const; + /** \brief returns the contents of the internal modifier image as a QVector */ QVector getDataModifierAsDoubleVector() const; protected: /** \brief points to the data array, holding the image */ @@ -212,16 +289,40 @@ class JKQTP_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase { /** \brief datatype of the data array data */ DataType datatypeModifier; + /** \brief how to apply the modifier column dataModifier + * \see ModifierMode + */ ModifierMode modifierMode; + /** \brief internal storage for minimum of the image value range + * + * This is set e.g. when calling drawImage() or draw() + */ double internalDataMin; + /** \brief internal storage for maximum of the image value range + * + * This is set e.g. when calling drawImage() or draw() + */ double internalDataMax; + /** \brief internal storage for minimum of the modifier image value range + * + * This is set e.g. when calling modifyImage() or draw() + */ double internalModifierMin; + /** \brief internal storage for maximum of the modifier image value range + * + * This is set e.g. when calling modifyImage() or draw() + */ 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 modify the given image \a img, using the internally set modifier data + * \see dataModifier, datatypeModifier + */ void modifyImage(QImage& img); + /** \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 + */ void modifyImage(QImage& img, void* dataModifier, DataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax); @@ -238,17 +339,59 @@ class JKQTP_LIB_EXPORT JKQTPImage: public JKQTPImageBase { Q_OBJECT public: - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPImage(JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPImage(JKQTPlotter* parent); - /** \brief class constructor, which points to an external image (not owned by this object!!!) */ + /** \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 + * + */ JKQTPImage(double x, double y, double width, double height, QImage* image, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor, which points to an external image (not owned by this object!!!) */ + /** \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 + * + */ JKQTPImage(double x, double y, double width, double height, QImage* image, JKQTPlotter* parent); - /** \brief class constructor, which generates an internal image object, by copying \a image */ + /** \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 + * + */ JKQTPImage(double x, double y, double width, double height, const QImage& image, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor, which generates an internal image object, by copying \a image */ + /** \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 + * + */ JKQTPImage(double x, double y, double width, double height, const QImage& image, JKQTPlotter* parent); virtual ~JKQTPImage() override; @@ -276,16 +419,41 @@ class JKQTP_LIB_EXPORT JKQTPImage: public JKQTPImageBase { /** \brief indicates that the image \a image is owned by this object (i.e. freed, when the object is destroyed) */ bool image_owned; + /** \brief create QActions that are shown in the context menu of the JKQTPlotter + * + * \see actSaveImage, actCopyImage, saveImagePlotAsImage(), copyImagePlotAsImage() + */ void createImageActions(); protected: + /** \brief QActions that saves the image (asking the user for a filename) + * + * \see actSaveImage, saveImagePlotAsImage() + */ QAction* actSaveImage; + /** \brief QActions that copies the image into the clipboard + * + * \see actCopyImage, copyImagePlotAsImage() + */ QAction* actCopyImage; public: + /** \copydoc JKQTPImageBase::setParent() */ virtual void setParent(JKQTBasePlotter* parent) override; + /** \copydoc JKQTPImageBase::setTitle() */ virtual void setTitle(const QString& title) override; public slots: + /** \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 QImage::save() + * + * \see actSaveImage, saveImagePlotAsImage(), QImage::save() + */ void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray()); + /** \brief copies the image into the clipboard + * + * \see actCopyImage, copyImagePlotAsImage() + */ void copyImagePlotAsImage(); }; @@ -304,10 +472,45 @@ class JKQTP_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase { Q_OBJECT public: - /** \brief class constructor */ - 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 parent parent plotter object + */ JKQTPMathImage(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 + * + */ + 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 + * + */ JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPMathImage(JKQTPlotter* parent); /** \brief plots the graph to the plotter object specified as parent */ @@ -538,26 +741,77 @@ class JKQTP_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase { QColor infColor; - /** \brief object used for color bar axes + /** \brief object used for color bar axes (right border, image data) * * \note this axis has some kind of a special role. It is used to format color bar axes */ JKQTPVerticalIndependentAxis* colorBarRightAxis; + /** \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 + */ JKQTPHorizontalIndependentAxis* colorBarTopAxis; + /** \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 + */ JKQTPVerticalIndependentAxis* modifierColorBarTopAxis; + /** \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 + */ JKQTPHorizontalIndependentAxis* modifierColorBarRightAxis; protected: + /** \brief QActions that saves the image (asking the user for a filename) + * + * \see actSaveImage, saveImagePlotAsImage() + */ QAction* actSaveImage; + /** \brief QActions that copies the image into the clipboard + * + * \see actCopyImage, copyImagePlotAsImage() + */ QAction* actCopyImage; + /** \brief QActions that saves the current palette + * + * \see actSaveImage, saveColorbarPlotAsImage() + */ QAction* actSavePalette; + /** \brief QActions that copies the current palette + * + * \see actCopyImage, copyColorbarPlotAsImage() + */ QAction* actCopyPalette; public: + /** \copydoc JKQTPImageBase::setTitle() */ virtual void setTitle(const QString& title) override; public slots: + /** \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 QImage::save() + * + * \see actSaveImage, saveImagePlotAsImage(), QImage::save() + */ void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray()); + /** \brief copies the image into the clipboard + * + * \see actCopyImage, copyImagePlotAsImage() + */ void copyImagePlotAsImage(); + /** \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 QImage::save() + * + * \see actSavePalette, saveColorbarPlotAsImage(), QImage::save() + */ void saveColorbarPlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray()); + /** \brief copies an image of the current palette into the clipboard + * + * \see actCopyPalette, copyColorbarPlotAsImage() + */ void copyColorbarPlotAsImage(); }; @@ -745,15 +999,71 @@ class JKQTP_LIB_EXPORT JKQTPColumnMathImage: public JKQTPMathImage { Q_OBJECT public: - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPColumnMathImage(JKQTBasePlotter* parent=nullptr); - JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \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 + */ JKQTPColumnMathImage(JKQTPlotter* parent); - JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); - JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, int Nx, int Ny, 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 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); /*! \copydoc imageColumn */ virtual void setImageColumn(int __value); @@ -775,7 +1085,14 @@ class JKQTP_LIB_EXPORT JKQTPColumnMathImage: public JKQTPMathImage { /** \brief column containing the modifier image */ int modifierColumn; + /** \copydoc JKQTPMathImage::ensureImageData() */ virtual void ensureImageData() override; + + private: + using JKQTPMathImage::setData; + using JKQTPMathImage::setDatatype; + using JKQTPMathImage::setDataModifier; + using JKQTPMathImage::setDatatypeModifier; }; diff --git a/lib/jkqtplotter/jkqtpgraphsimagergb.cpp b/lib/jkqtplotter/jkqtpgraphsimagergb.cpp index 312ca10518..11ba38c006 100644 --- a/lib/jkqtplotter/jkqtpgraphsimagergb.cpp +++ b/lib/jkqtplotter/jkqtpgraphsimagergb.cpp @@ -129,9 +129,8 @@ JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double he JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent): - JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) + JKQTPRGBMathImage(x, y, width, height, datatype, data, Nx, Ny, parent->getPlotter()) { - initObject(); } JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTBasePlotter *parent): @@ -142,9 +141,8 @@ JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTBasePlotter *parent): JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTPlotter *parent): - JKQTPMathImageBase(0,0,0,0, DoubleArray, nullptr, 0, 0, parent) + JKQTPRGBMathImage(parent->getPlotter()) { - initObject(); } void JKQTPRGBMathImage::setParent(JKQTBasePlotter* parent) { @@ -1150,7 +1148,7 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTBasePlotter *parent): this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter *parent): +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, JKQTBasePlotter *parent): JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) { this->modifierColumn=-1; @@ -1160,85 +1158,73 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,0,0,parent) { this->modifierColumn=-1; this->imageRColumn=imageRColumn; this->imageGColumn=-1; this->imageBColumn=-1; this->datatype=JKQTPMathImageBase::DoubleArray; + if (parent && imageRColumn>=0 && parent->getDatastore()) { + Nx=parent->getDatastore()->getColumnImageWidth(imageRColumn); + Ny=parent->getDatastore()->getColumnImageHeight(imageRColumn); + } } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,0,0,parent) { this->modifierColumn=-1; this->imageRColumn=imageRColumn; this->imageGColumn=imageGColumn; this->imageBColumn=-1; this->datatype=JKQTPMathImageBase::DoubleArray; + if (parent && imageRColumn>=0 && parent->getDatastore()) { + Nx=parent->getDatastore()->getColumnImageWidth(imageRColumn); + Ny=parent->getDatastore()->getColumnImageHeight(imageRColumn); + } } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,0,0,parent) { this->modifierColumn=-1; this->imageRColumn=imageRColumn; this->imageGColumn=imageGColumn; this->imageBColumn=imageBColumn; this->datatype=JKQTPMathImageBase::DoubleArray; + if (parent && imageRColumn>=0 && parent->getDatastore()) { + Nx=parent->getDatastore()->getColumnImageWidth(imageRColumn); + Ny=parent->getDatastore()->getColumnImageHeight(imageRColumn); + } } JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTPlotter *parent): - JKQTPRGBMathImage(0,0,0,0,DoubleArray,nullptr,0,0,parent) + JKQTPColumnRGBMathImage(parent->getPlotter()) { - this->modifierColumn=-1; - this->imageRColumn=-1; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, JKQTPlotter *parent): + JKQTPColumnRGBMathImage(x,y,width,height,Nx,Ny,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageRColumn=-1; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, JKQTPlotter *parent): + JKQTPColumnRGBMathImage(x,y,width,height,imageRColumn,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, JKQTPlotter *parent): + JKQTPColumnRGBMathImage(x,y,width,height,imageRColumn,imageGColumn,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=imageGColumn; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; } -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, JKQTPlotter *parent): + JKQTPColumnRGBMathImage(x,y,width,height,imageRColumn,imageGColumn,imageBColumn,parent->getPlotter()) { - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=imageGColumn; - this->imageBColumn=imageBColumn; - this->datatype=JKQTPMathImageBase::DoubleArray; } + bool JKQTPColumnRGBMathImage::usesColumn(int c) const { return (c==imageRColumn)||(c==imageBColumn)||(c==imageGColumn)||(c==modifierColumn); diff --git a/lib/jkqtplotter/jkqtpgraphsimagergb.h b/lib/jkqtplotter/jkqtpgraphsimagergb.h index 04152589a1..e803e2eb75 100644 --- a/lib/jkqtplotter/jkqtpgraphsimagergb.h +++ b/lib/jkqtplotter/jkqtpgraphsimagergb.h @@ -46,16 +46,46 @@ class JKQTP_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { using JKQTPMathImageBase::setData; - /** \brief class constructor */ + /** \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 + * + */ JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \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 + * + */ JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPRGBMathImage(JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPRGBMathImage(JKQTPlotter* parent); /** \brief plots the graph to the plotter object specified as parent */ @@ -316,21 +346,57 @@ class JKQTP_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { bool colorbarsSideBySide; - /** \brief object used for color bar axes + /** \brief object used for color bar axes (right border, red image data) * * \note this axis has some kind of a special role. It is used to format color bar axes */ JKQTPVerticalIndependentAxis* colorBarRightAxis; + /** \brief object used for color bar axes (top border, red image data) + * + * \note this axis has some kind of a special role. It is used to format color bar axes + */ JKQTPHorizontalIndependentAxis* colorBarTopAxis; + /** \brief object used for color bar axes (right border, green image data) + * + * \note this axis has some kind of a special role. It is used to format color bar axes + */ JKQTPVerticalIndependentAxis* colorBarRightAxisG; + /** \brief object used for color bar axes (top border, green image data) + * + * \note this axis has some kind of a special role. It is used to format color bar axes + */ JKQTPHorizontalIndependentAxis* colorBarTopAxisG; + /** \brief object used for color bar axes (right border, blue image data) + * + * \note this axis has some kind of a special role. It is used to format color bar axes + */ JKQTPVerticalIndependentAxis* colorBarRightAxisB; + /** \brief object used for color bar axes (top border, blue image data) + * + * \note this axis has some kind of a special role. It is used to format color bar axes + */ JKQTPHorizontalIndependentAxis* colorBarTopAxisB; + /** \brief internal storage for minimum of the green image value range + * + * This is set e.g. when calling drawImage() or draw() + */ double internalDataMinG; + /** \brief internal storage for maximum of the green image value range + * + * This is set e.g. when calling drawImage() or draw() + */ double internalDataMaxG; + /** \brief internal storage for minimum of the blue image value range + * + * This is set e.g. when calling drawImage() or draw() + */ double internalDataMinB; + /** \brief internal storage for maximum of the blue image value range + * + * This is set e.g. when calling drawImage() or draw() + */ double internalDataMaxB; protected: @@ -366,18 +432,114 @@ class JKQTP_LIB_EXPORT JKQTPColumnRGBMathImage: public JKQTPRGBMathImage { Q_OBJECT public: - /** \brief class constructor */ + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPColumnRGBMathImage(JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ + /** \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 + * + */ + JKQTPColumnRGBMathImage(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 imageRColumn column for red channel to be plotted + * \param palette color palette to use for the plotting + * \param parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, 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 imageRColumn column for red channel to be plotted + * \param imageGColumn column for green channel to be plotted + * \param palette color palette to use for the plotting + * \param parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, 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 imageRColumn column for red channel to be plotted + * \param imageGColumn column for green channel to be plotted + * \param imageBColumn column for blue channel to be plotted + * \param palette color palette to use for the plotting + * \param parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, JKQTBasePlotter* parent=nullptr); + /** \brief class constructor + * + * \param parent parent plotter object + */ JKQTPColumnRGBMathImage(JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, 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 parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(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 imageRColumn column for red channel to be plotted + * \param palette color palette to use for the plotting + * \param parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, 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 imageRColumn column for red channel to be plotted + * \param imageGColumn column for green channel to be plotted + * \param palette color palette to use for the plotting + * \param parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, 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 imageRColumn column for red channel to be plotted + * \param imageGColumn column for green channel to be plotted + * \param imageBColumn column for blue channel to be plotted + * \param palette color palette to use for the plotting + * \param parent parent plotter object + * + */ + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, JKQTPlotter* parent); /*! \copydoc imageRColumn */ virtual void setImageRColumn(int __value); @@ -407,8 +569,20 @@ class JKQTP_LIB_EXPORT JKQTPColumnRGBMathImage: public JKQTPRGBMathImage { int imageBColumn; /** \brief column containing the modifier image */ int modifierColumn; - + /** \copydoc JKQTPRGBMathImage::ensureImageData() */ void ensureImageData() override; + + private: + using JKQTPRGBMathImage::setData; + using JKQTPRGBMathImage::setDatatype; + using JKQTPRGBMathImage::setDataR; + using JKQTPRGBMathImage::setDatatypeR; + using JKQTPRGBMathImage::setDataG; + using JKQTPRGBMathImage::setDatatypeG; + using JKQTPRGBMathImage::setDataB; + using JKQTPRGBMathImage::setDatatypeB; + using JKQTPRGBMathImage::setDataModifier; + using JKQTPRGBMathImage::setDatatypeModifier; };