improved/breaking change: image plots now manage CONST-data, not plain pointer arrays... This is OK, since the raw data is never owned nor modified by the plot, only referenced!

This commit is contained in:
jkriege2 2020-09-28 19:24:17 +02:00
parent 48ec6060ab
commit 58403f8905
12 changed files with 370 additions and 351 deletions

View File

@ -38,6 +38,7 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
<li>improved/breaking change: extended styling system for graphs.</li> <li>improved/breaking change: extended styling system for graphs.</li>
<li>improved/breaking change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)</li> <li>improved/breaking change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)</li>
<li>improved/breaking change: made more functions and function parameters const</li> <li>improved/breaking change: made more functions and function parameters const</li>
<li>improved/breaking change: image plots now manage CONST-data, not plain pointer arrays... This is OK, since the raw data is never owned nor modified by the plot, only referenced!.</li>
<li>bugfixed/improved: aspect ratio handling in JKQTPlotter.</li> <li>bugfixed/improved: aspect ratio handling in JKQTPlotter.</li>
<li>new: added geometric plot objects JKQTPGeoArrow to draw arrows (aka lines with added line-end decorators, also extended JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines to draw line-end decorator (aka arrows)</li> <li>new: added geometric plot objects JKQTPGeoArrow to draw arrows (aka lines with added line-end decorators, also extended JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines to draw line-end decorator (aka arrows)</li>
<li>new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves</li> <li>new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves</li>

View File

@ -2986,7 +2986,7 @@ QString ModifierModeToString(const JKQTPMathImageModifierMode &mode) {
return "none"; return "none";
} }
void JKQTPModifyImage(QImage &img, JKQTPMathImageModifierMode modifierMode, void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax) void JKQTPModifyImage(QImage &img, JKQTPMathImageModifierMode modifierMode, const void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax)
{ {
if (!dataModifier) return; if (!dataModifier) return;
//getModifierMinMax(internalModifierMin, internalModifierMax); //getModifierMinMax(internalModifierMin, internalModifierMax);
@ -3011,16 +3011,16 @@ void JKQTPModifyImage(QImage &img, JKQTPMathImageModifierMode modifierMode, void
} }
//qDebug()<<"mod: "<<modifierMode<<" ch:"<<modChannel<<" rgb:"<<rgbModMode; //qDebug()<<"mod: "<<modifierMode<<" ch:"<<modChannel<<" rgb:"<<rgbModMode;
switch(datatypeModifier) { switch(datatypeModifier) {
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<const double*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<const float*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<const uint8_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<const uint16_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<const uint32_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<const uint64_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<const int8_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<const int16_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<const int32_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<const int64_t*>(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break;
} }
} }

View File

@ -549,7 +549,7 @@ inline QVector<double> JKQTPImagePlot_BarrayToDVector(const bool* input, int N)
*/ */
template <class T> template <class T>
inline double JKQTPImagePlot_getImageMin(T* dbl, int width, int height) inline double JKQTPImagePlot_getImageMin(const T* dbl, int width, int height)
{ {
if (!dbl || width<=0 || height<=0) if (!dbl || width<=0 || height<=0)
return 0; return 0;
@ -580,7 +580,7 @@ inline double JKQTPImagePlot_getImageMin(T* dbl, int width, int height)
*/ */
template <class T> template <class T>
inline double JKQTPImagePlot_getImageMax(T* dbl, int width, int height) inline double JKQTPImagePlot_getImageMax(const T* dbl, int width, int height)
{ {
if (!dbl || width<=0 || height<=0) if (!dbl || width<=0 || height<=0)
return 0; return 0;
@ -623,7 +623,7 @@ inline double JKQTPImagePlot_getImageMax(T* dbl, int width, int height)
leave alpha as it is. leave alpha as it is.
*/ */
template <class T> template <class T>
inline void JKQTPImagePlot_array2RGBimage(T* dbl_in, int width, int height, QImage &img, int channel, double minColor, double maxColor, JKQTPRGBMathImageRGBMode rgbMode=JKQTPRGBMathImageModeRGBMode, bool logScale=false, double logBase=10.0) inline void JKQTPImagePlot_array2RGBimage(const T* dbl_in, int width, int height, QImage &img, int channel, double minColor, double maxColor, JKQTPRGBMathImageRGBMode rgbMode=JKQTPRGBMathImageModeRGBMode, bool logScale=false, double logBase=10.0)
{ {
if (!dbl_in || width<=0 || height<=0) if (!dbl_in || width<=0 || height<=0)
return; return;
@ -653,16 +653,18 @@ inline void JKQTPImagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma
} }
T* dbl=dbl_in; const T* dbl=dbl_in;
T* dbllog=nullptr;
if (logScale) { if (logScale) {
double logB=log10(logBase); double logB=log10(logBase);
dbl=static_cast<T*>(malloc(width*height*sizeof(T))); dbllog=static_cast<T*>(malloc(width*height*sizeof(T)));
//memcpy(dbl, dbl_in, width*height*sizeof(T)); //memcpy(dbl, dbl_in, width*height*sizeof(T));
for (int i=0; i<width*height; i++) { for (int i=0; i<width*height; i++) {
dbl[i]=log10(dbl_in[i])/logB; dbllog[i]=log10(dbl_in[i])/logB;
} }
min=log10(min)/logB; min=log10(min)/logB;
max=log10(max)/logB; max=log10(max)/logB;
dbl=dbllog;
} }
double delta=max-min; double delta=max-min;
@ -864,7 +866,7 @@ inline void JKQTPImagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma
} }
} }
if (logScale) free(dbl); if (logScale) free(dbllog);
} }
@ -1069,7 +1071,7 @@ QString JKQTCOMMON_LIB_EXPORT ModifierModeToString(const JKQTPMathImageModifierM
/** \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 ) /** \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 )
\ingroup jkqtplotter_imagelots_tools \ingroup jkqtplotter_imagelots_tools
*/ */
void JKQTCOMMON_LIB_EXPORT JKQTPModifyImage(QImage& img, JKQTPMathImageModifierMode modifierMode, void* dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax); void JKQTCOMMON_LIB_EXPORT JKQTPModifyImage(QImage& img, JKQTPMathImageModifierMode modifierMode, const void* dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax);

View File

@ -63,7 +63,7 @@ void JKQTPContourPlot::draw(JKQTPEnhancedPainter &painter)
int64_t colChecksum=-1; int64_t colChecksum=-1;
if (data && Nx*Ny>0) { if (data && Nx*Ny>0) {
colChecksum=static_cast<int64_t>(qChecksum(reinterpret_cast<char*>(data), Nx*Ny* getSampleSize())); colChecksum=static_cast<int64_t>(qChecksum(reinterpret_cast<const char*>(data), Nx*Ny* getSampleSize()/sizeof(char)));
} }
/*if (parent && parent->getDatastore() && imageColumn>=0) { /*if (parent && parent->getDatastore() && imageColumn>=0) {
colChecksum=static_cast<int64_t>(parent->getDatastore()->getColumnChecksum(imageColumn)); colChecksum=static_cast<int64_t>(parent->getDatastore()->getColumnChecksum(imageColumn));

View File

@ -132,62 +132,68 @@ void JKQTPImageBase::plotImage(JKQTPEnhancedPainter& painter, QImage& image, dou
} }
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
double xmin=parent->getXMin(); // determine full shown plot rectangle in pixel coordinates
double xmax=parent->getXMax(); const double xmin=parent->getXMin();
double ymin=parent->getYMin(); const double xmax=parent->getXMax();
double ymax=parent->getYMax(); const double ymin=parent->getYMin();
QPointF pp1=transform(xmin,ymax); const double ymax=parent->getYMax();
QPointF pp2=transform(xmax,ymin); QPointF pix_plot_topleft=transform(xmin,ymax);
QRectF pr(pp1, pp2); QPointF pix_plot_bottomright=transform(xmax,ymin);
QRectF pix_plotrectangle(pix_plot_topleft, pix_plot_bottomright);
// these flags say, whether to mirror the image in one or the other direction, before plotting
bool mirrx=false; bool mirrx=false;
bool mirry=false; bool mirry=false;
QPointF p1=transform(x,y+height); // determine pixel coordinates of image (x..x+width / y..y+width)
QPointF p2=transform(x+width,y); QPointF pix_topelft=transform(x,y+height);
if (p1.x()>p2.x()) { QPointF pix_bottomright=transform(x+width,y);
double tmp=p1.x(); if (pix_topelft.x()>pix_bottomright.x()) {
p1.setX(p2.x()); double tmp=pix_topelft.x();
p2.setX(tmp); pix_topelft.setX(pix_bottomright.x());
tmp=pp1.x(); pix_bottomright.setX(tmp);
pp1.setX(pp2.x()); tmp=pix_plot_topleft.x();
pp2.setX(tmp); pix_plot_topleft.setX(pix_plot_bottomright.x());
pix_plot_bottomright.setX(tmp);
mirrx=true; mirrx=true;
} }
if (p1.y()>p2.y()) { if (pix_topelft.y()>pix_bottomright.y()) {
double tmp=p1.y(); double tmp=pix_topelft.y();
p1.setY(p2.y()); pix_topelft.setY(pix_bottomright.y());
p2.setY(tmp); pix_bottomright.setY(tmp);
tmp=pp1.y(); tmp=pix_plot_topleft.y();
pp1.setY(pp2.y()); pix_plot_topleft.setY(pix_plot_bottomright.y());
pp2.setY(tmp); pix_plot_bottomright.setY(tmp);
mirry=true; mirry=true;
} }
QRectF r(p1, p2); const QRectF pix_imagerect(pix_topelft, pix_bottomright);
if (image.width()>0 && image.height()>0 && !image.isNull()) { if (image.width()>0 && image.height()>0 && !image.isNull()) {
if (r.width()<2*pr.width() && r.height()<2*pr.height()) { // now we determine, whether to directly draw the image (if its size is smaller than twice the plot rectangle,
// or not ...
if (pix_imagerect.width()<2.0*pix_plotrectangle.width() && pix_imagerect.height()<2.0*pix_plotrectangle.height()) {
//painter.drawImage(QRectF(p1.x(), p2.y(), fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y())), image); //painter.drawImage(QRectF(p1.x(), p2.y(), fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y())), image);
painter.drawImage(QPointF(p1.x(), p1.y()), image.mirrored(mirrx, mirry).scaled(QSize(fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y())), Qt::IgnoreAspectRatio, Qt::FastTransformation)); painter.drawImage(QPointF(pix_topelft.x(), pix_topelft.y()), image.mirrored(mirrx, mirry).scaled(QSize(fabs(pix_bottomright.x()-pix_topelft.x()), fabs(pix_bottomright.y()-pix_topelft.y())), Qt::IgnoreAspectRatio, Qt::FastTransformation));
//qDebug()<<"\nimage.size = "<<image.size() <<" SIMPLE!"; //qDebug()<<"\nimage.size = "<<image.size() <<" SIMPLE!";
} else { } else {
double pixwidth=fabs(p2.x()-p1.x())/static_cast<double>(image.width()); // ... if the image is much larger than the plot rectangle, we cut a potion from the image, before plotting
double pixheight=fabs(p2.y()-p1.y())/static_cast<double>(image.height()); const double pixwidth=fabs(pix_bottomright.x()-pix_topelft.x())/static_cast<double>(image.width());
const double pixheight=fabs(pix_bottomright.y()-pix_topelft.y())/static_cast<double>(image.height());
//qDebug()<<"\nimage.size = "<<image.size(); //qDebug()<<"\nimage.size = "<<image.size();
//qDebug()<<"size = "<<QSizeF(width, height); //qDebug()<<"size = "<<QSizeF(width, height);
//qDebug()<<"pixsize = "<<QSizeF(pixwidth, pixheight); //qDebug()<<"pixsize = "<<QSizeF(pixwidth, pixheight);
//qDebug()<<"p1 = "<<p1<< " p2 = "<<p2; //qDebug()<<"p1 = "<<p1<< " p2 = "<<p2;
//qDebug()<<"pp1 = "<<pp1<<" pp2 = "<<pp2; //qDebug()<<"pp1 = "<<pp1<<" pp2 = "<<pp2;
QPointF ps1(floor((pp1.x()-p1.x())/pixwidth), floor((pp1.y()-p1.y())/pixheight)); QPointF ps1(floor((pix_plot_topleft.x()-pix_topelft.x())/pixwidth), floor((pix_plot_topleft.y()-pix_topelft.y())/pixheight));
QPointF ps2=ps1+QPointF(ceil(fabs(pp2.x()-pp1.x())/pixwidth), ceil(fabs(pp2.y()-pp1.y())/pixheight)); QPointF ps2=ps1+QPointF(ceil(fabs(pix_plot_bottomright.x()-pix_plot_topleft.x())/pixwidth), ceil(fabs(pix_plot_bottomright.y()-pix_plot_topleft.y())/pixheight));
if (ps1.x()<0) ps1.setX(0); if (ps1.x()<0) ps1.setX(0);
if (ps1.y()<0) ps1.setY(0); if (ps1.y()<0) ps1.setY(0);
if (ps2.x()>image.width()) ps2.setX(image.width()); if (ps2.x()>image.width()) ps2.setX(image.width());
if (ps2.y()>image.height()) ps2.setY(image.height()); if (ps2.y()>image.height()) ps2.setY(image.height());
QRectF source(ps1, ps2); const QRectF source(ps1, ps2);
QRectF target(p1.x()+ps1.x()*pixwidth, p1.y()+ps1.y()*pixheight, source.width()*pixwidth, source.height()*pixheight); const QRectF target(pix_topelft.x()+ps1.x()*pixwidth, pix_topelft.y()+ps1.y()*pixheight, source.width()*pixwidth, source.height()*pixheight);
//qDebug()<<"source = "<<source; //qDebug()<<"source = "<<source;
//qDebug()<<"target = "<<target; //qDebug()<<"target = "<<target;
painter.drawImage(target, image.mirrored(mirrx, mirry), source); painter.drawImage(target, image.mirrored(mirrx, mirry), source);
@ -376,7 +382,7 @@ void JKQTPImage::copyImagePlotAsImage()
JKQTPMathImageBase::JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent): JKQTPMathImageBase::JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTBasePlotter* parent):
JKQTPImageBase(x, y, width, height, parent) JKQTPImageBase(x, y, width, height, parent)
{ {
this->data=data; this->data=data;
@ -388,7 +394,7 @@ JKQTPMathImageBase::JKQTPMathImageBase(double x, double y, double width, double
} }
JKQTPMathImageBase::JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent): JKQTPMathImageBase::JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTPlotter* parent):
JKQTPImageBase(x, y, width, height, parent) JKQTPImageBase(x, y, width, height, parent)
{ {
this->data=data; this->data=data;
@ -433,12 +439,12 @@ int JKQTPMathImageBase::getNy() const
return this->Ny; return this->Ny;
} }
void JKQTPMathImageBase::setData(void *__value) void JKQTPMathImageBase::setData(const void *__value)
{ {
this->data = __value; this->data = __value;
} }
void *JKQTPMathImageBase::getData() const const void *JKQTPMathImageBase::getData() const
{ {
return this->data; return this->data;
} }
@ -453,12 +459,12 @@ JKQTPMathImageDataType JKQTPMathImageBase::getDatatype() const
return this->datatype; return this->datatype;
} }
void JKQTPMathImageBase::setDataModifier(void *__value) void JKQTPMathImageBase::setDataModifier(const void *__value)
{ {
this->dataModifier = __value; this->dataModifier = __value;
} }
void *JKQTPMathImageBase::getDataModifier() const const void *JKQTPMathImageBase::getDataModifier() const
{ {
return this->dataModifier; return this->dataModifier;
} }
@ -520,20 +526,20 @@ JKQTPMathImageBase::JKQTPMathImageBase(double x, double y, double width, double
datatypeModifier=JKQTPMathImageDataType::DoubleArray; datatypeModifier=JKQTPMathImageDataType::DoubleArray;
} }
void JKQTPMathImageBase::setData(void* data, int Nx, int Ny, JKQTPMathImageDataType datatype) { void JKQTPMathImageBase::setData(const void *data, int Nx, int Ny, JKQTPMathImageDataType datatype) {
this->data=data; this->data=data;
this->datatype=datatype; this->datatype=datatype;
this->Nx=Nx; this->Nx=Nx;
this->Ny=Ny; this->Ny=Ny;
} }
void JKQTPMathImageBase::setData(void* data, int Nx, int Ny) { void JKQTPMathImageBase::setData(const void* data, int Nx, int Ny) {
this->data=data; this->data=data;
this->Nx=Nx; this->Nx=Nx;
this->Ny=Ny; this->Ny=Ny;
} }
void JKQTPMathImageBase::setDataModifier(void *data, JKQTPMathImageDataType datatype) void JKQTPMathImageBase::setDataModifier(const void *data, JKQTPMathImageDataType datatype)
{ {
this->dataModifier=data; this->dataModifier=data;
this->datatypeModifier=datatype; this->datatypeModifier=datatype;
@ -546,44 +552,44 @@ void JKQTPMathImageBase::getDataMinMax(double& imin, double& imax) {
if (!data) return; if (!data) return;
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
imin= JKQTPImagePlot_getImageMin<double>(static_cast<double*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<double>(static_cast<const double*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<double>(static_cast<double*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<double>(static_cast<const double*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
imin= JKQTPImagePlot_getImageMin<float>(static_cast<float*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<float>(static_cast<const float*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<float>(static_cast<float*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<float>(static_cast<const float*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<uint8_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<const uint8_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<uint8_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<const uint8_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<uint16_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<const uint16_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<uint16_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<const uint16_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<uint32_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<const uint32_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<uint32_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<const uint32_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<uint64_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<const uint64_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<uint64_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<const uint64_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<int8_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<const int8_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<int8_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<const int8_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<int16_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<const int16_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<int16_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<const int16_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<int32_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<const int32_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<int32_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<const int32_t*>(data), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<int64_t*>(data), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<const int64_t*>(data), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<int64_t*>(data), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<const int64_t*>(data), Nx, Ny);
break; break;
} }
} }
@ -595,44 +601,44 @@ void JKQTPMathImageBase::getModifierMinMax(double &imin, double &imax)
if (!dataModifier) return; if (!dataModifier) return;
switch(datatypeModifier) { switch(datatypeModifier) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
imin= JKQTPImagePlot_getImageMin<double>(static_cast<double*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<double>(static_cast<const double*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<double>(static_cast<double*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<double>(static_cast<const double*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
imin= JKQTPImagePlot_getImageMin<float>(static_cast<float*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<float>(static_cast<const float*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<float>(static_cast<float*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<float>(static_cast<const float*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<uint8_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<const uint8_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<uint8_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<const uint8_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<uint16_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<const uint16_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<uint16_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<const uint16_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<uint32_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<const uint32_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<uint32_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<const uint32_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<uint64_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<const uint64_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<uint64_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<const uint64_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<int8_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<const int8_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<int8_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<const int8_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<int16_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<const int16_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<int16_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<const int16_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<int32_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<const int32_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<int32_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<const int32_t*>(dataModifier), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<int64_t*>(dataModifier), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<const int64_t*>(dataModifier), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<int64_t*>(dataModifier), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<const int64_t*>(dataModifier), Nx, Ny);
break; break;
} }
} }
@ -641,34 +647,34 @@ QVector<double> JKQTPMathImageBase::getDataAsDoubleVector() const
{ {
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
return JKQTPImagePlot_arrayToDVector(static_cast<double*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const double*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
return JKQTPImagePlot_arrayToDVector(static_cast<float*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const float*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint8_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint8_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint16_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint16_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint32_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint32_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint64_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint64_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int8_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int8_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int16_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int16_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int32_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int32_t*>(data), Nx*Ny);
break; break;
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int64_t*>(data), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int64_t*>(data), Nx*Ny);
break; break;
} }
QVector<double> res; QVector<double> res;
@ -679,25 +685,25 @@ QVector<double> JKQTPMathImageBase::getDataModifierAsDoubleVector() const
{ {
switch(datatypeModifier) { switch(datatypeModifier) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
return JKQTPImagePlot_arrayToDVector(static_cast<double*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const double*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
return JKQTPImagePlot_arrayToDVector(static_cast<float*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const float*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint8_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint8_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint16_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint16_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint32_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint32_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint64_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint64_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int8_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int8_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int16_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int16_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int32_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int32_t*>(dataModifier), Nx*Ny);
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int64_t*>(dataModifier), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int64_t*>(dataModifier), Nx*Ny);
} }
QVector<double> res; QVector<double> res;
return res; return res;
@ -729,7 +735,7 @@ void JKQTPMathImage::initJKQTPMathImage() {
this->autoModifierRange=true; this->autoModifierRange=true;
} }
JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter* parent): JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter* parent):
JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent), JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent),
JKQTPColorPaletteWithModifierStyleAndToolsMixin(parent) JKQTPColorPaletteWithModifierStyleAndToolsMixin(parent)
{ {
@ -747,7 +753,7 @@ JKQTPMathImage::JKQTPMathImage(JKQTBasePlotter *parent):
JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent): JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void *data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent):
JKQTPMathImage(x, y, width, height, datatype, data, Nx, Ny, palette, parent->getPlotter()) JKQTPMathImage(x, y, width, height, datatype, data, Nx, Ny, palette, parent->getPlotter())
{ {
} }
@ -983,16 +989,16 @@ QImage JKQTPMathImage::drawImage() {
getDataMinMax(internalDataMin, internalDataMax); getDataMinMax(internalDataMin, internalDataMax);
getModifierMinMax(internalModifierMin, internalModifierMax); getModifierMinMax(internalModifierMin, internalModifierMax);
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: JKQTPImageTools::array2image<double>(static_cast<double*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::DoubleArray: JKQTPImageTools::array2image<double>(static_cast<const double*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::FloatArray: JKQTPImageTools::array2image<float>(static_cast<float*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::FloatArray: JKQTPImageTools::array2image<float>(static_cast<const float*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::UInt8Array: JKQTPImageTools::array2image<uint8_t>(static_cast<uint8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::UInt8Array: JKQTPImageTools::array2image<uint8_t>(static_cast<const uint8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::UInt16Array: JKQTPImageTools::array2image<uint16_t>(static_cast<uint16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::UInt16Array: JKQTPImageTools::array2image<uint16_t>(static_cast<const uint16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::UInt32Array: JKQTPImageTools::array2image<uint32_t>(static_cast<uint32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::UInt32Array: JKQTPImageTools::array2image<uint32_t>(static_cast<const uint32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::UInt64Array: JKQTPImageTools::array2image<uint64_t>(static_cast<uint64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::UInt64Array: JKQTPImageTools::array2image<uint64_t>(static_cast<const uint64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::Int8Array: JKQTPImageTools::array2image<int8_t>(static_cast<int8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::Int8Array: JKQTPImageTools::array2image<int8_t>(static_cast<const int8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::Int16Array: JKQTPImageTools::array2image<int16_t>(static_cast<int16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::Int16Array: JKQTPImageTools::array2image<int16_t>(static_cast<const int16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::Int32Array: JKQTPImageTools::array2image<int32_t>(static_cast<int32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::Int32Array: JKQTPImageTools::array2image<int32_t>(static_cast<const int32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
case JKQTPMathImageDataType::Int64Array: JKQTPImageTools::array2image<int64_t>(static_cast<int64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break; case JKQTPMathImageDataType::Int64Array: JKQTPImageTools::array2image<int64_t>(static_cast<const int64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rangeMinFailAction, rangeMaxFailAction, rangeMinFailColor, rangeMaxFailColor, nanColor, infColor); break;
} }
modifyImage(img, dataModifier, datatypeModifier, Nx, Ny, internalModifierMin, internalModifierMax); modifyImage(img, dataModifier, datatypeModifier, Nx, Ny, internalModifierMin, internalModifierMax);
return img; return img;

View File

@ -86,23 +86,24 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImageBase: public JKQTPGraph {
/** \brief returns the color to be used for the key label */ /** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() const override; virtual QColor getKeyLabelColor() const override;
/** \copydoc x */
void setX(double __value);
/** \copydoc x */ /** \copydoc x */
double getX() const; double getX() const;
/** \copydoc y */ /** \copydoc y */
void setY(double __value);
/** \copydoc y */
double getY() const; double getY() const;
/** \copydoc width */ /** \copydoc width */
void setWidth(double __value);
/** \copydoc width */
double getWidth() const; double getWidth() const;
/** \copydoc height */ /** \copydoc height */
void setHeight(double __value);
/** \copydoc height */
double getHeight() const; double getHeight() const;
public slots:
/** \copydoc x */
void setX(double __value);
/** \copydoc y */
void setY(double __value);
/** \copydoc width */
void setWidth(double __value);
/** \copydoc height */
void setHeight(double __value);
protected: protected:
/** \brief x coordinate of lower left corner */ /** \brief x coordinate of lower left corner */
@ -114,12 +115,18 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImageBase: public JKQTPGraph {
/** \brief height of image */ /** \brief height of image */
double height; double height;
/*! \brief plot the given QImage onto the widget where the QImage fills the area defined by x, y (lower left corner) and width, height /** \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
in the simplest case your implementation of draw() will call * <code>plotImage(painter, image, this->x, this->y, this->width, this->height);</code>
<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
*/ */
virtual void plotImage(JKQTPEnhancedPainter& painter, QImage& image, double x, double y, double width, double height); void plotImage(JKQTPEnhancedPainter& painter, QImage& image, double x, double y, double width, double height);
}; };
@ -162,7 +169,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
* \param parent parent plotter object * \param parent parent plotter object
* *
*/ */
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr);
/** \brief class constructor /** \brief class constructor
@ -193,7 +200,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
* \param parent parent plotter object * \param parent parent plotter object
* *
*/ */
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTPlotter* parent);
/** \brief plots a key marker inside the specified rectangle \a rect */ /** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
@ -206,22 +213,22 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
int getNx() const; int getNx() const;
/** \copydoc Ny */ /** \copydoc Ny */
void setNy(int __value); void setNy(int __value);
/** \copydoc Ny */ /** \copydoc Ny */
void setNy(size_t __value); void setNy(size_t __value);
/** \copydoc Ny */ /** \copydoc Ny */
int getNy() const; int getNy() const;
/** \copydoc data */ /** \copydoc data */
virtual void setData(void* __value); virtual void setData(const void* __value);
/** \copydoc data */ /** \copydoc data */
virtual void *getData() const; virtual const void *getData() const;
/** \copydoc datatype */ /** \copydoc datatype */
virtual void setDatatype(JKQTPMathImageDataType __value); virtual void setDatatype(JKQTPMathImageDataType __value);
/** \copydoc datatype */ /** \copydoc datatype */
virtual JKQTPMathImageDataType getDatatype() const; virtual JKQTPMathImageDataType getDatatype() const;
/** \copydoc dataModifier */ /** \copydoc dataModifier */
virtual void setDataModifier(void* __value); virtual void setDataModifier(const void* __value);
/** \copydoc dataModifier */ /** \copydoc dataModifier */
virtual void *getDataModifier() const; virtual const void *getDataModifier() const;
/** \copydoc datatypeModifier */ /** \copydoc datatypeModifier */
virtual void setDatatypeModifier(JKQTPMathImageDataType __value); virtual void setDatatypeModifier(JKQTPMathImageDataType __value);
/** \copydoc datatypeModifier */ /** \copydoc datatypeModifier */
@ -229,11 +236,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
/** \copydoc modifierMode */ /** \copydoc modifierMode */
/** \brief sets dataModifier (\copybrief dataModifier ) and datatypeModifier (\copybrief datatypeModifier ) */ /** \brief sets dataModifier (\copybrief dataModifier ) and datatypeModifier (\copybrief datatypeModifier ) */
virtual void setDataModifier(void* data, JKQTPMathImageDataType datatype); virtual void setDataModifier(const void *data, JKQTPMathImageDataType datatype);
/** \brief sets data (\copybrief data ) and datatype (\copybrief datatype ), as well as the size of data (Nx: \copybrief Nx and Ny: \copybrief Ny ) */ /** \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, JKQTPMathImageDataType datatype); virtual void setData(const void* data, int Nx, int Ny, JKQTPMathImageDataType datatype);
/** \brief sets data (\copybrief data ), as well as the size of data (Nx: \copybrief Nx and Ny: \copybrief Ny ) */ /** \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); virtual void setData(const void* data, int Nx, int Ny);
/** \brief determine min/max data value of the image */ /** \brief determine min/max data value of the image */
virtual void getDataMinMax(double& imin, double& imax); virtual void getDataMinMax(double& imin, double& imax);
/** \brief determine min/max data value of the image */ /** \brief determine min/max data value of the image */
@ -245,7 +252,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
QVector<double> getDataModifierAsDoubleVector() const; QVector<double> getDataModifierAsDoubleVector() const;
protected: protected:
/** \brief points to the data array, holding the image */ /** \brief points to the data array, holding the image */
void* data; const void* data;
/** \brief datatype of the data array data */ /** \brief datatype of the data array data */
JKQTPMathImageDataType datatype; JKQTPMathImageDataType datatype;
/** \brief width of the data array data in pt */ /** \brief width of the data array data in pt */
@ -254,7 +261,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
int Ny; int Ny;
/** \brief points to the data array, holding the modifier image */ /** \brief points to the data array, holding the modifier image */
void* dataModifier; const void* dataModifier;
/** \brief datatype of the data array data */ /** \brief datatype of the data array data */
JKQTPMathImageDataType datatypeModifier; JKQTPMathImageDataType datatypeModifier;
@ -371,7 +378,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImage: public JKQTPImageBase {
void clear_image(); void clear_image();
/** \copydoc image */ /** \copydoc image */
inline QImage* getImage() const { return this->image; } inline QImage* getImage() { return this->image; }
/** \copydoc image */
inline const QImage* getImage() const { return this->image; }
protected: protected:
/** \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) */ /** \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) */
QImage* image; QImage* image;
@ -452,7 +461,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase, public J
* \param parent parent plotter object * \param parent parent plotter object
* *
*/ */
JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr); JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, 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 x origin of the image (x-direction) in system coordinates
@ -467,7 +476,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase, public J
* \param parent parent plotter object * \param parent parent plotter object
* *
*/ */
JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent); JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent);
/** \brief class constructor /** \brief class constructor
* *
* \param parent parent plotter object * \param parent parent plotter object
@ -591,20 +600,20 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase, public J
double JKQTPMathImage::getValueAt(double x, double y) double JKQTPMathImage::getValueAt(double x, double y)
{ {
ensureImageData(); ensureImageData();
int xx=jkqtp_truncTo<int>((x-this->x)/width*double(Nx)); const int xx=jkqtp_truncTo<int>((x-this->x)/width*double(Nx));
int yy=jkqtp_truncTo<int>((y-this->y)/height*double(Ny)); const int yy=jkqtp_truncTo<int>((y-this->y)/height*double(Ny));
if (xx>=0 && xx<static_cast<int64_t>(Nx) && yy>=0 && yy<static_cast<int64_t>(Ny)) { if (xx>=0 && xx<static_cast<int64_t>(Nx) && yy>=0 && yy<static_cast<int64_t>(Ny)) {
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: return static_cast<double>((static_cast<double*>(data))[yy*Nx+xx]); case JKQTPMathImageDataType::DoubleArray: return static_cast<double>((static_cast<const double*>(data))[yy*Nx+xx]);
case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<float*>(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<uint8_t*>(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<uint16_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<uint32_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<uint64_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<int8_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<int16_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<int32_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<int64_t*>(data))[yy*Nx+xx]); case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<const int64_t*>(data))[yy*Nx+xx]);
} } } }
return 0.0; return 0.0;
} }
@ -617,25 +626,25 @@ double JKQTPMathImage::getPixelValue(int xIdx, int yIdx) const {
if (!data) return 0; if (!data) return 0;
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
return (static_cast<double*>(data))[yIdx*getNx()+xIdx]; return (static_cast<const double*>(data))[yIdx*getNx()+xIdx];
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
return static_cast<double>((static_cast<float*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const float*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
return static_cast<double>((static_cast<uint8_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint8_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
return static_cast<double>((static_cast<uint16_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint16_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
return static_cast<double>((static_cast<uint32_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint32_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
return static_cast<double>((static_cast<uint64_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint64_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
return static_cast<double>((static_cast<int8_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int8_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
return static_cast<double>((static_cast<int16_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int16_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
return static_cast<double>((static_cast<int32_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int32_t*>(data))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
return static_cast<double>((static_cast<int64_t*>(data))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int64_t*>(data))[yIdx*getNx()+xIdx]);
default: default:
return 0; return 0;
} }
@ -676,20 +685,20 @@ int JKQTPMathImage::getSampleSize() const {
double JKQTPMathImage::getModifierValueAt(double x, double y) double JKQTPMathImage::getModifierValueAt(double x, double y)
{ {
ensureImageData(); ensureImageData();
int xx=jkqtp_truncTo<int>((x-this->x)/width*double(Nx)); const int xx=jkqtp_truncTo<int>((x-this->x)/width*double(Nx));
int yy=jkqtp_truncTo<int>((y-this->y)/height*double(Ny)); const int yy=jkqtp_truncTo<int>((y-this->y)/height*double(Ny));
if (xx>=0 && xx<(int64_t)Nx && yy>=0 && yy<(int64_t)Ny) { if (xx>=0 && xx<(int64_t)Nx && yy>=0 && yy<(int64_t)Ny) {
switch(datatypeModifier) { switch(datatypeModifier) {
case JKQTPMathImageDataType::DoubleArray: return (static_cast<double*>(dataModifier))[yy*Nx+xx]; case JKQTPMathImageDataType::DoubleArray: return (static_cast<const double*>(dataModifier))[yy*Nx+xx];
case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<float*>(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<uint8_t*>(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<uint16_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<uint32_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<uint64_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<int8_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<int16_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<int32_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<int64_t*>(dataModifier))[yy*Nx+xx]); case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<const int64_t*>(dataModifier))[yy*Nx+xx]);
} } } }
return 0.0; return 0.0;
} }
@ -702,25 +711,25 @@ double JKQTPMathImage::getModifierPixelValue(int xIdx, int yIdx) const {
if (!dataModifier) return 0; if (!dataModifier) return 0;
switch(datatypeModifier) { switch(datatypeModifier) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
return (static_cast<double*>(dataModifier))[yIdx*getNx()+xIdx]; return (static_cast<const double*>(dataModifier))[yIdx*getNx()+xIdx];
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
return static_cast<double>((static_cast<float*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const float*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
return static_cast<double>((static_cast<uint8_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint8_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
return static_cast<double>((static_cast<uint16_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint16_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
return static_cast<double>((static_cast<uint32_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint32_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
return static_cast<double>((static_cast<uint64_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const uint64_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
return static_cast<double>((static_cast<int8_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int8_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
return static_cast<double>((static_cast<int16_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int16_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
return static_cast<double>((static_cast<int32_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int32_t*>(dataModifier))[yIdx*getNx()+xIdx]);
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
return static_cast<double>((static_cast<int64_t*>(dataModifier))[yIdx*getNx()+xIdx]); return static_cast<double>((static_cast<const int64_t*>(dataModifier))[yIdx*getNx()+xIdx]);
default: default:
return 0; return 0;
} }

View File

@ -32,7 +32,7 @@
#include <QClipboard> #include <QClipboard>
JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, const bool *data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent):
JKQTPImageBase(x, y, width, height, parent) JKQTPImageBase(x, y, width, height, parent)
{ {
actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this);
@ -59,7 +59,7 @@ JKQTPOverlayImage::JKQTPOverlayImage(JKQTBasePlotter *parent):
this->trueColor=QColor("red"); this->trueColor=QColor("red");
} }
JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, const bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent):
JKQTPImageBase(x, y, width, height, parent) JKQTPImageBase(x, y, width, height, parent)
{ {
actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this);
@ -185,17 +185,17 @@ int JKQTPOverlayImage::getNy() const
return this->Ny; return this->Ny;
} }
void JKQTPOverlayImage::setData(bool *__value) void JKQTPOverlayImage::setData(const bool *__value)
{ {
this->data = __value; this->data = __value;
} }
bool *JKQTPOverlayImage::getData() const const bool *JKQTPOverlayImage::getData() const
{ {
return this->data; return this->data;
} }
void JKQTPOverlayImage::setData(bool* data, int Nx, int Ny) { void JKQTPOverlayImage::setData(const bool *data, int Nx, int Ny) {
this->data=data; this->data=data;
this->Nx=Nx; this->Nx=Nx;
this->Ny=Ny; this->Ny=Ny;
@ -365,15 +365,16 @@ int JKQTPColumnOverlayImageEnhanced::getImageColumn() const
return this->imageColumn; return this->imageColumn;
} }
void JKQTPColumnOverlayImageEnhanced::draw(JKQTPEnhancedPainter &painter) { void JKQTPColumnOverlayImageEnhanced::draw(JKQTPEnhancedPainter &painter) {
double* d=parent->getDatastore()->getColumnPointer(imageColumn,0); const double* d=parent->getDatastore()->getColumnPointer(imageColumn,0);
size_t imgSize=parent->getDatastore()->getRows(imageColumn); size_t imgSize=parent->getDatastore()->getRows(imageColumn);
this->data=(bool*)malloc(imgSize*sizeof(bool)); bool* locData=static_cast<bool*>(malloc(imgSize*sizeof(bool)));
this->data=locData;
this->Ny= static_cast<int>(imgSize/this->Nx); this->Ny= static_cast<int>(imgSize/this->Nx);
for (size_t i=0; i<imgSize; i++) { for (size_t i=0; i<imgSize; i++) {
data[i]=(d[i]!=0.0); locData[i]=(d[i]!=0.0);
} }
JKQTPOverlayImageEnhanced::draw(painter); JKQTPOverlayImageEnhanced::draw(painter);
free(data); free(locData);
data=nullptr; data=nullptr;
} }

View File

@ -46,11 +46,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase {
public: public:
/** \brief class constructor */ /** \brief class constructor */
JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); JKQTPOverlayImage(double x, double y, double width, double height, const bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr);
JKQTPOverlayImage(JKQTBasePlotter* parent=nullptr); JKQTPOverlayImage(JKQTBasePlotter* parent=nullptr);
/** \brief class constructor */ /** \brief class constructor */
JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); JKQTPOverlayImage(double x, double y, double width, double height, const bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent);
JKQTPOverlayImage(JKQTPlotter* parent); JKQTPOverlayImage(JKQTPlotter* parent);
/** \brief plots the graph to the plotter object specified as parent */ /** \brief plots the graph to the plotter object specified as parent */
@ -85,19 +85,19 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase {
/** \copydoc Ny */ /** \copydoc Ny */
int getNy() const; int getNy() const;
/** \copydoc data */ /** \copydoc data */
virtual void setData(bool* __value); virtual void setData(const bool* __value);
/** \copydoc data */ /** \copydoc data */
bool *getData() const; const bool *getData() const;
/** \brief set the plot-data to a given array \a data with size \a Nx * \a Ny in row-major ordering */ /** \brief set the plot-data to a given array \a data with size \a Nx * \a Ny in row-major ordering */
virtual void setData(bool* data, int Nx, int Ny); virtual void setData(const bool* data, int Nx, int Ny);
/** \brief return the data used for plotting as a QVector<double> in row-major data-ordering */ /** \brief return the data used for plotting as a QVector<double> in row-major data-ordering */
QVector<double> getDataAsDoubleVector() const; QVector<double> getDataAsDoubleVector() const;
protected: protected:
/** \brief points to the data array, holding the image */ /** \brief points to the data array, holding the image */
bool* data; const bool* data;
/** \brief width of the data array data in pt */ /** \brief width of the data array data in pt */
int Nx; int Nx;
/** \brief height of the data array data in pt */ /** \brief height of the data array data in pt */

View File

@ -121,14 +121,14 @@ void JKQTPRGBMathImage::initObject()
JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter *parent): JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTBasePlotter *parent):
JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent)
{ {
initObject(); initObject();
} }
JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent): JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTPlotter *parent):
JKQTPRGBMathImage(x, y, width, height, datatype, data, Nx, Ny, parent->getPlotter()) JKQTPRGBMathImage(x, y, width, height, datatype, data, Nx, Ny, parent->getPlotter())
{ {
} }
@ -261,7 +261,7 @@ void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftS
struct RGBOutsizeData { struct RGBOutsizeData {
double internalDataMin; double internalDataMin;
double internalDataMax; double internalDataMax;
void* data; const void* data;
JKQTPVerticalIndependentAxis* colorBarRightAxis; JKQTPVerticalIndependentAxis* colorBarRightAxis;
JKQTPHorizontalIndependentAxis* colorBarTopAxis; JKQTPHorizontalIndependentAxis* colorBarTopAxis;
QString name; QString name;
@ -490,12 +490,12 @@ void JKQTPRGBMathImage::getDataMinMax(double& imin, double& imax) {
} }
} }
void JKQTPRGBMathImage::setDataR(void *__value) void JKQTPRGBMathImage::setDataR(const void *__value)
{ {
setData(__value); setData(__value);
} }
void *JKQTPRGBMathImage::getDataR() const const void *JKQTPRGBMathImage::getDataR() const
{ {
return getData(); return getData();
} }
@ -510,12 +510,12 @@ JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeR() const
return getDatatype(); return getDatatype();
} }
void JKQTPRGBMathImage::setDataG(void *__value) void JKQTPRGBMathImage::setDataG(const void *__value)
{ {
this->dataG = __value; this->dataG = __value;
} }
void *JKQTPRGBMathImage::getDataG() const const void *JKQTPRGBMathImage::getDataG() const
{ {
return this->dataG; return this->dataG;
} }
@ -530,12 +530,12 @@ JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeG() const
return this->datatypeG; return this->datatypeG;
} }
void JKQTPRGBMathImage::setDataB(void *__value) void JKQTPRGBMathImage::setDataB(const void *__value)
{ {
this->dataB = __value; this->dataB = __value;
} }
void *JKQTPRGBMathImage::getDataB() const const void *JKQTPRGBMathImage::getDataB() const
{ {
return this->dataB; return this->dataB;
} }
@ -909,44 +909,44 @@ void JKQTPRGBMathImage::getDataMinMaxG(double& imin, double& imax) {
if (!dataG) return; if (!dataG) return;
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
imin= JKQTPImagePlot_getImageMin<double>(static_cast<double*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<double>(static_cast<const double*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<double>(static_cast<double*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<double>(static_cast<const double*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
imin= JKQTPImagePlot_getImageMin<float>(static_cast<float*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<float>(static_cast<const float*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<float>(static_cast<float*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<float>(static_cast<const float*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<uint8_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<const uint8_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<uint8_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<const uint8_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<uint16_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<const uint16_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<uint16_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<const uint16_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<uint32_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<const uint32_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<uint32_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<const uint32_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<uint64_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<const uint64_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<uint64_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<const uint64_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<int8_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<const int8_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<int8_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<const int8_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<int16_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<const int16_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<int16_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<const int16_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<int32_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<const int32_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<int32_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<const int32_t*>(dataG), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<int64_t*>(dataG), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<const int64_t*>(dataG), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<int64_t*>(dataG), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<const int64_t*>(dataG), Nx, Ny);
break; break;
} }
} else { } else {
@ -962,44 +962,44 @@ void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) {
if (!dataG) return; if (!dataG) return;
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
imin= JKQTPImagePlot_getImageMin<double>(static_cast<double*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<double>(static_cast<const double*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<double>(static_cast<double*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<double>(static_cast<const double*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
imin= JKQTPImagePlot_getImageMin<float>(static_cast<float*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<float>(static_cast<const float*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<float>(static_cast<float*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<float>(static_cast<const float*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<uint8_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<const uint8_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<uint8_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<const uint8_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<uint16_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<const uint16_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<uint16_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<const uint16_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<uint32_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<const uint32_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<uint32_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<const uint32_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<uint64_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<const uint64_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<uint64_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<const uint64_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<int8_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<const int8_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<int8_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<const int8_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<int16_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<const int16_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<int16_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<const int16_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<int32_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<const int32_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<int32_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<const int32_t*>(dataB), Nx, Ny);
break; break;
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<int64_t*>(dataB), Nx, Ny); imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<const int64_t*>(dataB), Nx, Ny);
imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<int64_t*>(dataB), Nx, Ny); imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<const int64_t*>(dataB), Nx, Ny);
break; break;
} }
} else { } else {
@ -1011,7 +1011,7 @@ void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) {
double JKQTPRGBMathImage::getValueAt(double x, double y, int channel) double JKQTPRGBMathImage::getValueAt(double x, double y, int channel)
{ {
ensureImageData(); ensureImageData();
void* dd=data; const void* dd=data;
if (channel==0) dd=data; if (channel==0) dd=data;
if (channel==1) dd=dataG; if (channel==1) dd=dataG;
if (channel==2) dd=dataB; if (channel==2) dd=dataB;
@ -1019,16 +1019,16 @@ double JKQTPRGBMathImage::getValueAt(double x, double y, int channel)
int yy=static_cast<int>(trunc((y-this->y)/height*Ny)); int yy=static_cast<int>(trunc((y-this->y)/height*Ny));
if (xx>=0 && xx<Nx && yy>=0 && yy<Ny) { if (xx>=0 && xx<Nx && yy>=0 && yy<Ny) {
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: return static_cast<double>((static_cast<double*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::DoubleArray: return static_cast<double>((static_cast<const double*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<float*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<const float*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::UInt8Array: return static_cast<double>((static_cast<uint8_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::UInt8Array: return static_cast<double>((static_cast<const uint8_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::UInt16Array: return static_cast<double>((static_cast<uint16_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::UInt16Array: return static_cast<double>((static_cast<const uint16_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::UInt32Array: return static_cast<double>((static_cast<uint32_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::UInt32Array: return static_cast<double>((static_cast<const uint32_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::UInt64Array: return static_cast<double>((static_cast<uint64_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::UInt64Array: return static_cast<double>((static_cast<const uint64_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::Int8Array: return static_cast<double>((static_cast<int8_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::Int8Array: return static_cast<double>((static_cast<const int8_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::Int16Array: return static_cast<double>((static_cast<int16_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::Int16Array: return static_cast<double>((static_cast<const int16_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::Int32Array: return static_cast<double>((static_cast<int32_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::Int32Array: return static_cast<double>((static_cast<const int32_t*>(dd))[yy*Nx+xx]); break;
case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<int64_t*>(dd))[yy*Nx+xx]); break; case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<const int64_t*>(dd))[yy*Nx+xx]); break;
} } } }
return 0.0; return 0.0;
} }
@ -1122,46 +1122,46 @@ QImage JKQTPRGBMathImage::drawImage() {
int palette = 0; int palette = 0;
if (data) { if (data) {
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<const double*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<const float*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<const uint8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<const uint16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<const uint32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<const uint64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<const int8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<const int16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<const int32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<const int64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
} }
} }
palette = 1; palette = 1;
if (dataG) { if (dataG) {
switch(datatypeG) { switch(datatypeG) {
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<const double*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<const float*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<const uint8_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<const uint16_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<const uint32_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<const uint64_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<const int8_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<const int16_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<const int32_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<const int64_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
} }
} }
palette = 2; palette = 2;
if (dataB) { if (dataB) {
switch(datatypeB) { switch(datatypeB) {
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<const double*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<const float*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<const uint8_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<const uint16_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<const uint32_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<const uint64_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<const int8_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<const int16_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<const int32_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<const int64_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
} }
} }
@ -1170,7 +1170,7 @@ QImage JKQTPRGBMathImage::drawImage() {
return img; return img;
} }
void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, JKQTPMathImageDataType datatype) { void JKQTPRGBMathImage::setData(const void* data, int Nx, int Ny, JKQTPMathImageDataType datatype) {
this->data=data; this->data=data;
this->datatype=datatype; this->datatype=datatype;
this->dataG=nullptr; this->dataG=nullptr;
@ -1179,7 +1179,7 @@ void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, JKQTPMathImageDataTy
this->Ny=Ny; this->Ny=Ny;
} }
void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny) { void JKQTPRGBMathImage::setData(const void* data, int Nx, int Ny) {
this->data=data; this->data=data;
this->Nx=Nx; this->Nx=Nx;
this->Ny=Ny; this->Ny=Ny;
@ -1188,7 +1188,7 @@ void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny) {
} }
void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny, JKQTPMathImageDataType datatype) { void JKQTPRGBMathImage::setData(const void *data, const void *dataG, const void *dataB, int Nx, int Ny, JKQTPMathImageDataType datatype) {
this->data=data; this->data=data;
this->datatype=datatype; this->datatype=datatype;
this->datatypeG=datatype; this->datatypeG=datatype;
@ -1199,7 +1199,7 @@ void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, in
this->Ny=Ny; this->Ny=Ny;
} }
void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny) { void JKQTPRGBMathImage::setData(const void *data, const void *dataG, const void *dataB, int Nx, int Ny) {
this->data=data; this->data=data;
this->dataG=dataG; this->dataG=dataG;
this->dataB=dataB; this->dataB=dataB;
@ -1328,25 +1328,25 @@ QVector<double> JKQTPRGBMathImage::getDataGAsDoubleVector() const
{ {
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
return JKQTPImagePlot_arrayToDVector(static_cast<double*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const double*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
return JKQTPImagePlot_arrayToDVector(static_cast<float*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const float*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint8_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint8_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint16_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint16_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint32_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint32_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint64_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint64_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int8_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int8_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int16_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int16_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int32_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int32_t*>(dataG), Nx*Ny);
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int64_t*>(dataG), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int64_t*>(dataG), Nx*Ny);
} }
QVector<double> res; QVector<double> res;
return res; return res;
@ -1356,25 +1356,25 @@ QVector<double> JKQTPRGBMathImage::getDataBAsDoubleVector() const
{ {
switch(datatype) { switch(datatype) {
case JKQTPMathImageDataType::DoubleArray: case JKQTPMathImageDataType::DoubleArray:
return JKQTPImagePlot_arrayToDVector(static_cast<double*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const double*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::FloatArray: case JKQTPMathImageDataType::FloatArray:
return JKQTPImagePlot_arrayToDVector(static_cast<float*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const float*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::UInt8Array: case JKQTPMathImageDataType::UInt8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint8_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint8_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::UInt16Array: case JKQTPMathImageDataType::UInt16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint16_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint16_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::UInt32Array: case JKQTPMathImageDataType::UInt32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint32_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint32_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::UInt64Array: case JKQTPMathImageDataType::UInt64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<uint64_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const uint64_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::Int8Array: case JKQTPMathImageDataType::Int8Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int8_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int8_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::Int16Array: case JKQTPMathImageDataType::Int16Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int16_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int16_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::Int32Array: case JKQTPMathImageDataType::Int32Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int32_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int32_t*>(dataB), Nx*Ny);
case JKQTPMathImageDataType::Int64Array: case JKQTPMathImageDataType::Int64Array:
return JKQTPImagePlot_arrayToDVector(static_cast<int64_t*>(dataB), Nx*Ny); return JKQTPImagePlot_arrayToDVector(static_cast<const int64_t*>(dataB), Nx*Ny);
} }
QVector<double> res; QVector<double> res;
return res; return res;

View File

@ -66,7 +66,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
* \param parent parent plotter object * \param parent parent plotter object
* *
*/ */
JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr);
/** \brief class constructor /** \brief class constructor
* *
@ -81,7 +81,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
* \param parent parent plotter object * \param parent parent plotter object
* *
*/ */
JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, const void* data, int Nx, int Ny, JKQTPlotter* parent);
/** \brief class constructor /** \brief class constructor
* *
@ -104,14 +104,14 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
/** \brief set the plot-data to a given array \a data (red), \a dataG (green), \a dataB (blue) with size \a Nx * \a Ny in row-major ordering and with the given \a datatype */ /** \brief set the plot-data to a given array \a data (red), \a dataG (green), \a dataB (blue) with size \a Nx * \a Ny in row-major ordering and with the given \a datatype */
virtual void setData(void* dataR, void* dataG, void* dataB, int Nx, int Ny, JKQTPMathImageDataType datatype); virtual void setData(const void* dataR, const void* dataG, const void* dataB, int Nx, int Ny, JKQTPMathImageDataType datatype);
/** \brief set the plot-data to a given array \a data (red), \a dataG (green), \a dataB (blue) with size \a Nx * \a Ny in row-major ordering */ /** \brief set the plot-data to a given array \a data (red), \a dataG (green), \a dataB (blue) with size \a Nx * \a Ny in row-major ordering */
virtual void setData(void* dataR, void* dataG, void* dataB, int Nx, int Ny); virtual void setData(const void* dataR, const void* dataG, const void* dataB, int Nx, int Ny);
/** \brief set the plot-data to a given array \a data (red) with size \a Nx * \a Ny in row-major ordering and with the given \a datatype */ /** \brief set the plot-data to a given array \a data (red) with size \a Nx * \a Ny in row-major ordering and with the given \a datatype */
virtual void setData(void* dataR, int Nx, int Ny, JKQTPMathImageDataType datatype) override; virtual void setData(const void* dataR, int Nx, int Ny, JKQTPMathImageDataType datatype) override;
/** \brief set the plot-data to a given array \a data (red) with size \a Nx * \a Ny in row-major ordering */ /** \brief set the plot-data to a given array \a data (red) with size \a Nx * \a Ny in row-major ordering */
virtual void setData(void* dataR, int Nx, int Ny) override ; virtual void setData(const void* dataR, int Nx, int Ny) override ;
/** \brief determine min/max data value of the image */ /** \brief determine min/max data value of the image */
@ -119,26 +119,26 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
/** \copydoc data */ /** \copydoc data */
virtual void setDataR(void* __value); virtual void setDataR(const void* __value);
/** \copydoc data */ /** \copydoc data */
void* getDataR() const; const void* getDataR() const;
/** \copydoc datatype */ /** \copydoc datatype */
void setDatatypeR(JKQTPMathImageDataType __value); void setDatatypeR(JKQTPMathImageDataType __value);
/** \copydoc datatype */ /** \copydoc datatype */
JKQTPMathImageDataType getDatatypeR() const; JKQTPMathImageDataType getDatatypeR() const;
/** \copydoc dataG */ /** \copydoc dataG */
virtual void setDataG(void* __value); virtual void setDataG(const void* __value);
/** \copydoc dataG */ /** \copydoc dataG */
void* getDataG() const; const void* getDataG() const;
/** \copydoc datatypeG */ /** \copydoc datatypeG */
void setDatatypeG(JKQTPMathImageDataType __value); void setDatatypeG(JKQTPMathImageDataType __value);
/** \copydoc datatypeG */ /** \copydoc datatypeG */
JKQTPMathImageDataType getDatatypeG() const; JKQTPMathImageDataType getDatatypeG() const;
/** \copydoc dataB */ /** \copydoc dataB */
virtual void setDataB(void* __value); virtual void setDataB(const void* __value);
/** \copydoc dataB */ /** \copydoc dataB */
void* getDataB() const; const void* getDataB() const;
/** \copydoc datatypeB */ /** \copydoc datatypeB */
void setDatatypeB(JKQTPMathImageDataType __value); void setDatatypeB(JKQTPMathImageDataType __value);
/** \copydoc datatypeB */ /** \copydoc datatypeB */
@ -330,11 +330,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
protected: protected:
void initObject(); void initObject();
/** \brief points to the data array, holding the image */ /** \brief points to the data array, holding the image */
void* dataG; const void* dataG;
/** \brief datatype of the data array data */ /** \brief datatype of the data array data */
JKQTPMathImageDataType datatypeG; JKQTPMathImageDataType datatypeG;
/** \brief points to the data array, holding the image */ /** \brief points to the data array, holding the image */
void* dataB; const void* dataB;
/** \brief datatype of the data array data */ /** \brief datatype of the data array data */
JKQTPMathImageDataType datatypeB; JKQTPMathImageDataType datatypeB;

View File

@ -754,7 +754,7 @@ JKQTPMathImageModifierMode JKQTPColorPaletteWithModifierStyleAndToolsMixin::getM
} }
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::modifyImage(QImage &img, void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax) void JKQTPColorPaletteWithModifierStyleAndToolsMixin::modifyImage(QImage &img, const void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax)
{ {
JKQTPModifyImage(img, modifierMode, dataModifier, datatypeModifier, Nx, Ny, internalModifierMin, internalModifierMax); JKQTPModifyImage(img, modifierMode, dataModifier, datatypeModifier, Nx, Ny, internalModifierMin, internalModifierMax);
} }

View File

@ -315,7 +315,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteWithModifierStyleAndToolsMixin : p
/** \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 /** \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, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax); void modifyImage(QImage& img, const void* dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax);
protected: protected: