diff --git a/rtdata/languages/default b/rtdata/languages/default index 352c4f92e..91eb5e2bf 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1130,6 +1130,8 @@ PREFERENCES_TISTD;Standard PREFERENCES_TP_LABEL;Tool panel: PREFERENCES_TP_USEICONORTEXT;Use tab icons instead of text PREFERENCES_TP_VSCROLLBAR;Hide vertical scrollbar +PREFERENCES_AUTOSAVE_TP_OPEN;Automatically save tools collapsed/expanded\nstate before exiting +PREFERENCES_SAVE_TP_OPEN_NOW;Save tools collapsed/expanded state now PREFERENCES_TUNNELMETADATA;Copy Exif/IPTC/XMP unchanged to output file PREFERENCES_USEBUNDLEDPROFILES;Use bundled profiles PREFERENCES_VIEW;Output device's white balance (monitor, TV, projector, viewing, etc.) diff --git a/rtdata/themes/RawTherapee-GTK3-20_.css b/rtdata/themes/RawTherapee-GTK3-20_.css index ff780a4e3..398bb97d4 100644 --- a/rtdata/themes/RawTherapee-GTK3-20_.css +++ b/rtdata/themes/RawTherapee-GTK3-20_.css @@ -639,18 +639,11 @@ paned box, paned grid { } paned > separator { - border-width: 1px; - border-color: #484848; - margin: 0; - padding: 0; -} -paned.horizontal > separator { - min-width: 2px; - border-style: none solid; -} -paned.vertical > separator { - min-height: 2px; - border-style: solid none; + border-width: 1px 1px 0 0; + border-style: solid; + border-color: #404040; + padding: 0px; + margin: 4px; } #PlacesPaned { diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index aea20d8c9..1df27c5fb 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -113,7 +113,7 @@ using namespace rtengine; void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const double cablue, const double caautostrength, array2D &rawData) { -// multithreaded and partly vectorized by Ingo Weyrich +// multithreaded and vectorized by Ingo Weyrich constexpr int ts = 128; constexpr int tsh = ts / 2; //shifts to location of vertical and diagonal neighbors @@ -136,7 +136,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const // local variables const int width = W, height = H; //temporary array to store simple interpolation of G - float *Gtmp = (float (*)) calloc ((height) * (width), sizeof * Gtmp); + float *Gtmp = (float (*)) malloc ((height * width + ((height * width) & 1)) / 2 * sizeof * Gtmp); // temporary array to avoid race conflicts, only every second pixel needs to be saved here float *RawDataTmp = (float*) malloc( (height * width + ((height * width) & 1)) * sizeof(float) / 2); @@ -185,7 +185,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const float blockavethr[2][2] = {{0, 0}, {0, 0}}, blocksqavethr[2][2] = {{0, 0}, {0, 0}}, blockdenomthr[2][2] = {{0, 0}, {0, 0}}; // assign working space - constexpr int buffersize = 3 * sizeof(float) * ts * ts + 6 * sizeof(float) * ts * tsh + 8 * 64 + 63; + constexpr int buffersize = sizeof(float) * ts * ts + 8 * sizeof(float) * ts * tsh + 8 * 64 + 63; char *buffer = (char *) malloc(buffersize); char *data = (char*)( ( uintptr_t(buffer) + uintptr_t(63)) / 64 * 64); @@ -194,22 +194,21 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const //rgb data in a tile float* rgb[3]; rgb[0] = (float (*)) data; - rgb[1] = (float (*)) (data + 1 * sizeof(float) * ts * ts + 1 * 64); - rgb[2] = (float (*)) (data + 2 * sizeof(float) * ts * ts + 2 * 64); + rgb[1] = (float (*)) (data + sizeof(float) * ts * tsh + 1 * 64); + rgb[2] = (float (*)) (data + sizeof(float) * (ts * ts + ts * tsh) + 2 * 64); //high pass filter for R/B in vertical direction - float *rbhpfh = (float (*)) (data + 3 * sizeof(float) * ts * ts + 3 * 64); + float *rbhpfh = (float (*)) (data + 2 * sizeof(float) * ts * ts + 3 * 64); //high pass filter for R/B in horizontal direction - float *rbhpfv = (float (*)) (data + 3 * sizeof(float) * ts * ts + sizeof(float) * ts * tsh + 4 * 64); + float *rbhpfv = (float (*)) (data + 2 * sizeof(float) * ts * ts + sizeof(float) * ts * tsh + 4 * 64); //low pass filter for R/B in horizontal direction - float *rblpfh = (float (*)) (data + 4 * sizeof(float) * ts * ts + 5 * 64); + float *rblpfh = (float (*)) (data + 3 * sizeof(float) * ts * ts + 5 * 64); //low pass filter for R/B in vertical direction - float *rblpfv = (float (*)) (data + 4 * sizeof(float) * ts * ts + sizeof(float) * ts * tsh + 6 * 64); + float *rblpfv = (float (*)) (data + 3 * sizeof(float) * ts * ts + sizeof(float) * ts * tsh + 6 * 64); //low pass filter for colour differences in horizontal direction - float *grblpfh = (float (*)) (data + 5 * sizeof(float) * ts * ts + 7 * 64); + float *grblpfh = (float (*)) (data + 4 * sizeof(float) * ts * ts + 7 * 64); //low pass filter for colour differences in vertical direction - float *grblpfv = (float (*)) (data + 5 * sizeof(float) * ts * ts + sizeof(float) * ts * tsh + 8 * 64); - //colour differences + float *grblpfv = (float (*)) (data + 4 * sizeof(float) * ts * ts + sizeof(float) * ts * tsh + 8 * 64); float *grbdiff = rbhpfh; // there is no overlap in buffer usage => share //green interpolated to optical sample points for R/B float *gshift = rbhpfv; // there is no overlap in buffer usage => share @@ -236,13 +235,38 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const // rgb values should be floating point numbers between 0 and 1 // after white balance multipliers are applied - for (int rr = rrmin; rr < rrmax; rr++) - for (int row = rr + top, cc = ccmin; cc < ccmax; cc++) { - int col = cc + left; +#ifdef __SSE2__ + vfloat c65535v = F2V(65535.f); +#endif + + for (int rr = rrmin; rr < rrmax; rr++) { + int row = rr + top; + int cc = ccmin; + int col = cc + left; +#ifdef __SSE2__ + int c0 = FC(rr, cc); + if(c0 == 1) { + rgb[c0][rr * ts + cc] = rawData[row][col] / 65535.f; + cc++; + col++; + c0 = FC(rr, cc); + } + int indx1 = rr * ts + cc; + for (; cc < ccmax - 7; cc+=8, col+=8, indx1 += 8) { + vfloat val1 = LVFU(rawData[row][col]) / c65535v; + vfloat val2 = LVFU(rawData[row][col + 4]) / c65535v; + vfloat nonGreenv = _mm_shuffle_ps(val1,val2,_MM_SHUFFLE( 2,0,2,0 )); + STVFU(rgb[c0][indx1 >> 1], nonGreenv); + STVFU(rgb[1][indx1], val1); + STVFU(rgb[1][indx1 + 4], val2); + } +#endif + for (; cc < ccmax; cc++, col++) { int c = FC(rr, cc); int indx1 = rr * ts + cc; - rgb[c][indx1] = (rawData[row][col]) / 65535.0f; + rgb[c][indx1 >> ((c & 1) ^ 1)] = rawData[row][col] / 65535.f; } + } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //fill borders @@ -250,7 +274,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = ccmin; cc < ccmax; cc++) { int c = FC(rr, cc); - rgb[c][rr * ts + cc] = rgb[c][(border2 - rr) * ts + cc]; + rgb[c][(rr * ts + cc) >> ((c & 1) ^ 1)] = rgb[c][((border2 - rr) * ts + cc) >> ((c & 1) ^ 1)]; } } @@ -258,7 +282,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = ccmin; cc < ccmax; cc++) { int c = FC(rr, cc); - rgb[c][(rrmax + rr)*ts + cc] = (rawData[(height - rr - 2)][left + cc]) / 65535.0f; + rgb[c][((rrmax + rr)*ts + cc) >> ((c & 1) ^ 1)] = rawData[(height - rr - 2)][left + cc] / 65535.f; } } @@ -266,7 +290,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = rrmin; rr < rrmax; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][rr * ts + cc] = rgb[c][rr * ts + border2 - cc]; + rgb[c][(rr * ts + cc) >> ((c & 1) ^ 1)] = rgb[c][(rr * ts + border2 - cc) >> ((c & 1) ^ 1)]; } } @@ -274,7 +298,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = rrmin; rr < rrmax; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][rr * ts + ccmax + cc] = (rawData[(top + rr)][(width - cc - 2)]) / 65535.0f; + rgb[c][(rr * ts + ccmax + cc) >> ((c & 1) ^ 1)] = rawData[(top + rr)][(width - cc - 2)] / 65535.f; } } @@ -283,7 +307,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rr)*ts + cc] = (rawData[border2 - rr][border2 - cc]) / 65535.0f; + rgb[c][(rr * ts + cc) >> ((c & 1) ^ 1)] = rawData[border2 - rr][border2 - cc] / 65535.f; } } @@ -291,7 +315,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rrmax + rr)*ts + ccmax + cc] = (rawData[(height - rr - 2)][(width - cc - 2)]) / 65535.0f; + rgb[c][((rrmax + rr)*ts + ccmax + cc) >> ((c & 1) ^ 1)] = rawData[(height - rr - 2)][(width - cc - 2)] / 65535.f; } } @@ -299,7 +323,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rr)*ts + ccmax + cc] = (rawData[(border2 - rr)][(width - cc - 2)]) / 65535.0f; + rgb[c][(rr * ts + ccmax + cc) >> ((c & 1) ^ 1)] = rawData[(border2 - rr)][(width - cc - 2)] / 65535.f; } } @@ -307,7 +331,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rrmax + rr)*ts + cc] = (rawData[(height - rr - 2)][(border2 - cc)]) / 65535.0f; + rgb[c][((rrmax + rr)*ts + cc) >> ((c & 1) ^ 1)] = rawData[(height - rr - 2)][(border2 - cc)] / 65535.f; } } @@ -328,30 +352,45 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const #ifdef __SSE2__ for (; cc < cc1 - 9; cc+=8, indx+=8) { //compute directional weights using image gradients - vfloat wtuv = onev / SQRV(epsv + vabsf(LC2VFU(rgb[1][indx + v1]) - LC2VFU(rgb[1][indx - v1])) + vabsf(LC2VFU(rgb[c][indx]) - LC2VFU(rgb[c][indx - v2])) + vabsf(LC2VFU(rgb[1][indx - v1]) - LC2VFU(rgb[1][indx - v3]))); - vfloat wtdv = onev / SQRV(epsv + vabsf(LC2VFU(rgb[1][indx - v1]) - LC2VFU(rgb[1][indx + v1])) + vabsf(LC2VFU(rgb[c][indx]) - LC2VFU(rgb[c][indx + v2])) + vabsf(LC2VFU(rgb[1][indx + v1]) - LC2VFU(rgb[1][indx + v3]))); - vfloat wtlv = onev / SQRV(epsv + vabsf(LC2VFU(rgb[1][indx + 1]) - LC2VFU(rgb[1][indx - 1])) + vabsf(LC2VFU(rgb[c][indx]) - LC2VFU(rgb[c][indx - 2])) + vabsf(LC2VFU(rgb[1][indx - 1]) - LC2VFU(rgb[1][indx - 3]))); - vfloat wtrv = onev / SQRV(epsv + vabsf(LC2VFU(rgb[1][indx - 1]) - LC2VFU(rgb[1][indx + 1])) + vabsf(LC2VFU(rgb[c][indx]) - LC2VFU(rgb[c][indx + 2])) + vabsf(LC2VFU(rgb[1][indx + 1]) - LC2VFU(rgb[1][indx + 3]))); + vfloat rgb1mv1v = LC2VFU(rgb[1][indx - v1]); + vfloat rgb1pv1v = LC2VFU(rgb[1][indx + v1]); + vfloat rgbcv = LVFU(rgb[c][indx >> 1]); + vfloat temp1v = epsv + vabsf(rgb1mv1v - rgb1pv1v); + vfloat wtuv = onev / SQRV(temp1v + vabsf(rgbcv - LVFU(rgb[c][(indx - v2) >> 1])) + vabsf(rgb1mv1v - LC2VFU(rgb[1][indx - v3]))); + vfloat wtdv = onev / SQRV(temp1v + vabsf(rgbcv - LVFU(rgb[c][(indx + v2) >> 1])) + vabsf(rgb1pv1v - LC2VFU(rgb[1][indx + v3]))); + vfloat rgb1m1v = LC2VFU(rgb[1][indx - 1]); + vfloat rgb1p1v = LC2VFU(rgb[1][indx + 1]); + vfloat temp2v = epsv + vabsf(rgb1m1v - rgb1p1v); + vfloat wtlv = onev / SQRV(temp2v + vabsf(rgbcv - LVFU(rgb[c][(indx - 2) >> 1])) + vabsf(rgb1m1v - LC2VFU(rgb[1][indx - 3]))); + vfloat wtrv = onev / SQRV(temp2v + vabsf(rgbcv - LVFU(rgb[c][(indx + 2) >> 1])) + vabsf(rgb1p1v - LC2VFU(rgb[1][indx + 3]))); //store in rgb array the interpolated G value at R/B grid points using directional weighted average - STC2VFU(rgb[1][indx], (wtuv * LC2VFU(rgb[1][indx - v1]) + wtdv * LC2VFU(rgb[1][indx + v1]) + wtlv * LC2VFU(rgb[1][indx - 1]) + wtrv * LC2VFU(rgb[1][indx + 1])) / (wtuv + wtdv + wtlv + wtrv)); + STC2VFU(rgb[1][indx], (wtuv * rgb1mv1v + wtdv * rgb1pv1v + wtlv * rgb1m1v + wtrv * rgb1p1v) / (wtuv + wtdv + wtlv + wtrv)); } #endif for (; cc < cc1 - 3; cc+=2, indx+=2) { //compute directional weights using image gradients - float wtu = 1.f / SQR(eps + fabsf(rgb[1][indx + v1] - rgb[1][indx - v1]) + fabsf(rgb[c][indx] - rgb[c][indx - v2]) + fabsf(rgb[1][indx - v1] - rgb[1][indx - v3])); - float wtd = 1.f / SQR(eps + fabsf(rgb[1][indx - v1] - rgb[1][indx + v1]) + fabsf(rgb[c][indx] - rgb[c][indx + v2]) + fabsf(rgb[1][indx + v1] - rgb[1][indx + v3])); - float wtl = 1.f / SQR(eps + fabsf(rgb[1][indx + 1] - rgb[1][indx - 1]) + fabsf(rgb[c][indx] - rgb[c][indx - 2]) + fabsf(rgb[1][indx - 1] - rgb[1][indx - 3])); - float wtr = 1.f / SQR(eps + fabsf(rgb[1][indx - 1] - rgb[1][indx + 1]) + fabsf(rgb[c][indx] - rgb[c][indx + 2]) + fabsf(rgb[1][indx + 1] - rgb[1][indx + 3])); + float wtu = 1.f / SQR(eps + fabsf(rgb[1][indx + v1] - rgb[1][indx - v1]) + fabsf(rgb[c][indx >> 1] - rgb[c][(indx - v2) >> 1]) + fabsf(rgb[1][indx - v1] - rgb[1][indx - v3])); + float wtd = 1.f / SQR(eps + fabsf(rgb[1][indx - v1] - rgb[1][indx + v1]) + fabsf(rgb[c][indx >> 1] - rgb[c][(indx + v2) >> 1]) + fabsf(rgb[1][indx + v1] - rgb[1][indx + v3])); + float wtl = 1.f / SQR(eps + fabsf(rgb[1][indx + 1] - rgb[1][indx - 1]) + fabsf(rgb[c][indx >> 1] - rgb[c][(indx - 2) >> 1]) + fabsf(rgb[1][indx - 1] - rgb[1][indx - 3])); + float wtr = 1.f / SQR(eps + fabsf(rgb[1][indx - 1] - rgb[1][indx + 1]) + fabsf(rgb[c][indx >> 1] - rgb[c][(indx + 2) >> 1]) + fabsf(rgb[1][indx + 1] - rgb[1][indx + 3])); //store in rgb array the interpolated G value at R/B grid points using directional weighted average rgb[1][indx] = (wtu * rgb[1][indx - v1] + wtd * rgb[1][indx + v1] + wtl * rgb[1][indx - 1] + wtr * rgb[1][indx + 1]) / (wtu + wtd + wtl + wtr); } if (row > -1 && row < height) { - for(int col = max(left + 3, 0), indx = rr * ts + 3 - (left < 0 ? (left+3) : 0); col < min(cc1 + left - 3, width); col++, indx++) { - Gtmp[row * width + col] = rgb[1][indx]; + int offset = (FC(row,max(left + 3, 0)) & 1); + int col = max(left + 3, 0) + offset; + int indx = rr * ts + 3 - (left < 0 ? (left+3) : 0) + offset; +#ifdef __SSE2__ + for(; col < min(cc1 + left - 3, width) - 7; col+=8, indx+=8) { + STVFU(Gtmp[(row * width + col) >> 1], LC2VFU(rgb[1][indx])); + } +#endif + for(; col < min(cc1 + left - 3, width); col+=2, indx+=2) { + Gtmp[(row * width + col) >> 1] = rgb[1][indx]; } } @@ -361,47 +400,53 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const vfloat zd25v = F2V(0.25f); #endif for (int rr = 4; rr < rr1 - 4; rr++) { - int cc = 4 + (FC(rr, 2) & 1), indx = rr * ts + cc, c = FC(rr, cc); + int cc = 4 + (FC(rr, 2) & 1); + int indx = rr * ts + cc; + int c = FC(rr, cc); #ifdef __SSE2__ for (; cc < cc1 - 10; cc += 8, indx += 8) { vfloat rgb1v = LC2VFU(rgb[1][indx]); - vfloat rgbcv = LC2VFU(rgb[c][indx]); - vfloat temp1v = vabsf(vabsf((rgb1v - rgbcv) - (LC2VFU(rgb[1][indx + v4]) - LC2VFU(rgb[c][indx + v4]))) + - vabsf(LC2VFU(rgb[1][indx - v4]) - LC2VFU(rgb[c][indx - v4]) - rgb1v + rgbcv) - - vabsf(LC2VFU(rgb[1][indx - v4]) - LC2VFU(rgb[c][indx - v4]) - LC2VFU(rgb[1][indx + v4]) + LC2VFU(rgb[c][indx + v4]))); + vfloat rgbcv = LVFU(rgb[c][indx >> 1]); + vfloat rgb1mv4 = LC2VFU(rgb[1][indx - v4]); + vfloat rgb1pv4 = LC2VFU(rgb[1][indx + v4]); + vfloat temp1v = vabsf(vabsf((rgb1v - rgbcv) - (rgb1pv4 - LVFU(rgb[c][(indx + v4) >> 1]))) + + vabsf(rgb1mv4 - LVFU(rgb[c][(indx - v4) >> 1]) - rgb1v + rgbcv) - + vabsf(rgb1mv4 - LVFU(rgb[c][(indx - v4) >> 1]) - rgb1pv4 + LVFU(rgb[c][(indx + v4) >> 1]))); STVFU(rbhpfv[indx >> 1], temp1v); - vfloat temp2v = vabsf(vabsf((rgb1v - rgbcv) - (LC2VFU(rgb[1][indx + 4]) - LC2VFU(rgb[c][indx + 4]))) + - vabsf(LC2VFU(rgb[1][indx - 4]) - LC2VFU(rgb[c][indx - 4]) - rgb1v + rgbcv) - - vabsf(LC2VFU(rgb[1][indx - 4]) - LC2VFU(rgb[c][indx - 4]) - LC2VFU(rgb[1][indx + 4]) + LC2VFU(rgb[c][indx + 4]))); + vfloat rgb1m4 = LC2VFU(rgb[1][indx - 4]); + vfloat rgb1p4 = LC2VFU(rgb[1][indx + 4]); + vfloat temp2v = vabsf(vabsf((rgb1v - rgbcv) - (rgb1p4 - LVFU(rgb[c][(indx + 4) >> 1]))) + + vabsf(rgb1m4 - LVFU(rgb[c][(indx - 4) >> 1]) - rgb1v + rgbcv) - + vabsf(rgb1m4 - LVFU(rgb[c][(indx - 4) >> 1]) - rgb1p4 + LVFU(rgb[c][(indx + 4) >> 1]))); STVFU(rbhpfh[indx >> 1], temp2v); //low and high pass 1D filters of G in vertical/horizontal directions rgb1v = vmul2f(rgb1v); - vfloat glpfvv = zd25v * (rgb1v + LC2VFU(rgb[1][indx + v2]) + LC2VFU(rgb[1][indx - v2])); - vfloat glpfhv = zd25v * (rgb1v + LC2VFU(rgb[1][indx + 2]) + LC2VFU(rgb[1][indx - 2])); + vfloat glpfvv = (rgb1v + LC2VFU(rgb[1][indx + v2]) + LC2VFU(rgb[1][indx - v2])); + vfloat glpfhv = (rgb1v + LC2VFU(rgb[1][indx + 2]) + LC2VFU(rgb[1][indx - 2])); rgbcv = vmul2f(rgbcv); - STVFU(rblpfv[indx >> 1], epsv + vabsf(glpfvv - zd25v * (rgbcv + LC2VFU(rgb[c][indx + v2]) + LC2VFU(rgb[c][indx - v2])))); - STVFU(rblpfh[indx >> 1], epsv + vabsf(glpfhv - zd25v * (rgbcv + LC2VFU(rgb[c][indx + 2]) + LC2VFU(rgb[c][indx - 2])))); - STVFU(grblpfv[indx >> 1], glpfvv + zd25v * (rgbcv + LC2VFU(rgb[c][indx + v2]) + LC2VFU(rgb[c][indx - v2]))); - STVFU(grblpfh[indx >> 1], glpfhv + zd25v * (rgbcv + LC2VFU(rgb[c][indx + 2]) + LC2VFU(rgb[c][indx - 2]))); + STVFU(rblpfv[indx >> 1], zd25v * vabsf(glpfvv - (rgbcv + LVFU(rgb[c][(indx + v2) >> 1]) + LVFU(rgb[c][(indx - v2) >> 1])))); + STVFU(rblpfh[indx >> 1], zd25v * vabsf(glpfhv - (rgbcv + LVFU(rgb[c][(indx + 2) >> 1]) + LVFU(rgb[c][(indx - 2) >> 1])))); + STVFU(grblpfv[indx >> 1], zd25v * (glpfvv + (rgbcv + LVFU(rgb[c][(indx + v2) >> 1]) + LVFU(rgb[c][(indx - v2) >> 1])))); + STVFU(grblpfh[indx >> 1], zd25v * (glpfhv + (rgbcv + LVFU(rgb[c][(indx + 2) >> 1]) + LVFU(rgb[c][(indx - 2) >> 1])))); } #endif for (; cc < cc1 - 4; cc += 2, indx += 2) { - rbhpfv[indx >> 1] = fabsf(fabsf((rgb[1][indx] - rgb[c][indx]) - (rgb[1][indx + v4] - rgb[c][indx + v4])) + - fabsf((rgb[1][indx - v4] - rgb[c][indx - v4]) - (rgb[1][indx] - rgb[c][indx])) - - fabsf((rgb[1][indx - v4] - rgb[c][indx - v4]) - (rgb[1][indx + v4] - rgb[c][indx + v4]))); - rbhpfh[indx >> 1] = fabsf(fabsf((rgb[1][indx] - rgb[c][indx]) - (rgb[1][indx + 4] - rgb[c][indx + 4])) + - fabsf((rgb[1][indx - 4] - rgb[c][indx - 4]) - (rgb[1][indx] - rgb[c][indx])) - - fabsf((rgb[1][indx - 4] - rgb[c][indx - 4]) - (rgb[1][indx + 4] - rgb[c][indx + 4]))); + rbhpfv[indx >> 1] = fabsf(fabsf((rgb[1][indx] - rgb[c][indx >> 1]) - (rgb[1][indx + v4] - rgb[c][(indx + v4) >> 1])) + + fabsf((rgb[1][indx - v4] - rgb[c][(indx - v4) >> 1]) - (rgb[1][indx] - rgb[c][indx >> 1])) - + fabsf((rgb[1][indx - v4] - rgb[c][(indx - v4) >> 1]) - (rgb[1][indx + v4] - rgb[c][(indx + v4) >> 1]))); + rbhpfh[indx >> 1] = fabsf(fabsf((rgb[1][indx] - rgb[c][indx >> 1]) - (rgb[1][indx + 4] - rgb[c][(indx + 4) >> 1])) + + fabsf((rgb[1][indx - 4] - rgb[c][(indx - 4) >> 1]) - (rgb[1][indx] - rgb[c][indx >> 1])) - + fabsf((rgb[1][indx - 4] - rgb[c][(indx - 4) >> 1]) - (rgb[1][indx + 4] - rgb[c][(indx + 4) >> 1]))); //low and high pass 1D filters of G in vertical/horizontal directions - float glpfv = 0.25f * (2.f * rgb[1][indx] + rgb[1][indx + v2] + rgb[1][indx - v2]); - float glpfh = 0.25f * (2.f * rgb[1][indx] + rgb[1][indx + 2] + rgb[1][indx - 2]); - rblpfv[indx >> 1] = eps + fabsf(glpfv - 0.25f * (2.f * rgb[c][indx] + rgb[c][indx + v2] + rgb[c][indx - v2])); - rblpfh[indx >> 1] = eps + fabsf(glpfh - 0.25f * (2.f * rgb[c][indx] + rgb[c][indx + 2] + rgb[c][indx - 2])); - grblpfv[indx >> 1] = glpfv + 0.25f * (2.f * rgb[c][indx] + rgb[c][indx + v2] + rgb[c][indx - v2]); - grblpfh[indx >> 1] = glpfh + 0.25f * (2.f * rgb[c][indx] + rgb[c][indx + 2] + rgb[c][indx - 2]); + float glpfv = (2.f * rgb[1][indx] + rgb[1][indx + v2] + rgb[1][indx - v2]); + float glpfh = (2.f * rgb[1][indx] + rgb[1][indx + 2] + rgb[1][indx - 2]); + rblpfv[indx >> 1] = 0.25f * fabsf(glpfv - (2.f * rgb[c][indx >> 1] + rgb[c][(indx + v2) >> 1] + rgb[c][(indx - v2) >> 1])); + rblpfh[indx >> 1] = 0.25f * fabsf(glpfh - (2.f * rgb[c][indx >> 1] + rgb[c][(indx + 2) >> 1] + rgb[c][(indx - 2) >> 1])); + grblpfv[indx >> 1] = 0.25f * (glpfv + (2.f * rgb[c][indx >> 1] + rgb[c][(indx + v2) >> 1] + rgb[c][(indx - v2) >> 1])); + grblpfh[indx >> 1] = 0.25f * (glpfh + (2.f * rgb[c][indx >> 1] + rgb[c][(indx + 2) >> 1] + rgb[c][(indx - 2) >> 1])); } } @@ -414,10 +459,9 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const } #ifdef __SSE2__ - vfloat zd3125v = F2V(0.3125f); - vfloat zd09375v = F2V(0.09375f); + vfloat zd3v = F2V(0.3f); vfloat zd1v = F2V(0.1f); - vfloat zd125v = F2V(0.125f); + vfloat zd5v = F2V(0.5f); #endif // along line segments, find the point along each segment that minimizes the colour variance @@ -439,29 +483,27 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const //solve for the interpolation position that minimizes colour difference variance over the tile //vertical - vfloat gdiffv = zd3125v * (LC2VFU(rgb[1][indx + ts]) - LC2VFU(rgb[1][indx - ts])) + zd09375v * (LC2VFU(rgb[1][indx + ts + 1]) - LC2VFU(rgb[1][indx - ts + 1]) + LC2VFU(rgb[1][indx + ts - 1]) - LC2VFU(rgb[1][indx - ts - 1])); - vfloat deltgrbv = LC2VFU(rgb[c][indx]) - LC2VFU(rgb[1][indx]); + vfloat temp1 = zd3v * (LC2VFU(rgb[1][indx + ts + 1]) - LC2VFU(rgb[1][indx - ts - 1])); + vfloat temp2 = zd3v * (LC2VFU(rgb[1][indx - ts + 1]) - LC2VFU(rgb[1][indx + ts - 1])); + vfloat gdiffvv = (LC2VFU(rgb[1][indx + ts]) - LC2VFU(rgb[1][indx - ts])) + (temp1 - temp2); + vfloat deltgrbv = LVFU(rgb[c][indx >> 1]) - LC2VFU(rgb[1][indx]); - vfloat gradwtv = vabsf(zd25v * LVFU(rbhpfv[indx >> 1]) + zd125v * (LVFU(rbhpfv[(indx >> 1) + 1]) + LVFU(rbhpfv[(indx >> 1) - 1])) ) * (LVFU(grblpfv[(indx >> 1) - v1]) + LVFU(grblpfv[(indx >> 1) + v1])) / (epsv + zd1v * (LVFU(grblpfv[(indx >> 1) - v1]) + LVFU(grblpfv[(indx >> 1) + v1])) + LVFU(rblpfv[(indx >> 1) - v1]) + LVFU(rblpfv[(indx >> 1) + v1])); + vfloat gradwtvv = (LVFU(rbhpfv[indx >> 1]) + zd5v * (LVFU(rbhpfv[(indx >> 1) + 1]) + LVFU(rbhpfv[(indx >> 1) - 1]))) * (LVFU(grblpfv[(indx >> 1) - v1]) + LVFU(grblpfv[(indx >> 1) + v1])) / (epsv + zd1v * (LVFU(grblpfv[(indx >> 1) - v1]) + LVFU(grblpfv[(indx >> 1) + v1])) + LVFU(rblpfv[(indx >> 1) - v1]) + LVFU(rblpfv[(indx >> 1) + v1])); - coeff00v += gradwtv * deltgrbv * deltgrbv; - coeff01v += gradwtv * gdiffv * deltgrbv; - coeff02v += gradwtv * gdiffv * gdiffv; + coeff00v += gradwtvv * deltgrbv * deltgrbv; + coeff01v += gradwtvv * gdiffvv * deltgrbv; + coeff02v += gradwtvv * gdiffvv * gdiffvv; //horizontal - gdiffv = zd3125v * (LC2VFU(rgb[1][indx + 1]) - LC2VFU(rgb[1][indx - 1])) + zd09375v * (LC2VFU(rgb[1][indx + 1 + ts]) - LC2VFU(rgb[1][indx - 1 + ts]) + LC2VFU(rgb[1][indx + 1 - ts]) - LC2VFU(rgb[1][indx - 1 - ts])); + vfloat gdiffhv = (LC2VFU(rgb[1][indx + 1]) - LC2VFU(rgb[1][indx - 1])) + (temp1 + temp2); - gradwtv = vabsf(zd25v * LVFU(rbhpfh[indx >> 1]) + zd125v * (LVFU(rbhpfh[(indx >> 1) + v1]) + LVFU(rbhpfh[(indx >> 1) - v1])) ) * (LVFU(grblpfh[(indx >> 1) - 1]) + LVFU(grblpfh[(indx >> 1) + 1])) / (epsv + zd1v * (LVFU(grblpfh[(indx >> 1) - 1]) + LVFU(grblpfh[(indx >> 1) + 1])) + LVFU(rblpfh[(indx >> 1) - 1]) + LVFU(rblpfh[(indx >> 1) + 1])); + vfloat gradwthv = (LVFU(rbhpfh[indx >> 1]) + zd5v * (LVFU(rbhpfh[(indx >> 1) + v1]) + LVFU(rbhpfh[(indx >> 1) - v1]))) * (LVFU(grblpfh[(indx >> 1) - 1]) + LVFU(grblpfh[(indx >> 1) + 1])) / (epsv + zd1v * (LVFU(grblpfh[(indx >> 1) - 1]) + LVFU(grblpfh[(indx >> 1) + 1])) + LVFU(rblpfh[(indx >> 1) - 1]) + LVFU(rblpfh[(indx >> 1) + 1])); - coeff10v += gradwtv * deltgrbv * deltgrbv; - coeff11v += gradwtv * gdiffv * deltgrbv; - coeff12v += gradwtv * gdiffv * gdiffv; - - // In Mathematica, - // f[x_]=Expand[Total[Flatten[ - // ((1-x) RotateLeft[Gint,shift1]+x RotateLeft[Gint,shift2]-cfapad)^2[[dv;;-1;;2,dh;;-1;;2]]]]]; - // extremum = -.5Coefficient[f[x],x]/Coefficient[f[x],x^2] + coeff10v += gradwthv * deltgrbv * deltgrbv; + coeff11v += gradwthv * gdiffhv * deltgrbv; + coeff12v += gradwthv * gdiffhv * gdiffhv; } + coeff[0][0][c>>1] += vhadd(coeff00v); coeff[0][1][c>>1] += vhadd(coeff01v); coeff[0][2][c>>1] += vhadd(coeff02v); @@ -476,19 +518,19 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const //solve for the interpolation position that minimizes colour difference variance over the tile //vertical - float gdiff = 0.3125f * (rgb[1][indx + ts] - rgb[1][indx - ts]) + 0.09375f * (rgb[1][indx + ts + 1] - rgb[1][indx - ts + 1] + rgb[1][indx + ts - 1] - rgb[1][indx - ts - 1]); - float deltgrb = (rgb[c][indx] - rgb[1][indx]); + float gdiff = (rgb[1][indx + ts] - rgb[1][indx - ts]) + 0.3f * (rgb[1][indx + ts + 1] - rgb[1][indx - ts + 1] + rgb[1][indx + ts - 1] - rgb[1][indx - ts - 1]); + float deltgrb = (rgb[c][indx >> 1] - rgb[1][indx]); - float gradwt = fabsf(0.25f * rbhpfv[indx >> 1] + 0.125f * (rbhpfv[(indx >> 1) + 1] + rbhpfv[(indx >> 1) - 1]) ) * (grblpfv[(indx >> 1) - v1] + grblpfv[(indx >> 1) + v1]) / (eps + 0.1f * (grblpfv[(indx >> 1) - v1] + grblpfv[(indx >> 1) + v1]) + rblpfv[(indx >> 1) - v1] + rblpfv[(indx >> 1) + v1]); + float gradwt = (rbhpfv[indx >> 1] + 0.5f * (rbhpfv[(indx >> 1) + 1] + rbhpfv[(indx >> 1) - 1]) ) * (grblpfv[(indx >> 1) - v1] + grblpfv[(indx >> 1) + v1]) / (eps + 0.1f * (grblpfv[(indx >> 1) - v1] + grblpfv[(indx >> 1) + v1]) + rblpfv[(indx >> 1) - v1] + rblpfv[(indx >> 1) + v1]); coeff[0][0][c>>1] += gradwt * deltgrb * deltgrb; coeff[0][1][c>>1] += gradwt * gdiff * deltgrb; coeff[0][2][c>>1] += gradwt * gdiff * gdiff; //horizontal - gdiff = 0.3125f * (rgb[1][indx + 1] - rgb[1][indx - 1]) + 0.09375f * (rgb[1][indx + 1 + ts] - rgb[1][indx - 1 + ts] + rgb[1][indx + 1 - ts] - rgb[1][indx - 1 - ts]); + gdiff = (rgb[1][indx + 1] - rgb[1][indx - 1]) + 0.3f * (rgb[1][indx + 1 + ts] - rgb[1][indx - 1 + ts] + rgb[1][indx + 1 - ts] - rgb[1][indx - 1 - ts]); - gradwt = fabsf(0.25f * rbhpfh[indx >> 1] + 0.125f * (rbhpfh[(indx >> 1) + v1] + rbhpfh[(indx >> 1) - v1]) ) * (grblpfh[(indx >> 1) - 1] + grblpfh[(indx >> 1) + 1]) / (eps + 0.1f * (grblpfh[(indx >> 1) - 1] + grblpfh[(indx >> 1) + 1]) + rblpfh[(indx >> 1) - 1] + rblpfh[(indx >> 1) + 1]); + gradwt = (rbhpfh[indx >> 1] + 0.5f * (rbhpfh[(indx >> 1) + v1] + rbhpfh[(indx >> 1) - v1]) ) * (grblpfh[(indx >> 1) - 1] + grblpfh[(indx >> 1) + 1]) / (eps + 0.1f * (grblpfh[(indx >> 1) - 1] + grblpfh[(indx >> 1) + 1]) + rblpfh[(indx >> 1) - 1] + rblpfh[(indx >> 1) + 1]); coeff[1][0][c>>1] += gradwt * deltgrb * deltgrb; coeff[1][1][c>>1] += gradwt * gdiff * deltgrb; @@ -501,6 +543,19 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const } } + for (int dir = 0; dir < 2; dir++) { + for (int k = 0; k < 3; k++) { + for (int c = 0; c < 2; c++) { + coeff[dir][k][c] *= 0.25f; + if(k == 1) { + coeff[dir][k][c] *= 0.3125f; + } else if(k == 2) { + coeff[dir][k][c] *= SQR(0.3125f); + } + } + } + } + for (int c = 0; c < 2; c++) { for (int dir = 0; dir < 2; dir++) { // vert/hor @@ -719,26 +774,51 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const // rgb values should be floating point number between 0 and 1 // after white balance multipliers are applied - for (int rr = rrmin; rr < rrmax; rr++) - for (int row = rr + top, cc = ccmin; cc < ccmax; cc++) { - int col = cc + left; +#ifdef __SSE2__ + vfloat c65535v = F2V(65535.f); + vmask gmask = _mm_set_epi32(0, 0xffffffff, 0, 0xffffffff); +#endif + for (int rr = rrmin; rr < rrmax; rr++) { + int row = rr + top; + int cc = ccmin; + int col = cc + left; + int indx = row * width + col; + int indx1 = rr * ts + cc; +#ifdef __SSE2__ + int c = FC(rr, cc); + if(c & 1) { + rgb[1][indx1] = rawData[row][col] / 65535.f; + indx++; + indx1++; + cc++; + col++; + c = FC(rr, cc); + } + for (; cc < ccmax - 7; cc += 8, col += 8, indx += 8, indx1 += 8) { + vfloat val1v = LVFU(rawData[row][col]) / c65535v; + vfloat val2v = LVFU(rawData[row][col + 4]) / c65535v; + STVFU(rgb[c][indx1 >> 1], _mm_shuffle_ps(val1v, val2v, _MM_SHUFFLE(2, 0, 2, 0))); + vfloat gtmpv = LVFU(Gtmp[indx >> 1]); + STVFU(rgb[1][indx1], vself(gmask, PERMUTEPS(gtmpv, _MM_SHUFFLE(1, 1, 0, 0)), val1v)); + STVFU(rgb[1][indx1 + 4], vself(gmask, PERMUTEPS(gtmpv, _MM_SHUFFLE(3, 3, 2, 2)), val2v)); + } +#endif + for (; cc < ccmax; cc++, col++, indx++, indx1++) { int c = FC(rr, cc); - int indx = row * width + col; - int indx1 = rr * ts + cc; - rgb[c][indx1] = (rawData[row][col]) / 65535.0f; + rgb[c][indx1 >> ((c & 1) ^ 1)] = rawData[row][col] / 65535.f; if ((c & 1) == 0) { - rgb[1][indx1] = Gtmp[indx]; + rgb[1][indx1] = Gtmp[indx >> 1]; } } - + } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //fill borders if (rrmin > 0) { for (int rr = 0; rr < border; rr++) for (int cc = ccmin; cc < ccmax; cc++) { int c = FC(rr, cc); - rgb[c][rr * ts + cc] = rgb[c][(border2 - rr) * ts + cc]; + rgb[c][(rr * ts + cc) >> ((c & 1) ^ 1)] = rgb[c][((border2 - rr) * ts + cc) >> ((c & 1) ^ 1)]; rgb[1][rr * ts + cc] = rgb[1][(border2 - rr) * ts + cc]; } } @@ -747,8 +827,10 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = ccmin; cc < ccmax; cc++) { int c = FC(rr, cc); - rgb[c][(rrmax + rr)*ts + cc] = (rawData[(height - rr - 2)][left + cc]) / 65535.0f; - rgb[1][(rrmax + rr)*ts + cc] = Gtmp[(height - rr - 2) * width + left + cc]; + rgb[c][((rrmax + rr)*ts + cc) >> ((c & 1) ^ 1)] = (rawData[(height - rr - 2)][left + cc]) / 65535.f; + if ((c & 1) == 0) { + rgb[1][(rrmax + rr)*ts + cc] = Gtmp[((height - rr - 2) * width + left + cc) >> 1]; + } } } @@ -756,7 +838,7 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = rrmin; rr < rrmax; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][rr * ts + cc] = rgb[c][rr * ts + border2 - cc]; + rgb[c][(rr * ts + cc) >> ((c & 1) ^ 1)] = rgb[c][(rr * ts + border2 - cc) >> ((c & 1) ^ 1)]; rgb[1][rr * ts + cc] = rgb[1][rr * ts + border2 - cc]; } } @@ -765,8 +847,10 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = rrmin; rr < rrmax; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][rr * ts + ccmax + cc] = (rawData[(top + rr)][(width - cc - 2)]) / 65535.0f; - rgb[1][rr * ts + ccmax + cc] = Gtmp[(top + rr) * width + (width - cc - 2)]; + rgb[c][(rr * ts + ccmax + cc) >> ((c & 1) ^ 1)] = (rawData[(top + rr)][(width - cc - 2)]) / 65535.f; + if ((c & 1) == 0) { + rgb[1][rr * ts + ccmax + cc] = Gtmp[((top + rr) * width + (width - cc - 2)) >> 1]; + } } } @@ -775,8 +859,10 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rr)*ts + cc] = (rawData[border2 - rr][border2 - cc]) / 65535.0f; - rgb[1][(rr)*ts + cc] = Gtmp[(border2 - rr) * width + border2 - cc]; + rgb[c][(rr * ts + cc) >> ((c & 1) ^ 1)] = (rawData[border2 - rr][border2 - cc]) / 65535.f; + if ((c & 1) == 0) { + rgb[1][rr * ts + cc] = Gtmp[((border2 - rr) * width + border2 - cc) >> 1]; + } } } @@ -784,8 +870,10 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rrmax + rr)*ts + ccmax + cc] = (rawData[(height - rr - 2)][(width - cc - 2)]) / 65535.0f; - rgb[1][(rrmax + rr)*ts + ccmax + cc] = Gtmp[(height - rr - 2) * width + (width - cc - 2)]; + rgb[c][((rrmax + rr)*ts + ccmax + cc) >> ((c & 1) ^ 1)] = (rawData[(height - rr - 2)][(width - cc - 2)]) / 65535.f; + if ((c & 1) == 0) { + rgb[1][(rrmax + rr)*ts + ccmax + cc] = Gtmp[((height - rr - 2) * width + (width - cc - 2)) >> 1]; + } } } @@ -793,8 +881,10 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rr)*ts + ccmax + cc] = (rawData[(border2 - rr)][(width - cc - 2)]) / 65535.0f; - rgb[1][(rr)*ts + ccmax + cc] = Gtmp[(border2 - rr) * width + (width - cc - 2)]; + rgb[c][(rr * ts + ccmax + cc) >> ((c & 1) ^ 1)] = (rawData[(border2 - rr)][(width - cc - 2)]) / 65535.f; + if ((c & 1) == 0) { + rgb[1][rr * ts + ccmax + cc] = Gtmp[((border2 - rr) * width + (width - cc - 2)) >> 1]; + } } } @@ -802,8 +892,10 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 0; rr < border; rr++) for (int cc = 0; cc < border; cc++) { int c = FC(rr, cc); - rgb[c][(rrmax + rr)*ts + cc] = (rawData[(height - rr - 2)][(border2 - cc)]) / 65535.0f; - rgb[1][(rrmax + rr)*ts + cc] = Gtmp[(height - rr - 2) * width + (border2 - cc)]; + rgb[c][((rrmax + rr)*ts + cc) >> ((c & 1) ^ 1)] = (rawData[(height - rr - 2)][(border2 - cc)]) / 65535.f; + if ((c & 1) == 0) { + rgb[1][(rrmax + rr)*ts + cc] = Gtmp[((height - rr - 2) * width + (border2 - cc)) >> 1]; + } } } @@ -813,24 +905,20 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const if (!autoCA) { //manual CA correction; use red/blue slider values to set CA shift parameters for (int rr = 3; rr < rr1 - 3; rr++) - for (int row = rr + top, cc = 3, indx = rr * ts + cc; cc < cc1 - 3; cc++, indx++) { - int col = cc + left; + for (int cc = 3, indx = rr * ts + cc; cc < cc1 - 3; cc++, indx++) { int c = FC(rr, cc); if (c != 1) { //compute directional weights using image gradients - float wtu = 1.0 / SQR(eps + fabsf(rgb[1][(rr + 1) * ts + cc] - rgb[1][(rr - 1) * ts + cc]) + fabsf(rgb[c][(rr) * ts + cc] - rgb[c][(rr - 2) * ts + cc]) + fabsf(rgb[1][(rr - 1) * ts + cc] - rgb[1][(rr - 3) * ts + cc])); - float wtd = 1.0 / SQR(eps + fabsf(rgb[1][(rr - 1) * ts + cc] - rgb[1][(rr + 1) * ts + cc]) + fabsf(rgb[c][(rr) * ts + cc] - rgb[c][(rr + 2) * ts + cc]) + fabsf(rgb[1][(rr + 1) * ts + cc] - rgb[1][(rr + 3) * ts + cc])); - float wtl = 1.0 / SQR(eps + fabsf(rgb[1][(rr) * ts + cc + 1] - rgb[1][(rr) * ts + cc - 1]) + fabsf(rgb[c][(rr) * ts + cc] - rgb[c][(rr) * ts + cc - 2]) + fabsf(rgb[1][(rr) * ts + cc - 1] - rgb[1][(rr) * ts + cc - 3])); - float wtr = 1.0 / SQR(eps + fabsf(rgb[1][(rr) * ts + cc - 1] - rgb[1][(rr) * ts + cc + 1]) + fabsf(rgb[c][(rr) * ts + cc] - rgb[c][(rr) * ts + cc + 2]) + fabsf(rgb[1][(rr) * ts + cc + 1] - rgb[1][(rr) * ts + cc + 3])); + float wtu = 1.f / SQR(eps + fabsf(rgb[1][(rr + 1) * ts + cc] - rgb[1][(rr - 1) * ts + cc]) + fabsf(rgb[c][(rr * ts + cc) >> 1] - rgb[c][((rr - 2) * ts + cc) >> 1]) + fabsf(rgb[1][(rr - 1) * ts + cc] - rgb[1][(rr - 3) * ts + cc])); + float wtd = 1.f / SQR(eps + fabsf(rgb[1][(rr - 1) * ts + cc] - rgb[1][(rr + 1) * ts + cc]) + fabsf(rgb[c][(rr * ts + cc) >> 1] - rgb[c][((rr + 2) * ts + cc) >> 1]) + fabsf(rgb[1][(rr + 1) * ts + cc] - rgb[1][(rr + 3) * ts + cc])); + float wtl = 1.f / SQR(eps + fabsf(rgb[1][rr * ts + cc + 1] - rgb[1][rr * ts + cc - 1]) + fabsf(rgb[c][(rr * ts + cc) >> 1] - rgb[c][(rr * ts + cc - 2) >> 1]) + fabsf(rgb[1][rr * ts + cc - 1] - rgb[1][rr * ts + cc - 3])); + float wtr = 1.f / SQR(eps + fabsf(rgb[1][rr * ts + cc - 1] - rgb[1][rr * ts + cc + 1]) + fabsf(rgb[c][(rr * ts + cc) >> 1] - rgb[c][(rr * ts + cc + 2) >> 1]) + fabsf(rgb[1][rr * ts + cc + 1] - rgb[1][rr * ts + cc + 3])); //store in rgb array the interpolated G value at R/B grid points using directional weighted average rgb[1][indx] = (wtu * rgb[1][indx - v1] + wtd * rgb[1][indx + v1] + wtl * rgb[1][indx - 1] + wtr * rgb[1][indx + 1]) / (wtu + wtd + wtl + wtr); } - if (row > -1 && row < height && col > -1 && col < width) { - Gtmp[row * width + col] = rgb[1][indx]; - } } float hfrac = -((float)(hblock - 0.5) / (hblsz - 2) - 0.5); @@ -884,34 +972,39 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const for (int rr = 4; rr < rr1 - 4; rr++) { int cc = 4 + (FC(rr, 2) & 1); int c = FC(rr, cc); + int indx = (rr * ts + cc) >> 1; + int indxfc = (rr + shiftvfloor[c]) * ts + cc + shifthceil[c]; + int indxff = (rr + shiftvfloor[c]) * ts + cc + shifthfloor[c]; + int indxcc = (rr + shiftvceil[c]) * ts + cc + shifthceil[c]; + int indxcf = (rr + shiftvceil[c]) * ts + cc + shifthfloor[c]; #ifdef __SSE2__ vfloat shifthfracv = F2V(shifthfrac[c]); vfloat shiftvfracv = F2V(shiftvfrac[c]); - for (; cc < cc1 - 10; cc += 8) { + for (; cc < cc1 - 10; cc += 8, indxfc += 8, indxff += 8, indxcc += 8, indxcf += 8, indx += 4) { //perform CA correction using colour ratios or colour differences - vfloat Ginthfloorv = vintpf(shifthfracv, LC2VFU(rgb[1][(rr + shiftvfloor[c]) * ts + cc + shifthceil[c]]), LC2VFU(rgb[1][(rr + shiftvfloor[c]) * ts + cc + shifthfloor[c]])); - vfloat Ginthceilv = vintpf(shifthfracv, LC2VFU(rgb[1][(rr + shiftvceil[c]) * ts + cc + shifthceil[c]]), LC2VFU(rgb[1][(rr + shiftvceil[c]) * ts + cc + shifthfloor[c]])); + vfloat Ginthfloorv = vintpf(shifthfracv, LC2VFU(rgb[1][indxfc]), LC2VFU(rgb[1][indxff])); + vfloat Ginthceilv = vintpf(shifthfracv, LC2VFU(rgb[1][indxcc]), LC2VFU(rgb[1][indxcf])); //Gint is bilinear interpolation of G at CA shift point vfloat Gintv = vintpf(shiftvfracv, Ginthceilv, Ginthfloorv); //determine R/B at grid points using colour differences at shift point plus interpolated G value at grid point //but first we need to interpolate G-R/G-B to grid points... - STVFU(grbdiff[((rr)*ts + cc) >> 1], Gintv - LC2VFU(rgb[c][(rr) * ts + cc])); - STVFU(gshift[((rr)*ts + cc) >> 1], Gintv); + STVFU(grbdiff[indx], Gintv - LVFU(rgb[c][indx])); + STVFU(gshift[indx], Gintv); } #endif - for (; cc < cc1 - 4; cc += 2) { + for (; cc < cc1 - 4; cc += 2, indxfc += 2, indxff += 2, indxcc += 2, indxcf += 2, ++indx) { //perform CA correction using colour ratios or colour differences - float Ginthfloor = intp(shifthfrac[c], rgb[1][(rr + shiftvfloor[c]) * ts + cc + shifthceil[c]], rgb[1][(rr + shiftvfloor[c]) * ts + cc + shifthfloor[c]]); - float Ginthceil = intp(shifthfrac[c], rgb[1][(rr + shiftvceil[c]) * ts + cc + shifthceil[c]], rgb[1][(rr + shiftvceil[c]) * ts + cc + shifthfloor[c]]); + float Ginthfloor = intp(shifthfrac[c], rgb[1][indxfc], rgb[1][indxff]); + float Ginthceil = intp(shifthfrac[c], rgb[1][indxcc], rgb[1][indxcf]); //Gint is bilinear interpolation of G at CA shift point float Gint = intp(shiftvfrac[c], Ginthceil, Ginthfloor); //determine R/B at grid points using colour differences at shift point plus interpolated G value at grid point //but first we need to interpolate G-R/G-B to grid points... - grbdiff[((rr)*ts + cc) >> 1] = Gint - rgb[c][(rr) * ts + cc]; - gshift[((rr)*ts + cc) >> 1] = Gint; + grbdiff[indx] = Gint - rgb[c][indx]; + gshift[indx] = Gint; } } @@ -920,54 +1013,105 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const shiftvfrac[0] /= 2.f; shiftvfrac[2] /= 2.f; - // this loop does not deserve vectorization in mainly because the most expensive part with the divisions does not happen often (less than 1/10 in my tests) - for (int rr = 8; rr < rr1 - 8; rr++) - for (int cc = 8 + (FC(rr, 2) & 1), c = FC(rr, cc), indx = rr * ts + cc; cc < cc1 - 8; cc += 2, indx += 2) { +#ifdef __SSE2__ + vfloat zd25v = F2V(0.25f); + vfloat onev = F2V(1.f); + vfloat zd5v = F2V(0.5f); + vfloat epsv = F2V(eps); +#endif + for (int rr = 8; rr < rr1 - 8; rr++) { + int cc = 8 + (FC(rr, 2) & 1); + int c = FC(rr, cc); + int GRBdir0 = GRBdir[0][c]; + int GRBdir1 = GRBdir[1][c]; + vfloat shifthfracc = F2V(shifthfrac[c]); + vfloat shiftvfracc = F2V(shiftvfrac[c]); +#ifdef __SSE2__ + for (int indx = rr * ts + cc; cc < cc1 - 14; cc += 8, indx += 8) { + //interpolate colour difference from optical R/B locations to grid locations + vfloat grbdiffinthfloor = vintpf(shifthfracc, LVFU(grbdiff[(indx - GRBdir1) >> 1]), LVFU(grbdiff[indx >> 1])); + vfloat grbdiffinthceil = vintpf(shifthfracc, LVFU(grbdiff[((rr - GRBdir0) * ts + cc - GRBdir1) >> 1]), LVFU(grbdiff[((rr - GRBdir0) * ts + cc) >> 1])); + //grbdiffint is bilinear interpolation of G-R/G-B at grid point + vfloat grbdiffint = vintpf(shiftvfracc, grbdiffinthceil, grbdiffinthfloor); - float grbdiffold = rgb[1][indx] - rgb[c][indx]; + //now determine R/B at grid points using interpolated colour differences and interpolated G value at grid point + vfloat cinv = LVFU(rgb[c][indx >> 1]); + vfloat rinv = LC2VFU(rgb[1][indx]); + vfloat RBint = rinv - grbdiffint; + vmask cmask = vmaskf_ge(vabsf(RBint - cinv), zd25v * (RBint + cinv)); + if(_mm_movemask_ps((vfloat)cmask)) { + // if for any of the 4 pixels the condition is true, do the math for all 4 pixels and mask the unused out at the end + //gradient weights using difference from G at CA shift points and G at grid points + vfloat p0 = onev / (epsv + vabsf(rinv - LVFU(gshift[indx >> 1]))); + vfloat p1 = onev / (epsv + vabsf(rinv - LVFU(gshift[(indx - GRBdir1) >> 1]))); + vfloat p2 = onev / (epsv + vabsf(rinv - LVFU(gshift[((rr - GRBdir0) * ts + cc) >> 1]))); + vfloat p3 = onev / (epsv + vabsf(rinv - LVFU(gshift[((rr - GRBdir0) * ts + cc - GRBdir1) >> 1]))); + + grbdiffint = vself(cmask, (p0 * LVFU(grbdiff[indx >> 1]) + p1 * LVFU(grbdiff[(indx - GRBdir1) >> 1]) + + p2 * LVFU(grbdiff[((rr - GRBdir0) * ts + cc) >> 1]) + p3 * LVFU(grbdiff[((rr - GRBdir0) * ts + cc - GRBdir1) >> 1])) / (p0 + p1 + p2 + p3), grbdiffint); + + } + vfloat grbdiffold = rinv - cinv; + RBint = rinv - grbdiffint; + RBint = vself(vmaskf_gt(vabsf(grbdiffold), vabsf(grbdiffint)), RBint, cinv); + RBint = vself(vmaskf_lt(grbdiffold * grbdiffint, ZEROV), rinv - zd5v * (grbdiffold + grbdiffint), RBint); + STVFU(rgb[c][indx >> 1], RBint); + } +#endif + for (int c = FC(rr, cc), indx = rr * ts + cc; cc < cc1 - 8; cc += 2, indx += 2) { + float grbdiffold = rgb[1][indx] - rgb[c][indx >> 1]; //interpolate colour difference from optical R/B locations to grid locations - float grbdiffinthfloor = intp(shifthfrac[c], grbdiff[(indx - GRBdir[1][c]) >> 1], grbdiff[indx >> 1]); - float grbdiffinthceil = intp(shifthfrac[c], grbdiff[((rr - GRBdir[0][c]) * ts + cc - GRBdir[1][c]) >> 1], grbdiff[((rr - GRBdir[0][c]) * ts + cc) >> 1]); + float grbdiffinthfloor = intp(shifthfrac[c], grbdiff[(indx - GRBdir1) >> 1], grbdiff[indx >> 1]); + float grbdiffinthceil = intp(shifthfrac[c], grbdiff[((rr - GRBdir0) * ts + cc - GRBdir1) >> 1], grbdiff[((rr - GRBdir0) * ts + cc) >> 1]); //grbdiffint is bilinear interpolation of G-R/G-B at grid point float grbdiffint = intp(shiftvfrac[c], grbdiffinthceil, grbdiffinthfloor); //now determine R/B at grid points using interpolated colour differences and interpolated G value at grid point float RBint = rgb[1][indx] - grbdiffint; - if (fabsf(RBint - rgb[c][indx]) < 0.25f * (RBint + rgb[c][indx])) { + if (fabsf(RBint - rgb[c][indx >> 1]) < 0.25f * (RBint + rgb[c][indx >> 1])) { if (fabsf(grbdiffold) > fabsf(grbdiffint) ) { - rgb[c][indx] = RBint; + rgb[c][indx >> 1] = RBint; } } else { //gradient weights using difference from G at CA shift points and G at grid points - float p0 = 1.0f / (eps + fabsf(rgb[1][indx] - gshift[indx >> 1])); - float p1 = 1.0f / (eps + fabsf(rgb[1][indx] - gshift[(indx - GRBdir[1][c]) >> 1])); - float p2 = 1.0f / (eps + fabsf(rgb[1][indx] - gshift[((rr - GRBdir[0][c]) * ts + cc) >> 1])); - float p3 = 1.0f / (eps + fabsf(rgb[1][indx] - gshift[((rr - GRBdir[0][c]) * ts + cc - GRBdir[1][c]) >> 1])); + float p0 = 1.f / (eps + fabsf(rgb[1][indx] - gshift[indx >> 1])); + float p1 = 1.f / (eps + fabsf(rgb[1][indx] - gshift[(indx - GRBdir1) >> 1])); + float p2 = 1.f / (eps + fabsf(rgb[1][indx] - gshift[((rr - GRBdir0) * ts + cc) >> 1])); + float p3 = 1.f / (eps + fabsf(rgb[1][indx] - gshift[((rr - GRBdir0) * ts + cc - GRBdir1) >> 1])); - grbdiffint = (p0 * grbdiff[indx >> 1] + p1 * grbdiff[(indx - GRBdir[1][c]) >> 1] + - p2 * grbdiff[((rr - GRBdir[0][c]) * ts + cc) >> 1] + p3 * grbdiff[((rr - GRBdir[0][c]) * ts + cc - GRBdir[1][c]) >> 1]) / (p0 + p1 + p2 + p3) ; + grbdiffint = (p0 * grbdiff[indx >> 1] + p1 * grbdiff[(indx - GRBdir1) >> 1] + + p2 * grbdiff[((rr - GRBdir0) * ts + cc) >> 1] + p3 * grbdiff[((rr - GRBdir0) * ts + cc - GRBdir1) >> 1]) / (p0 + p1 + p2 + p3) ; //now determine R/B at grid points using interpolated colour differences and interpolated G value at grid point if (fabsf(grbdiffold) > fabsf(grbdiffint) ) { - rgb[c][indx] = rgb[1][indx] - grbdiffint; + rgb[c][indx >> 1] = rgb[1][indx] - grbdiffint; } } //if colour difference interpolation overshot the correction, just desaturate if (grbdiffold * grbdiffint < 0) { - rgb[c][indx] = rgb[1][indx] - 0.5f * (grbdiffold + grbdiffint); + rgb[c][indx >> 1] = rgb[1][indx] - 0.5f * (grbdiffold + grbdiffint); } } + } // copy CA corrected results to temporary image matrix for (int rr = border; rr < rr1 - border; rr++) { int c = FC(rr + top, left + border + (FC(rr + top, 2) & 1)); - - for (int row = rr + top, cc = border + (FC(rr, 2) & 1), indx = (row * width + cc + left) >> 1; cc < cc1 - border; cc += 2, indx++) { - RawDataTmp[indx] = 65535.0f * rgb[c][(rr) * ts + cc]; + int row = rr + top; + int cc = border + (FC(rr, 2) & 1); + int indx = (row * width + cc + left) >> 1; + int indx1 = (rr * ts + cc) >> 1; +#ifdef __SSE2__ + for (; indx < (row * width + cc1 - border - 7 + left) >> 1; indx+=4, indx1 += 4) { + STVFU(RawDataTmp[indx], c65535v * LVFU(rgb[c][indx1])); + } +#endif + for (; indx < (row * width + cc1 - border + left) >> 1; indx++, indx1++) { + RawDataTmp[indx] = 65535.f * rgb[c][indx1]; } } @@ -993,17 +1137,23 @@ void RawImageSource::CA_correct_RT(const bool autoCA, const double cared, const // copy temporary image matrix back to image matrix #pragma omp for - for(int row = 0; row < height; row++) - for(int col = 0 + (FC(row, 0) & 1), indx = (row * width + col) >> 1; col < width; col += 2, indx++) { + for(int row = 0; row < height; row++) { + int col = FC(row, 0) & 1; + int indx = (row * width + col) >> 1; +#ifdef __SSE2__ + for(; col < width - 7; col += 8, indx += 4) { + STC2VFU(rawData[row][col], LVFU(RawDataTmp[indx])); + } +#endif + for(; col < width; col += 2, indx++) { rawData[row][col] = RawDataTmp[indx]; } + } } // clean up free(buffer); - - } free(Gtmp); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 7518416cb..6d6fccc88 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -1113,13 +1113,13 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { - chsacol = 327.; + chsacol = 400.;//327.; colch = 0; } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0; colch = 1; } else if (curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { - chsacol = 327.0; + chsacol = 400.;//327.0; colch = 2; } @@ -1382,13 +1382,13 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { - chsacol = 327.; + chsacol = 400.;//327.; colch = 0; } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0; colch = 1; } else if (curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { - chsacol = 327.0; + chsacol = 400.;//327.0; colch = 2; } @@ -2812,13 +2812,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int hist16JCAM[posl]++; if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { - chsacol = 327.f; + chsacol = 400.f;//327.f; colch = ncie_C_p; } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0f; colch = 100.f * sqrtf (ncie_C_p / ncie->Q_p[i][j]); } else { /*if(curveMode3 == ColorAppearanceParams::TC_MODE_COLORF)*/ - chsacol = 327.0f; + chsacol = 400.f;//327.0f; colch = ncie->M_p[i][j]; } diff --git a/rtengine/rawimage.h b/rtengine/rawimage.h index 62752b59c..c2cdcb6ec 100644 --- a/rtengine/rawimage.h +++ b/rtengine/rawimage.h @@ -20,6 +20,8 @@ #define __RAWIMAGE_H #include +#include +#include #include "dcraw.h" #include "imageio.h" @@ -233,7 +235,13 @@ public: } float get_pre_mul(int c )const { - return pre_mul[c]; + if(std::isfinite(pre_mul[c])) { + return pre_mul[c]; + } else { + std::cout << "Failure decoding '" << filename << "', please file a bug report including the raw file and the line below:" << std::endl; + std::cout << "rawimage.h get_pre_mul() : pre_mul[" << c << "] value " << pre_mul[c] << " automatically replaced by value 1.0" << std::endl; + return 1.f; + } } float get_rgb_cam( int r, int c) const { diff --git a/rtgui/CMakeLists.txt b/rtgui/CMakeLists.txt index 629e3890f..05afd9af5 100644 --- a/rtgui/CMakeLists.txt +++ b/rtgui/CMakeLists.txt @@ -229,7 +229,7 @@ if((WIN32) AND NOT(UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG")) set_target_properties(rth PROPERTIES LINK_FLAGS "-mwindows") endif() set_target_properties(rth PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" OUTPUT_NAME rawtherapee) -set_target_properties(rth-cli PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -DRAWTHERAPEE_CLI" OUTPUT_NAME rawtherapee-cli) +set_target_properties(rth-cli PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" OUTPUT_NAME rawtherapee-cli) # Add linked libraries dependencies to executables targets target_link_libraries(rth rtengine diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index aced7faa3..71d0729e6 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -72,61 +72,70 @@ int setprogressStrUI ( void *p ) } -bool find_default_monitor_profile(GdkWindow *rootwin, Glib::ustring &defprof, Glib::ustring &defprofname) +bool find_default_monitor_profile (GdkWindow *rootwin, Glib::ustring &defprof, Glib::ustring &defprofname) { #ifdef WIN32 - HDC hDC = GetDC(nullptr); + HDC hDC = GetDC (nullptr); if (hDC != nullptr) { - if (SetICMMode(hDC, ICM_ON)) { + if (SetICMMode (hDC, ICM_ON)) { char profileName[MAX_PATH + 1]; DWORD profileLength = MAX_PATH; - if (GetICMProfileA(hDC, &profileLength, profileName)) { - defprof = Glib::ustring(profileName); - defprofname = Glib::path_get_basename(defprof); - size_t pos = defprofname.rfind("."); + if (GetICMProfileA (hDC, &profileLength, profileName)) { + defprof = Glib::ustring (profileName); + defprofname = Glib::path_get_basename (defprof); + size_t pos = defprofname.rfind ("."); if (pos != Glib::ustring::npos) { - defprofname = defprofname.substr(0, pos); + defprofname = defprofname.substr (0, pos); } - defprof = Glib::ustring("file:") + defprof; + + defprof = Glib::ustring ("file:") + defprof; return true; } // might fail if e.g. the monitor has no profile } - ReleaseDC(NULL, hDC); + ReleaseDC (NULL, hDC); } + #elif !defined(__APPLE__) // taken from geeqie (image.c) and adapted // Originally licensed as GPL v2+, with the following copyright: // * Copyright (C) 2006 John Ellis // * Copyright (C) 2008 - 2016 The Geeqie Team - // + // guchar *prof = nullptr; gint proflen; GdkAtom type = GDK_NONE; gint format = 0; - if (gdk_property_get(rootwin, gdk_atom_intern("_ICC_PROFILE", FALSE), GDK_NONE, 0, 64 * 1024 * 1024, FALSE, &type, &format, &proflen, &prof) && proflen > 0) { - cmsHPROFILE p = cmsOpenProfileFromMem(prof, proflen); + + if (gdk_property_get (rootwin, gdk_atom_intern ("_ICC_PROFILE", FALSE), GDK_NONE, 0, 64 * 1024 * 1024, FALSE, &type, &format, &proflen, &prof) && proflen > 0) { + cmsHPROFILE p = cmsOpenProfileFromMem (prof, proflen); + if (p) { defprofname = "from GDK"; - defprof = Glib::build_filename(Options::rtdir, "GDK_ICC_PROFILE.icc"); - if (cmsSaveProfileToFile(p, defprof.c_str())) { - cmsCloseProfile(p); + defprof = Glib::build_filename (Options::rtdir, "GDK_ICC_PROFILE.icc"); + + if (cmsSaveProfileToFile (p, defprof.c_str())) { + cmsCloseProfile (p); + if (prof) { - g_free(prof); + g_free (prof); } - defprof = Glib::ustring("file:") + defprof; + + defprof = Glib::ustring ("file:") + defprof; return true; } } } + if (prof) { - g_free(prof); + g_free (prof); } + #endif return false; } @@ -153,26 +162,31 @@ private: #if !defined(__APPLE__) // monitor profile not supported on apple void prepareProfileBox () { - profileBox.setPreferredWidth(70, 200); + profileBox.setPreferredWidth (70, 200); setExpandAlignProperties (&profileBox, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); profileBox.append (M ("PREFERENCES_PROFILE_NONE")); Glib::ustring defprofname; - if (find_default_monitor_profile(profileBox.get_root_window()->gobj(), defprof, defprofname)) { + + if (find_default_monitor_profile (profileBox.get_root_window()->gobj(), defprof, defprofname)) { profileBox.append (M ("MONITOR_PROFILE_SYSTEM") + " (" + defprofname + ")"); + if (options.rtSettings.autoMonitorProfile) { - rtengine::ICCStore::getInstance()->setDefaultMonitorProfileName(defprof); - profileBox.set_active(1); + rtengine::ICCStore::getInstance()->setDefaultMonitorProfileName (defprof); + profileBox.set_active (1); } else { - profileBox.set_active(0); + profileBox.set_active (0); } } else { profileBox.set_active (0); } + const std::vector profiles = rtengine::ICCStore::getInstance()->getProfiles (rtengine::ICCStore::ProfileType::MONITOR); - for (const auto profile: profiles) { + + for (const auto profile : profiles) { profileBox.append (profile); } + profileBox.set_tooltip_text (profileBox.get_active_text ()); } #endif @@ -181,34 +195,34 @@ private: { // same order as the enum intentBox.addEntry ("intent-perceptual.png", M ("PREFERENCES_INTENT_PERCEPTUAL")); - intentBox.addEntry("intent-relative.png", M("PREFERENCES_INTENT_RELATIVE")); + intentBox.addEntry ("intent-relative.png", M ("PREFERENCES_INTENT_RELATIVE")); intentBox.addEntry ("intent-absolute.png", M ("PREFERENCES_INTENT_ABSOLUTE")); setExpandAlignProperties (intentBox.buttonGroup, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); - intentBox.setSelected(1); + intentBox.setSelected (1); intentBox.show (); } void prepareSoftProofingBox () { Gtk::Image *softProofImage = Gtk::manage (new RTImage ("softProof.png")); - softProofImage->set_padding(0, 0); - softProof.add(*softProofImage); - softProof.set_relief(Gtk::RELIEF_NONE); - softProof.set_tooltip_markup(M("SOFTPROOF_TOOLTIP")); + softProofImage->set_padding (0, 0); + softProof.add (*softProofImage); + softProof.set_relief (Gtk::RELIEF_NONE); + softProof.set_tooltip_markup (M ("SOFTPROOF_TOOLTIP")); - softProof.set_active(false); - softProof.set_sensitive(canSProof); + softProof.set_active (false); + softProof.set_sensitive (canSProof); softProof.show (); Gtk::Image *spGamutCheckImage = Gtk::manage (new RTImage ("spGamutCheck.png")); - spGamutCheckImage->set_padding(0, 0); - spGamutCheck.add(*spGamutCheckImage); - spGamutCheck.set_relief(Gtk::RELIEF_NONE); - spGamutCheck.set_tooltip_markup(M("SOFTPROOF_GAMUTCHECK_TOOLTIP")); + spGamutCheckImage->set_padding (0, 0); + spGamutCheck.add (*spGamutCheckImage); + spGamutCheck.set_relief (Gtk::RELIEF_NONE); + spGamutCheck.set_tooltip_markup (M ("SOFTPROOF_GAMUTCHECK_TOOLTIP")); - spGamutCheck.set_active(false); - spGamutCheck.set_sensitive(false); + spGamutCheck.set_active (false); + spGamutCheck.set_sensitive (false); spGamutCheck.show (); } @@ -244,30 +258,35 @@ private: Glib::ustring profile; #if !defined(__APPLE__) // monitor profile not supported on apple + if (!defprof.empty() && profileBox.get_active_row_number () == 1) { profile = defprof; + if (profile.empty ()) { profile = options.rtSettings.monitorProfile; } + if (profile.empty ()) { profile = "sRGB IEC61966-2.1"; } } else if (profileBox.get_active_row_number () > 0) { profile = profileBox.get_active_text (); } + #else profile = "RT_sRGB"; #endif #if !defined(__APPLE__) // monitor profile not supported on apple + if (profileBox.get_active_row_number () == 0) { profile.clear (); intentBox.set_sensitive (false); intentBox.setSelected (1); - softProof.set_sensitive(false); - spGamutCheck.set_sensitive(false); + softProof.set_sensitive (false); + spGamutCheck.set_sensitive (false); profileBox.set_tooltip_text (""); @@ -279,38 +298,40 @@ private: if (supportsPerceptual || supportsRelativeColorimetric || supportsAbsoluteColorimetric) { intentBox.set_sensitive (true); - intentBox.setItemSensitivity(0, supportsPerceptual); - intentBox.setItemSensitivity(1, supportsRelativeColorimetric); - intentBox.setItemSensitivity(2, supportsAbsoluteColorimetric); - softProof.set_sensitive(canSProof); - spGamutCheck.set_sensitive(canSProof); + intentBox.setItemSensitivity (0, supportsPerceptual); + intentBox.setItemSensitivity (1, supportsRelativeColorimetric); + intentBox.setItemSensitivity (2, supportsAbsoluteColorimetric); + softProof.set_sensitive (canSProof); + spGamutCheck.set_sensitive (canSProof); } else { - intentBox.setItemSensitivity(0, true); - intentBox.setItemSensitivity(1, true); - intentBox.setItemSensitivity(2, true); + intentBox.setItemSensitivity (0, true); + intentBox.setItemSensitivity (1, true); + intentBox.setItemSensitivity (2, true); intentBox.set_sensitive (false); intentBox.setSelected (1); - softProof.set_sensitive(false); - spGamutCheck.set_sensitive(false); + softProof.set_sensitive (false); + spGamutCheck.set_sensitive (false); } profileBox.set_tooltip_text (profileBox.get_active_text ()); } + #endif rtengine::RenderingIntent intent; + switch (intentBox.getSelected ()) { - default: - case 0: - intent = rtengine::RI_PERCEPTUAL; - break; + default: + case 0: + intent = rtengine::RI_PERCEPTUAL; + break; - case 1: - intent = rtengine::RI_RELATIVE; - break; + case 1: + intent = rtengine::RI_RELATIVE; + break; - case 2: - intent = rtengine::RI_ABSOLUTE; - break; + case 2: + intent = rtengine::RI_ABSOLUTE; + break; } if (!processor) { @@ -320,8 +341,10 @@ private: if (!noEvent) { processor->beginUpdateParams (); } + processor->setMonitorProfile (profile, intent); processor->setSoftProofing (softProof.get_sensitive() && softProof.get_active(), spGamutCheck.get_sensitive() && spGamutCheck.get_active()); + if (!noEvent) { processor->endUpdateParams (rtengine::EvMonitorTransform); } @@ -331,36 +354,43 @@ private: { if (!canSProof) { ConnectionBlocker profileBlocker (softproofConn); - softProof.set_active(false); - softProof.set_sensitive(false); + softProof.set_active (false); + softProof.set_sensitive (false); #if !defined(__APPLE__) // monitor profile not supported on apple } else { - softProof.set_sensitive(profileBox.get_active_row_number () > 0); + softProof.set_sensitive (profileBox.get_active_row_number () > 0); #endif } - spGamutCheck.set_sensitive(softProof.get_sensitive() && softProof.get_active()); + + spGamutCheck.set_sensitive (softProof.get_sensitive() && softProof.get_active()); #if !defined(__APPLE__) // monitor profile not supported on apple + if (profileBox.get_active_row_number () > 0) { #endif + if (processor) { if (!noEvent) { processor->beginUpdateParams (); } + processor->setSoftProofing (softProof.get_sensitive() && softProof.get_active(), spGamutCheck.get_sensitive() && spGamutCheck.get_active()); + if (!noEvent) { processor->endUpdateParams (rtengine::EvMonitorTransform); } } + #if !defined(__APPLE__) // monitor profile not supported on apple } + #endif } public: explicit ColorManagementToolbar (rtengine::StagedImageProcessor* const& ipc) : intentBox (Glib::ustring (), true), - canSProof(!options.rtSettings.printerProfile.empty() && options.rtSettings.printerProfile != "None"), // assuming the printer profile exist! + canSProof (!options.rtSettings.printerProfile.empty() && options.rtSettings.printerProfile != "None"), // assuming the printer profile exist! processor (ipc) { #if !defined(__APPLE__) // monitor profile not supported on apple @@ -371,8 +401,8 @@ public: reset (); - softproofConn = softProof.signal_toggled().connect(sigc::mem_fun (this, &ColorManagementToolbar::softProofToggled)); - spGamutCheck.signal_toggled().connect(sigc::mem_fun (this, &ColorManagementToolbar::spGamutCheckToggled)); + softproofConn = softProof.signal_toggled().connect (sigc::mem_fun (this, &ColorManagementToolbar::softProofToggled)); + spGamutCheck.signal_toggled().connect (sigc::mem_fun (this, &ColorManagementToolbar::spGamutCheckToggled)); #if !defined(__APPLE__) // monitor profile not supported on apple profileConn = profileBox.signal_changed ().connect (sigc::mem_fun (this, &ColorManagementToolbar::profileBoxChanged)); #endif @@ -389,7 +419,7 @@ public: grid->attach_next_to (spGamutCheck, Gtk::POS_RIGHT, 1, 1); } - void canSoftProof(bool canSP) + void canSoftProof (bool canSP) { canSProof = canSP; updateSoftProofParameters(); @@ -398,7 +428,7 @@ public: void updateProcessor() { if (processor) { - updateParameters(true); + updateParameters (true); } } @@ -409,43 +439,44 @@ public: ConnectionBlocker profileBlocker (profileConn); if (!defprof.empty() && options.rtSettings.autoMonitorProfile) { - profileBox.set_active(1); + profileBox.set_active (1); } else { setActiveTextOrIndex (profileBox, options.rtSettings.monitorProfile, 0); } + #endif switch (options.rtSettings.monitorIntent) { - default: - case rtengine::RI_PERCEPTUAL: - intentBox.setSelected (0); - break; + default: + case rtengine::RI_PERCEPTUAL: + intentBox.setSelected (0); + break; - case rtengine::RI_RELATIVE: - intentBox.setSelected (1); - break; + case rtengine::RI_RELATIVE: + intentBox.setSelected (1); + break; - case rtengine::RI_ABSOLUTE: - intentBox.setSelected (2); - break; + case rtengine::RI_ABSOLUTE: + intentBox.setSelected (2); + break; } updateParameters (); } - void defaultMonitorProfileChanged(const Glib::ustring &profile_name, bool auto_monitor_profile) + void defaultMonitorProfileChanged (const Glib::ustring &profile_name, bool auto_monitor_profile) { ConnectionBlocker profileBlocker (profileConn); - + if (auto_monitor_profile && !defprof.empty()) { - rtengine::ICCStore::getInstance()->setDefaultMonitorProfileName(defprof); + rtengine::ICCStore::getInstance()->setDefaultMonitorProfileName (defprof); #ifndef __APPLE__ - profileBox.set_active(1); + profileBox.set_active (1); #endif } else { - rtengine::ICCStore::getInstance()->setDefaultMonitorProfileName(profile_name); + rtengine::ICCStore::getInstance()->setDefaultMonitorProfileName (profile_name); #ifndef __APPLE__ - setActiveTextOrIndex(profileBox, profile_name, 0); + setActiveTextOrIndex (profileBox, profile_name, 0); #endif } } @@ -453,7 +484,7 @@ public: }; EditorPanel::EditorPanel (FilePanel* filePanel) - : catalogPane(nullptr), realized(false), tbBeforeLock(nullptr), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), previewHandler(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), beforeLabel(nullptr), afterLabel(nullptr), beforeHeaderBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), parentWindow(nullptr), openThm(nullptr), isrc(nullptr), ipc(nullptr), beforeIpc(nullptr), err(0), isProcessing(false) + : catalogPane (nullptr), realized (false), tbBeforeLock (nullptr), iHistoryShow (nullptr), iHistoryHide (nullptr), iTopPanel_1_Show (nullptr), iTopPanel_1_Hide (nullptr), iRightPanel_1_Show (nullptr), iRightPanel_1_Hide (nullptr), iBeforeLockON (nullptr), iBeforeLockOFF (nullptr), previewHandler (nullptr), beforePreviewHandler (nullptr), beforeIarea (nullptr), beforeBox (nullptr), afterBox (nullptr), beforeLabel (nullptr), afterLabel (nullptr), beforeHeaderBox (nullptr), afterHeaderBox (nullptr), parent (nullptr), parentWindow (nullptr), openThm (nullptr), isrc (nullptr), ipc (nullptr), beforeIpc (nullptr), err (0), isProcessing (false) { epih = new EditorPanelIdleHelper; @@ -477,7 +508,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) profilep = Gtk::manage (new ProfilePanel ()); ppframe = new Gtk::Frame (); - ppframe->set_name("ProfilePanel"); + ppframe->set_name ("ProfilePanel"); ppframe->add (*profilep); ppframe->set_label (M ("PROFILEPANEL_LABEL")); //leftbox->pack_start (*ppframe, Gtk::PACK_SHRINK, 4); @@ -551,7 +582,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) iareapanel = new ImageAreaPanel (); tpc->setEditProvider (iareapanel->imageArea); - tpc->getToolBar()->setLockablePickerToolListener(iareapanel->imageArea); + tpc->getToolBar()->setLockablePickerToolListener (iareapanel->imageArea); Gtk::HBox* toolBarPanel = Gtk::manage (new Gtk::HBox ()); toolBarPanel->set_name ("EditorTopPanel"); @@ -580,7 +611,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) afterBox->pack_start (*iareapanel); beforeAfterBox = Gtk::manage (new Gtk::HBox()); - beforeAfterBox->set_name("BeforeAfterContainer"); + beforeAfterBox->set_name ("BeforeAfterContainer"); beforeAfterBox->pack_start (*afterBox); editbox->pack_start (*toolBarPanel, Gtk::PACK_SHRINK, 2); @@ -680,6 +711,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) iops->attach_next_to (*vsep2, Gtk::POS_LEFT, 1, 1); iops->attach_next_to (*progressLabel, Gtk::POS_LEFT, 1, 1); iops->attach_next_to (*vsep1, Gtk::POS_LEFT, 1, 1); + if (!gimpPlugin) { iops->attach_next_to (*sendtogimp, Gtk::POS_LEFT, 1, 1); } @@ -715,10 +747,10 @@ EditorPanel::EditorPanel (FilePanel* filePanel) editbox->show_all (); // build screen - hpanedl = Gtk::manage (new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); - hpanedl->set_name("EditorLeftPaned"); - hpanedr = Gtk::manage (new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); - hpanedr->set_name("EditorRightPaned"); + hpanedl = Gtk::manage (new Gtk::Paned (Gtk::ORIENTATION_HORIZONTAL)); + hpanedl->set_name ("EditorLeftPaned"); + hpanedr = Gtk::manage (new Gtk::Paned (Gtk::ORIENTATION_HORIZONTAL)); + hpanedr->set_name ("EditorRightPaned"); leftbox->reference (); vboxright->reference (); @@ -919,6 +951,14 @@ void EditorPanel::writeOptions() } } + +void EditorPanel::writeToolExpandedStatus (std::vector &tpOpen) +{ + if (tpc) { + tpc->writeToolExpandedStatus (tpOpen); + } +} + void EditorPanel::showTopPanel (bool show) { if (tbTopPanel_1->get_active() != show) { @@ -1026,7 +1066,7 @@ void EditorPanel::close () tpc->closeImage (); // this call stops image processing tpc->writeOptions (); rtengine::ImageSource* is = isrc->getImageSource(); - is->setProgressListener( nullptr ); + is->setProgressListener ( nullptr ); if (ipc) { ipc->setPreviewImageListener (nullptr); @@ -1039,7 +1079,7 @@ void EditorPanel::close () delete previewHandler; previewHandler = nullptr; - if(iareapanel) { + if (iareapanel) { iareapanel->imageArea->setPreviewHandler (nullptr); iareapanel->imageArea->setImProcCoordinator (nullptr); iareapanel->imageArea->unsubscribe(); @@ -1050,7 +1090,7 @@ void EditorPanel::close () navigator->previewWindow->setPreviewHandler (nullptr); // If the file was deleted somewhere, the openThm.descreaseRef delete the object, but we don't know here - if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) { + if (Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) { openThm->removeThumbnailListener (this); openThm->decreaseRef (); } @@ -1064,7 +1104,7 @@ void EditorPanel::saveProfile () } // If the file was deleted, do not generate ghost entries - if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) { + if (Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) { ProcParams params; ipc->getParams (¶ms); @@ -1112,10 +1152,11 @@ void EditorPanel::setProgressState (bool inProcessing) p->inProcessing = inProcessing; p->epih = epih; - const auto func = [](gpointer data) -> gboolean { - spsparams* const p = static_cast(data); + const auto func = [] (gpointer data) -> gboolean { + spsparams* const p = static_cast (data); - if (p->epih->destroyed) { + if (p->epih->destroyed) + { if (p->epih->pending == 1) { delete p->epih; } else { @@ -1134,7 +1175,7 @@ void EditorPanel::setProgressState (bool inProcessing) return FALSE; }; - idle_register.add(func, p); + idle_register.add (func, p); } void EditorPanel::setProgress (double p) @@ -1142,7 +1183,7 @@ void EditorPanel::setProgress (double p) spparams *s = new spparams; s->val = p; s->pProgress = progressLabel; - idle_register.add(setprogressStrUI, s); + idle_register.add (setprogressStrUI, s); } void EditorPanel::setProgressStr (Glib::ustring str) @@ -1151,7 +1192,7 @@ void EditorPanel::setProgressStr (Glib::ustring str) s->str = str; s->val = -1; s->pProgress = progressLabel; - idle_register.add(setprogressStrUI, s); + idle_register.add (setprogressStrUI, s); } // This is only called from the ThreadUI, so within the gtk thread @@ -1162,7 +1203,7 @@ void EditorPanel::refreshProcessingState (bool inProcessingP) if (inProcessingP) { if (processingStartedTime == 0) { - processingStartedTime = ::time(nullptr); + processingStartedTime = ::time (nullptr); } s->str = "PROGRESSBAR_PROCESSING"; @@ -1177,7 +1218,7 @@ void EditorPanel::refreshProcessingState (bool inProcessingP) // Ring a sound if it was a long event if (processingStartedTime != 0) { - time_t curTime = ::time(nullptr); + time_t curTime = ::time (nullptr); if (::difftime (curTime, processingStartedTime) > options.sndLngEditProcDoneSecs) { SoundManager::playSoundAsync (options.sndLngEditProcDone); @@ -1235,10 +1276,11 @@ void EditorPanel::error (Glib::ustring title, Glib::ustring descr) p->title = title; p->epih = epih; - const auto func = [](gpointer data) -> gboolean { + const auto func = [] (gpointer data) -> gboolean { errparams* const p = static_cast (data); - if (p->epih->destroyed) { + if (p->epih->destroyed) + { if (p->epih->pending == 1) { delete p->epih; } else { @@ -1257,7 +1299,7 @@ void EditorPanel::error (Glib::ustring title, Glib::ustring descr) return FALSE; }; - idle_register.add(func, p); + idle_register.add (func, p); } void EditorPanel::info_toggled () @@ -1410,56 +1452,56 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event) // Editor Layout switch (event->keyval) { - case GDK_KEY_L: - if (tbTopPanel_1) { - tbTopPanel_1->set_active (!tbTopPanel_1->get_active()); // toggle top panel - } + case GDK_KEY_L: + if (tbTopPanel_1) { + tbTopPanel_1->set_active (!tbTopPanel_1->get_active()); // toggle top panel + } - if (ctrl) { - hidehp->set_active (!hidehp->get_active()); // toggle History (left panel) - } + if (ctrl) { + hidehp->set_active (!hidehp->get_active()); // toggle History (left panel) + } - if (alt) { - tbRightPanel_1->set_active (!tbRightPanel_1->get_active()); // toggle right panel - } + if (alt) { + tbRightPanel_1->set_active (!tbRightPanel_1->get_active()); // toggle right panel + } - return true; - break; - - case GDK_KEY_l: - if (!shift && !alt /*&& !ctrl*/) { - hidehp->set_active (!hidehp->get_active()); // toggle History (left panel) return true; - } + break; - if (alt && !ctrl) { // toggle right panel - tbRightPanel_1->set_active (!tbRightPanel_1->get_active()); - return true; - } + case GDK_KEY_l: + if (!shift && !alt /*&& !ctrl*/) { + hidehp->set_active (!hidehp->get_active()); // toggle History (left panel) + return true; + } - if (alt && ctrl) { // toggle left and right panels - hidehp->set_active (!hidehp->get_active()); - tbRightPanel_1->set_active (!tbRightPanel_1->get_active()); - return true; - } + if (alt && !ctrl) { // toggle right panel + tbRightPanel_1->set_active (!tbRightPanel_1->get_active()); + return true; + } - break; + if (alt && ctrl) { // toggle left and right panels + hidehp->set_active (!hidehp->get_active()); + tbRightPanel_1->set_active (!tbRightPanel_1->get_active()); + return true; + } - case GDK_KEY_m: // Maximize preview panel: hide top AND right AND history panels - if (!ctrl && !alt) { - toggleSidePanels(); - return true; - } + break; - break; + case GDK_KEY_m: // Maximize preview panel: hide top AND right AND history panels + if (!ctrl && !alt) { + toggleSidePanels(); + return true; + } - case GDK_KEY_M: // Maximize preview panel: hide top AND right AND history panels AND (fit image preview) - if (!ctrl && !alt) { - toggleSidePanelsZoomFit(); - return true; - } + break; - break; + case GDK_KEY_M: // Maximize preview panel: hide top AND right AND history panels AND (fit image preview) + if (!ctrl && !alt) { + toggleSidePanelsZoomFit(); + return true; + } + + break; } #ifdef __WIN32__ @@ -1482,170 +1524,172 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event) if (!ctrl) { // Normal switch (event->keyval) { - case GDK_KEY_bracketright: - tpc->coarse->rotateRight(); - return true; - - case GDK_KEY_bracketleft: - tpc->coarse->rotateLeft(); - return true; - - case GDK_KEY_i: - case GDK_KEY_I: - info->set_active (!info->get_active()); - return true; - - case GDK_KEY_B: - beforeAfter->set_active (!beforeAfter->get_active()); - return true; - - case GDK_KEY_plus: - case GDK_KEY_equal: - case GDK_KEY_KP_Add: - iareapanel->imageArea->zoomPanel->zoomInClicked(); - return true; - - case GDK_KEY_minus: - case GDK_KEY_underscore: - case GDK_KEY_KP_Subtract: - iareapanel->imageArea->zoomPanel->zoomOutClicked(); - return true; - - case GDK_KEY_z://GDK_1 - iareapanel->imageArea->zoomPanel->zoom11Clicked(); - return true; - - /* - #ifndef __WIN32__ - case GDK_KEY_9: // toggle background color of the preview - iareapanel->imageArea->previewModePanel->togglebackColor(); - return true; - #endif - */ - case GDK_KEY_r: //preview mode Red - iareapanel->imageArea->previewModePanel->toggleR(); - return true; - - case GDK_KEY_g: //preview mode Green - iareapanel->imageArea->previewModePanel->toggleG(); - return true; - - case GDK_KEY_b: //preview mode Blue - iareapanel->imageArea->previewModePanel->toggleB(); - return true; - - case GDK_KEY_v: //preview mode Luminosity - iareapanel->imageArea->previewModePanel->toggleL(); - return true; - - case GDK_KEY_F: //preview mode Focus Mask - iareapanel->imageArea->indClippedPanel->toggleFocusMask(); - return true; - - case GDK_KEY_less: - iareapanel->imageArea->indClippedPanel->toggleClipped (false); - return true; - - case GDK_KEY_greater: - iareapanel->imageArea->indClippedPanel->toggleClipped (true); - return true; - - case GDK_KEY_f: - iareapanel->imageArea->zoomPanel->zoomFitClicked(); - return true; - - case GDK_KEY_F5: - openThm->openDefaultViewer ((event->state & GDK_SHIFT_MASK) ? 2 : 1); - return true; - - case GDK_KEY_y: // synchronize filebrowser with image in Editor - if (!simpleEditor && fPanel && !fname.empty()) { - fPanel->fileCatalog->selectImage (fname, false); + case GDK_KEY_bracketright: + tpc->coarse->rotateRight(); return true; - } - break; // to avoid gcc complain - - case GDK_KEY_x: // clear filters and synchronize filebrowser with image in Editor - if (!simpleEditor && fPanel && !fname.empty()) { - fPanel->fileCatalog->selectImage (fname, true); + case GDK_KEY_bracketleft: + tpc->coarse->rotateLeft(); return true; - } - break; // to avoid gcc complain + case GDK_KEY_i: + case GDK_KEY_I: + info->set_active (!info->get_active()); + return true; + + case GDK_KEY_B: + beforeAfter->set_active (!beforeAfter->get_active()); + return true; + + case GDK_KEY_plus: + case GDK_KEY_equal: + case GDK_KEY_KP_Add: + iareapanel->imageArea->zoomPanel->zoomInClicked(); + return true; + + case GDK_KEY_minus: + case GDK_KEY_underscore: + case GDK_KEY_KP_Subtract: + iareapanel->imageArea->zoomPanel->zoomOutClicked(); + return true; + + case GDK_KEY_z://GDK_1 + iareapanel->imageArea->zoomPanel->zoom11Clicked(); + return true; + + /* + #ifndef __WIN32__ + case GDK_KEY_9: // toggle background color of the preview + iareapanel->imageArea->previewModePanel->togglebackColor(); + return true; + #endif + */ + case GDK_KEY_r: //preview mode Red + iareapanel->imageArea->previewModePanel->toggleR(); + return true; + + case GDK_KEY_g: //preview mode Green + iareapanel->imageArea->previewModePanel->toggleG(); + return true; + + case GDK_KEY_b: //preview mode Blue + iareapanel->imageArea->previewModePanel->toggleB(); + return true; + + case GDK_KEY_v: //preview mode Luminosity + iareapanel->imageArea->previewModePanel->toggleL(); + return true; + + case GDK_KEY_F: //preview mode Focus Mask + iareapanel->imageArea->previewModePanel->toggleFocusMask(); + return true; + + case GDK_KEY_f: + iareapanel->imageArea->zoomPanel->zoomFitClicked(); + return true; + + case GDK_KEY_less: + iareapanel->imageArea->indClippedPanel->toggleClipped (false); + return true; + + case GDK_KEY_greater: + iareapanel->imageArea->indClippedPanel->toggleClipped (true); + return true; + + case GDK_KEY_F5: + openThm->openDefaultViewer ((event->state & GDK_SHIFT_MASK) ? 2 : 1); + return true; + + case GDK_KEY_y: // synchronize filebrowser with image in Editor + if (!simpleEditor && fPanel && !fname.empty()) { + fPanel->fileCatalog->selectImage (fname, false); + return true; + } + + break; // to avoid gcc complain + + case GDK_KEY_x: // clear filters and synchronize filebrowser with image in Editor + if (!simpleEditor && fPanel && !fname.empty()) { + fPanel->fileCatalog->selectImage (fname, true); + return true; + } + + break; // to avoid gcc complain } } else { // With control switch (event->keyval) { - case GDK_KEY_S: - saveProfile(); - setProgressStr (M ("PROGRESSBAR_PROCESSING_PROFILESAVED")); - return true; + case GDK_KEY_S: + saveProfile(); + setProgressStr (M ("PROGRESSBAR_PROCESSING_PROFILESAVED")); + return true; - case GDK_KEY_s: - if (!gimpPlugin) { - saveAsPressed(); - } - return true; + case GDK_KEY_s: + if (!gimpPlugin) { + saveAsPressed(); + } - case GDK_KEY_b: - if (!gimpPlugin && !simpleEditor) { - queueImgPressed(); - } + return true; - return true; + case GDK_KEY_b: + if (!gimpPlugin && !simpleEditor) { + queueImgPressed(); + } - case GDK_KEY_e: - if (!gimpPlugin) { - sendToGimpPressed(); - } - return true; + return true; - case GDK_KEY_z: - history->undo (); - return true; + case GDK_KEY_e: + if (!gimpPlugin) { + sendToGimpPressed(); + } - case GDK_KEY_Z: - history->redo (); - return true; + return true; - case GDK_KEY_F5: - openThm->openDefaultViewer (3); - return true; + case GDK_KEY_z: + history->undo (); + return true; + + case GDK_KEY_Z: + history->redo (); + return true; + + case GDK_KEY_F5: + openThm->openDefaultViewer (3); + return true; } } //if (!ctrl) } //if (!alt) if (alt) { switch (event->keyval) { - case GDK_KEY_s: - history->addBookmarkPressed (); - setProgressStr (M ("PROGRESSBAR_SNAPSHOT_ADDED")); - return true; + case GDK_KEY_s: + history->addBookmarkPressed (); + setProgressStr (M ("PROGRESSBAR_SNAPSHOT_ADDED")); + return true; - case GDK_KEY_f: - iareapanel->imageArea->zoomPanel->zoomFitCropClicked(); - return true; + case GDK_KEY_f: + iareapanel->imageArea->zoomPanel->zoomFitCropClicked(); + return true; } } if (shift) { switch (event->keyval) { - case GDK_KEY_F3: // open Previous image from Editor's perspective - if (!simpleEditor && fPanel && !fname.empty()) { - EditorPanel::openPreviousEditorImage(); - return true; - } + case GDK_KEY_F3: // open Previous image from Editor's perspective + if (!simpleEditor && fPanel && !fname.empty()) { + EditorPanel::openPreviousEditorImage(); + return true; + } - break; // to avoid gcc complain + break; // to avoid gcc complain - case GDK_KEY_F4: // open next image from Editor's perspective - if (!simpleEditor && fPanel && !fname.empty()) { - EditorPanel::openNextEditorImage(); - return true; - } + case GDK_KEY_F4: // open next image from Editor's perspective + if (!simpleEditor && fPanel && !fname.empty()) { + EditorPanel::openNextEditorImage(); + return true; + } - break; // to avoid gcc complain + break; // to avoid gcc complain } } @@ -1699,8 +1743,9 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, Gl else if (sf.format == "jpg") ld->startFunc (sigc::bind (sigc::mem_fun (img, &rtengine::IImage16::saveAsJPEG), fname, sf.jpegQuality, sf.jpegSubSamp), sigc::bind (sigc::mem_fun (*this, &EditorPanel::idle_imageSaved), ld, img, fname, sf)); - else + else { delete ld; + } } else { Glib::ustring msg_ = Glib::ustring ("") + fname + ": Error during image processing\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); @@ -1796,7 +1841,7 @@ void EditorPanel::saveAsPressed () fnameOut = saveAsDialog->getFileName (); options.lastSaveAsPath = saveAsDialog->getDirectory (); - saveAsDialog->get_size(options.saveAsDialogWidth, options.saveAsDialogHeight); + saveAsDialog->get_size (options.saveAsDialogWidth, options.saveAsDialogHeight); options.autoSuffix = saveAsDialog->getAutoSuffix (); options.saveMethodNum = saveAsDialog->getSaveMethodNum (); lastSaveAsFileName = Glib::path_get_basename (removeExtension (fnameOut)); @@ -1897,25 +1942,27 @@ void EditorPanel::sendToGimpPressed () } -bool EditorPanel::saveImmediately(const Glib::ustring &filename, const SaveFormat &sf) +bool EditorPanel::saveImmediately (const Glib::ustring &filename, const SaveFormat &sf) { rtengine::procparams::ProcParams pparams; ipc->getParams (&pparams); - rtengine::ProcessingJob *job = rtengine::ProcessingJob::create(ipc->getInitialImage(), pparams); + rtengine::ProcessingJob *job = rtengine::ProcessingJob::create (ipc->getInitialImage(), pparams); // save immediately - rtengine::IImage16 *img = rtengine::processImage(job, err, nullptr, options.tunnelMetaData, false); + rtengine::IImage16 *img = rtengine::processImage (job, err, nullptr, options.tunnelMetaData, false); int err = 0; + if (sf.format == "tif") { - err = img->saveAsTIFF(filename, sf.tiffBits, sf.tiffUncompressed); + err = img->saveAsTIFF (filename, sf.tiffBits, sf.tiffUncompressed); } else if (sf.format == "png") { - err = img->saveAsPNG(filename, sf.pngCompression, sf.pngBits); + err = img->saveAsPNG (filename, sf.pngCompression, sf.pngBits); } else if (sf.format == "jpg") { - err = img->saveAsJPEG(filename, sf.jpegQuality, sf.jpegSubSamp); + err = img->saveAsJPEG (filename, sf.jpegQuality, sf.jpegSubSamp); } else { err = 1; } + img->free(); return !err; } @@ -1966,7 +2013,7 @@ bool EditorPanel::idle_sendToGimp ( ProgressConnector *pc, int tries = 1; while (Glib::file_test (fileName, Glib::FILE_TEST_EXISTS) && tries < 1000) { - fileName = Glib::ustring::compose("%1-%2.%3", fname, tries, sf.format); + fileName = Glib::ustring::compose ("%1-%2.%3", fname, tries, sf.format); tries++; } @@ -2012,9 +2059,9 @@ bool EditorPanel::idle_sentToGimp (ProgressConnector *pc, rtengine::IImage1 } if (!success) { - Gtk::MessageDialog msgd (*parent, M("MAIN_MSG_CANNOTSTARTEDITOR"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - msgd.set_secondary_text (M("MAIN_MSG_CANNOTSTARTEDITOR_SECONDARY")); - msgd.set_title (M("MAIN_BUTTON_SENDTOEDITOR")); + Gtk::MessageDialog msgd (*parent, M ("MAIN_MSG_CANNOTSTARTEDITOR"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + msgd.set_secondary_text (M ("MAIN_MSG_CANNOTSTARTEDITOR_SECONDARY")); + msgd.set_title (M ("MAIN_BUTTON_SENDTOEDITOR")); msgd.run (); } } @@ -2069,7 +2116,7 @@ void EditorPanel::beforeAfterToggled () if (beforeAfter->get_active ()) { int errorCode = 0; - rtengine::InitialImage *beforeImg = rtengine::InitialImage::load ( isrc->getImageSource ()->getFileName(), openThm->getType() == FT_Raw , &errorCode, nullptr); + rtengine::InitialImage *beforeImg = rtengine::InitialImage::load ( isrc->getImageSource ()->getFileName(), openThm->getType() == FT_Raw, &errorCode, nullptr); if ( !beforeImg || errorCode ) { return; @@ -2138,7 +2185,7 @@ void EditorPanel::tbBeforeLock_toggled () } void EditorPanel::histogramChanged (LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma, LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve, /*LUTu & histCLurve, LUTu & histLLCurve,*/ LUTu & histLCAM, LUTu & histCCAM, - LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw , LUTu & histChroma, LUTu & histLRETI) + LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw, LUTu & histChroma, LUTu & histLRETI) { if (histogramPanel) { @@ -2199,9 +2246,9 @@ void EditorPanel::tbShowHideSidePanels_managestate() ShowHideSidePanelsconn.block (false); } -void EditorPanel::updateProfiles(const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC) +void EditorPanel::updateProfiles (const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC) { - colorMgmtToolBar->canSoftProof(!printerProfile.empty() && printerProfile != "None"); + colorMgmtToolBar->canSoftProof (!printerProfile.empty() && printerProfile != "None"); } void EditorPanel::updateTPVScrollbar (bool hide) @@ -2218,64 +2265,64 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) { switch (newPosition) { - case 0: + case 0: - // No histogram - if (!oldPosition) { - // An histogram actually exist, we delete it - delete histogramPanel; - histogramPanel = nullptr; - } + // No histogram + if (!oldPosition) { + // An histogram actually exist, we delete it + delete histogramPanel; + histogramPanel = nullptr; + } - // else no need to create it - break; + // else no need to create it + break; - case 1: + case 1: - // Histogram on the left pane - if (oldPosition == 0) { - // There was no Histogram before, so we create it - histogramPanel = Gtk::manage (new HistogramPanel ()); - leftbox->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); - } else if (oldPosition == 2) { - // The histogram was on the right side, so we move it to the left - histogramPanel->reference(); - removeIfThere (vboxright, histogramPanel, false); - leftbox->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); - histogramPanel->unreference(); - } + // Histogram on the left pane + if (oldPosition == 0) { + // There was no Histogram before, so we create it + histogramPanel = Gtk::manage (new HistogramPanel ()); + leftbox->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); + } else if (oldPosition == 2) { + // The histogram was on the right side, so we move it to the left + histogramPanel->reference(); + removeIfThere (vboxright, histogramPanel, false); + leftbox->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); + histogramPanel->unreference(); + } - histogramPanel->reorder (Gtk::POS_LEFT); - leftbox->reorder_child (*histogramPanel, 0); - break; + histogramPanel->reorder (Gtk::POS_LEFT); + leftbox->reorder_child (*histogramPanel, 0); + break; - case 2: - default: + case 2: + default: - // Histogram on the right pane - if (oldPosition == 0) { - // There was no Histogram before, so we create it - histogramPanel = Gtk::manage (new HistogramPanel ()); - vboxright->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); - } else if (oldPosition == 1) { - // The histogram was on the left side, so we move it to the right - histogramPanel->reference(); - removeIfThere (leftbox, histogramPanel, false); - vboxright->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); - histogramPanel->unreference(); - } + // Histogram on the right pane + if (oldPosition == 0) { + // There was no Histogram before, so we create it + histogramPanel = Gtk::manage (new HistogramPanel ()); + vboxright->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); + } else if (oldPosition == 1) { + // The histogram was on the left side, so we move it to the right + histogramPanel->reference(); + removeIfThere (leftbox, histogramPanel, false); + vboxright->pack_start (*histogramPanel, Gtk::PACK_SHRINK, 2); + histogramPanel->unreference(); + } - histogramPanel->reorder (Gtk::POS_RIGHT); - vboxright->reorder_child (*histogramPanel, 0); - break; + histogramPanel->reorder (Gtk::POS_RIGHT); + vboxright->reorder_child (*histogramPanel, 0); + break; } iareapanel->imageArea->setPointerMotionHListener (histogramPanel); } -void EditorPanel::defaultMonitorProfileChanged(const Glib::ustring &profile_name, bool auto_monitor_profile) +void EditorPanel::defaultMonitorProfileChanged (const Glib::ustring &profile_name, bool auto_monitor_profile) { - colorMgmtToolBar->defaultMonitorProfileChanged(profile_name, auto_monitor_profile); + colorMgmtToolBar->defaultMonitorProfileChanged (profile_name, auto_monitor_profile); } diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index d3d0eeaf7..286905bf5 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -46,12 +46,12 @@ struct EditorPanelIdleHelper { class RTWindow; class EditorPanel final : - public Gtk::VBox, - public PParamsChangeListener, - public rtengine::ProgressListener, - public ThumbnailListener, - public HistoryBeforeLineListener, - public rtengine::HistogramListener + public Gtk::VBox, + public PParamsChangeListener, + public rtengine::ProgressListener, + public ThumbnailListener, + public HistoryBeforeLineListener, + public rtengine::HistogramListener { public: explicit EditorPanel (FilePanel* filePanel = nullptr); @@ -74,6 +74,7 @@ public: } void writeOptions(); + void writeToolExpandedStatus (std::vector &tpOpen); void showTopPanel (bool show); bool isRealized() @@ -130,14 +131,14 @@ public: { return isProcessing; } - void updateProfiles(const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC); + void updateProfiles (const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC); void updateTPVScrollbar (bool hide); void updateTabsUsesIcons (bool useIcons); void updateHistogramPosition (int oldPosition, int newPosition); - void defaultMonitorProfileChanged(const Glib::ustring &profile_name, bool auto_monitor_profile); + void defaultMonitorProfileChanged (const Glib::ustring &profile_name, bool auto_monitor_profile); - bool saveImmediately(const Glib::ustring &filename, const SaveFormat &sf); + bool saveImmediately (const Glib::ustring &filename, const SaveFormat &sf); Gtk::Paned* catalogPane; diff --git a/rtgui/exportpanel.cc b/rtgui/exportpanel.cc index 72cf30fdd..7fdc3ae50 100644 --- a/rtgui/exportpanel.cc +++ b/rtgui/exportpanel.cc @@ -32,193 +32,193 @@ ExportPanel::ExportPanel () : listener (nullptr) pack_start(*enabled, Gtk::PACK_SHRINK, 4); pack_start (*Gtk::manage(new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 2);*/ - Gtk::Label* labExportTitle = Gtk::manage ( new Gtk::Label (M("EXPORT_FASTEXPORTOPTIONS")) ); + Gtk::Label* labExportTitle = Gtk::manage ( new Gtk::Label (M ("EXPORT_FASTEXPORTOPTIONS")) ); labExportTitle->set_use_markup (true); - labExportTitle->set_tooltip_text (M("EXPORT_INSTRUCTIONS")); - labExportTitle->set_alignment(Gtk::ALIGN_START); - pack_start(*labExportTitle, Gtk::PACK_SHRINK, 4); + labExportTitle->set_tooltip_text (M ("EXPORT_INSTRUCTIONS")); + labExportTitle->set_alignment (Gtk::ALIGN_START); + pack_start (*labExportTitle, Gtk::PACK_SHRINK, 4); Gtk::RadioButton::Group pipeline_group; - use_fast_pipeline = Gtk::manage ( new Gtk::RadioButton (pipeline_group, M("EXPORT_USE_FAST_PIPELINE"))); - use_normal_pipeline = Gtk::manage ( new Gtk::RadioButton (pipeline_group, M("EXPORT_USE_NORMAL_PIPELINE"))); - bypass_box = Gtk::manage(new Gtk::VBox()); - bypass_ALL = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_ALL"))); - use_fast_pipeline->set_tooltip_text(M("EXPORT_USE_FAST_PIPELINE_TIP")); - bypass_sharpening = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_SHARPENING"))); - bypass_sharpenEdge = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_SHARPENEDGE"))); - bypass_sharpenMicro = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_SHARPENMICRO"))); + use_fast_pipeline = Gtk::manage ( new Gtk::RadioButton (pipeline_group, M ("EXPORT_USE_FAST_PIPELINE"))); + use_normal_pipeline = Gtk::manage ( new Gtk::RadioButton (pipeline_group, M ("EXPORT_USE_NORMAL_PIPELINE"))); + bypass_box = Gtk::manage (new Gtk::VBox()); + bypass_ALL = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_ALL"))); + use_fast_pipeline->set_tooltip_text (M ("EXPORT_USE_FAST_PIPELINE_TIP")); + bypass_sharpening = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_SHARPENING"))); + bypass_sharpenEdge = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_SHARPENEDGE"))); + bypass_sharpenMicro = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_SHARPENMICRO"))); //bypass_lumaDenoise = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_LUMADENOISE"))); //bypass_colorDenoise = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_COLORDENOISE"))); - bypass_defringe = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_DEFRINGE"))); - bypass_dirpyrDenoise = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_DIRPYRDENOISE"))); - bypass_sh_hq = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_SH_HQ"))); - bypass_dirpyrequalizer = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_DIRPYREQUALIZER"))); - bypass_wavelet = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_EQUALIZER"))); - bypass_raw_ccSteps = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_CCSTEPS"))); - bypass_raw_ca = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_CA"))); - bypass_raw_df = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_DF"))); - bypass_raw_ff = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_FF"))); + bypass_defringe = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_DEFRINGE"))); + bypass_dirpyrDenoise = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_DIRPYRDENOISE"))); + bypass_sh_hq = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_SH_HQ"))); + bypass_dirpyrequalizer = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_DIRPYREQUALIZER"))); + bypass_wavelet = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_EQUALIZER"))); + bypass_raw_ccSteps = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_CCSTEPS"))); + bypass_raw_ca = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_CA"))); + bypass_raw_df = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_DF"))); + bypass_raw_ff = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_FF"))); // ---------------------- Bayer sensor frame ----------------------- - Gtk::Frame *bayerFrame = Gtk::manage( new Gtk::Frame(M("TP_RAW_SENSOR_BAYER"))); + Gtk::Frame *bayerFrame = Gtk::manage ( new Gtk::Frame (M ("TP_RAW_SENSOR_BAYER"))); Gtk::VBox* bayerFrameVBox = Gtk::manage (new Gtk::VBox ()); Gtk::HBox* hb_raw_bayer_method = Gtk::manage (new Gtk::HBox ()); - hb_raw_bayer_method->pack_start (*Gtk::manage (new Gtk::Label ( M("EXPORT_RAW_DMETHOD") + ": ")), Gtk::PACK_SHRINK, 4); + hb_raw_bayer_method->pack_start (*Gtk::manage (new Gtk::Label ( M ("EXPORT_RAW_DMETHOD") + ": ")), Gtk::PACK_SHRINK, 4); raw_bayer_method = Gtk::manage (new MyComboBoxText ()); - for( size_t i = 0; i < procparams::RAWParams::BayerSensor::numMethods; i++) { - raw_bayer_method->append(procparams::RAWParams::BayerSensor::methodstring[i]); + for ( size_t i = 0; i < procparams::RAWParams::BayerSensor::numMethods; i++) { + raw_bayer_method->append (procparams::RAWParams::BayerSensor::methodstring[i]); } - raw_bayer_method->set_active(0); + raw_bayer_method->set_active (0); hb_raw_bayer_method->pack_end (*raw_bayer_method, Gtk::PACK_EXPAND_WIDGET, 4); //bypass_raw_all_enhance = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_ALL_ENHANCE"))); - bypass_raw_bayer_linenoise = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_LINENOISE"))); - bypass_raw_bayer_greenthresh = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_GREENTHRESH"))); - bypass_raw_bayer_dcb_iterations = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_DCB_ITERATIONS"))); - bypass_raw_bayer_dcb_enhance = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_DCB_ENHANCE"))); - bypass_raw_bayer_lmmse_iterations = Gtk::manage ( new Gtk::CheckButton (M("EXPORT_BYPASS_RAW_LMMSE_ITERATIONS"))); + bypass_raw_bayer_linenoise = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_LINENOISE"))); + bypass_raw_bayer_greenthresh = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_GREENTHRESH"))); + bypass_raw_bayer_dcb_iterations = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_DCB_ITERATIONS"))); + bypass_raw_bayer_dcb_enhance = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_DCB_ENHANCE"))); + bypass_raw_bayer_lmmse_iterations = Gtk::manage ( new Gtk::CheckButton (M ("EXPORT_BYPASS_RAW_LMMSE_ITERATIONS"))); // ---------------------- Bayer sensor frame ----------------------- - Gtk::Frame *xtransFrame = Gtk::manage( new Gtk::Frame(M("TP_RAW_SENSOR_XTRANS"))); + Gtk::Frame *xtransFrame = Gtk::manage ( new Gtk::Frame (M ("TP_RAW_SENSOR_XTRANS"))); Gtk::VBox* xtransFrameVBox = Gtk::manage (new Gtk::VBox ()); Gtk::HBox* hb_raw_xtrans_method = Gtk::manage (new Gtk::HBox ()); - hb_raw_xtrans_method->pack_start (*Gtk::manage (new Gtk::Label ( M("EXPORT_RAW_DMETHOD") + ": ")), Gtk::PACK_SHRINK, 4); + hb_raw_xtrans_method->pack_start (*Gtk::manage (new Gtk::Label ( M ("EXPORT_RAW_DMETHOD") + ": ")), Gtk::PACK_SHRINK, 4); raw_xtrans_method = Gtk::manage (new MyComboBoxText ()); - for( size_t i = 0; i < procparams::RAWParams::XTransSensor::numMethods; i++) { - raw_xtrans_method->append(procparams::RAWParams::XTransSensor::methodstring[i]); + for ( size_t i = 0; i < procparams::RAWParams::XTransSensor::numMethods; i++) { + raw_xtrans_method->append (procparams::RAWParams::XTransSensor::methodstring[i]); } - raw_xtrans_method->set_active(0); + raw_xtrans_method->set_active (0); hb_raw_xtrans_method->pack_end (*raw_xtrans_method, Gtk::PACK_EXPAND_WIDGET, 4); // ---------------------------------------------------------------- // start global packing Gtk::HBox* lblbox = Gtk::manage (new Gtk::HBox ()); - lblbox->pack_start (*Gtk::manage (new Gtk::Label (M("EXPORT_PIPELINE"))), Gtk::PACK_SHRINK, 4); + lblbox->pack_start (*Gtk::manage (new Gtk::Label (M ("EXPORT_PIPELINE"))), Gtk::PACK_SHRINK, 4); pack_start (*lblbox, Gtk::PACK_SHRINK, 4); - pack_start(*use_fast_pipeline , Gtk::PACK_SHRINK, 4); - pack_start(*use_normal_pipeline , Gtk::PACK_SHRINK, 4); + pack_start (*use_fast_pipeline, Gtk::PACK_SHRINK, 4); + pack_start (*use_normal_pipeline, Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*Gtk::manage(new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*Gtk::manage (new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 4); lblbox = Gtk::manage (new Gtk::HBox ()); - lblbox->pack_start (*Gtk::manage (new Gtk::Label (M("EXPORT_BYPASS"))), Gtk::PACK_SHRINK, 4); + lblbox->pack_start (*Gtk::manage (new Gtk::Label (M ("EXPORT_BYPASS"))), Gtk::PACK_SHRINK, 4); bypass_box->pack_start (*lblbox, Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_ALL , Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_ALL, Gtk::PACK_SHRINK, 4); // bypass_box->pack_start(*Gtk::manage(new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_sharpening , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_sharpenEdge , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_sharpenMicro , Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_sharpening, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_sharpenEdge, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_sharpenMicro, Gtk::PACK_SHRINK, 4); //pack_start(*bypass_lumaDenoise , Gtk::PACK_SHRINK, 4); //pack_start(*bypass_colorDenoise , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_defringe , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_dirpyrDenoise, Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_sh_hq , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_dirpyrequalizer , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_wavelet , Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_defringe, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_dirpyrDenoise, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_sh_hq, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_dirpyrequalizer, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_wavelet, Gtk::PACK_SHRINK, 4); - bayerFrameVBox->pack_start(*hb_raw_bayer_method, Gtk::PACK_SHRINK, 4); + bayerFrameVBox->pack_start (*hb_raw_bayer_method, Gtk::PACK_SHRINK, 4); //bayerFrameVBox->pack_start(*bypass_raw_all_enhance , Gtk::PACK_SHRINK, 4); - bayerFrameVBox->pack_start(*bypass_raw_bayer_dcb_iterations, Gtk::PACK_SHRINK, 4); - bayerFrameVBox->pack_start(*bypass_raw_bayer_dcb_enhance , Gtk::PACK_SHRINK, 4); - bayerFrameVBox->pack_start(*bypass_raw_bayer_lmmse_iterations, Gtk::PACK_SHRINK, 4); - bayerFrameVBox->pack_start(*bypass_raw_bayer_linenoise , Gtk::PACK_SHRINK, 4); - bayerFrameVBox->pack_start(*bypass_raw_bayer_greenthresh , Gtk::PACK_SHRINK, 4); - bayerFrame->add(*bayerFrameVBox); + bayerFrameVBox->pack_start (*bypass_raw_bayer_dcb_iterations, Gtk::PACK_SHRINK, 4); + bayerFrameVBox->pack_start (*bypass_raw_bayer_dcb_enhance, Gtk::PACK_SHRINK, 4); + bayerFrameVBox->pack_start (*bypass_raw_bayer_lmmse_iterations, Gtk::PACK_SHRINK, 4); + bayerFrameVBox->pack_start (*bypass_raw_bayer_linenoise, Gtk::PACK_SHRINK, 4); + bayerFrameVBox->pack_start (*bypass_raw_bayer_greenthresh, Gtk::PACK_SHRINK, 4); + bayerFrame->add (*bayerFrameVBox); - xtransFrameVBox->pack_start(*hb_raw_xtrans_method, Gtk::PACK_SHRINK, 4); - xtransFrame->add(*xtransFrameVBox); + xtransFrameVBox->pack_start (*hb_raw_xtrans_method, Gtk::PACK_SHRINK, 4); + xtransFrame->add (*xtransFrameVBox); - bypass_box->pack_start(*bypass_raw_ccSteps , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_raw_ca , Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_raw_ccSteps, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_raw_ca, Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_raw_df , Gtk::PACK_SHRINK, 4); - bypass_box->pack_start(*bypass_raw_ff , Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_raw_df, Gtk::PACK_SHRINK, 4); + bypass_box->pack_start (*bypass_raw_ff, Gtk::PACK_SHRINK, 4); - pack_start(*bypass_box, Gtk::PACK_SHRINK); - - pack_start (*Gtk::manage(new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 2); + pack_start (*bypass_box, Gtk::PACK_SHRINK); + + pack_start (*Gtk::manage (new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 2); // Resize options Gtk::HBox* rmbox = Gtk::manage (new Gtk::HBox ()); - rmbox->pack_start (*Gtk::manage (new Gtk::Label (M("TP_RESIZE_LABEL"))), Gtk::PACK_SHRINK, 4); + rmbox->pack_start (*Gtk::manage (new Gtk::Label (M ("TP_RESIZE_LABEL"))), Gtk::PACK_SHRINK, 4); pack_start (*rmbox, Gtk::PACK_SHRINK, 4); Gtk::HBox* wbox = Gtk::manage (new Gtk::HBox ()); Gtk::HBox* hbox = Gtk::manage (new Gtk::HBox ()); MaxWidth = Gtk::manage (new MySpinButton ()); MaxHeight = Gtk::manage (new MySpinButton ()); - wbox->pack_start (*Gtk::manage (new Gtk::Label (M("EXPORT_MAXWIDTH"))), Gtk::PACK_SHRINK, 4); + wbox->pack_start (*Gtk::manage (new Gtk::Label (M ("EXPORT_MAXWIDTH"))), Gtk::PACK_SHRINK, 4); wbox->pack_start (*MaxWidth); - hbox->pack_start (*Gtk::manage (new Gtk::Label (M("EXPORT_MAXHEIGHT"))), Gtk::PACK_SHRINK, 4); + hbox->pack_start (*Gtk::manage (new Gtk::Label (M ("EXPORT_MAXHEIGHT"))), Gtk::PACK_SHRINK, 4); hbox->pack_start (*MaxHeight); pack_start (*wbox, Gtk::PACK_SHRINK, 4); pack_start (*hbox, Gtk::PACK_SHRINK, 4); MaxWidth->set_digits (0); - MaxWidth->set_width_chars(5); - MaxWidth->set_max_width_chars(5); + MaxWidth->set_width_chars (5); + MaxWidth->set_max_width_chars (5); MaxWidth->set_increments (1, 100); MaxWidth->set_value (options.fastexport_resize_width); MaxWidth->set_range (32, 10000); MaxHeight->set_digits (0); - MaxHeight->set_width_chars(5); - MaxHeight->set_max_width_chars(5); + MaxHeight->set_width_chars (5); + MaxHeight->set_max_width_chars (5); MaxHeight->set_increments (1, 100); MaxHeight->set_value (options.fastexport_resize_height); MaxHeight->set_range (32, 10000); // Buttons btnFastExport = Gtk::manage ( new Gtk::Button () ); - btnFastExport->set_tooltip_text(M("EXPORT_PUTTOQUEUEFAST")); + btnFastExport->set_tooltip_text (M ("EXPORT_PUTTOQUEUEFAST")); btnFastExport->set_image (*Gtk::manage (new RTImage ("processing.png"))); - pack_start(*btnFastExport, Gtk::PACK_SHRINK, 4); + pack_start (*btnFastExport, Gtk::PACK_SHRINK, 4); // add panel ending Gtk::VBox* vboxpe = Gtk::manage (new Gtk::VBox ()); Gtk::HSeparator* hseptpe = Gtk::manage (new Gtk::HSeparator ()); - Gtk::Image* peImg = Gtk::manage (new RTImage("PanelEnding.png")); - vboxpe->pack_start(*hseptpe, Gtk::PACK_SHRINK, 4); - vboxpe->pack_start(*peImg); - pack_start(*vboxpe, Gtk::PACK_SHRINK, 0); + Gtk::Image* peImg = Gtk::manage (new RTImage ("PanelEnding.png")); + vboxpe->pack_start (*hseptpe, Gtk::PACK_SHRINK, 4); + vboxpe->pack_start (*peImg); + pack_start (*vboxpe, Gtk::PACK_SHRINK, 0); - use_fast_pipeline->signal_toggled().connect(sigc::mem_fun(*this, &ExportPanel::use_fast_pipeline_toggled)); - btnFastExport->signal_clicked().connect( sigc::mem_fun(*this, &ExportPanel::FastExportPressed) ); + use_fast_pipeline->signal_toggled().connect (sigc::mem_fun (*this, &ExportPanel::use_fast_pipeline_toggled)); + btnFastExport->signal_clicked().connect ( sigc::mem_fun (*this, &ExportPanel::FastExportPressed) ); //btnExportLoadSettings->signal_clicked().connect( sigc::mem_fun(*this, &ExportPanel::LoadSettings) ); //btnExportSaveSettings->signal_clicked().connect( sigc::mem_fun(*this, &ExportPanel::SaveSettings) ); - bypass_ALLconn = bypass_ALL->signal_toggled().connect (sigc::mem_fun(*this, &ExportPanel::bypassALL_Toggled)); + bypass_ALLconn = bypass_ALL->signal_toggled().connect (sigc::mem_fun (*this, &ExportPanel::bypassALL_Toggled)); - bypass_sharpeningConn = bypass_sharpening->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_sharpenEdgeConn = bypass_sharpenEdge->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_sharpenMicroConn = bypass_sharpenMicro->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_sharpeningConn = bypass_sharpening->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_sharpenEdgeConn = bypass_sharpenEdge->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_sharpenMicroConn = bypass_sharpenMicro->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); //bypass_lumaDenoiseConn = bypass_lumaDenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); //bypass_colorDenoiseConn = bypass_colorDenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_defringeConn = bypass_defringe->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_dirpyrDenoiseConn = bypass_dirpyrDenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_sh_hqConn = bypass_sh_hq->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_dirpyrequalizerConn = bypass_dirpyrequalizer->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_waveletConn = bypass_wavelet->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_defringeConn = bypass_defringe->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_dirpyrDenoiseConn = bypass_dirpyrDenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_sh_hqConn = bypass_sh_hq->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_dirpyrequalizerConn = bypass_dirpyrequalizer->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_waveletConn = bypass_wavelet->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); //bypass_raw_all_enhanceConn = bypass_raw_bayer_all_enhance->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_bayer_dcb_iterationsConn = bypass_raw_bayer_dcb_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_bayer_dcb_enhanceConn = bypass_raw_bayer_dcb_enhance->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_bayer_lmmse_iterationsConn = bypass_raw_bayer_lmmse_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_bayer_linenoiseConn = bypass_raw_bayer_linenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_bayer_greenthreshConn = bypass_raw_bayer_greenthresh->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_ccStepsConn = bypass_raw_ccSteps->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_caConn = bypass_raw_ca->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_dfConn = bypass_raw_df->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); - bypass_raw_ffConn = bypass_raw_ff->signal_toggled().connect (sigc::bind (sigc::mem_fun(*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_bayer_dcb_iterationsConn = bypass_raw_bayer_dcb_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_bayer_dcb_enhanceConn = bypass_raw_bayer_dcb_enhance->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_bayer_lmmse_iterationsConn = bypass_raw_bayer_lmmse_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_bayer_linenoiseConn = bypass_raw_bayer_linenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_bayer_greenthreshConn = bypass_raw_bayer_greenthresh->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_ccStepsConn = bypass_raw_ccSteps->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_caConn = bypass_raw_ca->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_dfConn = bypass_raw_df->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); + bypass_raw_ffConn = bypass_raw_ff->signal_toggled().connect (sigc::bind (sigc::mem_fun (*bypass_ALL, &Gtk::CheckButton::set_inconsistent), true)); LoadDefaultSettings(); } @@ -251,39 +251,39 @@ void ExportPanel::SaveSettingsAsDefault() } \ } while (false) // Save fast export settings to options - FE_OPT_STORE_(options.fastexport_bypass_sharpening, bypass_sharpening->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_sharpenEdge, bypass_sharpenEdge->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_sharpenMicro, bypass_sharpenMicro->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_sharpening, bypass_sharpening->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_sharpenEdge, bypass_sharpenEdge->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_sharpenMicro, bypass_sharpenMicro->get_active ()); //options.fastexport_bypass_lumaDenoise = bypass_lumaDenoise->get_active (); //options.fastexport_bypass_colorDenoise = bypass_colorDenoise->get_active (); - FE_OPT_STORE_(options.fastexport_bypass_defringe, bypass_defringe->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_dirpyrDenoise, bypass_dirpyrDenoise->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_sh_hq, bypass_sh_hq->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_dirpyrequalizer, bypass_dirpyrequalizer->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_wavelet, bypass_wavelet->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_defringe, bypass_defringe->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_dirpyrDenoise, bypass_dirpyrDenoise->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_sh_hq, bypass_sh_hq->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_dirpyrequalizer, bypass_dirpyrequalizer->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_wavelet, bypass_wavelet->get_active ()); //options.fastexport_bypass_raw_bayer_all_enhance = bypass_raw_all_enhance->get_active (); - FE_OPT_STORE_(options.fastexport_bypass_raw_bayer_dcb_iterations, bypass_raw_bayer_dcb_iterations->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_bayer_dcb_enhance, bypass_raw_bayer_dcb_enhance->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_bayer_lmmse_iterations, bypass_raw_bayer_lmmse_iterations->get_active()); - FE_OPT_STORE_(options.fastexport_bypass_raw_bayer_linenoise, bypass_raw_bayer_linenoise->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_bayer_greenthresh, bypass_raw_bayer_greenthresh->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_ccSteps, bypass_raw_ccSteps->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_ca, bypass_raw_ca->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_df, bypass_raw_df->get_active ()); - FE_OPT_STORE_(options.fastexport_bypass_raw_ff, bypass_raw_ff->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_bayer_dcb_iterations, bypass_raw_bayer_dcb_iterations->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_bayer_dcb_enhance, bypass_raw_bayer_dcb_enhance->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_bayer_lmmse_iterations, bypass_raw_bayer_lmmse_iterations->get_active()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_bayer_linenoise, bypass_raw_bayer_linenoise->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_bayer_greenthresh, bypass_raw_bayer_greenthresh->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_ccSteps, bypass_raw_ccSteps->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_ca, bypass_raw_ca->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_df, bypass_raw_df->get_active ()); + FE_OPT_STORE_ (options.fastexport_bypass_raw_ff, bypass_raw_ff->get_active ()); //saving Bayer demosaic_method int currentRow = raw_bayer_method->get_active_row_number(); - if( currentRow >= 0 && currentRow < procparams::RAWParams::BayerSensor::numMethods) { - FE_OPT_STORE_(options.fastexport_raw_bayer_method, procparams::RAWParams::BayerSensor::methodstring[currentRow]); + if ( currentRow >= 0 && currentRow < procparams::RAWParams::BayerSensor::numMethods) { + FE_OPT_STORE_ (options.fastexport_raw_bayer_method, procparams::RAWParams::BayerSensor::methodstring[currentRow]); } //saving X-Trans demosaic_method currentRow = raw_xtrans_method->get_active_row_number(); - if( currentRow >= 0 && currentRow < procparams::RAWParams::XTransSensor::numMethods) { - FE_OPT_STORE_(options.fastexport_raw_xtrans_method, procparams::RAWParams::XTransSensor::methodstring[currentRow]); + if ( currentRow >= 0 && currentRow < procparams::RAWParams::XTransSensor::numMethods) { + FE_OPT_STORE_ (options.fastexport_raw_xtrans_method, procparams::RAWParams::XTransSensor::methodstring[currentRow]); } // options.fastexport_icm_input = icm_input ; @@ -295,15 +295,20 @@ void ExportPanel::SaveSettingsAsDefault() // options.fastexport_resize_appliesTo = resize_appliesTo; // options.fastexport_resize_dataspec = resize_dataspec ; - FE_OPT_STORE_(options.fastexport_resize_method, "Lanczos"); - FE_OPT_STORE_(options.fastexport_resize_width, MaxWidth->get_value_as_int ()); - FE_OPT_STORE_(options.fastexport_resize_height, MaxHeight->get_value_as_int ()); + FE_OPT_STORE_ (options.fastexport_resize_method, "Lanczos"); + FE_OPT_STORE_ (options.fastexport_resize_width, MaxWidth->get_value_as_int ()); + FE_OPT_STORE_ (options.fastexport_resize_height, MaxHeight->get_value_as_int ()); - FE_OPT_STORE_(options.fastexport_use_fast_pipeline, use_fast_pipeline->get_active()); + FE_OPT_STORE_ (options.fastexport_use_fast_pipeline, use_fast_pipeline->get_active()); #undef FE_OPT_STORE_ if (changed) { - Options::save(); + try { + Options::save(); + } catch (Options::Error &e) { + Gtk::MessageDialog msgd (getToplevelWindow (this), e.get_msg(), true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true); + msgd.run(); + } } } @@ -323,7 +328,7 @@ void ExportPanel::LoadDefaultSettings() //bypass_raw_bayer_all_enhance->set_active (options.fastexport_bypass_raw_bayer_all_enhance ); bypass_raw_bayer_dcb_iterations->set_active (options.fastexport_bypass_raw_bayer_dcb_iterations ); bypass_raw_bayer_dcb_enhance->set_active (options.fastexport_bypass_raw_bayer_dcb_enhance ); - bypass_raw_bayer_lmmse_iterations->set_active(options.fastexport_bypass_raw_bayer_lmmse_iterations); + bypass_raw_bayer_lmmse_iterations->set_active (options.fastexport_bypass_raw_bayer_lmmse_iterations); bypass_raw_bayer_linenoise->set_active (options.fastexport_bypass_raw_bayer_linenoise ); bypass_raw_bayer_greenthresh->set_active (options.fastexport_bypass_raw_bayer_greenthresh ); bypass_raw_ccSteps->set_active (options.fastexport_bypass_raw_ccSteps ); @@ -332,20 +337,20 @@ void ExportPanel::LoadDefaultSettings() bypass_raw_ff->set_active (options.fastexport_bypass_raw_ff ); // Bayer demosaic method - raw_bayer_method->set_active(procparams::RAWParams::BayerSensor::numMethods); + raw_bayer_method->set_active (procparams::RAWParams::BayerSensor::numMethods); - for( size_t i = 0; i < procparams::RAWParams::BayerSensor::numMethods; i++) - if( options.fastexport_raw_bayer_method == procparams::RAWParams::BayerSensor::methodstring[i]) { - raw_bayer_method->set_active(i); + for ( size_t i = 0; i < procparams::RAWParams::BayerSensor::numMethods; i++) + if ( options.fastexport_raw_bayer_method == procparams::RAWParams::BayerSensor::methodstring[i]) { + raw_bayer_method->set_active (i); break; } // X-Trans demosaic method - raw_xtrans_method->set_active(procparams::RAWParams::XTransSensor::numMethods); + raw_xtrans_method->set_active (procparams::RAWParams::XTransSensor::numMethods); - for( size_t i = 0; i < procparams::RAWParams::XTransSensor::numMethods; i++) - if( options.fastexport_raw_xtrans_method == procparams::RAWParams::XTransSensor::methodstring[i]) { - raw_xtrans_method->set_active(i); + for ( size_t i = 0; i < procparams::RAWParams::XTransSensor::numMethods; i++) + if ( options.fastexport_raw_xtrans_method == procparams::RAWParams::XTransSensor::methodstring[i]) { + raw_xtrans_method->set_active (i); break; } @@ -358,14 +363,14 @@ void ExportPanel::LoadDefaultSettings() // resize_appliesTo = options.fastexport_resize_appliesTo; // resize_dataspec = options.fastexport_resize_dataspec ; - MaxWidth->set_value(options.fastexport_resize_width); - MaxHeight->set_value(options.fastexport_resize_height); + MaxWidth->set_value (options.fastexport_resize_width); + MaxHeight->set_value (options.fastexport_resize_height); if (options.fastexport_use_fast_pipeline) { - use_fast_pipeline->set_active(true); - bypass_box->set_sensitive(false); + use_fast_pipeline->set_active (true); + bypass_box->set_sensitive (false); } else { - use_normal_pipeline->set_active(true); + use_normal_pipeline->set_active (true); } } @@ -405,26 +410,26 @@ void ExportPanel::bypassALL_Toggled() bypass_ALL->set_inconsistent (false); - bypass_sharpening->set_active(bypass_ALL->get_active()); - bypass_sharpenEdge->set_active(bypass_ALL->get_active()); - bypass_sharpenMicro->set_active(bypass_ALL->get_active()); + bypass_sharpening->set_active (bypass_ALL->get_active()); + bypass_sharpenEdge->set_active (bypass_ALL->get_active()); + bypass_sharpenMicro->set_active (bypass_ALL->get_active()); //bypass_lumaDenoise->set_active(bypass_ALL->get_active()); //bypass_colorDenoise->set_active(bypass_ALL->get_active()); - bypass_defringe->set_active(bypass_ALL->get_active()); - bypass_dirpyrDenoise->set_active(bypass_ALL->get_active()); - bypass_sh_hq->set_active(bypass_ALL->get_active()); - bypass_dirpyrequalizer->set_active(bypass_ALL->get_active()); - bypass_wavelet->set_active(bypass_ALL->get_active()); + bypass_defringe->set_active (bypass_ALL->get_active()); + bypass_dirpyrDenoise->set_active (bypass_ALL->get_active()); + bypass_sh_hq->set_active (bypass_ALL->get_active()); + bypass_dirpyrequalizer->set_active (bypass_ALL->get_active()); + bypass_wavelet->set_active (bypass_ALL->get_active()); //bypass_raw_bayer_all_enhance->set_active(bypass_ALL->get_active()); - bypass_raw_bayer_dcb_iterations->set_active(bypass_ALL->get_active()); - bypass_raw_bayer_dcb_enhance->set_active(bypass_ALL->get_active()); - bypass_raw_bayer_lmmse_iterations->set_active(bypass_ALL->get_active()); - bypass_raw_bayer_linenoise->set_active(bypass_ALL->get_active()); - bypass_raw_bayer_greenthresh->set_active(bypass_ALL->get_active()); - bypass_raw_ccSteps->set_active(bypass_ALL->get_active()); - bypass_raw_ca->set_active(bypass_ALL->get_active()); - bypass_raw_df->set_active(bypass_ALL->get_active()); - bypass_raw_ff->set_active(bypass_ALL->get_active()); + bypass_raw_bayer_dcb_iterations->set_active (bypass_ALL->get_active()); + bypass_raw_bayer_dcb_enhance->set_active (bypass_ALL->get_active()); + bypass_raw_bayer_lmmse_iterations->set_active (bypass_ALL->get_active()); + bypass_raw_bayer_linenoise->set_active (bypass_ALL->get_active()); + bypass_raw_bayer_greenthresh->set_active (bypass_ALL->get_active()); + bypass_raw_ccSteps->set_active (bypass_ALL->get_active()); + bypass_raw_ca->set_active (bypass_ALL->get_active()); + bypass_raw_df->set_active (bypass_ALL->get_active()); + bypass_raw_ff->set_active (bypass_ALL->get_active()); bypass_sharpeningConn.block (false); bypass_sharpenEdgeConn.block (false); @@ -450,7 +455,7 @@ void ExportPanel::bypassALL_Toggled() void ExportPanel::use_fast_pipeline_toggled() { - bypass_box->set_sensitive(!use_fast_pipeline->get_active()); + bypass_box->set_sensitive (!use_fast_pipeline->get_active()); } /* diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index 69c3d8487..7908b9133 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -96,14 +96,14 @@ bool fast_export = false; * -1 if there is an error in parameters * -2 if an error occurred during processing * -3 if at least one required procparam file was not found */ -int processLineParams( int argc, char **argv ); +int processLineParams ( int argc, char **argv ); -bool dontLoadCache( int argc, char **argv ); +bool dontLoadCache ( int argc, char **argv ); -int main(int argc, char **argv) +int main (int argc, char **argv) { - setlocale(LC_ALL, ""); - setlocale(LC_NUMERIC, "C"); // to set decimal point to "." + setlocale (LC_ALL, ""); + setlocale (LC_NUMERIC, "C"); // to set decimal point to "." Gio::init (); @@ -116,33 +116,33 @@ int main(int argc, char **argv) #ifdef WIN32 WCHAR exnameU[512] = {0}; GetModuleFileNameW (NULL, exnameU, 511); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); + WideCharToMultiByte (CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 511) < 0) { - strncpy(exname, argv[0], 511); + if (readlink ("/proc/self/exe", exname, 511) < 0) { + strncpy (exname, argv[0], 511); } #endif - exePath = Glib::path_get_dirname(exname); + exePath = Glib::path_get_dirname (exname); // set paths - if (Glib::path_is_absolute(DATA_SEARCH_PATH)) { + if (Glib::path_is_absolute (DATA_SEARCH_PATH)) { argv0 = DATA_SEARCH_PATH; } else { - argv0 = Glib::build_filename(exePath, DATA_SEARCH_PATH); + argv0 = Glib::build_filename (exePath, DATA_SEARCH_PATH); } - if (Glib::path_is_absolute(CREDITS_SEARCH_PATH)) { + if (Glib::path_is_absolute (CREDITS_SEARCH_PATH)) { creditsPath = CREDITS_SEARCH_PATH; } else { - creditsPath = Glib::build_filename(exePath, CREDITS_SEARCH_PATH); + creditsPath = Glib::build_filename (exePath, CREDITS_SEARCH_PATH); } - if (Glib::path_is_absolute(LICENCE_SEARCH_PATH)) { + if (Glib::path_is_absolute (LICENCE_SEARCH_PATH)) { licensePath = LICENCE_SEARCH_PATH; } else { - licensePath = Glib::build_filename(exePath, LICENCE_SEARCH_PATH); + licensePath = Glib::build_filename (exePath, LICENCE_SEARCH_PATH); } #else @@ -151,22 +151,24 @@ int main(int argc, char **argv) licensePath = LICENCE_SEARCH_PATH; #endif - bool quickstart = dontLoadCache(argc, argv); + bool quickstart = dontLoadCache (argc, argv); - if (!Options::load (quickstart)) { - printf("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!\n"); + try { + Options::load (quickstart); + } catch (Options::Error &) { + printf ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!\n"); return -2; } - rtengine::setPaths(options); + rtengine::setPaths (options); - TIFFSetWarningHandler(nullptr); // avoid annoying message boxes + TIFFSetWarningHandler (nullptr); // avoid annoying message boxes #ifndef WIN32 // Move the old path to the new one if the new does not exist - if (Glib::file_test(Glib::build_filename(options.rtdir, "cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test(options.cacheBaseDir, Glib::FILE_TEST_IS_DIR)) { - g_rename(Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); + if (Glib::file_test (Glib::build_filename (options.rtdir, "cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test (options.cacheBaseDir, Glib::FILE_TEST_IS_DIR)) { + g_rename (Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); } #endif @@ -175,57 +177,58 @@ int main(int argc, char **argv) bool consoleOpened = false; // suppression of annoying error boxes - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); if (argc > 1 || options.rtSettings.verbose) { - Glib::ustring fname(fname_to_utf8 (argv[1])); + Glib::ustring fname (fname_to_utf8 (argv[1])); #if ECLIPSE_ARGS - fname = fname.substr(1, fname.length()-2); + fname = fname.substr (1, fname.length() - 2); #endif + if (options.rtSettings.verbose || ( !Glib::file_test (fname, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR))) { - bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001); - bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001); + bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001); + bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001); // no console, if stdout and stderr both are redirected to file - if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) { + if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) { // check if parameter -w was passed. // We have to do that in this step, because it controls whether to open a console to show the output of following steps bool Console = true; - for(int i = 1; i < argc; i++) - if(!strcmp(argv[i], "-w")) { + for (int i = 1; i < argc; i++) + if (!strcmp (argv[i], "-w")) { Console = false; break; } - if(Console && AllocConsole()) { - AttachConsole( GetCurrentProcessId() ) ; + if (Console && AllocConsole()) { + AttachConsole ( GetCurrentProcessId() ) ; // Don't allow CTRL-C in console to terminate RT - SetConsoleCtrlHandler( NULL, true ); + SetConsoleCtrlHandler ( NULL, true ); // Set title of console char consoletitle[128]; - sprintf(consoletitle, "RawTherapee %s Console", RTVERSION); - SetConsoleTitle(consoletitle); + sprintf (consoletitle, "RawTherapee %s Console", RTVERSION); + SetConsoleTitle (consoletitle); // increase size of screen buffer COORD c; c.X = 200; c.Y = 1000; - SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c ); + SetConsoleScreenBufferSize ( GetStdHandle ( STD_OUTPUT_HANDLE ), c ); // Disable console-Cursor CONSOLE_CURSOR_INFO cursorInfo; cursorInfo.dwSize = 100; cursorInfo.bVisible = false; - SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo ); + SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); - if(!stdoutRedirectedtoFile) { - freopen( "CON", "w", stdout ) ; + if (!stdoutRedirectedtoFile) { + freopen ( "CON", "w", stdout ) ; } - if(!stderrRedirectedtoFile) { - freopen( "CON", "w", stderr ) ; + if (!stderrRedirectedtoFile) { + freopen ( "CON", "w", stderr ) ; } - freopen( "CON", "r", stdin ) ; + freopen ( "CON", "r", stdin ) ; consoleOpened = true; @@ -236,31 +239,34 @@ int main(int argc, char **argv) } } } + #endif int ret = 0; // printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing std::cout << "RawTherapee, version " << RTVERSION << ", command line" << std::endl; + if (argc > 1) { - ret = processLineParams(argc, argv); - } - else { + ret = processLineParams (argc, argv); + } else { std::cout << "Terminating without anything to do." << std::endl; } #ifdef WIN32 - if(consoleOpened) { - printf("Press any key to exit RawTherapee\n"); - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); + + if (consoleOpened) { + printf ("Press any key to exit RawTherapee\n"); + FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); getch(); } + #endif return ret; } -void deleteProcParams(std::vector &pparams) +void deleteProcParams (std::vector &pparams) { for (unsigned int i = 0; i < pparams.size(); i++) { pparams[i]->deleteInstance(); @@ -272,14 +278,15 @@ void deleteProcParams(std::vector &pparam } -bool dontLoadCache( int argc, char **argv ) +bool dontLoadCache ( int argc, char **argv ) { for (int iArg = 1; iArg < argc; iArg++) { - Glib::ustring currParam(argv[iArg]); + Glib::ustring currParam (argv[iArg]); #if ECLIPSE_ARGS - currParam = currParam.substr(1, currParam.length()-2); + currParam = currParam.substr (1, currParam.length() - 2); #endif - if( currParam.at(0) == '-' && currParam.at(1) == 'q' ) { + + if ( currParam.at (0) == '-' && currParam.at (1) == 'q' ) { return true; } } @@ -287,7 +294,7 @@ bool dontLoadCache( int argc, char **argv ) return false; } -int processLineParams( int argc, char **argv ) +int processLineParams ( int argc, char **argv ) { rtengine::procparams::PartialProfile *rawParams = nullptr, *imgParams = nullptr; std::vector inputFiles; @@ -308,311 +315,316 @@ int processLineParams( int argc, char **argv ) std::string outputType = ""; unsigned errors = 0; - for( int iArg = 1; iArg < argc; iArg++) { - Glib::ustring currParam(argv[iArg]); + for ( int iArg = 1; iArg < argc; iArg++) { + Glib::ustring currParam (argv[iArg]); #if ECLIPSE_ARGS - currParam = currParam.substr(1, currParam.length()-2); -#endif - if( currParam.at(0) == '-' ) { - switch( currParam.at(1) ) { - case 'O': - copyParamsFile = true; - - case 'o': // outputfile or dir - if( iArg + 1 < argc ) { - iArg++; - outputPath = Glib::ustring(fname_to_utf8(argv[iArg])); -#if ECLIPSE_ARGS - outputPath = outputPath.substr(1, outputPath.length()-2); -#endif - if(outputPath.substr(0,9) == "/dev/null") { - outputPath.assign("/dev/null"); // removing any useless chars or filename - outputDirectory = false; - leaveUntouched = true; - } else if(Glib::file_test (outputPath, Glib::FILE_TEST_IS_DIR)) { - outputDirectory = true; - } - } - - break; - - case 'p': // processing parameters for all inputs; all set procparams are required, so - - // RT stop if any of them can't be loaded for any reason. - if( iArg + 1 < argc ) { - iArg++; - Glib::ustring fname(fname_to_utf8(argv[iArg])); -#if ECLIPSE_ARGS - fname = fname.substr(1, fname.length()-2); + currParam = currParam.substr (1, currParam.length() - 2); #endif - if (fname.at(0) == '-') { - std::cerr << "Error: filename missing next to the -p switch" << std::endl; - deleteProcParams(processingParams); - return -3; + if ( currParam.at (0) == '-' ) { + switch ( currParam.at (1) ) { + case 'O': + copyParamsFile = true; + + case 'o': // outputfile or dir + if ( iArg + 1 < argc ) { + iArg++; + outputPath = Glib::ustring (fname_to_utf8 (argv[iArg])); +#if ECLIPSE_ARGS + outputPath = outputPath.substr (1, outputPath.length() - 2); +#endif + + if (outputPath.substr (0, 9) == "/dev/null") { + outputPath.assign ("/dev/null"); // removing any useless chars or filename + outputDirectory = false; + leaveUntouched = true; + } else if (Glib::file_test (outputPath, Glib::FILE_TEST_IS_DIR)) { + outputDirectory = true; + } } - rtengine::procparams::PartialProfile* currentParams = new rtengine::procparams::PartialProfile(true); + break; - if (!(currentParams->load ( fname ))) { - processingParams.push_back(currentParams); + case 'p': // processing parameters for all inputs; all set procparams are required, so + + // RT stop if any of them can't be loaded for any reason. + if ( iArg + 1 < argc ) { + iArg++; + Glib::ustring fname (fname_to_utf8 (argv[iArg])); +#if ECLIPSE_ARGS + fname = fname.substr (1, fname.length() - 2); +#endif + + if (fname.at (0) == '-') { + std::cerr << "Error: filename missing next to the -p switch" << std::endl; + deleteProcParams (processingParams); + return -3; + } + + rtengine::procparams::PartialProfile* currentParams = new rtengine::procparams::PartialProfile (true); + + if (! (currentParams->load ( fname ))) { + processingParams.push_back (currentParams); + } else { + std::cerr << "Error: \"" << fname << "\" not found" << std::endl; + deleteProcParams (processingParams); + return -3; + } + } + + break; + + case 'S': + skipIfNoSidecar = true; + + case 's': // Processing params next to file (file extension appended) + sideProcParams = true; + sideCarFilePos = processingParams.size(); + break; + + case 'd': + useDefault = true; + break; + + case 'q': + break; + + case 'Y': + overwriteFiles = true; + break; + + case 'a': + allExtensions = true; + break; + + case 'j': + if (currParam.length() > 2 && currParam.at (2) == 's') { + if (currParam.length() == 3) { + std::cerr << "Error: the -js switch requires a mandatory value!" << std::endl; + deleteProcParams (processingParams); + return -3; + } + + // looking for the subsampling parameter + subsampling = atoi (currParam.substr (3).c_str()); + + if (subsampling < 1 || subsampling > 3) { + std::cerr << "Error: the value accompanying the -js switch has to be in the [1-3] range!" << std::endl; + deleteProcParams (processingParams); + return -3; + } } else { - std::cerr << "Error: \"" << fname << "\" not found" << std::endl; - deleteProcParams(processingParams); - return -3; + outputType = "jpg"; + compression = atoi (currParam.substr (2).c_str()); + + if (compression < 0 || compression > 100) { + std::cerr << "Error: the value accompanying the -j switch has to be in the [0-100] range!" << std::endl; + deleteProcParams (processingParams); + return -3; + } } - } - break; + break; - case 'S': - skipIfNoSidecar = true; + case 'b': + bits = atoi (currParam.substr (2).c_str()); - case 's': // Processing params next to file (file extension appended) - sideProcParams = true; - sideCarFilePos = processingParams.size(); - break; - - case 'd': - useDefault = true; - break; - - case 'q': - break; - - case 'Y': - overwriteFiles = true; - break; - - case 'a': - allExtensions = true; - break; - - case 'j': - if (currParam.length() > 2 && currParam.at(2) == 's') { - if (currParam.length() == 3) { - std::cerr << "Error: the -js switch requires a mandatory value!" << std::endl; - deleteProcParams(processingParams); + if (bits != 8 && bits != 16) { + std::cerr << "Error: specify -b8 for 8-bit or -b16 for 16-bit output." << std::endl; + deleteProcParams (processingParams); return -3; } - // looking for the subsampling parameter - subsampling = atoi(currParam.substr(3).c_str()); + break; - if (subsampling < 1 || subsampling > 3) { - std::cerr << "Error: the value accompanying the -js switch has to be in the [1-3] range!" << std::endl; - deleteProcParams(processingParams); - return -3; - } - } else { - outputType = "jpg"; - compression = atoi(currParam.substr(2).c_str()); + case 't': + outputType = "tif"; + compression = ((currParam.size() < 3 || currParam.at (2) != 'z') ? 0 : 1); + break; - if (compression < 0 || compression > 100) { - std::cerr << "Error: the value accompanying the -j switch has to be in the [0-100] range!" << std::endl; - deleteProcParams(processingParams); - return -3; - } - } + case 'n': + outputType = "png"; + compression = -1; + break; - break; + case 'f': + fast_export = true; + break; - case 'b': - bits = atoi(currParam.substr(2).c_str()); - - if (bits != 8 && bits != 16) { - std::cerr << "Error: specify -b8 for 8-bit or -b16 for 16-bit output." << std::endl; - deleteProcParams(processingParams); - return -3; - } - - break; - - case 't': - outputType = "tif"; - compression = ((currParam.size() < 3 || currParam.at(2) != 'z') ? 0 : 1); - break; - - case 'n': - outputType = "png"; - compression = -1; - break; - - case 'f': - fast_export = true; - break; - - case 'c': // MUST be last option - while (iArg + 1 < argc) { - iArg++; - Glib::ustring argument(fname_to_utf8(argv[iArg])); + case 'c': // MUST be last option + while (iArg + 1 < argc) { + iArg++; + Glib::ustring argument (fname_to_utf8 (argv[iArg])); #if ECLIPSE_ARGS - argument = argument.substr(1, argument.length()-2); + argument = argument.substr (1, argument.length() - 2); #endif - if (!Glib::file_test (argument, Glib::FILE_TEST_EXISTS)) { - std::cout << "\"" << argument << "\" doesn't exist !" << std::endl; - continue; - } - - if (Glib::file_test (argument, Glib::FILE_TEST_IS_REGULAR)) { - bool notAll = allExtensions && !options.is_parse_extention (argument); - bool notRetained = !allExtensions && !options.has_retained_extention (argument); - if (notAll || notRetained) { - if (notAll) { - std::cout << "\"" << argument << "\" is not one of the file format to process: skipped" << std::endl; - } else if (notRetained) { - std::cout << "\"" << argument << "\" is not one of the retained file format to process: skipped" << std::endl; - } - } - else { - inputFiles.emplace_back (argument); - } - continue; - - } - - if (Glib::file_test (argument, Glib::FILE_TEST_IS_DIR)) { - - auto dir = Gio::File::create_for_path (argument); - if (!dir || !dir->query_exists()) { + if (!Glib::file_test (argument, Glib::FILE_TEST_EXISTS)) { + std::cout << "\"" << argument << "\" doesn't exist !" << std::endl; continue; } - try { - - auto enumerator = dir->enumerate_children("standard::name,standard::type"); - - while (auto file = enumerator->next_file()) { - - const auto fileName = Glib::build_filename(argument, file->get_name()); - bool isDir = file->get_file_type() == Gio::FILE_TYPE_DIRECTORY; - bool notAll = allExtensions && !options.is_parse_extention(fileName); - bool notRetained = !allExtensions && !options.has_retained_extention(fileName); - - if (isDir || notAll || notRetained) { - if (isDir) { - std::cout << "\"" << fileName << "\" is a directory: skipped" << std::endl; - } else if (notAll) { - std::cout << "\"" << fileName << "\" is not one of the file format to process: skipped" << std::endl; - } else if (notRetained) { - std::cout << "\"" << fileName << "\" is not one of the retained file format to process: skipped" << std::endl; - } - continue; + if (Glib::file_test (argument, Glib::FILE_TEST_IS_REGULAR)) { + bool notAll = allExtensions && !options.is_parse_extention (argument); + bool notRetained = !allExtensions && !options.has_retained_extention (argument); + if (notAll || notRetained) { + if (notAll) { + std::cout << "\"" << argument << "\" is not one of the file format to process: skipped" << std::endl; + } else if (notRetained) { + std::cout << "\"" << argument << "\" is not one of the retained file format to process: skipped" << std::endl; } - - if (sideProcParams && skipIfNoSidecar) { - // look for the sidecar proc params - if (!Glib::file_test(fileName + paramFileExtension, Glib::FILE_TEST_EXISTS)) { - std::cout << "\"" << fileName << "\" has no side-car file: image skipped" << std::endl; - continue; - } - } - - inputFiles.emplace_back (fileName); + } else { + inputFiles.emplace_back (argument); } - } catch (Glib::Exception&) {} + continue; - continue; + } + + if (Glib::file_test (argument, Glib::FILE_TEST_IS_DIR)) { + + auto dir = Gio::File::create_for_path (argument); + + if (!dir || !dir->query_exists()) { + continue; + } + + try { + + auto enumerator = dir->enumerate_children ("standard::name,standard::type"); + + while (auto file = enumerator->next_file()) { + + const auto fileName = Glib::build_filename (argument, file->get_name()); + bool isDir = file->get_file_type() == Gio::FILE_TYPE_DIRECTORY; + bool notAll = allExtensions && !options.is_parse_extention (fileName); + bool notRetained = !allExtensions && !options.has_retained_extention (fileName); + + if (isDir || notAll || notRetained) { + if (isDir) { + std::cout << "\"" << fileName << "\" is a directory: skipped" << std::endl; + } else if (notAll) { + std::cout << "\"" << fileName << "\" is not one of the file format to process: skipped" << std::endl; + } else if (notRetained) { + std::cout << "\"" << fileName << "\" is not one of the retained file format to process: skipped" << std::endl; + } + + continue; + + } + + if (sideProcParams && skipIfNoSidecar) { + // look for the sidecar proc params + if (!Glib::file_test (fileName + paramFileExtension, Glib::FILE_TEST_EXISTS)) { + std::cout << "\"" << fileName << "\" has no side-car file: image skipped" << std::endl; + continue; + } + } + + inputFiles.emplace_back (fileName); + } + + } catch (Glib::Exception&) {} + + continue; + } + + std::cerr << "\"" << argument << "\" is neither a regular file nor a directory." << std::endl; } - std::cerr << "\"" << argument << "\" is neither a regular file nor a directory." << std::endl; + break; +#ifdef WIN32 + + case 'w': // This case is handled outside this function + break; +#endif + + case 'h': + case '?': + default: { + Glib::ustring pparamsExt = paramFileExtension.substr (1); + std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; + std::cout << std::endl; + std::cout << " Website: http://www.rawtherapee.com/" << std::endl; + std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; + std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; + std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; + std::cout << std::endl; + std::cout << "Symbols:" << std::endl; + std::cout << " indicate parameters you can change." << std::endl; + std::cout << " [Square brackets] mean the parameter is optional." << std::endl; + std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; + std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; + std::cout << std::endl; + std::cout << "Usage:" << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " -c | Convert files in batch with default parameters." << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " -c | Convert files in batch with your own settings." << std::endl; + std::cout << std::endl; +#ifdef WIN32 + std::cout << " -w Do not open the Windows console" << std::endl; + std::cout << std::endl; +#endif + std::cout << "Options:" << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << "[-o |-O ] [-q] [-a] [-s|-S] [-p [-p ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] [-f] -c " << std::endl; + std::cout << std::endl; + std::cout << " -c Specify one or more input files or directory." << std::endl; + std::cout << " When specifying directories, Rawtherapee will look for images files that comply with the" << std::endl; + std::cout << " selected extensions (see also '-a')." << std::endl; + std::cout << " -c must be the last option." << std::endl; + std::cout << " -o | Set output file or folder." << std::endl; + std::cout << " Saves output file alongside input file if -o is not specified." << std::endl; + std::cout << " -O | Set output file or folder and copy " << pparamsExt << " file into it." << std::endl; + std::cout << " Saves output file alongside input file if -O is not specified." << std::endl; + std::cout << " -q Quick-start mode. Does not load cached files to speedup start time." << std::endl; + std::cout << " -a Process all supported image file types when specifying a folder, even those" << std::endl; + std::cout << " not currently selected in Preferences > File Browser > Parsed Extensions." << std::endl; + std::cout << " -s Use the existing sidecar file to build the processing parameters," << std::endl; + std::cout << " e.g. for photo.raw there should be a photo.raw." << pparamsExt << " file in the same folder." << std::endl; + std::cout << " If the sidecar file does not exist, neutral values will be used." << std::endl; + std::cout << " -S Like -s but skip if the sidecar file does not exist." << std::endl; + std::cout << " -p Specify processing profile to be used for all conversions." << std::endl; + std::cout << " You can specify as many sets of \"-p \" options as you like," << std::endl; + std::cout << " each will be built on top of the previous one, as explained below." << std::endl; + std::cout << " -d Use the default raw or non-raw processing profile as set in" << std::endl; + std::cout << " Preferences > Image Processing > Default Processing Profile" << std::endl; + std::cout << " -j[1-100] Specify output to be JPEG (default, if -t and -n are not set)." << std::endl; + std::cout << " Optionally, specify compression 1-100 (default value: 92)." << std::endl; + std::cout << " -js<1-3> Specify the JPEG chroma subsampling parameter, where:" << std::endl; + std::cout << " 1 = Best compression: 2x2, 1x1, 1x1 (4:2:0)" << std::endl; + std::cout << " Chroma halved vertically and horizontally." << std::endl; + std::cout << " 2 = Balanced (default): 2x1, 1x1, 1x1 (4:2:2)" << std::endl; + std::cout << " Chroma halved horizontally." << std::endl; + std::cout << " 3 = Best quality: 1x1, 1x1, 1x1 (4:4:4)" << std::endl; + std::cout << " No chroma subsampling." << std::endl; + std::cout << " -b<8|16> Specify bit depth per channel (default value: 16 for TIFF, 8 for PNG)." << std::endl; + std::cout << " Only applies to TIFF and PNG output, JPEG is always 8." << std::endl; + std::cout << " -t[z] Specify output to be TIFF." << std::endl; + std::cout << " Uncompressed by default, or deflate compression with 'z'." << std::endl; + std::cout << " -n Specify output to be compressed PNG." << std::endl; + std::cout << " Compression is hard-coded to 6." << std::endl; + std::cout << " -Y Overwrite output if present." << std::endl; + std::cout << " -f Use the custom fast-export processing pipeline." << std::endl; + std::cout << std::endl; + std::cout << "Your " << pparamsExt << " files can be incomplete, RawTherapee will build the final values as follows:" << std::endl; + std::cout << " 1- A new processing profile is created using neutral values," << std::endl; + std::cout << " 2- If the \"-d\" option is set, the values are overridden by those found in" << std::endl; + std::cout << " the default raw or non-raw processing profile." << std::endl; + std::cout << " 3- If one or more \"-p\" options are set, the values are overridden by those" << std::endl; + std::cout << " found in these processing profiles." << std::endl; + std::cout << " 4- If the \"-s\" or \"-S\" options are set, the values are finally overridden by those" << std::endl; + std::cout << " found in the sidecar files." << std::endl; + std::cout << " The processing profiles are processed in the order specified on the command line." << std::endl; + return -1; } - - break; -#ifdef WIN32 - - case 'w': // This case is handled outside this function - break; -#endif - - case 'h': - case '?': - default: { - Glib::ustring pparamsExt = paramFileExtension.substr(1); - std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; - std::cout << std::endl; - std::cout << " Website: http://www.rawtherapee.com/" << std::endl; - std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; - std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; - std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; - std::cout << std::endl; - std::cout << "Symbols:" << std::endl; - std::cout << " indicate parameters you can change." << std::endl; - std::cout << " [Square brackets] mean the parameter is optional." << std::endl; - std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; - std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; - std::cout << std::endl; - std::cout << "Usage:" << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " -c | Convert files in batch with default parameters." << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " -c | Convert files in batch with your own settings." << std::endl; - std::cout << std::endl; -#ifdef WIN32 - std::cout << " -w Do not open the Windows console" << std::endl; - std::cout << std::endl; -#endif - std::cout << "Options:" << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << "[-o |-O ] [-q] [-a] [-s|-S] [-p [-p ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] [-f] -c " << std::endl; - std::cout << std::endl; - std::cout << " -c Specify one or more input files or directory." << std::endl; - std::cout << " When specifying directories, Rawtherapee will look for images files that comply with the" << std::endl; - std::cout << " selected extensions (see also '-a')." << std::endl; - std::cout << " -c must be the last option." << std::endl; - std::cout << " -o | Set output file or folder." << std::endl; - std::cout << " Saves output file alongside input file if -o is not specified." << std::endl; - std::cout << " -O | Set output file or folder and copy " << pparamsExt << " file into it." << std::endl; - std::cout << " Saves output file alongside input file if -O is not specified." << std::endl; - std::cout << " -q Quick-start mode. Does not load cached files to speedup start time." << std::endl; - std::cout << " -a Process all supported image file types when specifying a folder, even those" << std::endl; - std::cout << " not currently selected in Preferences > File Browser > Parsed Extensions." << std::endl; - std::cout << " -s Use the existing sidecar file to build the processing parameters," << std::endl; - std::cout << " e.g. for photo.raw there should be a photo.raw." << pparamsExt << " file in the same folder." << std::endl; - std::cout << " If the sidecar file does not exist, neutral values will be used." << std::endl; - std::cout << " -S Like -s but skip if the sidecar file does not exist." << std::endl; - std::cout << " -p Specify processing profile to be used for all conversions." << std::endl; - std::cout << " You can specify as many sets of \"-p \" options as you like," << std::endl; - std::cout << " each will be built on top of the previous one, as explained below." << std::endl; - std::cout << " -d Use the default raw or non-raw processing profile as set in" << std::endl; - std::cout << " Preferences > Image Processing > Default Processing Profile" << std::endl; - std::cout << " -j[1-100] Specify output to be JPEG (default, if -t and -n are not set)." << std::endl; - std::cout << " Optionally, specify compression 1-100 (default value: 92)." << std::endl; - std::cout << " -js<1-3> Specify the JPEG chroma subsampling parameter, where:" << std::endl; - std::cout << " 1 = Best compression: 2x2, 1x1, 1x1 (4:2:0)" << std::endl; - std::cout << " Chroma halved vertically and horizontally." << std::endl; - std::cout << " 2 = Balanced (default): 2x1, 1x1, 1x1 (4:2:2)" << std::endl; - std::cout << " Chroma halved horizontally." << std::endl; - std::cout << " 3 = Best quality: 1x1, 1x1, 1x1 (4:4:4)" << std::endl; - std::cout << " No chroma subsampling." << std::endl; - std::cout << " -b<8|16> Specify bit depth per channel (default value: 16 for TIFF, 8 for PNG)." << std::endl; - std::cout << " Only applies to TIFF and PNG output, JPEG is always 8." << std::endl; - std::cout << " -t[z] Specify output to be TIFF." << std::endl; - std::cout << " Uncompressed by default, or deflate compression with 'z'." << std::endl; - std::cout << " -n Specify output to be compressed PNG." << std::endl; - std::cout << " Compression is hard-coded to 6." << std::endl; - std::cout << " -Y Overwrite output if present." << std::endl; - std::cout << " -f Use the custom fast-export processing pipeline." << std::endl; - std::cout << std::endl; - std::cout << "Your " << pparamsExt << " files can be incomplete, RawTherapee will build the final values as follows:" << std::endl; - std::cout << " 1- A new processing profile is created using neutral values," << std::endl; - std::cout << " 2- If the \"-d\" option is set, the values are overridden by those found in" << std::endl; - std::cout << " the default raw or non-raw processing profile." << std::endl; - std::cout << " 3- If one or more \"-p\" options are set, the values are overridden by those" << std::endl; - std::cout << " found in these processing profiles." << std::endl; - std::cout << " 4- If the \"-s\" or \"-S\" options are set, the values are finally overridden by those" << std::endl; - std::cout << " found in the sidecar files." << std::endl; - std::cout << " The processing profiles are processed in the order specified on the command line." << std::endl; - return -1; - } } } else { - argv1 = Glib::ustring(fname_to_utf8(argv[iArg])); + argv1 = Glib::ustring (fname_to_utf8 (argv[iArg])); #if ECLIPSE_ARGS - argv1 = argv1.substr(1, argv1.length()-2); + argv1 = argv1.substr (1, argv1.length() - 2); #endif - if( outputDirectory ) { + if ( outputDirectory ) { options.savePathFolder = outputPath; options.saveUsePathTemplate = false; } else { @@ -639,41 +651,41 @@ int processLineParams( int argc, char **argv ) } } - if( !argv1.empty() ) { + if ( !argv1.empty() ) { return 1; } - if( inputFiles.empty() ) { + if ( inputFiles.empty() ) { return 2; } if (useDefault) { - rawParams = new rtengine::procparams::PartialProfile(true, true); - Glib::ustring profPath = options.findProfilePath(options.defProfRaw); + rawParams = new rtengine::procparams::PartialProfile (true, true); + Glib::ustring profPath = options.findProfilePath (options.defProfRaw); - if (options.is_defProfRawMissing() || profPath.empty() || (profPath != DEFPROFILE_DYNAMIC && rawParams->load(profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename(profPath, Glib::path_get_basename(options.defProfRaw) + paramFileExtension)))) { + if (options.is_defProfRawMissing() || profPath.empty() || (profPath != DEFPROFILE_DYNAMIC && rawParams->load (profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename (profPath, Glib::path_get_basename (options.defProfRaw) + paramFileExtension)))) { std::cerr << "Error: default raw processing profile not found" << std::endl; rawParams->deleteInstance(); delete rawParams; - deleteProcParams(processingParams); + deleteProcParams (processingParams); return -3; } - imgParams = new rtengine::procparams::PartialProfile(true); - profPath = options.findProfilePath(options.defProfImg); + imgParams = new rtengine::procparams::PartialProfile (true); + profPath = options.findProfilePath (options.defProfImg); - if (options.is_defProfImgMissing() || profPath.empty() || (profPath != DEFPROFILE_DYNAMIC && imgParams->load(profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename(profPath, Glib::path_get_basename(options.defProfImg) + paramFileExtension)))) { + if (options.is_defProfImgMissing() || profPath.empty() || (profPath != DEFPROFILE_DYNAMIC && imgParams->load (profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename (profPath, Glib::path_get_basename (options.defProfImg) + paramFileExtension)))) { std::cerr << "Error: default non-raw processing profile not found" << std::endl; imgParams->deleteInstance(); delete imgParams; rawParams->deleteInstance(); delete rawParams; - deleteProcParams(processingParams); + deleteProcParams (processingParams); return -3; } } - for( size_t iFile = 0; iFile < inputFiles.size(); iFile++) { + for ( size_t iFile = 0; iFile < inputFiles.size(); iFile++) { // Has to be reinstanciated at each profile to have a ProcParams object with default values rtengine::procparams::ProcParams currentParams; @@ -688,34 +700,34 @@ int processLineParams( int argc, char **argv ) Glib::ustring outputFile; - if( outputType.empty() ) { + if ( outputType.empty() ) { outputType = "jpg"; } - if( outputPath.empty() ) { + if ( outputPath.empty() ) { Glib::ustring s = inputFile; - Glib::ustring::size_type ext = s.find_last_of('.'); - outputFile = s.substr(0, ext) + "." + outputType; - } else if( outputDirectory ) { - Glib::ustring s = Glib::path_get_basename( inputFile ); - Glib::ustring::size_type ext = s.find_last_of('.'); - outputFile = Glib::build_filename(outputPath, s.substr(0, ext) + "." + outputType); + Glib::ustring::size_type ext = s.find_last_of ('.'); + outputFile = s.substr (0, ext) + "." + outputType; + } else if ( outputDirectory ) { + Glib::ustring s = Glib::path_get_basename ( inputFile ); + Glib::ustring::size_type ext = s.find_last_of ('.'); + outputFile = Glib::build_filename (outputPath, s.substr (0, ext) + "." + outputType); } else { if (leaveUntouched) { outputFile = outputPath; } else { Glib::ustring s = outputPath; - Glib::ustring::size_type ext = s.find_last_of('.'); - outputFile = s.substr(0, ext) + "." + outputType; + Glib::ustring::size_type ext = s.find_last_of ('.'); + outputFile = s.substr (0, ext) + "." + outputType; } } - if( inputFile == outputFile) { + if ( inputFile == outputFile) { std::cerr << "Cannot overwrite: " << inputFile << std::endl; continue; } - if( !overwriteFiles && Glib::file_test( outputFile , Glib::FILE_TEST_EXISTS ) ) { + if ( !overwriteFiles && Glib::file_test ( outputFile, Glib::FILE_TEST_EXISTS ) ) { std::cerr << outputFile << " already exists: use -Y option to overwrite. This image has been skipped." << std::endl; continue; } @@ -741,18 +753,20 @@ int processLineParams( int argc, char **argv ) if (options.defProfRaw == DEFPROFILE_DYNAMIC) { rawParams->deleteInstance(); delete rawParams; - rawParams = ProfileStore::getInstance()->loadDynamicProfile(ii->getMetaData()); + rawParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData()); } + std::cout << " Merging default raw processing profile" << std::endl; - rawParams->applyTo(¤tParams); - } else { + rawParams->applyTo (¤tParams); + } else { if (options.defProfImg == DEFPROFILE_DYNAMIC) { imgParams->deleteInstance(); delete imgParams; - imgParams = ProfileStore::getInstance()->loadDynamicProfile(ii->getMetaData()); + imgParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData()); } + std::cout << " Merging default non-raw processing profile" << std::endl; - imgParams->applyTo(¤tParams); + imgParams->applyTo (¤tParams); } } @@ -766,7 +780,7 @@ int processLineParams( int argc, char **argv ) Glib::ustring sideProcessingParams = inputFile + paramFileExtension; // the "load" method don't reset the procparams values anymore, so values found in the procparam file override the one of currentParams - if( !Glib::file_test( sideProcessingParams, Glib::FILE_TEST_EXISTS ) || currentParams.load ( sideProcessingParams )) { + if ( !Glib::file_test ( sideProcessingParams, Glib::FILE_TEST_EXISTS ) || currentParams.load ( sideProcessingParams )) { std::cerr << "Warning: sidecar file requested but not found for: " << sideProcessingParams << std::endl; } else { sideCarFound = true; @@ -774,15 +788,15 @@ int processLineParams( int argc, char **argv ) } } - if( processingParams.size() > i ) { + if ( processingParams.size() > i ) { std::cout << " Merging procparams #" << i << std::endl; - processingParams[i]->applyTo(¤tParams); + processingParams[i]->applyTo (¤tParams); } i++; } while (i < processingParams.size() + (sideProcParams ? 1 : 0)); - if( sideProcParams && !sideCarFound && skipIfNoSidecar ) { + if ( sideProcParams && !sideCarFound && skipIfNoSidecar ) { delete ii; errors++; std::cerr << "Error: no sidecar procparams found for: " << inputFile << std::endl; @@ -791,7 +805,7 @@ int processLineParams( int argc, char **argv ) job = rtengine::ProcessingJob::create (ii, currentParams, fast_export); - if( !job ) { + if ( !job ) { errors++; std::cerr << "Error creating processing for: " << inputFile << std::endl; ii->decreaseRef(); @@ -801,31 +815,31 @@ int processLineParams( int argc, char **argv ) // Process image rtengine::IImage16* resultImage = rtengine::processImage (job, errorCode, nullptr, options.tunnelMetaData); - if( !resultImage ) { + if ( !resultImage ) { errors++; std::cerr << "Error processing: " << inputFile << std::endl; - rtengine::ProcessingJob::destroy( job ); + rtengine::ProcessingJob::destroy ( job ); continue; } // save image to disk - if( outputType == "jpg" ) { - errorCode = resultImage->saveAsJPEG( outputFile, compression, subsampling ); - } else if( outputType == "tif" ) { - errorCode = resultImage->saveAsTIFF( outputFile, bits, compression == 0 ); - } else if( outputType == "png" ) { - errorCode = resultImage->saveAsPNG( outputFile, compression, bits ); + if ( outputType == "jpg" ) { + errorCode = resultImage->saveAsJPEG ( outputFile, compression, subsampling ); + } else if ( outputType == "tif" ) { + errorCode = resultImage->saveAsTIFF ( outputFile, bits, compression == 0 ); + } else if ( outputType == "png" ) { + errorCode = resultImage->saveAsPNG ( outputFile, compression, bits ); } else { errorCode = resultImage->saveToFile (outputFile); } - if(errorCode) { + if (errorCode) { errors++; std::cerr << "Error saving to: " << outputFile << std::endl; } else { - if( copyParamsFile ) { + if ( copyParamsFile ) { Glib::ustring outputProcessingParams = outputFile + paramFileExtension; - currentParams.save( outputProcessingParams ); + currentParams.save ( outputProcessingParams ); } } @@ -843,7 +857,7 @@ int processLineParams( int argc, char **argv ) delete rawParams; } - deleteProcParams(processingParams); + deleteProcParams (processingParams); return errors > 0 ? -2 : 0; } diff --git a/rtgui/main.cc b/rtgui/main.cc index 455749fdd..f133c1e07 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -118,83 +118,89 @@ static void myGdkLockLeave() * -1 if there is an error in parameters * -2 if an error occurred during processing * -3 if at least one required procparam file was not found */ -int processLineParams( int argc, char **argv ) +int processLineParams ( int argc, char **argv ) { - for( int iArg = 1; iArg < argc; iArg++) { - Glib::ustring currParam(argv[iArg]); + for ( int iArg = 1; iArg < argc; iArg++) { + Glib::ustring currParam (argv[iArg]); #if ECLIPSE_ARGS - currParam = currParam.substr(1, currParam.length()-2); + currParam = currParam.substr (1, currParam.length() - 2); #endif - if( currParam.at(0) == '-' ) { - switch( currParam.at(1) ) { + + if ( currParam.at (0) == '-' ) { + switch ( currParam.at (1) ) { #ifdef WIN32 - case 'w': // This case is handled outside this function - break; + case 'w': // This case is handled outside this function + break; #endif - case 'v': - return 0; + + case 'v': + return 0; #ifndef __APPLE__ // TODO agriggio - there seems to be already some "single instance app" support for OSX in rtwindow. Disabling it here until I understand how to merge the two - case 'R': - if (!gimpPlugin) { - remote = true; - } - break; -#endif - - case 'g': - if (currParam == "-gimp") { - gimpPlugin = true; - simpleEditor = true; - remote = false; + + case 'R': + if (!gimpPlugin) { + remote = true; + } + break; - } +#endif + + case 'g': + if (currParam == "-gimp") { + gimpPlugin = true; + simpleEditor = true; + remote = false; + break; + } + // no break here on purpose - case 'h': - case '?': - default: { - Glib::ustring pparamsExt = paramFileExtension.substr(1); - std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; - std::cout << std::endl; - std::cout << " Website: http://www.rawtherapee.com/" << std::endl; - std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; - std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; - std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; - std::cout << std::endl; - std::cout << "Symbols:" << std::endl; - std::cout << " indicate parameters you can change." << std::endl; - //std::cout << " [Square brackets] mean the parameter is optional." << std::endl; - //std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; - //std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; - std::cout << std::endl; - std::cout << "Usage:" << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " Start File Browser inside folder." << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " Start Image Editor with file." << std::endl; - std::cout << std::endl; - std::cout << "Options:" << std::endl; + case 'h': + case '?': + default: { + Glib::ustring pparamsExt = paramFileExtension.substr (1); + std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; + std::cout << std::endl; + std::cout << " Website: http://www.rawtherapee.com/" << std::endl; + std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; + std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; + std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; + std::cout << std::endl; + std::cout << "Symbols:" << std::endl; + std::cout << " indicate parameters you can change." << std::endl; + //std::cout << " [Square brackets] mean the parameter is optional." << std::endl; + //std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; + //std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; + std::cout << std::endl; + std::cout << "Usage:" << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " Start File Browser inside folder." << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " Start Image Editor with file." << std::endl; + std::cout << std::endl; + std::cout << "Options:" << std::endl; #ifdef WIN32 - std::cout << " -w Do not open the Windows console" << std::endl; + std::cout << " -w Do not open the Windows console" << std::endl; #endif - std::cout << " -v Print RawTherapee version number and exit" << std::endl; + std::cout << " -v Print RawTherapee version number and exit" << std::endl; #ifndef __APPLE__ - std::cout << " -R Raise an already running RawTherapee instance (if available)" << std::endl; + std::cout << " -R Raise an already running RawTherapee instance (if available)" << std::endl; #endif - std::cout << " -h -? Display this help message" << std::endl; - return -1; - } + std::cout << " -h -? Display this help message" << std::endl; + return -1; + } } } else { if (argv1.empty()) { - argv1 = Glib::ustring(fname_to_utf8(argv[iArg])); + argv1 = Glib::ustring (fname_to_utf8 (argv[iArg])); #if ECLIPSE_ARGS - argv1 = argv1.substr(1, argv1.length()-2); + argv1 = argv1.substr (1, argv1.length() - 2); #endif } else if (gimpPlugin) { - argv2 = Glib::ustring(fname_to_utf8(argv[iArg])); + argv2 = Glib::ustring (fname_to_utf8 (argv[iArg])); break; } + if (!gimpPlugin) { break; } @@ -207,22 +213,25 @@ int processLineParams( int argc, char **argv ) bool init_rt() { - if (!Options::load ()) { + try { + Options::load(); + } catch (Options::Error &e) { + std::cout << "ERROR: " << e.get_msg() << std::endl; return false; } extProgStore->init(); SoundManager::init(); - if( !options.rtSettings.verbose ) { - TIFFSetWarningHandler(nullptr); // avoid annoying message boxes + if ( !options.rtSettings.verbose ) { + TIFFSetWarningHandler (nullptr); // avoid annoying message boxes } #ifndef WIN32 // Move the old path to the new one if the new does not exist - if (Glib::file_test(Glib::build_filename(options.rtdir, "cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test(options.cacheBaseDir, Glib::FILE_TEST_IS_DIR)) { - g_rename(Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); + if (Glib::file_test (Glib::build_filename (options.rtdir, "cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test (options.cacheBaseDir, Glib::FILE_TEST_IS_DIR)) { + g_rename (Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); } #endif @@ -239,11 +248,11 @@ void cleanup_rt() RTWindow *create_rt_window() { - Glib::ustring icon_path = Glib::build_filename(argv0, "images"); + Glib::ustring icon_path = Glib::build_filename (argv0, "images"); Glib::RefPtr defaultIconTheme = Gtk::IconTheme::get_default(); - defaultIconTheme->append_search_path(icon_path); + defaultIconTheme->append_search_path (icon_path); - rtengine::setPaths(options); + rtengine::setPaths (options); MyExpander::init(); // has to stay AFTER rtengine::setPaths // ------- loading theme files @@ -251,8 +260,8 @@ RTWindow *create_rt_window() Glib::RefPtr screen = Gdk::Screen::get_default(); if (screen) { - Gtk::Settings::get_for_screen(screen)->property_gtk_theme_name() = "Adwaita"; - Gtk::Settings::get_for_screen(screen)->property_gtk_application_prefer_dark_theme() = true; + Gtk::Settings::get_for_screen (screen)->property_gtk_theme_name() = "Adwaita"; + Gtk::Settings::get_for_screen (screen)->property_gtk_application_prefer_dark_theme() = true; #if defined(__APPLE__) // This will force screen resolution regarding font, but I don't think it's compliant with Gtk guidelines... @@ -260,27 +269,52 @@ RTWindow *create_rt_window() screen->set_resolution (96.); #endif - Glib::RefPtr regex = Glib::Regex::create(THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); - Glib::ustring filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); - if (!regex->match(options.theme + ".css") || !Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { + Glib::RefPtr regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); + Glib::ustring filename; + Glib::MatchInfo mInfo; + bool match = regex->match(options.theme + ".css", mInfo); + if (match) { + // save old theme (name + version) + Glib::ustring initialTheme(options.theme); + + // update version + auto pos = options.theme.find("-GTK3-"); + Glib::ustring themeRootName(options.theme.substr(0, pos)); + if (GTK_MINOR_VERSION < 20) { + options.theme = themeRootName + "-GTK3-_19"; + } else { + options.theme = themeRootName + "-GTK3-20_"; + } + // check if this version exist + if (!Glib::file_test(Glib::build_filename(argv0, "themes", options.theme + ".css"), Glib::FILE_TEST_EXISTS)) { + // set back old theme version if the actual one doesn't exist yet + options.theme = initialTheme; + } + } + filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); + + if (!match || !Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { options.theme = "RawTherapee-GTK"; + // We're not testing GTK_MAJOR_VERSION == 3 here, since this branch requires Gtk3 only if (GTK_MINOR_VERSION < 20) { options.theme = options.theme + "3-_19"; } else { options.theme = options.theme + "3-20_"; } - filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); + + filename = Glib::build_filename (argv0, "themes", options.theme + ".css"); } + cssRT = Gtk::CssProvider::create(); try { cssRT->load_from_path (filename); - Gtk::StyleContext::add_provider_for_screen(screen, cssRT, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk::StyleContext::add_provider_for_screen (screen, cssRT, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Glib::Error &err) { - printf("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str()); + printf ("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str()); } catch (...) { - printf("Error: Can't load css file \"%s\"\n", filename.c_str()); + printf ("Error: Can't load css file \"%s\"\n", filename.c_str()); } // Set the font face and size @@ -289,23 +323,23 @@ RTWindow *create_rt_window() cssForced = Gtk::CssProvider::create(); //GTK318 #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 - cssForced->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize)); + cssForced->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize)); #else - cssForced->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize)); + cssForced->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize)); #endif //GTK318 - Gtk::StyleContext::add_provider_for_screen(screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk::StyleContext::add_provider_for_screen (screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Glib::Error &err) { - printf("Error: \"%s\"\n", err.what().c_str()); + printf ("Error: \"%s\"\n", err.what().c_str()); } catch (...) { - printf("Error: Can't find the font named \"%s\"\n", options.fontFamily.c_str()); + printf ("Error: Can't find the font named \"%s\"\n", options.fontFamily.c_str()); } } } #ifndef NDEBUG else if (!screen) { - printf("ERROR: Can't get default screen!\n"); + printf ("ERROR: Can't get default screen!\n"); } #endif @@ -317,12 +351,12 @@ RTWindow *create_rt_window() // alerting users if the default raw and image profiles are missing if (options.is_defProfRawMissing()) { - Gtk::MessageDialog msgd (Glib::ustring::compose(M("OPTIONS_DEFRAW_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (Glib::ustring::compose (M ("OPTIONS_DEFRAW_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } if (options.is_defProfImgMissing()) { - Gtk::MessageDialog msgd (Glib::ustring::compose(M("OPTIONS_DEFIMG_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (Glib::ustring::compose (M ("OPTIONS_DEFIMG_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } @@ -330,12 +364,13 @@ RTWindow *create_rt_window() } -class RTApplication: public Gtk::Application { +class RTApplication: public Gtk::Application +{ public: RTApplication(): - Gtk::Application("com.rawtherapee.application", - Gio::APPLICATION_HANDLES_OPEN), - rtWindow(nullptr) + Gtk::Application ("com.rawtherapee.application", + Gio::APPLICATION_HANDLES_OPEN), + rtWindow (nullptr) { } @@ -344,6 +379,7 @@ public: if (rtWindow) { delete rtWindow; } + cleanup_rt(); } @@ -353,19 +389,19 @@ private: if (rtWindow) { return true; } - + if (!init_rt()) { Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - add_window(msgd); + add_window (msgd); msgd.run (); return false; } else { rtWindow = create_rt_window(); - add_window(*rtWindow); + add_window (*rtWindow); return true; } } - + // Override default signal handlers: void on_activate() override { @@ -373,9 +409,9 @@ private: rtWindow->present(); } } - - void on_open(const Gio::Application::type_vec_files& files, - const Glib::ustring& hint) override + + void on_open (const Gio::Application::type_vec_files& files, + const Glib::ustring& hint) override { if (create_window()) { struct Data { @@ -385,29 +421,30 @@ private: }; Data *d = new Data; d->filecatalog = rtWindow->fpanel->fileCatalog; - + for (const auto &f : files) { - Thumbnail *thm = cacheMgr->getEntry(f->get_path()); + Thumbnail *thm = cacheMgr->getEntry (f->get_path()); + if (thm) { - d->entries.push_back(thm); + d->entries.push_back (thm); d->lastfilename = f->get_path(); } } - + if (!d->entries.empty()) { const auto doit = - [](gpointer data) -> gboolean - { - Data *d = static_cast(data); - d->filecatalog->openRequested(d->entries); - d->filecatalog->selectImage(d->lastfilename, true); - delete d; - return FALSE; - }; - gdk_threads_add_idle(doit, d); + [] (gpointer data) -> gboolean { + Data *d = static_cast (data); + d->filecatalog->openRequested (d->entries); + d->filecatalog->selectImage (d->lastfilename, true); + delete d; + return FALSE; + }; + gdk_threads_add_idle (doit, d); } else { delete d; } + rtWindow->present(); } } @@ -432,10 +469,10 @@ void show_gimp_plugin_info_dialog(Gtk::Window *parent) } // namespace -int main(int argc, char **argv) +int main (int argc, char **argv) { - setlocale(LC_ALL, ""); - setlocale(LC_NUMERIC, "C"); // to set decimal point to "." + setlocale (LC_ALL, ""); + setlocale (LC_NUMERIC, "C"); // to set decimal point to "." simpleEditor = false; gimpPlugin = false; @@ -445,7 +482,7 @@ int main(int argc, char **argv) argv2 = ""; Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now - gdk_threads_set_lock_functions(G_CALLBACK(myGdkLockEnter), (G_CALLBACK(myGdkLockLeave))); + gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave))); gdk_threads_init(); gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal Gio::init (); @@ -458,33 +495,33 @@ int main(int argc, char **argv) #ifdef WIN32 WCHAR exnameU[512] = {0}; GetModuleFileNameW (NULL, exnameU, 511); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); + WideCharToMultiByte (CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 511) < 0) { - strncpy(exname, argv[0], 511); + if (readlink ("/proc/self/exe", exname, 511) < 0) { + strncpy (exname, argv[0], 511); } #endif - exePath = Glib::path_get_dirname(exname); + exePath = Glib::path_get_dirname (exname); // set paths - if (Glib::path_is_absolute(DATA_SEARCH_PATH)) { + if (Glib::path_is_absolute (DATA_SEARCH_PATH)) { argv0 = DATA_SEARCH_PATH; } else { - argv0 = Glib::build_filename(exePath, DATA_SEARCH_PATH); + argv0 = Glib::build_filename (exePath, DATA_SEARCH_PATH); } - if (Glib::path_is_absolute(CREDITS_SEARCH_PATH)) { + if (Glib::path_is_absolute (CREDITS_SEARCH_PATH)) { creditsPath = CREDITS_SEARCH_PATH; } else { - creditsPath = Glib::build_filename(exePath, CREDITS_SEARCH_PATH); + creditsPath = Glib::build_filename (exePath, CREDITS_SEARCH_PATH); } - if (Glib::path_is_absolute(LICENCE_SEARCH_PATH)) { + if (Glib::path_is_absolute (LICENCE_SEARCH_PATH)) { licensePath = LICENCE_SEARCH_PATH; } else { - licensePath = Glib::build_filename(exePath, LICENCE_SEARCH_PATH); + licensePath = Glib::build_filename (exePath, LICENCE_SEARCH_PATH); } #else @@ -492,60 +529,61 @@ int main(int argc, char **argv) creditsPath = CREDITS_SEARCH_PATH; licensePath = LICENCE_SEARCH_PATH; #endif - - + + #ifdef WIN32 bool consoleOpened = false; // suppression of annoying error boxes - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + + if (argc > 1) { + int ret = processLineParams ( argc, argv); - if(argc > 1) { - int ret = processLineParams( argc, argv); if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR))) { - bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001); - bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001); + bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001); + bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001); // no console, if stdout and stderr both are redirected to file - if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) { + if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) { // check if parameter -w was passed. // We have to do that in this step, because it controls whether to open a console to show the output of following steps bool Console = true; - for(int i = 1; i < argc; i++) - if(!strcmp(argv[i], "-w")) { + for (int i = 1; i < argc; i++) + if (!strcmp (argv[i], "-w")) { Console = false; break; } - if(Console && AllocConsole()) { - AttachConsole( GetCurrentProcessId() ) ; + if (Console && AllocConsole()) { + AttachConsole ( GetCurrentProcessId() ) ; // Don't allow CTRL-C in console to terminate RT - SetConsoleCtrlHandler( NULL, true ); + SetConsoleCtrlHandler ( NULL, true ); // Set title of console char consoletitle[128]; - sprintf(consoletitle, "RawTherapee %s Console", RTVERSION); - SetConsoleTitle(consoletitle); + sprintf (consoletitle, "RawTherapee %s Console", RTVERSION); + SetConsoleTitle (consoletitle); // increase size of screen buffer COORD c; c.X = 200; c.Y = 1000; - SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c ); + SetConsoleScreenBufferSize ( GetStdHandle ( STD_OUTPUT_HANDLE ), c ); // Disable console-Cursor CONSOLE_CURSOR_INFO cursorInfo; cursorInfo.dwSize = 100; cursorInfo.bVisible = false; - SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo ); + SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); - if(!stdoutRedirectedtoFile) { - freopen( "CON", "w", stdout ) ; + if (!stdoutRedirectedtoFile) { + freopen ( "CON", "w", stdout ) ; } - if(!stderrRedirectedtoFile) { - freopen( "CON", "w", stderr ) ; + if (!stderrRedirectedtoFile) { + freopen ( "CON", "w", stderr ) ; } - freopen( "CON", "r", stdin ) ; + freopen ( "CON", "r", stdin ) ; consoleOpened = true; @@ -556,10 +594,10 @@ int main(int argc, char **argv) } } - if( ret <= 0 ) { - if(consoleOpened) { - printf("Press any key to exit RawTherapee\n"); - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); + if ( ret <= 0 ) { + if (consoleOpened) { + printf ("Press any key to exit RawTherapee\n"); + FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); getch(); } @@ -577,9 +615,9 @@ int main(int argc, char **argv) #endif if (argc > 1) { - int ret = processLineParams( argc, argv); + int ret = processLineParams ( argc, argv); - if( ret <= 0 ) { + if ( ret <= 0 ) { return ret; } } @@ -588,54 +626,59 @@ int main(int argc, char **argv) #endif if (gimpPlugin) { - if (!Glib::file_test(argv1, Glib::FILE_TEST_EXISTS) || Glib::file_test(argv1, Glib::FILE_TEST_IS_DIR)) { - printf("Error: argv1 doesn't exist\n"); + if (!Glib::file_test (argv1, Glib::FILE_TEST_EXISTS) || Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR)) { + printf ("Error: argv1 doesn't exist\n"); return 1; } + if (argv2.empty()) { - printf("Error: -gimp requires two arguments\n"); + printf ("Error: -gimp requires two arguments\n"); return 1; } - } else if (!remote && Glib::file_test(argv1, Glib::FILE_TEST_EXISTS)) { + } else if (!remote && Glib::file_test (argv1, Glib::FILE_TEST_EXISTS)) { simpleEditor = true; } int ret = 0; + if (remote) { - char *app_argv[2] = { const_cast(argv0.c_str()) }; + char *app_argv[2] = { const_cast (argv0.c_str()) }; int app_argc = 1; + if (!argv1.empty()) { app_argc = 2; - app_argv[1] = const_cast(argv1.c_str()); + app_argv[1] = const_cast (argv1.c_str()); } + RTApplication app; - ret = app.run(app_argc, app_argv); + ret = app.run (app_argc, app_argv); } else { if (init_rt()) { - Gtk::Main m(&argc, &argv); + Gtk::Main m (&argc, &argv); gdk_threads_enter(); - const std::unique_ptr rtWindow(create_rt_window()); + const std::unique_ptr rtWindow (create_rt_window()); if (gimpPlugin) { show_gimp_plugin_info_dialog(rtWindow.get()); } - m.run(*rtWindow); + m.run (*rtWindow); gdk_threads_leave(); if (gimpPlugin && - rtWindow->epanel && rtWindow->epanel->isRealized()) { + rtWindow->epanel && rtWindow->epanel->isRealized()) { SaveFormat sf; sf.format = "tif"; sf.tiffBits = 16; sf.tiffUncompressed = true; sf.saveParams = true; - - if (!rtWindow->epanel->saveImmediately(argv2, sf)) { + + if (!rtWindow->epanel->saveImmediately (argv2, sf)) { ret = -2; } } + cleanup_rt(); } else { - Gtk::Main m(&argc, &argv); + Gtk::Main m (&argc, &argv); Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); ret = -2; @@ -645,8 +688,8 @@ int main(int argc, char **argv) #ifdef WIN32 if (consoleOpened) { - printf("Press any key to exit RawTherapee\n"); - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); + printf ("Press any key to exit RawTherapee\n"); + FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); getch(); } diff --git a/rtgui/options.cc b/rtgui/options.cc index 7293a3a63..2b504a2de 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -405,6 +405,7 @@ void Options::setDefaults () editorToSendTo = 1; favoriteDirs.clear(); tpOpen.clear (); + autoSaveTpOpen = true; //crvOpen.clear (); parseExtensions.clear (); parseExtensionsEnabled.clear (); @@ -642,7 +643,7 @@ void Options::setDefaults () #endif // rtSettings.viewingdevice = 0; // rtSettings.viewingdevicegrey = 3; - // rtSettings.viewinggreySc = 1; + // rtSettings.viewinggreySc = 1; rtSettings.leveldnv = 2; rtSettings.leveldnti = 0; rtSettings.leveldnaut = 0; @@ -744,14 +745,15 @@ void Options::filterOutParsedExtensions () } } -int Options::readFromFile (Glib::ustring fname) +void Options::readFromFile (Glib::ustring fname) { setlocale (LC_NUMERIC, "C"); // to set decimal point to "." Glib::KeyFile keyFile; if ( !Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) { - return 1; + Glib::ustring msg = Glib::ustring::compose ("Options file %1 does not exist", fname); + throw Error (msg); } try { @@ -1435,6 +1437,10 @@ int Options::readFromFile (Glib::ustring fname) tpOpen = keyFile.get_integer_list ("GUI", "ToolPanelsExpanded"); } + if (keyFile.has_key ("GUI", "ToolPanelsExpandedAutoSave")) { + autoSaveTpOpen = keyFile.get_boolean ("GUI", "ToolPanelsExpandedAutoSave"); + } + if (keyFile.has_key ("GUI", "MultiDisplayMode")) { multiDisplayMode = keyFile.get_integer ("GUI", "MultiDisplayMode"); } @@ -1557,11 +1563,11 @@ int Options::readFromFile (Glib::ustring fname) rtSettings.viewingdevicegrey = keyFile.get_integer ("Color Management", "grey"); } */ -/* - if (keyFile.has_key ("Color Management", "greySc")) { - rtSettings.viewinggreySc = keyFile.get_integer ("Color Management", "greySc"); - } -*/ + /* + if (keyFile.has_key ("Color Management", "greySc")) { + rtSettings.viewinggreySc = keyFile.get_integer ("Color Management", "greySc"); + } + */ if (keyFile.has_key ("Color Management", "CBDLArtif")) { rtSettings.artifact_cbdl = keyFile.get_double ("Color Management", "CBDLArtif"); } @@ -1866,21 +1872,26 @@ int Options::readFromFile (Glib::ustring fname) filterOutParsedExtensions (); - return 0; + return; } } catch (Glib::Error &err) { + Glib::ustring msg = Glib::ustring::compose ("Options::readFromFile / Error code %1 while reading values from \"%2\":\n%3", err.code(), fname, err.what()); + if (options.rtSettings.verbose) { - printf ("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str()); + printf ("%s\n", msg.c_str()); } + + throw Error (msg); } catch (...) { + Glib::ustring msg = Glib::ustring::compose ("Options::readFromFile / Unknown exception while trying to load \"%1\"!", fname); + if (options.rtSettings.verbose) { - printf ("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str()); + printf ("%s\n", msg.c_str()); } + + throw Error (msg); } - - return 1; - } bool Options::safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& section, @@ -1898,7 +1909,7 @@ bool Options::safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& sec return false; } -int Options::saveToFile (Glib::ustring fname) +void Options::saveToFile (Glib::ustring fname) { Glib::ustring keyData; @@ -2100,6 +2111,7 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_boolean ("GUI", "ProcessingQueueEnbled", procQueueEnabled); Glib::ArrayHandle tpopen = tpOpen; keyFile.set_integer_list ("GUI", "ToolPanelsExpanded", tpopen); + keyFile.set_boolean ("GUI", "ToolPanelsExpandedAutoSave", autoSaveTpOpen); keyFile.set_integer ("GUI", "MultiDisplayMode", multiDisplayMode); keyFile.set_double_list ("GUI", "CutOverlayBrush", cutOverlayBrush); keyFile.set_double_list ("GUI", "NavGuideBrush", navGuideBrush); @@ -2229,31 +2241,23 @@ int Options::saveToFile (Glib::ustring fname) keyData = keyFile.to_data (); - } catch (Glib::KeyFileError&) {} - - if (keyData.empty ()) { - return 1; + } catch (Glib::KeyFileError &e) { + throw Error (e.what()); } FILE *f = g_fopen (fname.c_str (), "wt"); if (f == nullptr) { std::cout << "Warning! Unable to save your preferences to: " << fname << std::endl; -#ifndef RAWTHERAPEE_CLI Glib::ustring msg_ = Glib::ustring::compose (M ("MAIN_MSG_WRITEFAILED"), fname.c_str()); - //writeFailed (getToplevelWindow (this), msg_); - Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true); - msgd.run (); -#endif - return 1; + throw Error (msg_); } else { fprintf (f, "%s", keyData.c_str ()); fclose (f); - return 0; } } -bool Options::load (bool lightweight) +void Options::load (bool lightweight) { // Find the application data path @@ -2267,7 +2271,8 @@ bool Options::load (bool lightweight) rtdir = Glib::ustring (path); if (!Glib::path_is_absolute (rtdir)) { - return false; + Glib::ustring msg = Glib::ustring::compose ("Settings path %1 is not absolute", rtdir); + throw Error (msg); } } else { #ifdef WIN32 @@ -2292,7 +2297,11 @@ bool Options::load (bool lightweight) cacheBaseDir = Glib::build_filename (argv0, "cache"); // Read the global option file (the one located in the application's base folder) - options.readFromFile (Glib::build_filename (argv0, "options")); + try { + options.readFromFile (Glib::build_filename (argv0, "options")); + } catch (Options::Error &) { + // ignore errors here + } // Modify the path of the cache folder to the one provided in RT_CACHE environment variable path = g_getenv ("RT_CACHE"); @@ -2301,7 +2310,8 @@ bool Options::load (bool lightweight) cacheBaseDir = Glib::ustring (path); if (!Glib::path_is_absolute (cacheBaseDir)) { - return false; + Glib::ustring msg = Glib::ustring::compose ("Cache base dir %1 is not absolute", cacheBaseDir); + throw Error (msg); } } // No environment variable provided, so falling back to the multi user mode, is enabled @@ -2317,12 +2327,14 @@ bool Options::load (bool lightweight) if (options.multiUser) { // Read the user option file (the one located somewhere in the user's home folder) // Those values supersets those of the global option file - int r = options.readFromFile (Glib::build_filename (rtdir, "options")); - - // If the local option file does not exist or is broken, and the local cache folder does not exist, recreate it - if (r && !g_mkdir_with_parents (rtdir.c_str (), 511)) { - // Save the option file - options.saveToFile (Glib::build_filename (rtdir, "options")); + try { + options.readFromFile (Glib::build_filename (rtdir, "options")); + } catch (Options::Error &) { + // If the local option file does not exist or is broken, and the local cache folder does not exist, recreate it + if (!g_mkdir_with_parents (rtdir.c_str (), 511)) { + // Save the option file + options.saveToFile (Glib::build_filename (rtdir, "options")); + } } #ifdef __APPLE__ @@ -2415,8 +2427,6 @@ bool Options::load (bool lightweight) langMgr.load (localeTranslation, new MultiLangMgr (languageTranslation, new MultiLangMgr (defaultTranslation))); rtengine::init (&options.rtSettings, argv0, rtdir, !lightweight); - - return true; } void Options::save () diff --git a/rtgui/options.h b/rtgui/options.h index 13025ee7c..291a45d47 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -21,6 +21,7 @@ #include #include "../rtengine/rtengine.h" +#include #define STARTUPDIR_CURRENT 0 #define STARTUPDIR_HOME 1 @@ -42,17 +43,16 @@ // Special name for the Dynamic profile #define DEFPROFILE_DYNAMIC "Dynamic" -struct SaveFormat -{ +struct SaveFormat { SaveFormat() : - format("jpg"), - pngBits(8), - pngCompression(6), - jpegQuality(90), - jpegSubSamp(2), - tiffBits(8), - tiffUncompressed(true), - saveParams(true) + format ("jpg"), + pngBits (8), + pngCompression (6), + jpegQuality (90), + jpegSubSamp (2), + tiffBits (8), + tiffUncompressed (true), + saveParams (true) { } @@ -73,14 +73,31 @@ enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0}; class Options { +public: + class Error: public std::exception + { + public: + Error (const Glib::ustring &msg): msg_ (msg) {} + const char *what() const throw() + { + return msg_.c_str(); + } + const Glib::ustring &get_msg() const throw() + { + return msg_; + } + + private: + Glib::ustring msg_; + }; private: bool defProfRawMissing; bool defProfImgMissing; Glib::ustring userProfilePath; Glib::ustring globalProfilePath; - bool checkProfilePath(Glib::ustring &path); - bool checkDirPath(Glib::ustring &path, Glib::ustring errString); + bool checkProfilePath (Glib::ustring &path); + bool checkDirPath (Glib::ustring &path, Glib::ustring errString); void updatePaths(); int getString (const char* src, char* dst); void error (int line); @@ -95,8 +112,8 @@ private: * @param destination destination variable to store to * @return @c true if @p destination was changed */ - bool safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& section, - const Glib::ustring& entryName, Glib::ustring& destination); + bool safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& section, + const Glib::ustring& entryName, Glib::ustring& destination); public: @@ -206,6 +223,7 @@ public: std::vector parseExtensionsEnabled; // List of bool to retain extension or not std::vector parsedExtensions; // List containing all retained extensions (lowercase) std::vector tpOpen; + bool autoSaveTpOpen; //std::vector crvOpen; std::vector baBehav; rtengine::Settings rtSettings; @@ -326,10 +344,10 @@ public: Options* copyFrom (Options* other); void filterOutParsedExtensions (); void setDefaults (); - int readFromFile (Glib::ustring fname); - int saveToFile (Glib::ustring fname); - static bool load (bool lightweight = false); - static void save (); + void readFromFile (Glib::ustring fname); + void saveToFile (Glib::ustring fname); + static void load (bool lightweight = false); + static void save(); // if multiUser=false, send back the global profile path Glib::ustring getPreferredProfilePath(); @@ -341,10 +359,10 @@ public: { return globalProfilePath; } - Glib::ustring findProfilePath(Glib::ustring &profName); + Glib::ustring findProfilePath (Glib::ustring &profName); bool is_parse_extention (Glib::ustring fname); bool has_retained_extention (Glib::ustring fname); - bool is_extention_enabled(Glib::ustring ext); + bool is_extention_enabled (Glib::ustring ext); bool is_defProfRawMissing() { return defProfRawMissing; @@ -353,11 +371,11 @@ public: { return defProfImgMissing; } - void setDefProfRawMissing(bool value) + void setDefProfRawMissing (bool value) { defProfRawMissing = value; } - void setDefProfImgMissing(bool value) + void setDefProfImgMissing (bool value) { defProfImgMissing = value; } diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index f0f35300f..94b39bd53 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -878,14 +878,14 @@ Gtk::Widget* Preferences::getColorManagementPanel () grey->append (M("PREFERENCES_GREY30")); grey->append (M("PREFERENCES_GREY40")); */ -/* - Gtk::Label* greySclab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_GREYSC") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties (greySclab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - greySc = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties (greySc, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - greySc->append (M ("PREFERENCES_GREYSCA")); - greySc->append (M ("PREFERENCES_GREYSC18")); -*/ + /* + Gtk::Label* greySclab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_GREYSC") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (greySclab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + greySc = Gtk::manage (new Gtk::ComboBoxText ()); + setExpandAlignProperties (greySc, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + greySc->append (M ("PREFERENCES_GREYSCA")); + greySc->append (M ("PREFERENCES_GREYSC18")); + */ Gtk::Frame* fcielab = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CIEART_FRAME")) ); setExpandAlignProperties (fcielab, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); @@ -986,8 +986,20 @@ Gtk::Widget* Preferences::getGeneralPanel () workflowGrid->attach_next_to (*hb4label, *ckbFileBrowserToolbarSingleRow, Gtk::POS_BOTTOM, 1, 1); workflowGrid->attach_next_to (*ckbHideTPVScrollbar, *hb4label, Gtk::POS_RIGHT, 1, 1); workflowGrid->attach_next_to (*ckbUseIconNoText, *ckbHideTPVScrollbar, Gtk::POS_RIGHT, 1, 1); + ckbAutoSaveTpOpen = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_AUTOSAVE_TP_OPEN"))); + workflowGrid->attach_next_to (*ckbAutoSaveTpOpen, *hb4label, Gtk::POS_BOTTOM, 1, 1); + btnSaveTpOpenNow = Gtk::manage (new Gtk::Button (M ("PREFERENCES_SAVE_TP_OPEN_NOW"))); + setExpandAlignProperties (btnSaveTpOpenNow, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + workflowGrid->attach_next_to (*btnSaveTpOpenNow, *ckbAutoSaveTpOpen, Gtk::POS_RIGHT, 1, 1); + + auto save_tp_open_now = + [&]() -> void { + parent->writeToolExpandedStatus (moptions.tpOpen); + }; + btnSaveTpOpenNow->signal_clicked().connect (save_tp_open_now); fworklflow->add (*workflowGrid); + mvbsd->attach_next_to (*fworklflow, Gtk::POS_TOP, 2, 1); // --------------------------------------------- @@ -1792,6 +1804,8 @@ void Preferences::storePreferences () moptions.overwriteOutputFile = chOverwriteOutputFile->get_active (); moptions.UseIconNoText = ckbUseIconNoText->get_active(); + moptions.autoSaveTpOpen = ckbAutoSaveTpOpen->get_active(); + moptions.rgbDenoiseThreadLimit = rgbDenoiseTreadLimitSB->get_value_as_int(); moptions.clutCacheSize = clutCacheSizeSB->get_value_as_int(); moptions.maxInspectorBuffers = maxInspectorBuffersSB->get_value_as_int(); @@ -2009,6 +2023,8 @@ void Preferences::fillPreferences () ckbHideTPVScrollbar->set_active (moptions.hideTPVScrollbar); ckbUseIconNoText->set_active (moptions.UseIconNoText); + ckbAutoSaveTpOpen->set_active (moptions.autoSaveTpOpen); + rgbDenoiseTreadLimitSB->set_value (moptions.rgbDenoiseThreadLimit); clutCacheSizeSB->set_value (moptions.clutCacheSize); maxInspectorBuffersSB->set_value (moptions.maxInspectorBuffers); @@ -2103,7 +2119,14 @@ void Preferences::okPressed () workflowUpdate(); options.copyFrom (&moptions); options.filterOutParsedExtensions(); - Options::save (); + + try { + Options::save (); + } catch (Options::Error &e) { + Gtk::MessageDialog msgd (getToplevelWindow (this), e.get_msg(), true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true); + msgd.run(); + } + dynProfilePanel->save(); hide (); } diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 1a86c64a9..c9659d3dc 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -36,8 +36,8 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::TreeModelColumn ext; ExtensionColumns() { - add(enabled); - add(ext); + add (enabled); + add (ext); } }; ExtensionColumns extensionColumns; @@ -54,11 +54,11 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::TreeModelColumn addsetid; BehavColumns() { - add(label); - add(badd); - add(bset); - add(visible); - add(addsetid); + add (label); + add (badd); + add (bset); + add (visible); + add (addsetid); } }; @@ -68,7 +68,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Glib::ustring shortFName; Glib::ustring longFName; - ThemeFilename (Glib::ustring sfname, Glib::ustring lfname) : shortFName(sfname), longFName(lfname) {} + ThemeFilename (Glib::ustring sfname, Glib::ustring lfname) : shortFName (sfname), longFName (lfname) {} }; Glib::RefPtr behModel; @@ -122,7 +122,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::SpinButton* panFactor; Gtk::CheckButton* rememberZoomPanCheckbutton; - // Gtk::ComboBoxText* view; +// Gtk::ComboBoxText* view; // Gtk::ComboBoxText* grey; // Gtk::ComboBoxText* greySc; Gtk::ComboBoxText* dnv; @@ -201,6 +201,9 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::CheckButton* ckbHideTPVScrollbar; Gtk::CheckButton* ckbUseIconNoText; + Gtk::CheckButton* ckbAutoSaveTpOpen; + Gtk::Button* btnSaveTpOpenNow; + DynamicProfilePanel *dynProfilePanel; Glib::ustring storedValueRaw; @@ -232,9 +235,9 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener void iccDirChanged (); void switchThemeTo (Glib::ustring newTheme); void switchFontTo (const Glib::ustring &newFontFamily, const int newFontSize); - bool splashClosed(GdkEventAny* event); + bool splashClosed (GdkEventAny* event); - int getThemeRowNumber(Glib::ustring& longThemeFName); + int getThemeRowNumber (Glib::ustring& longThemeFName); void appendBehavList (Gtk::TreeModel::iterator& parent, Glib::ustring label, int id, bool set); diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index c51d1b7f0..9af387567 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -32,27 +32,27 @@ static gboolean osx_should_quit_cb (GtkosxApplication *app, gpointer data) { RTWindow *rtWin = (RTWindow *)data; - return rtWin->on_delete_event(0); + return rtWin->on_delete_event (0); } static void osx_will_quit_cb (GtkosxApplication *app, gpointer data) { RTWindow *rtWin = (RTWindow *)data; - rtWin->on_delete_event(0); + rtWin->on_delete_event (0); gtk_main_quit (); } -bool RTWindow::osxFileOpenEvent(Glib::ustring path) +bool RTWindow::osxFileOpenEvent (Glib::ustring path) { CacheManager* cm = CacheManager::getInstance(); - Thumbnail* thm = cm->getEntry( path ); + Thumbnail* thm = cm->getEntry ( path ); - if(thm && fpanel) { + if (thm && fpanel) { std::vector entries; - entries.push_back(thm); - fpanel->fileCatalog->openRequested(entries); + entries.push_back (thm); + fpanel->fileCatalog->openRequested (entries); return true; } @@ -69,25 +69,25 @@ osx_open_file_cb (GtkosxApplication *app, gchar *path_, gpointer data) return false; } - Glib::ustring path = Glib::ustring(path_); - Glib::ustring suffix = path.length() > 4 ? path.substr(path.length() - 3) : ""; + Glib::ustring path = Glib::ustring (path_); + Glib::ustring suffix = path.length() > 4 ? path.substr (path.length() - 3) : ""; suffix = suffix.lowercase(); if (suffix == "pp3") { - path = path.substr(0, path.length() - 4); + path = path.substr (0, path.length() - 4); } - return rtWin->osxFileOpenEvent(path); + return rtWin->osxFileOpenEvent (path); } #endif // __APPLE__ RTWindow::RTWindow () - : mainNB(nullptr) - , bpanel(nullptr) - , splash(nullptr) - , btn_fullscreen(nullptr) - , epanel(nullptr) - , fpanel(nullptr) + : mainNB (nullptr) + , bpanel (nullptr) + , splash (nullptr) + , btn_fullscreen (nullptr) + , epanel (nullptr) + , fpanel (nullptr) { cacheMgr->init (); @@ -95,11 +95,11 @@ RTWindow::RTWindow () ProfilePanel::init (this); Glib::ustring fName = "rt-logo-small.png"; - Glib::ustring fullPath = rtengine::findIconAbsolutePath(fName); + Glib::ustring fullPath = rtengine::findIconAbsolutePath (fName); try { set_default_icon_from_file (fullPath); - } catch(Glib::Exception& ex) { + } catch (Glib::Exception& ex) { printf ("%s\n", ex.what().c_str()); } @@ -122,55 +122,57 @@ RTWindow::RTWindow () #endif versionStr = "RawTherapee " + versionString; - set_title_decorated(""); - set_resizable(true); - set_decorated(true); - set_default_size(options.windowWidth, options.windowHeight); - set_modal(false); + set_title_decorated (""); + set_resizable (true); + set_decorated (true); + set_default_size (options.windowWidth, options.windowHeight); + set_modal (false); Gdk::Rectangle lMonitorRect; - get_screen()->get_monitor_geometry(std::min(options.windowMonitor, Gdk::Screen::get_default()->get_n_monitors() - 1), lMonitorRect); + get_screen()->get_monitor_geometry (std::min (options.windowMonitor, Gdk::Screen::get_default()->get_n_monitors() - 1), lMonitorRect); + if (options.windowMaximized) { - move(lMonitorRect.get_x(), lMonitorRect.get_y()); + move (lMonitorRect.get_x(), lMonitorRect.get_y()); maximize(); } else { unmaximize(); - resize(options.windowWidth, options.windowHeight); - if(options.windowX <= lMonitorRect.get_x() + lMonitorRect.get_width() && options.windowY <= lMonitorRect.get_y() + lMonitorRect.get_height()) { - move(options.windowX, options.windowY); + resize (options.windowWidth, options.windowHeight); + + if (options.windowX <= lMonitorRect.get_x() + lMonitorRect.get_width() && options.windowY <= lMonitorRect.get_y() + lMonitorRect.get_height()) { + move (options.windowX, options.windowY); } else { - move(lMonitorRect.get_x(), lMonitorRect.get_y()); + move (lMonitorRect.get_x(), lMonitorRect.get_y()); } } on_delete_has_run = false; is_fullscreen = false; - property_destroy_with_parent().set_value(false); - signal_window_state_event().connect( sigc::mem_fun(*this, &RTWindow::on_window_state_event) ); - signal_key_press_event().connect( sigc::mem_fun(*this, &RTWindow::keyPressed) ); + property_destroy_with_parent().set_value (false); + signal_window_state_event().connect ( sigc::mem_fun (*this, &RTWindow::on_window_state_event) ); + signal_key_press_event().connect ( sigc::mem_fun (*this, &RTWindow::keyPressed) ); - if(simpleEditor) { - epanel = Gtk::manage( new EditorPanel (nullptr) ); + if (simpleEditor) { + epanel = Gtk::manage ( new EditorPanel (nullptr) ); epanel->setParent (this); - epanel->setParentWindow(this); + epanel->setParentWindow (this); add (*epanel); show_all (); pldBridge = nullptr; // No progress listener CacheManager* cm = CacheManager::getInstance(); - Thumbnail* thm = cm->getEntry( argv1 ); + Thumbnail* thm = cm->getEntry ( argv1 ); - if(thm) { + if (thm) { int error; - rtengine::InitialImage *ii = rtengine::InitialImage::load(argv1, thm->getType() == FT_Raw, &error, nullptr); - epanel->open( thm, ii ); + rtengine::InitialImage *ii = rtengine::InitialImage::load (argv1, thm->getType() == FT_Raw, &error, nullptr); + epanel->open ( thm, ii ); } } else { mainNB = Gtk::manage (new Gtk::Notebook ()); mainNB->set_name ("MainNotebook"); mainNB->set_scrollable (true); - mainNB->signal_switch_page().connect_notify( sigc::mem_fun(*this, &RTWindow::on_mainNB_switch_page) ); + mainNB->signal_switch_page().connect_notify ( sigc::mem_fun (*this, &RTWindow::on_mainNB_switch_page) ); // Editor panel fpanel = new FilePanel () ; @@ -178,20 +180,20 @@ RTWindow::RTWindow () // decorate tab Gtk::Grid* fpanelLabelGrid = Gtk::manage (new Gtk::Grid ()); - setExpandAlignProperties(fpanelLabelGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - Gtk::Label* fpl = Gtk::manage (new Gtk::Label( Glib::ustring(" ") + M("MAIN_FRAME_EDITOR") )); + setExpandAlignProperties (fpanelLabelGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + Gtk::Label* fpl = Gtk::manage (new Gtk::Label ( Glib::ustring (" ") + M ("MAIN_FRAME_EDITOR") )); if (options.mainNBVertical) { mainNB->set_tab_pos (Gtk::POS_LEFT); fpl->set_angle (90); - fpanelLabelGrid->attach_next_to(*Gtk::manage (new RTImage ("gtk-directory.png")), Gtk::POS_TOP, 1, 1); - fpanelLabelGrid->attach_next_to(*fpl, Gtk::POS_TOP, 1, 1); + fpanelLabelGrid->attach_next_to (*Gtk::manage (new RTImage ("gtk-directory.png")), Gtk::POS_TOP, 1, 1); + fpanelLabelGrid->attach_next_to (*fpl, Gtk::POS_TOP, 1, 1); } else { - fpanelLabelGrid->attach_next_to(*Gtk::manage (new RTImage ("gtk-directory.png")), Gtk::POS_RIGHT, 1, 1); - fpanelLabelGrid->attach_next_to(*fpl, Gtk::POS_RIGHT, 1, 1); + fpanelLabelGrid->attach_next_to (*Gtk::manage (new RTImage ("gtk-directory.png")), Gtk::POS_RIGHT, 1, 1); + fpanelLabelGrid->attach_next_to (*fpl, Gtk::POS_RIGHT, 1, 1); } - fpanelLabelGrid->set_tooltip_markup (M("MAIN_FRAME_FILEBROWSER_TOOLTIP")); + fpanelLabelGrid->set_tooltip_markup (M ("MAIN_FRAME_FILEBROWSER_TOOLTIP")); fpanelLabelGrid->show_all (); mainNB->append_page (*fpanel, *fpanelLabelGrid); @@ -200,16 +202,16 @@ RTWindow::RTWindow () bpanel = Gtk::manage ( new BatchQueuePanel (fpanel->fileCatalog) ); // decorate tab, the label is unimportant since its updated in batchqueuepanel anyway - Gtk::Label* lbq = Gtk::manage ( new Gtk::Label (M("MAIN_FRAME_BATCHQUEUE")) ); + Gtk::Label* lbq = Gtk::manage ( new Gtk::Label (M ("MAIN_FRAME_BATCHQUEUE")) ); if (options.mainNBVertical) { - lbq->set_angle(90); + lbq->set_angle (90); } mainNB->append_page (*bpanel, *lbq); - if(isSingleTabMode()) { + if (isSingleTabMode()) { createSetmEditor(); } @@ -225,46 +227,46 @@ RTWindow::RTWindow () //Gtk::LinkButton* rtWeb = Gtk::manage (new Gtk::LinkButton ("http://rawtherapee.com")); // unused... but fail to be linked anyway !? //Gtk::Button* preferences = Gtk::manage (new Gtk::Button (M("MAIN_BUTTON_PREFERENCES")+"...")); Gtk::Button* preferences = Gtk::manage (new Gtk::Button ()); - setExpandAlignProperties(preferences, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - preferences->set_image (*Gtk::manage(new RTImage ("gtk-preferences.png"))); - preferences->set_tooltip_markup (M("MAIN_BUTTON_PREFERENCES")); - preferences->signal_clicked().connect( sigc::mem_fun(*this, &RTWindow::showPreferences) ); + setExpandAlignProperties (preferences, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + preferences->set_image (*Gtk::manage (new RTImage ("gtk-preferences.png"))); + preferences->set_tooltip_markup (M ("MAIN_BUTTON_PREFERENCES")); + preferences->signal_clicked().connect ( sigc::mem_fun (*this, &RTWindow::showPreferences) ); //btn_fullscreen = Gtk::manage( new Gtk::Button(M("MAIN_BUTTON_FULLSCREEN"))); - btn_fullscreen = Gtk::manage( new Gtk::Button()); - setExpandAlignProperties(btn_fullscreen, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - btn_fullscreen->set_tooltip_markup (M("MAIN_BUTTON_FULLSCREEN")); + btn_fullscreen = Gtk::manage ( new Gtk::Button()); + setExpandAlignProperties (btn_fullscreen, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + btn_fullscreen->set_tooltip_markup (M ("MAIN_BUTTON_FULLSCREEN")); btn_fullscreen->set_image (*iFullscreen); - btn_fullscreen->signal_clicked().connect( sigc::mem_fun(*this, &RTWindow::toggle_fullscreen) ); - setExpandAlignProperties(&prProgBar, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - prProgBar.set_show_text(true); + btn_fullscreen->signal_clicked().connect ( sigc::mem_fun (*this, &RTWindow::toggle_fullscreen) ); + setExpandAlignProperties (&prProgBar, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + prProgBar.set_show_text (true); Gtk::Grid* actionGrid = Gtk::manage (new Gtk::Grid ()); - actionGrid->set_row_spacing(2); - actionGrid->set_column_spacing(2); + actionGrid->set_row_spacing (2); + actionGrid->set_column_spacing (2); - setExpandAlignProperties(actionGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + setExpandAlignProperties (actionGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); if (options.mainNBVertical) { - prProgBar.set_orientation(Gtk::ORIENTATION_VERTICAL); - prProgBar.set_inverted(true); - actionGrid->set_orientation(Gtk::ORIENTATION_VERTICAL); - actionGrid->attach_next_to(prProgBar, Gtk::POS_BOTTOM, 1, 1); - actionGrid->attach_next_to(*preferences, Gtk::POS_BOTTOM, 1, 1); - actionGrid->attach_next_to(*btn_fullscreen, Gtk::POS_BOTTOM, 1, 1); - mainNB->set_action_widget(actionGrid, Gtk::PACK_END); + prProgBar.set_orientation (Gtk::ORIENTATION_VERTICAL); + prProgBar.set_inverted (true); + actionGrid->set_orientation (Gtk::ORIENTATION_VERTICAL); + actionGrid->attach_next_to (prProgBar, Gtk::POS_BOTTOM, 1, 1); + actionGrid->attach_next_to (*preferences, Gtk::POS_BOTTOM, 1, 1); + actionGrid->attach_next_to (*btn_fullscreen, Gtk::POS_BOTTOM, 1, 1); + mainNB->set_action_widget (actionGrid, Gtk::PACK_END); } else { - prProgBar.set_orientation(Gtk::ORIENTATION_HORIZONTAL); - actionGrid->set_orientation(Gtk::ORIENTATION_HORIZONTAL); - actionGrid->attach_next_to(prProgBar, Gtk::POS_RIGHT, 1, 1); - actionGrid->attach_next_to(*preferences, Gtk::POS_RIGHT, 1, 1); - actionGrid->attach_next_to(*btn_fullscreen, Gtk::POS_RIGHT, 1, 1); - mainNB->set_action_widget(actionGrid, Gtk::PACK_END); + prProgBar.set_orientation (Gtk::ORIENTATION_HORIZONTAL); + actionGrid->set_orientation (Gtk::ORIENTATION_HORIZONTAL); + actionGrid->attach_next_to (prProgBar, Gtk::POS_RIGHT, 1, 1); + actionGrid->attach_next_to (*preferences, Gtk::POS_RIGHT, 1, 1); + actionGrid->attach_next_to (*btn_fullscreen, Gtk::POS_RIGHT, 1, 1); + mainNB->set_action_widget (actionGrid, Gtk::PACK_END); } actionGrid->show_all(); - pldBridge = new PLDBridge(static_cast(this)); + pldBridge = new PLDBridge (static_cast (this)); add (*mainNB); show_all (); @@ -272,9 +274,10 @@ RTWindow::RTWindow () bpanel->init (this); if (!argv1.empty() && !remote) { - Thumbnail* thm = cacheMgr->getEntry(argv1); + Thumbnail* thm = cacheMgr->getEntry (argv1); + if (thm) { - fpanel->fileCatalog->openRequested({thm}); + fpanel->fileCatalog->openRequested ({thm}); } } } @@ -282,7 +285,7 @@ RTWindow::RTWindow () RTWindow::~RTWindow() { - if(!simpleEditor) { + if (!simpleEditor) { delete pldBridge; } @@ -300,7 +303,7 @@ void RTWindow::on_realize () { Gtk::Window::on_realize (); - if( fpanel ) { + if ( fpanel ) { fpanel->setAspect(); } @@ -308,19 +311,20 @@ void RTWindow::on_realize () epanel->setAspect(); } - mainWindowCursorManager.init(get_window()); + mainWindowCursorManager.init (get_window()); // Display release notes only if new major version. // Pattern matches "5.1" from "5.1-23-g12345678" std::string vs[] = {versionString, options.version}; - std::regex pat("(^[0-9.]+).*"); + std::regex pat ("(^[0-9.]+).*"); std::smatch sm; std::vector vMajor; + for (const auto &v : vs) { - if (std::regex_match(v, sm, pat)) { + if (std::regex_match (v, sm, pat)) { if (sm.size() == 2) { std::ssub_match smsub = sm[1]; - vMajor.push_back(smsub.str()); + vMajor.push_back (smsub.str()); } } } @@ -333,7 +337,7 @@ void RTWindow::on_realize () splash = new Splash (*this); splash->set_transient_for (*this); - splash->signal_delete_event().connect( sigc::mem_fun(*this, &RTWindow::splashClosed) ); + splash->signal_delete_event().connect ( sigc::mem_fun (*this, &RTWindow::splashClosed) ); if (splash->hasReleaseNotes()) { splash->showReleaseNotes(); @@ -346,38 +350,39 @@ void RTWindow::on_realize () } } -bool RTWindow::on_configure_event(GdkEventConfigure* event) +bool RTWindow::on_configure_event (GdkEventConfigure* event) { if (!is_maximized() && is_visible()) { - get_size(options.windowWidth, options.windowHeight); + get_size (options.windowWidth, options.windowHeight); get_position (options.windowX, options.windowY); } - return Gtk::Widget::on_configure_event(event); + return Gtk::Widget::on_configure_event (event); } -bool RTWindow::on_window_state_event(GdkEventWindowState* event) +bool RTWindow::on_window_state_event (GdkEventWindowState* event) { if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) { options.windowMaximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED; } - return Gtk::Widget::on_window_state_event(event); + + return Gtk::Widget::on_window_state_event (event); } -void RTWindow::on_mainNB_switch_page(Gtk::Widget* widget, guint page_num) +void RTWindow::on_mainNB_switch_page (Gtk::Widget* widget, guint page_num) { - if(!on_delete_has_run) { - if(isEditorPanel(page_num)) { + if (!on_delete_has_run) { + if (isEditorPanel (page_num)) { if (isSingleTabMode() && epanel) { MoveFileBrowserToEditor(); } - EditorPanel *ep = static_cast(mainNB->get_nth_page(page_num)); + EditorPanel *ep = static_cast (mainNB->get_nth_page (page_num)); ep->setAspect(); if (!isSingleTabMode()) { if (filesEdited.size() > 0) { - set_title_decorated(ep->getFileName()); + set_title_decorated (ep->getFileName()); } } } else { @@ -387,7 +392,7 @@ void RTWindow::on_mainNB_switch_page(Gtk::Widget* widget, guint page_num) epanel->saveProfile(); // Moving the FileBrowser only if the user has switched to the FileBrowser tab - if (mainNB->get_nth_page(page_num) == fpanel) { + if (mainNB->get_nth_page (page_num) == fpanel) { MoveFileBrowserToMain(); } } @@ -398,32 +403,32 @@ void RTWindow::on_mainNB_switch_page(Gtk::Widget* widget, guint page_num) void RTWindow::addEditorPanel (EditorPanel* ep, const std::string &name) { if (options.multiDisplayMode > 0) { - EditWindow * wndEdit = EditWindow::getInstance(this); + EditWindow * wndEdit = EditWindow::getInstance (this); wndEdit->show(); - wndEdit->addEditorPanel(ep, name); + wndEdit->addEditorPanel (ep, name); wndEdit->toFront(); } else { ep->setParent (this); - ep->setParentWindow(this); + ep->setParentWindow (this); // construct closeable tab for the image Gtk::Grid* titleGrid = Gtk::manage (new Gtk::Grid ()); titleGrid->set_tooltip_markup (name); - RTImage *closebimg = Gtk::manage(new RTImage ("gtk-close.png")); + RTImage *closebimg = Gtk::manage (new RTImage ("gtk-close.png")); Gtk::Button* closeb = Gtk::manage (new Gtk::Button ()); closeb->set_name ("CloseButton"); closeb->add (*closebimg); closeb->set_relief (Gtk::RELIEF_NONE); closeb->set_focus_on_click (false); - closeb->signal_clicked().connect( sigc::bind (sigc::mem_fun(*this, &RTWindow::remEditorPanel) , ep)); + closeb->signal_clicked().connect ( sigc::bind (sigc::mem_fun (*this, &RTWindow::remEditorPanel), ep)); - titleGrid->attach_next_to(*Gtk::manage (new RTImage ("rtwindow.png")), Gtk::POS_RIGHT, 1, 1); - titleGrid->attach_next_to(*Gtk::manage (new Gtk::Label (Glib::path_get_basename (name))), Gtk::POS_RIGHT, 1, 1); - titleGrid->attach_next_to(*closeb, Gtk::POS_RIGHT, 1, 1); + titleGrid->attach_next_to (*Gtk::manage (new RTImage ("rtwindow.png")), Gtk::POS_RIGHT, 1, 1); + titleGrid->attach_next_to (*Gtk::manage (new Gtk::Label (Glib::path_get_basename (name))), Gtk::POS_RIGHT, 1, 1); + titleGrid->attach_next_to (*closeb, Gtk::POS_RIGHT, 1, 1); titleGrid->show_all (); //GTK318 #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 - titleGrid->set_column_spacing(2); + titleGrid->set_column_spacing (2); #endif //GTK318 @@ -432,11 +437,11 @@ void RTWindow::addEditorPanel (EditorPanel* ep, const std::string &name) mainNB->set_current_page (mainNB->page_num (*ep)); mainNB->set_tab_reorderable (*ep, true); - set_title_decorated(name); + set_title_decorated (name); epanels[ name ] = ep; filesEdited.insert ( name ); fpanel->refreshEditedState (filesEdited); - ep->tbTopPanel_1_visible(false); //hide the toggle Top Panel button + ep->tbTopPanel_1_visible (false); //hide the toggle Top Panel button } } @@ -447,8 +452,8 @@ void RTWindow::remEditorPanel (EditorPanel* ep) } if (options.multiDisplayMode > 0) { - EditWindow * wndEdit = EditWindow::getInstance(this); - wndEdit->remEditorPanel(ep); + EditWindow * wndEdit = EditWindow::getInstance (this); + wndEdit->remEditorPanel (ep); } else { bool queueHadFocus = (mainNB->get_current_page() == mainNB->page_num (*bpanel)); epanels.erase (ep->getFileName()); @@ -457,37 +462,37 @@ void RTWindow::remEditorPanel (EditorPanel* ep) mainNB->remove_page (*ep); - if (!isEditorPanel(mainNB->get_current_page())) { - if(!queueHadFocus) { + if (!isEditorPanel (mainNB->get_current_page())) { + if (!queueHadFocus) { mainNB->set_current_page (mainNB->page_num (*fpanel)); } - set_title_decorated(""); + set_title_decorated (""); } else { - EditorPanel* ep = static_cast(mainNB->get_nth_page (mainNB->get_current_page())); - set_title_decorated(ep->getFileName()); + EditorPanel* ep = static_cast (mainNB->get_nth_page (mainNB->get_current_page())); + set_title_decorated (ep->getFileName()); } // TODO: ask what to do: close & apply, close & apply selection, close & revert, cancel } } -bool RTWindow::selectEditorPanel(const std::string &name) +bool RTWindow::selectEditorPanel (const std::string &name) { if (options.multiDisplayMode > 0) { - EditWindow * wndEdit = EditWindow::getInstance(this); + EditWindow * wndEdit = EditWindow::getInstance (this); - if (wndEdit->selectEditorPanel(name)) { - set_title_decorated(name); + if (wndEdit->selectEditorPanel (name)) { + set_title_decorated (name); wndEdit->toFront(); return true; } } else { - std::map::iterator iep = epanels.find(name); + std::map::iterator iep = epanels.find (name); if (iep != epanels.end()) { mainNB->set_current_page (mainNB->page_num (*iep->second)); - set_title_decorated(name); + set_title_decorated (name); return true; } else { //set_title_decorated(name); @@ -521,12 +526,12 @@ bool RTWindow::keyPressed (GdkEventKey* event) #endif if (try_quit) { - if (!on_delete_event(nullptr)) { + if (!on_delete_event (nullptr)) { gtk_main_quit(); } } - if(event->keyval == GDK_KEY_F11) { + if (event->keyval == GDK_KEY_F11) { toggle_fullscreen(); } @@ -537,40 +542,40 @@ bool RTWindow::keyPressed (GdkEventKey* event) }; if (ctrl) { - switch(event->keyval) { - case GDK_KEY_F2: // file browser panel - mainNB->set_current_page (mainNB->page_num (*fpanel)); - return true; - - case GDK_KEY_F3: // batch queue panel - mainNB->set_current_page (mainNB->page_num (*bpanel)); - return true; - - case GDK_KEY_F4: //single tab mode, editor panel - if (isSingleTabMode() && epanel) { - mainNB->set_current_page (mainNB->page_num (*epanel)); - } - - return true; - - case GDK_KEY_w: //multi-tab mode, close editor panel - if (!isSingleTabMode() && - mainNB->get_current_page() != mainNB->page_num(*fpanel) && - mainNB->get_current_page() != mainNB->page_num(*bpanel)) { - - EditorPanel* ep = static_cast(mainNB->get_nth_page (mainNB->get_current_page())); - remEditorPanel (ep); + switch (event->keyval) { + case GDK_KEY_F2: // file browser panel + mainNB->set_current_page (mainNB->page_num (*fpanel)); return true; - } + + case GDK_KEY_F3: // batch queue panel + mainNB->set_current_page (mainNB->page_num (*bpanel)); + return true; + + case GDK_KEY_F4: //single tab mode, editor panel + if (isSingleTabMode() && epanel) { + mainNB->set_current_page (mainNB->page_num (*epanel)); + } + + return true; + + case GDK_KEY_w: //multi-tab mode, close editor panel + if (!isSingleTabMode() && + mainNB->get_current_page() != mainNB->page_num (*fpanel) && + mainNB->get_current_page() != mainNB->page_num (*bpanel)) { + + EditorPanel* ep = static_cast (mainNB->get_nth_page (mainNB->get_current_page())); + remEditorPanel (ep); + return true; + } } } - if (mainNB->get_current_page() == mainNB->page_num(*fpanel)) { + if (mainNB->get_current_page() == mainNB->page_num (*fpanel)) { return fpanel->handleShortcutKey (event); - } else if (mainNB->get_current_page() == mainNB->page_num(*bpanel)) { + } else if (mainNB->get_current_page() == mainNB->page_num (*bpanel)) { return bpanel->handleShortcutKey (event); } else { - EditorPanel* ep = static_cast(mainNB->get_nth_page (mainNB->get_current_page())); + EditorPanel* ep = static_cast (mainNB->get_nth_page (mainNB->get_current_page())); return ep->handleShortcutKey (event); } @@ -581,7 +586,7 @@ void RTWindow::addBatchQueueJob (BatchQueueEntry* bqe, bool head) { std::vector entries; - entries.push_back(bqe); + entries.push_back (bqe); bpanel->addBatchQueueJobs (entries, head); fpanel->queue_draw (); } @@ -593,7 +598,7 @@ void RTWindow::addBatchQueueJobs (std::vector &entries) fpanel->queue_draw (); } -bool RTWindow::on_delete_event(GdkEventAny* event) +bool RTWindow::on_delete_event (GdkEventAny* event) { if (on_delete_has_run) { @@ -608,14 +613,14 @@ bool RTWindow::on_delete_event(GdkEventAny* event) if (isSingleTabMode() || simpleEditor) { isProcessing = epanel->getIsProcessing(); } else if (options.multiDisplayMode > 0) { - editWindow = EditWindow::getInstance(this, false); + editWindow = EditWindow::getInstance (this, false); isProcessing = editWindow->isProcessing(); } else { int pageCount = mainNB->get_n_pages(); for (int i = 0; i < pageCount && !isProcessing; i++) { - if(isEditorPanel(i)) { - isProcessing |= (static_cast(mainNB->get_nth_page(i)))->getIsProcessing(); + if (isEditorPanel (i)) { + isProcessing |= (static_cast (mainNB->get_nth_page (i)))->getIsProcessing(); } } } @@ -624,11 +629,11 @@ bool RTWindow::on_delete_event(GdkEventAny* event) return true; } - if( fpanel ) { + if ( fpanel ) { fpanel->saveOptions (); } - if( bpanel ) { + if ( bpanel ) { bpanel->saveOptions (); } @@ -644,7 +649,7 @@ bool RTWindow::on_delete_event(GdkEventAny* event) // Look at the active panel first, if any, otherwise look at the first one (sorted on the filename) int page = mainNB->get_current_page(); - Gtk::Widget *w = mainNB->get_nth_page(page); + Gtk::Widget *w = mainNB->get_nth_page (page); bool optionsWritten = false; for (std::map::iterator i = epanels.begin(); i != epanels.end(); ++i) { @@ -667,19 +672,55 @@ bool RTWindow::on_delete_event(GdkEventAny* event) ProfilePanel::cleanup(); if (!options.windowMaximized) { - get_size(options.windowWidth, options.windowHeight); + get_size (options.windowWidth, options.windowHeight); get_position (options.windowX, options.windowY); } - options.windowMonitor = get_screen()->get_monitor_at_window(get_window()); + options.windowMonitor = get_screen()->get_monitor_at_window (get_window()); + + try { + Options::save (); + } catch (Options::Error &e) { + Gtk::MessageDialog msgd (getToplevelWindow (this), e.get_msg(), true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true); + msgd.run(); + } - Options::save (); hide(); on_delete_has_run = true; return false; } + +void RTWindow::writeToolExpandedStatus (std::vector &tpOpen) +{ + if ((isSingleTabMode() || gimpPlugin) && epanel->isRealized()) { + epanel->writeToolExpandedStatus (tpOpen); + } else { + // Storing the options of the last EditorPanel before Gtk destroys everything + // Look at the active panel first, if any, otherwise look at the first one (sorted on the filename) + if (epanels.size()) { + int page = mainNB->get_current_page(); + Gtk::Widget *w = mainNB->get_nth_page (page); + bool optionsWritten = false; + + for (std::map::iterator i = epanels.begin(); i != epanels.end(); ++i) { + if (i->second == w) { + i->second->writeToolExpandedStatus (tpOpen); + optionsWritten = true; + } + } + + if (!optionsWritten) { + // fallback solution: save the options of the first editor panel + std::map::iterator i = epanels.begin(); + i->second->writeToolExpandedStatus (tpOpen); + } + } + } +} + + void RTWindow::showPreferences () { Preferences *pref = new Preferences (this); @@ -687,11 +728,13 @@ void RTWindow::showPreferences () delete pref; fpanel->optionsChanged (); + if (epanel) { - epanel->defaultMonitorProfileChanged(options.rtSettings.monitorProfile, options.rtSettings.autoMonitorProfile); + epanel->defaultMonitorProfileChanged (options.rtSettings.monitorProfile, options.rtSettings.autoMonitorProfile); } + for (const auto &p : epanels) { - p.second->defaultMonitorProfileChanged(options.rtSettings.monitorProfile, options.rtSettings.autoMonitorProfile); + p.second->defaultMonitorProfileChanged (options.rtSettings.monitorProfile, options.rtSettings.autoMonitorProfile); } } @@ -724,7 +767,7 @@ void RTWindow::toggle_fullscreen () if (btn_fullscreen) { //btn_fullscreen->set_label(M("MAIN_BUTTON_FULLSCREEN")); - btn_fullscreen->set_tooltip_markup(M("MAIN_BUTTON_FULLSCREEN")); + btn_fullscreen->set_tooltip_markup (M ("MAIN_BUTTON_FULLSCREEN")); btn_fullscreen->set_image (*iFullscreen); } } else { @@ -733,7 +776,7 @@ void RTWindow::toggle_fullscreen () if (btn_fullscreen) { //btn_fullscreen->set_label(M("MAIN_BUTTON_UNFULLSCREEN")); - btn_fullscreen->set_tooltip_markup(M("MAIN_BUTTON_UNFULLSCREEN")); + btn_fullscreen->set_tooltip_markup (M ("MAIN_BUTTON_UNFULLSCREEN")); btn_fullscreen->set_image (*iFullscreen_exit); } } @@ -756,50 +799,51 @@ void RTWindow::SetMainCurrent() void RTWindow::MoveFileBrowserToMain() { - if( fpanel->ribbonPane->get_children().empty()) { + if ( fpanel->ribbonPane->get_children().empty()) { FileCatalog *fCatalog = fpanel->fileCatalog; - epanel->catalogPane->remove(*fCatalog); - fpanel->ribbonPane->add(*fCatalog); - fCatalog->enableTabMode(false); - fCatalog->tbLeftPanel_1_visible(true); - fCatalog->tbRightPanel_1_visible(true); + epanel->catalogPane->remove (*fCatalog); + fpanel->ribbonPane->add (*fCatalog); + fCatalog->enableTabMode (false); + fCatalog->tbLeftPanel_1_visible (true); + fCatalog->tbRightPanel_1_visible (true); } } void RTWindow::MoveFileBrowserToEditor() { - if(epanel->catalogPane->get_children().empty() ) { + if (epanel->catalogPane->get_children().empty() ) { FileCatalog *fCatalog = fpanel->fileCatalog; - fpanel->ribbonPane->remove(*fCatalog); + fpanel->ribbonPane->remove (*fCatalog); fCatalog->disableInspector(); - epanel->catalogPane->add(*fCatalog); - epanel->showTopPanel(options.editorFilmStripOpened); - fCatalog->enableTabMode(true); + epanel->catalogPane->add (*fCatalog); + epanel->showTopPanel (options.editorFilmStripOpened); + fCatalog->enableTabMode (true); fCatalog->refreshHeight(); - fCatalog->tbLeftPanel_1_visible(false); - fCatalog->tbRightPanel_1_visible(false); + fCatalog->tbLeftPanel_1_visible (false); + fCatalog->tbRightPanel_1_visible (false); } } -void RTWindow::updateProfiles(const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC) +void RTWindow::updateProfiles (const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC) { - if(epanel) { - epanel->updateProfiles(printerProfile, printerIntent, printerBPC); + if (epanel) { + epanel->updateProfiles (printerProfile, printerIntent, printerBPC); } - for(auto panel : epanels) { - panel.second->updateProfiles(printerProfile, printerIntent, printerBPC); + for (auto panel : epanels) { + panel.second->updateProfiles (printerProfile, printerIntent, printerBPC); } } void RTWindow::updateTPVScrollbar (bool hide) { fpanel->updateTPVScrollbar (hide); - if(epanel) { + + if (epanel) { epanel->updateTPVScrollbar (hide); } - for(auto panel : epanels) { + for (auto panel : epanels) { panel.second->updateTPVScrollbar (hide); } } @@ -807,11 +851,12 @@ void RTWindow::updateTPVScrollbar (bool hide) void RTWindow::updateTabsUsesIcons (bool useIcons) { fpanel->updateTabsUsesIcons (useIcons); - if(epanel) { + + if (epanel) { epanel->updateTabsUsesIcons (useIcons); } - for(auto panel : epanels) { + for (auto panel : epanels) { panel.second->updateTabsUsesIcons (useIcons); } } @@ -828,22 +873,23 @@ void RTWindow::updateFBToolBarVisibility (bool showFilmStripToolBar) void RTWindow::updateHistogramPosition (int oldPosition, int newPosition) { - if(epanel) { + if (epanel) { epanel->updateHistogramPosition (oldPosition, newPosition); } - for(auto panel : epanels) { + + for (auto panel : epanels) { panel.second->updateHistogramPosition (oldPosition, newPosition); } } -bool RTWindow::splashClosed(GdkEventAny* event) +bool RTWindow::splashClosed (GdkEventAny* event) { delete splash; splash = nullptr; return true; } -void RTWindow::set_title_decorated(Glib::ustring fname) +void RTWindow::set_title_decorated (Glib::ustring fname) { Glib::ustring subtitle; @@ -851,7 +897,7 @@ void RTWindow::set_title_decorated(Glib::ustring fname) subtitle = " - " + fname; } - set_title(versionStr + subtitle); + set_title (versionStr + subtitle); } void RTWindow::closeOpenEditors() @@ -859,36 +905,36 @@ void RTWindow::closeOpenEditors() std::map::const_iterator itr; itr = epanels.begin(); - while(itr != epanels.end()) { - remEditorPanel((*itr).second); + while (itr != epanels.end()) { + remEditorPanel ((*itr).second); itr = epanels.begin(); } } -bool RTWindow::isEditorPanel(Widget* panel) +bool RTWindow::isEditorPanel (Widget* panel) { return (panel != bpanel) && (panel != fpanel); } -bool RTWindow::isEditorPanel(guint pageNum) +bool RTWindow::isEditorPanel (guint pageNum) { - return isEditorPanel(mainNB->get_nth_page(pageNum)); + return isEditorPanel (mainNB->get_nth_page (pageNum)); } -void RTWindow::setEditorMode(bool tabbedUI) +void RTWindow::setEditorMode (bool tabbedUI) { MoveFileBrowserToMain(); closeOpenEditors(); SetMainCurrent(); - if(tabbedUI) { - mainNB->remove_page(*epanel); + if (tabbedUI) { + mainNB->remove_page (*epanel); epanel = nullptr; - set_title_decorated(""); + set_title_decorated (""); } else { createSetmEditor(); epanel->show_all(); - set_title_decorated(""); + set_title_decorated (""); } } @@ -897,25 +943,25 @@ void RTWindow::createSetmEditor() // Editor panel, single-tab mode only epanel = Gtk::manage ( new EditorPanel (fpanel) ); epanel->setParent (this); - epanel->setParentWindow(this); + epanel->setParentWindow (this); // decorate tab Gtk::Grid* const editorLabelGrid = Gtk::manage (new Gtk::Grid ()); - setExpandAlignProperties(editorLabelGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - Gtk::Label* const el = Gtk::manage (new Gtk::Label( Glib::ustring(" ") + M("MAIN_FRAME_EDITOR") )); + setExpandAlignProperties (editorLabelGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + Gtk::Label* const el = Gtk::manage (new Gtk::Label ( Glib::ustring (" ") + M ("MAIN_FRAME_EDITOR") )); const auto pos = options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT; if (options.mainNBVertical) { - el->set_angle(90); + el->set_angle (90); } - editorLabelGrid->attach_next_to(*Gtk::manage (new RTImage ("rt-logo-small.png")), pos, 1, 1); - editorLabelGrid->attach_next_to(*el, pos, 1, 1); + editorLabelGrid->attach_next_to (*Gtk::manage (new RTImage ("rt-logo-small.png")), pos, 1, 1); + editorLabelGrid->attach_next_to (*el, pos, 1, 1); - editorLabelGrid->set_tooltip_markup (M("MAIN_FRAME_EDITOR_TOOLTIP")); + editorLabelGrid->set_tooltip_markup (M ("MAIN_FRAME_EDITOR_TOOLTIP")); editorLabelGrid->show_all (); - epanel->tbTopPanel_1_visible(true); //show the toggle Top Panel button + epanel->tbTopPanel_1_visible (true); //show the toggle Top Panel button mainNB->append_page (*epanel, *editorLabelGrid); } diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index faad5f849..9c1699bcf 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -50,15 +50,15 @@ private: bool isSingleTabMode() { - return !options.tabbedUI && !(options.multiDisplayMode > 0); + return !options.tabbedUI && ! (options.multiDisplayMode > 0); }; - void findVerNumbers(int* numbers, Glib::ustring versionStr); + void findVerNumbers (int* numbers, Glib::ustring versionStr); - bool on_expose_event_epanel(GdkEventExpose* event); - bool on_expose_event_fpanel(GdkEventExpose* event); - bool splashClosed(GdkEventAny* event); - bool isEditorPanel(Widget* panel); - bool isEditorPanel(guint pageNum); + bool on_expose_event_epanel (GdkEventExpose* event); + bool on_expose_event_fpanel (GdkEventExpose* event); + bool splashClosed (GdkEventAny* event); + bool isEditorPanel (Widget* panel); + bool isEditorPanel (guint pageNum); Glib::ustring versionStr; #if defined(__APPLE__) @@ -70,20 +70,20 @@ public: ~RTWindow(); #if defined(__APPLE__) - bool osxFileOpenEvent(Glib::ustring path); + bool osxFileOpenEvent (Glib::ustring path); #endif void addEditorPanel (EditorPanel* ep, const std::string &name); void remEditorPanel (EditorPanel* ep); - bool selectEditorPanel(const std::string &name); + bool selectEditorPanel (const std::string &name); void addBatchQueueJob (BatchQueueEntry* bqe, bool head = false); void addBatchQueueJobs (std::vector &entries); bool keyPressed (GdkEventKey* event); - bool on_configure_event(GdkEventConfigure* event); - bool on_delete_event(GdkEventAny* event); - bool on_window_state_event(GdkEventWindowState* event); - void on_mainNB_switch_page(Gtk::Widget* widget, guint page_num); + bool on_configure_event (GdkEventConfigure* event); + bool on_delete_event (GdkEventAny* event); + bool on_window_state_event (GdkEventWindowState* event); + void on_mainNB_switch_page (Gtk::Widget* widget, guint page_num); void showPreferences (); void on_realize (); @@ -115,10 +115,12 @@ public: { return is_fullscreen; } - void set_title_decorated(Glib::ustring fname); + void set_title_decorated (Glib::ustring fname); void closeOpenEditors(); - void setEditorMode(bool tabbedUI); + void setEditorMode (bool tabbedUI); void createSetmEditor(); + + void writeToolExpandedStatus (std::vector &tpOpen); }; #endif diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index b06463eff..e30309fdf 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -28,7 +28,7 @@ using namespace rtengine::procparams; -ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), hasChanged(false), editDataProvider(nullptr) +ToolPanelCoordinator::ToolPanelCoordinator () : ipc (nullptr), hasChanged (false), editDataProvider (nullptr) { exposurePanel = Gtk::manage (new ToolVBox ()); @@ -53,7 +53,7 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), hasChanged(false), colortoning = Gtk::manage (new ColorToning ()); lensgeom = Gtk::manage (new LensGeometry ()); lensProf = Gtk::manage (new LensProfilePanel ()); - lensProf->setLensGeomRef(lensgeom); + lensProf->setLensGeomRef (lensgeom); distortion = Gtk::manage (new Distortion ()); rotate = Gtk::manage (new Rotate ()); vibrance = Gtk::manage (new Vibrance ()); @@ -203,8 +203,8 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), hasChanged(false), toolPanelNotebook = new Gtk::Notebook (); toolPanelNotebook->set_name ("ToolPanelNotebook"); - metadataPanel->append_page (*exifpanel, M("MAIN_TAB_EXIF")); - metadataPanel->append_page (*iptcpanel, M("MAIN_TAB_IPTC")); + metadataPanel->append_page (*exifpanel, M ("MAIN_TAB_EXIF")); + metadataPanel->append_page (*iptcpanel, M ("MAIN_TAB_IPTC")); exposurePanelSW = Gtk::manage (new MyScrolledWindow ()); detailsPanelSW = Gtk::manage (new MyScrolledWindow ()); @@ -217,47 +217,47 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), hasChanged(false), // load panel endings for (int i = 0; i < 6; i++) { vbPanelEnd[i] = Gtk::manage (new Gtk::VBox ()); - imgPanelEnd[i] = Gtk::manage (new RTImage("PanelEnding.png")); + imgPanelEnd[i] = Gtk::manage (new RTImage ("PanelEnding.png")); imgPanelEnd[i]->show (); vbPanelEnd[i]->pack_start (*imgPanelEnd[i], Gtk::PACK_SHRINK); vbPanelEnd[i]->show_all(); } exposurePanelSW->add (*exposurePanel); - exposurePanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + exposurePanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); exposurePanel->pack_start (*vbPanelEnd[0], Gtk::PACK_SHRINK, 4); detailsPanelSW->add (*detailsPanel); - detailsPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + detailsPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); detailsPanel->pack_start (*vbPanelEnd[1], Gtk::PACK_SHRINK, 4); colorPanelSW->add (*colorPanel); - colorPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + colorPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); colorPanel->pack_start (*vbPanelEnd[2], Gtk::PACK_SHRINK, 4); waveletPanelSW->add (*waveletPanel); - waveletPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + waveletPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); waveletPanel->pack_start (*vbPanelEnd[5], Gtk::PACK_SHRINK, 0); transformPanelSW->add (*transformPanel); - transformPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + transformPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); transformPanel->pack_start (*vbPanelEnd[3], Gtk::PACK_SHRINK, 4); rawPanelSW->add (*rawPanel); - rawPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + rawPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); rawPanel->pack_start (*vbPanelEnd[4], Gtk::PACK_SHRINK, 0); TOITypes type = options.UseIconNoText ? TOI_ICON : TOI_TEXT; - toiE = Gtk::manage (new TextOrIcon ("exposure.png" , M("MAIN_TAB_EXPOSURE") , M("MAIN_TAB_EXPOSURE_TOOLTIP") , type)); - toiD = Gtk::manage (new TextOrIcon ("detail.png" , M("MAIN_TAB_DETAIL") , M("MAIN_TAB_DETAIL_TOOLTIP") , type)); - toiC = Gtk::manage (new TextOrIcon ("colour.png" , M("MAIN_TAB_COLOR") , M("MAIN_TAB_COLOR_TOOLTIP") , type)); - toiW = Gtk::manage (new TextOrIcon ("wavelet.png" , M("MAIN_TAB_WAVELET") , M("MAIN_TAB_WAVELET_TOOLTIP") , type)); - toiT = Gtk::manage (new TextOrIcon ("transform.png", M("MAIN_TAB_TRANSFORM"), M("MAIN_TAB_TRANSFORM_TOOLTIP"), type)); - toiR = Gtk::manage (new TextOrIcon ("raw.png" , M("MAIN_TAB_RAW") , M("MAIN_TAB_RAW_TOOLTIP") , type)); - toiM = Gtk::manage (new TextOrIcon ("meta.png" , M("MAIN_TAB_METADATA") , M("MAIN_TAB_METADATA_TOOLTIP") , type)); + toiE = Gtk::manage (new TextOrIcon ("exposure.png", M ("MAIN_TAB_EXPOSURE"), M ("MAIN_TAB_EXPOSURE_TOOLTIP"), type)); + toiD = Gtk::manage (new TextOrIcon ("detail.png", M ("MAIN_TAB_DETAIL"), M ("MAIN_TAB_DETAIL_TOOLTIP"), type)); + toiC = Gtk::manage (new TextOrIcon ("colour.png", M ("MAIN_TAB_COLOR"), M ("MAIN_TAB_COLOR_TOOLTIP"), type)); + toiW = Gtk::manage (new TextOrIcon ("wavelet.png", M ("MAIN_TAB_WAVELET"), M ("MAIN_TAB_WAVELET_TOOLTIP"), type)); + toiT = Gtk::manage (new TextOrIcon ("transform.png", M ("MAIN_TAB_TRANSFORM"), M ("MAIN_TAB_TRANSFORM_TOOLTIP"), type)); + toiR = Gtk::manage (new TextOrIcon ("raw.png", M ("MAIN_TAB_RAW"), M ("MAIN_TAB_RAW_TOOLTIP"), type)); + toiM = Gtk::manage (new TextOrIcon ("meta.png", M ("MAIN_TAB_METADATA"), M ("MAIN_TAB_METADATA_TOOLTIP"), type)); toolPanelNotebook->append_page (*exposurePanelSW, *toiE); toolPanelNotebook->append_page (*detailsPanelSW, *toiD); @@ -287,17 +287,17 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), hasChanged(false), icm->setICMPanelListener (this); toolBar = new ToolBar (); - toolBar->setToolBarListener(this); + toolBar->setToolBarListener (this); } void ToolPanelCoordinator::addPanel (Gtk::Box* where, FoldableToolPanel* panel, int level) { - panel->setParent(where); - panel->setLevel(level); + panel->setParent (where); + panel->setLevel (level); expList.push_back (panel->getExpander()); - where->pack_start(*panel->getExpander(), false, false); + where->pack_start (*panel->getExpander(), false, false); } ToolPanelCoordinator::~ToolPanelCoordinator () @@ -309,12 +309,13 @@ ToolPanelCoordinator::~ToolPanelCoordinator () delete toolBar; } -void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtrans) +void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXtrans) { GThreadLock lock; - if(isRaw) { - rawPanelSW->set_sensitive(true); + if (isRaw) { + rawPanelSW->set_sensitive (true); + if (isBayer) { sensorxtrans->FoldableToolPanel::hide(); sensorbayer->FoldableToolPanel::show(); @@ -332,7 +333,7 @@ void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtr flatfield->FoldableToolPanel::hide(); } } else { - rawPanelSW->set_sensitive(false); + rawPanelSW->set_sensitive (false); } } @@ -345,7 +346,7 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib:: return; } - int changeFlags = refreshmap[(int)event]; + int changeFlags = refreshmap[ (int)event]; ProcParams* params = ipc->beginUpdateParams (); @@ -355,14 +356,15 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib:: // Compensate rotation on flip if (event == rtengine::EvCTHFlip || event == rtengine::EvCTVFlip) { - if (fabs(params->rotate.degree) > 0.001) { + if (fabs (params->rotate.degree) > 0.001) { params->rotate.degree *= -1; - changeFlags |= refreshmap[(int)rtengine::EvROTDegree]; + changeFlags |= refreshmap[ (int)rtengine::EvROTDegree]; rotate->read (params); } } int tr = TR_NONE; + if (params->coarse.rotate == 90) { tr = TR_R90; } else if (params->coarse.rotate == 180) { @@ -427,14 +429,14 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi } // And apply the partial profile nparams to mergedParams - nparams->applyTo(mergedParams); + nparams->applyTo (mergedParams); // Derive the effective changes, if it's a profile change, to prevent slow RAW rerendering if not necessary bool filterRawRefresh = false; if (event != rtengine::EvPhotoLoaded) { - ParamsEdited pe(true); - std::vector lParams(2); + ParamsEdited pe (true); + std::vector lParams (2); lParams[0] = *params; lParams[1] = *mergedParams; pe.initFrom (lParams); @@ -446,6 +448,7 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi delete mergedParams; tr = TR_NONE; + if (params->coarse.rotate == 90) { tr = TR_R90; } else if (params->coarse.rotate == 180) { @@ -456,7 +459,7 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi // trimming overflowing cropped area ipc->getInitialImage()->getImageSource()->getFullSize (fw, fh, tr); - crop->trim(params, fw, fh); + crop->trim (params, fw, fh); // updating the GUI with updated values for (auto toolPanel : toolPanels) { @@ -474,7 +477,7 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi // start the IPC processing if (filterRawRefresh) { - ipc->endUpdateParams ( refreshmap[(int)event] & ALLNORAW ); + ipc->endUpdateParams ( refreshmap[ (int)event] & ALLNORAW ); } else { ipc->endUpdateParams (event); } @@ -526,7 +529,7 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool ipc->setSizeListener (crop); ipc->setSizeListener (resize); ipc->setImageTypeListener (this); - flatfield->setShortcutPath(Glib::path_get_dirname(ipc->getInitialImage()->getFileName())); + flatfield->setShortcutPath (Glib::path_get_dirname (ipc->getInitialImage()->getFileName())); icm->setRawMeta (raw, (const rtengine::ImageData*)pMetaData); lensProf->setRawMeta (raw, pMetaData); @@ -552,7 +555,7 @@ void ToolPanelCoordinator::closeAllTools() for (size_t i = 0; i < options.tpOpen.size(); i++) if (i < expList.size()) { - expList.at(i)->set_expanded (false); + expList.at (i)->set_expanded (false); } } @@ -561,7 +564,7 @@ void ToolPanelCoordinator::openAllTools() for (size_t i = 0; i < options.tpOpen.size(); i++) if (i < expList.size()) { - expList.at(i)->set_expanded (true); + expList.at (i)->set_expanded (true); } } @@ -570,20 +573,20 @@ void ToolPanelCoordinator::updateToolState() for (size_t i = 0; i < options.tpOpen.size(); i++) if (i < expList.size()) { - expList.at(i)->set_expanded (options.tpOpen.at(i)); + expList.at (i)->set_expanded (options.tpOpen.at (i)); } - if(options.tpOpen.size() > expList.size()) { + if (options.tpOpen.size() > expList.size()) { size_t sizeWavelet = options.tpOpen.size() - expList.size(); std::vector temp; for (size_t i = 0; i < sizeWavelet; i++) { - temp.push_back(options.tpOpen.at(i + expList.size())); + temp.push_back (options.tpOpen.at (i + expList.size())); } - wavelet->updateToolState(temp); - wavelet->setExpanded(true); - retinex->updateToolState(temp); + wavelet->updateToolState (temp); + wavelet->setExpanded (true); + retinex->updateToolState (temp); } } @@ -597,14 +600,23 @@ void ToolPanelCoordinator::writeOptions () { crop->writeOptions (); - options.tpOpen.clear (); + + if (options.autoSaveTpOpen) { + writeToolExpandedStatus (options.tpOpen); + } +} + + +void ToolPanelCoordinator::writeToolExpandedStatus (std::vector &tpOpen) +{ + tpOpen.clear (); for (size_t i = 0; i < expList.size(); i++) { - options.tpOpen.push_back (expList.at(i)->get_expanded ()); + tpOpen.push_back (expList.at (i)->get_expanded ()); } - wavelet->writeOptions(options.tpOpen); - retinex->writeOptions(options.tpOpen); + wavelet->writeOptions (tpOpen); + retinex->writeOptions (tpOpen); } @@ -679,14 +691,14 @@ rtengine::RawImage* ToolPanelCoordinator::getDF() const rtengine::ImageMetaData *imd = ipc->getInitialImage()->getMetaData(); - if(imd) { + if (imd) { int iso = imd->getISOSpeed(); double shutter = imd->getShutterSpeed(); - std::string maker( imd->getMake() ); - std::string model( imd->getModel() ); + std::string maker ( imd->getMake() ); + std::string model ( imd->getModel() ); time_t timestamp = imd->getDateTimeAsTS(); - return rtengine::dfm.searchDarkFrame( maker, model, iso, shutter, timestamp); + return rtengine::dfm.searchDarkFrame ( maker, model, iso, shutter, timestamp); } return nullptr; @@ -700,17 +712,17 @@ rtengine::RawImage* ToolPanelCoordinator::getFF() const rtengine::ImageMetaData *imd = ipc->getInitialImage()->getMetaData(); - if(imd) { + if (imd) { // int iso = imd->getISOSpeed(); temporarilly removed because unused // double shutter = imd->getShutterSpeed(); temporarilly removed because unused double aperture = imd->getFNumber(); double focallength = imd->getFocalLen(); - std::string maker( imd->getMake() ); - std::string model( imd->getModel() ); - std::string lens( imd->getLens() ); + std::string maker ( imd->getMake() ); + std::string model ( imd->getModel() ); + std::string lens ( imd->getLens() ); time_t timestamp = imd->getDateTimeAsTS(); - return rtengine::ffm.searchFlatField( maker, model, lens, focallength, aperture, timestamp); + return rtengine::ffm.searchFlatField ( maker, model, lens, focallength, aperture, timestamp); } return nullptr; @@ -783,8 +795,8 @@ void ToolPanelCoordinator::updateCurveBackgroundHistogram (LUTu & histToneCurve, colorappearance->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve, /*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); toneCurve->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); lcurve->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve, /*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); - rgbcurves->updateCurveBackgroundHistogram(histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); - retinex->updateCurveBackgroundHistogram(histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); + rgbcurves->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); + retinex->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); } @@ -798,10 +810,10 @@ void ToolPanelCoordinator::foldAllButOne (Gtk::Box* parent, FoldableToolPanel* o if (currentTP->getParent() == parent) { // Section in the same tab, we unfold it if it's not the one that has been clicked if (currentTP != openedSection) { - currentTP->setExpanded(false); + currentTP->setExpanded (false); } else { if (!currentTP->getExpanded()) { - currentTP->setExpanded(true); + currentTP->setExpanded (true); } } } @@ -817,36 +829,36 @@ bool ToolPanelCoordinator::handleShortcutKey (GdkEventKey* event) bool alt = event->state & GDK_MOD1_MASK; if (alt) { - switch(event->keyval) { - case GDK_KEY_e: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*exposurePanelSW)); - return true; - - case GDK_KEY_d: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*detailsPanelSW)); - return true; - - case GDK_KEY_c: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*colorPanelSW)); - return true; - - case GDK_KEY_t: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*transformPanelSW)); - return true; - - case GDK_KEY_r: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*rawPanelSW)); - return true; - - case GDK_KEY_w: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*waveletPanelSW)); - return true; - - case GDK_KEY_m: - if (metadataPanel) { - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*metadataPanel)); + switch (event->keyval) { + case GDK_KEY_e: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*exposurePanelSW)); return true; - } + + case GDK_KEY_d: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*detailsPanelSW)); + return true; + + case GDK_KEY_c: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*colorPanelSW)); + return true; + + case GDK_KEY_t: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*transformPanelSW)); + return true; + + case GDK_KEY_r: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*rawPanelSW)); + return true; + + case GDK_KEY_w: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*waveletPanelSW)); + return true; + + case GDK_KEY_m: + if (metadataPanel) { + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*metadataPanel)); + return true; + } } } @@ -865,7 +877,7 @@ void ToolPanelCoordinator::updateVScrollbars (bool hide) waveletPanelSW->set_policy (Gtk::POLICY_AUTOMATIC, policy); for (auto currExp : expList) { - currExp->updateVScrollbars(hide); + currExp->updateVScrollbars (hide); } } @@ -874,14 +886,14 @@ void ToolPanelCoordinator::updateTabsHeader (bool useIcons) GThreadLock lock; // All GUI acces from idle_add callbacks or separate thread HAVE to be protected TOITypes type = useIcons ? TOI_ICON : TOI_TEXT; - toiE->switchTo(type); - toiD->switchTo(type); - toiC->switchTo(type); - toiT->switchTo(type); - toiR->switchTo(type); + toiE->switchTo (type); + toiD->switchTo (type); + toiC->switchTo (type); + toiT->switchTo (type); + toiR->switchTo (type); if (toiM) { - toiM->switchTo(type); + toiM->switchTo (type); } } @@ -900,24 +912,24 @@ void ToolPanelCoordinator::toolSelected (ToolMode tool) GThreadLock lock; // All GUI acces from idle_add callbacks or separate thread HAVE to be protected switch (tool) { - case TMCropSelect: - crop->setExpanded(true); - toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW)); - break; + case TMCropSelect: + crop->setExpanded (true); + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*transformPanelSW)); + break; - case TMSpotWB: - whitebalance->setExpanded(true); - toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*colorPanelSW)); - break; + case TMSpotWB: + whitebalance->setExpanded (true); + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*colorPanelSW)); + break; - case TMStraighten: - lensgeom->setExpanded(true); - rotate->setExpanded(true); - toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW)); - break; + case TMStraighten: + lensgeom->setExpanded (true); + rotate->setExpanded (true); + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*transformPanelSW)); + break; - default: - break; + default: + break; } } @@ -931,14 +943,14 @@ void ToolPanelCoordinator::editModeSwitchedOff () void ToolPanelCoordinator::dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile) { - flatfield->setShortcutPath(dirname); + flatfield->setShortcutPath (dirname); } -void ToolPanelCoordinator::setEditProvider(EditDataProvider *provider) +void ToolPanelCoordinator::setEditProvider (EditDataProvider *provider) { editDataProvider = provider; for (size_t i = 0; i < toolPanels.size(); i++) { - toolPanels.at(i)->setEditProvider(provider); + toolPanels.at (i)->setEditProvider (provider); } } diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index cfb85e372..5a71ef692 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -217,7 +217,7 @@ public: // toolpanellistener interface void panelChanged (rtengine::ProcEvent event, const Glib::ustring& descr); - void imageTypeChanged(bool isRaw, bool isBayer, bool isXtrans); + void imageTypeChanged (bool isRaw, bool isBayer, bool isXtrans); // profilechangelistener interface void profileChange (const rtengine::procparams::PartialProfile* nparams, rtengine::ProcEvent event, const Glib::ustring& descr, const ParamsEdited* paramsEdited = nullptr); void setDefaults (rtengine::procparams::ProcParams* defparams); @@ -239,6 +239,8 @@ public: // read/write the "expanded" state of the expanders & read/write the crop panel settings (ratio, guide type, etc.) void readOptions (); void writeOptions (); + void writeToolExpandedStatus (std::vector &tpOpen); + // wbprovider interface void getAutoWB (double& temp, double& green, double equal, double tempBias) @@ -297,7 +299,7 @@ public: void toolSelected (ToolMode tool); void editModeSwitchedOff (); - void setEditProvider(EditDataProvider *provider); + void setEditProvider (EditDataProvider *provider); }; #endif