mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 17:41:39 +08:00
using mix-in class JKQTPColorPaletteWithModifierStyleAndToolsMixin now also in JKQTPMathImage ...
This commit is contained in:
parent
4347d27c04
commit
686fb1eeb1
@ -64,7 +64,7 @@ int main(int argc, char* argv[])
|
||||
graph->setModifierColumn(cModifier);
|
||||
graph->setAutoModifierRange(true);
|
||||
// ... and specify which image property is modified (here the saturation, but ModifyAlpha for the transparency and ModifyValue from the HSV color-model are also possible):
|
||||
graph->setModifierMode(JKQTPMathImageBase::ModifySaturation);
|
||||
graph->setModifierMode(JKQTPMathImageModifierMode::ModifySaturation);
|
||||
// set size of the data (the datastore does not contain this info, as it only manages 1D columns of data and this is used to assume a row-major ordering
|
||||
graph->setNx(NX);
|
||||
graph->setNy(NY);
|
||||
|
@ -56,8 +56,8 @@ int main(int argc, char* argv[])
|
||||
// the converted range of data is determined automatically because setAutoImageRange(true)
|
||||
JKQTPMathImage* graph=new JKQTPMathImage(&plot);
|
||||
graph->setTitle("");
|
||||
// set array as datasource, with correct size NX*NY and datatype JKQTPMathImageBase::DataType::DoubleArray
|
||||
graph->setData(airydisk, NX, NY, JKQTPMathImageBase::DataType::DoubleArray);
|
||||
// set array as datasource, with correct size NX*NY and datatype JKQTPMathImageDataType::DoubleArray
|
||||
graph->setData(airydisk, NX, NY, JKQTPMathImageDataType::DoubleArray);
|
||||
// where does the image start in the plot, given in plot-axis-coordinates (bottom-left corner)
|
||||
graph->setX(-w/2.0);
|
||||
graph->setY(-h/2.0);
|
||||
|
@ -54,7 +54,7 @@ TestWidgetImages::TestWidgetImages(QWidget *parent) :
|
||||
bimg2[y*100+x]=static_cast<double>(rand())/static_cast<double>(RAND_MAX)>0.9;
|
||||
}
|
||||
}
|
||||
pimg2=new JKQTPMathImage(10,0,10,10, JKQTPMathImageBase::DoubleArray, img2, 100, 100, JKQTPMathImageGRAY, plotImg->getPlotter());
|
||||
pimg2=new JKQTPMathImage(10,0,10,10, JKQTPMathImageDataType::DoubleArray, img2, 100, 100, JKQTPMathImageGRAY, plotImg->getPlotter());
|
||||
pimg2->setImageMin(-1);
|
||||
pimg2->setImageMax(0.5);
|
||||
pimg2->setImageName("left image");
|
||||
@ -63,7 +63,7 @@ TestWidgetImages::TestWidgetImages(QWidget *parent) :
|
||||
pimg2->setColorBarTopVisible(true);
|
||||
pimg2->setColorBarRightVisible(false);
|
||||
plotImg->getPlotter()->addGraph(pimg2);
|
||||
pimg3=new JKQTPMathImage(20,0,10,10, JKQTPMathImageBase::DoubleArray, img2, 100, 100, JKQTPMathImageMATLAB, plotImg->getPlotter());
|
||||
pimg3=new JKQTPMathImage(20,0,10,10, JKQTPMathImageDataType::DoubleArray, img2, 100, 100, JKQTPMathImageMATLAB, plotImg->getPlotter());
|
||||
pimg3->setColorBarTopVisible(true);
|
||||
pimg3->setColorBarRightVisible(true);
|
||||
pimg3->setImageMax(0.5);
|
||||
@ -73,8 +73,8 @@ TestWidgetImages::TestWidgetImages(QWidget *parent) :
|
||||
pimg3->setRangeMinFailAction(JKQTPMathImageTransparent);
|
||||
pimg3->setAutoImageRange(false);
|
||||
pimg3->setImageName("I(x,y)=\\sin\\left(\\frac{2\\pi\\cdot\\sqrt{1+x^2+y^2}}{20}\\right)");
|
||||
pimg3->setDataModifier(img2M, JKQTPMathImageBase::Int32Array);
|
||||
pimg3->setModifierMode(JKQTPMathImageBase::ModifyNone);
|
||||
pimg3->setDataModifier(img2M, JKQTPMathImageDataType::Int32Array);
|
||||
pimg3->setModifierMode(JKQTPMathImageModifierMode::ModifyNone);
|
||||
pimg3->setTitle("right image");
|
||||
plotImg->getPlotter()->addGraph(pimg3);
|
||||
|
||||
@ -131,6 +131,6 @@ void TestWidgetImages::setImgPalette1(int index)
|
||||
|
||||
void TestWidgetImages::setImgModifier(int index)
|
||||
{
|
||||
pimg3->setModifierMode(JKQTPMathImage::ModifierMode(index));
|
||||
pimg3->setModifierMode(static_cast<JKQTPMathImageModifierMode>(index));
|
||||
plotImg->redrawPlot();
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ TestWidgetRGBImages::TestWidgetRGBImages(QWidget *parent) :
|
||||
rgb_aimg2[y*100+x]=double(x)/100.0;
|
||||
}
|
||||
}
|
||||
rgbimg=new JKQTPRGBMathImage(0,0,10,10, JKQTPMathImageBase::DoubleArray, rgb_rimg2, 100, 100, plotImgRGB->getPlotter());
|
||||
rgbimg=new JKQTPRGBMathImage(0,0,10,10, JKQTPMathImageDataType::DoubleArray, rgb_rimg2, 100, 100, plotImgRGB->getPlotter());
|
||||
rgbimg->setImageMin(-1);
|
||||
rgbimg->setImageMax(0.5);
|
||||
rgbimg->setImageMinB(-1);
|
||||
@ -58,9 +58,9 @@ TestWidgetRGBImages::TestWidgetRGBImages(QWidget *parent) :
|
||||
rgbimg->setImageName("R image");
|
||||
rgbimg->setImageNameG("G image");
|
||||
rgbimg->setImageNameB("B image");
|
||||
rgbimg->setData(rgb_rimg2, rgb_gimg2, rgb_bimg2, 100, 100, JKQTPMathImageBase::DoubleArray);
|
||||
rgbimg->setDataModifier(rgb_aimg2, JKQTPMathImageBase::DoubleArray);
|
||||
rgbimg->setModifierMode(JKQTPMathImageBase::ModifyNone);
|
||||
rgbimg->setData(rgb_rimg2, rgb_gimg2, rgb_bimg2, 100, 100, JKQTPMathImageDataType::DoubleArray);
|
||||
rgbimg->setDataModifier(rgb_aimg2, JKQTPMathImageDataType::DoubleArray);
|
||||
rgbimg->setModifierMode(JKQTPMathImageModifierMode::ModifyNone);
|
||||
plotImgRGB->getPlotter()->addGraph(rgbimg);
|
||||
rgbimg->setAutoImageRange(false);
|
||||
rgbimg->setColorBarTopVisible(true);
|
||||
@ -80,8 +80,8 @@ TestWidgetRGBImages::TestWidgetRGBImages(QWidget *parent) :
|
||||
rgbimg2->setImageGColumn(rgb_colg=plotImgRGB->getDatastore()->addCopiedColumn(rgb_gimg2, 100*100, "G"));
|
||||
rgbimg2->setImageBColumn(rgb_colb=plotImgRGB->getDatastore()->addCopiedColumn(rgb_rimg2, 100*100, "B"));
|
||||
rgbimg2->setModifierColumn(rgb_cola=plotImgRGB->getDatastore()->addCopiedColumn(rgb_aimg2, 100*100, "alpha"));
|
||||
rgbimg2->setModifierMode(JKQTPMathImageBase::ModifyNone);
|
||||
//rgbimg2->setData(rgb_rimg2, rgb_gimg2, rgb_bimg2, 100, 100, JKQTPMathImageBase::DoubleArray);
|
||||
rgbimg2->setModifierMode(JKQTPMathImageModifierMode::ModifyNone);
|
||||
//rgbimg2->setData(rgb_rimg2, rgb_gimg2, rgb_bimg2, 100, 100, JKQTPMathImageDataType::DoubleArray);
|
||||
plotImgRGB->getPlotter()->addGraph(rgbimg2);
|
||||
rgbimg2->setAutoImageRange(true);
|
||||
rgbimg2->setColorBarTopVisible(true);
|
||||
@ -195,8 +195,8 @@ void TestWidgetRGBImages::updateRGBChannels()
|
||||
|
||||
void TestWidgetRGBImages::setRGBModifier(int item)
|
||||
{
|
||||
rgbimg->setModifierMode(JKQTPMathImage::ModifierMode(item));
|
||||
rgbimg2->setModifierMode(JKQTPMathImage::ModifierMode(item));
|
||||
rgbimg->setModifierMode(static_cast<JKQTPMathImageModifierMode>(item));
|
||||
rgbimg2->setModifierMode(static_cast<JKQTPMathImageModifierMode>(item));
|
||||
plotImgRGB->redrawPlot();
|
||||
}
|
||||
|
||||
|
@ -2546,6 +2546,7 @@ JKQTPImageTools::LUTType JKQTPBuildColorPaletteLUTLinSegmentsSorted(const QList<
|
||||
j1++; j2++;
|
||||
}
|
||||
}
|
||||
JKQTPSetColorChannel(lut[lut.size()-1], channel, jkqtp_bounded<int>(0, items.last().colval_endprevious, 255));
|
||||
}
|
||||
};
|
||||
|
||||
@ -2584,6 +2585,7 @@ JKQTPImageTools::LUTType JKQTPBuildColorPaletteLUTLinInterpolateSorted(const QLi
|
||||
j1++; j2++;
|
||||
}
|
||||
}
|
||||
lut[lut_size-1]=items.last().second;
|
||||
|
||||
return lut;
|
||||
}
|
||||
@ -2971,3 +2973,65 @@ JKQTPColorPaletteSingleColorLinSegment::JKQTPColorPaletteSingleColorLinSegment()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
JKQTPMathImageModifierMode StringToModifierMode(const QString &mode) {
|
||||
QString m=mode.toLower();
|
||||
if (m=="value" ) return JKQTPMathImageModifierMode::ModifyValue;
|
||||
if (m=="saturation" ) return JKQTPMathImageModifierMode::ModifySaturation;
|
||||
if (m=="alpha" ) return JKQTPMathImageModifierMode::ModifyAlpha;
|
||||
if (m=="luminance" ) return JKQTPMathImageModifierMode::ModifyLuminance;
|
||||
if (m=="hue" ) return JKQTPMathImageModifierMode::ModifyHue;
|
||||
|
||||
return JKQTPMathImageModifierMode::ModifyNone;
|
||||
}
|
||||
|
||||
QString ModifierModeToString(const JKQTPMathImageModifierMode &mode) {
|
||||
|
||||
if (mode==JKQTPMathImageModifierMode::ModifyValue) return "value";
|
||||
if (mode==JKQTPMathImageModifierMode::ModifySaturation) return "saturation";
|
||||
if (mode==JKQTPMathImageModifierMode::ModifyAlpha) return "alpha";
|
||||
if (mode==JKQTPMathImageModifierMode::ModifyLuminance) return "luminance";
|
||||
if (mode==JKQTPMathImageModifierMode::ModifyHue) return "hue";
|
||||
return "none";
|
||||
}
|
||||
|
||||
void JKQTPModifyImage(QImage &img, JKQTPMathImageModifierMode modifierMode, void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax)
|
||||
{
|
||||
if (!dataModifier) return;
|
||||
//getModifierMinMax(internalModifierMin, internalModifierMax);
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
JKQTPRGBMathImageRGBMode rgbModMode=JKQTPRGBMathImageModeRGBMode;
|
||||
int modChannel=3;
|
||||
if (modifierMode==JKQTPMathImageModifierMode::ModifyValue) {
|
||||
modChannel=2;
|
||||
rgbModMode=JKQTPRGBMathImageModeHSVMode;
|
||||
} else if (modifierMode==JKQTPMathImageModifierMode::ModifySaturation) {
|
||||
modChannel=1;
|
||||
rgbModMode=JKQTPRGBMathImageModeHSVMode;
|
||||
} else if (modifierMode==JKQTPMathImageModifierMode::ModifyAlpha) {
|
||||
modChannel=3;
|
||||
rgbModMode=JKQTPRGBMathImageModeRGBMode;
|
||||
} else if (modifierMode==JKQTPMathImageModifierMode::ModifyLuminance) {
|
||||
modChannel=2;
|
||||
rgbModMode=JKQTPRGBMathImageModeHSLMode;
|
||||
} else if (modifierMode==JKQTPMathImageModifierMode::ModifyHue) {
|
||||
modChannel=0;
|
||||
rgbModMode=JKQTPRGBMathImageModeHSLMode;
|
||||
}
|
||||
//qDebug()<<"mod: "<<modifierMode<<" ch:"<<modChannel<<" rgb:"<<rgbModMode;
|
||||
switch(datatypeModifier) {
|
||||
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<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::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<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::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<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::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<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::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,21 @@
|
||||
#include "jkqtcommon/jkqtcommon_imexport.h"
|
||||
#include "jkqtcommon/jkqtpmathtools.h"
|
||||
|
||||
/** \brief possible datatypes of the data array, plotted by this class.
|
||||
\ingroup jkqtplotter_imagelots_tools
|
||||
*/
|
||||
enum class JKQTPMathImageDataType {
|
||||
FloatArray, /*!< Data is of type \c float */
|
||||
DoubleArray, /*!< Data is of type \c double */
|
||||
UInt8Array, /*!< Data is of type \c uint8_t */
|
||||
UInt16Array, /*!< Data is of type \c uint16_t */
|
||||
UInt32Array, /*!< Data is of type \c uint32_t */
|
||||
UInt64Array, /*!< Data is of type \c uint8_t */
|
||||
Int8Array, /*!< Data is of type \c int8_t */
|
||||
Int16Array, /*!< Data is of type \c int16_t */
|
||||
Int32Array, /*!< Data is of type \c int32_t */
|
||||
Int64Array /*!< Data is of type \c int64_t */
|
||||
};
|
||||
|
||||
/*! \brief retrieve an R/G/B/Alpha (\a ch == 0/1/2/3) value from the \c QRgb value \a rgb
|
||||
\ingroup jkqtplotter_imagelots_tools
|
||||
@ -1029,6 +1044,32 @@ JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT(const Q
|
||||
|
||||
|
||||
|
||||
/** \brief describes how to modify a rendered image with a second data array \see ModifierModeToString(), StringToModifierMode(), JKQTPImageModifierModeComboBox
|
||||
\ingroup jkqtplotter_imagelots_tools*/
|
||||
enum class JKQTPMathImageModifierMode {
|
||||
ModifyNone=0, /*!< no modification \image html JKQTPMathImageBaseModifyNone.png */
|
||||
ModifyValue=1, /*!< modify the VALUE-channel from the HSV color space \image html JKQTPMathImageBaseModifyValue.png */
|
||||
ModifySaturation=2,/*!< modify the SATURATION-channel from the HSV color space \image html JKQTPMathImageBaseModifySaturation.png */
|
||||
ModifyAlpha=3,/*!< modify the ALPHA/TRANSPARENCY-channel from the RGBA color space \image html JKQTPMathImageBaseModifyAlpha.png */
|
||||
ModifyTransparency=ModifyAlpha,/*!< \see ModifyAlpha */
|
||||
ModifyLuminance=4,/*!< modify the LUMINANCE-channel from the HSL color space \image html JKQTPMathImageBaseModifyLuminance.png */
|
||||
ModifyHue=5,/*!< modify the VALUE-channel from the HSV color space \image html JKQTPMathImageBaseModifyHue.png */
|
||||
};
|
||||
|
||||
/** \brief convert a ModifierMode to a string
|
||||
\ingroup jkqtplotter_imagelots_tools
|
||||
\see ModifierModeToString(), ModifierMode */
|
||||
JKQTPMathImageModifierMode JKQTCOMMON_LIB_EXPORT StringToModifierMode(const QString& mode);
|
||||
|
||||
/** \brief convert a string to a ModifierMode
|
||||
\ingroup jkqtplotter_imagelots_tools
|
||||
\see StringToModifierMode(), ModifierMode */
|
||||
QString JKQTCOMMON_LIB_EXPORT ModifierModeToString(const JKQTPMathImageModifierMode& mode);
|
||||
|
||||
/** \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
|
||||
*/
|
||||
void JKQTCOMMON_LIB_EXPORT JKQTPModifyImage(QImage& img, JKQTPMathImageModifierMode modifierMode, void* dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax);
|
||||
|
||||
|
||||
|
||||
|
@ -429,7 +429,7 @@ JKQTPColumnContourPlot::JKQTPColumnContourPlot(JKQTBasePlotter *parent):
|
||||
JKQTPContourPlot(parent)
|
||||
{
|
||||
this->imageColumn=imageColumn;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
}
|
||||
|
||||
JKQTPColumnContourPlot::JKQTPColumnContourPlot(JKQTPlotter *parent):
|
||||
@ -466,9 +466,9 @@ void JKQTPColumnContourPlot::ensureImageData()
|
||||
if (this->Nx==0 || imageColumn<0 || !parent->getDatastore()->getColumnPointer(imageColumn,0)) {
|
||||
this->Ny=0;
|
||||
this->data=nullptr;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
} else {
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
this->data=parent->getDatastore()->getColumnPointer(imageColumn,0);
|
||||
this->Ny=static_cast<int>(parent->getDatastore()->getRows(imageColumn)/this->Nx);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -133,38 +133,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImageBase: public JKQTPGraph {
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief possible datatypes of the data array, plotted by this class. */
|
||||
enum DataType {
|
||||
FloatArray, /*!< Data is of type \c float */
|
||||
DoubleArray, /*!< Data is of type \c double */
|
||||
UInt8Array, /*!< Data is of type \c uint8_t */
|
||||
UInt16Array, /*!< Data is of type \c uint16_t */
|
||||
UInt32Array, /*!< Data is of type \c uint32_t */
|
||||
UInt64Array, /*!< Data is of type \c uint8_t */
|
||||
Int8Array, /*!< Data is of type \c int8_t */
|
||||
Int16Array, /*!< Data is of type \c int16_t */
|
||||
Int32Array, /*!< Data is of type \c int32_t */
|
||||
Int64Array /*!< Data is of type \c int64_t */
|
||||
};
|
||||
|
||||
/** \brief describes how to modify a rendered image with a second data array \see ModifierModeToString(), StringToModifierMode(), JKQTPImageModifierModeComboBox */
|
||||
enum ModifierMode {
|
||||
ModifyNone=0, /*!< no modification \image html JKQTPMathImageBaseModifyNone.png */
|
||||
ModifyValue=1, /*!< modify the VALUE-channel from the HSV color space \image html JKQTPMathImageBaseModifyValue.png */
|
||||
ModifySaturation=2,/*!< modify the SATURATION-channel from the HSV color space \image html JKQTPMathImageBaseModifySaturation.png */
|
||||
ModifyAlpha=3,/*!< modify the ALPHA/TRANSPARENCY-channel from the RGBA color space \image html JKQTPMathImageBaseModifyAlpha.png */
|
||||
ModifyTransparency=ModifyAlpha,/*!< \see ModifyAlpha */
|
||||
ModifyLuminance=4,/*!< modify the LUMINANCE-channel from the HSL color space \image html JKQTPMathImageBaseModifyLuminance.png */
|
||||
ModifyHue=5,/*!< modify the VALUE-channel from the HSV color space \image html JKQTPMathImageBaseModifyHue.png */
|
||||
};
|
||||
|
||||
/** \brief convert a ModifierMode to a string \see ModifierModeToString(), ModifierMode */
|
||||
static ModifierMode StringToModifierMode(const QString& mode);
|
||||
|
||||
/** \brief convert a string to a ModifierMode \see StringToModifierMode(), ModifierMode */
|
||||
static QString ModifierModeToString(const ModifierMode& mode);
|
||||
|
||||
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
@ -194,7 +162,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
* \param parent parent plotter object
|
||||
*
|
||||
*/
|
||||
JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr);
|
||||
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr);
|
||||
|
||||
|
||||
/** \brief class constructor
|
||||
@ -225,7 +193,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
* \param parent parent plotter object
|
||||
*
|
||||
*/
|
||||
JKQTPMathImageBase(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent);
|
||||
JKQTPMathImageBase(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent);
|
||||
|
||||
/** \brief plots a key marker inside the specified rectangle \a rect */
|
||||
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
|
||||
@ -247,26 +215,23 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
/*! \copydoc data */
|
||||
virtual void *getData() const;
|
||||
/*! \copydoc datatype */
|
||||
virtual void setDatatype(DataType __value);
|
||||
virtual void setDatatype(JKQTPMathImageDataType __value);
|
||||
/*! \copydoc datatype */
|
||||
virtual DataType getDatatype() const;
|
||||
virtual JKQTPMathImageDataType getDatatype() const;
|
||||
/*! \copydoc dataModifier */
|
||||
virtual void setDataModifier(void* __value);
|
||||
/*! \copydoc dataModifier */
|
||||
virtual void *getDataModifier() const;
|
||||
/*! \copydoc datatypeModifier */
|
||||
virtual void setDatatypeModifier(DataType __value);
|
||||
virtual void setDatatypeModifier(JKQTPMathImageDataType __value);
|
||||
/*! \copydoc datatypeModifier */
|
||||
virtual DataType getDatatypeModifier() const;
|
||||
virtual JKQTPMathImageDataType getDatatypeModifier() const;
|
||||
/*! \copydoc modifierMode */
|
||||
void setModifierMode(const ModifierMode & __value);
|
||||
/*! \copydoc modifierMode */
|
||||
ModifierMode getModifierMode() const;
|
||||
|
||||
/** \brief sets dataModifier (\copybrief dataModifier ) and datatypeModifier (\copybrief datatypeModifier ) */
|
||||
virtual void setDataModifier(void* data, DataType datatype);
|
||||
virtual void setDataModifier(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 ) */
|
||||
virtual void setData(void* data, int Nx, int Ny, DataType datatype);
|
||||
virtual void setData(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 ) */
|
||||
virtual void setData(void* data, int Nx, int Ny);
|
||||
/** \brief determine min/max data value of the image */
|
||||
@ -282,7 +247,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
/** \brief points to the data array, holding the image */
|
||||
void* data;
|
||||
/** \brief datatype of the data array data */
|
||||
DataType datatype;
|
||||
JKQTPMathImageDataType datatype;
|
||||
/** \brief width of the data array data in pt */
|
||||
int Nx;
|
||||
/** \brief height of the data array data in pt */
|
||||
@ -291,12 +256,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
/** \brief points to the data array, holding the modifier image */
|
||||
void* dataModifier;
|
||||
/** \brief datatype of the data array data */
|
||||
DataType datatypeModifier;
|
||||
JKQTPMathImageDataType datatypeModifier;
|
||||
|
||||
/** \brief how to apply the modifier column dataModifier
|
||||
* \see ModifierMode
|
||||
*/
|
||||
ModifierMode modifierMode;
|
||||
|
||||
/** \brief internal storage for minimum of the image value range
|
||||
*
|
||||
@ -321,14 +282,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
/** \brief overwrite this to fill the data poiters before they are accessed (e.g. to load data from a column in the datastore */
|
||||
virtual void ensureImageData();
|
||||
|
||||
/** \brief modify the given image \a img, using the internally set modifier data
|
||||
* \see dataModifier, datatypeModifier
|
||||
*/
|
||||
void modifyImage(QImage& img);
|
||||
/** \brief modify the given image \a img, using modifier image \a dataModifier (of type \a datatypeModifier and size \a Nx * \a Ny), using values in the range \a internalModifierMin ... \a internalModifierMax
|
||||
*/
|
||||
void modifyImage(QImage& img, void* dataModifier, DataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -476,7 +429,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImage: public JKQTPImageBase {
|
||||
|
||||
\see \ref JKQTPlotterImagePlotNoDatastore
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase {
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase, public JKQTPColorPaletteWithModifierStyleAndToolsMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@ -499,7 +452,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase {
|
||||
* \param parent parent plotter object
|
||||
*
|
||||
*/
|
||||
JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr);
|
||||
JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param x origin of the image (x-direction) in system coordinates
|
||||
@ -514,7 +467,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase {
|
||||
* \param parent parent plotter object
|
||||
*
|
||||
*/
|
||||
JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent);
|
||||
JKQTPMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTPlotter* parent);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent parent plotter object
|
||||
@ -526,136 +479,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase {
|
||||
|
||||
virtual void setParent(JKQTBasePlotter* parent) override;
|
||||
|
||||
/*! \brief get list with all available palettes */
|
||||
static QStringList getPalettes() ;
|
||||
/*! \brief get list with all available palettes */
|
||||
static int getPalettesCount() ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteIcon(int i) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteIcon(JKQTPMathImageColorPalette palette) ;
|
||||
/*! \brief get QImage representing the given palette */
|
||||
static QImage getPaletteImage(int i, int width, int height=1) ;
|
||||
/*! \brief get QImage representing the given palette */
|
||||
static QImage getPaletteImage(JKQTPMathImageColorPalette palette, int width, int height=1) ;
|
||||
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteKeyIcon(int i) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteKeyIcon(JKQTPMathImageColorPalette palette) ;
|
||||
/*! \brief get QImage representing the given palette */
|
||||
static QImage getPaletteKeyImage(int i, int width, int height) ;
|
||||
/*! \brief get QImage representing the given palette */
|
||||
static QImage getPaletteKeyImage(JKQTPMathImageColorPalette palette, int width, int height) ;
|
||||
|
||||
|
||||
/*! \copydoc palette */
|
||||
void setPalette(const JKQTPMathImageColorPalette & __value);
|
||||
/*! \copydoc palette */
|
||||
void setPalette(int pal);
|
||||
/*! \copydoc palette */
|
||||
JKQTPMathImageColorPalette getPalette() const;
|
||||
/*! \copydoc rangeMinFailAction */
|
||||
void setRangeMinFailAction(const JKQTPMathImageColorRangeFailAction & __value);
|
||||
/*! \copydoc rangeMinFailAction */
|
||||
JKQTPMathImageColorRangeFailAction getActionRangeMinFail() const;
|
||||
/*! \copydoc rangeMaxFailAction */
|
||||
void setRangeMaxFailAction(const JKQTPMathImageColorRangeFailAction & __value);
|
||||
/*! \copydoc rangeMaxFailAction */
|
||||
JKQTPMathImageColorRangeFailAction getActionRangeMaxFail() const;
|
||||
/*! \copydoc rangeMinFailColor */
|
||||
void setRangeMinFailColor(const QColor & __value);
|
||||
/*! \copydoc rangeMinFailColor */
|
||||
QColor getRangeMinFailColor() const;
|
||||
/*! \copydoc rangeMaxFailColor */
|
||||
void setRangeMaxFailColor(const QColor & __value);
|
||||
/*! \copydoc rangeMaxFailColor */
|
||||
QColor getRangeMaxFailColor() const;
|
||||
/*! \copydoc nanColor */
|
||||
void setNanColor(const QColor & __value);
|
||||
/*! \copydoc nanColor */
|
||||
QColor getNanColor() const;
|
||||
/*! \copydoc infColor */
|
||||
void setInfColor(const QColor & __value);
|
||||
/*! \copydoc infColor */
|
||||
QColor getInfColor() const;
|
||||
/*! \copydoc showColorBar */
|
||||
void setShowColorBar(bool __value);
|
||||
/*! \copydoc showColorBar */
|
||||
bool getShowColorBar() const;
|
||||
/*! \copydoc colorBarWidth */
|
||||
void setColorBarWidth(double __value);
|
||||
/*! \copydoc colorBarWidth */
|
||||
double getColorBarWidth() const;
|
||||
/*! \copydoc colorBarModifiedWidth */
|
||||
void setColorBarModifiedWidth(double __value);
|
||||
/*! \copydoc colorBarModifiedWidth */
|
||||
double getColorBarModifiedWidth() const;
|
||||
/*! \copydoc colorBarOffset */
|
||||
void setColorBarOffset(double __value);
|
||||
/*! \copydoc colorBarOffset */
|
||||
double getColorBarOffset() const;
|
||||
/*! \copydoc colorBarRelativeHeight */
|
||||
void setColorBarRelativeHeight(double __value);
|
||||
/*! \copydoc colorBarRelativeHeight */
|
||||
double getColorBarRelativeHeight() const;
|
||||
/*! \copydoc imageMin */
|
||||
void setImageMin(double __value);
|
||||
/*! \copydoc imageMin */
|
||||
double getImageMin() const;
|
||||
/*! \copydoc imageMax */
|
||||
void setImageMax(double __value);
|
||||
/*! \copydoc imageMax */
|
||||
double getImageMax() const;
|
||||
/*! \copydoc autoImageRange */
|
||||
void setAutoImageRange(bool __value);
|
||||
/*! \copydoc autoImageRange */
|
||||
bool getAutoImageRange() const;
|
||||
/*! \copydoc imageName */
|
||||
void setImageName(const QString & __value);
|
||||
/*! \copydoc imageName */
|
||||
QString getImageName() const;
|
||||
/*! \copydoc imageNameFontSize */
|
||||
void setImageNameFontSize(double __value);
|
||||
/*! \copydoc imageNameFontSize */
|
||||
double getImageNameFontSize() const;
|
||||
/*! \copydoc colorBarRightAxis */
|
||||
JKQTPVerticalIndependentAxis* getColorBarRightAxis();
|
||||
/*! \copydoc colorBarTopAxis */
|
||||
JKQTPHorizontalIndependentAxis* getColorBarTopAxis();
|
||||
/*! \copydoc modifierColorBarTopAxis */
|
||||
JKQTPVerticalIndependentAxis* getModifierColorBarTopAxis();
|
||||
/*! \copydoc modifierColorBarRightAxis */
|
||||
JKQTPHorizontalIndependentAxis* getModifierColorBarRightAxis();
|
||||
/*! \copydoc colorBarRightAxis */
|
||||
const JKQTPVerticalIndependentAxis* getColorBarRightAxis() const;
|
||||
/*! \copydoc colorBarTopAxis */
|
||||
const JKQTPHorizontalIndependentAxis* getColorBarTopAxis() const;
|
||||
/*! \copydoc modifierColorBarTopAxis */
|
||||
const JKQTPVerticalIndependentAxis* getModifierColorBarTopAxis() const;
|
||||
/*! \copydoc modifierColorBarRightAxis */
|
||||
const JKQTPHorizontalIndependentAxis *getModifierColorBarRightAxis() const;
|
||||
/*! \copydoc colorBarTopVisible */
|
||||
void setColorBarTopVisible(bool __value);
|
||||
/*! \copydoc colorBarTopVisible */
|
||||
bool getColorBarTopVisible() const;
|
||||
/*! \copydoc colorBarRightVisible */
|
||||
void setColorBarRightVisible(bool __value);
|
||||
/*! \copydoc colorBarRightVisible */
|
||||
bool getColorBarRightVisible() const;
|
||||
/*! \copydoc autoModifierRange */
|
||||
void setAutoModifierRange(bool __value);
|
||||
/*! \copydoc autoModifierRange */
|
||||
bool getAutoModifierRange() const;
|
||||
/*! \copydoc modifierMin */
|
||||
void setModifierMin(double __value);
|
||||
/*! \copydoc modifierMin */
|
||||
double getModifierMin() const;
|
||||
/*! \copydoc modifierMax */
|
||||
void setModifierMax(double __value);
|
||||
/*! \copydoc modifierMax */
|
||||
double getModifierMax() const;
|
||||
|
||||
|
||||
|
||||
/*! \brief if the graph plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
|
||||
@ -702,75 +525,13 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase {
|
||||
|
||||
/** \brief plots a key marker inside the specified rectangle \a rect */
|
||||
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
|
||||
/** \brief determine min/max data value of the image */
|
||||
virtual void cbGetDataMinMax(double& imin, double& imax) override;
|
||||
/** \brief determine min/max data value of the modifier image */
|
||||
virtual void cbGetModifierDataMinMax(double& imin, double& imax) override;
|
||||
|
||||
protected:
|
||||
void initJKQTPMathImage();
|
||||
/** \brief top color bar visible */
|
||||
bool colorBarTopVisible;
|
||||
/** \brief right color bar visible */
|
||||
bool colorBarRightVisible;
|
||||
/** \brief name of the image displayed above color bar (may contain LaTeX markup!) */
|
||||
QString imageName;
|
||||
/** \brief font size in points when displaying imageName */
|
||||
double imageNameFontSize;
|
||||
/** \brief palette for plotting an image */
|
||||
JKQTPMathImageColorPalette palette;
|
||||
/** \brief indicate whether to display a color bar */
|
||||
bool showColorBar;
|
||||
/** \brief width of the color bar [pt] */
|
||||
double colorBarWidth;
|
||||
/** \brief width of the color bar when modifier is on */
|
||||
double colorBarModifiedWidth;
|
||||
/** \brief height of the color bar, as multiple of plotHeight */
|
||||
double colorBarRelativeHeight;
|
||||
/** \brief indicates whether to estimate min/max of the image automatically */
|
||||
bool autoImageRange;
|
||||
/** \brief image value range minimum */
|
||||
double imageMin;
|
||||
/** \brief image value range maximum */
|
||||
double imageMax;
|
||||
/** \brief indicates whether to estimate min/max of the modifier automatically */
|
||||
bool autoModifierRange;
|
||||
/** \brief modifier value range minimum */
|
||||
double modifierMin;
|
||||
/** \brief modifier value range maximum */
|
||||
double modifierMax;
|
||||
/** \brief offset between outside space border and color bar [pt] */
|
||||
double colorBarOffset;
|
||||
/** \brief which action to take if a color is below \a imageMin and \a autoImageRange \c ==false */
|
||||
JKQTPMathImageColorRangeFailAction rangeMinFailAction;
|
||||
/** \brief which action to take if a color is above \a imageMax and \a autoImageRange \c ==false */
|
||||
JKQTPMathImageColorRangeFailAction rangeMaxFailAction;
|
||||
/** \brief color to use for some settings of \a rangeMinFailAction */
|
||||
QColor rangeMinFailColor;
|
||||
/** \brief color to use for some settings of \a rangeMaxFailAction */
|
||||
QColor rangeMaxFailColor;
|
||||
/** \brief color to use for a not-a-number value */
|
||||
QColor nanColor;
|
||||
/** \brief color to use for an infinity value */
|
||||
QColor infColor;
|
||||
|
||||
|
||||
/** \brief object used for color bar axes (right border, image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPVerticalIndependentAxis* colorBarRightAxis;
|
||||
/** \brief object used for color bar axes (top border, image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPHorizontalIndependentAxis* colorBarTopAxis;
|
||||
/** \brief object used for color bar axes (right border, modifier image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPVerticalIndependentAxis* modifierColorBarTopAxis;
|
||||
/** \brief object used for color bar axes (top border, modifier image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPHorizontalIndependentAxis* modifierColorBarRightAxis;
|
||||
|
||||
protected:
|
||||
/** \brief QActions that saves the image (asking the user for a filename)
|
||||
@ -830,20 +591,20 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPMathImage: public JKQTPMathImageBase {
|
||||
double JKQTPMathImage::getValueAt(double x, double y)
|
||||
{
|
||||
ensureImageData();
|
||||
int xx=trunc((x-this->x)/width*double(Nx));
|
||||
int yy=trunc((y-this->y)/height*double(Ny));
|
||||
if (xx>=0 && xx<(int64_t)Nx && yy>=0 && yy<(int64_t)Ny) {
|
||||
int xx=jkqtp_truncTo<int>((x-this->x)/width*double(Nx));
|
||||
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)) {
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray: return (static_cast<double*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::FloatArray: return (static_cast<float*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt8Array: return (static_cast<uint8_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt16Array: return (static_cast<uint16_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt32Array: return (static_cast<uint32_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt64Array: return (static_cast<uint64_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int8Array: return (static_cast<int8_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int16Array: return (static_cast<int16_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int32Array: return (static_cast<int32_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int64Array: return (static_cast<int64_t*>(data))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageDataType::DoubleArray: return static_cast<double>((static_cast<double*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<float*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt8Array: return static_cast<double>((static_cast<uint8_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt16Array: return static_cast<double>((static_cast<uint16_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt32Array: return static_cast<double>((static_cast<uint32_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt64Array: return static_cast<double>((static_cast<uint64_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int8Array: return static_cast<double>((static_cast<int8_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int16Array: return static_cast<double>((static_cast<int16_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int32Array: return static_cast<double>((static_cast<int32_t*>(data))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<int64_t*>(data))[yy*Nx+xx]);
|
||||
} }
|
||||
return 0.0;
|
||||
}
|
||||
@ -855,26 +616,26 @@ double JKQTPMathImage::getPixelValue(int xIdx, int yIdx) const {
|
||||
//ensureImageData();
|
||||
if (!data) return 0;
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
return (static_cast<double*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
return (static_cast<float*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
return (static_cast<uint8_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
return (static_cast<uint16_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
return (static_cast<uint32_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
return (static_cast<uint64_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
return (static_cast<int8_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
return (static_cast<int16_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
return (static_cast<int32_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
return (static_cast<int64_t*>(data))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
return static_cast<double>((static_cast<float*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
return static_cast<double>((static_cast<uint8_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
return static_cast<double>((static_cast<uint16_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
return static_cast<double>((static_cast<uint32_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
return static_cast<double>((static_cast<uint64_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
return static_cast<double>((static_cast<int8_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
return static_cast<double>((static_cast<int16_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
return static_cast<double>((static_cast<int32_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
return static_cast<double>((static_cast<int64_t*>(data))[yIdx*getNx()+xIdx]);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -884,25 +645,25 @@ double JKQTPMathImage::getPixelValue(int xIdx, int yIdx) const {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int JKQTPMathImage::getSampleSize() const {
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
return sizeof(double);
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
return sizeof(float);
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
return sizeof(uint8_t);
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
return sizeof(uint16_t);
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
return sizeof(uint32_t);
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
return sizeof(uint64_t);
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
return sizeof(int8_t);
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
return sizeof(int16_t);
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
return sizeof(int32_t);
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
return sizeof(int64_t);
|
||||
default:
|
||||
return 0;
|
||||
@ -915,20 +676,20 @@ int JKQTPMathImage::getSampleSize() const {
|
||||
double JKQTPMathImage::getModifierValueAt(double x, double y)
|
||||
{
|
||||
ensureImageData();
|
||||
int xx=trunc((x-this->x)/width*double(Nx));
|
||||
int yy=trunc((y-this->y)/height*double(Ny));
|
||||
int xx=jkqtp_truncTo<int>((x-this->x)/width*double(Nx));
|
||||
int yy=jkqtp_truncTo<int>((y-this->y)/height*double(Ny));
|
||||
if (xx>=0 && xx<(int64_t)Nx && yy>=0 && yy<(int64_t)Ny) {
|
||||
switch(datatypeModifier) {
|
||||
case JKQTPMathImageBase::DoubleArray: return (static_cast<double*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::FloatArray: return (static_cast<float*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt8Array: return (static_cast<uint8_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt16Array: return (static_cast<uint16_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt32Array: return (static_cast<uint32_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::UInt64Array: return (static_cast<uint64_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int8Array: return (static_cast<int8_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int16Array: return (static_cast<int16_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int32Array: return (static_cast<int32_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageBase::Int64Array: return (static_cast<int64_t*>(dataModifier))[yy*Nx+xx]; break;
|
||||
case JKQTPMathImageDataType::DoubleArray: return (static_cast<double*>(dataModifier))[yy*Nx+xx];
|
||||
case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<float*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt8Array: return static_cast<double>((static_cast<uint8_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt16Array: return static_cast<double>((static_cast<uint16_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt32Array: return static_cast<double>((static_cast<uint32_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::UInt64Array: return static_cast<double>((static_cast<uint64_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int8Array: return static_cast<double>((static_cast<int8_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int16Array: return static_cast<double>((static_cast<int16_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int32Array: return static_cast<double>((static_cast<int32_t*>(dataModifier))[yy*Nx+xx]);
|
||||
case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<int64_t*>(dataModifier))[yy*Nx+xx]);
|
||||
} }
|
||||
return 0.0;
|
||||
}
|
||||
@ -940,26 +701,26 @@ double JKQTPMathImage::getModifierPixelValue(int xIdx, int yIdx) const {
|
||||
//ensureImageData();
|
||||
if (!dataModifier) return 0;
|
||||
switch(datatypeModifier) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
return (static_cast<double*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
return (static_cast<float*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
return (static_cast<uint8_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
return (static_cast<uint16_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
return (static_cast<uint32_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
return (static_cast<uint64_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
return (static_cast<int8_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
return (static_cast<int16_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
return (static_cast<int32_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
return (static_cast<int64_t*>(dataModifier))[yIdx*getNx()+xIdx];
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
return static_cast<double>((static_cast<float*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
return static_cast<double>((static_cast<uint8_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
return static_cast<double>((static_cast<uint16_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
return static_cast<double>((static_cast<uint32_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
return static_cast<double>((static_cast<uint64_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
return static_cast<double>((static_cast<int8_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
return static_cast<double>((static_cast<int16_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
return static_cast<double>((static_cast<int32_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
return static_cast<double>((static_cast<int64_t*>(dataModifier))[yIdx*getNx()+xIdx]);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -969,25 +730,25 @@ double JKQTPMathImage::getModifierPixelValue(int xIdx, int yIdx) const {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int JKQTPMathImage::getModifierSampleSize() const {
|
||||
switch(datatypeModifier) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
return sizeof(double);
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
return sizeof(float);
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
return sizeof(uint8_t);
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
return sizeof(uint16_t);
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
return sizeof(uint32_t);
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
return sizeof(uint64_t);
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
return sizeof(int8_t);
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
return sizeof(int16_t);
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
return sizeof(int32_t);
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
return sizeof(int64_t);
|
||||
default:
|
||||
return 0;
|
||||
|
@ -121,20 +121,20 @@ void JKQTPRGBMathImage::initObject()
|
||||
|
||||
|
||||
|
||||
JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter *parent):
|
||||
JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, 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, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent):
|
||||
JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent):
|
||||
JKQTPRGBMathImage(x, y, width, height, datatype, data, Nx, Ny, parent->getPlotter())
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTBasePlotter *parent):
|
||||
JKQTPMathImageBase(0,0,0,0, DoubleArray, nullptr, 0, 0, parent)
|
||||
JKQTPMathImageBase(0,0,0,0, JKQTPMathImageDataType::DoubleArray, nullptr, 0, 0, parent)
|
||||
{
|
||||
initObject();
|
||||
}
|
||||
@ -500,12 +500,12 @@ void *JKQTPRGBMathImage::getDataR() const
|
||||
return getData();
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setDatatypeR(JKQTPMathImageBase::DataType __value)
|
||||
void JKQTPRGBMathImage::setDatatypeR(JKQTPMathImageDataType __value)
|
||||
{
|
||||
setDatatype(__value);
|
||||
}
|
||||
|
||||
JKQTPMathImageBase::DataType JKQTPRGBMathImage::getDatatypeR() const
|
||||
JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeR() const
|
||||
{
|
||||
return getDatatype();
|
||||
}
|
||||
@ -520,12 +520,12 @@ void *JKQTPRGBMathImage::getDataG() const
|
||||
return this->dataG;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setDatatypeG(JKQTPMathImageBase::DataType __value)
|
||||
void JKQTPRGBMathImage::setDatatypeG(JKQTPMathImageDataType __value)
|
||||
{
|
||||
this->datatypeG = __value;
|
||||
}
|
||||
|
||||
JKQTPMathImageBase::DataType JKQTPRGBMathImage::getDatatypeG() const
|
||||
JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeG() const
|
||||
{
|
||||
return this->datatypeG;
|
||||
}
|
||||
@ -540,12 +540,12 @@ void *JKQTPRGBMathImage::getDataB() const
|
||||
return this->dataB;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setDatatypeB(JKQTPMathImageBase::DataType __value)
|
||||
void JKQTPRGBMathImage::setDatatypeB(JKQTPMathImageDataType __value)
|
||||
{
|
||||
this->datatypeB = __value;
|
||||
}
|
||||
|
||||
JKQTPMathImageBase::DataType JKQTPRGBMathImage::getDatatypeB() const
|
||||
JKQTPMathImageDataType JKQTPRGBMathImage::getDatatypeB() const
|
||||
{
|
||||
return this->datatypeB;
|
||||
}
|
||||
@ -832,49 +832,119 @@ JKQTPRGBMathImageRGBMode JKQTPRGBMathImage::getRgbMode() const
|
||||
return this->rgbMode;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setModifierMode(const JKQTPMathImageModifierMode &__value)
|
||||
{
|
||||
this->modifierMode = __value;
|
||||
}
|
||||
|
||||
JKQTPMathImageModifierMode JKQTPRGBMathImage::getModifierMode() const
|
||||
{
|
||||
return this->modifierMode;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPRGBMathImage::setColorBarModifiedWidth(double __value)
|
||||
{
|
||||
this->colorBarModifiedWidth = __value;
|
||||
}
|
||||
|
||||
double JKQTPRGBMathImage::getColorBarModifiedWidth() const
|
||||
{
|
||||
return this->colorBarModifiedWidth;
|
||||
}
|
||||
|
||||
|
||||
JKQTPVerticalIndependentAxis *JKQTPRGBMathImage::getModifierColorBarTopAxis() {
|
||||
return this->modifierColorBarTopAxis;
|
||||
}
|
||||
|
||||
JKQTPHorizontalIndependentAxis *JKQTPRGBMathImage::getModifierColorBarRightAxis() {
|
||||
return this->modifierColorBarRightAxis ;
|
||||
}
|
||||
|
||||
|
||||
const JKQTPVerticalIndependentAxis *JKQTPRGBMathImage::getModifierColorBarTopAxis() const {
|
||||
return this->modifierColorBarTopAxis;
|
||||
}
|
||||
|
||||
const JKQTPHorizontalIndependentAxis *JKQTPRGBMathImage::getModifierColorBarRightAxis() const {
|
||||
return this->modifierColorBarRightAxis ;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPRGBMathImage::setAutoModifierRange(bool __value)
|
||||
{
|
||||
this->autoModifierRange = __value;
|
||||
}
|
||||
|
||||
bool JKQTPRGBMathImage::getAutoModifierRange() const
|
||||
{
|
||||
return this->autoModifierRange;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setModifierMin(double __value)
|
||||
{
|
||||
this->modifierMin = __value;
|
||||
}
|
||||
|
||||
double JKQTPRGBMathImage::getModifierMin() const
|
||||
{
|
||||
return this->modifierMin;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setModifierMax(double __value)
|
||||
{
|
||||
this->modifierMax = __value;
|
||||
}
|
||||
|
||||
double JKQTPRGBMathImage::getModifierMax() const
|
||||
{
|
||||
return this->modifierMax;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::getDataMinMaxG(double& imin, double& imax) {
|
||||
ensureImageData();
|
||||
if (autoImageRange) {
|
||||
imin=imax=0;
|
||||
if (!dataG) return;
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
imin= JKQTPImagePlot_getImageMin<double>(static_cast<double*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<double>(static_cast<double*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
imin= JKQTPImagePlot_getImageMin<float>(static_cast<float*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<float>(static_cast<float*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<uint8_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<uint8_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<uint16_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<uint16_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<uint32_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<uint32_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<uint64_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<uint64_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<int8_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<int8_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<int16_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<int16_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<int32_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<int32_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<int64_t*>(dataG), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<int64_t*>(dataG), Nx, Ny);
|
||||
break;
|
||||
@ -891,43 +961,43 @@ void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) {
|
||||
imin=imax=0;
|
||||
if (!dataG) return;
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
imin= JKQTPImagePlot_getImageMin<double>(static_cast<double*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<double>(static_cast<double*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
imin= JKQTPImagePlot_getImageMin<float>(static_cast<float*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<float>(static_cast<float*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint8_t>(static_cast<uint8_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint8_t>(static_cast<uint8_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint16_t>(static_cast<uint16_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint16_t>(static_cast<uint16_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint32_t>(static_cast<uint32_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint32_t>(static_cast<uint32_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
imin= JKQTPImagePlot_getImageMin<uint64_t>(static_cast<uint64_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<uint64_t>(static_cast<uint64_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int8_t>(static_cast<int8_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int8_t>(static_cast<int8_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int16_t>(static_cast<int16_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int16_t>(static_cast<int16_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int32_t>(static_cast<int32_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int32_t>(static_cast<int32_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
imin= JKQTPImagePlot_getImageMin<int64_t>(static_cast<int64_t*>(dataB), Nx, Ny);
|
||||
imax= JKQTPImagePlot_getImageMax<int64_t>(static_cast<int64_t*>(dataB), Nx, Ny);
|
||||
break;
|
||||
@ -949,16 +1019,16 @@ double JKQTPRGBMathImage::getValueAt(double x, double y, int channel)
|
||||
int yy=static_cast<int>(trunc((y-this->y)/height*Ny));
|
||||
if (xx>=0 && xx<Nx && yy>=0 && yy<Ny) {
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray: return static_cast<double>((static_cast<double*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::FloatArray: return static_cast<double>((static_cast<float*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::UInt8Array: return static_cast<double>((static_cast<uint8_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::UInt16Array: return static_cast<double>((static_cast<uint16_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::UInt32Array: return static_cast<double>((static_cast<uint32_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::UInt64Array: return static_cast<double>((static_cast<uint64_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::Int8Array: return static_cast<double>((static_cast<int8_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::Int16Array: return static_cast<double>((static_cast<int16_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::Int32Array: return static_cast<double>((static_cast<int32_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageBase::Int64Array: return static_cast<double>((static_cast<int64_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageDataType::DoubleArray: return static_cast<double>((static_cast<double*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageDataType::FloatArray: return static_cast<double>((static_cast<float*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageDataType::UInt8Array: return static_cast<double>((static_cast<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::UInt32Array: return static_cast<double>((static_cast<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::Int8Array: return static_cast<double>((static_cast<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::Int32Array: return static_cast<double>((static_cast<int32_t*>(dd))[yy*Nx+xx]); break;
|
||||
case JKQTPMathImageDataType::Int64Array: return static_cast<double>((static_cast<int64_t*>(dd))[yy*Nx+xx]); break;
|
||||
} }
|
||||
return 0.0;
|
||||
}
|
||||
@ -1045,61 +1115,62 @@ QImage JKQTPRGBMathImage::drawImage() {
|
||||
c.setHsv(0,255,127);
|
||||
img.fill(c.rgba());
|
||||
}
|
||||
getModifierMinMax(internalModifierMin, internalModifierMax);
|
||||
getDataMinMax(internalDataMin, internalDataMax);
|
||||
getDataMinMaxG(internalDataMinG, internalDataMaxG);
|
||||
getDataMinMaxB(internalDataMinB, internalDataMaxB);
|
||||
int palette = 0;
|
||||
if (data) {
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break;
|
||||
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<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::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<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::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<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::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<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::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<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;
|
||||
}
|
||||
}
|
||||
palette = 1;
|
||||
if (dataG) {
|
||||
switch(datatypeG) {
|
||||
case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break;
|
||||
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<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::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<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::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<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::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<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::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<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;
|
||||
}
|
||||
}
|
||||
palette = 2;
|
||||
if (dataB) {
|
||||
switch(datatypeB) {
|
||||
case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<double*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage<float>(static_cast<float*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<uint8_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage<uint16_t>(static_cast<uint16_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<uint32_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage<uint64_t>(static_cast<uint64_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<int8_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage<int16_t>(static_cast<int16_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<int32_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage<int64_t>(static_cast<int64_t*>(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break;
|
||||
case JKQTPMathImageDataType::DoubleArray: JKQTPImagePlot_array2RGBimage<double>(static_cast<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::UInt8Array: JKQTPImagePlot_array2RGBimage<uint8_t>(static_cast<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::UInt32Array: JKQTPImagePlot_array2RGBimage<uint32_t>(static_cast<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::Int8Array: JKQTPImagePlot_array2RGBimage<int8_t>(static_cast<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::Int32Array: JKQTPImagePlot_array2RGBimage<int32_t>(static_cast<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;
|
||||
}
|
||||
}
|
||||
|
||||
modifyImage(img);
|
||||
JKQTPModifyImage(img, modifierMode, dataModifier, datatypeModifier, Nx, Ny, internalModifierMin, internalModifierMax);
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, DataType datatype) {
|
||||
void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, JKQTPMathImageDataType datatype) {
|
||||
this->data=data;
|
||||
this->datatype=datatype;
|
||||
this->dataG=nullptr;
|
||||
@ -1117,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, JKQTPMathImageBase::DataType datatype) {
|
||||
void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny, JKQTPMathImageDataType datatype) {
|
||||
this->data=data;
|
||||
this->datatype=datatype;
|
||||
this->datatypeG=datatype;
|
||||
@ -1139,33 +1210,33 @@ void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, in
|
||||
|
||||
|
||||
JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTBasePlotter *parent):
|
||||
JKQTPRGBMathImage(0,0,0,0,DoubleArray,nullptr,0,0,parent)
|
||||
JKQTPRGBMathImage(0,0,0,0,JKQTPMathImageDataType::DoubleArray,nullptr,0,0,parent)
|
||||
{
|
||||
this->modifierColumn=-1;
|
||||
this->imageRColumn=-1;
|
||||
this->imageGColumn=-1;
|
||||
this->imageBColumn=-1;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
}
|
||||
|
||||
JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, JKQTBasePlotter *parent):
|
||||
JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent)
|
||||
JKQTPRGBMathImage(x,y,width,height,JKQTPMathImageDataType::DoubleArray,nullptr,Nx,Ny,parent)
|
||||
{
|
||||
this->modifierColumn=-1;
|
||||
this->imageRColumn=-1;
|
||||
this->imageGColumn=-1;
|
||||
this->imageBColumn=-1;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
}
|
||||
|
||||
JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, JKQTBasePlotter *parent):
|
||||
JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,0,0,parent)
|
||||
JKQTPRGBMathImage(x,y,width,height,JKQTPMathImageDataType::DoubleArray,nullptr,0,0,parent)
|
||||
{
|
||||
this->modifierColumn=-1;
|
||||
this->imageRColumn=imageRColumn;
|
||||
this->imageGColumn=-1;
|
||||
this->imageBColumn=-1;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
if (parent && imageRColumn>=0 && parent->getDatastore()) {
|
||||
Nx= static_cast<int>(parent->getDatastore()->getColumnImageWidth(imageRColumn));
|
||||
Ny= static_cast<int>(parent->getDatastore()->getColumnImageHeight(imageRColumn));
|
||||
@ -1173,13 +1244,13 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt
|
||||
}
|
||||
|
||||
JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, JKQTBasePlotter *parent):
|
||||
JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,0,0,parent)
|
||||
JKQTPRGBMathImage(x,y,width,height,JKQTPMathImageDataType::DoubleArray,nullptr,0,0,parent)
|
||||
{
|
||||
this->modifierColumn=-1;
|
||||
this->imageRColumn=imageRColumn;
|
||||
this->imageGColumn=imageGColumn;
|
||||
this->imageBColumn=-1;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
if (parent && imageRColumn>=0 && parent->getDatastore()) {
|
||||
Nx= static_cast<int>(parent->getDatastore()->getColumnImageWidth(imageRColumn));
|
||||
Ny= static_cast<int>(parent->getDatastore()->getColumnImageHeight(imageRColumn));
|
||||
@ -1187,13 +1258,13 @@ JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double widt
|
||||
}
|
||||
|
||||
JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, JKQTBasePlotter *parent):
|
||||
JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,0,0,parent)
|
||||
JKQTPRGBMathImage(x,y,width,height,JKQTPMathImageDataType::DoubleArray,nullptr,0,0,parent)
|
||||
{
|
||||
this->modifierColumn=-1;
|
||||
this->imageRColumn=imageRColumn;
|
||||
this->imageGColumn=imageGColumn;
|
||||
this->imageBColumn=imageBColumn;
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
if (parent && imageRColumn>=0 && parent->getDatastore()) {
|
||||
Nx= static_cast<int>(parent->getDatastore()->getColumnImageWidth(imageRColumn));
|
||||
Ny= static_cast<int>(parent->getDatastore()->getColumnImageHeight(imageRColumn));
|
||||
@ -1234,9 +1305,9 @@ bool JKQTPColumnRGBMathImage::usesColumn(int c) const
|
||||
void JKQTPColumnRGBMathImage::ensureImageData()
|
||||
{
|
||||
JKQTPRGBMathImage::ensureImageData();
|
||||
this->datatype=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatypeG=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatypeB=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatype=JKQTPMathImageDataType::DoubleArray;
|
||||
this->datatypeG=JKQTPMathImageDataType::DoubleArray;
|
||||
this->datatypeB=JKQTPMathImageDataType::DoubleArray;
|
||||
this->data=parent->getDatastore()->getColumnPointer(imageRColumn,0);
|
||||
this->dataG=parent->getDatastore()->getColumnPointer(imageGColumn,0);
|
||||
this->dataB=parent->getDatastore()->getColumnPointer(imageBColumn,0);
|
||||
@ -1248,7 +1319,7 @@ void JKQTPColumnRGBMathImage::ensureImageData()
|
||||
Ny=1;
|
||||
}
|
||||
}*/
|
||||
this->datatypeModifier=JKQTPMathImageBase::DoubleArray;
|
||||
this->datatypeModifier=JKQTPMathImageDataType::DoubleArray;
|
||||
this->dataModifier=parent->getDatastore()->getColumnPointer(modifierColumn,0);
|
||||
}
|
||||
|
||||
@ -1256,36 +1327,26 @@ void JKQTPColumnRGBMathImage::ensureImageData()
|
||||
QVector<double> JKQTPRGBMathImage::getDataGAsDoubleVector() const
|
||||
{
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<double*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<float*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint8_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint16_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint32_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint64_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int8_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int16_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int32_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int64_t*>(dataG), Nx*Ny);
|
||||
break;
|
||||
}
|
||||
QVector<double> res;
|
||||
return res;
|
||||
@ -1294,36 +1355,26 @@ QVector<double> JKQTPRGBMathImage::getDataGAsDoubleVector() const
|
||||
QVector<double> JKQTPRGBMathImage::getDataBAsDoubleVector() const
|
||||
{
|
||||
switch(datatype) {
|
||||
case JKQTPMathImageBase::DoubleArray:
|
||||
case JKQTPMathImageDataType::DoubleArray:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<double*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::FloatArray:
|
||||
case JKQTPMathImageDataType::FloatArray:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<float*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt8Array:
|
||||
case JKQTPMathImageDataType::UInt8Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint8_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt16Array:
|
||||
case JKQTPMathImageDataType::UInt16Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint16_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt32Array:
|
||||
case JKQTPMathImageDataType::UInt32Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint32_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::UInt64Array:
|
||||
case JKQTPMathImageDataType::UInt64Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<uint64_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int8Array:
|
||||
case JKQTPMathImageDataType::Int8Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int8_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int16Array:
|
||||
case JKQTPMathImageDataType::Int16Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int16_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int32Array:
|
||||
case JKQTPMathImageDataType::Int32Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int32_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
case JKQTPMathImageBase::Int64Array:
|
||||
case JKQTPMathImageDataType::Int64Array:
|
||||
return JKQTPImagePlot_arrayToDVector(static_cast<int64_t*>(dataB), Nx*Ny);
|
||||
break;
|
||||
}
|
||||
QVector<double> res;
|
||||
return res;
|
||||
|
@ -34,11 +34,18 @@
|
||||
|
||||
|
||||
|
||||
/*! \brief class to plot an image from an 2-dimensional array of values
|
||||
/*! \brief class to plot an image from an 2-dimensional array of RGB values
|
||||
\ingroup jkqtplotter_imagelots_elements
|
||||
|
||||
This class extends JKQTPMathImageBase and interprets the data array JKQTPMathImageBase::data as
|
||||
the 1st (RED) color channel and adds two more channels for GREEN and BLUE.
|
||||
|
||||
Using setRgbMode() you can also use a different color system than RGB.
|
||||
|
||||
\image html rgbimageplots.png
|
||||
\image html rgbimageplot_opencv.png
|
||||
|
||||
\see Examples: \ref JKQTPlotterRGBImagePlot and \ref JKQTPlotterImagePlotRGBOpenCV
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
Q_OBJECT
|
||||
@ -59,7 +66,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
* \param parent parent plotter object
|
||||
*
|
||||
*/
|
||||
JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr);
|
||||
JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr);
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
@ -74,7 +81,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
* \param parent parent plotter object
|
||||
*
|
||||
*/
|
||||
JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent);
|
||||
JKQTPRGBMathImage(double x, double y, double width, double height, JKQTPMathImageDataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent);
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
@ -97,12 +104,12 @@ 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, DataType datatype);
|
||||
virtual void setData(void* dataR, void* dataG, 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);
|
||||
|
||||
/** \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, DataType datatype) override;
|
||||
virtual void setData(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 ;
|
||||
|
||||
@ -116,26 +123,26 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
/*! \copydoc data */
|
||||
void* getDataR() const;
|
||||
/*! \copydoc datatype */
|
||||
void setDatatypeR(DataType __value);
|
||||
void setDatatypeR(JKQTPMathImageDataType __value);
|
||||
/*! \copydoc datatype */
|
||||
DataType getDatatypeR() const;
|
||||
JKQTPMathImageDataType getDatatypeR() const;
|
||||
|
||||
/*! \copydoc dataG */
|
||||
virtual void setDataG(void* __value);
|
||||
/*! \copydoc dataG */
|
||||
void* getDataG() const;
|
||||
/*! \copydoc datatypeG */
|
||||
void setDatatypeG(DataType __value);
|
||||
void setDatatypeG(JKQTPMathImageDataType __value);
|
||||
/*! \copydoc datatypeG */
|
||||
DataType getDatatypeG() const;
|
||||
JKQTPMathImageDataType getDatatypeG() const;
|
||||
/*! \copydoc dataB */
|
||||
virtual void setDataB(void* __value);
|
||||
/*! \copydoc dataB */
|
||||
void* getDataB() const;
|
||||
/*! \copydoc datatypeB */
|
||||
void setDatatypeB(DataType __value);
|
||||
void setDatatypeB(JKQTPMathImageDataType __value);
|
||||
/*! \copydoc datatypeB */
|
||||
DataType getDatatypeB() const;
|
||||
JKQTPMathImageDataType getDatatypeB() const;
|
||||
/*! \copydoc showColorBar */
|
||||
void setShowColorBar(bool __value);
|
||||
/*! \copydoc showColorBar */
|
||||
@ -256,6 +263,35 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
void setRgbMode(JKQTPRGBMathImageRGBMode __value);
|
||||
/*! \copydoc rgbMode */
|
||||
JKQTPRGBMathImageRGBMode getRgbMode() const;
|
||||
/*! \copydoc modifierMode */
|
||||
void setModifierMode(const JKQTPMathImageModifierMode & __value);
|
||||
/*! \copydoc modifierMode */
|
||||
JKQTPMathImageModifierMode getModifierMode() const;
|
||||
|
||||
/*! \copydoc colorBarModifiedWidth */
|
||||
void setColorBarModifiedWidth(double __value);
|
||||
/*! \copydoc colorBarModifiedWidth */
|
||||
double getColorBarModifiedWidth() const;
|
||||
/*! \copydoc modifierColorBarTopAxis */
|
||||
JKQTPVerticalIndependentAxis* getModifierColorBarTopAxis();
|
||||
/*! \copydoc modifierColorBarRightAxis */
|
||||
JKQTPHorizontalIndependentAxis* getModifierColorBarRightAxis();
|
||||
/*! \copydoc modifierColorBarTopAxis */
|
||||
const JKQTPVerticalIndependentAxis* getModifierColorBarTopAxis() const;
|
||||
/*! \copydoc modifierColorBarRightAxis */
|
||||
const JKQTPHorizontalIndependentAxis *getModifierColorBarRightAxis() const;
|
||||
/*! \copydoc autoModifierRange */
|
||||
void setAutoModifierRange(bool __value);
|
||||
/*! \copydoc autoModifierRange */
|
||||
bool getAutoModifierRange() const;
|
||||
/*! \copydoc modifierMin */
|
||||
void setModifierMin(double __value);
|
||||
/*! \copydoc modifierMin */
|
||||
double getModifierMin() const;
|
||||
/*! \copydoc modifierMax */
|
||||
void setModifierMax(double __value);
|
||||
/*! \copydoc modifierMax */
|
||||
double getModifierMax() const;
|
||||
|
||||
/** \brief return the data of the green channel used for plotting as a QVector<double> in row-major data-ordering */
|
||||
QVector<double> getDataGAsDoubleVector() const;
|
||||
@ -296,11 +332,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
/** \brief points to the data array, holding the image */
|
||||
void* dataG;
|
||||
/** \brief datatype of the data array data */
|
||||
DataType datatypeG;
|
||||
JKQTPMathImageDataType datatypeG;
|
||||
/** \brief points to the data array, holding the image */
|
||||
void* dataB;
|
||||
/** \brief datatype of the data array data */
|
||||
DataType datatypeB;
|
||||
JKQTPMathImageDataType datatypeB;
|
||||
|
||||
/** \brief how to interpret the three data channels red, green and blue */
|
||||
JKQTPRGBMathImageRGBMode rgbMode;
|
||||
@ -376,8 +412,31 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase {
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPHorizontalIndependentAxis* colorBarTopAxisB;
|
||||
/** \brief indicates whether to estimate min/max of the modifier automatically */
|
||||
bool autoModifierRange;
|
||||
/** \brief modifier value range minimum */
|
||||
double modifierMin;
|
||||
/** \brief modifier value range maximum */
|
||||
double modifierMax;
|
||||
/** \brief width of the color bar when modifier is on */
|
||||
double colorBarModifiedWidth;
|
||||
/** \brief how to apply the modifier column dataModifier
|
||||
* \see ModifierMode
|
||||
*/
|
||||
JKQTPMathImageModifierMode modifierMode;
|
||||
|
||||
|
||||
/** \brief object used for color bar axes (right border, modifier image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPVerticalIndependentAxis* modifierColorBarTopAxis;
|
||||
/** \brief object used for color bar axes (top border, modifier image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPHorizontalIndependentAxis* modifierColorBarRightAxis;
|
||||
|
||||
/** \brief internal storage for minimum of the green image value range
|
||||
*
|
||||
* This is set e.g. when calling drawImage() or draw()
|
||||
|
@ -550,29 +550,29 @@ void JKQTPSpecialLineTypeComboBox::addStep(JKQTPSpecialLineType step, const QStr
|
||||
|
||||
JKQTPImageModifierModeComboBox::JKQTPImageModifierModeComboBox(QWidget * /*parent*/)
|
||||
{
|
||||
addMode(JKQTPMathImageBase::ModifyNone, tr("none"));
|
||||
addMode(JKQTPMathImageBase::ModifyValue, tr("value"));
|
||||
addMode(JKQTPMathImageBase::ModifySaturation, tr("saturation"));
|
||||
addMode(JKQTPMathImageBase::ModifyAlpha, tr("alpha/transparency"));
|
||||
addMode(JKQTPMathImageBase::ModifyLuminance, tr("luminance"));
|
||||
addMode(JKQTPMathImageBase::ModifyHue, tr("hue"));
|
||||
addMode(JKQTPMathImageModifierMode::ModifyNone, tr("none"));
|
||||
addMode(JKQTPMathImageModifierMode::ModifyValue, tr("value"));
|
||||
addMode(JKQTPMathImageModifierMode::ModifySaturation, tr("saturation"));
|
||||
addMode(JKQTPMathImageModifierMode::ModifyAlpha, tr("alpha/transparency"));
|
||||
addMode(JKQTPMathImageModifierMode::ModifyLuminance, tr("luminance"));
|
||||
addMode(JKQTPMathImageModifierMode::ModifyHue, tr("hue"));
|
||||
}
|
||||
|
||||
JKQTPMathImageBase::ModifierMode JKQTPImageModifierModeComboBox::getModifierMode() const
|
||||
JKQTPMathImageModifierMode JKQTPImageModifierModeComboBox::getModifierMode() const
|
||||
{
|
||||
bool ok=false;
|
||||
JKQTPMathImageBase::ModifierMode m=JKQTPMathImageBase::ModifyNone;
|
||||
if (currentIndex()>=0) m=JKQTPMathImageBase::ModifierMode(itemData(currentIndex()).toInt(&ok));
|
||||
if (!ok) m=JKQTPMathImageBase::ModifyNone;
|
||||
JKQTPMathImageModifierMode m=JKQTPMathImageModifierMode::ModifyNone;
|
||||
if (currentIndex()>=0) m=JKQTPMathImageModifierMode(itemData(currentIndex()).toInt(&ok));
|
||||
if (!ok) m=JKQTPMathImageModifierMode::ModifyNone;
|
||||
return m;
|
||||
}
|
||||
|
||||
void JKQTPImageModifierModeComboBox::setModifierMode(JKQTPMathImageBase::ModifierMode mode)
|
||||
void JKQTPImageModifierModeComboBox::setModifierMode(JKQTPMathImageModifierMode mode)
|
||||
{
|
||||
setCurrentIndex(findData(static_cast<int>(mode)));
|
||||
}
|
||||
|
||||
void JKQTPImageModifierModeComboBox::addMode(JKQTPMathImageBase::ModifierMode mode, const QString &name, const QIcon &icon)
|
||||
void JKQTPImageModifierModeComboBox::addMode(JKQTPMathImageModifierMode mode, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, static_cast<int>(mode));
|
||||
}
|
||||
|
@ -250,20 +250,20 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineTypeComboBox: public QComboBox {
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPMathImageBase::ModifierMode
|
||||
/*! \brief a QComboBox which shows JKQTPMathImageModifierMode
|
||||
\ingroup jkqtpcomboboxes
|
||||
|
||||
\see JKQTPMathImageBase::ModifierMode
|
||||
\see JKQTPMathImageModifierMode
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPImageModifierModeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPImageModifierModeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPMathImageBase::ModifierMode getModifierMode() const;
|
||||
void setModifierMode(JKQTPMathImageBase::ModifierMode mode);
|
||||
JKQTPMathImageModifierMode getModifierMode() const;
|
||||
void setModifierMode(JKQTPMathImageModifierMode mode);
|
||||
protected:
|
||||
void addMode(JKQTPMathImageBase::ModifierMode mode, const QString& name, const QIcon& icon=QIcon());
|
||||
void addMode(JKQTPMathImageModifierMode mode, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
#endif // JKQTPCOMBOBOXES_H
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtcommon/jkqtpdrawingtools.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#ifdef QT_XML_LIB
|
||||
# include <QtXml/QtXml>
|
||||
#endif
|
||||
@ -124,9 +125,9 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
|
||||
static const uint8_t h=1;
|
||||
static const uint8_t dSize = 200*h;
|
||||
uint8_t d[dSize];//, dd[200*h];
|
||||
for (int i=0; i<200; i++) {
|
||||
for (uint8_t i=0; i<200; i++) {
|
||||
for (int j=0; j<h; j++) {
|
||||
d[i*h+j]=i;
|
||||
d[static_cast<int>(i)*h+j]=i;
|
||||
//dd[i*h+j]=j;
|
||||
}
|
||||
}
|
||||
@ -137,7 +138,7 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
|
||||
QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter);
|
||||
|
||||
double icolorBarRelativeHeight=colorBarRelativeHeight;
|
||||
int barHeight=rightSpace.height()*icolorBarRelativeHeight;
|
||||
int barHeight=static_cast<int>(rightSpace.height()*icolorBarRelativeHeight);
|
||||
if (barHeight<1) barHeight=1;
|
||||
// find a height for the bar that allows to show the image name
|
||||
while ((barHeight>1) && ((rightSpace.height()-barHeight)/2<names.height())) {
|
||||
@ -146,7 +147,7 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
|
||||
|
||||
//qDebug()<<"r: "<<imageName<<rightSpace;
|
||||
|
||||
QRect cb(rightSpace.x()+cbParent->pt2px(painter, colorBarOffset), rightSpace.top()+(rightSpace.height()-barHeight)/2, cbParent->pt2px(painter, colorBarWidth), barHeight);
|
||||
QRect cb(static_cast<int>(rightSpace.x()+cbParent->pt2px(painter, colorBarOffset)), rightSpace.top()+(rightSpace.height()-barHeight)/2, static_cast<int>(cbParent->pt2px(painter, colorBarWidth)), barHeight);
|
||||
painter.drawImage(cb, b.mirrored(true, false));
|
||||
QPen p=painter.pen();
|
||||
p.setColor(colorBarRightAxis->getAxisColor());
|
||||
@ -176,9 +177,9 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
|
||||
static const uint8_t h=1;
|
||||
static const uint8_t dSize = 200*h;
|
||||
uint8_t d[dSize];//, dd[200*h];
|
||||
for (int i=0; i<200; i++) {
|
||||
for (uint8_t i=0; i<200; i++) {
|
||||
for (int j=0; j<h; j++) {
|
||||
d[i*h+j]=i;
|
||||
d[static_cast<int>(i)*h+j]=i;
|
||||
//dd[i*h+j]=j;
|
||||
}
|
||||
}
|
||||
@ -188,7 +189,7 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
|
||||
QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter);
|
||||
|
||||
double icolorBarRelativeHeight=colorBarRelativeHeight;
|
||||
int barWidth=topSpace.width()*icolorBarRelativeHeight;
|
||||
int barWidth=static_cast<int>(topSpace.width()*icolorBarRelativeHeight);
|
||||
if (barWidth<1) barWidth=1;
|
||||
// find a height for the bar that allows to show the image name
|
||||
while ((barWidth>1) && ((topSpace.width()-barWidth)/2<names.width())) {
|
||||
@ -196,7 +197,7 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
|
||||
}
|
||||
|
||||
|
||||
QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+(colorBarWidth)), barWidth, cbParent->pt2px(painter, colorBarWidth));
|
||||
QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, static_cast<int>(topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+(colorBarWidth))), barWidth, static_cast<int>(cbParent->pt2px(painter, colorBarWidth)));
|
||||
//qDebug()<<"t: "<<imageName<<topSpace<<topSpace.bottom()<<colorBarOffset<<"\n "<<cb;
|
||||
QMatrix rm;
|
||||
rm.rotate(90);
|
||||
@ -238,7 +239,7 @@ int JKQTPColorPaletteStyleAndToolsMixin::getPalettesCount()
|
||||
}
|
||||
|
||||
QIcon JKQTPColorPaletteStyleAndToolsMixin::getPaletteIcon(int i) {
|
||||
QImage img=getPaletteImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH);
|
||||
QImage img=getPaletteImage(i, static_cast<size_t>(JKQTPImageTools::PALETTE_ICON_WIDTH));
|
||||
QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,7);
|
||||
QPainter p(&pix);
|
||||
@ -254,26 +255,25 @@ QIcon JKQTPColorPaletteStyleAndToolsMixin::getPaletteIcon(JKQTPMathImageColorPal
|
||||
return getPaletteIcon(static_cast<int>(palette));
|
||||
}
|
||||
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteImage(int i, int width)
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteImage(int i, size_t width)
|
||||
{
|
||||
QImage img;
|
||||
double* pic=static_cast<double*>(malloc(width*sizeof(double)));
|
||||
for (int j=0; j<width; j++) {
|
||||
std::vector<double> pic(static_cast<size_t>(width), 0.0);
|
||||
for (size_t j=0; j<width; j++) {
|
||||
pic[j]=j;
|
||||
}
|
||||
JKQTPImageTools::array2image<double>(pic, width, 1, img, static_cast<JKQTPMathImageColorPalette>(i), 0, width-1);
|
||||
free(pic);
|
||||
JKQTPImageTools::array2image<double>(pic.data(), static_cast<int>(width), 1, img, static_cast<JKQTPMathImageColorPalette>(i), 0, width-1);
|
||||
return img;
|
||||
}
|
||||
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteImage(JKQTPMathImageColorPalette palette, int width)
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteImage(JKQTPMathImageColorPalette palette, size_t width)
|
||||
{
|
||||
return getPaletteImage(static_cast<int>(palette), width);
|
||||
}
|
||||
|
||||
QIcon JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyIcon(int i)
|
||||
{
|
||||
QImage img=getPaletteKeyImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH, JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT);
|
||||
QImage img=getPaletteKeyImage(i, static_cast<size_t>(JKQTPImageTools::PALETTE_ICON_WIDTH), static_cast<size_t>(JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT));
|
||||
QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT);
|
||||
QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT-1);
|
||||
QPainter p(&pix);
|
||||
@ -289,7 +289,7 @@ QIcon JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyIcon(JKQTPMathImageColor
|
||||
return getPaletteIcon(static_cast<int>(palette));
|
||||
}
|
||||
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyImage(int i, int width, int height)
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyImage(int i, size_t width, size_t height)
|
||||
{
|
||||
QImage img;
|
||||
|
||||
@ -302,20 +302,19 @@ QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyImage(int i, int width,
|
||||
const double w2x=double(width*width)/(8.0*8.0);
|
||||
const double w2y=double(height*height)/(8.0*8.0);
|
||||
|
||||
double* pic=static_cast<double*>(malloc(width*height*sizeof(double)));
|
||||
std::vector<double> pic(width*height, 0.0);
|
||||
double mmax=0;
|
||||
for (int j=0; j<width*height; j++) {
|
||||
const int x=j%width;
|
||||
const int y=j/width;
|
||||
for (size_t j=0; j<width*height; j++) {
|
||||
const size_t x=j%width;
|
||||
const size_t y=j/width;
|
||||
pic[j]=exp(-0.5*(double((x-x01)*double(x-x01))/w1x+double((y-y01)*double(y-y01))/w1y))+0.7*exp(-0.5*(double((x-x02)*double(x-x02))/w2x+double((y-y02)*double(y-y02))/w2y));
|
||||
if (pic[j]>mmax) mmax=pic[j];
|
||||
}
|
||||
JKQTPImageTools::array2image<double>(pic, width, height, img, static_cast<JKQTPMathImageColorPalette>(i), 0, mmax);
|
||||
free(pic);
|
||||
JKQTPImageTools::array2image<double>(pic.data(), static_cast<int>(width), static_cast<int>(height), img, static_cast<JKQTPMathImageColorPalette>(i), 0, mmax);
|
||||
return img;
|
||||
}
|
||||
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyImage(JKQTPMathImageColorPalette palette, int width, int height)
|
||||
QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyImage(JKQTPMathImageColorPalette palette, size_t width, size_t height)
|
||||
{
|
||||
return getPaletteKeyImage(static_cast<int>(palette), width, height);
|
||||
}
|
||||
@ -538,3 +537,283 @@ bool JKQTPColorPaletteStyleAndToolsMixin::getColorBarRightVisible() const
|
||||
return this->colorBarRightVisible;
|
||||
}
|
||||
|
||||
|
||||
JKQTPColorPaletteWithModifierStyleAndToolsMixin::JKQTPColorPaletteWithModifierStyleAndToolsMixin(JKQTBasePlotter *parent):
|
||||
JKQTPColorPaletteStyleAndToolsMixin(parent)
|
||||
{
|
||||
modifierColorBarTopAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent);
|
||||
modifierColorBarTopAxis->setDrawMode1(JKQTPCADMLine);
|
||||
modifierColorBarTopAxis->setDrawMode2(JKQTPCADMcomplete);
|
||||
modifierColorBarTopAxis->setAxisLabel("");
|
||||
modifierColorBarTopAxis->setMinTicks(3);
|
||||
modifierColorBarTopAxis->setShowZeroAxis(false);
|
||||
modifierColorBarTopAxis->setMinorTicks(0);
|
||||
modifierColorBarTopAxis->setTickOutsideLength(0);
|
||||
modifierColorBarTopAxis->setMinorTickOutsideLength(0);
|
||||
modifierColorBarRightAxis=new JKQTPHorizontalIndependentAxis (0, 100, 0, 100, parent);
|
||||
modifierColorBarRightAxis->setDrawMode1(JKQTPCADMLine);
|
||||
modifierColorBarRightAxis->setDrawMode2(JKQTPCADMcomplete);
|
||||
modifierColorBarRightAxis->setAxisLabel("");
|
||||
modifierColorBarRightAxis->setMinTicks(5);
|
||||
modifierColorBarRightAxis->setShowZeroAxis(false);
|
||||
modifierColorBarRightAxis->setMinorTicks(0);
|
||||
modifierColorBarRightAxis->setTickOutsideLength(0);
|
||||
modifierColorBarRightAxis->setMinorTickOutsideLength(0);
|
||||
this->colorBarModifiedWidth=80;
|
||||
modifierMode=JKQTPMathImageModifierMode::ModifyNone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::cbGetOutsideSize(JKQTPEnhancedPainter &painter, int &leftSpace, int &rightSpace, int &topSpace, int &bottomSpace)
|
||||
{
|
||||
Q_UNUSED(leftSpace);
|
||||
Q_UNUSED(bottomSpace);
|
||||
if (showColorBar) {
|
||||
double internalDataMin=0;
|
||||
double internalDataMax=0;
|
||||
double internalModifierMin=0;
|
||||
double internalModifierMax=0;
|
||||
cbGetDataMinMax(internalDataMin, internalDataMax);
|
||||
cbGetModifierDataMinMax(internalDataMin, internalDataMax);
|
||||
if (colorBarRightVisible) {
|
||||
rightSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarRightAxis->setRange(internalDataMin, internalDataMax);
|
||||
colorBarRightAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotHeight());
|
||||
modifierColorBarRightAxis->setRange(internalModifierMin, internalModifierMax);
|
||||
modifierColorBarRightAxis->setAxisWidth(cbParent->pt2px(painter, colorBarModifiedWidth));
|
||||
QSizeF s1=colorBarRightAxis->getSize2(painter);
|
||||
QSizeF s2=colorBarRightAxis->getSize1(painter);
|
||||
QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter);
|
||||
rightSpace+=qMax(static_cast<double>(s1.width()+s2.width()), static_cast<double>(names.width()));
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
rightSpace=rightSpace+static_cast<int>(2.0*cbParent->pt2px(painter, colorBarModifiedWidth-colorBarWidth));
|
||||
}
|
||||
}
|
||||
if (colorBarTopVisible) {
|
||||
//topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarTopAxis->setRange(internalDataMin, internalDataMax);
|
||||
colorBarTopAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotWidth());
|
||||
modifierColorBarTopAxis->setRange(internalModifierMin, internalModifierMax);
|
||||
modifierColorBarTopAxis->setAxisWidth(cbParent->pt2px(painter, colorBarModifiedWidth));
|
||||
QSizeF s1=colorBarTopAxis->getSize2(painter);
|
||||
QSizeF s2=colorBarTopAxis->getSize1(painter);
|
||||
QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter);
|
||||
topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast<double>(s1.height()+s2.height()), static_cast<double>(names.height()));
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
topSpace=topSpace+static_cast<int>(2.0*cbParent->pt2px(painter, colorBarModifiedWidth-colorBarWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter &painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace)
|
||||
{
|
||||
if (showColorBar) {
|
||||
double internalDataMin=0;
|
||||
double internalDataMax=0;
|
||||
double internalModifierMin=0;
|
||||
double internalModifierMax=0;
|
||||
cbGetDataMinMax(internalDataMin, internalDataMax);
|
||||
cbGetModifierDataMinMax(internalDataMin, internalDataMax);
|
||||
uint8_t h=1;
|
||||
static const uint8_t dSize = 200*h;
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
h=50;
|
||||
}
|
||||
std::vector<double> d(dSize, 0.0);
|
||||
std::vector<double> dd(dSize, 0.0);
|
||||
for (uint8_t i=0; i<dSize; i++) {
|
||||
for (uint8_t j=0; j<h; j++) {
|
||||
d[i*h+j]=i;
|
||||
dd[i*h+j]=j;
|
||||
}
|
||||
}
|
||||
|
||||
QImage b(h,200, QImage::Format_ARGB32);
|
||||
JKQTPImageTools::array2image<double>(d.data(),h,dSize/h, b, palette, 0, dSize/h-1);
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
modifyImage(b, dd.data(), JKQTPMathImageDataType::DoubleArray, h,dSize/h, 0, h-1);
|
||||
}
|
||||
|
||||
if (colorBarRightVisible) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
|
||||
QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter);
|
||||
|
||||
double icolorBarRelativeHeight=colorBarRelativeHeight;
|
||||
int barHeight=static_cast<int>(rightSpace.height()*icolorBarRelativeHeight);
|
||||
if (barHeight<1) barHeight=1;
|
||||
// find a height for the bar that allows to show the image name
|
||||
while ((barHeight>1) && ((rightSpace.height()-barHeight)/2<names.height())) {
|
||||
barHeight--;
|
||||
}
|
||||
|
||||
//qDebug()<<"r: "<<imageName<<rightSpace;
|
||||
|
||||
QRect cb(static_cast<int>(rightSpace.x()+cbParent->pt2px(painter, colorBarOffset)), rightSpace.top()+(rightSpace.height()-barHeight)/2, static_cast<int>(cbParent->pt2px(painter, (modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth)), barHeight);
|
||||
painter.drawImage(cb, b.mirrored(true, false));
|
||||
QPen p=painter.pen();
|
||||
p.setColor(colorBarRightAxis->getAxisColor());
|
||||
p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH, cbParent->pt2px(painter, colorBarRightAxis->getLineWidth()*cbParent->getLineWidthMultiplier())));
|
||||
painter.setPen(p);
|
||||
painter.drawRect(cb);
|
||||
|
||||
colorBarRightAxis->setRange(internalDataMin, internalDataMax);
|
||||
colorBarRightAxis->setAxisWidth(cb.height());
|
||||
colorBarRightAxis->setAxisOffset(cb.top());
|
||||
colorBarRightAxis->setOtherAxisOffset(cb.left());
|
||||
colorBarRightAxis->setOtherAxisWidth(cb.width());
|
||||
colorBarRightAxis->drawAxes(painter);
|
||||
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
modifierColorBarRightAxis->setRange(internalModifierMin, internalModifierMax);
|
||||
modifierColorBarRightAxis->setAxisWidth(cbParent->pt2px(painter, colorBarModifiedWidth));
|
||||
modifierColorBarRightAxis->setAxisOffset(cb.left());
|
||||
modifierColorBarRightAxis->setOtherAxisOffset(cb.top());
|
||||
modifierColorBarRightAxis->setOtherAxisWidth(cb.height());
|
||||
modifierColorBarRightAxis->drawAxes(painter);
|
||||
}
|
||||
|
||||
cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier());
|
||||
cbParent->getMathText()->setFontRomanOrSpecial(cbParent->getCurrentPlotterStyle().defaultFontName);
|
||||
cbParent->getMathText()->parse(imageName);
|
||||
cbParent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(rightSpace.x(), rightSpace.y(), rightSpace.width(), (rightSpace.height()-barHeight)/2));
|
||||
|
||||
|
||||
}
|
||||
if (colorBarTopVisible) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
|
||||
QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter);
|
||||
|
||||
double icolorBarRelativeHeight=colorBarRelativeHeight;
|
||||
int barWidth=topSpace.width()*icolorBarRelativeHeight;
|
||||
if (barWidth<1) barWidth=1;
|
||||
// find a height for the bar that allows to show the image name
|
||||
while ((barWidth>1) && ((topSpace.width()-barWidth)/2<names.width())) {
|
||||
barWidth--;
|
||||
}
|
||||
|
||||
|
||||
QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+((modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth)), barWidth, cbParent->pt2px(painter, (modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth));
|
||||
//qDebug()<<"t: "<<imageName<<topSpace<<topSpace.bottom()<<colorBarOffset<<"\n "<<cb;
|
||||
QMatrix rm;
|
||||
rm.rotate(90);
|
||||
painter.drawImage(cb, b.transformed(rm));
|
||||
QPen p=painter.pen();
|
||||
p.setColor(colorBarTopAxis->getAxisColor());
|
||||
p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH, cbParent->pt2px(painter, colorBarTopAxis->getLineWidth()*cbParent->getLineWidthMultiplier())));
|
||||
painter.setPen(p);
|
||||
painter.drawRect(cb);
|
||||
|
||||
|
||||
colorBarTopAxis->setRange(internalDataMin, internalDataMax);
|
||||
colorBarTopAxis->setAxisWidth(cb.width());
|
||||
colorBarTopAxis->setAxisOffset(cb.left());
|
||||
colorBarTopAxis->setOtherAxisOffset(cb.top());
|
||||
colorBarTopAxis->setOtherAxisWidth(cb.height());
|
||||
colorBarTopAxis->drawAxes(painter);
|
||||
|
||||
if (modifierMode!=JKQTPMathImageModifierMode::ModifyNone) {
|
||||
modifierColorBarTopAxis->setRange(internalModifierMin, internalModifierMax);
|
||||
modifierColorBarTopAxis->setAxisWidth(cbParent->pt2px(painter, colorBarModifiedWidth));
|
||||
modifierColorBarTopAxis->setAxisOffset(cb.top());
|
||||
modifierColorBarTopAxis->setOtherAxisOffset(cb.left());
|
||||
modifierColorBarTopAxis->setOtherAxisWidth(cb.width());
|
||||
modifierColorBarTopAxis->drawAxes(painter);
|
||||
}
|
||||
|
||||
cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier());
|
||||
cbParent->getMathText()->setFontRomanOrSpecial(cbParent->getCurrentPlotterStyle().defaultFontName);
|
||||
cbParent->getMathText()->parse(imageName);
|
||||
cbParent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(topSpace.right()-(topSpace.width()-barWidth)/2, topSpace.y(), (topSpace.width()-barWidth)/2, topSpace.height()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::cbSetParent(JKQTBasePlotter *parent)
|
||||
{
|
||||
JKQTPColorPaletteStyleAndToolsMixin::cbSetParent(parent);
|
||||
modifierColorBarTopAxis->setParent(parent);
|
||||
modifierColorBarRightAxis->setParent(parent);
|
||||
}
|
||||
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::setModifierMode(const JKQTPMathImageModifierMode &__value)
|
||||
{
|
||||
this->modifierMode = __value;
|
||||
}
|
||||
|
||||
JKQTPMathImageModifierMode JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierMode() const
|
||||
{
|
||||
return this->modifierMode;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::modifyImage(QImage &img, void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax)
|
||||
{
|
||||
JKQTPModifyImage(img, modifierMode, dataModifier, datatypeModifier, Nx, Ny, internalModifierMin, internalModifierMax);
|
||||
}
|
||||
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::setColorBarModifiedWidth(double __value)
|
||||
{
|
||||
this->colorBarModifiedWidth = __value;
|
||||
}
|
||||
|
||||
double JKQTPColorPaletteWithModifierStyleAndToolsMixin::getColorBarModifiedWidth() const
|
||||
{
|
||||
return this->colorBarModifiedWidth;
|
||||
}
|
||||
|
||||
|
||||
JKQTPVerticalIndependentAxis *JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierColorBarTopAxis() {
|
||||
return this->modifierColorBarTopAxis;
|
||||
}
|
||||
|
||||
JKQTPHorizontalIndependentAxis *JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierColorBarRightAxis() {
|
||||
return this->modifierColorBarRightAxis ;
|
||||
}
|
||||
|
||||
|
||||
const JKQTPVerticalIndependentAxis *JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierColorBarTopAxis() const {
|
||||
return this->modifierColorBarTopAxis;
|
||||
}
|
||||
|
||||
const JKQTPHorizontalIndependentAxis *JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierColorBarRightAxis() const {
|
||||
return this->modifierColorBarRightAxis ;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::setAutoModifierRange(bool __value)
|
||||
{
|
||||
this->autoModifierRange = __value;
|
||||
}
|
||||
|
||||
bool JKQTPColorPaletteWithModifierStyleAndToolsMixin::getAutoModifierRange() const
|
||||
{
|
||||
return this->autoModifierRange;
|
||||
}
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::setModifierMin(double __value)
|
||||
{
|
||||
this->modifierMin = __value;
|
||||
}
|
||||
|
||||
double JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierMin() const
|
||||
{
|
||||
return this->modifierMin;
|
||||
}
|
||||
|
||||
void JKQTPColorPaletteWithModifierStyleAndToolsMixin::setModifierMax(double __value)
|
||||
{
|
||||
this->modifierMax = __value;
|
||||
}
|
||||
|
||||
double JKQTPColorPaletteWithModifierStyleAndToolsMixin::getModifierMax() const
|
||||
{
|
||||
return this->modifierMax;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class JKQTPVerticalIndependentAxis; // forward
|
||||
class JKQTPHorizontalIndependentAxis; // forward
|
||||
class JKQTBasePlotter; // forward
|
||||
|
||||
|
||||
/*! \brief if a class is derived from this class, it may use color bars
|
||||
\ingroup jkqtplotter_imagelots_tools
|
||||
*/
|
||||
@ -55,18 +56,18 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteStyleAndToolsMixin {
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteIcon(JKQTPMathImageColorPalette palette) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QImage getPaletteImage(int i, int width) ;
|
||||
static QImage getPaletteImage(int i, size_t width) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QImage getPaletteImage(JKQTPMathImageColorPalette palette, int width) ;
|
||||
static QImage getPaletteImage(JKQTPMathImageColorPalette palette, size_t width) ;
|
||||
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteKeyIcon(int i) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QIcon getPaletteKeyIcon(JKQTPMathImageColorPalette palette) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QImage getPaletteKeyImage(int i, int width, int height) ;
|
||||
static QImage getPaletteKeyImage(int i, size_t width, size_t height) ;
|
||||
/*! \brief get QIcon representing the given palette */
|
||||
static QImage getPaletteKeyImage(JKQTPMathImageColorPalette palette, int width, int height) ;
|
||||
static QImage getPaletteKeyImage(JKQTPMathImageColorPalette palette, size_t width, size_t height) ;
|
||||
|
||||
|
||||
|
||||
@ -75,7 +76,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteStyleAndToolsMixin {
|
||||
|
||||
\note If you want to draw outside, then you'll also have to implement drawOutside()
|
||||
*/
|
||||
void cbGetOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace);
|
||||
virtual void cbGetOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace);
|
||||
|
||||
/*! \brief plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
|
||||
|
||||
@ -83,11 +84,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteStyleAndToolsMixin {
|
||||
|
||||
The four value supplied tell the method where to draw (inside one of the rectangles).
|
||||
*/
|
||||
void cbDrawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace);
|
||||
virtual void cbDrawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace);
|
||||
|
||||
|
||||
/** \brief set the parent class for internal objects (e.g. color bars) */
|
||||
void cbSetParent(JKQTBasePlotter* parent);
|
||||
virtual void cbSetParent(JKQTBasePlotter* parent);
|
||||
|
||||
|
||||
/** \brief determine min/max data value of the image */
|
||||
@ -228,11 +229,15 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteStyleAndToolsMixin {
|
||||
QColor infColor;
|
||||
|
||||
|
||||
/** \brief object used for color bar axes
|
||||
/** \brief object used for color bar axes at the right
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPVerticalIndependentAxis* colorBarRightAxis;
|
||||
/** \brief object used for color bar axes at the top
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPHorizontalIndependentAxis* colorBarTopAxis;
|
||||
|
||||
|
||||
@ -240,4 +245,106 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteStyleAndToolsMixin {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief if a class is derived from this class, it may use color bars that have 2 axes (one "data"/color axis and one "modifier" axis)
|
||||
\ingroup jkqtplotter_imagelots_tools
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPColorPaletteWithModifierStyleAndToolsMixin : public JKQTPColorPaletteStyleAndToolsMixin {
|
||||
Q_GADGET
|
||||
public:
|
||||
|
||||
|
||||
|
||||
JKQTPColorPaletteWithModifierStyleAndToolsMixin(JKQTBasePlotter *parent);
|
||||
virtual ~JKQTPColorPaletteWithModifierStyleAndToolsMixin()=default;
|
||||
|
||||
/*! \brief if the graph plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
|
||||
|
||||
\note If you want to draw outside, then you'll also have to implement drawOutside()
|
||||
*/
|
||||
virtual void cbGetOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace) override;
|
||||
|
||||
/*! \brief plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
|
||||
|
||||
\note If you want to draw outside, then you'll also have to implement getOutsideSize(), so enough space is reserved
|
||||
|
||||
The four value supplied tell the method where to draw (inside one of the rectangles).
|
||||
*/
|
||||
virtual void cbDrawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) override;
|
||||
|
||||
|
||||
/** \brief set the parent class for internal objects (e.g. color bars) */
|
||||
virtual void cbSetParent(JKQTBasePlotter* parent) override;
|
||||
|
||||
|
||||
/** \brief determine min/max data value of the modifier image */
|
||||
virtual void cbGetModifierDataMinMax(double& imin, double& imax)=0;
|
||||
|
||||
|
||||
/*! \copydoc modifierMode */
|
||||
void setModifierMode(const JKQTPMathImageModifierMode & __value);
|
||||
/*! \copydoc modifierMode */
|
||||
JKQTPMathImageModifierMode getModifierMode() const;
|
||||
|
||||
/*! \copydoc colorBarModifiedWidth */
|
||||
void setColorBarModifiedWidth(double __value);
|
||||
/*! \copydoc colorBarModifiedWidth */
|
||||
double getColorBarModifiedWidth() const;
|
||||
/*! \copydoc modifierColorBarTopAxis */
|
||||
JKQTPVerticalIndependentAxis* getModifierColorBarTopAxis();
|
||||
/*! \copydoc modifierColorBarRightAxis */
|
||||
JKQTPHorizontalIndependentAxis* getModifierColorBarRightAxis();
|
||||
/*! \copydoc modifierColorBarTopAxis */
|
||||
const JKQTPVerticalIndependentAxis* getModifierColorBarTopAxis() const;
|
||||
/*! \copydoc modifierColorBarRightAxis */
|
||||
const JKQTPHorizontalIndependentAxis *getModifierColorBarRightAxis() const;
|
||||
/*! \copydoc autoModifierRange */
|
||||
void setAutoModifierRange(bool __value);
|
||||
/*! \copydoc autoModifierRange */
|
||||
bool getAutoModifierRange() const;
|
||||
/*! \copydoc modifierMin */
|
||||
void setModifierMin(double __value);
|
||||
/*! \copydoc modifierMin */
|
||||
double getModifierMin() const;
|
||||
/*! \copydoc modifierMax */
|
||||
void setModifierMax(double __value);
|
||||
/*! \copydoc modifierMax */
|
||||
double getModifierMax() const;
|
||||
|
||||
|
||||
/** \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);
|
||||
|
||||
protected:
|
||||
|
||||
/** \brief indicates whether to estimate min/max of the modifier automatically */
|
||||
bool autoModifierRange;
|
||||
/** \brief modifier value range minimum */
|
||||
double modifierMin;
|
||||
/** \brief modifier value range maximum */
|
||||
double modifierMax;
|
||||
/** \brief width of the color bar when modifier is on */
|
||||
double colorBarModifiedWidth;
|
||||
/** \brief how to apply the modifier column dataModifier
|
||||
* \see ModifierMode
|
||||
*/
|
||||
JKQTPMathImageModifierMode modifierMode;
|
||||
|
||||
|
||||
/** \brief object used for color bar axes (right border, modifier image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPVerticalIndependentAxis* modifierColorBarTopAxis;
|
||||
/** \brief object used for color bar axes (top border, modifier image data)
|
||||
*
|
||||
* \note this axis has some kind of a special role. It is used to format color bar axes
|
||||
*/
|
||||
JKQTPHorizontalIndependentAxis* modifierColorBarRightAxis;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPIMAGETOOLS_H
|
||||
|
Loading…
Reference in New Issue
Block a user