/* Copyright (c) 2008-2019 Jan W. Krieger () This software is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License (LGPL) for more details. You should have received a copy of the GNU Lesser General Public License (LGPL) along with this program. If not, see . */ #include "jkqtplottertools/jkqtpimagetools.h" #include #include #include #include #ifndef NO_JKQTPLOTTER #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtpbaseplotter.h" #include "jkqtplottertools/jkqtpdrawingtools.h" #endif #ifdef QT_XML_LIB # include #endif const int JKQTPImageTools::PALETTE_ICON_WIDTH = 64; const int JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT = 64; const int JKQTPImageTools::LUTSIZE = 256; QList global_jkqtpimagetools_lutstore = QList(); bool JKQTPImagePlot_buildDefinedPaletteLessThan(const QPair &s1, const QPair &s2) { return s1.first > items, int lut_size) { qSort(items.begin(), items.end(), JKQTPImagePlot_buildDefinedPaletteLessThan); double dmin=items.first().first; double dmax=items.last().first; double delta=(dmax-dmin)/double(lut_size); int i=0; int j=0; for (double v=dmin; v<=dmax; v=v+delta) { double r=0; double g=0; double b=0; if (j+1=items[j+1].first) j++; } else { r=double(qRed(items.last().second)); g=double(qGreen(items.last().second)); b=double(qBlue(items.last().second)); } if (i<=lut_size) lut[i]=qRgb(static_cast(r), static_cast(g), static_cast(b)); i++; } } void JKQTPImagePlot_buildDefinedPaletteLinInterpolate(int* lut, int N, ...) { QList > items; va_list args; va_start(args, N); for (int i=0; i > items) { qSort(items.begin(), items.end(), JKQTPImagePlot_buildDefinedPaletteLessThan); double dmin=items.first().first; double dmax=items.last().first; double delta=(dmax-dmin)/double(JKQTPImageTools::LUTSIZE); int i=0; int j=0; for (double v=dmin; v<=dmax; v=v+delta) { double r=0; double g=0; double b=0; if (j+1=items[j+1].first) j++; } if (i<=JKQTPImageTools::LUTSIZE) lut[i]=qRgb(static_cast(r), static_cast(g), static_cast(b)); i++; } } void JKQTPImagePlot_buildDefinedPalette(int* lut, int N, ...) { QList > items; va_list args; va_start(args, N); for (int i=0; i > > JKQTPImagePlot_lutsFromFiles; template bool JKQTPImagePlot_QPairCompareFirst(const QPair &s1, const QPair &s2) { return s1.first < s2.first; } QStringList JKQTPImagePlot_getPredefinedPalettes() { static QStringList sl; if (JKQTPImagePlot_palettesSearchPaths.isEmpty()) { JKQTPImagePlot_palettesSearchPaths<<":/colorpalettes/"; JKQTPImagePlot_palettesSearchPaths<<(QApplication::applicationDirPath()+"/colorpalettes/"); JKQTPImagePlot_palettesSearchPaths<<(QApplication::applicationDirPath()+"/assets/colorpalettes/"); } if (sl.size()<=0) { sl< > pal; QRegExp rx3("\\s*([0-9eE.+-]+)\\s*([,\\t ])\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*", Qt::CaseInsensitive); rx3.setMinimal(false); QRegExp rx4("\\s*([0-9eE.+-]+)\\s*([,\\t ])\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*", Qt::CaseInsensitive); rx4.setMinimal(false); // determine format for (int i=slt.size()-1; i>=0; i--) { slt[i]=slt[i].trimmed(); if (rx4.indexIn(slt[i])>=0) { has4=true; double r=JKQTPImagePlot_QStringToDouble(rx4.cap(3)); double g=JKQTPImagePlot_QStringToDouble(rx4.cap(4)); double b=JKQTPImagePlot_QStringToDouble(rx4.cap(5)); if (r>1.0 || g>1.0 || b>1.0) { rgb255=true; } } else if (rx3.indexIn(slt[i])>=0) { has4=false; double r=JKQTPImagePlot_QStringToDouble(rx3.cap(1)); double g=JKQTPImagePlot_QStringToDouble(rx3.cap(3)); double b=JKQTPImagePlot_QStringToDouble(rx3.cap(4)); if (r>1.0 || g>1.0 || b>1.0) { rgb255=true; } } else { slt.removeAt(i); } } // read data bool ok=true; for (int i=0; i=0) { x=JKQTPImagePlot_QStringToDouble(rx4.cap(1)); r=JKQTPImagePlot_QStringToDouble(rx4.cap(3)); g=JKQTPImagePlot_QStringToDouble(rx4.cap(4)); b=JKQTPImagePlot_QStringToDouble(rx4.cap(5)); } else if (!has4 && rx3.indexIn(slt[i])>=0) { x=i; r=JKQTPImagePlot_QStringToDouble(rx3.cap(1)); g=JKQTPImagePlot_QStringToDouble(rx3.cap(3)); b=JKQTPImagePlot_QStringToDouble(rx3.cap(4)); //qDebug()<(round(255*r)), 255), qBound(0,static_cast(round(255*g)), 255), qBound(0,static_cast(round(255*b)), 255))); } else { pal<(round(r)), 255), qBound(0,static_cast(round(g)), 255), qBound(0,static_cast(round(b)), 255))); } } } //qDebug()<<"read: "< > pal; if (colorspace=="rgb"){ QDomElement e = n.firstChildElement("Point"); while(!e.isNull()) { double x=JKQTPImagePlot_QStringToDouble(e.attribute("x", "0")); //double o=JKQTPImagePlot_QStringToDouble(e.attribute("o", "0")); double r=JKQTPImagePlot_QStringToDouble(e.attribute("r", "0")); double g=JKQTPImagePlot_QStringToDouble(e.attribute("g", "0")); double b=JKQTPImagePlot_QStringToDouble(e.attribute("b", "0")); pal<(round(255*r)), 255), qBound(0,static_cast(round(255*g)), 255), qBound(0,static_cast(round(255*b)), 255))); e = e.nextSiblingElement("Point"); } if (pal.size()>1) { sl<); JKQTPImagePlot_lutsFromFiles[sl.size()-1]=pal; palID=sl.size(); //qDebug()<<"read "< &lutstore) { QList ls=lutstore; lutstore.clear(); for (int i=0; i& lutstore, JKQTPMathImageColorPalette palette) { int* lut_used=nullptr; if (palette == JKQTPMathImageRED) { //int*& plut=lutstore[palette]; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(static_cast(255.0*v), 0, 0); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGREEN) { //int*& plut=&lut_green; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(0, static_cast(255.0*v), 0); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUE) { //int*& plut=&lut_blue; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(0, 0, static_cast(255.0*v)); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGRAY) { //int*& plut=&lut_gray; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(static_cast(255.0*v), static_cast(255.0*v), static_cast(255.0*v)); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageALPHA) { //int*& plut=&lut_gray; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgba(255,255,255, static_cast(255.0*v)); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_ALPHA) { //int*& plut=&lut_gray; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgba(255,255,255, static_cast(255.0*v)); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDRED) { //int*& plut=&lut_invred; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(static_cast(255.0*(1.0-v)), 0, 0); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDGREEN) { //int*& plut=&lut_invgreen; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(0, static_cast(255.0*(1.0-v)), 0); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDBLUE) { //int*& plut=&lut_invblue; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=qRgb(0, 0, static_cast(255.0*(1.0-v))); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDGRAY) { //int*& plut=&lut_invgray; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=1.0-(l/static_cast(JKQTPImageTools::LUTSIZE)); plut[l]=qRgb(static_cast(255.0*v), static_cast(255.0*v), static_cast(255.0*v)); } plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageMATLAB) { //int*& plut=&lut_matlab; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = 382.5 - 1020.0 * std::abs(v - 0.75); if (r > 255.0) r = 255.0; else if (r < 0.0) r = 0.0; double g = 382.5 - 1020.0 * std::abs(v - 0.5); if (g > 255.0) g = 255.0; else if (g < 0.0) g = 0.0; double b = 382.5 - 1020.0 * std::abs(v - 0.25); if (b > 255.0) b = 255.0; else if (b < 0.0) b = 0.0; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_MATLAB) { //int*& plut=&lut_matlab_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 382.5 - 1020.0 * std::abs(v - 0.75); if (r > 255.0) r = 255.0; else if (r < 0.0) r = 0.0; double g = 382.5 - 1020.0 * std::abs(v - 0.5); if (g > 255.0) g = 255.0; else if (g < 0.0) g = 0.0; double b = 382.5 - 1020.0 * std::abs(v - 0.25); if (b > 255.0) b = 255.0; else if (b < 0.0) b = 0.0; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageRYGB) //gnuplot: 30,-13,-23 { //int*& plut=&lut_rygb; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = 796.875*v - 199.21875; if (r > 255.0) r = 255.0; else if (r < 0.0) r = 0.0; double g = 255.0 * std::sin(M_PI*v); double b = 255.0 - 765.0 * v; if (b < 0.0) b = 0.0; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_RYGB) //gnuplot: 30,-13,-23 { //int*& plut=&lut_rygb_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 796.875*v - 199.21875; if (r > 255.0) r = 255.0; else if (r < 0.0) r = 0.0; double g = 255.0 * std::sin(M_PI*v); double b = 255.0 - 765.0 * v; if (b < 0.0) b = 0.0; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageHSV) { //int*& plut=&lut_hsv; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); int h = static_cast(floor(6*v)); double f = 6*v-double(h); switch (h) { case 0: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; case 1: plut[l]=qRgb(static_cast(255.0*(1-f)), 255, 0); break; case 2: plut[l]=qRgb(0, 255, static_cast(255.0*f)); break; case 3: plut[l]=qRgb(0, static_cast(255.0*(1-f)), 255); break; case 4: plut[l]=qRgb(static_cast(255.0*f), 0, 255); break; case 5: plut[l]=qRgb(255, 0, static_cast(255.0*(1-f))); break; case 6: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; } } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_HSV) { //int*& plut=&lut_invhsv; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); int h = static_cast(floor(6.0-6.0*v)); double f = 6.0-6.0*v-double(h); switch (h) { case 0: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; case 1: plut[l]=qRgb(static_cast(255.0*(1-f)), 255, 0); break; case 2: plut[l]=qRgb(0, 255, static_cast(255.0*f)); break; case 3: plut[l]=qRgb(0, static_cast(255.0*(1-f)), 255); break; case 4: plut[l]=qRgb(static_cast(255.0*f), 0, 255); break; case 5: plut[l]=qRgb(255, 0, static_cast(255.0*(1-f))); break; case 6: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; } } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageRAINBOW) //gnuplot: 33,13,10 { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*std::abs(2.0*v-0.5); if (r > 255.0) r = 255.0; double g = 255.0*sin(M_PI*v); double b = 255.0*cos(0.5*M_PI*v); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_RAINBOW) //gnuplot: 33,13,10 { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*std::abs(2.0*v-0.5); if (r > 255.0) r = 255.0; double g = 255.0*sin(M_PI*v); double b = 255.0*cos(0.5*M_PI*v); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageHOT) //gnuplot: 21,22,23 { //int*& plut=&lut_hot; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = 765.0*v; if (r > 255.0) r = 255.0; double g = 765.0*v-255.0; if (g > 255.0) g = 255.0; else if (g < 0.0) g = 0.0; double b = 765.0*v-510.0; if (b < 0.0) b = 0.0; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_HOT) //gnuplot: 21,22,23 { //int*& plut=&lut_hot_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 765.0*v; if (r > 255.0) r = 255.0; double g = 765.0*v-255.0; if (g > 255.0) g = 255.0; else if (g < 0.0) g = 0.0; double b = 765.0*v-510.0; if (b < 0.0) b = 0.0; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageOCEAN) //gnuplot: 23,28,3 { //int*& plut=&lut_ocean; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = 765.0*v-510.0; if (r < 0.0) r = 0.0; double g = std::abs(382.5*v-127.5); double b = 255.0*v; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_OCEAN) //gnuplot: 23,28,3 { //int*& plut=&lut_ocean_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 765.0*v-510.0; if (r < 0.0) r = 0.0; double g = std::abs(382.5*v-127.5); double b = 255.0*v; plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUEMAGENTAYELLOW) //gnuplot: 30,31,32 { //int*& plut=&lut_bluemagentayellow; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = (v/0.32-0.78125); if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; double g = 2.0*v-0.84; if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; double b = 4.0*v; if (b>1 || b<0) b = -2.0*v+1.84; if (b>1 || b<0) b = v/0.08-11.5; if (b>1 || b<0) b=1; if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW) //gnuplot: 30,31,32 { //int*& plut=&lut_bluemagentayellow_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = (v/0.32-0.78125); if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; double g = 2.0*v-0.84; if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; double b = 4.0*v; if (b>1 || b<0) b = -2.0*v+1.84; if (b>1 || b<0) b = v/0.08-11.5; if (b>1 || b<0) b=1; if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUEYELLOW) //gnuplot: 8,9,10 { //int*& plut=&lut_blueyellow; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = sqrt(sqrt(v)); if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; double g = sin(M_PI/2.0*v); if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; double b = cos(M_PI/2.0*v); if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_BLUEYELLOW) //gnuplot: 8,9,10 { //int*& plut=&lut_blueyellow_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = sqrt(sqrt(v)); if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; double g = sin(M_PI/2.0*v); if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; double b = cos(M_PI/2.0*v); if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageCYAN) { //int*& plut=&lut_cyan; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = v*0.5; if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; double g = v; if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; double b = v; if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_CYAN) { //int*& plut=&lut_cyan_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = v*0.5; if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; double g = v; if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; double b = v; if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageTRAFFICLIGHT) { //int*& plut=&lut_trafficlight; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=l/static_cast(JKQTPImageTools::LUTSIZE); double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; if (r > 255.0) r = 255.0; double g = (v < 0.5) ? 512.0*v+128.0 : 512.0-512.0*v; if (g > 255.0) g = 255.0; plut[l]=qRgb(static_cast(r), static_cast(g), 0); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_TRAFFICLIGHT) { //int*& plut=&lut_trafficlight_inverted; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; if (r > 255.0) r = 255.0; double g = (v < 0.5) ? 512.0*v+128.0 : 512.0-512.0*v; if (g > 255.0) g = 255.0; plut[l]=qRgb(static_cast(r), static_cast(g), 0); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUEWHITERED) //gnuplot: 34,13,-34 { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(8.0, 0xFFB2182B); lst<(7.0, 0xFFD6604D); lst<(6.0, 0xFFF4A582); lst<(5.0, 0xFFFDDBC7); lst<(4.0, 0xFFD1E5F0); lst<(3.0, 0xFF92C5DE); lst<(2.0, 0xFF4393C3); lst<(1.0, 0xFF2166AC); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageREDWHITEBLUE) //gnuplot: https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/RdBu.plt { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFB2182B); lst<(1.0, 0xFFD6604D); lst<(2.0, 0xFFF4A582); lst<(3.0, 0xFFFDDBC7); lst<(4.0, 0xFFD1E5F0); lst<(5.0, 0xFF92C5DE); lst<(6.0, 0xFF4393C3); lst<(7.0, 0xFF2166AC); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLACKBLUEREDYELLOW) //gnuplot: 7,5,15 { // int*& plut=&lut_BLACKBLUEREDYELLOW; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*qBound(0.0,sqrt(v),1.0); double g = 255.0*qBound(0.0,v*v*v,1.0); double b = 255.0*qBound(0.0,sin(2.0*M_PI*v),1.0); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGREENREDVIOLET) //gnuplot: 3,11,6 { //int*& plut=&lut_GREENREDVIOLET; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*qBound(0.0,v,1.0); double g = 255.0*qBound(0.0,fabs(v-0.5),1.0); double b = 255.0*qBound(0.0,v*v*v*v,1.0); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLACKBLUEWHITEYELLOWWHITE) //gnuplot: 30,31,32 { //int*& plut=&lut_BLACKBLUEVIOLETYELLOWWHITE; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*qBound(0.0,v/0.32-0.78125,1.0); double g = 255.0*qBound(0.0,v/0.32-0.78125,1.0); double b = 255.0*qBound(0.0,(v<0.25)?4*v:(v<0.42)?1.0:(v<0.92)?-2.0*v+1.84:v/0.08-11.5,1.0); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageWHITEYELLOWWHITEBLUEBLACK) //gnuplot: 30,31,32 { //int*& plut=&lut_WHITEYELLOWVIOLETBLUEBLACK; if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); double r = 255.0*qBound(0.0,v/0.32-0.78125,1.0); double g = 255.0*qBound(0.0,v/0.32-0.78125,1.0); double b = 255.0*qBound(0.0,(v<0.25)?4*v:(v<0.42)?1.0:(v<0.92)?-2.0*v+1.84:v/0.08-11.5,1.0); plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBR_GR) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/BrBG.plt { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, qRgb(0x8C, 0x51, 0x0A)); lst<(1.0, qRgb(0xBF, 0x81, 0x2D)); lst<(2.0, qRgb(0xDF, 0xC2, 0x7D)); lst<(3.0, 0xFFF6E8C3); lst<(4.0, 0xFFC7EAE5); lst<(5.0, 0xFF80CDC1); lst<(6.0, 0xFF35978F); lst<(7.0, 0xFF01665E); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBR_GR_STEP) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/BrBG.plt { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, qRgb(0x8C, 0x51, 0x0A)); lst<(1.0, qRgb(0xBF, 0x81, 0x2D)); lst<(2.0, qRgb(0xDF, 0xC2, 0x7D)); lst<(3.0, 0xFFF6E8C3); lst<(4.0, 0xFFC7EAE5); lst<(5.0, 0xFF80CDC1); lst<(6.0, 0xFF35978F); lst<(7.0, 0xFF01665E); JKQTPImagePlot_buildDefinedPalette(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePU_OR) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/PuOr.plt { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFB35806); lst<(1.0, 0xFFE08214); lst<(2.0, 0xFFFDB863); lst<(3.0, 0xFFFEE0B6); lst<(4.0, 0xFFF7F7F7); lst<(5.0, 0xFFD8DAEB); lst<(6.0, 0xFFB2ABD2); lst<(7.0, 0xFF8073AC); lst<(8.0, 0xFF542788); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePU_OR_STEP) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/PuOr.plt { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFB35806); lst<(1.0, 0xFFE08214); lst<(2.0, 0xFFFDB863); lst<(3.0, 0xFFFEE0B6); lst<(4.0, 0xFFF7F7F7); lst<(5.0, 0xFFD8DAEB); lst<(6.0, 0xFFB2ABD2); lst<(7.0, 0xFF8073AC); lst<(8.0, 0xFF542788); JKQTPImagePlot_buildDefinedPalette(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYL_GN_BU) //http://colorbrewer2.org/ { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFFFFFD9); lst<(1.0, 0xFFEDF8B1); lst<(2.0, 0xFFC7E9B4); lst<(3.0, 0xFF7FCDBB); lst<(4.0, 0xFF41B6C4); lst<(5.0, 0xFF1D91C0); lst<(6.0, 0xFF225EA8); lst<(7.0, 0xFF253494); lst<(8.0, 0xFF081D58); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYL_GN_BU_STEP) //http://colorbrewer2.org/ { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFFFFFD9); lst<(1.0, 0xFFEDF8B1); lst<(2.0, 0xFFC7E9B4); lst<(3.0, 0xFF7FCDBB); lst<(4.0, 0xFF41B6C4); lst<(5.0, 0xFF1D91C0); lst<(6.0, 0xFF225EA8); lst<(7.0, 0xFF253494); lst<(8.0, 0xFF081D58); JKQTPImagePlot_buildDefinedPalette(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGN_BU) //http://colorbrewer2.org/ { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFF7FCF0); lst<(1.0, 0xFFE0F3DB); lst<(2.0, 0xFFCCEBC5); lst<(3.0, 0xFFA8DDB5); lst<(4.0, 0xFF7BCCC4); lst<(5.0, 0xFF4EB3D3); lst<(6.0, 0xFF2B8CBE); lst<(7.0, 0xFF0868AC); lst<(8.0, 0xFF084081); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGN_BU_STEP) //http://colorbrewer2.org/ { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFFF7FCF0); lst<(1.0, 0xFFE0F3DB); lst<(2.0, 0xFFCCEBC5); lst<(3.0, 0xFFA8DDB5); lst<(4.0, 0xFF7BCCC4); lst<(5.0, 0xFF4EB3D3); lst<(6.0, 0xFF2B8CBE); lst<(7.0, 0xFF0868AC); lst<(8.0, 0xFF084081); JKQTPImagePlot_buildDefinedPalette(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBU_GN) //http://colorbrewer2.org/ { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(8.0, 0xFFF7FCF0); lst<(7.0, 0xFFE0F3DB); lst<(6.0, 0xFFCCEBC5); lst<(5.0, 0xFFA8DDB5); lst<(4.0, 0xFF7BCCC4); lst<(3.0, 0xFF4EB3D3); lst<(2.0, 0xFF2B8CBE); lst<(1.0, 0xFF0868AC); lst<(0.0, 0xFF084081); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBU_GN_STEP) //http://colorbrewer2.org/ { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(8.0, 0xFFF7FCF0); lst<(7.0, 0xFFE0F3DB); lst<(6.0, 0xFFCCEBC5); lst<(5.0, 0xFFA8DDB5); lst<(4.0, 0xFF7BCCC4); lst<(3.0, 0xFF4EB3D3); lst<(2.0, 0xFF2B8CBE); lst<(1.0, 0xFF0868AC); lst<(0.0, 0xFF084081); JKQTPImagePlot_buildDefinedPalette(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_MAGENTA) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,1,0,v).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageMAGENTA) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,1,0,v).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_YELLOW) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,0,1,v).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYELLOW) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,0,1,v).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_MAGENTAWHITE) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,v,0,0).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageMAGENTAWHITE) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,v,0,0).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_YELLOWWHITE) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,0,v,0).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYELLOWWHITE) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(0,0,v,0).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_CYANWHITE) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(v,0,0,0).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageCYANWHITE) // from CMYK model { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); plut[l]=QColor::fromCmykF(v,0,0,0).rgba(); } } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBlueGreenRed) { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(1.0, QColor("blue").rgb()); lst<(2.0, QColor("green").rgb()); lst<(3.0, QColor("red").rgb()); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageRedGreenBlue) { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(1.0, QColor("red").rgb()); lst<(2.0, QColor("green").rgb()); lst<(3.0, QColor("blue").rgb()); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT) { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(1.0, QColor("magenta").rgb()); lst<(2.0, QColor("yellow").rgb()); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT+1) { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(1.0, QColor("yellow").rgb()); lst<(2.0, QColor("magenta").rgb()); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT+2) { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(1.0, QColor("red").rgb()); lst<(2.0, QColor("blue").rgb()); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT+3) { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(1.0, QColor("blue").rgb()); lst<(2.0, QColor("red").rgb()); JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); } } lut_used=lutstore[palette]; /* } else if (palette == JKQTPMathImagePU_OR) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/PuOr.plt { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { QList > lst; lst<(0.0, 0xFF); lst<(1.0, 0xFF); lst<(2.0, 0xFF); lst<(3.0, 0xFF); lst<(4.0, 0xFF); lst<(5.0, 0xFF); lst<(6.0, 0xFF); lst<(7.0, 0xFF); lst<(8.0, 0xFF); JKQTPImagePlot_buildDefinedPalette(plut, lst); } } lut_used=lutstore[palette]; */ } else if (JKQTPImagePlot_lutsFromFiles.contains(palette)) // LUTs read from files in JKQTPImagePlot_lutsFromFiles { if (lutstore[palette]==nullptr) { lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); int* plut=lutstore[palette]; //std::cout<<"!!! creating rainbow lut\n"; if (plut!=nullptr) { if (JKQTPImagePlot_lutsFromFiles[palette].size()>220) JKQTPImagePlot_buildDefinedPalette(plut, JKQTPImagePlot_lutsFromFiles[palette]); else JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, JKQTPImagePlot_lutsFromFiles[palette]); } } lut_used=lutstore[palette]; } return lut_used; } QImage JKQTPMathImageGetPaletteImage(int i, int width) { return JKQTPMathImageGetPaletteImage(i, width, 1); } QImage JKQTPMathImageGetPaletteImage(int i, int width, int height) { QImage img; double* pic=static_cast(malloc(width*height*sizeof(double))); for (int j=0; j(pic, width, height, img, (JKQTPMathImageColorPalette)i, Qt::black, Qt::black); free(pic); return img; } QImage JKQTPMathImageGetPaletteImage(JKQTPMathImageColorPalette palette, int width) { return JKQTPMathImageGetPaletteImage(static_cast(palette), width); } QImage JKQTPMathImageGetPaletteImage(JKQTPMathImageColorPalette palette, int width, int height) { return JKQTPMathImageGetPaletteImage(static_cast(palette), width, height); } QImage JKQTPMathImageGetPaletteImage(int *lut, int lut_size, int width) { QImage img; double* pic=static_cast(malloc(width*sizeof(double))); for (int j=0; j(pic, width, 1, img, lut, lut_size, Qt::black, Qt::black); free(pic); return img; } QIcon JKQTPMathImageGetPaletteIcon(int i) { QImage img=JKQTPMathImageGetPaletteImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH); QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,8); QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,7); QPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); p.drawRect(r); p.end(); return QIcon(pix); } QIcon JKQTPMathImageGetPaletteIcon(JKQTPMathImageColorPalette palette) { return JKQTPMathImageGetPaletteIcon(static_cast(palette)); } QImage JKQTPMathImageGetAlphaPaletteImage(int *lut, int lut_size, int width, int height) { QImage img; if (!lut || lut_size<=0 || width<=0 || height<=0) return img; double* pic=static_cast(malloc(width*sizeof(double))); for (int j=0; j l1(lut_size, QColor("white").rgba()); for (int i=0; i(pic, width, 1, img, l1.data(), lut_size, Qt::black, Qt::black); free(pic); QImage img2(width, height, QImage::Format_ARGB32); QPainter p(&img2); QBrush b; b.setStyle(Qt::TexturePattern); b.setTextureImage(img1); p.setBrush(b); p.fillRect(QRect(0,0,width,height), b); p.drawImage(QRect(0,0,width,height), img); p.end(); return img2; } #ifndef NO_JKQTPLOTTER JKQTPColorPaletteTools::JKQTPColorPaletteTools(JKQTBasePlotter *parent) { cbParent=parent; colorBarRightAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); colorBarRightAxis->setDrawMode1(JKQTPCADMLine); colorBarRightAxis->setDrawMode2(JKQTPCADMcomplete); colorBarRightAxis->setAxisLabel(""); colorBarRightAxis->setMinTicks(3); colorBarRightAxis->setShowZeroAxis(false); colorBarRightAxis->setMinorTicks(0); colorBarRightAxis->setTickOutsideLength(0); colorBarRightAxis->setMinorTickOutsideLength(0); colorBarTopAxis=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); colorBarTopAxis->setDrawMode1(JKQTPCADMLine); colorBarTopAxis->setDrawMode2(JKQTPCADMcomplete); colorBarTopAxis->setAxisLabel(""); colorBarTopAxis->setMinTicks(3); colorBarTopAxis->setShowZeroAxis(false); colorBarTopAxis->setMinorTicks(0); colorBarTopAxis->setTickOutsideLength(0); colorBarTopAxis->setMinorTickOutsideLength(0); this->palette=JKQTPMathImageMATLAB; this->imageNameFontName=parent->getDefaultTextFontName(); this->imageNameFontSize=parent->getDefaultTextSize(); this->imageName=""; this->showColorBar=true; this->colorBarWidth=14; this->colorBarRelativeHeight=0.75; this->autoImageRange=true; this->imageMin=0; this->imageMax=1; this->colorBarOffset=4; this->rangeMinFailAction=JKQTPMathImageLastPaletteColor; this->rangeMaxFailAction=JKQTPMathImageLastPaletteColor; this->rangeMinFailColor=QColor("black"); this->rangeMaxFailColor=QColor("black"); this->nanColor=QColor("black"); this->infColor=QColor("black"); this->colorBarTopVisible=false; this->colorBarRightVisible=true; if (parent) this->palette=parent->getCurrentPlotterStyle().defaultPalette; } JKQTPColorPaletteTools::~JKQTPColorPaletteTools() = default; void JKQTPColorPaletteTools::cbGetOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace) { Q_UNUSED(leftSpace); Q_UNUSED(bottomSpace); if (showColorBar) { double internalDataMin=getInternalDataMin(); double internalDataMax=getInternalDataMax(); cbGetDataMinMax(internalDataMin, internalDataMax); if (colorBarRightVisible) { rightSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset); colorBarRightAxis->setRange(internalDataMin, internalDataMax); colorBarRightAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotHeight()); QSizeF s1=colorBarRightAxis->getSize2(painter); QSizeF s2=colorBarRightAxis->getSize1(painter); QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); rightSpace+=qMax(static_cast(s1.width()+s2.width()), static_cast(names.width())); } if (colorBarTopVisible) { //topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset); colorBarTopAxis->setRange(internalDataMin, internalDataMax); colorBarTopAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotWidth()); 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(s1.height()+s2.height()), static_cast(names.height())); } } } void JKQTPColorPaletteTools::cbDrawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) { Q_UNUSED(leftSpace); Q_UNUSED(bottomSpace); if (showColorBar) { double internalDataMin=getInternalDataMin(); double internalDataMax=getInternalDataMax(); cbGetDataMinMax(internalDataMin, internalDataMax); if (colorBarRightVisible) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); 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 (int j=0; j(d, h, 200, b, palette, 0, 199); QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); double icolorBarRelativeHeight=colorBarRelativeHeight; int barHeight=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)/2pt2px(painter, colorBarOffset), rightSpace.top()+(rightSpace.height()-barHeight)/2, cbParent->pt2px(painter, colorBarWidth), barHeight); painter.drawImage(cb, b.mirrored(true, false)); QPen p=painter.pen(); p.setColor(colorBarRightAxis->getAxisColor()); p.setWidthF(qMax(JKQTPlotterDrawinTools::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); cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); cbParent->getMathText()->setFontRomanOrSpecial(imageNameFontName); 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();}); 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 (int j=0; j(d,h,200, b, palette, 0, 199); 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)/2pt2px(painter, colorBarOffset+(colorBarWidth)), barWidth, cbParent->pt2px(painter, colorBarWidth)); //qDebug()<<"t: "<getAxisColor()); p.setWidthF(qMax(JKQTPlotterDrawinTools::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); cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); cbParent->getMathText()->setFontRomanOrSpecial(imageNameFontName); 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())); } } } QStringList JKQTPColorPaletteTools::getPalettes() { return JKQTPImagePlot_getPredefinedPalettes(); } int JKQTPColorPaletteTools::getPalettesCount() { return getPalettes().size(); } QIcon JKQTPColorPaletteTools::getPaletteIcon(int i) { QImage img=getPaletteImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH); QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,8); QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,7); QPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); p.drawRect(r); p.end(); return QIcon(pix); } QIcon JKQTPColorPaletteTools::getPaletteIcon(JKQTPMathImageColorPalette palette) { return getPaletteIcon(static_cast(palette)); } QImage JKQTPColorPaletteTools::getPaletteImage(int i, int width) { QImage img; double* pic=static_cast(malloc(width*sizeof(double))); for (int j=0; j(pic, width, 1, img, (JKQTPMathImageColorPalette)i, 0, width-1); free(pic); return img; } QImage JKQTPColorPaletteTools::getPaletteImage(JKQTPMathImageColorPalette palette, int width) { return getPaletteImage(static_cast(palette), width); } QIcon JKQTPColorPaletteTools::getPaletteKeyIcon(int i) { QImage img=getPaletteKeyImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH, 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); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); p.drawRect(r); p.end(); return QIcon(pix); } QIcon JKQTPColorPaletteTools::getPaletteKeyIcon(JKQTPMathImageColorPalette palette) { return getPaletteIcon(static_cast(palette)); } QImage JKQTPColorPaletteTools::getPaletteKeyImage(int i, int width, int height) { QImage img; const double x01=double(width)/3.0; const double y01=double(height)/3.0*2.0; const double w1x=double(width*width)/(5.0*5.0); const double w1y=double(height*height)/(2.0*2.0); const double x02=double(width)/3.0*2.0; const double y02=double(height)/4.0; const double w2x=double(width*width)/(8.0*8.0); const double w2y=double(height*height)/(8.0*8.0); double* pic=static_cast(malloc(width*height*sizeof(double))); double mmax=0; for (int j=0; jmmax) mmax=pic[j]; } JKQTPImagePlot_array2image(pic, width, height, img, (JKQTPMathImageColorPalette)i, 0, mmax); free(pic); return img; } QImage JKQTPColorPaletteTools::getPaletteKeyImage(JKQTPMathImageColorPalette palette, int width, int height) { return getPaletteKeyImage(static_cast(palette), width, height); } void JKQTPColorPaletteTools::setPalette(int pal) { palette=(JKQTPMathImageColorPalette)pal; } void JKQTPColorPaletteTools::cbSetParent(JKQTBasePlotter* parent) { cbParent=parent; colorBarRightAxis->setParent(parent); colorBarTopAxis->setParent(parent); } double JKQTPColorPaletteTools::getInternalDataMin() const { return 0; } double JKQTPColorPaletteTools::getInternalDataMax() const { return 0; } #endif QString JKQTPMathImageColorPalette2String(JKQTPMathImageColorPalette p) { switch (p) { case JKQTPMathImageGRAY: return QString("gray"); case JKQTPMathImageINVERTEDGRAY: return QString("invgray"); case JKQTPMathImageRED: return QString("red"); case JKQTPMathImageINVERTEDRED: return QString("invred"); case JKQTPMathImageGREEN: return QString("green"); case JKQTPMathImageINVERTEDGREEN: return QString("invgreen"); case JKQTPMathImageBLUE: return QString("blue"); case JKQTPMathImageINVERTEDBLUE: return QString("invblue"); case JKQTPMathImageCYAN: return QString("cyan"); case JKQTPMathImageINVERTED_CYAN: return QString("invcyan"); case JKQTPMathImageYELLOW: return QString("yellow"); case JKQTPMathImageINVERTED_YELLOW: return QString("invyellow"); case JKQTPMathImageMAGENTA: return QString("magenta"); case JKQTPMathImageINVERTED_MAGENTA: return QString("invmagenta"); case JKQTPMathImageMATLAB: return QString("Matlab"); case JKQTPMathImageINVERTED_MATLAB: return QString("invMatlab"); case JKQTPMathImageRYGB: return QString("RYGB"); case JKQTPMathImageINVERTED_RYGB: return QString("invRYGB"); case JKQTPMathImageHSV: return QString("HSV"); case JKQTPMathImageINVERTED_HSV: return QString("invHSV"); case JKQTPMathImageRAINBOW: return QString("rainbow"); case JKQTPMathImageINVERTED_RAINBOW: return QString("invrainbow"); case JKQTPMathImageHOT: return QString("AFMhot"); case JKQTPMathImageINVERTED_HOT: return QString("invAFMhot"); case JKQTPMathImageOCEAN: return QString("ocean"); case JKQTPMathImageINVERTED_OCEAN: return QString("invocean"); case JKQTPMathImageTRAFFICLIGHT: return QString("trafficlight"); case JKQTPMathImageINVERTED_TRAFFICLIGHT: return QString("invtrafficlight"); case JKQTPMathImageBLUEMAGENTAYELLOW: return QString("BlMaYe"); case JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW: return QString("YeMaBl"); case JKQTPMathImageBLUEYELLOW: return QString("BlYe"); case JKQTPMathImageINVERTED_BLUEYELLOW: return QString("YeBl"); case JKQTPMathImageBLUEWHITERED: return QString("bluewhitered"); case JKQTPMathImageREDWHITEBLUE: return QString("redwhiteblue"); case JKQTPMathImageBLACKBLUEREDYELLOW: return QString("BBlRdYe"); case JKQTPMathImageGREENREDVIOLET: return QString("GnRdVi"); case JKQTPMathImageBLACKBLUEWHITEYELLOWWHITE: return QString("BWprint"); case JKQTPMathImageWHITEYELLOWWHITEBLUEBLACK: return QString("invBWprint"); case JKQTPMathImageBR_GR: return QString("BrBG"); case JKQTPMathImagePU_OR: return QString("PuOr"); case JKQTPMathImageGN_BU: return QString("greenblue"); case JKQTPMathImageBU_GN: return QString("bluegreen"); case JKQTPMathImageYL_GN_BU: return QString("YeGnBu"); case JKQTPMathImageBR_GR_STEP: return QString("stepsBrBG"); case JKQTPMathImagePU_OR_STEP: return QString("stepsPuOr"); case JKQTPMathImageGN_BU_STEP: return QString("stepsGnBl"); case JKQTPMathImageBU_GN_STEP: return QString("stepsBlGn"); case JKQTPMathImageYL_GN_BU_STEP: return QString("stepsYeGnBu"); case JKQTPMathImageCYANWHITE: return QString("cyanwhite"); case JKQTPMathImageINVERTED_CYANWHITE: return QString("whitecyan"); case JKQTPMathImageYELLOWWHITE: return QString("yellowwhite"); case JKQTPMathImageINVERTED_YELLOWWHITE: return QString("whiteyellow"); case JKQTPMathImageMAGENTAWHITE: return QString("magentawhite"); case JKQTPMathImageINVERTED_MAGENTAWHITE: return QString("whitemagenta"); case JKQTPMathImageBlueGreenRed: return QString("bluegreenred"); case JKQTPMathImageRedGreenBlue: return QString("redgreenblue"); case JKQTPMathImageALPHA: return QString("alpha"); case JKQTPMathImageINVERTED_ALPHA: return QString("invAlpha"); default: return QString::number(static_cast(p)); } } JKQTPMathImageColorPalette String2JKQTPMathImageColorPalette(const QString &p) { if (QString::compare(p, "gray", Qt::CaseInsensitive)==0) return JKQTPMathImageGRAY; if (QString::compare(p, "invgray", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDGRAY; if (QString::compare(p, "red", Qt::CaseInsensitive)==0) return JKQTPMathImageRED; if (QString::compare(p, "invred", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDRED; if (QString::compare(p, "green", Qt::CaseInsensitive)==0) return JKQTPMathImageGREEN; if (QString::compare(p, "invgreen", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDGREEN; if (QString::compare(p, "blue", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUE; if (QString::compare(p, "invblue", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDBLUE; if (QString::compare(p, "cyan", Qt::CaseInsensitive)==0) return JKQTPMathImageCYAN; if (QString::compare(p, "invcyan", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_CYAN; if (QString::compare(p, "yellow", Qt::CaseInsensitive)==0) return JKQTPMathImageYELLOW; if (QString::compare(p, "invyellow", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_YELLOW; if (QString::compare(p, "magenta", Qt::CaseInsensitive)==0) return JKQTPMathImageMAGENTA; if (QString::compare(p, "invmagenta", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_MAGENTA; if (QString::compare(p, "Matlab", Qt::CaseInsensitive)==0) return JKQTPMathImageMATLAB; if (QString::compare(p, "invMatlab", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_MATLAB; if (QString::compare(p, "RYGB", Qt::CaseInsensitive)==0) return JKQTPMathImageRYGB; if (QString::compare(p, "invRYGB", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_RYGB; if (QString::compare(p, "HSV", Qt::CaseInsensitive)==0) return JKQTPMathImageHSV; if (QString::compare(p, "invHSV", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_HSV; if (QString::compare(p, "rainbow", Qt::CaseInsensitive)==0) return JKQTPMathImageRAINBOW; if (QString::compare(p, "invrainbow", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_RAINBOW; if (QString::compare(p, "AFMhot", Qt::CaseInsensitive)==0) return JKQTPMathImageHOT; if (QString::compare(p, "invAFMhot", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_HOT; if (QString::compare(p, "ocean", Qt::CaseInsensitive)==0) return JKQTPMathImageOCEAN; if (QString::compare(p, "invocean", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_OCEAN; if (QString::compare(p, "trafficlight", Qt::CaseInsensitive)==0) return JKQTPMathImageTRAFFICLIGHT; if (QString::compare(p, "invtrafficlight", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_TRAFFICLIGHT; if (QString::compare(p, "BlMaYe", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUEMAGENTAYELLOW; if (QString::compare(p, "YeMaBl", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW; if (QString::compare(p, "BlYe", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUEYELLOW; if (QString::compare(p, "YeBl", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_BLUEYELLOW; if (QString::compare(p, "bluewhitered", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUEWHITERED; if (QString::compare(p, "redwhiteblue", Qt::CaseInsensitive)==0) return JKQTPMathImageREDWHITEBLUE; if (QString::compare(p, "BBlRdYe", Qt::CaseInsensitive)==0) return JKQTPMathImageBLACKBLUEREDYELLOW; if (QString::compare(p, "GnRdVi", Qt::CaseInsensitive)==0) return JKQTPMathImageGREENREDVIOLET; if (QString::compare(p, "BWprint", Qt::CaseInsensitive)==0) return JKQTPMathImageBLACKBLUEWHITEYELLOWWHITE; if (QString::compare(p, "invBWprint", Qt::CaseInsensitive)==0) return JKQTPMathImageWHITEYELLOWWHITEBLUEBLACK; if (QString::compare(p, "BrBG", Qt::CaseInsensitive)==0) return JKQTPMathImageBR_GR; if (QString::compare(p, "PuOr", Qt::CaseInsensitive)==0) return JKQTPMathImagePU_OR; if (QString::compare(p, "greenblue", Qt::CaseInsensitive)==0) return JKQTPMathImageGN_BU; if (QString::compare(p, "bluegreen", Qt::CaseInsensitive)==0) return JKQTPMathImageBU_GN; if (QString::compare(p, "YeGnBu", Qt::CaseInsensitive)==0) return JKQTPMathImageYL_GN_BU; if (QString::compare(p, "stepsBrBG", Qt::CaseInsensitive)==0) return JKQTPMathImageBR_GR_STEP; if (QString::compare(p, "stepsPuOr", Qt::CaseInsensitive)==0) return JKQTPMathImagePU_OR_STEP; if (QString::compare(p, "stepsGnBl", Qt::CaseInsensitive)==0) return JKQTPMathImageGN_BU_STEP; if (QString::compare(p, "stepsBlGn", Qt::CaseInsensitive)==0) return JKQTPMathImageBU_GN_STEP; if (QString::compare(p, "stepsYeGnBu", Qt::CaseInsensitive)==0) return JKQTPMathImageYL_GN_BU_STEP; if (QString::compare(p, "cyanwhite", Qt::CaseInsensitive)==0) return JKQTPMathImageCYANWHITE; if (QString::compare(p, "whitecyan", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_CYANWHITE; if (QString::compare(p, "yellowwhite", Qt::CaseInsensitive)==0) return JKQTPMathImageYELLOWWHITE; if (QString::compare(p, "whiteyellow", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_YELLOWWHITE; if (QString::compare(p, "magentawhite", Qt::CaseInsensitive)==0) return JKQTPMathImageMAGENTAWHITE; if (QString::compare(p, "whitemagenta", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_MAGENTAWHITE; if (QString::compare(p, "bluegreenred", Qt::CaseInsensitive)==0) return JKQTPMathImageBlueGreenRed; if (QString::compare(p, "redgreenblue", Qt::CaseInsensitive)==0) return JKQTPMathImageRedGreenBlue; if (QString::compare(p, "alpha", Qt::CaseInsensitive)==0) return JKQTPMathImageALPHA; if (QString::compare(p, "invAlpha", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_ALPHA; bool ok=false; JKQTPMathImageColorPalette res = static_cast(p.toInt(&ok)); if (!ok) return JKQTPMathImageMATLAB; else return res; }