diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f6f83f567..ab81edec6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -155,6 +155,7 @@ jobs: "libpixman-1-0.dll" \ "libpng16-16.dll" \ "librsvg-2-2.dll" \ + "libsharpyuv-0.dll" \ "libsigc-2.0-0.dll" \ "libstdc++-6.dll" \ "libsystre-0.dll" \ diff --git a/rtdata/languages/default b/rtdata/languages/default index 22038bee0..68fda352b 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1414,6 +1414,7 @@ HISTORY_MSG_FILMNEGATIVE_COLORSPACE;Film negative color space HISTORY_MSG_FILMNEGATIVE_ENABLED;Film Negative HISTORY_MSG_FILMNEGATIVE_REF_SPOT;FN - Reference input HISTORY_MSG_FILMNEGATIVE_VALUES;Film negative values +HISTORY_MSG_GAMUTMUNSEL;Gamut-Munsell HISTORY_MSG_HISTMATCHING;Auto-matched tone curve HISTORY_MSG_HLBL;Color propagation - blur HISTORY_MSG_ICL_LABGRIDCIEXY;Cie xy @@ -1421,6 +1422,7 @@ HISTORY_MSG_ICM_AINTENT;Abstract profile intent HISTORY_MSG_ICM_BLUX;Primaries Blue X HISTORY_MSG_ICM_BLUY;Primaries Blue Y HISTORY_MSG_ICM_FBW;Black and White +HISTORY_MSG_ICM_GAMUT;Gamut control HISTORY_MSG_ICM_GREX;Primaries Green X HISTORY_MSG_ICM_GREY;Primaries Green Y HISTORY_MSG_ICM_OUTPUT_PRIMARIES;Output - Primaries @@ -1440,6 +1442,7 @@ HISTORY_MSG_LOCALCONTRAST_DARKNESS;Local Contrast - Darkness HISTORY_MSG_LOCALCONTRAST_ENABLED;Local Contrast HISTORY_MSG_LOCALCONTRAST_LIGHTNESS;Local Contrast - Lightness HISTORY_MSG_LOCALCONTRAST_RADIUS;Local Contrast - Radius +HISTORY_MSG_LOCAL_GAMUTMUNSEL;Local - Gamut-Munsell HISTORY_MSG_METADATA_MODE;Metadata copy mode HISTORY_MSG_MICROCONTRAST_CONTRAST;Microcontrast - Contrast threshold HISTORY_MSG_PDSHARPEN_AUTO_CONTRAST;CS - Auto threshold @@ -2266,6 +2269,7 @@ TP_COLORAPP_TCMODE_LIGHTNESS;Lightness TP_COLORAPP_TCMODE_SATUR;Saturation TP_COLORAPP_TEMP2_TOOLTIP;Either symmetrical mode temp = White balance.\nEither select illuminant always set Tint=1.\n\nA temp=2856\nD41 temp=4100\nD50 temp=5003\nD55 temp=5503\nD60 temp=6000\nD65 temp=6504\nD75 temp=7504 TP_COLORAPP_TEMP_TOOLTIP;To select an illuminant, always set Tint=1.\n\nA temp=2856\nD41 temp=4100\nD50 temp=5003\nD55 temp=5503\nD60 temp=6000\nD65 temp=6504\nD75 temp=7504 +TP_COLORAPP_TEMPOUT_TOOLTIP;Temperature and Tint.\nDepending on the choices made previously, the selected temperature is:\nWhite balance\nA temp=2856\nD41 temp=4100\nD50 temp=5003\nD55 temp=5503\nD60 temp=6000\nD65 temp=6504\nD75 temp=7504\nFree. TP_COLORAPP_TONECIE;Use CIECAM for tone mapping TP_COLORAPP_TONECIE_TOOLTIP;If this option is disabled, tone mapping is done in L*a*b* space.\nIf this option is enabled, tone mapping is done using CIECAM02.\nThe Tone Mapping tool must be enabled for this setting to take effect. TP_COLORAPP_VIEWINGF_TOOLTIP;Takes into account the support on which the final image will be viewed (monitor, TV, projector, printer, etc.), as well as its environment. This process will take the data coming from process 'Image Adjustments' and 'bring' it to the support in such a way that the viewing conditions and its environment are taken into account. @@ -2535,6 +2539,7 @@ TP_ICM_DCPILLUMINANT;Illuminant TP_ICM_DCPILLUMINANT_INTERPOLATED;Interpolated TP_ICM_DCPILLUMINANT_TOOLTIP;Select which embedded DCP illuminant to employ. Default is 'interpolated' which is a mix between the two based on white balance. The setting is only available if a dual-illuminant DCP with interpolation support is selected. TP_ICM_FBW;Black-and-White +TP_ICM_GAMUT;Gamut control TP_ICM_ILLUMPRIM_TOOLTIP;Choose the illuminant closest to the shooting conditions.\nChanges can only be made when the 'Destination primaries' selection is set to 'Custom (sliders)'. TP_ICM_INPUTCAMERA;Camera standard TP_ICM_INPUTCAMERAICC;Auto-matched camera profile @@ -2612,8 +2617,6 @@ TP_ICM_WORKING_TRC_SRGB;sRGB g=2.4 s=12.92 TP_ICM_WORKING_TRC_TOOLTIP;Only for built-in profiles. TP_IMPULSEDENOISE_LABEL;Impulse Noise Reduction TP_IMPULSEDENOISE_THRESH;Threshold -TP_LABCURVE_AVOIDCOLORSHIFT;Avoid color shift -TP_LABCURVE_AVOIDCOLORSHIFT_TOOLTIP;Fit colors into gamut of the working color space and apply Munsell correction (Uniform Perceptual Lab). TP_LABCURVE_BRIGHTNESS;Lightness TP_LABCURVE_CHROMATICITY;Chromaticity TP_LABCURVE_CHROMA_TOOLTIP;To apply B&W toning, set Chromaticity to -100. @@ -2678,7 +2681,7 @@ TP_LOCALLAB_ARTIF_TOOLTIP;ΔE scope threshold increases the range of ΔE scope. TP_LOCALLAB_AUTOGRAY;Auto mean luminance (Yb%) TP_LOCALLAB_AUTOGRAYCIE;Auto TP_LOCALLAB_AVOID;Avoid color shift -TP_LOCALLAB_AVOIDCOLORSHIFT_TOOLTIP;Fit colors into gamut of the working color space and apply Munsell correction (Uniform Perceptual Lab).\nMunsell correction always disabled when Jz or CAM16 is used. +TP_LOCALLAB_AVOIDCOLORSHIFT_TOOLTIP;Fit colors into gamut of the working color space and apply Munsell correction (Uniform Perceptual Lab).\nMunsell correction always disabled when Jz or CAM16 or Color Appearance and Lighting is used.\n\nDefault: Munsell.\nMunsell correction: fixes Lab mode hue drifts due to non-linearity, when chromaticity is changed (Uniform Perceptual Lab).\nLab: applies a gamut control, in relative colorimetric, Munsell is then applied.\nXYZ Absolute, applies gamut control, in absolute colorimetric, Munsell is then applied.\nXYZ Relative, applies gamut control, in relative colorimetric, Munsell is then applied. TP_LOCALLAB_AVOIDMUN;Munsell correction only TP_LOCALLAB_AVOIDMUN_TOOLTIP;Munsell correction always disabled when Jz or CAM16 is used. TP_LOCALLAB_AVOIDRAD;Soft radius @@ -2908,6 +2911,11 @@ TP_LOCALLAB_GAMM;Gamma TP_LOCALLAB_GAMMASKCOL;Gamma TP_LOCALLAB_GAMMASK_TOOLTIP;Adjusting Gamma and Slope can provide a soft and artifact-free transformation of the mask by progressively modifying 'L' to avoid any discontinuities. TP_LOCALLAB_GAMSH;Gamma +TP_LOCALLAB_GAMUTNON;None +TP_LOCALLAB_GAMUTLABRELA;Lab +TP_LOCALLAB_GAMUTXYZABSO;XYZ Absolute +TP_LOCALLAB_GAMUTXYZRELA;XYZ Relative +TP_LOCALLAB_GAMUTMUNSELL;Munsell only TP_LOCALLAB_GAMW;Gamma (wavelet pyramids) TP_LOCALLAB_GRADANG;Gradient angle TP_LOCALLAB_GRADANG_TOOLTIP;Rotation angle in degrees: -180 0 +180. diff --git a/rtdata/themes/TooWaBlue-GTK3-20_.css b/rtdata/themes/TooWaBlue-GTK3-20_.css index 2e9c6ccde..ba25e70b7 100644 --- a/rtdata/themes/TooWaBlue-GTK3-20_.css +++ b/rtdata/themes/TooWaBlue-GTK3-20_.css @@ -1281,6 +1281,11 @@ menuitem:hover > * { color: @text-hl-color; } +menu menuitem > radio + * image:not(.dummy), +#MyExpander menu menuitem > radio + * image:not(.dummy) { + margin-left: 1pt; +} + menu image:not(.dummy), #MyExpander menu image:not(.dummy) { min-height: 2em; diff --git a/rtdata/themes/size - Legacy.css b/rtdata/themes/size - Legacy.css index 08c39f973..089a909ee 100644 --- a/rtdata/themes/size - Legacy.css +++ b/rtdata/themes/size - Legacy.css @@ -383,6 +383,11 @@ menu arrow { margin: 0 -0.25em 0 0; } +menu menuitem > radio + * image:not(.dummy), +#MyExpander menu menuitem > radio + * image:not(.dummy) { + margin-left: 1pt; +} + menu image:not(.dummy), #MyExpander menu image:not(.dummy) { min-height: 2em; @@ -1029,4 +1034,4 @@ messagedialog headerbar button.titlebutton { min-height: 1.25em; margin: 0; } -/*** end ***************************************************************************************/ \ No newline at end of file +/*** end ***************************************************************************************/ diff --git a/rtdata/themes/size.css b/rtdata/themes/size.css index 2d23bf860..675ed51c2 100644 --- a/rtdata/themes/size.css +++ b/rtdata/themes/size.css @@ -351,6 +351,11 @@ menu arrow { margin: 0 -0.25em 0 0; } +menu menuitem > radio + * image:not(.dummy), +#MyExpander menu menuitem > radio + * image:not(.dummy) { + margin-left: 1pt; +} + menu image:not(.dummy), #MyExpander menu image:not(.dummy) { min-height: 2em; diff --git a/rtengine/color.cc b/rtengine/color.cc index d6c35208d..085fd41ce 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -24,6 +24,7 @@ #include "sleef.h" #include "opthelper.h" #include "iccstore.h" +#include using namespace std; @@ -1910,6 +1911,152 @@ void Color::Lch2Luv(float c, float h, float &u, float &v) v = c * sincosval.y; } +void Color::primaries_to_xyz(double p[6], double Wx, double Wz, double *pxyz) +{ + //calculate Xr, Xg, Xb, Yr, Yb, Tg, Zr,Zg Zb + double Wy = 1.0; + double Xr = p[0] / p[1]; + double Yr = 1.0; + double Zr = (1.0 - p[0] - p[1]) / p[1]; + double Xg = p[2] / p[3]; + double Yg = 1.0; + double Zg = (1.0 - p[2] - p[3]) / p[3]; + double Xb = p[4] / p[5]; + double Yb = 1.0; + double Zb = (1.0 - p[4] - p[5]) / p[5]; + + using Triple = std::array; + + using Matrix = std::array; + + Matrix input_prim; + Matrix inv_input_prim = {}; + input_prim[0][0] = Xr; + input_prim[0][1] = Yr; + input_prim[0][2] = Zr; + input_prim[1][0] = Xg; + input_prim[1][1] = Yg; + input_prim[1][2] = Zg; + input_prim[2][0] = Xb; + input_prim[2][1] = Yb; + input_prim[2][2] = Zb; + + //invert matrix + if (!rtengine::invertMatrix(input_prim, inv_input_prim)) { + std::cout << "Matrix is not invertible, skipping" << std::endl; + } + + //white point D50 used by LCMS + double Wdx = 0.96420; + double Wdy = 1.0; + double Wdz = 0.82490; + + double Sr = Wx * inv_input_prim [0][0] + Wy * inv_input_prim [1][0] + Wz * inv_input_prim [2][0]; + double Sg = Wx * inv_input_prim [0][1] + Wy * inv_input_prim [1][1] + Wz * inv_input_prim [2][1]; + double Sb = Wx * inv_input_prim [0][2] + Wy * inv_input_prim [1][2] + Wz * inv_input_prim [2][2]; + + //XYZ matrix for primaries and temp + Matrix mat_xyz = {}; + mat_xyz[0][0] = Sr * Xr; + mat_xyz[0][1] = Sr * Yr; + mat_xyz[0][2] = Sr * Zr; + mat_xyz[1][0] = Sg * Xg; + mat_xyz[1][1] = Sg * Yg; + mat_xyz[1][2] = Sg * Zg; + mat_xyz[2][0] = Sb * Xb; + mat_xyz[2][1] = Sb * Yb; + mat_xyz[2][2] = Sb * Zb; + + //chromatic adaptation Bradford + Matrix MaBradford = {}; + MaBradford[0][0] = 0.8951; + MaBradford[0][1] = -0.7502; + MaBradford[0][2] = 0.0389; + MaBradford[1][0] = 0.2664; + MaBradford[1][1] = 1.7135; + MaBradford[1][2] = -0.0685; + MaBradford[2][0] = -0.1614; + MaBradford[2][1] = 0.0367; + MaBradford[2][2] = 1.0296; + + Matrix Ma_oneBradford = {}; + Ma_oneBradford[0][0] = 0.9869929; + Ma_oneBradford[0][1] = 0.4323053; + Ma_oneBradford[0][2] = -0.0085287; + Ma_oneBradford[1][0] = -0.1470543; + Ma_oneBradford[1][1] = 0.5183603; + Ma_oneBradford[1][2] = 0.0400428; + Ma_oneBradford[2][0] = 0.1599627; + Ma_oneBradford[2][1] = 0.0492912; + Ma_oneBradford[2][2] = 0.9684867; + + //R G B source + double Rs = Wx * MaBradford[0][0] + Wy * MaBradford[1][0] + Wz * MaBradford[2][0]; + double Gs = Wx * MaBradford[0][1] + Wy * MaBradford[1][1] + Wz * MaBradford[2][1]; + double Bs = Wx * MaBradford[0][2] + Wy * MaBradford[1][2] + Wz * MaBradford[2][2]; + + // R G B destination + double Rd = Wdx * MaBradford[0][0] + Wdy * MaBradford[1][0] + Wdz * MaBradford[2][0]; + double Gd = Wdx * MaBradford[0][1] + Wdy * MaBradford[1][1] + Wdz * MaBradford[2][1]; + double Bd = Wdx * MaBradford[0][2] + Wdy * MaBradford[1][2] + Wdz * MaBradford[2][2]; + + //cone destination + Matrix cone_dest_sourc = {}; + cone_dest_sourc [0][0] = Rd / Rs; + cone_dest_sourc [0][1] = 0.; + cone_dest_sourc [0][2] = 0.; + cone_dest_sourc [1][0] = 0.; + cone_dest_sourc [1][1] = Gd / Gs; + cone_dest_sourc [1][2] = 0.; + cone_dest_sourc [2][0] = 0.; + cone_dest_sourc [2][1] = 0.; + cone_dest_sourc [2][2] = Bd / Bs; + + //cone dest + Matrix cone_ma_one = {}; + + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + cone_ma_one[i][j] = 0; + + for (int k = 0; k < 3; ++k) { + cone_ma_one[i][j] += cone_dest_sourc [i][k] * Ma_oneBradford[k][j]; + } + } + } + + //generate adaptation bradford matrix + Matrix adapt_chroma = {}; + + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + adapt_chroma [i][j] = 0; + + for (int k = 0; k < 3; ++k) { + adapt_chroma[i][j] += MaBradford[i][k] * cone_ma_one[k][j]; + } + } + } + + Matrix mat_xyz_brad = {}; + + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + mat_xyz_brad[i][j] = 0; + + for (int k = 0; k < 3; ++k) { + mat_xyz_brad[i][j] += mat_xyz[i][k] * adapt_chroma[k][j]; + } + } + } + + //push result in pxyz + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + pxyz[i * 3 + j] = mat_xyz_brad[i][j]; + } + } +} /* * Gamut mapping algorithm @@ -1931,13 +2078,19 @@ void Color::Lch2Luv(float c, float h, float &u, float &v) * columns of the matrix p=xyz_rgb are RGB tristimulus primaries in XYZ * c is the color fixed on the boundary; and m=0 for c=0, m=1 for c=255 */ + void Color::gamutmap(float &X, float Y, float &Z, const double p[3][3]) { - float u = 4 * X / (X + 15 * Y + 3 * Z) - u0; - float v = 9 * Y / (X + 15 * Y + 3 * Z) - v0; - + float epsil = 0.0001f; + float intermXYZ = X + 15 * Y + 3 * Z; + if(intermXYZ <= 0.f) { + intermXYZ = epsil; + } + + float u = 4 * X / (intermXYZ) - u0; + float v = 9 * Y / (intermXYZ) - v0; float lam[3][2]; - float lam_min = 1.0; + float lam_min = 1.0f; for (int c = 0; c < 3; c++) for (int m = 0; m < 2; m++) { @@ -1955,17 +2108,24 @@ void Color::gamutmap(float &X, float Y, float &Z, const double p[3][3]) p[0][c] * (5 * Y * p[1][c1] + m * 65535 * p[1][c1] * p[2][c2] + Y * p[2][c1] - m * 65535 * p[1][c2] * p[2][c1]) + m * 65535 * p[0][c2] * (p[1][c1] * p[2][c] - p[1][c] * p[2][c1]))); - if (lam[c][m] < lam_min && lam[c][m] > 0) { + if (lam[c][m] < lam_min && lam[c][m] > 0.f) { lam_min = lam[c][m]; } } - u = u * lam_min + u0; - v = v * lam_min + v0; + u = u * (double) lam_min + u0; + v = v * (double) lam_min + v0; X = (9 * u * Y) / (4 * v); - Z = (12 - 3 * u - 20 * v) * Y / (4 * v); + float intermuv = 12 - 3 * u - 20 * v; + if(intermuv < 0.f) { + intermuv = 0.f; + } + Z = (intermuv) * Y / (4 * v); + + + } void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s) diff --git a/rtengine/color.h b/rtengine/color.h index f602ade83..3622a9e36 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -1847,6 +1847,13 @@ static inline void Lab2XYZ(vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, v */ static void gamutmap(float &X, float Y, float &Z, const double p[3][3]); + /** + * @brief Convert primaries in XYZ values in function of illuminant + * @param p primaries red, gree, blue + * @param Wx Wy white for illuminant + * @param pxyz return matrix XYZ + */ + static void primaries_to_xyz (double p[6], double Wx, double Wz, double *pxyz); /** * @brief Get HSV's hue from the Lab's hue diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index e0a6cda92..aadc0b969 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -19,6 +19,7 @@ #pragma once +#include #include #include "myfile.h" diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index df354bfd8..ec5ffc8ef 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -1913,7 +1913,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) adap = pow(2.0, E_V - 3.0); // cd / m2 // end calculation adaptation scene luminosity } - + if(params->colorappearance.catmethod == "symg") {//force abolute luminance scenescene to 400 in symmetric + adap = 400.; + } float d, dj, yb; bool execsharp = false; @@ -1935,24 +1937,60 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) CAMBrightCurveQ.dirty = true; ipf.ciecam_02float(ncie, float (adap), pW, 2, nprevl, params.get(), customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 0, scale, execsharp, d, dj, yb, 1); - - if ((params->colorappearance.autodegree || params->colorappearance.autodegreeout) && acListener && params->colorappearance.enabled && !params->colorappearance.presetcat02) { - acListener->autoCamChanged(100.* (double)d, 100.* (double)dj); + //call listener + if ((params->colorappearance.autodegree || params->colorappearance.autodegreeout) && acListener && params->colorappearance.enabled) { + if(params->colorappearance.catmethod == "symg") {//force chromatic adaptation to 90 in symmetric + d = 0.9; + dj = 0.9; + } + acListener->autoCamChanged(100.* (double)d, 100.* (double)dj); } - if (params->colorappearance.autoadapscen && acListener && params->colorappearance.enabled && !params->colorappearance.presetcat02) { - acListener->adapCamChanged(adap); //real value of adapt scene + if (params->colorappearance.autoadapscen && acListener && params->colorappearance.enabled) { + acListener->adapCamChanged(adap); //real value of adapt scene, force to 400 in symmetric } - if (params->colorappearance.autoybscen && acListener && params->colorappearance.enabled && !params->colorappearance.presetcat02) { + if (params->colorappearance.autoybscen && acListener && params->colorappearance.enabled) { + if(params->colorappearance.catmethod == "symg") {//force yb scene to 18 in symmetric + yb = 18; + } + acListener->ybCamChanged((int) yb); //real value Yb scene } - - // if (params->colorappearance.enabled && params->colorappearance.presetcat02 && params->colorappearance.autotempout) { - // if (params->colorappearance.enabled && params->colorappearance.presetcat02) { - // acListener->wbCamChanged(params->wb.temperature, params->wb.green); //real temp and tint - // acListener->wbCamChanged(params->wb.temperature, 1.f); //real temp and tint = 1. - // } + double tempsym = 5003.; + int wmodel = 0;//wmodel allows - arbitrary - choice of illuminant and temp with choice + if (params->colorappearance.wbmodel == "RawT") { + wmodel = 0; + } else if (params->colorappearance.wbmodel == "RawTCAT02") { + wmodel = 1; + } else if (params->colorappearance.wbmodel == "free") { + wmodel = 2;//force white balance in symmetric + } + + if(params->colorappearance.catmethod == "symg" && wmodel == 2) { + tempsym = params->wb.temperature;//force white balance in symmetric + } else { + if (params->colorappearance.illum == "iA") {//otherwise force illuminant source + tempsym = 2856.; + } else if (params->colorappearance.illum == "i41") { + tempsym = 4100.; + } else if (params->colorappearance.illum == "i50") { + tempsym = 5003.; + } else if (params->colorappearance.illum == "i55") { + tempsym = 5503.; + } else if (params->colorappearance.illum == "i60") { + tempsym = 6000. ; + } else if (params->colorappearance.illum == "i65") { + tempsym = 6504.; + } else if (params->colorappearance.illum == "i75") { + tempsym = 7504.; + } else if (params->colorappearance.illum == "ifree") { + tempsym = params->wb.temperature;//force white balance in symmetric + } + } + if (params->colorappearance.enabled && params->colorappearance.autotempout) { + acListener->wbCamChanged(tempsym, 1.f); //real temp and tint = 1. + } } else { // CIECAM is disabled, we free up its image buffer to save some space diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 15ebcc2e6..0e08a28eb 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -54,7 +54,8 @@ #pragma GCC diagnostic warning "-Wextra" #pragma GCC diagnostic warning "-Wdouble-promotion" -namespace { +namespace +{ using namespace rtengine; @@ -218,32 +219,37 @@ void proPhotoBlue(float *rtemp, float *gtemp, float *btemp, int istart, int tH, } } -void customToneCurve(const ToneCurve &customToneCurve, ToneCurveMode curveMode, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize, PerceptualToneCurveState ptcApplyState) { +void customToneCurve(const ToneCurve &customToneCurve, ToneCurveMode curveMode, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize, PerceptualToneCurveState ptcApplyState) +{ if (curveMode == ToneCurveMode::STD) { // Standard - const StandardToneCurve& userToneCurve = static_cast (customToneCurve); + const StandardToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); } } else if (curveMode == ToneCurveMode::FILMLIKE) { // Adobe like - const AdobeToneCurve& userToneCurve = static_cast (customToneCurve); + const AdobeToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); } } else if (curveMode == ToneCurveMode::SATANDVALBLENDING) { // apply the curve on the saturation and value channels - const SatAndValueBlendingToneCurve& userToneCurve = static_cast (customToneCurve); + const SatAndValueBlendingToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } else if (curveMode == ToneCurveMode::WEIGHTEDSTD) { // apply the curve to the rgb channels, weighted - const WeightedStdToneCurve& userToneCurve = static_cast (customToneCurve); + const WeightedStdToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); } } else if (curveMode == ToneCurveMode::LUMINANCE) { // apply the curve to the luminance channel - const LuminanceToneCurve& userToneCurve = static_cast (customToneCurve); + const LuminanceToneCurve& userToneCurve = static_cast(customToneCurve); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { @@ -251,7 +257,8 @@ void customToneCurve(const ToneCurve &customToneCurve, ToneCurveMode curveMode, } } } else if (curveMode == ToneCurveMode::PERCEPTUAL) { // apply curve while keeping color appearance constant - const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve); + const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize], ptcApplyState); } @@ -277,7 +284,7 @@ namespace rtengine using namespace procparams; -ImProcFunctions::~ImProcFunctions () +ImProcFunctions::~ImProcFunctions() { if (monitorTransform) { cmsDeleteTransform(monitorTransform); @@ -307,7 +314,7 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R #if !defined(__APPLE__) // No support for monitor profiles on OS X, all data is sRGB monitor = ICCStore::getInstance()->getProfile(monitorProfile); #else - monitor = ICCStore::getInstance()->getProfile (settings->srgb); + monitor = ICCStore::getInstance()->getProfile(settings->srgb); #endif } @@ -325,7 +332,7 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R if (softProof) { cmsHPROFILE oprof = nullptr; RenderingIntent outIntent; - + flags = cmsFLAGS_SOFTPROOFING | cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; if (!settings->printerProfile.empty()) { @@ -334,9 +341,11 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R if (settings->printerBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + outIntent = RenderingIntent(settings->printerIntent); } else { oprof = ICCStore::getInstance()->getProfile(params->icm.outputProfile); + if (params->icm.outputBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } @@ -352,20 +361,23 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R // } const auto make_gamma_table = - [](cmsHPROFILE prof, cmsTagSignature tag) -> void + [](cmsHPROFILE prof, cmsTagSignature tag) -> void { + cmsToneCurve *tc = static_cast(cmsReadTag(prof, tag)); + + if (tc) { - cmsToneCurve *tc = static_cast(cmsReadTag(prof, tag)); - if (tc) { - const cmsUInt16Number *table = cmsGetToneCurveEstimatedTable(tc); - cmsToneCurve *tc16 = cmsBuildTabulatedToneCurve16(nullptr, cmsGetToneCurveEstimatedTableEntries(tc), table); - if (tc16) { - cmsWriteTag(prof, tag, tc16); - cmsFreeToneCurve(tc16); - } + const cmsUInt16Number *table = cmsGetToneCurveEstimatedTable(tc); + cmsToneCurve *tc16 = cmsBuildTabulatedToneCurve16(nullptr, cmsGetToneCurveEstimatedTableEntries(tc), table); + + if (tc16) { + cmsWriteTag(prof, tag, tc16); + cmsFreeToneCurve(tc16); } - }; + } + }; cmsHPROFILE softproof = ProfileContent(oprof).toProfile(); + if (softproof) { make_gamma_table(softproof, cmsSigRedTRCTag); make_gamma_table(softproof, cmsSigGreenTRCTag); @@ -439,7 +451,7 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R void ImProcFunctions::firstAnalysis(const Imagefloat* const original, const ProcParams ¶ms, LUTu & histogram) { - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params.icm.workingProfile); + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params.icm.workingProfile); lumimul[0] = wprof[1][0]; lumimul[1] = wprof[1][1]; @@ -956,18 +968,20 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb float cz, wh, pfl; int c16 = 1; + if (params->colorappearance.modelmethod == "02") { c16 = 1; - }else if (params->colorappearance.modelmethod == "16") { + } else if (params->colorappearance.modelmethod == "16") { c16 = 16; - } //I don't use PQ here...hence no 21 + } //I don't use PQ here...hence no 21 + float plum = 100.f; - Ciecam02::initcam1float (yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c, c16, plum); + Ciecam02::initcam1float(yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c, c16, plum); //printf ("wh=%f \n", wh); const float pow1 = pow_F(1.64f - pow_F(0.29f, n), 0.73f); float nj, nbbj, ncbj, czj, awj, flj; - Ciecam02::initcam2float (yb2, pilotout, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj, c16, plum); + Ciecam02::initcam2float(yb2, pilotout, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj, c16, plum); #ifdef __SSE2__ const float reccmcz = 1.f / (c2 * czj); #endif @@ -1011,7 +1025,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb //matrix for current working space - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.workingProfile); + TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.workingProfile); const float wip[3][3] = { { (float)wiprof[0][0], (float)wiprof[0][1], (float)wiprof[0][2]}, { (float)wiprof[1][0], (float)wiprof[1][1], (float)wiprof[1][2]}, @@ -1084,7 +1098,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Q, M, s, aw, fl, wh, x, y, z, xw1, yw1, zw1, - c, nc, pow1, nbb, ncb, pfl, cz, d, c16, plum); + c, nc, pow1, nbb, ncb, pfl, cz, d, c16, plum); Jbuffer[k] = J; Cbuffer[k] = C; hbuffer[k] = h; @@ -1122,7 +1136,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Q, M, s, aw, fl, wh, x, y, z, xw1, yw1, zw1, - c, nc, pow1, nbb, ncb, pfl, cz, d, c16, plum); + c, nc, pow1, nbb, ncb, pfl, cz, d, c16, plum); #endif float Jpro, Cpro, hpro, Qpro, Mpro, spro; Jpro = J; @@ -1132,6 +1146,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Mpro = M; spro = s; bool jp = false; + if ((hasColCurve1) && (curveMode == ColorAppearanceParams::TcMode::BRIGHT)) { jp = true; float Qq = Qpro * coefQ; @@ -1141,6 +1156,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Qq = Qq / coefQ; Qpro = 0.2f * (Qq - Qold) + Qold; } + if ((hasColCurve2) && (curveMode2 == ColorAppearanceParams::TcMode::BRIGHT)) { jp = true; float Qq2 = Qpro * coefQ; @@ -1149,10 +1165,12 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb userColCurveB2.Apply(Qq2); Qq2 = Qq2 / coefQ; Qpro = 0.2f * (Qq2 - Qold2) + Qold2; - } - if(jp) { + } + + if (jp) { Jpro = SQR((10.f * Qpro) / wh); } + // we cannot have all algorithms with all chroma curves if (alg == 0) { Jpro = CAMBrightCurveJ[Jpro * 327.68f]; //lightness CIECAM02 + contrast @@ -1240,73 +1258,73 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb } if (hasColCurve1 && (curveMode == ColorAppearanceParams::TcMode::LIGHT)) { - float Jj = (float) Jpro * 327.68f; - float Jold = Jj; - float Jold100 = (float) Jpro; - float redu = 25.f; - float reduc = 1.f; - const Lightcurve& userColCurveJ1 = static_cast(customColCurve1); - userColCurveJ1.Apply(Jj); + float Jj = (float) Jpro * 327.68f; + float Jold = Jj; + float Jold100 = (float) Jpro; + float redu = 25.f; + float reduc = 1.f; + const Lightcurve& userColCurveJ1 = static_cast(customColCurve1); + userColCurveJ1.Apply(Jj); - if (Jj > Jold) { - if (Jj < 65535.f) { - if (Jold < 327.68f * redu) { - Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility - } else { - reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); - Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights - } + if (Jj > Jold) { + if (Jj < 65535.f) { + if (Jold < 327.68f * redu) { + Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility + } else { + reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); + Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights } - } else if (Jj > 10.f) { - Jj = 0.8f * (Jj - Jold) + Jold; - } else if (Jj >= 0.f) { - Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts } + } else if (Jj > 10.f) { + Jj = 0.8f * (Jj - Jold) + Jold; + } else if (Jj >= 0.f) { + Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts + } - Jpro = (float)(Jj / 327.68f); + Jpro = (float)(Jj / 327.68f); - if (Jpro < 1.f) { - Jpro = 1.f; - } + if (Jpro < 1.f) { + Jpro = 1.f; + } } - if (hasColCurve2 && (curveMode2 == ColorAppearanceParams::TcMode::LIGHT)) { - float Jj = (float) Jpro * 327.68f; - float Jold = Jj; - float Jold100 = (float) Jpro; - float redu = 25.f; - float reduc = 1.f; - const Lightcurve& userColCurveJ2 = static_cast(customColCurve2); - userColCurveJ2.Apply(Jj); + if (hasColCurve2 && (curveMode2 == ColorAppearanceParams::TcMode::LIGHT)) { + float Jj = (float) Jpro * 327.68f; + float Jold = Jj; + float Jold100 = (float) Jpro; + float redu = 25.f; + float reduc = 1.f; + const Lightcurve& userColCurveJ2 = static_cast(customColCurve2); + userColCurveJ2.Apply(Jj); - if (Jj > Jold) { - if (Jj < 65535.f) { - if (Jold < 327.68f * redu) { - Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility - } else { - reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); - Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights - } - } - } else if (Jj > 10.f) { - if (!t1L) { - Jj = 0.8f * (Jj - Jold) + Jold; - } else { - Jj = 0.4f * (Jj - Jold) + Jold; - } - } else if (Jj >= 0.f) { - if (!t1L) { - Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts - } else { - Jj = 0.5f * (Jj - Jold) + Jold; + if (Jj > Jold) { + if (Jj < 65535.f) { + if (Jold < 327.68f * redu) { + Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility + } else { + reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); + Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights } } - - Jpro = (float)(Jj / 327.68f); - - if (Jpro < 1.f) { - Jpro = 1.f; + } else if (Jj > 10.f) { + if (!t1L) { + Jj = 0.8f * (Jj - Jold) + Jold; + } else { + Jj = 0.4f * (Jj - Jold) + Jold; } + } else if (Jj >= 0.f) { + if (!t1L) { + Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts + } else { + Jj = 0.5f * (Jj - Jold) + Jold; + } + } + + Jpro = (float)(Jj / 327.68f); + + if (Jpro < 1.f) { + Jpro = 1.f; + } } if (hasColCurve3) {//curve 3 with chroma saturation colorfullness @@ -1456,47 +1474,33 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb #else float xx, yy, zz; //process normal==> viewing + TMatrix wprofc = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile); + const double wpc[3][3] = {//improve precision with double + {wprofc[0][0], wprofc[0][1], wprofc[0][2]}, + {wprofc[1][0], wprofc[1][1], wprofc[1][2]}, + {wprofc[2][0], wprofc[2][1], wprofc[2][2]} + }; Ciecam02::jch2xyz_ciecam02float(xx, yy, zz, J, C, h, xw2, yw2, zw2, - c2, nc2, pow1n, nbbj, ncbj, flj, czj, dj, awj, c16, plum); + c2, nc2, pow1n, nbbj, ncbj, flj, czj, dj, awj, c16, plum); float x, y, z; x = xx * 655.35f; y = yy * 655.35f; z = zz * 655.35f; float Ll, aa, bb; + //convert xyz=>lab - Color::XYZ2Lab(x, y, z, Ll, aa, bb); - - // gamut control in Lab mode; I must study how to do with cIECAM only if (gamu == 1) { - float Lprov1, Chprov1; - Lprov1 = Ll / 327.68f; - Chprov1 = sqrtf(SQR(aa) + SQR(bb)) / 327.68f; - float2 sincosval; - - if (Chprov1 == 0.0f) { - sincosval.y = 1.f; - sincosval.x = 0.0f; - } else { - sincosval.y = aa / (Chprov1 * 327.68f); - sincosval.x = bb / (Chprov1 * 327.68f); - } - - - //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); - lab->L[i][j] = Lprov1 * 327.68f; - lab->a[i][j] = 327.68f * Chprov1 * sincosval.y; - lab->b[i][j] = 327.68f * Chprov1 * sincosval.x; - - } else { - lab->L[i][j] = Ll; - lab->a[i][j] = aa; - lab->b[i][j] = bb; + Color::gamutmap(x, y, z, wpc); } + Color::XYZ2Lab(x, y, z, Ll, aa, bb); + lab->L[i][j] = Ll; + lab->a[i][j] = aa; + lab->b[i][j] = bb; + #endif } } @@ -1592,7 +1596,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb if (params->defringe.enabled) if (execsharp) { lab->deleteLab(); - defringecam (ncie);//defringe adapted to CIECAM + defringecam(ncie); //defringe adapted to CIECAM lab->reallocLab(); } @@ -1603,7 +1607,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb const bool hotbad = params->dirpyrequalizer.skinprotect != 0.0; lab->deleteLab(); - badpixcam (ncie, artifact / scale, 5, 2, chrom, hotbad); //enabled remove artifacts for cbDL + badpixcam(ncie, artifact / scale, 5, 2, chrom, hotbad); //enabled remove artifacts for cbDL lab->reallocLab(); } @@ -1611,7 +1615,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb if (params->colorappearance.badpixsl > 0 && execsharp) { int mode = params->colorappearance.badpixsl; lab->deleteLab(); - badpixcam (ncie, 3.0, 10, mode, 0, true);//for bad pixels CIECAM + badpixcam(ncie, 3.0, 10, mode, 0, true); //for bad pixels CIECAM lab->reallocLab(); } @@ -1620,17 +1624,17 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb buffers[0] = lab->L; buffers[1] = lab->a; buffers[2] = lab->b; - impulsedenoisecam (ncie, buffers); //impulse adapted to CIECAM + impulsedenoisecam(ncie, buffers); //impulse adapted to CIECAM } if (params->sharpenMicro.enabled)if (execsharp) { - MLmicrocontrastcam (ncie); + MLmicrocontrastcam(ncie); } if (params->sharpening.enabled) if (execsharp) { float **buffer = lab->L; // We can use the L-buffer from lab as buffer to save some memory - sharpeningcam (ncie, buffer, showSharpMask); // sharpening adapted to CIECAM + sharpeningcam(ncie, buffer, showSharpMask); // sharpening adapted to CIECAM } //if(params->dirpyrequalizer.enabled) if(execsharp) { @@ -1643,7 +1647,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb float t_l = static_cast(params->dirpyrequalizer.hueskin.getTopLeft()) / 100.0f; float t_r = static_cast(params->dirpyrequalizer.hueskin.getTopRight()) / 100.0f; lab->deleteLab(); - dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, b_l, t_l, t_r, scale); //contrast by detail adapted to CIECAM + dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, b_l, t_l, t_r, scale); //contrast by detail adapted to CIECAM lab->reallocLab(); } @@ -1666,6 +1670,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb #ifdef _OPENMP #pragma omp for schedule(dynamic, 10) #endif + for (int i = 0; i < height; i++) // update CieImages with new values after sharpening, defringe, contrast by detail level for (int j = 0; j < width; j++) { float interm = fabsf(ncie->sh_p[i][j] / (32768.f)); @@ -1685,7 +1690,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb if (epdEnabled && params->colorappearance.tonecie && algepd) { lab->deleteLab(); - EPDToneMapCIE (ncie, a_w, c_, width, height, minQ, maxQ, Iterates, scale ); + EPDToneMapCIE(ncie, a_w, c_, width, height, minQ, maxQ, Iterates, scale); lab->reallocLab(); } @@ -1769,7 +1774,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Ciecam02::jch2xyz_ciecam02float(xx, yy, zz, ncie->J_p[i][j], ncie_C_p, ncie->h_p[i][j], xw2, yw2, zw2, - c2, nc2, pow1n, nbbj, ncbj, flj, czj, dj, awj, c16, plum); + c2, nc2, pow1n, nbbj, ncbj, flj, czj, dj, awj, c16, plum); float x = (float)xx * 655.35f; float y = (float)yy * 655.35f; float z = (float)zz * 655.35f; @@ -1894,7 +1899,7 @@ void ImProcFunctions::moyeqt(Imagefloat* working, float &moyS, float &eqty) for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { - const double s = Color::rgb2s(CLIP(working->r (i, j)), CLIP(working->g (i, j)), CLIP(working->b (i, j))); + const double s = Color::rgb2s(CLIP(working->r(i, j)), CLIP(working->g(i, j)), CLIP(working->b(i, j))); moy += s; sqrs += SQR(s); } @@ -1946,12 +1951,12 @@ filmlike_clip(float *r, float *g, float *b) } } -void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, const LUTf& hltonecurve, const LUTf& shtonecurve, const LUTf& tonecurve, - int sat, const LUTf& rCurve, const LUTf& gCurve, const LUTf& bCurve, float satLimit, float satLimitOpacity, - const ColorGradientCurve& ctColorCurve, const OpacityCurve& ctOpacityCurve, bool opautili, const LUTf& clToningcurve, const LUTf& cl2Toningcurve, - const ToneCurve& customToneCurve1, const ToneCurve& customToneCurve2, const ToneCurve& customToneCurvebw1, const ToneCurve& customToneCurvebw2, - double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, DCPProfile *dcpProf, const DCPProfileApplyState& asIn, - LUTu& histToneCurve, size_t chunkSize, bool measure) +void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, const LUTf& hltonecurve, const LUTf& shtonecurve, const LUTf& tonecurve, + int sat, const LUTf& rCurve, const LUTf& gCurve, const LUTf& bCurve, float satLimit, float satLimitOpacity, + const ColorGradientCurve& ctColorCurve, const OpacityCurve& ctOpacityCurve, bool opautili, const LUTf& clToningcurve, const LUTf& cl2Toningcurve, + const ToneCurve& customToneCurve1, const ToneCurve& customToneCurve2, const ToneCurve& customToneCurvebw1, const ToneCurve& customToneCurvebw2, + double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, DCPProfile *dcpProf, const DCPProfileApplyState& asIn, + LUTu& histToneCurve, size_t chunkSize, bool measure) { rgbProc(working, lab, pipetteBuffer, hltonecurve, shtonecurve, tonecurve, sat, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, @@ -1959,12 +1964,12 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } // Process RGB image and convert to LAB space -void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, const LUTf& hltonecurve, const LUTf& shtonecurve, const LUTf& tonecurve, - int sat, const LUTf& rCurve, const LUTf& gCurve, const LUTf& bCurve, float satLimit, float satLimitOpacity, - const ColorGradientCurve& ctColorCurve, const OpacityCurve& ctOpacityCurve, bool opautili, const LUTf& clToningcurve, const LUTf& cl2Toningcurve, - const ToneCurve& customToneCurve1, const ToneCurve& customToneCurve2, const ToneCurve& customToneCurvebw1, const ToneCurve& customToneCurvebw2, - double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, double expcomp, int hlcompr, int hlcomprthresh, - DCPProfile *dcpProf, const DCPProfileApplyState& asIn, LUTu& histToneCurve, size_t chunkSize, bool measure) +void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, const LUTf& hltonecurve, const LUTf& shtonecurve, const LUTf& tonecurve, + int sat, const LUTf& rCurve, const LUTf& gCurve, const LUTf& bCurve, float satLimit, float satLimitOpacity, + const ColorGradientCurve& ctColorCurve, const OpacityCurve& ctOpacityCurve, bool opautili, const LUTf& clToningcurve, const LUTf& cl2Toningcurve, + const ToneCurve& customToneCurve1, const ToneCurve& customToneCurve2, const ToneCurve& customToneCurvebw1, const ToneCurve& customToneCurvebw2, + double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, double expcomp, int hlcompr, int hlcomprthresh, + DCPProfile *dcpProf, const DCPProfileApplyState& asIn, LUTu& histToneCurve, size_t chunkSize, bool measure) { std::unique_ptr stop; @@ -1995,8 +2000,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } } - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params->icm.workingProfile); - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.workingProfile); + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile); + TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.workingProfile); float toxyz[3][3] = { { @@ -2150,13 +2155,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer PerceptualToneCurveState ptc1ApplyState, ptc2ApplyState; if (hasToneCurve1 && curveMode == ToneCurveMode::PERCEPTUAL) { - const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve1); - userToneCurve.initApplyState (ptc1ApplyState, params->icm.workingProfile); + const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve1); + userToneCurve.initApplyState(ptc1ApplyState, params->icm.workingProfile); } if (hasToneCurve2 && curveMode2 == ToneCurveMode::PERCEPTUAL) { - const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve2); - userToneCurve.initApplyState (ptc2ApplyState, params->icm.workingProfile); + const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve2); + userToneCurve.initApplyState(ptc2ApplyState, params->icm.workingProfile); } bool hasColorToning = params->colorToning.enabled && bool (ctOpacityCurve) && bool (ctColorCurve) && params->colorToning.method != "LabGrid"; @@ -2351,6 +2356,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } highlightToneCurve(hltonecurve, rtemp, gtemp, btemp, istart, tH, jstart, tW, TS, exp_scale, comp, hlrange); + if (params->toneCurve.black != 0.0) { shadowToneCurve(shtonecurve, rtemp, gtemp, btemp, istart, tH, jstart, tW, TS); } @@ -2402,7 +2408,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float tmpg[4] ALIGNED16; float tmpb[4] ALIGNED16; - for (; j < tW - 3; j+=4, tj+=4) { + for (; j < tW - 3; j += 4, tj += 4) { //brightness/contrast STVF(tmpr[0], tonecurve(LVF(rtemp[ti * TS + tj]))); STVF(tmpg[0], tonecurve(LVF(gtemp[ti * TS + tj]))); @@ -2683,6 +2689,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer else if (params->colorToning.method == "Splitco") { constexpr float reducac = 0.3f; constexpr int mode = 0; + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { const float r = rtemp[ti * TS + tj]; @@ -3113,9 +3120,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer Color::RGB2Lab(&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], &(lab->L[i][jstart]), &(lab->a[i][jstart]), &(lab->b[i][jstart]), toxyz, tW - jstart); } - // if (hasColorToningLabGrid) { - // colorToningLabGrid(lab, jstart, tW, istart, tH, false); - // } + // if (hasColorToningLabGrid) { + // colorToningLabGrid(lab, jstart, tW, istart, tH, false); + // } } else { // black & white // Auto channel mixer needs whole image, so we now copy to tmpImage and close the tiled processing for (int i = istart, ti = 0; i < tH; i++, ti++) { @@ -3494,9 +3501,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { Color::RGB2Lab(tmpImage->r(i), tmpImage->g(i), tmpImage->b(i), lab->L[i], lab->a[i], lab->b[i], toxyz, tW); - // if (hasColorToningLabGrid) { - // colorToningLabGrid(lab, 0, tW, i, i + 1, false); - // } + // if (hasColorToningLabGrid) { + // colorToningLabGrid(lab, 0, tW, i, i + 1, false); + // } } @@ -3511,7 +3518,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } if (sCurveEnabled) { - delete sCurve; + delete sCurve; } if (vCurveEnabled) { @@ -3955,7 +3962,7 @@ void ImProcFunctions::toning2col(float r, float g, float b, float &ro, float &go * @param iplow iphigh [0..1] luminance * @param wp wip 3x3 matrix and inverse conversion rgb XYZ **/ -void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go, float &bo, int algm, int metchrom, int twoc, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, const LUTf & clToningcurve, const LUTf & cl2Toningcurve, float iplow, float iphigh, double wp[3][3], double wip[3][3] ) +void ImProcFunctions::labtoning(float r, float g, float b, float &ro, float &go, float &bo, int algm, int metchrom, int twoc, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, const LUTf & clToningcurve, const LUTf & cl2Toningcurve, float iplow, float iphigh, double wp[3][3], double wip[3][3]) { ro = CLIP(r); go = CLIP(g); @@ -4014,7 +4021,7 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go } -void ImProcFunctions::luminanceCurve (LabImage* lold, LabImage* lnew, const LUTf& curve) +void ImProcFunctions::luminanceCurve(LabImage* lold, LabImage* lnew, const LUTf& curve) { int W = lold->W; @@ -4034,7 +4041,7 @@ void ImProcFunctions::luminanceCurve (LabImage* lold, LabImage* lnew, const LUTf -void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, const LUTf& acurve, const LUTf& bcurve, const LUTf& satcurve, const LUTf& lhskcurve, const LUTf& clcurve, LUTf & curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLCurve) +void ImProcFunctions::chromiLuminanceCurve(PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, const LUTf& acurve, const LUTf& bcurve, const LUTf& satcurve, const LUTf& lhskcurve, const LUTf& clcurve, LUTf & curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLCurve) { int W = lold->W; int H = lold->H; @@ -4069,7 +4076,8 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW // !params->labCurve.enabled. It is ugly, but it's the smallest code // change that I could find //------------------------------------------------------------------------- - class TempParams { + class TempParams + { const ProcParams **p_; const ProcParams *old_; ProcParams tmp_; @@ -4091,11 +4099,13 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW bool pipette_for_colortoning_labregions = editPipette && params->colorToning.enabled && params->colorToning.method == "LabRegions"; + if (!params->labCurve.enabled && pipette_for_colortoning_labregions) { utili = autili = butili = ccutili = cclutili = clcutili = false; tempparams.reset(new TempParams(¶ms)); curve.makeIdentity(); } + //------------------------------------------------------------------------- @@ -4104,6 +4114,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW // fill pipette buffer with zeros to avoid crashes editWhatever->fill(0.f); } + if (params->blackwhite.enabled && !params->colorToning.enabled) { for (int i = 0; i < lnew->H; ++i) { for (int j = 0; j < lnew->W; ++j) { @@ -4111,6 +4122,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW } } } + return; } @@ -4172,7 +4184,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW // if(params->labCurve.avoidclip ){ // parameter to adapt curve C=f(C) to gamut - if (params->icm.workingProfile == "ProPhoto") { + if (params->icm.workingProfile == "ProPhoto") { adjustr = 1.2f; // 1.2 instead 1.0 because it's very rare to have C>170.. } else if (params->icm.workingProfile == "Adobe RGB") { adjustr = 1.8f; @@ -4203,7 +4215,22 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW const bool clut = clcutili; const double rstprotection = 100. - params->labCurve.rstprotection; // Red and Skin Tones Protection // avoid color shift is disabled when bwToning is activated and enabled if gamut is true in colorappearanace - const bool avoidColorShift = (params->labCurve.avoidcolorshift || (params->colorappearance.gamut && params->colorappearance.enabled)) && !bwToning ; + // const bool avoidColorShift = (params->labCurve.avoidcolorshift || (params->colorappearance.gamut && params->colorappearance.enabled)) && !bwToning ; + //const bool avoidColorS = params->labCurve.avoidcolorshift; + int gamutmuns = 0; + + if (params->labCurve.gamutmunselmethod == "NONE") { + gamutmuns = 0; + } else if (params->labCurve.gamutmunselmethod == "LAB") { + gamutmuns = 1; + } else if (params->labCurve.gamutmunselmethod == "XYZ") { + gamutmuns = 2; + } else if (params->labCurve.gamutmunselmethod == "XYZREL") { + gamutmuns = 3; + } else if (params->labCurve.gamutmunselmethod == "MUN") { + gamutmuns = 4; + } + const float protectRed = (float)settings->protectred; const double protectRedH = settings->protectredh; const float protect_red = rtengine::LIM(protectRed, 20.f, 180.f); //default=60 chroma: one can put more or less if necessary...in 'option' 40...160 @@ -4228,17 +4255,17 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW const float scaleConst = 100.0f / 100.1f; - const bool gamutLch = settings->gamutLch; + //const bool gamutLch = settings->gamutLch; const float amountchroma = (float) settings->amchroma; - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.workingProfile); + TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.workingProfile); const double wip[3][3] = { {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params->icm.workingProfile); + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile); const double wp[3][3] = { {wprof[0][0], wprof[0][1], wprof[0][2]}, {wprof[1][0], wprof[1][1], wprof[1][2]}, @@ -4258,12 +4285,12 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW #endif for (int i = 0; i < H; i++) { - if (avoidColorShift) + // if (avoidColorShift) - // only if user activate Lab adjustments - if (autili || butili || ccutili || cclutili || chutili || lhutili || hhutili || clcutili || utili || chromaticity) { - Color::LabGamutMunsell(lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip); - } + // only if user activate Lab adjustments + // if (autili || butili || ccutili || cclutili || chutili || lhutili || hhutili || clcutili || utili || chromaticity) { + // Color::LabGamutMunsell(lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip); + // } #ifdef __SSE2__ @@ -4277,7 +4304,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW av = LVFU(lold->a[i][k]); bv = LVFU(lold->b[i][k]); STVF(HHBuffer[k], xatan2f(bv, av)); - STVF (CCBuffer[k], vsqrtf (SQRV (av) + SQRV (bv)) / c327d68v); + STVF(CCBuffer[k], vsqrtf(SQRV(av) + SQRV(bv)) / c327d68v); } for (; k < W; k++) { @@ -4431,8 +4458,8 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.f * Color::f2xyz (fx) * Color::D50x; - float z_ = 65535.f * Color::f2xyz (fz) * Color::D50z; + float x_ = 65535.f * Color::f2xyz(fx) * Color::D50x; + float z_ = 65535.f * Color::f2xyz(fz) * Color::D50z; float y_ = Lprov1 > Color::epskapf ? 65535.f * fy * fy * fy : 65535.f * Lprov1 / Color::kappaf; float R, G, B; Color::xyz2rgb(x_, y_, z_, R, G, B, wip); @@ -4704,24 +4731,57 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW btmp -= lold->b[i][j]; } - if (avoidColorShift) { - //gamutmap Lch ==> preserve Hue,but a little slower than gamutbdy for high values...and little faster for low values - if (gamutLch) { - float R, G, B; - //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); - lnew->L[i][j] = Lprov1 * 327.68f; - lnew->a[i][j] = 327.68f * Chprov1 * sincosval.y; - lnew->b[i][j] = 327.68f * Chprov1 * sincosval.x; - } else { - //use gamutbdy - //Luv limiter - float Y, u, v; - Color::Lab2Yuv(lnew->L[i][j], atmp, btmp, Y, u, v); - //Yuv2Lab includes gamut restriction map - Color::Yuv2Lab(Y, u, v, lnew->L[i][j], lnew->a[i][j], lnew->b[i][j], wp); + lnew->L[i][j] = Lprov1 * 327.68f; + lnew->a[i][j] = 327.68f * Chprov1 * sincosval.y; + lnew->b[i][j] = 327.68f * Chprov1 * sincosval.x; + + //gamutmap Lch ==> preserve Hue,but a little slower than gamutbdy for high values...and little faster for low values + if (gamutmuns == 1) { + float R, G, B; + //gamut control : Lab values are in gamut + Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); + lnew->L[i][j] = Lprov1 * 327.68f; + lnew->a[i][j] = 327.68f * Chprov1 * sincosval.y; + lnew->b[i][j] = 327.68f * Chprov1 * sincosval.x; + } + + if (gamutmuns == 2 || gamutmuns == 3) { + + float xg, yg, zg; + Color::Lab2XYZ(lnew->L[i][j], atmp, btmp, xg, yg, zg); + float x0 = xg; + float y0 = yg; + float z0 = zg; + + Color::gamutmap(xg, yg, zg, wp); + + if (gamutmuns == 3) {//0.5f arbitrary coeff + xg = xg + 0.5f * (x0 - xg); + yg = yg + 0.5f * (y0 - yg); + zg = zg + 0.5f * (z0 - zg); } + float Lag, aag2, bbg2; + Color::XYZ2Lab(xg, yg, zg, Lag, aag2, bbg2); + Lprov1 = Lag / 327.68f; + HH = xatan2f(bbg2, aag2); + Chprov1 = std::sqrt(SQR(aag2) + SQR(bbg2)) / 327.68f; + + if (Chprov1 == 0.0f) { + sincosval.y = 1.f; + sincosval.x = 0.0f; + } else { + sincosval.y = aag2 / (Chprov1 * 327.68f); + sincosval.x = bbg2 / (Chprov1 * 327.68f); + } + + lnew->L[i][j] = Lprov1 * 327.68f; + lnew->a[i][j] = 327.68f * Chprov1 * sincosval.y; + lnew->b[i][j] = 327.68f * Chprov1 * sincosval.x; + + } + + if (gamutmuns > 0) { if (utili || autili || butili || ccut || clut || cclutili || chutili || lhutili || hhutili || clcutili || chromaticity) { float correctionHue = 0.f; // Munsell's correction float correctlum = 0.f; @@ -4747,7 +4807,10 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW lnew->a[i][j] = 327.68f * Chprov * sincosval.y; // apply Munsell lnew->b[i][j] = 327.68f * Chprov * sincosval.x; } - } else { + } + + if (gamutmuns == 0) { + // if(Lprov1 > maxlp) maxlp=Lprov1; // if(Lprov1 < minlp) minlp=Lprov1; if (!bwToning) { @@ -4940,11 +5003,12 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid if (!params->epd.enabled) { return; } -/* - if (params->wavelet.enabled && params->wavelet.tmrs != 0) { - return; - } -*/ + + /* + if (params->wavelet.enabled && params->wavelet.tmrs != 0) { + return; + } + */ float stren = params->epd.strength; const float edgest = std::min(params->epd.edgeStopping, params->localContrast.enabled ? 3.0 : 4.0); float sca = params->epd.scale; @@ -4954,7 +5018,7 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid float *Qpr = ncie->Q_p[0]; if (settings->verbose) { - printf ("minQ=%f maxQ=%f Qpro=%f\n", static_cast(minQ), static_cast(maxQ), static_cast(Qpro)); + printf("minQ=%f maxQ=%f Qpro=%f\n", static_cast(minQ), static_cast(maxQ), static_cast(Qpro)); } if (maxQ > Qpro) { @@ -4993,6 +5057,7 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,10) #endif + for (int i = 0; i < Hei; i++) for (int j = 0; j < Wid; j++) { ncie->Q_p[i][j] = (ncie->Q_p[i][j] * Qpro) / gamm; @@ -5043,7 +5108,7 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns float stren = ((float)params->locallab.spots.at(sp).stren); const float edgest = std::min(params->locallab.spots.at(sp).estop, params->localContrast.enabled ? 3.0 : 4.0); - + float sca = ((float)params->locallab.spots.at(sp).scaltm); float gamm = ((float)params->locallab.spots.at(sp).gamma); float satur = ((float)params->locallab.spots.at(sp).satur) / 100.f; @@ -5064,6 +5129,7 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns #ifdef _OPENMP #pragma omp parallel for reduction(max:maxL) reduction(min:minL) schedule(dynamic,16) #endif + for (std::size_t i = 0; i < N; i++) { minL = rtengine::min(minL, L[i]); maxL = rtengine::max(maxL, L[i]); @@ -5081,8 +5147,8 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns #ifdef _OPENMP #pragma omp parallel for #endif - for (std::size_t i = 0; i < N; i++) - { + + for (std::size_t i = 0; i < N; i++) { L[i] = (L[i] - minL) * mult; } @@ -5111,8 +5177,12 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf(Compression, 1.5856f) / (1.0f + 38.7889f * powf(Compression, 1.5856f)); float sat = s + 0.3f * s * satur; + //printf("s=%f sat=%f \n", s, sat); - if(sat == 1.f) sat = 1.001f; + if (sat == 1.f) { + sat = 1.001f; + } + #ifdef _OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif @@ -5159,6 +5229,7 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) #ifdef _OPENMP #pragma omp parallel for reduction(min:minL) reduction(max:maxL) #endif + for (size_t i = 1; i < N; i++) { minL = std::min(minL, L[i]); maxL = std::max(maxL, L[i]); @@ -5173,6 +5244,7 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) #ifdef _OPENMP #pragma omp parallel for #endif + for (size_t i = 0; i < N; ++i) { L[i] = (L[i] - minL) * (gamm / maxL); } @@ -5186,7 +5258,7 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) Iterates = edgest * 15.f; } - epd.CompressDynamicRange (L, sca / skip, edgest, Compression, DetailBoost, Iterates, rew); + epd.CompressDynamicRange(L, sca / skip, edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. const float s = (1.f + 38.7889f) * std::pow(Compression, 1.5856f) / (1.f + 38.7889f * std::pow(Compression, 1.5856f)); @@ -5195,6 +5267,7 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) #ifdef _OPENMP #pragma omp parallel for #endif + for (size_t ii = 0; ii < N; ++ii) { a[ii] *= s; b[ii] *= s; @@ -5242,7 +5315,7 @@ void ImProcFunctions::getAutoExp(const LUTu &histogram, int histcompr, double cl int j = 0; - for (; j < min ((int)ave, imax); ++j) { + for (; j < min((int)ave, imax); ++j) { if (count < 8) { octile[count] += histogram[j]; @@ -5335,7 +5408,7 @@ void ImProcFunctions::getAutoExp(const LUTu &histogram, int histcompr, double cl } //compute clipped white point - unsigned int clippable = (int) (static_cast(sum) * clip / 100.0 ); + unsigned int clippable = (int)(static_cast(sum) * clip / 100.0); clipped = 0; int whiteclip = (imax) - 1; @@ -5414,7 +5487,7 @@ void ImProcFunctions::getAutoExp(const LUTu &histogram, int histcompr, double cl contr = (int) 50.0f * (1.1f - ospread); contr = max(0, min(100, contr)); //take gamma into account - double whiteclipg = (int) (CurveFactory::gamma2(whiteclip * static_cast(corr) / 65536.0) * 65536.0); + double whiteclipg = (int)(CurveFactory::gamma2(whiteclip * static_cast(corr) / 65536.0) * 65536.0); float gavg = 0.; @@ -5594,7 +5667,8 @@ void ImProcFunctions::rgb2lab(const Imagefloat &src, LabImage &dst, const Glib:: } void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, float L[], float a[], float b[], const procparams::ColorManagementParams &icm, bool consider_histogram_settings) const -{ // Adapted from ImProcFunctions::lab2rgb +{ + // Adapted from ImProcFunctions::lab2rgb const int src_width = src.getWidth(); const int src_height = src.getHeight(); @@ -5626,6 +5700,7 @@ void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, flo if (icm.outputProfile.empty() || icm.outputProfile == ColorManagementParams::NoICMString) { profile = "sRGB"; } + oprof = ICCStore::getInstance()->getProfile(profile); } @@ -5638,7 +5713,7 @@ void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, flo lcmsMutex->lock(); cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr); - cmsHTRANSFORM hTransform = cmsCreateTransform (oprof, TYPE_RGB_8, LabIProf, TYPE_Lab_FLT, icm.outputIntent, flags); + cmsHTRANSFORM hTransform = cmsCreateTransform(oprof, TYPE_RGB_8, LabIProf, TYPE_Lab_FLT, icm.outputIntent, flags); cmsCloseProfile(LabIProf); lcmsMutex->unlock(); @@ -5662,7 +5737,7 @@ void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, flo float* ra = a + (i - y) * w; float* rb = b + (i - y) * w; - cmsDoTransform (hTransform, src.data + ix, outbuffer, w); + cmsDoTransform(hTransform, src.data + ix, outbuffer, w); for (int j = 0; j < w; j++) { rL[j] = outbuffer[iy++] * 327.68f; @@ -5691,6 +5766,7 @@ void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, flo for (int i = y; i < y2; i++) { int offset = (i - y) * w; + for (int j = x; j < x2; j++) { float X, Y, Z; // lab2rgb uses gamma2curve, which is gammatab_srgb. @@ -5782,7 +5858,7 @@ void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, in float b_scale = (params->colorToning.labgridBHigh - params->colorToning.labgridBLow) / factor / scaling; float b_base = params->colorToning.labgridBLow / scaling; - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for if (MultiThread) #endif diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 1be1d0371..36c571291 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -257,7 +257,7 @@ enum class BlurType { int shortcu, bool delt, const float hueref, const float chromaref, const float lumaref, float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, bool fftt, float blu_ma, float cont_ma, int indic, float &fab); - void avoidcolshi(const struct local_params& lp, int sp, LabImage * original, LabImage *transformed, int cy, int cx, int sk); + void avoidcolshi(const struct local_params& lp, int sp, LabImage *transformed, LabImage *reserved, int cy, int cx, int sk); void deltaEforMask(float **rdE, int bfw, int bfh, LabImage* bufcolorig, const float hueref, const float chromaref, const float lumaref, float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh); diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index f48b2e52e..dd02b8f0f 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -416,6 +416,8 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, { const TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile); + double wprofprim[3][3];//store primaries to XYZ + bool gamutcontrol = params->icm.gamut; const float toxyz[3][3] = { { static_cast(wprof[0][0] / ((normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50x @@ -440,57 +442,64 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, if (settings->verbose) { printf("profile not accepted\n"); } + return; } if (mul == -5 && gampos == 2.4 && slpos == 12.92310) {//must be change if we change settings RT sRGB //only in this case we can shortcut..all process..no gamut control..because we reduce...leads to very small differences, but big speedup #ifdef _OPENMP - #pragma omp parallel for schedule(dynamic, 16) if (multiThread) + #pragma omp parallel for schedule(dynamic, 16) if (multiThread) #endif - for (int i = 0; i < ch; ++i) - for (int j = 0; j < cw; ++j) { - float r = src->r(i, j); - float g = src->g(i, j); - float b = src->b(i, j); - r = (Color::igammatab_srgb[r]) / 65535.f; - g = (Color::igammatab_srgb[g]) / 65535.f; - b = (Color::igammatab_srgb[b]) / 65535.f; - dst->r(i, j) = r; - dst->g(i, j) = g; - dst->b(i, j) = b; - } - return; + for (int i = 0; i < ch; ++i) + for (int j = 0; j < cw; ++j) { + float r = src->r(i, j); + float g = src->g(i, j); + float b = src->b(i, j); + r = (Color::igammatab_srgb[r]) / 65535.f; + g = (Color::igammatab_srgb[g]) / 65535.f; + b = (Color::igammatab_srgb[b]) / 65535.f; + dst->r(i, j) = r; + dst->g(i, j) = g; + dst->b(i, j) = b; + } + + return; } - - if (mul == 1 ||(params->icm.wprim == ColorManagementParams::Primaries::DEFAULT && params->icm.will == ColorManagementParams::Illuminant::DEFAULT)) {//shortcut and speedup when no call primaries and illuminant - no gamut control...in this case be careful + + if (mul == 1 || (params->icm.wprim == ColorManagementParams::Primaries::DEFAULT && params->icm.will == ColorManagementParams::Illuminant::DEFAULT)) { //shortcut and speedup when no call primaries and illuminant - no gamut control...in this case be careful GammaValues g_a; //gamma parameters double pwr = 1.0 / static_cast(gampos); Color::calcGamma(pwr, slpos, g_a); // call to calcGamma with selected gamma and slope #ifdef _OPENMP -# pragma omp parallel for schedule(dynamic,16) if (multiThread) + # pragma omp parallel for schedule(dynamic,16) if (multiThread) #endif + for (int y = 0; y < ch; ++y) { int x = 0; #ifdef __SSE2__ + for (; x < cw - 3; x += 4) { - STVFU(dst->r(y,x), F2V(65536.f) * gammalog(LVFU(src->r(y,x)), F2V(gampos), F2V(slpos), F2V(g_a[3]), F2V(g_a[4]))); - STVFU(dst->g(y,x), F2V(65536.f) * gammalog(LVFU(src->g(y,x)), F2V(gampos), F2V(slpos), F2V(g_a[3]), F2V(g_a[4]))); - STVFU(dst->b(y,x), F2V(65536.f) * gammalog(LVFU(src->b(y,x)), F2V(gampos), F2V(slpos), F2V(g_a[3]), F2V(g_a[4]))); - } + STVFU(dst->r(y, x), F2V(65536.f) * gammalog(LVFU(src->r(y, x)), F2V(gampos), F2V(slpos), F2V(g_a[3]), F2V(g_a[4]))); + STVFU(dst->g(y, x), F2V(65536.f) * gammalog(LVFU(src->g(y, x)), F2V(gampos), F2V(slpos), F2V(g_a[3]), F2V(g_a[4]))); + STVFU(dst->b(y, x), F2V(65536.f) * gammalog(LVFU(src->b(y, x)), F2V(gampos), F2V(slpos), F2V(g_a[3]), F2V(g_a[4]))); + } + #endif + for (; x < cw; ++x) { - dst->r(y,x) = 65536.f * gammalog(src->r(y,x), gampos, slpos, g_a[3], g_a[4]); - dst->g(y,x) = 65536.f * gammalog(src->g(y,x), gampos, slpos, g_a[3], g_a[4]); - dst->b(y,x) = 65536.f * gammalog(src->b(y,x), gampos, slpos, g_a[3], g_a[4]); + dst->r(y, x) = 65536.f * gammalog(src->r(y, x), gampos, slpos, g_a[3], g_a[4]); + dst->g(y, x) = 65536.f * gammalog(src->g(y, x), gampos, slpos, g_a[3], g_a[4]); + dst->b(y, x) = 65536.f * gammalog(src->b(y, x), gampos, slpos, g_a[3], g_a[4]); } } + return; } - + float redxx = params->icm.redx; float redyy = params->icm.redy; @@ -498,6 +507,7 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, float bluyy = params->icm.bluy; float grexx = params->icm.grex; float greyy = params->icm.grey; + float epsil = 0.0001f; if (prim == 12) {//convert datas area to xy float redgraphx = params->icm.labgridcieALow; @@ -519,11 +529,34 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, greyy = 0.55f * (gregraphy + 1.f) - 0.1f; greyy = rtengine::LIM(greyy, 0.5f, 1.f); } + //fixed crash when there is no space or too small..just a line...Possible if bx, by aligned with Gx,Gy Rx,Ry - float ac = (greyy - redyy) / (grexx - redxx); + //fix crash if user select 0 for redyy, bluyy, greyy + if (redyy == 0.f) { + redyy = epsil; + } + + if (bluyy == 0.f) { + bluyy = epsil; + } + + if (greyy == 0.f) { + greyy = epsil; + } + + //fix crash if grexx - redxx = 0 + float grered = 1.f; + grered = grexx - redxx; + + if (grered == 0.f) { + grered = epsil; + } + + float ac = (greyy - redyy) / grered; float bc = greyy - ac * grexx; float yc = ac * bluxx + bc; - if ((bluyy < yc + 0.0004f) && (bluyy > yc - 0.0004f)) {//under 0.0004 in some case crash because space too small + + if ((bluyy < yc + 0.0004f) && (bluyy > yc - 0.0004f)) { //under 0.0004 in some case crash because space too small return; } @@ -564,7 +597,6 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, } case ColorManagementParams::Primaries::ACES_P0: { - profile = "ACESp0"; break; } @@ -593,11 +625,13 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, break; } } - - if (settings->verbose && prim != 0) { - printf("prim=%i Profile Destination=%s\n", prim, profile.c_str()); - } + + if (settings->verbose && prim != 0) { + printf("prim=%i Profile Destination=%s\n", prim, profile.c_str()); + } + cmsHTRANSFORM hTransform = nullptr; + if (transform) { hTransform = transform; } else { @@ -622,7 +656,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, }; double tempv4 = 5003.; - float p[6]; //primaries + double p[6]; //primaries + double Wx = 1.0; + double Wz = 1.0; //primaries for 10 working profiles ==> output profiles if (profile == "WideGamut") { @@ -633,6 +669,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[4] = 0.1570; p[5] = 0.0180; illum = toUnderlying(ColorManagementParams::Illuminant::D50); + Wx = 0.964295676; + Wz = 0.825104603; + } else if (profile == "Adobe RGB") { p[0] = 0.6400; //Adobe primaries p[1] = 0.3300; @@ -642,6 +681,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[5] = 0.0600; tempv4 = 6504.; illum = toUnderlying(ColorManagementParams::Illuminant::D65); + Wx = 0.95045471; + Wz = 1.08905029; + } else if (profile == "sRGB") { p[0] = 0.6400; // sRGB primaries p[1] = 0.3300; @@ -651,6 +693,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[5] = 0.0600; tempv4 = 6504.; illum = toUnderlying(ColorManagementParams::Illuminant::D65); + Wx = 0.95045471; + Wz = 1.08905029; + } else if (profile == "BruceRGB") { p[0] = 0.6400; // Bruce primaries p[1] = 0.3300; @@ -660,7 +705,10 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[5] = 0.0600; tempv4 = 6504.; illum = toUnderlying(ColorManagementParams::Illuminant::D65); - } else if (profile == "Beta RGB") { + Wx = 0.95045471; + Wz = 1.08905029; + + } else if (profile == "Beta RGB") { p[0] = 0.6888; // Beta primaries p[1] = 0.3112; p[2] = 0.1986; @@ -668,6 +716,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[4] = 0.1265; p[5] = 0.0352; illum = toUnderlying(ColorManagementParams::Illuminant::D50); + Wx = 0.964295676; + Wz = 0.825104603; + } else if (profile == "BestRGB") { p[0] = 0.7347; // Best primaries p[1] = 0.2653; @@ -676,6 +727,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[4] = 0.1300; p[5] = 0.0350; illum = toUnderlying(ColorManagementParams::Illuminant::D50); + Wx = 0.964295676; + Wz = 0.825104603; + } else if (profile == "Rec2020") { p[0] = 0.7080; // Rec2020 primaries p[1] = 0.2920; @@ -685,6 +739,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[5] = 0.0460; tempv4 = 6504.; illum = toUnderlying(ColorManagementParams::Illuminant::D65); + Wx = 0.95045471; + Wz = 1.08905029; + } else if (profile == "ACESp0") { p[0] = 0.7347; // ACES P0 primaries p[1] = 0.2653; @@ -694,6 +751,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[5] = -0.0770; tempv4 = 6004.; illum = toUnderlying(ColorManagementParams::Illuminant::D60); + Wx = 0.952646075; + Wz = 1.008825184; + } else if (profile == "ACESp1") { p[0] = 0.713; // ACES P1 primaries p[1] = 0.293; @@ -703,6 +763,9 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[5] = 0.044; tempv4 = 6004.; illum = toUnderlying(ColorManagementParams::Illuminant::D60); + Wx = 0.952646075; + Wz = 1.008825184; + } else if (profile == "ProPhoto") { p[0] = 0.7347; //ProPhoto and default primaries p[1] = 0.2653; @@ -711,8 +774,11 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, p[4] = 0.0366; p[5] = 0.0001; illum = toUnderlying(ColorManagementParams::Illuminant::D50); + Wx = 0.964295676; + Wz = 0.825104603; + } else if (profile == "Custom") { - p[0] = redxx; + p[0] = redxx; p[1] = redyy; p[2] = grexx; p[3] = greyy; @@ -743,11 +809,13 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, gammaParams[3] = 1. / slpos; gammaParams[5] = 0.0; gammaParams[6] = 0.0; - // printf("ga0=%f ga1=%f ga2=%f ga3=%f ga4=%f\n", ga0, ga1, ga2, ga3, ga4); + // printf("ga0=%f ga1=%f ga2=%f ga3=%f ga4=%f\n", ga0, ga1, ga2, ga3, ga4); // 7 parameters for smoother curves cmsCIExyY xyD; + Glib::ustring ills = "D50"; + switch (ColorManagementParams::Illuminant(illum)) { case ColorManagementParams::Illuminant::DEFAULT: case ColorManagementParams::Illuminant::STDA: @@ -802,55 +870,95 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, cmsWhitePointFromTemp(&xyD, tempv4); switch (ColorManagementParams::Illuminant(illum)) { - case ColorManagementParams::Illuminant::DEFAULT: - case ColorManagementParams::Illuminant::D55: + case ColorManagementParams::Illuminant::DEFAULT: { + break; + } + + case ColorManagementParams::Illuminant::D55: { + Wx = 0.956565934; + Wz = 0.920253249; + break; + } + case ColorManagementParams::Illuminant::D80: { + Wx = 0.950095542; + Wz = 1.284213976; break; } case ColorManagementParams::Illuminant::D41: { + Wx = 0.991488263; + Wz = 0.631604625; break; } case ColorManagementParams::Illuminant::D50: { xyD = {0.3457, 0.3585, 1.0}; // near LCMS values but not perfect... it's a compromise!! + Wx = 0.964295676; + Wz = 0.825104603; break; } case ColorManagementParams::Illuminant::D60: { + Wx = 0.952646075; + Wz = 1.008825184; xyD = {0.32168, 0.33767, 1.0}; break; } case ColorManagementParams::Illuminant::D65: { + Wx = 0.95045471; + Wz = 1.08905029; xyD = {0.312700492, 0.329000939, 1.0}; break; } case ColorManagementParams::Illuminant::D120: { + Wx = 0.979182; + Wz = 1.623623; xyD = {0.269669, 0.28078, 1.0}; break; } case ColorManagementParams::Illuminant::STDA: { + Wx = 1.098500393; + Wz = 0.355848714; xyD = {0.447573, 0.407440, 1.0}; ills = "stdA 2875K"; break; } case ColorManagementParams::Illuminant::TUNGSTEN_2000K: { + Wx = 1.274335; + Wz = 0.145233; xyD = {0.526591, 0.41331, 1.0}; ills = "Tungsten 2000K"; break; } case ColorManagementParams::Illuminant::TUNGSTEN_1500K: { + Wx = 1.489921; + Wz = 0.053826; xyD = {0.585703, 0.393157, 1.0}; ills = "Tungsten 1500K"; break; } } + double wprofpri[9]; + + if (gamutcontrol) { + //xyz in functiuon primaries and illuminant + Color::primaries_to_xyz(p, Wx, Wz, wprofpri); + + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + wprofprim[i][j] = (double) wprofpri[j * 3 + i]; + //xyz in TMatrix format + } + } + } + //D41 0.377984 0.381229 //D55 0.332424 0.347426 //D80 0.293755 0.309185 @@ -869,7 +977,7 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, cmsWriteTag(oprofdef, cmsSigGreenTRCTag, GammaTRC[1]); cmsWriteTag(oprofdef, cmsSigBlueTRCTag, GammaTRC[2]); - //to read XYZ values and illuminant + //to read XYZ values and illuminant if (rtengine::settings->verbose) { cmsCIEXYZ *redT = static_cast(cmsReadTag(oprofdef, cmsSigRedMatrixColumnTag)); cmsCIEXYZ *greenT = static_cast(cmsReadTag(oprofdef, cmsSigGreenMatrixColumnTag)); @@ -881,6 +989,7 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, } cmsFreeToneCurve(GammaTRC[0]); + if (oprofdef) { constexpr cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE | cmsFLAGS_BLACKPOINTCOMPENSATION | cmsFLAGS_GAMUTCHECK; const cmsHPROFILE iprof = ICCStore::getInstance()->getXYZProfile(); @@ -889,7 +998,10 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, lcmsMutex->unlock(); } } + if (hTransform) { + + #ifdef _OPENMP #pragma omp parallel if (multiThread) #endif @@ -901,19 +1013,30 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, #pragma omp for schedule(dynamic, 16) nowait #endif - for (int i = 0; i < ch; ++i) { + for (int i = 0; i < ch; ++i) + { float *p = pBuf.data; + for (int j = 0; j < cw; ++j) { const float r = src->r(i, j); const float g = src->g(i, j); const float b = src->b(i, j); + float X = toxyz[0][0] * r + toxyz[0][1] * g + toxyz[0][2] * b; + float Y = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; + float Z = toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b; - *(p++) = toxyz[0][0] * r + toxyz[0][1] * g + toxyz[0][2] * b; - *(p++) = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; - *(p++) = toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b; + if (gamutcontrol) { + Color::gamutmap(X, Y, Z, wprofprim);//gamut control + } + + *(p++) = X; + *(p++) = Y; + *(p++) = Z; } + p = pBuf.data; cmsDoTransform(hTransform, p, p, cw); + for (int j = 0; j < cw; ++j) { dst->r(i, j) = *(p++) * normalize; dst->g(i, j) = *(p++) * normalize; @@ -921,10 +1044,12 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, } } } + if (!keepTransForm) { cmsDeleteTransform(hTransform); hTransform = nullptr; } + transform = hTransform; } } diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 62f211ae6..bdc1b6db1 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -12540,12 +12540,31 @@ void ImProcFunctions::clarimerge(const struct local_params& lp, float &mL, float } } -void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImage * original, LabImage *transformed, int cy, int cx, int sk) +void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImage *transformed, LabImage *reserved, int cy, int cx, int sk) { - if (params->locallab.spots.at(sp).avoid && lp.islocal) { + int avoidgamut = 0; + + if (params->locallab.spots.at(sp).avoidgamutMethod == "NONE") { + avoidgamut = 0; + } else if (params->locallab.spots.at(sp).avoidgamutMethod == "LAB") { + avoidgamut = 1; + } else if (params->locallab.spots.at(sp).avoidgamutMethod == "XYZ") { + avoidgamut = 2; + } else if (params->locallab.spots.at(sp).avoidgamutMethod == "XYZREL") { + avoidgamut = 3; + } else if (params->locallab.spots.at(sp).avoidgamutMethod == "MUNS") { + avoidgamut = 4; + } + + if (avoidgamut == 0) { + return; + } + + if (avoidgamut > 0 && lp.islocal) { const float ach = lp.trans / 100.f; bool execmunsell = true; - if(params->locallab.spots.at(sp).expcie && (params->locallab.spots.at(sp).modecam == "all" || params->locallab.spots.at(sp).modecam == "jz" || params->locallab.spots.at(sp).modecam == "cam16")) { + + if (params->locallab.spots.at(sp).expcie && (params->locallab.spots.at(sp).modecam == "all" || params->locallab.spots.at(sp).modecam == "jz" || params->locallab.spots.at(sp).modecam == "cam16")) { execmunsell = false; } @@ -12556,11 +12575,18 @@ void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImag {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile); + const double wp[3][3] = {//improve precision with double + {wprof[0][0], wprof[0][1], wprof[0][2]}, + {wprof[1][0], wprof[1][1], wprof[1][2]}, + {wprof[2][0], wprof[2][1], wprof[2][2]} + }; + const float softr = params->locallab.spots.at(sp).avoidrad;//max softr = 30 - const bool muns = params->locallab.spots.at(sp).avoidmun;//Munsell control with 200 LUT + // const bool muns = params->locallab.spots.at(sp).avoidmun;//Munsell control with 200 LUT //improve precision with mint and maxt const float tr = std::min(2.f, softr); - const float mint = 0.15f - 0.06f * tr;//between 0.15f and 0.03f + const float mint = 0.15f - 0.06f * tr;//between 0.15f and 0.03f const float maxt = 0.98f + 0.008f * tr;//between 0.98f and 0.996f const bool highlight = params->toneCurve.hrenabled; @@ -12581,6 +12607,7 @@ void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImag #ifdef _OPENMP #pragma omp for schedule(dynamic,16) #endif + for (int y = 0; y < transformed->H; y++) { const int loy = cy + y; const bool isZone0 = loy > lp.yc + lp.ly || loy < lp.yc - lp.lyT; // whole line is zone 0 => we can skip a lot of processing @@ -12640,7 +12667,7 @@ void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImag if (lp.shapmet == 0) { calcTransition(lox, loy, ach, lp, zone, localFactor); - } else /*if (lp.shapmet == 1)*/ { + } else { /*if (lp.shapmet == 1)*/ calcTransitionrect(lox, loy, ach, lp, zone, localFactor); } @@ -12675,42 +12702,103 @@ void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImag sincosval.y = aa / (Chprov1 * 327.68f); sincosval.x = bb / (Chprov1 * 327.68f); } + #endif + float lnew = transformed->L[y][x]; + float anew = transformed->a[y][x]; + float bnew = transformed->b[y][x]; + Lprov1 = lnew / 327.68f; + //HH = xatan2f(bnew, anew); - Color::pregamutlab(Lprov1, HH, chr); - Chprov1 = rtengine::min(Chprov1, chr); - if(!muns) { - float R, G, B; + if (avoidgamut == 1) { //Lab correction + + Color::pregamutlab(Lprov1, HH, chr); + Chprov1 = rtengine::min(Chprov1, chr); + + float R, G, B; Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, mint, maxt);//replace for best results - } - transformed->L[y][x] = Lprov1 * 327.68f; - transformed->a[y][x] = 327.68f * Chprov1 * sincosval.y; - transformed->b[y][x] = 327.68f * Chprov1 * sincosval.x; + lnew = Lprov1 * 327.68f; + anew = 327.68f * Chprov1 * sincosval.y; + bnew = 327.68f * Chprov1 * sincosval.x; + //HH = xatan2f(bnew, anew); + transformed->a[y][x] = anew; + transformed->b[y][x] = bnew; - if (needHH) { - const float Lprov2 = original->L[y][x] / 327.68f; + } else if (avoidgamut == 2 || avoidgamut == 3) { //XYZ correction + float xg, yg, zg; + const float aag = transformed->a[y][x];//anew + const float bbg = transformed->b[y][x];//bnew + float Lag = transformed->L[y][x]; + + Color::Lab2XYZ(Lag, aag, bbg, xg, yg, zg); + float x0 = xg; + float y0 = yg; + float z0 = zg; + + Color::gamutmap(xg, yg, zg, wp); + + if (avoidgamut == 3) {//0.5f arbitrary coeff + xg = xg + 0.5f * (x0 - xg); + yg = yg + 0.5f * (y0 - yg); + zg = zg + 0.5f * (z0 - zg); + } + + //Color::gamutmap(xg, yg, zg, wp);//Put XYZ in gamut wp + float aag2, bbg2; + Color::XYZ2Lab(xg, yg, zg, Lag, aag2, bbg2); + Lprov1 = Lag / 327.68f; + HH = xatan2f(bbg2, aag2);//rebuild HH in case of...absolute colorimetry + Chprov1 = std::sqrt(SQR(aag2) + SQR(bbg2)) / 327.68f; + + if (Chprov1 == 0.0f) { + sincosval.y = 1.f; + sincosval.x = 0.0f; + } else { + sincosval.y = aag2 / (Chprov1 * 327.68f); + sincosval.x = bbg2 / (Chprov1 * 327.68f); + } + + lnew = Lprov1 * 327.68f; + anew = 327.68f * Chprov1 * sincosval.y; + bnew = 327.68f * Chprov1 * sincosval.x; + transformed->a[y][x] = anew; + transformed->b[y][x] = bnew; + + } + + if (needHH && avoidgamut <= 4) {//Munsell + Lprov1 = lnew / 327.68f; + float Chprov = sqrt(SQR(anew) + SQR(bnew)) / 327.68f; + + const float Lprov2 = reserved->L[y][x] / 327.68f; float correctionHue = 0.f; // Munsell's correction float correctlum = 0.f; - const float memChprov = std::sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])) / 327.68f; - float Chprov = std::sqrt(SQR(transformed->a[y][x]) + SQR(transformed->b[y][x])) / 327.68f; - if(execmunsell) { + const float memChprov = std::sqrt(SQR(reserved->a[y][x]) + SQR(reserved->b[y][x])) / 327.68f; + + if (execmunsell) { Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum); } - if (std::fabs(correctionHue) < 0.015f) { - HH += correctlum; // correct only if correct Munsell chroma very small. + if (correctionHue != 0.f || correctlum != 0.f) { + + if (std::fabs(correctionHue) < 0.015f) { + HH += correctlum; // correct only if correct Munsell chroma very small. + } + + sincosval = xsincosf(HH + correctionHue); } - sincosval = xsincosf(HH + correctionHue); - transformed->a[y][x] = 327.68f * Chprov * sincosval.y; // apply Munsell - transformed->b[y][x] = 327.68f * Chprov * sincosval.x; + anew = 327.68f * Chprov * sincosval.y; // apply Munsell + bnew = 327.68f * Chprov * sincosval.x; + transformed->a[y][x] = anew; // apply Munsell + transformed->b[y][x] = bnew; } } } } - //Guidedfilter to reduce artifacts in transitions - if (softr != 0.f) {//soft for L a b because we change color... + //Guidedfilter to reduce artifacts in transitions : case Lab + if (softr != 0.f && avoidgamut == 1) {//soft for L a b because we change color... const float tmpblur = softr < 0.f ? -1.f / softr : 1.f + softr; const int r1 = rtengine::max(6 / sk * tmpblur + 0.5f, 1); const int r2 = rtengine::max(10 / sk * tmpblur + 0.5f, 1); @@ -12734,13 +12822,15 @@ void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImag for (int y = 0; y < bh ; y++) { for (int x = 0; x < bw; x++) { ble[y][x] = transformed->L[y][x] / 32768.f; - guid[y][x] = original->L[y][x] / 32768.f; + guid[y][x] = reserved->L[y][x] / 32768.f; } } + rtengine::guidedFilter(guid, ble, ble, r2, 0.2f * epsil, multiThread); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) if (multiThread) #endif + for (int y = 0; y < bh; y++) { for (int x = 0; x < bw; x++) { transformed->L[y][x] = 32768.f * ble[y][x]; @@ -12757,11 +12847,13 @@ void ImProcFunctions::avoidcolshi(const struct local_params& lp, int sp, LabImag blechro[y][x] = std::sqrt(SQR(transformed->b[y][x]) + SQR(transformed->a[y][x])) / 32768.f; } } + rtengine::guidedFilter(guid, blechro, blechro, r1, epsil, multiThread); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) if (multiThread) #endif + for (int y = 0; y < bh; y++) { for (int x = 0; x < bw; x++) { const float Chprov1 = std::sqrt(SQR(transformed->a[y][x]) + SQR(transformed->b[y][x])); @@ -13286,7 +13378,7 @@ void ImProcFunctions::Lab_Local( struct local_params lp; calcLocalParams(sp, oW, oH, params->locallab, lp, prevDeltaE, llColorMask, llColorMaskinv, llExpMask, llExpMaskinv, llSHMask, llSHMaskinv, llvibMask, lllcMask, llsharMask, llcbMask, llretiMask, llsoftMask, lltmMask, llblMask, lllogMask, ll_Mask, llcieMask, locwavCurveden, locwavdenutili); - avoidcolshi(lp, sp, original, transformed, cy, cx, sk); + //avoidcolshi(lp, sp, transformed, reserved, cy, cx, sk); const float radius = lp.rad / (sk * 1.4); //0 to 70 ==> see skip int levred; @@ -19188,7 +19280,7 @@ void ImProcFunctions::Lab_Local( // Gamut and Munsell control - very important do not deactivated to avoid crash - avoidcolshi(lp, sp, original, transformed, cy, cx, sk); + avoidcolshi(lp, sp, transformed, reserved, cy, cx, sk); } } diff --git a/rtengine/procevents.h b/rtengine/procevents.h index a83419559..13df614dc 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -137,7 +137,7 @@ enum ProcEventCode { EvHLComprThreshold = 107, EvResizeBoundingBox = 108, EvResizeAppliesTo = 109, - EvLAvoidColorShift = 110, + //EvLAvoidColorShift = 110, obsolete_111 = 111, // obsolete EvLRSTProtection = 112, EvDemosaicDCBIter = 113, @@ -617,7 +617,7 @@ enum ProcEventCode { Evlocallabadjblur = 587, Evlocallabbilateral = 588, Evlocallabsensiden = 589, - Evlocallabavoid = 590, + // Evlocallabavoid = 590, Evlocallabsharcontrast = 591, EvLocenacontrast = 592, Evlocallablcradius = 593, @@ -1067,7 +1067,7 @@ enum ProcEventCode { Evlocallabnlgam = 1037, Evlocallabdivgr = 1038, EvLocallabSpotavoidrad = 1039, - EvLocallabSpotavoidmun = 1040, + //EvLocallabSpotavoidmun = 1040, Evlocallabcontthres = 1041, Evlocallabnorm = 1042, Evlocallabreparw = 1043, diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index c9c420b44..e6bdc9619 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -608,7 +608,7 @@ LCurveParams::LCurveParams() : brightness(0), contrast(0), chromaticity(0), - avoidcolorshift(false), + gamutmunselmethod("MUN"), rstprotection(0), lcredsk(true) { @@ -630,7 +630,7 @@ bool LCurveParams::operator ==(const LCurveParams& other) const && brightness == other.brightness && contrast == other.contrast && chromaticity == other.chromaticity - && avoidcolorshift == other.avoidcolorshift + && gamutmunselmethod == other.gamutmunselmethod && rstprotection == other.rstprotection && lcredsk == other.lcredsk; } @@ -1461,8 +1461,7 @@ ColorAppearanceParams::ColorAppearanceParams() : ybout(18), greenout(1.0), tempsc(5003), - greensc(1.0), - presetcat02(false) + greensc(1.0) { } @@ -1512,8 +1511,7 @@ bool ColorAppearanceParams::operator ==(const ColorAppearanceParams& other) cons && ybout == other.ybout && greenout == other.greenout && tempsc == other.tempsc - && greensc == other.greensc - && presetcat02 == other.presetcat02; + && greensc == other.greensc; } bool ColorAppearanceParams::operator !=(const ColorAppearanceParams& other) const @@ -2278,6 +2276,7 @@ ColorManagementParams::ColorManagementParams() : bluy(0.0001), preser(0.), fbw(false), + gamut(false), labgridcieALow(0.51763),//Prophoto red = (0.7347+0.1) * 1.81818 - 1 labgridcieBLow(-0.33582), labgridcieAHigh(-0.75163),//Prophoto blue @@ -2324,6 +2323,7 @@ bool ColorManagementParams::operator ==(const ColorManagementParams& other) cons && labgridcieWy == other.labgridcieWy && preser == other.preser && fbw == other.fbw + && gamut == other.gamut && aRendIntent == other.aRendIntent && outputProfile == other.outputProfile && outputIntent == other.outputIntent @@ -2848,6 +2848,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : structexclu(0), struc(4.0), shapeMethod("IND"), + avoidgamutMethod("MUNS"), loc{150, 150, 150, 150}, centerX(0), centerY(0), @@ -2862,13 +2863,11 @@ LocallabParams::LocallabSpot::LocallabSpot() : balanh(1.0), colorde(5.0), colorscope(30.0), - avoidrad(0.7), + avoidrad(0.), transitweak(1.0), transitgrad(0.0), hishow(false), activ(true), - avoid(false), - avoidmun(false), blwh(false), recurs(false), laplac(true), @@ -4560,6 +4559,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && structexclu == other.structexclu && struc == other.struc && shapeMethod == other.shapeMethod + && avoidgamutMethod == other.avoidgamutMethod && loc == other.loc && centerX == other.centerX && centerY == other.centerY @@ -4579,8 +4579,6 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && transitgrad == other.transitgrad && hishow == other.hishow && activ == other.activ - && avoid == other.avoid - && avoidmun == other.avoidmun && blwh == other.blwh && recurs == other.recurs && laplac == other.laplac @@ -6045,7 +6043,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->labCurve.brightness, "Luminance Curve", "Brightness", labCurve.brightness, keyFile); saveToKeyfile(!pedited || pedited->labCurve.contrast, "Luminance Curve", "Contrast", labCurve.contrast, keyFile); saveToKeyfile(!pedited || pedited->labCurve.chromaticity, "Luminance Curve", "Chromaticity", labCurve.chromaticity, keyFile); - saveToKeyfile(!pedited || pedited->labCurve.avoidcolorshift, "Luminance Curve", "AvoidColorShift", labCurve.avoidcolorshift, keyFile); + saveToKeyfile(!pedited || pedited->labCurve.gamutmunselmethod, "Luminance Curve", "Gamutmunse", labCurve.gamutmunselmethod, keyFile); saveToKeyfile(!pedited || pedited->labCurve.rstprotection, "Luminance Curve", "RedAndSkinTonesProtection", labCurve.rstprotection, keyFile); saveToKeyfile(!pedited || pedited->labCurve.lcredsk, "Luminance Curve", "LCredsk", labCurve.lcredsk, keyFile); saveToKeyfile(!pedited || pedited->labCurve.lcurve, "Luminance Curve", "LCurve", labCurve.lcurve, keyFile); @@ -6146,7 +6144,6 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->colorappearance.ybout, "Color appearance", "Ybout", colorappearance.ybout, keyFile); saveToKeyfile(!pedited || pedited->colorappearance.datacie, "Color appearance", "Datacie", colorappearance.datacie, keyFile); saveToKeyfile(!pedited || pedited->colorappearance.tonecie, "Color appearance", "Tonecie", colorappearance.tonecie, keyFile); - saveToKeyfile(!pedited || pedited->colorappearance.presetcat02, "Color appearance", "Presetcat02", colorappearance.presetcat02, keyFile); const std::map ca_mapping = { {ColorAppearanceParams::TcMode::LIGHT, "Lightness"}, @@ -6348,6 +6345,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || spot_edited->structexclu, "Locallab", "StructExclu_" + index_str, spot.structexclu, keyFile); saveToKeyfile(!pedited || spot_edited->struc, "Locallab", "Struc_" + index_str, spot.struc, keyFile); saveToKeyfile(!pedited || spot_edited->shapeMethod, "Locallab", "ShapeMethod_" + index_str, spot.shapeMethod, keyFile); + saveToKeyfile(!pedited || spot_edited->avoidgamutMethod, "Locallab", "AvoidgamutMethod_" + index_str, spot.avoidgamutMethod, keyFile); saveToKeyfile(!pedited || spot_edited->loc, "Locallab", "Loc_" + index_str, spot.loc, keyFile); saveToKeyfile(!pedited || spot_edited->centerX, "Locallab", "CenterX_" + index_str, spot.centerX, keyFile); saveToKeyfile(!pedited || spot_edited->centerY, "Locallab", "CenterY_" + index_str, spot.centerY, keyFile); @@ -6367,8 +6365,6 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || spot_edited->transitgrad, "Locallab", "Transitgrad_" + index_str, spot.transitgrad, keyFile); saveToKeyfile(!pedited || spot_edited->hishow, "Locallab", "Hishow_" + index_str, spot.hishow, keyFile); saveToKeyfile(!pedited || spot_edited->activ, "Locallab", "Activ_" + index_str, spot.activ, keyFile); - saveToKeyfile(!pedited || spot_edited->avoid, "Locallab", "Avoid_" + index_str, spot.avoid, keyFile); - saveToKeyfile(!pedited || spot_edited->avoidmun, "Locallab", "Avoidmun_" + index_str, spot.avoidmun, keyFile); saveToKeyfile(!pedited || spot_edited->blwh, "Locallab", "Blwh_" + index_str, spot.blwh, keyFile); saveToKeyfile(!pedited || spot_edited->recurs, "Locallab", "Recurs_" + index_str, spot.recurs, keyFile); saveToKeyfile(!pedited || spot_edited->laplac, "Locallab", "Laplac_" + index_str, spot.laplac, keyFile); @@ -7193,6 +7189,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->icm.labgridcieWy, "Color Management", "LabGridcieWy", icm.labgridcieWy, keyFile); saveToKeyfile(!pedited || pedited->icm.preser, "Color Management", "Preser", icm.preser, keyFile); saveToKeyfile(!pedited || pedited->icm.fbw, "Color Management", "Fbw", icm.fbw, keyFile); + saveToKeyfile(!pedited || pedited->icm.gamut, "Color Management", "Gamut", icm.gamut, keyFile); saveToKeyfile(!pedited || pedited->icm.outputProfile, "Color Management", "OutputProfile", icm.outputProfile, keyFile); saveToKeyfile( !pedited || pedited->icm.aRendIntent, @@ -7871,7 +7868,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) // if Saturation == 0, should we set BWToning on? assignFromKeyfile(keyFile, "Luminance Curve", "Saturation", pedited, labCurve.chromaticity, pedited->labCurve.chromaticity); // transform AvoidColorClipping into AvoidColorShift - assignFromKeyfile(keyFile, "Luminance Curve", "AvoidColorClipping", pedited, labCurve.avoidcolorshift, pedited->labCurve.avoidcolorshift); +// assignFromKeyfile(keyFile, "Luminance Curve", "AvoidColorClipping", pedited, labCurve.avoidcolorshift, pedited->labCurve.avoidcolorshift); } else { if (keyFile.has_key("Luminance Curve", "Chromaticity")) { labCurve.chromaticity = keyFile.get_integer("Luminance Curve", "Chromaticity"); @@ -7885,7 +7882,6 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) } } - assignFromKeyfile(keyFile, "Luminance Curve", "AvoidColorShift", pedited, labCurve.avoidcolorshift, pedited->labCurve.avoidcolorshift); assignFromKeyfile(keyFile, "Luminance Curve", "RedAndSkinTonesProtection", pedited, labCurve.rstprotection, pedited->labCurve.rstprotection); } @@ -7914,6 +7910,25 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Luminance Curve", "hhCurve", pedited, labCurve.hhcurve, pedited->labCurve.hhcurve); assignFromKeyfile(keyFile, "Luminance Curve", "LcCurve", pedited, labCurve.lccurve, pedited->labCurve.lccurve); assignFromKeyfile(keyFile, "Luminance Curve", "ClCurve", pedited, labCurve.clcurve, pedited->labCurve.clcurve); + if (keyFile.has_key("Luminance Curve", "Gamutmunse")) { + assignFromKeyfile(keyFile, "Luminance Curve", "Gamutmunse", pedited, labCurve.gamutmunselmethod, pedited->labCurve.gamutmunselmethod); + } else { + if (ppVersion < 303) { + if (keyFile.has_key("Luminance Curve", "AvoidColorClipping")) { + labCurve.gamutmunselmethod = + keyFile.get_boolean("Luminance Curve", "AvoidColorClipping") ? "LAB" : "NONE"; + if (pedited) { + pedited->labCurve.gamutmunselmethod = true; + } + } + } else if (keyFile.has_key("Luminance Curve", "AvoidColorShift")) { + labCurve.gamutmunselmethod = + keyFile.get_boolean("Luminance Curve", "AvoidColorShift") ? "LAB" : "NONE"; + if (pedited) { + pedited->labCurve.gamutmunselmethod = true; + } + } + } } if (keyFile.has_group("Sharpening")) { @@ -8107,7 +8122,6 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Color appearance", "Ybout", pedited, colorappearance.ybout, pedited->colorappearance.ybout); assignFromKeyfile(keyFile, "Color appearance", "Datacie", pedited, colorappearance.datacie, pedited->colorappearance.datacie); assignFromKeyfile(keyFile, "Color appearance", "Tonecie", pedited, colorappearance.tonecie, pedited->colorappearance.tonecie); - assignFromKeyfile(keyFile, "Color appearance", "Presetcat02", pedited, colorappearance.presetcat02, pedited->colorappearance.presetcat02); const std::map tc_mapping = { {"Lightness", ColorAppearanceParams::TcMode::LIGHT}, @@ -8424,6 +8438,16 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "StructExclu_" + index_str, pedited, spot.structexclu, spotEdited.structexclu); assignFromKeyfile(keyFile, "Locallab", "Struc_" + index_str, pedited, spot.struc, spotEdited.struc); assignFromKeyfile(keyFile, "Locallab", "ShapeMethod_" + index_str, pedited, spot.shapeMethod, spotEdited.shapeMethod); + if (keyFile.has_key("Locallab", "AvoidgamutMethod_" + index_str)) { + assignFromKeyfile(keyFile, "Locallab", "AvoidgamutMethod_" + index_str, pedited, spot.avoidgamutMethod, spotEdited.avoidgamutMethod); + } else if (keyFile.has_key("Locallab", "Avoid_" + index_str)) { + const bool avoid = keyFile.get_boolean("Locallab", "Avoid_" + index_str); + const bool munsell = keyFile.has_key("Locallab", "Avoidmun_" + index_str) && keyFile.get_boolean("Locallab", "Avoidmun_" + index_str); + spot.avoidgamutMethod = avoid ? (munsell ? "MUNS" : "LAB") : "NONE"; + if (pedited) { + spotEdited.avoidgamutMethod = true; + } + } assignFromKeyfile(keyFile, "Locallab", "Loc_" + index_str, pedited, spot.loc, spotEdited.loc); assignFromKeyfile(keyFile, "Locallab", "CenterX_" + index_str, pedited, spot.centerX, spotEdited.centerX); assignFromKeyfile(keyFile, "Locallab", "CenterY_" + index_str, pedited, spot.centerY, spotEdited.centerY); @@ -8443,8 +8467,6 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Transitgrad_" + index_str, pedited, spot.transitgrad, spotEdited.transitgrad); assignFromKeyfile(keyFile, "Locallab", "Hishow_" + index_str, pedited, spot.hishow, spotEdited.hishow); assignFromKeyfile(keyFile, "Locallab", "Activ_" + index_str, pedited, spot.activ, spotEdited.activ); - assignFromKeyfile(keyFile, "Locallab", "Avoid_" + index_str, pedited, spot.avoid, spotEdited.avoid); - assignFromKeyfile(keyFile, "Locallab", "Avoidmun_" + index_str, pedited, spot.avoidmun, spotEdited.avoidmun); assignFromKeyfile(keyFile, "Locallab", "Blwh_" + index_str, pedited, spot.blwh, spotEdited.blwh); assignFromKeyfile(keyFile, "Locallab", "Recurs_" + index_str, pedited, spot.recurs, spotEdited.recurs); assignFromKeyfile(keyFile, "Locallab", "Laplac_" + index_str, pedited, spot.laplac, spotEdited.laplac); @@ -9459,6 +9481,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Color Management", "Bluy", pedited, icm.bluy, pedited->icm.bluy); assignFromKeyfile(keyFile, "Color Management", "Preser", pedited, icm.preser, pedited->icm.preser); assignFromKeyfile(keyFile, "Color Management", "Fbw", pedited, icm.fbw, pedited->icm.fbw); + assignFromKeyfile(keyFile, "Color Management", "Gamut", pedited, icm.gamut, pedited->icm.gamut); assignFromKeyfile(keyFile, "Color Management", "LabGridcieALow", pedited, icm.labgridcieALow, pedited->icm.labgridcieALow); assignFromKeyfile(keyFile, "Color Management", "LabGridcieBLow", pedited, icm.labgridcieBLow, pedited->icm.labgridcieBLow); assignFromKeyfile(keyFile, "Color Management", "LabGridcieAHigh", pedited, icm.labgridcieAHigh, pedited->icm.labgridcieAHigh); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 309bcb2ab..e86272b0a 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -376,7 +376,7 @@ struct LCurveParams { int brightness; int contrast; int chromaticity; - bool avoidcolorshift; + Glib::ustring gamutmunselmethod; double rstprotection; bool lcredsk; @@ -709,7 +709,6 @@ struct ColorAppearanceParams { double greenout; int tempsc; double greensc; - bool presetcat02; ColorAppearanceParams(); @@ -1020,6 +1019,8 @@ struct LocallabParams { int structexclu; double struc; Glib::ustring shapeMethod; // IND, SYM, INDSL, SYMSL + Glib::ustring avoidgamutMethod; // NONE, LAB, XYZ + std::vector loc; // For ellipse/rectangle: {locX, locXL, locY, locYT} int centerX; int centerY; @@ -1039,8 +1040,6 @@ struct LocallabParams { double transitgrad; bool hishow; bool activ; - bool avoid; - bool avoidmun; bool blwh; bool recurs; bool laplac; @@ -1937,6 +1936,7 @@ struct ColorManagementParams { double bluy; double preser; bool fbw; + bool gamut; double labgridcieALow; double labgridcieBLow; double labgridcieAHigh; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index d45283c38..3916adfbe 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -1185,8 +1185,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = { AUTOEXP, //Evlocallabforcebw AUTOEXP, //Evlocallabsigjz AUTOEXP, //Evlocallabsigq - AUTOEXP //Evlocallablogcie - + AUTOEXP //Evlocallablogcie }; diff --git a/rtgui/blackwhite.cc b/rtgui/blackwhite.cc index aa5c0605b..6e618ea3b 100644 --- a/rtgui/blackwhite.cc +++ b/rtgui/blackwhite.cc @@ -50,7 +50,8 @@ BlackWhite::BlackWhite (): FoldableToolPanel(this, TOOL_NAME, M("TP_BWMIX_LABEL" metHBox->set_spacing (2); Gtk::Label* metLabel = Gtk::manage (new Gtk::Label (M("TP_BWMIX_MET") + ":")); metHBox->pack_start (*metLabel, Gtk::PACK_SHRINK); - method = Gtk::manage (new MyComboBoxText ()); + + method = Gtk::manage (new MyComboBoxText ()); method->append (M("TP_BWMIX_MET_DESAT")); method->append (M("TP_BWMIX_MET_LUMEQUAL")); method->append (M("TP_BWMIX_MET_CHANMIX")); diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index 2c9235b53..5531a55c8 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -222,7 +222,6 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel (this, TOOL_NAME, M ("TP milestones.push_back ( GradientMilestone (1., 1., 1., 1.) ); auto m = ProcEventMapper::getInstance(); - Evcatpreset = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_CAT02PRESET"); EvCATAutotempout = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_TEMPOUT"); EvCATillum = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_ILLUM"); EvCATcomplex = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_CATCOMPLEX"); @@ -271,10 +270,6 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel (this, TOOL_NAME, M ("TP catHBox->pack_start(*catmethod); genVBox->pack_start (*catHBox, Gtk::PACK_SHRINK); - presetcat02 = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_PRESETCAT02"))); - presetcat02->set_tooltip_markup (M("TP_COLORAPP_PRESETCAT02_TOOLTIP")); - presetcat02conn = presetcat02->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::presetcat02pressed)); -// genVBox->pack_start (*presetcat02, Gtk::PACK_SHRINK); genFrame->add (*genVBox); pack_start (*genFrame, Gtk::PACK_EXPAND_WIDGET, 4); @@ -688,14 +683,22 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel (this, TOOL_NAME, M ("TP ybout->set_tooltip_markup (M ("TP_COLORAPP_YBOUT_TOOLTIP")); tempout->set_tooltip_markup (M ("TP_COLORAPP_TEMP2_TOOLTIP")); - // tempout->throwOnButtonRelease(); - // tempout->addAutoButton (M ("TP_COLORAPP_TEMPOUT_TOOLTIP")); - + tempout->throwOnButtonRelease(); + tempout->addAutoButton (M ("TP_COLORAPP_TEMPOUT_TOOLTIP")); + // I renable tempout with addautobutton to work properly (and all code disabled). There are certainly some redundancies, but it doesn't matter tempout->show(); greenout->show(); ybout->show(); - p3VBox->pack_start (*tempout); - p3VBox->pack_start (*greenout); + Gtk::Frame *tempgreenFrame; + tempgreenFrame = Gtk::manage(new Gtk::Frame()); + tempgreenFrame->set_label_align (0.025, 0.5); + Gtk::Box* tempgreenVBox; + tempgreenVBox = Gtk::manage ( new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); + tempgreenVBox->set_spacing (2); + tempgreenVBox->pack_start (*tempout); + tempgreenVBox->pack_start (*greenout); + tempgreenFrame->add(*tempgreenVBox); + p3VBox->pack_start(*tempgreenFrame); p3VBox->pack_start (*ybout); Gtk::Box* surrHBox = Gtk::manage (new Gtk::Box ()); @@ -829,7 +832,7 @@ void ColorAppearance::neutral_pressed () qcontrast->resetValue (false); colorh->resetValue (false); tempout->resetValue (false); -// tempout->setAutoValue (true); + tempout->setAutoValue (true); greenout->resetValue (false); ybout->resetValue (false); tempsc->resetValue (false); @@ -876,7 +879,6 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) tcmodeconn.block (true); tcmode2conn.block (true); tcmode3conn.block (true); - presetcat02conn.block (true); shape->setCurve (pp->colorappearance.curve); shape2->setCurve (pp->colorappearance.curve2); shape3->setCurve (pp->colorappearance.curve3); @@ -884,7 +886,6 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) toneCurveMode2->set_active (toUnderlying(pp->colorappearance.curveMode2)); toneCurveMode3->set_active (toUnderlying(pp->colorappearance.curveMode3)); curveMode3Changed(); // This will set the correct sensitive state of depending Adjusters - presetcat02->set_active(pp->colorappearance.presetcat02); nexttemp = pp->wb.temperature; nextgreen = 1.; //pp->wb.green; @@ -922,7 +923,7 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) adapscen->setAutoInconsistent (multiImage && !pedited->colorappearance.autoadapscen); ybscen->setAutoInconsistent (multiImage && !pedited->colorappearance.autoybscen); set_inconsistent (multiImage && !pedited->colorappearance.enabled); - // tempout->setAutoInconsistent (multiImage && !pedited->colorappearance.autotempout); + tempout->setAutoInconsistent (multiImage && !pedited->colorappearance.autotempout); shape->setUnChanged (!pedited->colorappearance.curve); shape2->setUnChanged (!pedited->colorappearance.curve2); @@ -948,7 +949,6 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) if (!pedited->colorappearance.curveMode3) { toneCurveMode3->set_active (3); } - presetcat02->set_inconsistent(!pedited->colorappearance.presetcat02); } @@ -1108,7 +1108,7 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) lastAutoAdapscen = pp->colorappearance.autoadapscen; lastAutoDegreeout = pp->colorappearance.autodegreeout; lastAutoybscen = pp->colorappearance.autoybscen; -// lastAutotempout = pp->colorappearance.autotempout; + lastAutotempout = pp->colorappearance.autotempout; degree->setValue (pp->colorappearance.degree); degree->setAutoValue (pp->colorappearance.autodegree); @@ -1131,15 +1131,11 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) qcontrast->setValue (pp->colorappearance.qcontrast); colorh->setValue (pp->colorappearance.colorh); tempout->setValue (pp->colorappearance.tempout); -// tempout->setAutoValue (pp->colorappearance.autotempout); + tempout->setAutoValue (pp->colorappearance.autotempout); greenout->setValue (pp->colorappearance.greenout); ybout->setValue (pp->colorappearance.ybout); tempsc->setValue (pp->colorappearance.tempsc); greensc->setValue (pp->colorappearance.greensc); - presetcat02conn.block (true); - presetcat02->set_active (pp->colorappearance.presetcat02); - presetcat02conn.block (false); - lastpresetcat02 = pp->colorappearance.presetcat02; if (complexmethod->get_active_row_number() == 0) { updateGUIToMode(0); @@ -1199,12 +1195,11 @@ void ColorAppearance::write (ProcParams* pp, ParamsEdited* pedited) pp->colorappearance.curve2 = shape2->getCurve (); pp->colorappearance.curve3 = shape3->getCurve (); pp->colorappearance.tempout = tempout->getValue (); -// pp->colorappearance.autotempout = tempout->getAutoValue (); + pp->colorappearance.autotempout = tempout->getAutoValue (); pp->colorappearance.greenout = greenout->getValue (); pp->colorappearance.ybout = ybout->getValue (); pp->colorappearance.tempsc = tempsc->getValue (); pp->colorappearance.greensc = greensc->getValue (); - pp->colorappearance.presetcat02 = presetcat02->get_active(); int tcMode = toneCurveMode->get_active_row_number(); @@ -1278,8 +1273,7 @@ void ColorAppearance::write (ProcParams* pp, ParamsEdited* pedited) pedited->colorappearance.ybout = ybout->getEditedState (); pedited->colorappearance.tempsc = tempsc->getEditedState (); pedited->colorappearance.greensc = greensc->getEditedState (); - pedited->colorappearance.presetcat02 = presetcat02->get_inconsistent (); -// pedited->colorappearance.autotempout = !tempout->getAutoInconsistent(); + pedited->colorappearance.autotempout = !tempout->getAutoInconsistent(); } @@ -1371,7 +1365,9 @@ void ColorAppearance::updateGUIToMode(int mode) curveEditorG->hide(); curveEditorG2->hide(); curveEditorG3->hide(); - greenout->hide(); + //greenout->hide(); + greenout->set_sensitive(false); + badpixsl->hide(); datacie->hide(); } else { @@ -1380,7 +1376,8 @@ void ColorAppearance::updateGUIToMode(int mode) curveEditorG->show(); curveEditorG2->show(); curveEditorG3->show(); - greenout->show(); + // greenout->show(); + greenout->set_sensitive(true); badpixsl->show(); datacie->show(); } @@ -1399,10 +1396,6 @@ void ColorAppearance::convertParamToNormal() shape2->reset(); shape3->reset(); wbmodel->set_active (0); - if (presetcat02->get_active ()) { - wbmodel->set_active (2); - illumChanged(); - } if (catmethod->get_active_row_number() == 1 || catmethod->get_active_row_number() == 2) { wbmodel->set_active (2); illumChanged(); @@ -1490,13 +1483,13 @@ void ColorAppearance::catmethodChanged() ybout->setValue(18); tempout->setValue (nexttemp); -/* if(tempout->getAutoValue()) { - tempout->resetValue (false); - } else { - tempout->setValue (nexttemp); - tempout->setAutoValue (true); - } -*/ + if(tempout->getAutoValue()) { + tempout->resetValue (false); + } else { + tempout->setValue (nexttemp); + tempout->setAutoValue (true); + } + greenout->setValue (nextgreen); enableListener(); @@ -1545,7 +1538,7 @@ void ColorAppearance::catmethodChanged() adaplum->resetValue (false); degreeout->resetValue (false); ybout->resetValue (false); - // tempout->resetValue (false); + tempout->resetValue (false); tempout->setValue (nexttemp); greenout->resetValue (false); enableListener(); @@ -1707,140 +1700,6 @@ void ColorAppearance::badpix_toggled () { } */ -void ColorAppearance::presetcat02pressed () //keep in case of... -{ - if (presetcat02->get_active ()) { - disableListener(); - jlight->resetValue (false); - qbright->resetValue (false); - chroma->resetValue (false); - schroma->resetValue (false); - mchroma->resetValue (false); - rstprotection->resetValue (false); - contrast->resetValue (false); - qcontrast->resetValue (false); - colorh->resetValue (false); - tempout->resetValue (false); - greenout->resetValue (false); - ybout->resetValue (false); - tempsc->resetValue (false); - greensc->resetValue (false); - badpixsl->resetValue (false); - wbmodel->set_active (0); - illum->set_active (2); - toneCurveMode->set_active (0); - toneCurveMode2->set_active (1); - toneCurveMode3->set_active (0); - shape->reset(); - shape2->reset(); - shape3->reset(); - gamutconn.block (true); - gamut->set_active (true); - gamutconn.block (false); - degree->setAutoValue (true); - degree->resetValue (false); - degree->setValue(90); - adapscen->resetValue (false); - adapscen->setAutoValue (true); - degreeout->resetValue (false); - degreeout->setAutoValue (true); - ybscen->resetValue (false); - ybscen->setAutoValue (true); - surrsrc->set_active (0); - wbmodel->set_active (2); - tempsc->resetValue (false); - greensc->resetValue (false); - adapscen->setValue(400.); - ybscen->setValue(18); - surround->set_active (0); - adaplum->setValue(400.); - degreeout->setValue(90); - ybout->setValue(18); - tempout->setValue (nexttemp); - -/* if(tempout->getAutoValue()) { - tempout->resetValue (false); - } else { - tempout->setValue (nexttemp); - tempout->setAutoValue (true); - } -*/ - greenout->setValue (nextgreen); - enableListener(); - } else { - disableListener(); -/* jlight->resetValue (false); - qbright->resetValue (false); - chroma->resetValue (false); - schroma->resetValue (false); - mchroma->resetValue (false); - rstprotection->resetValue (false); - contrast->resetValue (false); - qcontrast->resetValue (false); - colorh->resetValue (false); - tempout->resetValue (false); - greenout->resetValue (false); - ybout->resetValue (false); - tempsc->resetValue (false); - greensc->resetValue (false); - badpixsl->resetValue (false); - wbmodel->set_active (0); - toneCurveMode->set_active (0); - toneCurveMode2->set_active (0); - toneCurveMode3->set_active (0); - shape->reset(); - shape2->reset(); - shape3->reset(); - gamutconn.block (true); - gamut->set_active (true); - gamutconn.block (false); -*/ - degree->setAutoValue (true); - degree->resetValue (false); - adapscen->resetValue (false); - adapscen->setAutoValue (true); - degreeout->resetValue (false); - degreeout->setAutoValue (true); - ybscen->resetValue (false); - ybscen->setAutoValue (true); - surrsrc->set_active (0); - wbmodel->set_active (0); - illum->set_active (2); - tempsc->resetValue (false); - greensc->resetValue (false); - adapscen->resetValue (false); - ybscen->resetValue (false); - surround->set_active (0); - adaplum->resetValue (false); - degreeout->resetValue (false); - ybout->resetValue (false); - tempout->resetValue (false); - greenout->resetValue (false); - enableListener(); - - } - if (batchMode) { - if (presetcat02->get_inconsistent()) { - presetcat02->set_inconsistent (false); - presetcat02conn.block (true); - presetcat02->set_active (false); - presetcat02conn.block (false); - } else if (lastpresetcat02) { - presetcat02->set_inconsistent (true); - } - - lastpresetcat02 = presetcat02->get_active (); - } - - if (listener) { - if (presetcat02->get_active ()) { - listener->panelChanged (Evcatpreset, M ("GENERAL_ENABLED")); - } else { - listener->panelChanged (Evcatpreset, M ("GENERAL_DISABLED")); - } - } - -} void ColorAppearance::datacie_toggled () { @@ -2003,9 +1862,6 @@ void ColorAppearance::autoCamChanged (double ccam, double ccamout) void ColorAppearance::adapCamChanged (double cadap) { - if(presetcat02->get_active()){ - return; - } idle_register.add( [this, cadap]() -> bool @@ -2020,14 +1876,14 @@ void ColorAppearance::adapCamChanged (double cadap) void ColorAppearance::wbCamChanged (double temp, double tin) -{ +{//reactivate this function idle_register.add( [this, temp, tin]() -> bool { disableListener(); tempout->setValue(temp); - greenout->setValue(tin); + greenout->setValue(tin); enableListener(); return false; } @@ -2036,9 +1892,6 @@ void ColorAppearance::wbCamChanged (double temp, double tin) void ColorAppearance::ybCamChanged (int ybsc) { - if(presetcat02->get_active()){ - return; - } idle_register.add( [this, ybsc]() -> bool @@ -2124,16 +1977,6 @@ void ColorAppearance::adjusterChanged(Adjuster* a, double newval) void ColorAppearance::adjusterAutoToggled(Adjuster* a) { - /* - if(presetcat02->get_active ()){ - if(tempout->getAutoValue()) { - tempout->resetValue (false); - } else { - tempout->setValue (nexttemp); - tempout->setAutoValue (true); - } - } -*/ if (multiImage) { if (degree->getAutoInconsistent()) { degree->setAutoInconsistent (false); @@ -2169,7 +2012,7 @@ void ColorAppearance::adjusterAutoToggled(Adjuster* a) ybscen->setAutoInconsistent (true); } -/* lastAutotempout = tempout->getAutoValue(); + lastAutotempout = tempout->getAutoValue(); if (tempout->getAutoInconsistent()) { tempout->setAutoInconsistent (false); @@ -2179,7 +2022,7 @@ void ColorAppearance::adjusterAutoToggled(Adjuster* a) } lastAutotempout = tempout->getAutoValue(); -*/ + } if (listener && (multiImage || getEnabled()) ) { @@ -2223,7 +2066,7 @@ void ColorAppearance::adjusterAutoToggled(Adjuster* a) listener->panelChanged (EvCATAutoyb, M ("GENERAL_DISABLED")); } } -/* + if (a == tempout) { if (tempout->getAutoInconsistent()) { listener->panelChanged (EvCATAutotempout, M ("GENERAL_UNCHANGED")); @@ -2233,7 +2076,7 @@ void ColorAppearance::adjusterAutoToggled(Adjuster* a) listener->panelChanged (EvCATAutotempout, M ("GENERAL_DISABLED")); } } -*/ + } } void ColorAppearance::enabledChanged () diff --git a/rtgui/colorappearance.h b/rtgui/colorappearance.h index caa481c34..dcf19b977 100644 --- a/rtgui/colorappearance.h +++ b/rtgui/colorappearance.h @@ -70,7 +70,6 @@ public: bool adapCamComputed_ (); void ybCamChanged (int yb) override; bool ybCamComputed_ (); - void presetcat02pressed (); void curveChanged (CurveEditor* ce) override; void curveMode1Changed (); bool curveMode1Changed_ (); @@ -108,7 +107,6 @@ public: void writeOptions (std::vector &tpOpen); private: - rtengine::ProcEvent Evcatpreset; rtengine::ProcEvent EvCATAutotempout; rtengine::ProcEvent EvCATillum; rtengine::ProcEvent EvCATcomplex; @@ -161,8 +159,6 @@ private: Gtk::CheckButton* tonecie; // Gtk::CheckButton* sharpcie; Gtk::Button* neutral; - Gtk::CheckButton* presetcat02; - sigc::connection presetcat02conn; MyComboBoxText* surrsrc; sigc::connection surrsrcconn; @@ -200,7 +196,6 @@ private: bool lastgamut; bool lastdatacie; bool lasttonecie; - bool lastpresetcat02; double nexttemp; double nextgreen; diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index 0d57d98bb..60fde12a6 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -24,6 +24,7 @@ #include "options.h" #include "../rtengine/procparams.h" #include "rtimage.h" +#include "eventmapper.h" using namespace rtengine; using namespace procparams; @@ -55,6 +56,7 @@ ControlSpotPanel::ControlSpotPanel(): qualityMethod_(Gtk::manage(new MyComboBoxText())), //complexMethod_(Gtk::manage(new MyComboBoxText())), wavMethod_(Gtk::manage(new MyComboBoxText())), + avoidgamutMethod_(Gtk::manage(new MyComboBoxText())), sensiexclu_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIEXCLU"), 0, 100, 1, 12))), structexclu_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRUCCOL"), 0, 100, 1, 0))), @@ -76,15 +78,13 @@ ControlSpotPanel::ControlSpotPanel(): balanh_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BALANH"), 0.2, 2.5, 0.1, 1.0, Gtk::manage(new RTImage("rawtherapee-logo-16.png")), Gtk::manage(new RTImage("circle-red-green-small.png"))))), colorde_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_COLORDE"), -15, 15, 2, 5, Gtk::manage(new RTImage("circle-blue-yellow-small.png")), Gtk::manage(new RTImage("circle-gray-green-small.png"))))), colorscope_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_COLORSCOPE"), 0., 100.0, 1., 30.))), - avoidrad_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_AVOIDRAD"), 0., 30.0, 0.1, 0.7))), + avoidrad_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_AVOIDRAD"), 0., 30.0, 0.1, 0.))), scopemask_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SCOPEMASK"), 0, 100, 1, 60))), denoichmask_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DENOIMASK"), 0., 100., 0.5, 0))), lumask_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_LUMASK"), -50, 30, 1, 10, Gtk::manage(new RTImage("circle-yellow-small.png")), Gtk::manage(new RTImage("circle-gray-small.png")) ))), hishow_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_PREVSHOW")))), activ_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_ACTIVSPOT")))), - avoid_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_AVOID")))), - avoidmun_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_AVOIDMUN")))), blwh_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_BLWH")))), recurs_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_RECURS")))), laplac_(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_LAPLACC")))), @@ -100,6 +100,7 @@ ControlSpotPanel::ControlSpotPanel(): preview_(Gtk::manage(new Gtk::ToggleButton(M("TP_LOCALLAB_PREVIEW")))), ctboxshape(Gtk::manage(new Gtk::Box())), ctboxshapemethod(Gtk::manage(new Gtk::Box())), + ctboxgamut(Gtk::manage(new Gtk::Box())), controlPanelListener(nullptr), lastObject_(-1), @@ -111,6 +112,8 @@ ControlSpotPanel::ControlSpotPanel(): excluFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_EXCLUF")))), maskPrevActive(false) { + auto m = ProcEventMapper::getInstance(); + EvLocallabavoidgamutMethod = m->newEvent(AUTOEXP, "HISTORY_MSG_LOCAL_GAMUTMUNSEL"); const bool showtooltip = options.showtooltip; pack_start(*hishow_); @@ -397,23 +400,30 @@ ControlSpotPanel::ControlSpotPanel(): activConn_ = activ_->signal_toggled().connect( sigc::mem_fun(*this, &ControlSpotPanel::activChanged)); - avoidConn_ = avoid_->signal_toggled().connect( - sigc::mem_fun(*this, &ControlSpotPanel::avoidChanged)); - avoidmunConn_ = avoidmun_->signal_toggled().connect( - sigc::mem_fun(*this, &ControlSpotPanel::avoidmunChanged)); - - Gtk::Frame* const avFrame = Gtk::manage(new Gtk::Frame()); + Gtk::Label* const labelgamut = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_AVOID") + ":")); + ctboxgamut->pack_start(*labelgamut, Gtk::PACK_SHRINK, 4); + avoidgamutMethod_->append(M("TP_LOCALLAB_GAMUTNON")); + avoidgamutMethod_->append(M("TP_LOCALLAB_GAMUTLABRELA")); + avoidgamutMethod_->append(M("TP_LOCALLAB_GAMUTXYZABSO")); + avoidgamutMethod_->append(M("TP_LOCALLAB_GAMUTXYZRELA")); + avoidgamutMethod_->append(M("TP_LOCALLAB_GAMUTMUNSELL")); + avoidgamutMethod_->set_active(4); + avoidgamutconn_ = avoidgamutMethod_->signal_changed().connect( + sigc::mem_fun( + *this, &ControlSpotPanel::avoidgamutMethodChanged)); + ctboxgamut->pack_start(*avoidgamutMethod_); + if (showtooltip) { + ctboxgamut->set_tooltip_text(M("TP_LOCALLAB_AVOIDCOLORSHIFT_TOOLTIP")); + } + + Gtk::Frame* const avFrame = Gtk::manage(new Gtk::Frame()); ToolParamBlock* const avbox = Gtk::manage(new ToolParamBlock()); avFrame->set_label_align(0.025, 0.5); - avFrame->set_label_widget(*avoid_); + avbox->pack_start(*ctboxgamut); avbox->pack_start(*avoidrad_); - avbox->pack_start(*avoidmun_); avFrame->add(*avbox); specCaseBox->pack_start(*avFrame); - if (showtooltip) { - avoidmun_->set_tooltip_text(M("TP_LOCALLAB_AVOIDMUN_TOOLTIP")); - } blwhConn_ = blwh_->signal_toggled().connect( sigc::mem_fun(*this, &ControlSpotPanel::blwhChanged)); @@ -429,7 +439,6 @@ ControlSpotPanel::ControlSpotPanel(): if (showtooltip) { recurs_->set_tooltip_text(M("TP_LOCALLAB_RECURS_TOOLTIP")); - avoid_->set_tooltip_text(M("TP_LOCALLAB_AVOIDCOLORSHIFT_TOOLTIP")); } specCaseBox->pack_start(*recurs_); @@ -854,8 +863,6 @@ void ControlSpotPanel::load_ControlSpot_param() avoidrad_->setValue((double)row[spots_.avoidrad]); hishow_->set_active(row[spots_.hishow]); activ_->set_active(row[spots_.activ]); - avoid_->set_active(row[spots_.avoid]); - avoidmun_->set_active(row[spots_.avoidmun]); blwh_->set_active(row[spots_.blwh]); recurs_->set_active(row[spots_.recurs]); // laplac_->set_active(row[spots_.laplac]); @@ -868,6 +875,8 @@ void ControlSpotPanel::load_ControlSpot_param() //savrest_->set_active(row[spots_.savrest]); //complexMethod_->set_active(row[spots_.complexMethod]); wavMethod_->set_active(row[spots_.wavMethod]); + avoidgamutMethod_->set_active(row[spots_.avoidgamutMethod]); + } void ControlSpotPanel::controlspotChanged() @@ -1055,6 +1064,34 @@ void ControlSpotPanel::spotMethodChanged() } } +void ControlSpotPanel::avoidgamutMethodChanged() +{ + + // Get selected control spot + const auto s = treeview_->get_selection(); + + if (!s->count_selected_rows()) { + return; + } + const int meth = avoidgamutMethod_->get_active_row_number(); + avoidrad_->show(); + + if(meth == 2 || meth == 3 || meth == 4) { + avoidrad_->hide(); + } + + const auto iter = s->get_selected(); + Gtk::TreeModel::Row row = *iter; + + row[spots_.avoidgamutMethod] = avoidgamutMethod_->get_active_row_number(); + + // Raise event + if (listener) { + listener->panelChanged(EvLocallabavoidgamutMethod, avoidgamutMethod_->get_active_text()); + } + +} + void ControlSpotPanel::shapeMethodChanged() { // printf("shapeMethodChanged\n"); @@ -1217,6 +1254,7 @@ void ControlSpotPanel::updateParamVisibility() // Update Control Spot GUI according to shapeMethod_ combobox state (to be compliant with shapeMethodChanged function) const int method = shapeMethod_->get_active_row_number(); + const int meth = avoidgamutMethod_->get_active_row_number(); if (!batchMode) { if (method == 1 || method == 3) { // Symmetrical cases @@ -1260,6 +1298,12 @@ void ControlSpotPanel::updateParamVisibility() centerY_->show(); } + if(meth == 1) { + avoidrad_->show(); + } else { + avoidrad_->hide(); +} + // Update Control Spot GUI according to spotMethod_ combobox state (to be compliant with spotMethodChanged function) if (multiImage && spotMethod_->get_active_text() == M("GENERAL_UNCHANGED")) { excluFrame->show(); @@ -1588,57 +1632,6 @@ void ControlSpotPanel::hishowChanged() } - -void ControlSpotPanel::avoidChanged() -{ - // printf("avoidChanged\n"); - - // Get selected control spot - const auto s = treeview_->get_selection(); - - if (!s->count_selected_rows()) { - return; - } - - const auto iter = s->get_selected(); - Gtk::TreeModel::Row row = *iter; - row[spots_.avoid] = avoid_->get_active(); - - // Raise event - if (listener) { - if (avoid_->get_active()) { - listener->panelChanged(Evlocallabavoid, M("GENERAL_ENABLED")); - } else { - listener->panelChanged(Evlocallabavoid, M("GENERAL_DISABLED")); - } - } -} - -void ControlSpotPanel::avoidmunChanged() -{ - // printf("avoidmunChanged\n"); - - // Get selected control spot - const auto s = treeview_->get_selection(); - - if (!s->count_selected_rows()) { - return; - } - - const auto iter = s->get_selected(); - Gtk::TreeModel::Row row = *iter; - row[spots_.avoidmun] = avoidmun_->get_active(); - - // Raise event - if (listener) { - if (avoidmun_->get_active()) { - listener->panelChanged(EvLocallabSpotavoidmun, M("GENERAL_ENABLED")); - } else { - listener->panelChanged(EvLocallabSpotavoidmun, M("GENERAL_DISABLED")); - } - } -} - void ControlSpotPanel::activChanged() { // printf("activChanged\n"); @@ -1859,8 +1852,6 @@ void ControlSpotPanel::disableParamlistener(bool cond) avoidrad_->block(cond); hishowconn_.block(cond); activConn_.block(cond); - avoidConn_.block(cond); - avoidmunConn_.block(cond); blwhConn_.block(cond); recursConn_.block(cond); laplacConn_.block(cond); @@ -1872,6 +1863,8 @@ void ControlSpotPanel::disableParamlistener(bool cond) //savrestConn_.block(cond); //complexMethodconn_.block(cond); wavMethodconn_.block(cond); + avoidgamutconn_.block(cond); + } void ControlSpotPanel::setParamEditable(bool cond) @@ -1906,8 +1899,6 @@ void ControlSpotPanel::setParamEditable(bool cond) avoidrad_->set_sensitive(cond); hishow_->set_sensitive(cond); activ_->set_sensitive(cond); - avoid_->set_sensitive(cond); - avoidmun_->set_sensitive(cond); blwh_->set_sensitive(cond); recurs_->set_sensitive(cond); laplac_->set_sensitive(cond); @@ -1920,6 +1911,7 @@ void ControlSpotPanel::setParamEditable(bool cond) //complexMethod_->set_sensitive(cond); wavMethod_->set_sensitive(cond); preview_->set_sensitive(cond); + avoidgamutMethod_->set_sensitive(cond); if (!cond) { // Reset complex parameters visibility to default state @@ -2592,8 +2584,6 @@ ControlSpotPanel::SpotRow* ControlSpotPanel::getSpot(const int index) r->lumask = row[spots_.lumask]; r->hishow = row[spots_.hishow]; r->activ = row[spots_.activ]; - r->avoid = row[spots_.avoid]; - r->avoidmun = row[spots_.avoidmun]; r->blwh = row[spots_.blwh]; r->recurs = row[spots_.recurs]; r->laplac = row[spots_.laplac]; @@ -2601,6 +2591,7 @@ ControlSpotPanel::SpotRow* ControlSpotPanel::getSpot(const int index) r->shortc = row[spots_.shortc]; //r->savrest = row[spots_.savrest]; r->wavMethod = row[spots_.wavMethod]; + r->avoidgamutMethod = row[spots_.avoidgamutMethod]; return r; } @@ -2725,8 +2716,6 @@ void ControlSpotPanel::addControlSpot(SpotRow* newSpot) row[spots_.avoidrad] = newSpot->avoidrad; row[spots_.hishow] = newSpot->hishow; row[spots_.activ] = newSpot->activ; - row[spots_.avoid] = newSpot->avoid; - row[spots_.avoidmun] = newSpot->avoidmun; row[spots_.blwh] = newSpot->blwh; row[spots_.recurs] = newSpot->recurs; row[spots_.laplac] = newSpot->laplac; @@ -2738,6 +2727,7 @@ void ControlSpotPanel::addControlSpot(SpotRow* newSpot) //row[spots_.savrest] = newSpot->savrest; row[spots_.complexMethod] = newSpot->complexMethod; row[spots_.wavMethod] = newSpot->wavMethod; + row[spots_.avoidgamutMethod] = newSpot->avoidgamutMethod; updateParamVisibility(); disableParamlistener(false); @@ -2845,8 +2835,6 @@ ControlSpotPanel::ControlSpots::ControlSpots() add(avoidrad); add(hishow); add(activ); - add(avoid); - add(avoidmun); add(blwh); add(recurs); add(laplac); @@ -2858,6 +2846,7 @@ ControlSpotPanel::ControlSpots::ControlSpots() //add(savrest); add(complexMethod); add(wavMethod); + add(avoidgamutMethod); } //----------------------------------------------------------------------------- diff --git a/rtgui/controlspotpanel.h b/rtgui/controlspotpanel.h index 92406c690..b1e191b0e 100644 --- a/rtgui/controlspotpanel.h +++ b/rtgui/controlspotpanel.h @@ -57,6 +57,7 @@ public: int sensiexclu; int structexclu; int shapeMethod; // 0 = Independent (mouse), 1 = Symmetrical (mouse), 2 = Independent (mouse + sliders), 3 = Symmetrical (mouse + sliders) + int avoidgamutMethod; int locX; int locXL; int locY; @@ -79,8 +80,6 @@ public: double avoidrad; bool hishow; bool activ; - bool avoid; - bool avoidmun; bool blwh; bool recurs; bool laplac; @@ -243,7 +242,8 @@ private: void spotMethodChanged(); void shapeMethodChanged(); void qualityMethodChanged(); - //void complexMethodChanged(); + void avoidgamutMethodChanged(); + //void complexMethodChanged(); void wavMethodChanged(); void updateParamVisibility(); @@ -252,8 +252,6 @@ private: void hishowChanged(); void activChanged(); - void avoidChanged(); - void avoidmunChanged(); void blwhChanged(); void recursChanged(); void laplacChanged(); @@ -293,6 +291,7 @@ private: Gtk::TreeModelColumn sensiexclu; Gtk::TreeModelColumn structexclu; Gtk::TreeModelColumn shapeMethod; // 0 = Independent (mouse), 1 = Symmetrical (mouse), 2 = Independent (mouse + sliders), 3 = Symmetrical (mouse + sliders) + Gtk::TreeModelColumn avoidgamutMethod; Gtk::TreeModelColumn locX; Gtk::TreeModelColumn locXL; Gtk::TreeModelColumn locY; @@ -315,8 +314,6 @@ private: Gtk::TreeModelColumn avoidrad; Gtk::TreeModelColumn hishow; Gtk::TreeModelColumn activ; - Gtk::TreeModelColumn avoid; - Gtk::TreeModelColumn avoidmun; Gtk::TreeModelColumn blwh; Gtk::TreeModelColumn recurs; Gtk::TreeModelColumn laplac; @@ -347,6 +344,7 @@ private: }; ControlSpots spots_; + rtengine::ProcEvent EvLocallabavoidgamutMethod; // Child widgets Gtk::ScrolledWindow* const scrolledwindow_; @@ -381,6 +379,8 @@ private: //sigc::connection complexMethodconn_; MyComboBoxText* const wavMethod_; sigc::connection wavMethodconn_; + MyComboBoxText* const avoidgamutMethod_; + sigc::connection avoidgamutconn_; Adjuster* const sensiexclu_; Adjuster* const structexclu_; @@ -411,10 +411,6 @@ private: sigc::connection hishowconn_; Gtk::CheckButton* const activ_; sigc::connection activConn_; - Gtk::CheckButton* const avoid_; - sigc::connection avoidConn_; - Gtk::CheckButton* const avoidmun_; - sigc::connection avoidmunConn_; Gtk::CheckButton* const blwh_; sigc::connection blwhConn_; Gtk::CheckButton* const recurs_; @@ -438,6 +434,7 @@ private: Gtk::Box* const ctboxshape; Gtk::Box* const ctboxshapemethod; + Gtk::Box* const ctboxgamut; // Internal variables ControlPanelListener* controlPanelListener; diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index d84b36e67..95808d4b0 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -905,7 +905,6 @@ EditorPanel::EditorPanel (FilePanel* filePanel) send_to_external = Gtk::manage(new PopUpButton("", false)); send_to_external->set_tooltip_text(M("MAIN_BUTTON_SENDTOEDITOR_TOOLTIP")); setExpandAlignProperties(send_to_external->buttonGroup, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); - send_to_external->addEntry("palette-brush.png", M("GENERAL_OTHER")); updateExternalEditorWidget( options.externalEditorIndex >= 0 ? options.externalEditorIndex : options.externalEditors.size(), options.externalEditors @@ -2748,10 +2747,14 @@ void EditorPanel::tbShowHideSidePanels_managestate() void EditorPanel::updateExternalEditorWidget(int selectedIndex, const std::vector &editors) { - // Remove the editors and leave the "Other" entry. - while (send_to_external->getEntryCount() > 1) { - send_to_external->removeEntry(0); + // Remove the editors. + while (send_to_external->getEntryCount()) { + send_to_external->removeEntry(send_to_external->getEntryCount() - 1); } + + // Create new radio button group because they cannot be reused: https://developer-old.gnome.org/gtkmm/3.16/classGtk_1_1RadioButtonGroup.html#details. + send_to_external_radio_group = Gtk::RadioButtonGroup(); + // Add the editors. for (unsigned i = 0; i < editors.size(); i++) { const auto & name = editors[i].name.empty() ? Glib::ustring(" ") : editors[i].name; @@ -2771,11 +2774,12 @@ void EditorPanel::updateExternalEditorWidget(int selectedIndex, const std::vecto gioIcon = Gio::Icon::deserialize(Glib::VariantBase(icon_variant)); } - send_to_external->insertEntry(i, gioIcon, name); + send_to_external->insertEntry(i, gioIcon, name, &send_to_external_radio_group); } else { - send_to_external->insertEntry(i, "palette-brush.png", name); + send_to_external->insertEntry(i, "palette-brush.png", name, &send_to_external_radio_group); } } + send_to_external->addEntry("palette-brush.png", M("GENERAL_OTHER"), &send_to_external_radio_group); send_to_external->setSelected(selectedIndex); send_to_external->show(); } diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 65d663a06..98a475a7c 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -248,6 +248,7 @@ private: Gtk::Button* queueimg; Gtk::Button* saveimgas; PopUpButton* send_to_external; + Gtk::RadioButtonGroup send_to_external_radio_group; Gtk::Button* navSync; Gtk::Button* navNext; Gtk::Button* navPrev; diff --git a/rtgui/externaleditorpreferences.cc b/rtgui/externaleditorpreferences.cc index 58a562725..79dac52d2 100644 --- a/rtgui/externaleditorpreferences.cc +++ b/rtgui/externaleditorpreferences.cc @@ -274,7 +274,11 @@ void ExternalEditorPreferences::openFileChooserDialog() const auto exe_filter = Gtk::FileFilter::create(); exe_filter->set_name(M("FILECHOOSER_FILTER_EXECUTABLE")); exe_filter->add_custom(Gtk::FILE_FILTER_MIME_TYPE, [](const Gtk::FileFilter::Info &info) { +#ifdef WIN32 + return info.mime_type == "application/x-msdownload"; +#else return Gio::content_type_can_be_executable(info.mime_type); +#endif }); const auto all_filter = Gtk::FileFilter::create(); all_filter->set_name(M("FILECHOOSER_FILTER_ANY")); diff --git a/rtgui/extprog.cc b/rtgui/extprog.cc index e4cf63733..9ec87c548 100644 --- a/rtgui/extprog.cc +++ b/rtgui/extprog.cc @@ -318,22 +318,26 @@ bool ExtProgStore::openInPhotoshop (const Glib::ustring& fileName) return spawnCommandAsync (cmdLine); } -bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName) +bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName, const Glib::ustring* command) { + if (!command) { + command = &(options.customEditorProg); + } + #if defined WIN32 - const auto cmdLine = Glib::ustring("\"") + options.customEditorProg + Glib::ustring("\""); + const auto cmdLine = Glib::ustring("\"") + *command + Glib::ustring("\""); auto success = ShellExecute( NULL, "open", cmdLine.c_str(), ('"' + fileName + '"').c_str(), NULL, SW_SHOWNORMAL ); return (uintptr_t)success > 32; #elif defined __APPLE__ - const auto cmdLine = options.customEditorProg + Glib::ustring(" \"") + fileName + Glib::ustring("\""); + const auto cmdLine = *command + Glib::ustring(" \"") + fileName + Glib::ustring("\""); return spawnCommandAsync (cmdLine); #else - const auto cmdLine = options.customEditorProg + Glib::ustring(" ") + Glib::shell_quote(fileName); + const auto cmdLine = *command + Glib::ustring(" ") + Glib::shell_quote(fileName); return spawnCommandAsync (cmdLine); #endif @@ -342,13 +346,30 @@ bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName) bool ExtProgStore::openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr &editorInfo) { + bool success = false; + try { - return editorInfo->launch(Gio::File::create_for_path(fileName)); + success = editorInfo->launch(Gio::File::create_for_path(fileName)); } catch (const Glib::Error &e) { std::cerr << "Error launching external editor.\n" << "Error code #" << e.code() << ": " << e.what() << std::endl; - return false; + success = false; } + + if (success) { + return true; + } + + if (rtengine::settings->verbose) { + std::cout << "Unable to launch external editor with Gio. Trying custom launcher." << std::endl; + } + Glib::ustring command = editorInfo->get_commandline(); +#if defined WIN32 + if (command.length() > 2 && command[0] == '"' && command[command.length() - 1] == '"') { + command = command.substr(1, command.length() - 2); + } +#endif + return openInCustomEditor(fileName, &command); } diff --git a/rtgui/extprog.h b/rtgui/extprog.h index cdcf14e48..6547896ef 100644 --- a/rtgui/extprog.h +++ b/rtgui/extprog.h @@ -69,7 +69,7 @@ public: static bool openInGimp (const Glib::ustring& fileName); static bool openInPhotoshop (const Glib::ustring& fileName); - static bool openInCustomEditor (const Glib::ustring& fileName); + static bool openInCustomEditor (const Glib::ustring& fileName, const Glib::ustring* command = nullptr); static bool openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr &editorInfo); }; diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 522ec9b7f..18b82fe36 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -1506,48 +1506,110 @@ TextOrIcon::TextOrIcon (const Glib::ustring &fname, const Glib::ustring &labelTx } -MyImageMenuItem::MyImageMenuItem(Glib::ustring label, Glib::ustring imageFileName) +class ImageAndLabel::Impl { - RTImage* itemImage = nullptr; +public: + RTImage* image; + Gtk::Label* label; - if (!imageFileName.empty()) { - itemImage = Gtk::manage(new RTImage(imageFileName)); + Impl(RTImage* image, Gtk::Label* label) : image(image), label(label) {} + static std::unique_ptr createImage(const Glib::ustring& fileName); +}; + +std::unique_ptr ImageAndLabel::Impl::createImage(const Glib::ustring& fileName) +{ + if (fileName.empty()) { + return nullptr; } - - construct(label, itemImage); + return std::unique_ptr(new RTImage(fileName)); } -MyImageMenuItem::MyImageMenuItem(Glib::ustring label, RTImage* itemImage) { - construct(label, itemImage); +ImageAndLabel::ImageAndLabel(const Glib::ustring& label, const Glib::ustring& imageFileName) : + ImageAndLabel(label, Gtk::manage(Impl::createImage(imageFileName).release())) +{ } -void MyImageMenuItem::construct(Glib::ustring label, RTImage* itemImage) +ImageAndLabel::ImageAndLabel(const Glib::ustring& label, RTImage *image) : + pimpl(new Impl(image, Gtk::manage(new Gtk::Label(label)))) { - box = Gtk::manage (new Gtk::Grid()); - this->label = Gtk::manage( new Gtk::Label(label)); - box->set_orientation(Gtk::ORIENTATION_HORIZONTAL); + Gtk::Grid* grid = Gtk::manage(new Gtk::Grid()); + grid->set_orientation(Gtk::ORIENTATION_HORIZONTAL); - if (itemImage) { - image = itemImage; - box->attach_next_to(*image, Gtk::POS_LEFT, 1, 1); - } else { - image = nullptr; + if (image) { + grid->attach_next_to(*image, Gtk::POS_LEFT, 1, 1); } - box->attach_next_to(*this->label, Gtk::POS_RIGHT, 1, 1); - box->set_column_spacing(4); - box->set_row_spacing(0); - add(*box); + grid->attach_next_to(*(pimpl->label), Gtk::POS_RIGHT, 1, 1); + grid->set_column_spacing(4); + grid->set_row_spacing(0); + pack_start(*grid, Gtk::PACK_SHRINK, 0); +} + +const RTImage* ImageAndLabel::getImage() const +{ + return pimpl->image; +} + +const Gtk::Label* ImageAndLabel::getLabel() const +{ + return pimpl->label; +} + +class MyImageMenuItem::Impl +{ +private: + std::unique_ptr widget; + +public: + Impl(const Glib::ustring &label, const Glib::ustring &imageFileName) : + widget(new ImageAndLabel(label, imageFileName)) {} + Impl(const Glib::ustring &label, RTImage *itemImage) : + widget(new ImageAndLabel(label, itemImage)) {} + ImageAndLabel* getWidget() const { return widget.get(); } +}; + +MyImageMenuItem::MyImageMenuItem(const Glib::ustring& label, const Glib::ustring& imageFileName) : + pimpl(new Impl(label, imageFileName)) +{ + add(*(pimpl->getWidget())); +} + +MyImageMenuItem::MyImageMenuItem(const Glib::ustring& label, RTImage* itemImage) : + pimpl(new Impl(label, itemImage)) +{ + add(*(pimpl->getWidget())); } const RTImage *MyImageMenuItem::getImage () const { - return image; + return pimpl->getWidget()->getImage(); } const Gtk::Label* MyImageMenuItem::getLabel () const { - return label; + return pimpl->getWidget()->getLabel(); +} + +class MyRadioImageMenuItem::Impl +{ + std::unique_ptr widget; + +public: + Impl(const Glib::ustring &label, RTImage *image) : + widget(new ImageAndLabel(label, image)) {} + ImageAndLabel* getWidget() const { return widget.get(); } +}; + +MyRadioImageMenuItem::MyRadioImageMenuItem(const Glib::ustring& label, RTImage *image, Gtk::RadioButton::Group& group) : + Gtk::RadioMenuItem(group), + pimpl(new Impl(label, image)) +{ + add(*(pimpl->getWidget())); +} + +const Gtk::Label* MyRadioImageMenuItem::getLabel() const +{ + return pimpl->getWidget()->getLabel(); } MyProgressBar::MyProgressBar(int width) : w(rtengine::max(width, 10 * RTScalable::getScale())) {} diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 4aa3e2fae..152b626de 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -494,20 +494,56 @@ public: TextOrIcon (const Glib::ustring &filename, const Glib::ustring &labelTx, const Glib::ustring &tooltipTx); }; -class MyImageMenuItem final : public Gtk::MenuItem +/** + * Widget with image and label placed horizontally. + */ +class ImageAndLabel final : public Gtk::Box { -private: - Gtk::Grid *box; - RTImage *image; - Gtk::Label *label; - - void construct(Glib::ustring label, RTImage* image); + class Impl; + std::unique_ptr pimpl; public: - MyImageMenuItem (Glib::ustring label, Glib::ustring imageFileName); - MyImageMenuItem (Glib::ustring label, RTImage* image); + ImageAndLabel(const Glib::ustring& label, const Glib::ustring& imageFileName); + ImageAndLabel(const Glib::ustring& label, RTImage* image); + const RTImage* getImage() const; + const Gtk::Label* getLabel() const; +}; + +/** + * Menu item with an image and label. + */ +class MyImageMenuItemInterface +{ +public: + virtual const Gtk::Label* getLabel() const = 0; +}; + +/** + * Basic image menu item. + */ +class MyImageMenuItem final : public Gtk::MenuItem, public MyImageMenuItemInterface +{ + class Impl; + std::unique_ptr pimpl; + +public: + MyImageMenuItem (const Glib::ustring& label, const Glib::ustring& imageFileName); + MyImageMenuItem (const Glib::ustring& label, RTImage* image); const RTImage *getImage () const; - const Gtk::Label* getLabel () const; + const Gtk::Label* getLabel() const override; +}; + +/** + * Image menu item with radio selector. + */ +class MyRadioImageMenuItem final : public Gtk::RadioMenuItem, public MyImageMenuItemInterface +{ + class Impl; + std::unique_ptr pimpl; + +public: + MyRadioImageMenuItem(const Glib::ustring& label, RTImage* image, Gtk::RadioButton::Group& group); + const Gtk::Label* getLabel() const override; }; class MyProgressBar final : public Gtk::ProgressBar diff --git a/rtgui/icmpanel.cc b/rtgui/icmpanel.cc index ccc2b5533..57f12fd7e 100644 --- a/rtgui/icmpanel.cc +++ b/rtgui/icmpanel.cc @@ -64,6 +64,7 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, TOOL_NAME, M("TP_ICM_LABEL")), iu EvICMpreser = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_ICM_PRESER"); EvICMLabGridciexy = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_ICL_LABGRIDCIEXY"); EvICMfbw = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_ICM_FBW"); + EvICMgamut = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_ICM_GAMUT"); isBatchMode = lastToneCurve = lastApplyLookTable = lastApplyBaselineExposureOffset = lastApplyHueSatMap = false; ipDialog = Gtk::manage(new MyFileChooserButton(M("TP_ICM_INPUTDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN)); @@ -265,8 +266,12 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, TOOL_NAME, M("TP_ICM_LABEL")), iu wprimBox->pack_start(*wprim, Gtk::PACK_EXPAND_WIDGET); fbw = Gtk::manage(new Gtk::CheckButton((M("TP_ICM_FBW")))); fbw->set_active(true); + gamut = Gtk::manage(new Gtk::CheckButton((M("TP_ICM_GAMUT")))); + gamut->set_active(false); + trcProfVBox->pack_start(*wprimBox, Gtk::PACK_EXPAND_WIDGET); trcProfVBox->pack_start(*fbw, Gtk::PACK_EXPAND_WIDGET); + trcProfVBox->pack_start(*gamut, Gtk::PACK_EXPAND_WIDGET); neutral = Gtk::manage (new Gtk::Button (M ("TP_ICM_NEUTRAL"))); setExpandAlignProperties (neutral, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); @@ -470,6 +475,7 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, TOOL_NAME, M("TP_ICM_LABEL")), iu wprimconn = wprim->signal_changed().connect(sigc::mem_fun(*this, &ICMPanel::wprimChanged)); fbwconn = fbw->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::fbwChanged)); + gamutconn = gamut->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::gamutChanged)); obpcconn = obpc->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::oBPCChanged)); tcurveconn = ckbToneCurve->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::toneCurveChanged)); ltableconn = ckbApplyLookTable->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::applyLookTableChanged)); @@ -515,6 +521,7 @@ void ICMPanel::neutral_pressed () wSlope->setValue(defPar.workingTRCSlope);//12.92 preser->setValue(defPar.preser); fbw->set_active(defPar.fbw); + gamut->set_active(defPar.gamut); wTRC->set_active(toUnderlying(ColorManagementParams::WorkingTrc::NONE));//reset to none will->set_active(toUnderlying(ColorManagementParams::Illuminant::DEFAULT));//reset to default - after wprim } @@ -767,6 +774,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) ConnectionBlocker obpcconn_(obpcconn); ConnectionBlocker fbwconn_(fbwconn); + ConnectionBlocker gamutconn_(gamutconn); ConnectionBlocker ipc_(ipc); ConnectionBlocker tcurveconn_(tcurveconn); ConnectionBlocker ltableconn_(ltableconn); @@ -840,6 +848,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) obpc->set_active(pp->icm.outputBPC); fbw->set_active(pp->icm.fbw); + gamut->set_active(pp->icm.gamut); ckbToneCurve->set_active(pp->icm.toneCurve); lastToneCurve = pp->icm.toneCurve; ckbApplyLookTable->set_active(pp->icm.applyLookTable); @@ -864,6 +873,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) iunchanged->set_active(!pedited->icm.inputProfile); obpc->set_inconsistent(!pedited->icm.outputBPC); fbw->set_inconsistent(!pedited->icm.fbw); + gamut->set_inconsistent(!pedited->icm.gamut); ckbToneCurve->set_inconsistent(!pedited->icm.toneCurve); ckbApplyLookTable->set_inconsistent(!pedited->icm.applyLookTable); ckbApplyBaselineExposureOffset->set_inconsistent(!pedited->icm.applyBaselineExposureOffset); @@ -922,6 +932,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(false); wprim->set_sensitive(false); fbw->set_sensitive(false); + gamut->set_sensitive(false); wprimlab->set_sensitive(false); riaHBox->set_sensitive(false); redFrame->hide(); @@ -933,6 +944,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); if (ColorManagementParams::Primaries(wprim->get_active_row_number()) == ColorManagementParams::Primaries::DEFAULT) { redFrame->hide(); @@ -975,6 +987,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -992,6 +1005,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -1009,6 +1023,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); redFrame->show(); wGamma->set_sensitive(false); @@ -1027,6 +1042,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); riaHBox->set_sensitive(true); if (ColorManagementParams::Primaries(wprim->get_active_row_number()) == ColorManagementParams::Primaries::DEFAULT) { @@ -1044,6 +1060,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -1145,6 +1162,7 @@ void ICMPanel::write(ProcParams* pp, ParamsEdited* pedited) pp->icm.applyHueSatMap = ckbApplyHueSatMap->get_active(); pp->icm.outputBPC = obpc->get_active(); pp->icm.fbw = fbw->get_active(); + pp->icm.gamut = gamut->get_active(); pp->icm.workingTRCGamma = wGamma->getValue(); pp->icm.workingTRCSlope = wSlope->getValue(); pp->icm.redx = redx->getValue(); @@ -1164,6 +1182,7 @@ void ICMPanel::write(ProcParams* pp, ParamsEdited* pedited) pedited->icm.aRendIntent = aRendIntent->getSelected() < 4; pedited->icm.outputBPC = !obpc->get_inconsistent(); pedited->icm.fbw = !fbw->get_inconsistent(); + pedited->icm.gamut = !gamut->get_inconsistent(); pedited->icm.dcpIlluminant = dcpIll->get_active_text() != M("GENERAL_UNCHANGED"); pedited->icm.toneCurve = !ckbToneCurve->get_inconsistent(); pedited->icm.applyLookTable = !ckbApplyLookTable->get_inconsistent(); @@ -1270,6 +1289,7 @@ void ICMPanel::wtrcinChanged() willulab->set_sensitive(false); wprim->set_sensitive(false); fbw->set_sensitive(false); + gamut->set_sensitive(false); wprimlab->set_sensitive(false); redFrame->hide(); riaHBox->set_sensitive(false); @@ -1280,6 +1300,7 @@ void ICMPanel::wtrcinChanged() will->set_sensitive(false); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); willulab->set_sensitive(true); if (ColorManagementParams::Primaries(wprim->get_active_row_number()) == ColorManagementParams::Primaries::DEFAULT) { @@ -1313,6 +1334,7 @@ void ICMPanel::wtrcinChanged() willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -1338,6 +1360,7 @@ void ICMPanel::wtrcinChanged() willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); riaHBox->set_sensitive(true); @@ -1364,6 +1387,7 @@ void ICMPanel::wtrcinChanged() willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -1391,6 +1415,7 @@ void ICMPanel::wtrcinChanged() willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -1418,6 +1443,7 @@ void ICMPanel::wtrcinChanged() willulab->set_sensitive(true); wprim->set_sensitive(true); fbw->set_sensitive(true); + gamut->set_sensitive(true); wprimlab->set_sensitive(true); wGamma->set_sensitive(false); wSlope->set_sensitive(false); @@ -2025,6 +2051,33 @@ void ICMPanel::fbwChanged() } } +void ICMPanel::gamutChanged() +{ + if (multiImage) { + if (gamut->get_inconsistent()) { + gamut->set_inconsistent(false); + gamutconn.block(true); + gamut->set_active(false); + gamutconn.block(false); + } else if (lastgamut) { + gamut->set_inconsistent(true); + } + + lastgamut = gamut->get_active(); + } + + if (listener) { + if (gamut->get_inconsistent()) { + listener->panelChanged(EvICMgamut, M("GENERAL_UNCHANGED")); + } else if (fbw->get_active()) { + listener->panelChanged(EvICMgamut, M("GENERAL_ENABLED")); + } else { + listener->panelChanged(EvICMgamut, M("GENERAL_DISABLED")); + } + } +} + + void ICMPanel::setRawMeta(bool raw, const rtengine::FramesData* pMeta) { diff --git a/rtgui/icmpanel.h b/rtgui/icmpanel.h index 5caa3f90e..6c670c5e6 100644 --- a/rtgui/icmpanel.h +++ b/rtgui/icmpanel.h @@ -81,6 +81,8 @@ protected: bool lastfbw; sigc::connection fbwconn; bool isBatchMode; + bool lastgamut; + sigc::connection gamutconn; private: rtengine::ProcEvent EvICMprimariMethod; @@ -107,6 +109,7 @@ private: rtengine::ProcEvent EvICMpreser; rtengine::ProcEvent EvICMLabGridciexy; rtengine::ProcEvent EvICMfbw; + rtengine::ProcEvent EvICMgamut; LabGrid *labgridcie; IdleRegister idle_register; @@ -121,6 +124,7 @@ private: Gtk::Box* iVBox; Gtk::Box* wTRCBox; Gtk::CheckButton* fbw; + Gtk::CheckButton* gamut; Gtk::CheckButton* obpc; Gtk::RadioButton* inone; @@ -198,6 +202,7 @@ public: void aiChanged(int n); void oBPCChanged(); void fbwChanged(); + void gamutChanged(); void ipChanged(); void ipSelectionChanged(); void dcpIlluminantChanged(); diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc index 08560c59a..e29733cac 100644 --- a/rtgui/labcurve.cc +++ b/rtgui/labcurve.cc @@ -19,6 +19,7 @@ #include #include "labcurve.h" +#include "eventmapper.h" #include "curveeditor.h" #include "curveeditorgroup.h" @@ -34,61 +35,80 @@ using namespace rtengine::procparams; const Glib::ustring LCurve::TOOL_NAME = "labcurves"; -LCurve::LCurve () : FoldableToolPanel(this, TOOL_NAME, M("TP_LABCURVE_LABEL"), false, true) +LCurve::LCurve() : FoldableToolPanel(this, TOOL_NAME, M("TP_LABCURVE_LABEL"), false, true) { - brightness = Gtk::manage (new Adjuster (M("TP_LABCURVE_BRIGHTNESS"), -100., 100., 1., 0.)); - contrast = Gtk::manage (new Adjuster (M("TP_LABCURVE_CONTRAST"), -100., 100., 1., 0.)); - chromaticity = Gtk::manage (new Adjuster (M("TP_LABCURVE_CHROMATICITY"), -100., 100., 1., 0.)); + auto m = ProcEventMapper::getInstance(); + Evgamutmunsell = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_GAMUTMUNSEL"); + CurveListener::setMulti(true); + brightness = Gtk::manage(new Adjuster(M("TP_LABCURVE_BRIGHTNESS"), -100., 100., 1., 0.)); + contrast = Gtk::manage(new Adjuster(M("TP_LABCURVE_CONTRAST"), -100., 100., 1., 0.)); + chromaticity = Gtk::manage(new Adjuster(M("TP_LABCURVE_CHROMATICITY"), -100., 100., 1., 0.)); chromaticity->set_tooltip_markup(M("TP_LABCURVE_CHROMA_TOOLTIP")); - pack_start (*brightness); - brightness->show (); + pack_start(*brightness); + brightness->show(); - pack_start (*contrast); - contrast->show (); + pack_start(*contrast); + contrast->show(); - pack_start (*chromaticity); - chromaticity->show (); + pack_start(*chromaticity); + chromaticity->show(); - brightness->setAdjusterListener (this); - contrast->setAdjusterListener (this); - chromaticity->setAdjusterListener (this); + brightness->setAdjusterListener(this); + contrast->setAdjusterListener(this); + chromaticity->setAdjusterListener(this); brightness->setLogScale(2, 0, true); contrast->setLogScale(2, 0, true); chromaticity->setLogScale(2, 0, true); //%%%%%%%%%%%%%%%%%% - Gtk::Separator* hsep2 = Gtk::manage (new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)); - hsep2->show (); - pack_start (*hsep2, Gtk::PACK_EXPAND_WIDGET, 4); + Gtk::Separator* hsep2 = Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)); + hsep2->show(); + pack_start(*hsep2, Gtk::PACK_EXPAND_WIDGET, 4); - avoidcolorshift = Gtk::manage (new Gtk::CheckButton (M("TP_LABCURVE_AVOIDCOLORSHIFT"))); - avoidcolorshift->set_tooltip_text (M("TP_LABCURVE_AVOIDCOLORSHIFT_TOOLTIP")); - pack_start (*avoidcolorshift, Gtk::PACK_SHRINK, 4); - lcredsk = Gtk::manage (new Gtk::CheckButton (M("TP_LABCURVE_LCREDSK"))); - lcredsk->set_tooltip_markup (M("TP_LABCURVE_LCREDSK_TOOLTIP")); - pack_start (*lcredsk); - rstprotection = Gtk::manage ( new Adjuster (M("TP_LABCURVE_RSTPROTECTION"), 0., 100., 0.1, 0.) ); - pack_start (*rstprotection); - rstprotection->show (); - rstprotection->setAdjusterListener (this); - rstprotection->set_tooltip_text (M("TP_LABCURVE_RSTPRO_TOOLTIP")); + Gtk::Box* metHBox = Gtk::manage(new Gtk::Box()); + metHBox->set_spacing(2); + Gtk::Label* metLabel = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_AVOID") + ":")); + metHBox->pack_start(*metLabel, Gtk::PACK_SHRINK); - acconn = avoidcolorshift->signal_toggled().connect( sigc::mem_fun(*this, &LCurve::avoidcolorshift_toggled) ); - lcconn = lcredsk->signal_toggled().connect( sigc::mem_fun(*this, &LCurve::lcredsk_toggled) ); + gamutmunselmethod = Gtk::manage(new MyComboBoxText()); + gamutmunselmethod->append(M("TP_LOCALLAB_GAMUTNON")); + gamutmunselmethod->append(M("TP_LOCALLAB_GAMUTLABRELA")); + gamutmunselmethod->append(M("TP_LOCALLAB_GAMUTXYZABSO")); + gamutmunselmethod->append(M("TP_LOCALLAB_GAMUTXYZRELA")); + gamutmunselmethod->append(M("TP_LOCALLAB_GAMUTMUNSELL")); + gamutmunselmethod->set_active(4); + gamutmunselmethod->set_tooltip_text(M("TP_LOCALLAB_AVOIDCOLORSHIFT_TOOLTIP")); + metHBox->pack_start(*gamutmunselmethod); + pack_start(*metHBox); + gamutmunselmethodconn = gamutmunselmethod->signal_changed().connect(sigc::mem_fun(*this, &LCurve::gamutmunselChanged)); + + + lcredsk = Gtk::manage(new Gtk::CheckButton(M("TP_LABCURVE_LCREDSK"))); + lcredsk->set_tooltip_markup(M("TP_LABCURVE_LCREDSK_TOOLTIP")); + pack_start(*lcredsk); + + rstprotection = Gtk::manage(new Adjuster(M("TP_LABCURVE_RSTPROTECTION"), 0., 100., 0.1, 0.)); + pack_start(*rstprotection); + rstprotection->show(); + + rstprotection->setAdjusterListener(this); + rstprotection->set_tooltip_text(M("TP_LABCURVE_RSTPRO_TOOLTIP")); + + lcconn = lcredsk->signal_toggled().connect(sigc::mem_fun(*this, &LCurve::lcredsk_toggled)); //%%%%%%%%%%%%%%%%%%% - Gtk::Separator* hsep3 = Gtk::manage (new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)); - hsep3->show (); - pack_start (*hsep3, Gtk::PACK_EXPAND_WIDGET, 4); + Gtk::Separator* hsep3 = Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)); + hsep3->show(); + pack_start(*hsep3, Gtk::PACK_EXPAND_WIDGET, 4); - curveEditorG = new CurveEditorGroup (options.lastLabCurvesDir); - curveEditorG->setCurveListener (this); + curveEditorG = new CurveEditorGroup(options.lastLabCurvesDir); + curveEditorG->setCurveListener(this); lshape = static_cast(curveEditorG->addCurve(CT_Diagonal, "L*")); lshape->setTooltip(M("TP_LABCURVE_CURVEEDITOR_LL_TOOLTIP")); @@ -218,88 +238,111 @@ LCurve::LCurve () : FoldableToolPanel(this, TOOL_NAME, M("TP_LABCURVE_LABEL"), f // This will add the reset button at the end of the curveType buttons curveEditorG->curveListComplete(); - pack_start (*curveEditorG, Gtk::PACK_SHRINK, 4); - Gtk::Separator* hsepdh = Gtk::manage (new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)); - hsepdh->show (); - pack_start (*hsepdh, Gtk::PACK_EXPAND_WIDGET, 4); + pack_start(*curveEditorG, Gtk::PACK_SHRINK, 4); + Gtk::Separator* hsepdh = Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)); + hsepdh->show(); + pack_start(*hsepdh, Gtk::PACK_EXPAND_WIDGET, 4); + show_all_children(); } -LCurve::~LCurve () +LCurve::~LCurve() { delete curveEditorG; } -void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited) +void LCurve::read(const ProcParams* pp, const ParamsEdited* pedited) { - disableListener (); + disableListener(); + gamutmunselmethodconn.block(true); + + + brightness->setValue(pp->labCurve.brightness); + contrast->setValue(pp->labCurve.contrast); + chromaticity->setValue(pp->labCurve.chromaticity); + adjusterChanged(chromaticity, pp->labCurve.chromaticity); // To update the GUI sensitiveness + //%%%%%%%%%%%%%%%%%%%%%% + rstprotection->setValue(pp->labCurve.rstprotection); + + + bwtconn.block(true); + lcconn.block(true); + lcredsk->set_active(pp->labCurve.lcredsk); + + bwtconn.block(false); + lcconn.block(false); + + lastLCVal = pp->labCurve.lcredsk; + //%%%%%%%%%%%%%%%%%%%%%% + + lshape->setCurve(pp->labCurve.lcurve); + ashape->setCurve(pp->labCurve.acurve); + bshape->setCurve(pp->labCurve.bcurve); + ccshape->setCurve(pp->labCurve.cccurve); + chshape->setCurve(pp->labCurve.chcurve); + lhshape->setCurve(pp->labCurve.lhcurve); + hhshape->setCurve(pp->labCurve.hhcurve); + lcshape->setCurve(pp->labCurve.lccurve); + clshape->setCurve(pp->labCurve.clcurve); + + if (pedited && !pedited->labCurve.gamutmunselmethod) { + gamutmunselmethod->set_active(4); // "Unchanged" + } else if (pp->labCurve.gamutmunselmethod == "NONE") { + gamutmunselmethod->set_active(0); + } else if (pp->labCurve.gamutmunselmethod == "LAB") { + gamutmunselmethod->set_active(1); + } else if (pp->labCurve.gamutmunselmethod == "XYZ") { + gamutmunselmethod->set_active(2); + } else if (pp->labCurve.gamutmunselmethod == "XYZREL") { + gamutmunselmethod->set_active(3); + } else if (pp->labCurve.gamutmunselmethod == "MUN") { + gamutmunselmethod->set_active(4); + } + + gamutmunselChanged(); if (pedited) { - brightness->setEditedState (pedited->labCurve.brightness ? Edited : UnEdited); - contrast->setEditedState (pedited->labCurve.contrast ? Edited : UnEdited); - chromaticity->setEditedState (pedited->labCurve.chromaticity ? Edited : UnEdited); + brightness->setEditedState(pedited->labCurve.brightness ? Edited : UnEdited); + contrast->setEditedState(pedited->labCurve.contrast ? Edited : UnEdited); + chromaticity->setEditedState(pedited->labCurve.chromaticity ? Edited : UnEdited); //%%%%%%%%%%%%%%%%%%%%%% - rstprotection->setEditedState (pedited->labCurve.rstprotection ? Edited : UnEdited); - avoidcolorshift->set_inconsistent (!pedited->labCurve.avoidcolorshift); - lcredsk->set_inconsistent (!pedited->labCurve.lcredsk); + rstprotection->setEditedState(pedited->labCurve.rstprotection ? Edited : UnEdited); + lcredsk->set_inconsistent(!pedited->labCurve.lcredsk); //%%%%%%%%%%%%%%%%%%%%%% - lshape->setUnChanged (!pedited->labCurve.lcurve); - ashape->setUnChanged (!pedited->labCurve.acurve); - bshape->setUnChanged (!pedited->labCurve.bcurve); - ccshape->setUnChanged (!pedited->labCurve.cccurve); - chshape->setUnChanged (!pedited->labCurve.chcurve); - lhshape->setUnChanged (!pedited->labCurve.lhcurve); - hhshape->setUnChanged (!pedited->labCurve.hhcurve); - lcshape->setUnChanged (!pedited->labCurve.lccurve); - clshape->setUnChanged (!pedited->labCurve.clcurve); + lshape->setUnChanged(!pedited->labCurve.lcurve); + ashape->setUnChanged(!pedited->labCurve.acurve); + bshape->setUnChanged(!pedited->labCurve.bcurve); + ccshape->setUnChanged(!pedited->labCurve.cccurve); + chshape->setUnChanged(!pedited->labCurve.chcurve); + lhshape->setUnChanged(!pedited->labCurve.lhcurve); + hhshape->setUnChanged(!pedited->labCurve.hhcurve); + lcshape->setUnChanged(!pedited->labCurve.lccurve); + clshape->setUnChanged(!pedited->labCurve.clcurve); + + if (!pedited->labCurve.gamutmunselmethod) { + gamutmunselmethod->set_active_text(M("GENERAL_UNCHANGED")); + } set_inconsistent(multiImage && !pedited->labCurve.enabled); } - brightness->setValue (pp->labCurve.brightness); - contrast->setValue (pp->labCurve.contrast); - chromaticity->setValue (pp->labCurve.chromaticity); - adjusterChanged(chromaticity, pp->labCurve.chromaticity); // To update the GUI sensitiveness - //%%%%%%%%%%%%%%%%%%%%%% - rstprotection->setValue (pp->labCurve.rstprotection); + gamutmunselmethodconn.block(false); - bwtconn.block (true); - acconn.block (true); - lcconn.block (true); - avoidcolorshift->set_active (pp->labCurve.avoidcolorshift); - lcredsk->set_active (pp->labCurve.lcredsk); - - bwtconn.block (false); - acconn.block (false); - lcconn.block (false); - - lastACVal = pp->labCurve.avoidcolorshift; - lastLCVal = pp->labCurve.lcredsk; - //%%%%%%%%%%%%%%%%%%%%%% - - lshape->setCurve (pp->labCurve.lcurve); - ashape->setCurve (pp->labCurve.acurve); - bshape->setCurve (pp->labCurve.bcurve); - ccshape->setCurve (pp->labCurve.cccurve); - chshape->setCurve (pp->labCurve.chcurve); - lhshape->setCurve (pp->labCurve.lhcurve); - hhshape->setCurve (pp->labCurve.hhcurve); - lcshape->setCurve (pp->labCurve.lccurve); - clshape->setCurve (pp->labCurve.clcurve); setEnabled(pp->labCurve.enabled); - + queue_draw(); - enableListener (); + enableListener(); } -void LCurve::autoOpenCurve () + +void LCurve::autoOpenCurve() { // Open up the first curve if selected bool active = lshape->openIfNonlinear(); @@ -338,7 +381,7 @@ void LCurve::autoOpenCurve () } -void LCurve::setEditProvider (EditDataProvider *provider) +void LCurve::setEditProvider(EditDataProvider *provider) { lshape->setEditProvider(provider); ccshape->setEditProvider(provider); @@ -353,127 +396,128 @@ void LCurve::setEditProvider (EditDataProvider *provider) } -void LCurve::write (ProcParams* pp, ParamsEdited* pedited) +void LCurve::write(ProcParams* pp, ParamsEdited* pedited) { pp->labCurve.enabled = getEnabled(); - - pp->labCurve.brightness = brightness->getValue (); - pp->labCurve.contrast = (int)contrast->getValue (); - pp->labCurve.chromaticity = (int)chromaticity->getValue (); - //%%%%%%%%%%%%%%%%%%%%%% - pp->labCurve.avoidcolorshift = avoidcolorshift->get_active (); - pp->labCurve.lcredsk = lcredsk->get_active (); - pp->labCurve.rstprotection = rstprotection->getValue (); + pp->labCurve.brightness = brightness->getValue(); + pp->labCurve.contrast = (int)contrast->getValue(); + pp->labCurve.chromaticity = (int)chromaticity->getValue(); + //%%%%%%%%%%%%%%%%%%%%%% + pp->labCurve.lcredsk = lcredsk->get_active(); + + pp->labCurve.rstprotection = rstprotection->getValue(); //%%%%%%%%%%%%%%%%%%%%%% - pp->labCurve.lcurve = lshape->getCurve (); - pp->labCurve.acurve = ashape->getCurve (); - pp->labCurve.bcurve = bshape->getCurve (); - pp->labCurve.cccurve = ccshape->getCurve (); - pp->labCurve.chcurve = chshape->getCurve (); - pp->labCurve.lhcurve = lhshape->getCurve (); - pp->labCurve.hhcurve = hhshape->getCurve (); - pp->labCurve.lccurve = lcshape->getCurve (); - pp->labCurve.clcurve = clshape->getCurve (); + pp->labCurve.lcurve = lshape->getCurve(); + pp->labCurve.acurve = ashape->getCurve(); + pp->labCurve.bcurve = bshape->getCurve(); + pp->labCurve.cccurve = ccshape->getCurve(); + pp->labCurve.chcurve = chshape->getCurve(); + pp->labCurve.lhcurve = lhshape->getCurve(); + pp->labCurve.hhcurve = hhshape->getCurve(); + pp->labCurve.lccurve = lcshape->getCurve(); + pp->labCurve.clcurve = clshape->getCurve(); + + if (pedited) { - pedited->labCurve.brightness = brightness->getEditedState (); - pedited->labCurve.contrast = contrast->getEditedState (); - pedited->labCurve.chromaticity = chromaticity->getEditedState (); + pedited->labCurve.brightness = brightness->getEditedState(); + pedited->labCurve.contrast = contrast->getEditedState(); + pedited->labCurve.chromaticity = chromaticity->getEditedState(); //%%%%%%%%%%%%%%%%%%%%%% - pedited->labCurve.avoidcolorshift = !avoidcolorshift->get_inconsistent(); pedited->labCurve.lcredsk = !lcredsk->get_inconsistent(); - pedited->labCurve.rstprotection = rstprotection->getEditedState (); + pedited->labCurve.rstprotection = rstprotection->getEditedState(); + pedited->labCurve.gamutmunselmethod = gamutmunselmethod->get_active_text() != M("GENERAL_UNCHANGED"); - pedited->labCurve.lcurve = !lshape->isUnChanged (); - pedited->labCurve.acurve = !ashape->isUnChanged (); - pedited->labCurve.bcurve = !bshape->isUnChanged (); - pedited->labCurve.cccurve = !ccshape->isUnChanged (); - pedited->labCurve.chcurve = !chshape->isUnChanged (); - pedited->labCurve.lhcurve = !lhshape->isUnChanged (); - pedited->labCurve.hhcurve = !hhshape->isUnChanged (); - pedited->labCurve.lccurve = !lcshape->isUnChanged (); - pedited->labCurve.clcurve = !clshape->isUnChanged (); + pedited->labCurve.lcurve = !lshape->isUnChanged(); + pedited->labCurve.acurve = !ashape->isUnChanged(); + pedited->labCurve.bcurve = !bshape->isUnChanged(); + pedited->labCurve.cccurve = !ccshape->isUnChanged(); + pedited->labCurve.chcurve = !chshape->isUnChanged(); + pedited->labCurve.lhcurve = !lhshape->isUnChanged(); + pedited->labCurve.hhcurve = !hhshape->isUnChanged(); + pedited->labCurve.lccurve = !lcshape->isUnChanged(); + pedited->labCurve.clcurve = !clshape->isUnChanged(); pedited->labCurve.enabled = !get_inconsistent(); + } + if (gamutmunselmethod->get_active_row_number() == 0) { + pp->labCurve.gamutmunselmethod = "NONE"; + } else if (gamutmunselmethod->get_active_row_number() == 1) { + pp->labCurve.gamutmunselmethod = "LAB"; + } else if (gamutmunselmethod->get_active_row_number() == 2) { + pp->labCurve.gamutmunselmethod = "XYZ"; + } else if (gamutmunselmethod->get_active_row_number() == 3) { + pp->labCurve.gamutmunselmethod = "XYZREL"; + } else if (gamutmunselmethod->get_active_row_number() == 4) { + pp->labCurve.gamutmunselmethod = "MUN"; + } + + + } -void LCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) +void LCurve::setDefaults(const ProcParams* defParams, const ParamsEdited* pedited) { - brightness->setDefault (defParams->labCurve.brightness); - contrast->setDefault (defParams->labCurve.contrast); - chromaticity->setDefault (defParams->labCurve.chromaticity); - rstprotection->setDefault (defParams->labCurve.rstprotection); + brightness->setDefault(defParams->labCurve.brightness); + contrast->setDefault(defParams->labCurve.contrast); + chromaticity->setDefault(defParams->labCurve.chromaticity); + rstprotection->setDefault(defParams->labCurve.rstprotection); if (pedited) { - brightness->setDefaultEditedState (pedited->labCurve.brightness ? Edited : UnEdited); - contrast->setDefaultEditedState (pedited->labCurve.contrast ? Edited : UnEdited); - chromaticity->setDefaultEditedState (pedited->labCurve.chromaticity ? Edited : UnEdited); - rstprotection->setDefaultEditedState (pedited->labCurve.rstprotection ? Edited : UnEdited); + brightness->setDefaultEditedState(pedited->labCurve.brightness ? Edited : UnEdited); + contrast->setDefaultEditedState(pedited->labCurve.contrast ? Edited : UnEdited); + chromaticity->setDefaultEditedState(pedited->labCurve.chromaticity ? Edited : UnEdited); + rstprotection->setDefaultEditedState(pedited->labCurve.rstprotection ? Edited : UnEdited); } else { - brightness->setDefaultEditedState (Irrelevant); - contrast->setDefaultEditedState (Irrelevant); - chromaticity->setDefaultEditedState (Irrelevant); - rstprotection->setDefaultEditedState (Irrelevant); + brightness->setDefaultEditedState(Irrelevant); + contrast->setDefaultEditedState(Irrelevant); + chromaticity->setDefaultEditedState(Irrelevant); + rstprotection->setDefaultEditedState(Irrelevant); } } //%%%%%%%%%%%%%%%%%%%%%% -//Color shift control changed -void LCurve::avoidcolorshift_toggled () + +void LCurve::gamutmunselChanged() { - if (batchMode) { - if (avoidcolorshift->get_inconsistent()) { - avoidcolorshift->set_inconsistent (false); - acconn.block (true); - avoidcolorshift->set_active (false); - acconn.block (false); - } else if (lastACVal) { - avoidcolorshift->set_inconsistent (true); - } - - lastACVal = avoidcolorshift->get_active (); + if (listener && (multiImage || getEnabled())) { + listener->panelChanged(Evgamutmunsell, gamutmunselmethod->get_active_text()); } - if (listener && getEnabled()) { - if (avoidcolorshift->get_active ()) { - listener->panelChanged (EvLAvoidColorShift, M("GENERAL_ENABLED")); - } else { - listener->panelChanged (EvLAvoidColorShift, M("GENERAL_DISABLED")); - } - } } -void LCurve::lcredsk_toggled () + +void LCurve::lcredsk_toggled() { if (batchMode) { if (lcredsk->get_inconsistent()) { - lcredsk->set_inconsistent (false); - lcconn.block (true); - lcredsk->set_active (false); - lcconn.block (false); + lcredsk->set_inconsistent(false); + lcconn.block(true); + lcredsk->set_active(false); + lcconn.block(false); } else if (lastLCVal) { - lcredsk->set_inconsistent (true); + lcredsk->set_inconsistent(true); } - lastLCVal = lcredsk->get_active (); + lastLCVal = lcredsk->get_active(); } else { lcshape->refresh(); } if (listener && getEnabled()) { - if (lcredsk->get_active ()) { - listener->panelChanged (EvLLCredsk, M("GENERAL_ENABLED")); + if (lcredsk->get_active()) { + listener->panelChanged(EvLLCredsk, M("GENERAL_ENABLED")); } else { - listener->panelChanged (EvLLCredsk, M("GENERAL_DISABLED")); + listener->panelChanged(EvLLCredsk, M("GENERAL_DISABLED")); } } } @@ -486,44 +530,44 @@ void LCurve::lcredsk_toggled () * If more than one curve has been added, the curve listener is automatically * set to 'multi=true', and send a pointer of the modified curve in a parameter */ -void LCurve::curveChanged (CurveEditor* ce) +void LCurve::curveChanged(CurveEditor* ce) { if (listener && getEnabled()) { if (ce == lshape) { - listener->panelChanged (EvLLCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLLCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == ashape) { - listener->panelChanged (EvLaCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLaCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == bshape) { - listener->panelChanged (EvLbCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLbCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == ccshape) { - listener->panelChanged (EvLCCCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLCCCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == chshape) { - listener->panelChanged (EvLCHCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLCHCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == lhshape) { - listener->panelChanged (EvLLHCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLLHCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == hhshape) { - listener->panelChanged (EvLHHCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLHHCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == lcshape) { - listener->panelChanged (EvLLCCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLLCCurve, M("HISTORY_CUSTOMCURVE")); } if (ce == clshape) { - listener->panelChanged (EvLCLCurve, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged(EvLCLCurve, M("HISTORY_CUSTOMCURVE")); } @@ -535,45 +579,43 @@ void LCurve::adjusterChanged(Adjuster* a, double newval) Glib::ustring costr; if (a == brightness) { - costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), a->getValue()); + costr = Glib::ustring::format(std::setw(3), std::fixed, std::setprecision(2), a->getValue()); } else if (a == rstprotection) { - costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(1), a->getValue()); + costr = Glib::ustring::format(std::setw(3), std::fixed, std::setprecision(1), a->getValue()); } else { - costr = Glib::ustring::format ((int)a->getValue()); + costr = Glib::ustring::format((int)a->getValue()); } if (a == brightness) { if (listener && getEnabled()) { - listener->panelChanged (EvLBrightness, costr); + listener->panelChanged(EvLBrightness, costr); } } else if (a == contrast) { if (listener && getEnabled()) { - listener->panelChanged (EvLContrast, costr); + listener->panelChanged(EvLContrast, costr); } } else if (a == rstprotection) { if (listener && getEnabled()) { - listener->panelChanged (EvLRSTProtection, costr); + listener->panelChanged(EvLRSTProtection, costr); } } else if (a == chromaticity) { if (multiImage) { //if chromaticity==-100 (lowest value), we enter the B&W mode and avoid color shift and rstprotection has no effect - rstprotection->set_sensitive( true ); - avoidcolorshift->set_sensitive( true ); - lcredsk->set_sensitive( true ); + rstprotection->set_sensitive(true); + lcredsk->set_sensitive(true); } else { //if chromaticity==-100 (lowest value), we enter the B&W mode and avoid color shift and rstprotection has no effect - rstprotection->set_sensitive( int(newval) > -100 ); //no reason for grey rstprotection - avoidcolorshift->set_sensitive( int(newval) > -100 ); - lcredsk->set_sensitive( int(newval) > -100 ); + rstprotection->set_sensitive(int(newval) > -100); //no reason for grey rstprotection + lcredsk->set_sensitive(int(newval) > -100); } if (listener && getEnabled()) { - listener->panelChanged (EvLSaturation, costr); + listener->panelChanged(EvLSaturation, costr); } } } -void LCurve::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) +void LCurve::colorForValue(double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) { float R = 0.f, G = 0.f, B = 0.f; @@ -588,47 +630,54 @@ void LCurve::colorForValue (double valX, double valY, enum ColorCaller::ElemType float value = (1.f - 0.7f) * float(valX) + 0.7f; // whole hue range // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) - Color::hsv2rgb01(float(valY*0.8), float(valX), value, R, G, B); + Color::hsv2rgb01(float(valY * 0.8), float(valX), value, R, G, B); } else if (callerId == 6) { // cc - left bar float value = (1.f - 0.7f) * float(valX) + 0.7f; float hue = (1.14056f - 0.92f) * float(valY) + 0.92f; + if (hue > 1.0f) { hue -= 1.0f; } + // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) Color::hsv2rgb01(hue, float(valX), value, R, G, B); } else if (callerId == 3) { // lc - bottom bar float value = (1.f - 0.7f) * float(valX) + 0.7f; + if (lcredsk->get_active()) { // skin range // -0.1 rad < Hue < 1.6 rad // Y axis / from 0.92 up to 0.14056 float hue = (1.14056f - 0.92f) * float(valY) + 0.92f; + if (hue > 1.0f) { hue -= 1.0f; } + // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) Color::hsv2rgb01(hue, float(valX), value, R, G, B); } else { // whole hue range // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) - Color::hsv2rgb01(float(valY*0.8), float(valX), value, R, G, B); + Color::hsv2rgb01(float(valY * 0.8), float(valX), value, R, G, B); } } else if (callerId == 4) { // LH - bottom bar Color::hsv2rgb01(float(valX), 0.5f, float(valY), R, G, B); } else if (callerId == 5) { // HH - bottom bar float h = float((valY - 0.5) * 0.3 + valX); + if (h > 1.0f) { h -= 1.0f; } else if (h < 0.0f) { h += 1.0f; } + Color::hsv2rgb01(h, 0.5f, 0.5f, R, G, B); } else if (callerId == 7) { // cc and cl - left bar float value = (1.f - 0.7f) * float(valX) + 0.7f; // whole hue range // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) - Color::hsv2rgb01(float(valY*0.8), 1.f - float(valX), value, R, G, B); + Color::hsv2rgb01(float(valY * 0.8), 1.f - float(valX), value, R, G, B); } caller->ccRed = double(R); @@ -636,17 +685,19 @@ void LCurve::colorForValue (double valX, double valY, enum ColorCaller::ElemType caller->ccBlue = double(B); } -void LCurve::setBatchMode (bool batchMode) +void LCurve::setBatchMode(bool batchMode) { - ToolPanel::setBatchMode (batchMode); - brightness->showEditedCB (); - contrast->showEditedCB (); - chromaticity->showEditedCB (); - rstprotection->showEditedCB (); - curveEditorG->setBatchMode (batchMode); + ToolPanel::setBatchMode(batchMode); + brightness->showEditedCB(); + contrast->showEditedCB(); + chromaticity->showEditedCB(); + rstprotection->showEditedCB(); + curveEditorG->setBatchMode(batchMode); lcshape->setBottomBarColorProvider(nullptr, -1); lcshape->setLeftBarColorProvider(nullptr, -1); + gamutmunselmethod->append(M("GENERAL_UNCHANGED")); + } @@ -663,13 +714,13 @@ void LCurve::updateCurveBackgroundHistogram( const LUTu& histLRETI ) { - lshape->updateBackgroundHistogram (histLCurve); - ccshape->updateBackgroundHistogram (histCCurve); - lcshape->updateBackgroundHistogram (histCCurve); - clshape->updateBackgroundHistogram (histLCurve); + lshape->updateBackgroundHistogram(histLCurve); + ccshape->updateBackgroundHistogram(histCCurve); + lcshape->updateBackgroundHistogram(histCCurve); + clshape->updateBackgroundHistogram(histLCurve); } -void LCurve::setAdjusterBehavior (bool bradd, bool contradd, bool satadd) +void LCurve::setAdjusterBehavior(bool bradd, bool contradd, bool satadd) { brightness->setAddMode(bradd); @@ -677,7 +728,7 @@ void LCurve::setAdjusterBehavior (bool bradd, bool contradd, bool satadd) chromaticity->setAddMode(satadd); } -void LCurve::trimValues (rtengine::procparams::ProcParams* pp) +void LCurve::trimValues(rtengine::procparams::ProcParams* pp) { brightness->trimValue(pp->labCurve.brightness); @@ -689,11 +740,11 @@ void LCurve::enabledChanged() { if (listener) { if (get_inconsistent()) { - listener->panelChanged (EvLEnabled, M("GENERAL_UNCHANGED")); + listener->panelChanged(EvLEnabled, M("GENERAL_UNCHANGED")); } else if (getEnabled()) { - listener->panelChanged (EvLEnabled, M("GENERAL_ENABLED")); + listener->panelChanged(EvLEnabled, M("GENERAL_ENABLED")); } else { - listener->panelChanged (EvLEnabled, M("GENERAL_DISABLED")); + listener->panelChanged(EvLEnabled, M("GENERAL_DISABLED")); } } } diff --git a/rtgui/labcurve.h b/rtgui/labcurve.h index b9039baca..99e0cf0c4 100644 --- a/rtgui/labcurve.h +++ b/rtgui/labcurve.h @@ -59,11 +59,14 @@ protected: DiagonalCurveEditor* cdshape; //%%%%%%%%%%%%%%%% - Gtk::CheckButton* avoidcolorshift; Gtk::CheckButton* lcredsk; + MyComboBoxText* gamutmunselmethod; + sigc::connection gamutmunselmethodconn; + rtengine::ProcEvent Evgamutmunsell; + Adjuster* rstprotection; - sigc::connection bwtconn, acconn, lcconn; + sigc::connection bwtconn, lcconn; bool lastACVal, lastLCVal; //%%%%%%%%%%%%%%%% @@ -85,8 +88,8 @@ public: void curveChanged (CurveEditor* ce) override; void adjusterChanged (Adjuster* a, double newval) override; - void avoidcolorshift_toggled (); void lcredsk_toggled(); + void gamutmunselChanged(); void updateCurveBackgroundHistogram( const LUTu& histToneCurve, diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index b01783875..8e8e999d3 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -279,6 +279,18 @@ void Locallab::read(const rtengine::procparams::ProcParams* pp, const ParamsEdit } else { r->shapeMethod = 3; } + + if (pp->locallab.spots.at(i).avoidgamutMethod == "NONE") { + r->avoidgamutMethod = 0; + } else if (pp->locallab.spots.at(i).avoidgamutMethod == "LAB") { + r->avoidgamutMethod = 1; + } else if (pp->locallab.spots.at(i).avoidgamutMethod == "XYZ") { + r->avoidgamutMethod= 2; + } else if (pp->locallab.spots.at(i).avoidgamutMethod == "XYZREL") { + r->avoidgamutMethod= 3; + } else if (pp->locallab.spots.at(i).avoidgamutMethod == "MUNS") { + r->avoidgamutMethod= 4; + } r->locX = pp->locallab.spots.at(i).loc.at(0); r->locXL = pp->locallab.spots.at(i).loc.at(1); @@ -308,8 +320,6 @@ void Locallab::read(const rtengine::procparams::ProcParams* pp, const ParamsEdit r->avoidrad = pp->locallab.spots.at(i).avoidrad; r->hishow = pp->locallab.spots.at(i).hishow; r->activ = pp->locallab.spots.at(i).activ; - r->avoid = pp->locallab.spots.at(i).avoid; - r->avoidmun = pp->locallab.spots.at(i).avoidmun; r->blwh = pp->locallab.spots.at(i).blwh; r->recurs = pp->locallab.spots.at(i).recurs; r->laplac = true; //pp->locallab.spots.at(i).laplac; @@ -443,6 +453,18 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited r->shapeMethod = 3; } + if (newSpot->avoidgamutMethod == "NONE") { + r->avoidgamutMethod = 0; + } else if (newSpot->avoidgamutMethod == "LAB") { + r->avoidgamutMethod = 1; + } else if (newSpot->avoidgamutMethod == "XYZ") { + r->avoidgamutMethod = 2; + } else if (newSpot->avoidgamutMethod == "XYZREL") { + r->avoidgamutMethod = 3; + } else if (newSpot->avoidgamutMethod == "MUNS") { + r->avoidgamutMethod = 4; + } + // Calculate spot size and center position according to preview area if (provider && !batchMode) { provider->getImageSize(imW, imH); @@ -490,8 +512,6 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited r->avoidrad = newSpot->avoidrad; r->hishow = newSpot->hishow; r->activ = newSpot->activ; - r->avoid = newSpot->avoid; - r->avoidmun = newSpot->avoidmun; r->blwh = newSpot->blwh; r->recurs = newSpot->recurs; r->laplac = newSpot->laplac; @@ -744,6 +764,18 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited r->shapeMethod = 3; } //printf("n0=%f n1=%f n2=%f n3=%f\n", (double) newSpot->loc.at(0), (double) newSpot->loc.at(1), (double) newSpot->loc.at(2), (double) newSpot->loc.at(3)); + if (newSpot->avoidgamutMethod == "NONE") { + r->avoidgamutMethod = 0; + } else if (newSpot->avoidgamutMethod == "LAB") { + r->avoidgamutMethod = 1; + } else if (newSpot->avoidgamutMethod== "XYZ") { + r->avoidgamutMethod = 2; + } else if (newSpot->avoidgamutMethod== "XYZREL") { + r->avoidgamutMethod = 3; + } else if (newSpot->avoidgamutMethod== "MUNS") { + r->avoidgamutMethod = 4; + } + //printf("n0=%f n1=%f n2=%f n3=%f\n", (double) newSpot->loc.at(0), (double) newSpot->loc.at(1), (double) newSpot->loc.at(2), (double) newSpot->loc.at(3)); // Calculate spot size and center position according to preview area if (provider && !batchMode) { @@ -801,8 +833,6 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited r->colorscope = newSpot->colorscope; r->avoidrad = newSpot->avoidrad; r->activ = newSpot->activ; - r->avoid = newSpot->avoid; - r->avoidmun = newSpot->avoidmun; r->blwh = newSpot->blwh; r->recurs = newSpot->recurs; r->laplac = newSpot->laplac; @@ -929,6 +959,18 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pp->locallab.spots.at(pp->locallab.selspot).shapeMethod = "SYMSL"; } + if (r->avoidgamutMethod == 0) { + pp->locallab.spots.at(pp->locallab.selspot).avoidgamutMethod = "NONE"; + } else if (r->avoidgamutMethod == 1) { + pp->locallab.spots.at(pp->locallab.selspot).avoidgamutMethod = "LAB"; + } else if (r->avoidgamutMethod == 2) { + pp->locallab.spots.at(pp->locallab.selspot).avoidgamutMethod = "XYZ"; + } else if (r->avoidgamutMethod == 3) { + pp->locallab.spots.at(pp->locallab.selspot).avoidgamutMethod = "XYZREL"; + } else if (r->avoidgamutMethod == 4) { + pp->locallab.spots.at(pp->locallab.selspot).avoidgamutMethod = "MUNS"; + } + pp->locallab.spots.at(pp->locallab.selspot).loc.at(0) = r->locX; pp->locallab.spots.at(pp->locallab.selspot).loc.at(1) = r->locXL; pp->locallab.spots.at(pp->locallab.selspot).loc.at(2) = r->locY; @@ -957,8 +999,6 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pp->locallab.spots.at(pp->locallab.selspot).avoidrad = r->avoidrad; pp->locallab.spots.at(pp->locallab.selspot).hishow = r->hishow; pp->locallab.spots.at(pp->locallab.selspot).activ = r->activ; - pp->locallab.spots.at(pp->locallab.selspot).avoid = r->avoid; - pp->locallab.spots.at(pp->locallab.selspot).avoidmun = r->avoidmun; pp->locallab.spots.at(pp->locallab.selspot).blwh = r->blwh; pp->locallab.spots.at(pp->locallab.selspot).recurs = r->recurs; pp->locallab.spots.at(pp->locallab.selspot).laplac = r->laplac; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 9c7a92f39..7d641d753 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -104,7 +104,7 @@ void ParamsEdited::set(bool v) labCurve.brightness = v; labCurve.contrast = v; labCurve.chromaticity = v; - labCurve.avoidcolorshift = v; + labCurve.gamutmunselmethod = v; labCurve.rstprotection = v; labCurve.lcredsk = v; localContrast.enabled = v; @@ -254,7 +254,6 @@ void ParamsEdited::set(bool v) colorappearance.ybout = v; colorappearance.tempsc = v; colorappearance.greensc = v; - colorappearance.presetcat02 = v; //colorBoost.amount = v; //colorBoost.avoidclip = v; @@ -453,6 +452,7 @@ void ParamsEdited::set(bool v) icm.bluy = v; icm.preser = v; icm.fbw = v; + icm.gamut = v; icm.labgridcieALow = v; icm.labgridcieBLow = v; icm.labgridcieAHigh = v; @@ -804,7 +804,7 @@ void ParamsEdited::initFrom(const std::vector& labCurve.brightness = labCurve.brightness && p.labCurve.brightness == other.labCurve.brightness; labCurve.contrast = labCurve.contrast && p.labCurve.contrast == other.labCurve.contrast; labCurve.chromaticity = labCurve.chromaticity && p.labCurve.chromaticity == other.labCurve.chromaticity; - labCurve.avoidcolorshift = labCurve.avoidcolorshift && p.labCurve.avoidcolorshift == other.labCurve.avoidcolorshift; + labCurve.gamutmunselmethod = labCurve.gamutmunselmethod && p.labCurve.gamutmunselmethod == other.labCurve.gamutmunselmethod; labCurve.rstprotection = labCurve.rstprotection && p.labCurve.rstprotection == other.labCurve.rstprotection; labCurve.lcredsk = labCurve.lcredsk && p.labCurve.lcredsk == other.labCurve.lcredsk; @@ -908,7 +908,6 @@ void ParamsEdited::initFrom(const std::vector& vibrance.avoidcolorshift = vibrance.avoidcolorshift && p.vibrance.avoidcolorshift == other.vibrance.avoidcolorshift; vibrance.pastsattog = vibrance.pastsattog && p.vibrance.pastsattog == other.vibrance.pastsattog; vibrance.skintonescurve = vibrance.skintonescurve && p.vibrance.skintonescurve == other.vibrance.skintonescurve; - colorappearance.enabled = colorappearance.enabled && p.colorappearance.enabled == other.colorappearance.enabled; colorappearance.degree = colorappearance.degree && p.colorappearance.degree == other.colorappearance.degree; colorappearance.autodegree = colorappearance.autodegree && p.colorappearance.autodegree == other.colorappearance.autodegree; @@ -955,7 +954,6 @@ void ParamsEdited::initFrom(const std::vector& colorappearance.ybout = colorappearance.ybout && p.colorappearance.ybout == other.colorappearance.ybout; colorappearance.tempsc = colorappearance.tempsc && p.colorappearance.tempsc == other.colorappearance.tempsc; colorappearance.greensc = colorappearance.greensc && p.colorappearance.greensc == other.colorappearance.greensc; - colorappearance.presetcat02 = colorappearance.presetcat02 && p.colorappearance.presetcat02 == other.colorappearance.presetcat02; //colorBoost.amount = colorBoost.amount && p.colorBoost.amount == other.colorBoost.amount; //colorBoost.avoidclip = colorBoost.avoidclip && p.colorBoost.avoidclip == other.colorBoost.avoidclip; @@ -1091,6 +1089,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).structexclu = locallab.spots.at(j).structexclu && pSpot.structexclu == otherSpot.structexclu; locallab.spots.at(j).struc = locallab.spots.at(j).struc && pSpot.struc == otherSpot.struc; locallab.spots.at(j).shapeMethod = locallab.spots.at(j).shapeMethod && pSpot.shapeMethod == otherSpot.shapeMethod; + locallab.spots.at(j).avoidgamutMethod = locallab.spots.at(j).avoidgamutMethod && pSpot.avoidgamutMethod == otherSpot.avoidgamutMethod; locallab.spots.at(j).loc = locallab.spots.at(j).loc && pSpot.loc == otherSpot.loc; locallab.spots.at(j).centerX = locallab.spots.at(j).centerX && pSpot.centerX == otherSpot.centerX; locallab.spots.at(j).centerY = locallab.spots.at(j).centerY && pSpot.centerY == otherSpot.centerY; @@ -1110,8 +1109,6 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).transitgrad = locallab.spots.at(j).transitgrad && pSpot.transitgrad == otherSpot.transitgrad; locallab.spots.at(j).hishow = locallab.spots.at(j).hishow && pSpot.hishow == otherSpot.hishow; locallab.spots.at(j).activ = locallab.spots.at(j).activ && pSpot.activ == otherSpot.activ; - locallab.spots.at(j).avoid = locallab.spots.at(j).avoid && pSpot.avoid == otherSpot.avoid; - locallab.spots.at(j).avoidmun = locallab.spots.at(j).avoidmun && pSpot.avoidmun == otherSpot.avoidmun; locallab.spots.at(j).blwh = locallab.spots.at(j).blwh && pSpot.blwh == otherSpot.blwh; locallab.spots.at(j).recurs = locallab.spots.at(j).recurs && pSpot.recurs == otherSpot.recurs; locallab.spots.at(j).laplac = locallab.spots.at(j).laplac && pSpot.laplac == otherSpot.laplac; @@ -1873,6 +1870,7 @@ void ParamsEdited::initFrom(const std::vector& icm.labgridcieWy = icm.labgridcieWy && p.icm.labgridcieWy == other.icm.labgridcieWy; icm.preser = icm.preser && p.icm.preser == other.icm.preser; icm.fbw = icm.fbw && p.icm.fbw == other.icm.fbw; + icm.gamut = icm.gamut && p.icm.gamut == other.icm.gamut; icm.aRendIntent = icm.aRendIntent && p.icm.aRendIntent == other.icm.aRendIntent; icm.workingTRC = icm.workingTRC && p.icm.workingTRC == other.icm.workingTRC; icm.will = icm.will && p.icm.will == other.icm.will; @@ -2392,8 +2390,8 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.labCurve.chromaticity = dontforceSet && options.baBehav[ADDSET_LC_CHROMATICITY] ? toEdit.labCurve.chromaticity + mods.labCurve.chromaticity : mods.labCurve.chromaticity; } - if (labCurve.avoidcolorshift) { - toEdit.labCurve.avoidcolorshift = mods.labCurve.avoidcolorshift; + if (labCurve.gamutmunselmethod) { + toEdit.labCurve.gamutmunselmethod = mods.labCurve.gamutmunselmethod; } if (labCurve.rstprotection) { @@ -3034,9 +3032,6 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.colorappearance.tonecie = mods.colorappearance.tonecie; } - if (colorappearance.presetcat02) { - toEdit.colorappearance.presetcat02 = mods.colorappearance.presetcat02; - } // if (colorappearance.sharpcie) toEdit.colorappearance.sharpcie = mods.colorappearance.sharpcie; if (impulseDenoise.enabled) { @@ -3437,6 +3432,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).shapeMethod = mods.locallab.spots.at(i).shapeMethod; } + if (locallab.spots.at(i).avoidgamutMethod) { + toEdit.locallab.spots.at(i).avoidgamutMethod = mods.locallab.spots.at(i).avoidgamutMethod; + } + if (locallab.spots.at(i).loc) { toEdit.locallab.spots.at(i).loc = mods.locallab.spots.at(i).loc; } @@ -3513,14 +3512,6 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).activ = mods.locallab.spots.at(i).activ; } - if (locallab.spots.at(i).avoid) { - toEdit.locallab.spots.at(i).avoid = mods.locallab.spots.at(i).avoid; - } - - if (locallab.spots.at(i).avoidmun) { - toEdit.locallab.spots.at(i).avoidmun = mods.locallab.spots.at(i).avoidmun; - } - if (locallab.spots.at(i).blwh) { toEdit.locallab.spots.at(i).blwh = mods.locallab.spots.at(i).blwh; } @@ -6382,6 +6373,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.icm.fbw = mods.icm.fbw; } + if (icm.gamut) { + toEdit.icm.gamut = mods.icm.gamut; + } + if (icm.labgridcieALow) { toEdit.icm.labgridcieALow = mods.icm.labgridcieALow; } @@ -7411,6 +7406,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : structexclu(v), struc(v), shapeMethod(v), + avoidgamutMethod(v), loc(v), centerX(v), centerY(v), @@ -7430,8 +7426,6 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : transitgrad(v), hishow(v), activ(v), - avoid(v), - avoidmun(v), blwh(v), recurs(v), laplac(v), @@ -8103,6 +8097,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) structexclu = v; struc = v; shapeMethod = v; + avoidgamutMethod = v; loc = v; centerX = v; centerY = v; @@ -8122,8 +8117,6 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) transitgrad = v; hishow = v; activ = v; - avoid = v; - avoidmun = v; blwh = v; recurs = v; laplac = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 3c108f33d..616e6d261 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -109,7 +109,7 @@ struct LCurveParamsEdited { bool brightness; bool contrast; bool chromaticity; - bool avoidcolorshift; + bool gamutmunselmethod; bool rstprotection; bool lcurve; bool acurve; @@ -305,7 +305,6 @@ struct ColorAppearanceParamsEdited { bool ybout; bool tempsc; bool greensc; - bool presetcat02; }; struct DirPyrDenoiseParamsEdited { @@ -403,6 +402,7 @@ public: bool structexclu; bool struc; bool shapeMethod; + bool avoidgamutMethod; bool loc; bool centerX; bool centerY; @@ -422,8 +422,6 @@ public: bool transitgrad; bool hishow; bool activ; - bool avoid; - bool avoidmun; bool blwh; bool recurs; bool laplac; @@ -1231,6 +1229,7 @@ struct ColorManagementParamsEdited { bool bluy; bool preser; bool fbw; + bool gamut; bool labgridcieALow; bool labgridcieBLow; bool labgridcieAHigh; diff --git a/rtgui/popupcommon.cc b/rtgui/popupcommon.cc index 1dbde833e..a6d9b6046 100644 --- a/rtgui/popupcommon.cc +++ b/rtgui/popupcommon.cc @@ -73,44 +73,50 @@ PopUpCommon::~PopUpCommon () { } -bool PopUpCommon::addEntry (const Glib::ustring& fileName, const Glib::ustring& label) +bool PopUpCommon::addEntry (const Glib::ustring& fileName, const Glib::ustring& label, Gtk::RadioButtonGroup* radioGroup) { - return insertEntry(getEntryCount(), fileName, label); + return insertEntry(getEntryCount(), fileName, label, radioGroup); } -bool PopUpCommon::insertEntry(int position, const Glib::ustring& fileName, const Glib::ustring& label) +bool PopUpCommon::insertEntry(int position, const Glib::ustring& fileName, const Glib::ustring& label, Gtk::RadioButtonGroup *radioGroup) { RTImage* image = nullptr; if (!fileName.empty()) { image = Gtk::manage(new RTImage(fileName)); } - bool success = insertEntryImpl(position, fileName, Glib::RefPtr(), image, label); + bool success = insertEntryImpl(position, fileName, Glib::RefPtr(), image, label, radioGroup); if (!success && image) { delete image; } return success; } -bool PopUpCommon::insertEntry(int position, const Glib::RefPtr& gIcon, const Glib::ustring& label) +bool PopUpCommon::insertEntry(int position, const Glib::RefPtr& gIcon, const Glib::ustring& label, Gtk::RadioButtonGroup *radioGroup) { RTImage* image = Gtk::manage(new RTImage(gIcon, Gtk::ICON_SIZE_BUTTON)); - bool success = insertEntryImpl(position, "", gIcon, image, label); + bool success = insertEntryImpl(position, "", gIcon, image, label, radioGroup); if (!success) { delete image; } return success; } -bool PopUpCommon::insertEntryImpl(int position, const Glib::ustring& fileName, const Glib::RefPtr& gIcon, RTImage* image, const Glib::ustring& label) +bool PopUpCommon::insertEntryImpl(int position, const Glib::ustring& fileName, const Glib::RefPtr& gIcon, RTImage* image, const Glib::ustring& label, Gtk::RadioButtonGroup* radioGroup) { if (label.empty() || position < 0 || position > getEntryCount()) return false; // Create the menu item and image - MyImageMenuItem *newItem = Gtk::manage(new MyImageMenuItem(label, image)); + Gtk::MenuItem *newItem; + if (radioGroup) { + newItem = Gtk::manage(new MyRadioImageMenuItem(label, image, *radioGroup)); + } + else { + newItem = Gtk::manage(new MyImageMenuItem(label, image)); + } imageIcons.insert(imageIcons.begin() + position, gIcon); imageFilenames.insert(imageFilenames.begin() + position, fileName); - images.insert(images.begin() + position, newItem->getImage()); + images.insert(images.begin() + position, image); // When there is at least 1 choice, we add the arrow button if (images.size() == 1) { @@ -154,9 +160,8 @@ void PopUpCommon::removeEntry(int position) setButtonHint(); } - MyImageMenuItem *menuItem = dynamic_cast(menu->get_children()[position]); + std::unique_ptr menuItem(menu->get_children()[position]); menu->remove(*menuItem); - delete menuItem; imageIcons.erase(imageIcons.begin() + position); imageFilenames.erase(imageFilenames.begin() + position); images.erase(images.begin() + position); @@ -222,6 +227,12 @@ bool PopUpCommon::setSelected (int entryNum) changeImage(entryNum); selected = entryNum; setButtonHint(); + + auto radioMenuItem = dynamic_cast(menu->get_children()[entryNum]); + if (radioMenuItem && menu->get_active() != radioMenuItem) { + radioMenuItem->set_active(); + } + return true; } } @@ -248,7 +259,7 @@ void PopUpCommon::setButtonHint() if (selected > -1) { auto widget = menu->get_children ()[selected]; - auto item = dynamic_cast(widget); + auto item = dynamic_cast(widget); if (item) { hint += escapeHtmlChars(item->getLabel()->get_text()); diff --git a/rtgui/popupcommon.h b/rtgui/popupcommon.h index 59a5b8d0e..9ca6b2030 100644 --- a/rtgui/popupcommon.h +++ b/rtgui/popupcommon.h @@ -40,6 +40,7 @@ class Grid; class Menu; class Button; class ImageMenuItem; +class RadioButtonGroup; class Widget; } @@ -60,9 +61,9 @@ public: explicit PopUpCommon (Gtk::Button* button, const Glib::ustring& label = ""); virtual ~PopUpCommon (); - bool addEntry (const Glib::ustring& fileName, const Glib::ustring& label); - bool insertEntry(int position, const Glib::ustring& fileName, const Glib::ustring& label); - bool insertEntry(int position, const Glib::RefPtr& gIcon, const Glib::ustring& label); + bool addEntry (const Glib::ustring& fileName, const Glib::ustring& label, Gtk::RadioButtonGroup* radioGroup = nullptr); + bool insertEntry(int position, const Glib::ustring& fileName, const Glib::ustring& label, Gtk::RadioButtonGroup* radioGroup = nullptr); + bool insertEntry(int position, const Glib::RefPtr& gIcon, const Glib::ustring& label, Gtk::RadioButtonGroup* radioGroup = nullptr); int getEntryCount () const; bool setSelected (int entryNum); int getSelected () const; @@ -91,7 +92,7 @@ private: void changeImage(int position); void changeImage(const Glib::ustring& fileName, const Glib::RefPtr& gIcon); void entrySelected(Gtk::Widget* menuItem); - bool insertEntryImpl(int position, const Glib::ustring& fileName, const Glib::RefPtr& gIcon, RTImage* image, const Glib::ustring& label); + bool insertEntryImpl(int position, const Glib::ustring& fileName, const Glib::RefPtr& gIcon, RTImage* image, const Glib::ustring& label, Gtk::RadioButtonGroup* radioGroup); void showMenu(GdkEventButton* event); protected: diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index 672a450a5..922588a19 100755 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -33,7 +33,7 @@ class BatchQueueEntry; class BatchQueuePanel; class EditorPanel; -class ExternalEditor; +struct ExternalEditor; class FilePanel; class PLDBridge; class RTWindow final :