21#ifndef jkqtpgraphsimage_H
22#define jkqtpgraphsimage_H
29#include "jkqtplotter/graphs/jkqtpscatter.h"
30#include "jkqtplotter/jkqtptools.h"
31#include "jkqtplotter/jkqtpbaseelements.h"
32#include "jkqtplotter/jkqtplotter_imexport.h"
33#include "jkqtplotter/jkqtpimagetools.h"
77 virtual bool getXMinMax(
double& minx,
double& maxx,
double& smallestGreaterZero)
override;
79 virtual bool getYMinMax(
double& miny,
double& maxy,
double& smallestGreaterZero)
override;
235 virtual void setData(
const void* data,
int Nx,
int Ny);
375 inline const QImage*
getImage()
const {
return this->image; }
403 virtual void setTitle(
const QString& title)
override;
512 inline double getValueAt(
double x,
double y);
515 inline int getSampleSize()
const;
517 inline double getPixelValue(
int xIdx,
int yIdx)
const;
520 inline double getModifierValueAt(
double x,
double y);
523 inline int getModifierSampleSize()
const;
525 inline double getModifierPixelValue(
int xIdx,
int yIdx)
const;
560 virtual void setTitle(
const QString& title)
override;
595 const int xx=jkqtp_truncTo<int>((
x-this->x)/
width*
double(
Nx));
596 const int yy=jkqtp_truncTo<int>((
y-this->y)/
height*
double(
Ny));
597 if (xx>=0 && xx<
static_cast<int64_t
>(
Nx) && yy>=0 && yy<
static_cast<int64_t
>(
Ny)) {
621 return (
static_cast<const double*
>(
data))[yIdx*
getNx()+xIdx];
623 return static_cast<double>((
static_cast<const float*
>(
data))[yIdx*
getNx()+xIdx]);
625 return static_cast<double>((
static_cast<const uint8_t*
>(
data))[yIdx*
getNx()+xIdx]);
627 return static_cast<double>((
static_cast<const uint16_t*
>(
data))[yIdx*
getNx()+xIdx]);
629 return static_cast<double>((
static_cast<const uint32_t*
>(
data))[yIdx*
getNx()+xIdx]);
631 return static_cast<double>((
static_cast<const uint64_t*
>(
data))[yIdx*
getNx()+xIdx]);
633 return static_cast<double>((
static_cast<const int8_t*
>(
data))[yIdx*
getNx()+xIdx]);
635 return static_cast<double>((
static_cast<const int16_t*
>(
data))[yIdx*
getNx()+xIdx]);
637 return static_cast<double>((
static_cast<const int32_t*
>(
data))[yIdx*
getNx()+xIdx]);
639 return static_cast<double>((
static_cast<const int64_t*
>(
data))[yIdx*
getNx()+xIdx]);
650 return sizeof(double);
652 return sizeof(float);
654 return sizeof(uint8_t);
656 return sizeof(uint16_t);
658 return sizeof(uint32_t);
660 return sizeof(uint64_t);
662 return sizeof(int8_t);
664 return sizeof(int16_t);
666 return sizeof(int32_t);
668 return sizeof(int64_t);
680 const int xx=jkqtp_truncTo<int>((
x-this->x)/
width*
double(
Nx));
681 const int yy=jkqtp_truncTo<int>((
y-this->y)/
height*
double(
Ny));
682 if (xx>=0 && xx<(int64_t)
Nx && yy>=0 && yy<(int64_t)
Ny) {
708 return static_cast<double>((
static_cast<const float*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
710 return static_cast<double>((
static_cast<const uint8_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
712 return static_cast<double>((
static_cast<const uint16_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
714 return static_cast<double>((
static_cast<const uint32_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
716 return static_cast<double>((
static_cast<const uint64_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
718 return static_cast<double>((
static_cast<const int8_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
720 return static_cast<double>((
static_cast<const int16_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
722 return static_cast<double>((
static_cast<const int32_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
724 return static_cast<double>((
static_cast<const int64_t*
>(
dataModifier))[yIdx*
getNx()+xIdx]);
735 return sizeof(double);
737 return sizeof(float);
739 return sizeof(uint8_t);
741 return sizeof(uint16_t);
743 return sizeof(uint32_t);
745 return sizeof(uint64_t);
747 return sizeof(int8_t);
749 return sizeof(int16_t);
751 return sizeof(int32_t);
753 return sizeof(int64_t);
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
class to plot an image from an 2-dimensional array of values stored in a column of the datastore
Definition jkqtpimage.h:771
JKQTPColumnMathImage(double x, double y, double width, double height, JKQTPlotter *parent)
class constructor
virtual bool usesColumn(int c) const override
returns true if the given column is used by the graph
JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, JKQTPMathImageColorPalette palette, JKQTPlotter *parent)
class constructor
virtual void ensureImageData() override
overwrite this to fill the data poiters before they are accessed (e.g. to load data from a column in ...
JKQTPColumnMathImage(JKQTBasePlotter *parent=nullptr)
class constructor
JKQTPColumnMathImage(JKQTPlotter *parent)
class constructor
int getImageColumn() const
column containing the displayed image
int getModifierColumn() const
column containing the modifier image
virtual void setImageColumn(int __value)
column containing the displayed image
virtual void setModifierColumn(int __value)
column containing the modifier image
int modifierColumn
column containing the modifier image
Definition jkqtpimage.h:864
int imageColumn
column containing the displayed image
Definition jkqtpimage.h:862
JKQTPColumnMathImage(double x, double y, double width, double height, JKQTBasePlotter *parent=nullptr)
class constructor
virtual void setImageColumn(size_t __value)
column containing the displayed image
JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter *parent=nullptr)
class constructor
JKQTPColumnMathImage(double x, double y, double width, double height, int imageColumn, JKQTPlotter *parent)
class constructor
virtual void setModifierColumn(size_t __value)
column containing the modifier image
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
this virtual base class of the (data-column based) graphs, which are part of a JKQTPlotter plot and w...
Definition jkqtpgraphsbase.h:429
base class for plotting an image
Definition jkqtpimage.h:40
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
JKQTPImageBase(double x, double y, double width, double height, JKQTPlotter *parent)
class constructor
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
JKQTPImageBase(double x, double y, double width, double height, JKQTBasePlotter *parent=nullptr)
class constructor
double getWidth() const
width of image
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
void setHeight(double __value)
height of image
double x
x coordinate of lower left corner
Definition jkqtpimage.h:104
double y
y coordinate of lower left corner
Definition jkqtpimage.h:106
JKQTPImageBase(JKQTBasePlotter *parent=nullptr)
class constructor
void setX(double __value)
x coordinate of lower left corner
double getHeight() const
height of image
double getY() const
y coordinate of lower left corner
double getX() const
x coordinate of lower left corner
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
JKQTPImageBase(JKQTPlotter *parent)
class constructor
void setWidth(double __value)
width of image
void plotImage(JKQTPEnhancedPainter &painter, QImage &image, double x, double y, double width, double height)
plot the given QImage onto the widget where the QImage fills the area defined by x,...
double height
height of image
Definition jkqtpimage.h:110
void setY(double __value)
y coordinate of lower left corner
double width
width of image
Definition jkqtpimage.h:108
class to plot an image from a QImage object
Definition jkqtpimage.h:296
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
virtual void setImage(QImage *image)
set an external image to be plotted, the image will NOT BE OWNED by the graph-object
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
const QImage * getImage() const
the image to be plotted. This is freed by the destructor, iff image_owned is set to true (....
Definition jkqtpimage.h:375
JKQTPImage(JKQTPlotter *parent)
class constructor
QAction * actCopyImage
QActions that copies the image into the clipboard.
Definition jkqtpimage.h:398
virtual void setImage(const QImage &image)
copy an external image into an internally owned copy
void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray())
saves the image (asking the user for a filename, if filename is empty)
QAction * actSaveImage
QActions that saves the image (asking the user for a filename)
Definition jkqtpimage.h:393
JKQTPImage(JKQTBasePlotter *parent=nullptr)
class constructor
void copyImagePlotAsImage()
copies the image into the clipboard
QImage * image
the image to be plotted. This is freed by the destructor, iff image_owned is set to true (....
Definition jkqtpimage.h:378
bool image_owned
indicates that the image image is owned by this object (i.e. freed, when the object is destroyed)
Definition jkqtpimage.h:380
void clear_image()
deletes the internal image
JKQTPImage(double x, double y, double width, double height, const QImage &image, JKQTBasePlotter *parent=nullptr)
class constructor
JKQTPImage(double x, double y, double width, double height, QImage *image, JKQTPlotter *parent)
class constructor
virtual void setParent(JKQTBasePlotter *parent) override
sets the parent painter class
virtual void setTitle(const QString &title) override
sets the title of the plot (for display in key!).
JKQTPImage(double x, double y, double width, double height, QImage *image, JKQTBasePlotter *parent=nullptr)
class constructor
QImage * getImage()
the image to be plotted. This is freed by the destructor, iff image_owned is set to true (....
Definition jkqtpimage.h:373
virtual ~JKQTPImage() override
JKQTPImage(double x, double y, double width, double height, const QImage &image, JKQTPlotter *parent)
class constructor
void createImageActions()
create QActions that are shown in the context menu of the JKQTPlotter
base class to hold an image from an 2-dimensional array of values
Definition jkqtpimage.h:134
double internalDataMin
internal storage for minimum of the image value range
Definition jkqtpimage.h:265
int getNx() const
width of the data array data in pt
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void *data, int Nx, int Ny, JKQTBasePlotter *parent=nullptr)
class constructor
QVector< double > getDataAsDoubleVector() const
returns the contents of the internal data image as a QVector<double>
double internalDataMax
internal storage for maximum of the image value range
Definition jkqtpimage.h:270
void setNx(size_t __value)
width of the data array data in pt
int Ny
height of the data array data in pt
Definition jkqtpimage.h:253
void setNy(size_t __value)
height of the data array data in pt
virtual JKQTPMathImageDataType getDatatype() const
datatype of the data array data
virtual void setDatatypeModifier(JKQTPMathImageDataType __value)
datatype of the data array data
virtual const void * getDataModifier() const
points to the data array, holding the modifier image
virtual void setDatatype(JKQTPMathImageDataType __value)
datatype of the data array data
virtual JKQTPMathImageDataType getDatatypeModifier() const
datatype of the data array data
double internalModifierMax
internal storage for maximum of the modifier image value range
Definition jkqtpimage.h:280
const void * data
points to the data array, holding the image
Definition jkqtpimage.h:247
virtual const void * getData() const
points to the data array, holding the image
virtual void setDataModifier(const void *__value)
points to the data array, holding the modifier image
JKQTPMathImageDataType datatype
datatype of the data array data
Definition jkqtpimage.h:249
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void *data, int Nx, int Ny, JKQTPlotter *parent)
class constructor
JKQTPMathImageDataType datatypeModifier
datatype of the data array data
Definition jkqtpimage.h:258
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
virtual void getModifierMinMax(double &imin, double &imax)
determine min/max data value of the image
virtual void setDataModifier(const void *data, JKQTPMathImageDataType datatype)
sets dataModifier ( points to the data array, holding the modifier image ) and datatypeModifier ( ...
int getNy() const
height of the data array data in pt
virtual void setData(const void *data, int Nx, int Ny)
sets data ( points to the data array, holding the image ), as well as the size of data (Nx: width...
void setNy(int __value)
height of the data array data in pt
void setNx(int __value)
width of the data array data in pt
QVector< double > getDataModifierAsDoubleVector() const
returns the contents of the internal modifier image as a QVector<double>
JKQTPMathImageBase(double x, double y, double width, double height, JKQTBasePlotter *parent=nullptr)
class constructor
JKQTPMathImageBase(JKQTBasePlotter *parent=nullptr)
class constructor
int Nx
width of the data array data in pt
Definition jkqtpimage.h:251
virtual void ensureImageData()
overwrite this to fill the data poiters before they are accessed (e.g. to load data from a column in ...
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPlotter *parent=nullptr)
class constructor
virtual void setData(const void *__value)
points to the data array, holding the image
virtual void setData(const void *data, int Nx, int Ny, JKQTPMathImageDataType datatype)
sets data ( points to the data array, holding the image ) and datatype ( datatype of the data arr...
virtual void getDataMinMax(double &imin, double &imax)
determine min/max data value of the image
double internalModifierMin
internal storage for minimum of the modifier image value range
Definition jkqtpimage.h:275
JKQTPMathImageBase(JKQTPlotter *parent)
class constructor
const void * dataModifier
points to the data array, holding the modifier image
Definition jkqtpimage.h:256
class to plot an image from an 2-dimensional array of values
Definition jkqtpimage.h:433
void saveColorbarPlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray())
saves an image of the current palette (asking the user for a filename, if filename is empty)
double getModifierValueAt(double x, double y)
return the value (raw data!) of the contained modifier image at the given coordinate
Definition jkqtpimage.h:677
virtual void setTitle(const QString &title) override
sets the title of the plot (for display in key!).
virtual QImage drawImage()
return the plotted image only as a QImage
JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void *data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter *parent)
class constructor
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
JKQTPMathImage(JKQTBasePlotter *parent=nullptr)
class constructor
QAction * actCopyImage
QActions that copies the image into the clipboard.
Definition jkqtpimage.h:547
void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray())
saves the image (asking the user for a filename, if filename is empty)
QAction * actSavePalette
QActions that saves the current palette.
Definition jkqtpimage.h:552
int getSampleSize() const
retrieve size of a single sample in the image data (i.e. size of the datatype)
Definition jkqtpimage.h:647
void copyImagePlotAsImage()
copies the image into the clipboard
void copyColorbarPlotAsImage()
copies an image of the current palette into the clipboard
double getModifierPixelValue(int xIdx, int yIdx) const
retrieve modifier image data at a given position as double
Definition jkqtpimage.h:700
virtual void drawOutside(JKQTPEnhancedPainter &painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) override
plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
virtual QImage drawOutsidePalette(uint8_t steps=200)
returns a QImage, which contains the plaette drawn outside the plot. steps is the number of data-setp...
int getModifierSampleSize() const
retrieve size of a single sample in the modifier image data (i.e. size of the datatype)
Definition jkqtpimage.h:732
double getValueAt(double x, double y)
return the value (raw data!) of the contained image at the given coordinate
Definition jkqtpimage.h:592
virtual void cbGetDataMinMax(double &imin, double &imax) override
determine min/max data value of the image
JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void *data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter *parent=nullptr)
class constructor
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
void initJKQTPMathImage()
virtual void cbGetModifierDataMinMax(double &imin, double &imax) override
determine min/max data value of the modifier image
QAction * actCopyPalette
QActions that copies the current palette.
Definition jkqtpimage.h:557
virtual void getOutsideSize(JKQTPEnhancedPainter &painter, int &leftSpace, int &rightSpace, int &topSpace, int &bottomSpace) override
if the graph plots outside the actual plot field of view (e.g. color bars, scale bars,...
virtual void setParent(JKQTBasePlotter *parent) override
sets the parent painter class
virtual void getModifierMinMax(double &imin, double &imax) override
determine min/max data value of the image
double getPixelValue(int xIdx, int yIdx) const
retrieve image data at a given position as double
Definition jkqtpimage.h:615
JKQTPMathImage(JKQTPlotter *parent)
class constructor
QAction * actSaveImage
QActions that saves the image (asking the user for a filename)
Definition jkqtpimage.h:542
virtual void getDataMinMax(double &imin, double &imax) override
determine min/max data value of the image
plotter widget for scientific plots (uses JKQTBasePlotter to do the actual drawing)
Definition jkqtplotter.h:364
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89