From 58403f8905849e7a9add201defa3ce0a332305c7 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Mon, 28 Sep 2020 19:24:17 +0200 Subject: [PATCH] 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! --- doc/dox/whatsnew.dox | 1 + lib/jkqtcommon/jkqtpbasicimagetools.cpp | 22 +- lib/jkqtcommon/jkqtpbasicimagetools.h | 18 +- lib/jkqtplotter/graphs/jkqtpcontour.cpp | 2 +- lib/jkqtplotter/graphs/jkqtpimage.cpp | 232 +++++++++--------- lib/jkqtplotter/graphs/jkqtpimage.h | 155 ++++++------ lib/jkqtplotter/graphs/jkqtpimageoverlays.cpp | 19 +- lib/jkqtplotter/graphs/jkqtpimageoverlays.h | 12 +- lib/jkqtplotter/graphs/jkqtpimagergb.cpp | 228 ++++++++--------- lib/jkqtplotter/graphs/jkqtpimagergb.h | 28 +-- lib/jkqtplotter/jkqtpimagetools.cpp | 2 +- lib/jkqtplotter/jkqtpimagetools.h | 2 +- 12 files changed, 370 insertions(+), 351 deletions(-) diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 263280594a..c9a113f461 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -38,6 +38,7 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
  • improved/breaking change: extended styling system for graphs.
  • improved/breaking change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)
  • improved/breaking change: made more functions and function parameters const
  • +
  • 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!.
  • bugfixed/improved: aspect ratio handling in JKQTPlotter.
  • 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)
  • 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
  • diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.cpp b/lib/jkqtcommon/jkqtpbasicimagetools.cpp index 8fe0032b48..8277ae5f46 100644 --- a/lib/jkqtcommon/jkqtpbasicimagetools.cpp +++ b/lib/jkqtcommon/jkqtpbasicimagetools.cpp @@ -2986,7 +2986,7 @@ QString ModifierModeToString(const JKQTPMathImageModifierMode &mode) { 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; //getModifierMinMax(internalModifierMin, internalModifierMax); @@ -3011,16 +3011,16 @@ void JKQTPModifyImage(QImage &img, JKQTPMathImageModifierMode modifierMode, void } //qDebug()<<"mod: "<(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; - case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; + case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataModifier), Nx, Ny, img, modChannel, internalModifierMin, internalModifierMax, rgbModMode); break; } } diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.h b/lib/jkqtcommon/jkqtpbasicimagetools.h index 04c0d4e3bc..6417e75dfe 100644 --- a/lib/jkqtcommon/jkqtpbasicimagetools.h +++ b/lib/jkqtcommon/jkqtpbasicimagetools.h @@ -549,7 +549,7 @@ inline QVector JKQTPImagePlot_BarrayToDVector(const bool* input, int N) */ template -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) return 0; @@ -580,7 +580,7 @@ inline double JKQTPImagePlot_getImageMin(T* dbl, int width, int height) */ template -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) return 0; @@ -623,7 +623,7 @@ inline double JKQTPImagePlot_getImageMax(T* dbl, int width, int height) leave alpha as it is. */ template -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) 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) { double logB=log10(logBase); - dbl=static_cast(malloc(width*height*sizeof(T))); + dbllog=static_cast(malloc(width*height*sizeof(T))); //memcpy(dbl, dbl_in, width*height*sizeof(T)); for (int i=0; i0) { - colChecksum=static_cast(qChecksum(reinterpret_cast(data), Nx*Ny* getSampleSize())); + colChecksum=static_cast(qChecksum(reinterpret_cast(data), Nx*Ny* getSampleSize()/sizeof(char))); } /*if (parent && parent->getDatastore() && imageColumn>=0) { colChecksum=static_cast(parent->getDatastore()->getColumnChecksum(imageColumn)); diff --git a/lib/jkqtplotter/graphs/jkqtpimage.cpp b/lib/jkqtplotter/graphs/jkqtpimage.cpp index c7ab058483..ad428389ae 100644 --- a/lib/jkqtplotter/graphs/jkqtpimage.cpp +++ b/lib/jkqtplotter/graphs/jkqtpimage.cpp @@ -132,62 +132,68 @@ void JKQTPImageBase::plotImage(JKQTPEnhancedPainter& painter, QImage& image, dou } painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - double xmin=parent->getXMin(); - double xmax=parent->getXMax(); - double ymin=parent->getYMin(); - double ymax=parent->getYMax(); - QPointF pp1=transform(xmin,ymax); - QPointF pp2=transform(xmax,ymin); - QRectF pr(pp1, pp2); + // determine full shown plot rectangle in pixel coordinates + const double xmin=parent->getXMin(); + const double xmax=parent->getXMax(); + const double ymin=parent->getYMin(); + const double ymax=parent->getYMax(); + QPointF pix_plot_topleft=transform(xmin,ymax); + 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 mirry=false; - QPointF p1=transform(x,y+height); - QPointF p2=transform(x+width,y); - if (p1.x()>p2.x()) { - double tmp=p1.x(); - p1.setX(p2.x()); - p2.setX(tmp); - tmp=pp1.x(); - pp1.setX(pp2.x()); - pp2.setX(tmp); + // determine pixel coordinates of image (x..x+width / y..y+width) + QPointF pix_topelft=transform(x,y+height); + QPointF pix_bottomright=transform(x+width,y); + if (pix_topelft.x()>pix_bottomright.x()) { + double tmp=pix_topelft.x(); + pix_topelft.setX(pix_bottomright.x()); + pix_bottomright.setX(tmp); + tmp=pix_plot_topleft.x(); + pix_plot_topleft.setX(pix_plot_bottomright.x()); + pix_plot_bottomright.setX(tmp); mirrx=true; } - if (p1.y()>p2.y()) { - double tmp=p1.y(); - p1.setY(p2.y()); - p2.setY(tmp); - tmp=pp1.y(); - pp1.setY(pp2.y()); - pp2.setY(tmp); + if (pix_topelft.y()>pix_bottomright.y()) { + double tmp=pix_topelft.y(); + pix_topelft.setY(pix_bottomright.y()); + pix_bottomright.setY(tmp); + tmp=pix_plot_topleft.y(); + pix_plot_topleft.setY(pix_plot_bottomright.y()); + pix_plot_bottomright.setY(tmp); mirry=true; } - QRectF r(p1, p2); + const QRectF pix_imagerect(pix_topelft, pix_bottomright); 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(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.width()); - double pixheight=fabs(p2.y()-p1.y())/static_cast(image.height()); + // ... if the image is much larger than the plot rectangle, we cut a potion from the image, before plotting + const double pixwidth=fabs(pix_bottomright.x()-pix_topelft.x())/static_cast(image.width()); + const double pixheight=fabs(pix_bottomright.y()-pix_topelft.y())/static_cast(image.height()); //qDebug()<<"\nimage.size = "<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) { actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); @@ -185,17 +185,17 @@ int JKQTPOverlayImage::getNy() const return this->Ny; } -void JKQTPOverlayImage::setData(bool *__value) +void JKQTPOverlayImage::setData(const bool *__value) { this->data = __value; } -bool *JKQTPOverlayImage::getData() const +const bool *JKQTPOverlayImage::getData() const { 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->Nx=Nx; this->Ny=Ny; @@ -365,15 +365,16 @@ int JKQTPColumnOverlayImageEnhanced::getImageColumn() const return this->imageColumn; } 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); - this->data=(bool*)malloc(imgSize*sizeof(bool)); + bool* locData=static_cast(malloc(imgSize*sizeof(bool))); + this->data=locData; this->Ny= static_cast(imgSize/this->Nx); for (size_t i=0; i in row-major data-ordering */ QVector getDataAsDoubleVector() const; protected: /** \brief points to the data array, holding the image */ - bool* data; + const bool* data; /** \brief width of the data array data in pt */ int Nx; /** \brief height of the data array data in pt */ diff --git a/lib/jkqtplotter/graphs/jkqtpimagergb.cpp b/lib/jkqtplotter/graphs/jkqtpimagergb.cpp index 36d285906a..ca1ccf47b9 100644 --- a/lib/jkqtplotter/graphs/jkqtpimagergb.cpp +++ b/lib/jkqtplotter/graphs/jkqtpimagergb.cpp @@ -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) { 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()) { } @@ -261,7 +261,7 @@ void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftS struct RGBOutsizeData { double internalDataMin; double internalDataMax; - void* data; + const void* data; JKQTPVerticalIndependentAxis* colorBarRightAxis; JKQTPHorizontalIndependentAxis* colorBarTopAxis; 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); } -void *JKQTPRGBMathImage::getDataR() const +const void *JKQTPRGBMathImage::getDataR() const { return getData(); } @@ -510,12 +510,12 @@ JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeR() const return getDatatype(); } -void JKQTPRGBMathImage::setDataG(void *__value) +void JKQTPRGBMathImage::setDataG(const void *__value) { this->dataG = __value; } -void *JKQTPRGBMathImage::getDataG() const +const void *JKQTPRGBMathImage::getDataG() const { return this->dataG; } @@ -530,12 +530,12 @@ JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeG() const return this->datatypeG; } -void JKQTPRGBMathImage::setDataB(void *__value) +void JKQTPRGBMathImage::setDataB(const void *__value) { this->dataB = __value; } -void *JKQTPRGBMathImage::getDataB() const +const void *JKQTPRGBMathImage::getDataB() const { return this->dataB; } @@ -909,44 +909,44 @@ void JKQTPRGBMathImage::getDataMinMaxG(double& imin, double& imax) { if (!dataG) return; switch(datatype) { case JKQTPMathImageDataType::DoubleArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::FloatArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::UInt8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::UInt16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::UInt32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::UInt64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::Int8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::Int16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::Int32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; case JKQTPMathImageDataType::Int64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); break; } } else { @@ -962,44 +962,44 @@ void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) { if (!dataG) return; switch(datatype) { case JKQTPMathImageDataType::DoubleArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::FloatArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::UInt8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::UInt16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::UInt32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::UInt64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::Int8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::Int16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::Int32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; case JKQTPMathImageDataType::Int64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); break; } } else { @@ -1011,7 +1011,7 @@ void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) { double JKQTPRGBMathImage::getValueAt(double x, double y, int channel) { ensureImageData(); - void* dd=data; + const void* dd=data; if (channel==0) dd=data; if (channel==1) dd=dataG; if (channel==2) dd=dataB; @@ -1019,16 +1019,16 @@ double JKQTPRGBMathImage::getValueAt(double x, double y, int channel) int yy=static_cast(trunc((y-this->y)/height*Ny)); if (xx>=0 && xx=0 && yy((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::FloatArray: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::UInt8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::UInt16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::UInt32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::UInt64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::Int8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::Int16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::Int32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageDataType::Int64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::DoubleArray: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::FloatArray: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::UInt8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::UInt16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::UInt32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::UInt64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::Int8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::Int16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::Int32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageDataType::Int64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; } } return 0.0; } @@ -1122,46 +1122,46 @@ QImage JKQTPRGBMathImage::drawImage() { int palette = 0; if (data) { switch(datatype) { - case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; } } palette = 1; if (dataG) { switch(datatypeG) { - case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; } } palette = 2; if (dataB) { switch(datatypeB) { - case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageDataType::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; } } @@ -1170,7 +1170,7 @@ QImage JKQTPRGBMathImage::drawImage() { 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->datatype=datatype; this->dataG=nullptr; @@ -1179,7 +1179,7 @@ void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, JKQTPMathImageDataTy 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->Nx=Nx; 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->datatype=datatype; this->datatypeG=datatype; @@ -1199,7 +1199,7 @@ void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, in 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->dataG=dataG; this->dataB=dataB; @@ -1328,25 +1328,25 @@ QVector JKQTPRGBMathImage::getDataGAsDoubleVector() const { switch(datatype) { case JKQTPMathImageDataType::DoubleArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::FloatArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::UInt8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::UInt16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::UInt32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::UInt64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::Int8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::Int16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::Int32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); case JKQTPMathImageDataType::Int64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); } QVector res; return res; @@ -1356,25 +1356,25 @@ QVector JKQTPRGBMathImage::getDataBAsDoubleVector() const { switch(datatype) { case JKQTPMathImageDataType::DoubleArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::FloatArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::UInt8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::UInt16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::UInt32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::UInt64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::Int8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::Int16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::Int32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); case JKQTPMathImageDataType::Int64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); } QVector res; return res; diff --git a/lib/jkqtplotter/graphs/jkqtpimagergb.h b/lib/jkqtplotter/graphs/jkqtpimagergb.h index fdfb14c913..7124eb14d9 100644 --- a/lib/jkqtplotter/graphs/jkqtpimagergb.h +++ b/lib/jkqtplotter/graphs/jkqtpimagergb.h @@ -66,7 +66,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { * \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 * @@ -81,7 +81,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { * \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 * @@ -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 */ - 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 */ - 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 */ - 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 */ - 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 */ @@ -119,26 +119,26 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { /** \copydoc data */ - virtual void setDataR(void* __value); + virtual void setDataR(const void* __value); /** \copydoc data */ - void* getDataR() const; + const void* getDataR() const; /** \copydoc datatype */ void setDatatypeR(JKQTPMathImageDataType __value); /** \copydoc datatype */ JKQTPMathImageDataType getDatatypeR() const; /** \copydoc dataG */ - virtual void setDataG(void* __value); + virtual void setDataG(const void* __value); /** \copydoc dataG */ - void* getDataG() const; + const void* getDataG() const; /** \copydoc datatypeG */ void setDatatypeG(JKQTPMathImageDataType __value); /** \copydoc datatypeG */ JKQTPMathImageDataType getDatatypeG() const; /** \copydoc dataB */ - virtual void setDataB(void* __value); + virtual void setDataB(const void* __value); /** \copydoc dataB */ - void* getDataB() const; + const void* getDataB() const; /** \copydoc datatypeB */ void setDatatypeB(JKQTPMathImageDataType __value); /** \copydoc datatypeB */ @@ -330,11 +330,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { protected: void initObject(); /** \brief points to the data array, holding the image */ - void* dataG; + const void* dataG; /** \brief datatype of the data array data */ JKQTPMathImageDataType datatypeG; /** \brief points to the data array, holding the image */ - void* dataB; + const void* dataB; /** \brief datatype of the data array data */ JKQTPMathImageDataType datatypeB; diff --git a/lib/jkqtplotter/jkqtpimagetools.cpp b/lib/jkqtplotter/jkqtpimagetools.cpp index df289e18e2..77fa7b3874 100644 --- a/lib/jkqtplotter/jkqtpimagetools.cpp +++ b/lib/jkqtplotter/jkqtpimagetools.cpp @@ -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); } diff --git a/lib/jkqtplotter/jkqtpimagetools.h b/lib/jkqtplotter/jkqtpimagetools.h index 261ac92055..07c0a5641a 100644 --- a/lib/jkqtplotter/jkqtpimagetools.h +++ b/lib/jkqtplotter/jkqtpimagetools.h @@ -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 */ - 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: