From 9e1b9f7c199d037da055f62ae418437d0a42bd2b Mon Sep 17 00:00:00 2001 From: Desmis Date: Mon, 23 Jan 2017 13:06:10 +0100 Subject: [PATCH] Add C=f(C) curve and fixed some bugs --- rtdata/languages/default | 1 + rtengine/curves.cc | 18 ++ rtengine/curves.h | 1 + rtengine/dcrop.cc | 33 ++- rtengine/improccoordinator.cc | 178 +++++++++++++-- rtengine/improccoordinator.h | 8 +- rtengine/improcfun.h | 4 +- rtengine/iplocallab.cc | 129 ++++++++--- rtengine/procevents.h | 1 + rtengine/procparams.cc | 32 +++ rtengine/procparams.h | 2 + rtengine/refreshmap.cc | 3 +- rtengine/rtengine.h | 8 +- rtengine/simpleprocess.cc | 75 +++++- rtgui/edit.cc | 413 +++++++++++++++++----------------- rtgui/locallab.cc | 79 ++++++- rtgui/locallab.h | 7 +- rtgui/paramsedited.cc | 6 + rtgui/paramsedited.h | 1 + 19 files changed, 733 insertions(+), 266 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 5bd472cdc..68a5f29c9 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -740,6 +740,7 @@ HISTORY_MSG_505;Local - CBDL HISTORY_MSG_506;Local - Denoise HISTORY_MSG_507;Local - LH Curve HISTORY_MSG_508;Local - Enable curve +HISTORY_MSG_509;Local - CC curve HISTORY_NEWSNAPSHOT;Add HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: Alt-s HISTORY_SNAPSHOT;Snapshot diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 0d6896940..2f6a3d770 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -429,6 +429,24 @@ void CurveFactory::curveLocal (bool & locallutili, const std::vector& cu } +void CurveFactory::curveCCLocal (bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip) +{ + bool needed = false; + std::unique_ptr dCurve; + + if (!curvePoints.empty() && curvePoints[0] != 0) { + dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + + if (dCurve && !dCurve->isIdentity()) { + needed = true; + localcutili = true; + } + } + + fillCurveArray (dCurve.get(), LocalCCurve, skip, needed); + //LocalLCurve.dump("wav"); + +} void CurveFactory::localLCurve (double br, double contr, /*const std::vector& curvePoints,*/ diff --git a/rtengine/curves.h b/rtengine/curves.h index 773fecc53..2abd4daee 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -297,6 +297,7 @@ public: static void curveToning ( const std::vector& curvePoints, LUTf & ToningCurve, int skip); static void curveLocal ( bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip); + static void curveCCLocal ( bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip); static void complexsgnCurve ( bool & autili, bool & butili, bool & ccutili, bool & clcutili, const std::vector& acurvePoints, const std::vector& bcurvePoints, const std::vector& cccurvePoints, const std::vector& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve, diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 6a07d23cd..2db44d99f 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -799,6 +799,8 @@ void Crop::update (int todo) bool wavcontlutili = parent->wavcontlutili; bool locallutili = parent->locallutili; LUTf lllocalcurve2 (65536, 0); + bool localcutili = parent->locallutili; + LUTf cclocalcurve2 (65536, 0); LUTu dummy; bool needslocal = params.locallab.enabled; @@ -813,7 +815,7 @@ void Crop::update (int todo) int maxspot = settings->nspot + 1; if (needslocal ) { - // if(tyty ) { + // if (tyty ) { //Glib::ustring datalab2 = parent->imgsrc->getFileName() + ".mip"; Glib::ustring pop = options.getUserProfilePath() + "/"; @@ -973,6 +975,15 @@ void Crop::update (int todo) params.locallab.llcurve.clear(); params.locallab.llcurve = llc; + std::vector ccc; + + for (int j = 0; j < parent->sizecccs[sp]; j++) { + ccc.push_back ((double) (parent->cccurvs[sp * 500 + j]) / 1000.); + } + + params.locallab.cccurve.clear(); + params.locallab.cccurve = ccc; + std::vector lhc; for (int j = 0; j < parent->sizelhcs[sp]; j++) { @@ -985,13 +996,16 @@ void Crop::update (int todo) params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); locallutili = false; CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); + localcutili = false; + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); params.locallab.hueref = (parent->huerefs[sp]) / 100.f; params.locallab.chromaref = parent->chromarefs[sp]; params.locallab.lumaref = parent->lumarefs[sp]; - parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); + cclocalcurve2.clear(); if (skip <= 2) { usleep (settings->cropsleep); //wait to avoid crash when crop 100% and move window @@ -1182,6 +1196,16 @@ void Crop::update (int todo) params.locallab.llcurve.clear(); params.locallab.llcurve = llcL; + std::vector cccL; + + for (int j = 0; j < parent->sizecccs[sp]; j++) { + cccL.push_back ((double) (parent->cccurvs[0 * 500 + j]) / 1000.); + parent->cccurvs[sp * 500 + j] = parent->cccurvs[0 * 500 + j] ; + } + + params.locallab.cccurve.clear(); + params.locallab.cccurve = cccL; + std::vector lhcL; for (int j = 0; j < parent->sizelhcs[sp]; j++) { @@ -1194,16 +1218,19 @@ void Crop::update (int todo) params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); locallutili = false; + localcutili = false; CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); // skip == 1 ? 1 : 16); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); // skip == 1 ? 1 : 16); params.locallab.hueref = (parent->huerefs[sp]) / 100.f; params.locallab.chromaref = parent->chromarefs[sp]; params.locallab.lumaref = parent->lumarefs[sp]; - parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), locutili2, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), locutili2, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); + cclocalcurve2.clear(); } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index a2d107e76..0dfad4555 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -40,7 +40,7 @@ ImProcCoordinator::ImProcCoordinator () ncie (nullptr), imgsrc (nullptr), shmap (nullptr), lastAwbEqual (0.), ipf (¶ms, true), monitorIntent (RI_RELATIVE), softProof (false), gamutCheck (false), scale (10), highDetailPreprocessComputed (false), highDetailRawComputed (false), allocated (false), bwAutoR (-9000.f), bwAutoG (-9000.f), bwAutoB (-9000.f), CAMMean (NAN), coordX (0), coordY (0), localX (0), localY (0), - dataspot (nullptr), retistr (nullptr), retistrsav (nullptr), llstr (nullptr), lhstr (nullptr), + dataspot (nullptr), retistr (nullptr), retistrsav (nullptr), llstr (nullptr), lhstr (nullptr), ccstr (nullptr), ctColorCurve(), // localcurve(65536, 0), hltonecurve (65536), @@ -55,6 +55,7 @@ ImProcCoordinator::ImProcCoordinator () wavclCurve (65536, 0), clToningcurve (65536, 0), lllocalcurve (65536, 0), + cclocalcurve (65536, 0), cl2Toningcurve (65536, 0), Noisecurve (65536, 0), @@ -146,6 +147,8 @@ ImProcCoordinator::ImProcCoordinator () sizellcs (500, -10000), lhcurvs (25000, -10000), //allow 500 values for each control point * 500 sizelhcs (500, -10000), + cccurvs (25000, -10000), //allow 500 values for each control point * 500 + sizecccs (500, -10000), lumarefs (500, -100000.f), chromarefs (500, -100000.f), @@ -713,18 +716,27 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) */ bool isascii = true; - Glib::ustring datainterm = imgsrc->getFileName() + ".mip"; + Glib::ustring datainterm = imgsrc->getFileName() + ".ii";//extansion ii arbitrary to test if mip file is possible + ofstream finterm (datainterm, ios::out); if (finterm.fail()) { - printf ("Non ascii Mip file..switch to Profiles\n"); + printf ("Non ascii Mip file possible..switch to Profiles\n"); isascii = false; } else { - printf ("ascii Mip file!\n"); + printf ("ascii Mip file possible!\n"); } finterm.close(); + if (isascii == true) { + if ( std::remove (datainterm.c_str()) != 0 ) { + perror ( "Error deleting test ii file" ); + } else { + puts ( "Test ii file successfully deleted" ); + } + } + // printf("mip file=%s \n", datalab.c_str()); Glib::ustring pop = options.getUserProfilePath() + "/"; Glib::ustring datal; @@ -734,7 +746,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) datal = pop + Glib::path_get_basename (imgsrc->getFileName () + ".mip"); } - if (options.mip == MI_prev && isascii) { + if (options.mip == MI_prev && isascii) {//&& isascii datal = imgsrc->getFileName() + ".mip"; } @@ -809,7 +821,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { for (int sp = 1; sp < maxspot; sp++) { // spots default int t_sp = sp; - int t_mipversion = 10005;//new value for tone mapping + int t_mipversion = 10006;//new value for tone mapping int t_circrad = 18; int t_locX = 250; int t_locY = 250; @@ -879,6 +891,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) std::string t_curvlh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; //10005 int t_curvactiv = 0; + //10006 + std::string t_curvcc = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G";// "3000A0B0C1000D1000E";//with that it works ! //all variables except locRETgainCurve 'coomon for all) fic << "Mipversion=" << t_mipversion << '@' << endl; @@ -944,6 +958,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fic << "curveReti=" << t_curvret << '@' << endl; fic << "curveLL=" << t_curvll << '@' << endl; fic << "curveLH=" << t_curvlh << '@' << endl; + fic << "curveCC=" << t_curvcc << '@' << endl; fic << endl; } @@ -971,6 +986,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) retistr = new std::string[maxspot]; llstr = new std::string[maxspot]; lhstr = new std::string[maxspot]; + ccstr = new std::string[maxspot]; { @@ -1137,6 +1153,30 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) llstr[0] = ll_str + "@"; //end local L f(L) + //curve local C chrom + int sizc = params.locallab.cccurve.size(); + + if (sizc > 69) { + sizc = 69;//to avoid crash + } + + int s_curc[sizc + 1]; + int s_datcurc[sizc + 1]; + + for (int j = 0; j < sizc; j++) { + s_datcurc[j] = cccurvs[0 + j] = (int) (1000. * params.locallab.cccurve[j]); + } + + std::string cc_str = ""; + + for (int j = 0; j < sizc; j++) { + cc_str = cc_str + std::to_string (s_datcurc[j]) + delim[j]; + } + + ccstr[0] = cc_str + "@"; + //end local C f(C) + + //curve local L f(H) int sizh = params.locallab.LHcurve.size(); @@ -1166,7 +1206,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) if (params.locallab.anbspot == 0) { //update GUI and MIP after current spot ==> params, shift with the other alolistener if (aloListener && params.locallab.anbspot == 0) { - aloListener->localretChanged (dataspot, retistr[0], llstr[0], lhstr[0], 0, 1); + aloListener->localretChanged (dataspot, retistr[0], llstr[0], lhstr[0], ccstr[0], 0, 1); } } @@ -1184,6 +1224,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) bool excurvret = true; bool excurvll = true; bool excurvlh = true; + bool excurvcc = true; ifstream fich (datal, ios::in); @@ -1214,9 +1255,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) maxind = 56; } + if (versionmip == 10005) { + excurvcc = false; + } + int sizecu; int sizell; int sizelh; + int sizecc; while (getline (fich, line)) { spotline = line; @@ -1291,6 +1337,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // printf("lecture strLL=%s ns=%i si=%i\n", llstr[ns].c_str(), ns, sizell); } + if (excurvlh && spotline.substr (0, pos) == "curveLH") { std::string curstrh; int longecurh; @@ -1309,6 +1356,25 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) //printf("lecture strLH=%s ns=%i si=%i\n", lhstr[ns].c_str(), ns, sizelh); } + if (excurvcc && spotline.substr (0, pos) == "curveCC") { + std::string curstrc; + int longecurc; + std::string strendc = spotline.substr (posend - 1, 1); + std::size_t poszc = spotline.find (strendc); + int longec; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strendc) { + longec = sl + 1; + } + } + + ccstr[ns] = str3; + sizecc = longec; + // printf("lecture strCC=%s ns=%i si=%i\n", ccstr[ns].c_str(), ns, sizecc); + } + + } @@ -1362,13 +1428,21 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } } + if (versionmip == 10005) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + std::string cc_str = "3000A0B0C1000D1000E"; + ccstr[sp] = cc_str + "@"; + } + } + if (ns < (maxspot - 1)) { ofstream fic (datal, ios::out | ios::app); // ouverture en écriture avec effacement du fichier ouvert for (int sp = ns + 1 ; sp < maxspot; sp++) { // spots default int t_sp = sp; - int t_mipversion = 10005; + int t_mipversion = 10006; int t_circrad = 18; int t_locX = 250; int t_locY = 250; @@ -1434,6 +1508,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) std::string t_curvlh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; //10005 int t_curvactiv = 0; + //10006 + std::string t_curvcc = "3000A0B0C1000D1000E"; fic << "Mipversion=" << t_mipversion << '@' << endl; fic << "Spot=" << t_sp << '@' << endl; @@ -1497,6 +1573,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fic << "curveReti=" << t_curvret << '@' << endl; fic << "curveLL=" << t_curvll << '@' << endl; fic << "curveLH=" << t_curvlh << '@' << endl; + fic << "curveCC=" << t_curvcc << '@' << endl; fic << endl; } @@ -1516,6 +1593,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int sizecu2; int sizell2; int sizelh2; + int sizecc2; while (getline (fich2, line2)) { spotline2 = line2; @@ -1588,6 +1666,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } + if (spotline2.substr (0, pos2) == "curveLH") { std::string curstr2h; int longecur2h; @@ -1606,6 +1685,25 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } + if (spotline2.substr (0, pos2) == "curveCC") { + std::string curstr2c; + int longecur2c; + std::string strend2c = spotline2.substr (posend2 - 1, 1); + std::size_t posz2lc = spotline2.find (strend2c); + int longe2c; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strend2c) { + longe2c = sl + 1; + } + } + + ccstr[ns] = str32; + sizecc2 = longe2c; + + } + + } fich2.close() ; @@ -1797,6 +1895,24 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) delete [] s_datcl; + + int *s_datcc; + s_datcc = new int[70]; + int sizc; + + ipf.strcurv_data (ccstr[sp], s_datcc, sizc); + + sizecccs[sp] = sizc; + + std::vector cccend; + + for (int j = 0; j < sizc; j++) { + cccurvs[sp * 500 + j] = s_datcc[j]; + cccend.push_back ((double) (s_datcc[j]) / 1000.); + } + + delete [] s_datcc; + int *s_datch; s_datch = new int[70]; int sizh; @@ -1825,12 +1941,17 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.LHcurve.clear(); params.locallab.LHcurve = clhend; + params.locallab.cccurve.clear(); + params.locallab.cccurve = cccend; locallutili = false; + localcutili = false; + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); //scale == 1 ? 1 : 16); - ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); dataspot[57][sp] = huerefs[sp] = 100.f * params.locallab.hueref; dataspot[58][sp] = chromarefs[sp] = params.locallab.chromaref; dataspot[59][sp] = lumarefs[sp] = params.locallab.lumaref; @@ -1838,6 +1959,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) nextParams.locallab.chromaref = params.locallab.chromaref; nextParams.locallab.lumaref = params.locallab.lumaref; lllocalcurve.clear(); + cclocalcurve.clear(); } @@ -1851,7 +1973,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) if (aloListener && realspot != dataspot[16][0]) { //update GUI and MIP - aloListener->localChanged (dataspot, retistr[sp], llstr[sp], lhstr[sp], sp, maxreal); + aloListener->localChanged (dataspot, retistr[sp], llstr[sp], lhstr[sp], ccstr[sp], sp, maxreal); } @@ -2070,6 +2192,28 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) delete [] s_datcl; + + int *s_datcc; + s_datcc = new int[70]; + int sizc; + + ipf.strcurv_data (ccstr[0], s_datcc, sizc); + sizecccs[sp] = sizc; + std::vector cccend; + + ccstr[sp] = ccstr[0]; + + for (int j = 0; j < sizc; j++) { + cccurvs[sp * 500 + j] = s_datcc[j]; + cccend.push_back ((double) (s_datcc[j]) / 1000.); + + } + + params.locallab.cccurve.clear(); + params.locallab.cccurve = cccend; + + delete [] s_datcc; + int *s_datch; s_datch = new int[70]; int sizh; @@ -2093,13 +2237,18 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); locallutili = false; - CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); + localcutili = false; - ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); //scale == 1 ? 1 : 16); + + ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); dataspot[57][sp] = huerefs[sp] = 100.f * params.locallab.hueref; dataspot[58][sp] = chromarefs[sp] = params.locallab.chromaref; dataspot[59][sp] = lumarefs[sp] = params.locallab.lumaref; lllocalcurve.clear(); + cclocalcurve.clear(); + nextParams.locallab.hueref = params.locallab.hueref; nextParams.locallab.chromaref = params.locallab.chromaref; nextParams.locallab.lumaref = params.locallab.lumaref; @@ -2113,7 +2262,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) for (int spe = 1; spe < maxspot; spe++) { int t_sp = spe; - int t_mipversion = 10005; + int t_mipversion = 10006; int t_circrad = dataspot[2][spe]; int t_locX = dataspot[3][spe]; int t_locY = dataspot[4][spe]; @@ -2178,6 +2327,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) std::string t_curvret = retistr[spe]; std::string t_curvll = llstr[spe]; std::string t_curvlh = lhstr[spe]; + std::string t_curvcc = ccstr[spe]; fou << "Mipversion=" << t_mipversion << '@' << endl; fou << "Spot=" << t_sp << '@' << endl; @@ -2245,6 +2395,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fou << "curveReti=" << t_curvret << endl; fou << "curveLL=" << t_curvll << endl; fou << "curveLH=" << t_curvlh << endl; + fou << "curveCC=" << t_curvcc << endl; fou << endl; } @@ -2263,6 +2414,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) delete [] retistr; delete [] llstr; delete [] lhstr; + delete [] ccstr; // } diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 5303f28e9..80e72e369 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -107,6 +107,7 @@ protected: LUTf wavclCurve; LUTf clToningcurve; LUTf lllocalcurve; + LUTf cclocalcurve; LUTf cl2Toningcurve; LUTf Noisecurve; LUTf NoiseCCcurve; @@ -215,10 +216,13 @@ protected: bool opautili; bool wavcontlutili; bool locallutili; + bool localcutili; + int **dataspot; std::string *retistr; std::string *llstr; std::string *lhstr; + std::string *ccstr; LUTi circrads; LUTi centerx; @@ -233,7 +237,7 @@ protected: LUTi sensis; LUTi transits; LUTi inverss; - LUTi curvactivs; + LUTi curvactivs; LUTi smeths; LUTi curens; LUTi radiuss; @@ -284,6 +288,8 @@ protected: LUTi sizellcs; LUTi lhcurvs; LUTi sizelhcs; + LUTi cccurvs; + LUTi sizecccs; LUTf huerefs; LUTf chromarefs; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 09183b9cc..027715c40 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -278,7 +278,7 @@ public: //locallab void MSRLocal (float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); - void Lab_Local (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, double &hueref, double &chromaref, double &lumaref); + void Lab_Local (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, double &hueref, double &chromaref, double &lumaref); void addGaNoise (LabImage *lab, LabImage *dst, const float mean, const float variance, const int sk); void BlurNoise_Localold (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); void InverseBlurNoise_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); @@ -293,7 +293,7 @@ public: void DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); - void ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + void ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, float chprov, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); void InverseColorLight_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy); void Sharp_Local (int call, int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 049c5fdf4..32239d1cc 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -2950,7 +2950,7 @@ void ImProcFunctions::Sharp_Local (int call, int sp, float **loctemp, const floa -void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const local_params & lp, float ** deltE, LabImage * original, LabImage * transformed, int cx, int cy) +void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, float chprov, const local_params & lp, float ** deltE, LabImage * original, LabImage * transformed, int cx, int cy) { // BENCHFUN // chroma and lightness @@ -2981,6 +2981,11 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag const float amoins = (lp.chro - 1.f) / delhu; const float bmoins = 1.f - amoins * huemoins; + const float apluscurv = (1.f - chprov) / delhu; + const float bpluscurv = 1.f - apluscurv * hueplus; + const float amoinscurv = (chprov - 1.f) / delhu; + const float bmoinscurv = 1.f - amoinscurv * huemoins; + const float apl = (-1.f) / delhu; const float bpl = - apl * hueplus; @@ -3028,16 +3033,6 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag ImProcFunctions::secondeg_begin (reducac2, vi2, aO, bO);//parabolic if (call <= 3) { - // printf("actif\n"); - /* - if(lllocalcurve) { - printf("COURBE\n"); - } - - if(!lllocalcurve) { - printf("PAS DE COURBE\n"); - } - */ //Todo optimization in this first part with bufcolorig and bufcoltra #ifdef _OPENMP @@ -3118,12 +3113,14 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag eps = 0.01f; } + float kab = (original->a[y][x] / (original->b[y][x] + eps)); //prepare shape detection // printf("z"); //end buf for square float realchro = 1.f; + float realcurv = 1.f; float deltachro = fabs (rchro - chromaref); float deltahue = fabs (rhue - hueref); @@ -3161,14 +3158,19 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good if (rhue >= hueplus - delhu) { realchro = aplus * rhue + bplus; + realcurv = apluscurv * rhue + bpluscurv; + khu = apl * rhue + bpl; } else if (rhue < huemoins + delhu) { realchro = amoins * rhue + bmoins; + realcurv = amoinscurv * rhue + bmoinscurv; + khu = amo * rhue + bmo; } else { realchro = lp.chro; + realcurv = chprov; khu = 1.f; } @@ -3177,14 +3179,20 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { if (rhue >= hueplus - delhu && rhue < hueplus) { realchro = aplus * rhue + bplus; + realcurv = apluscurv * rhue + bpluscurv; + khu = apl * rhue + bpl; } else if (rhue >= huemoins && rhue < huemoins + delhu) { realchro = amoins * rhue + bmoins; + realcurv = amoinscurv * rhue + bmoinscurv; + khu = amo * rhue + bmo; } else { realchro = lp.chro; + realcurv = chprov; + khu = 1.f; } @@ -3195,14 +3203,19 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins) { if (rhue >= hueplus - delhu && rhue < hueplus) { realchro = aplus * rhue + bplus; + realcurv = apluscurv * rhue + bpluscurv; + khu = apl * rhue + bpl; } else if (rhue >= huemoins && rhue < huemoins + delhu) { realchro = amoins * rhue + bmoins; + realcurv = amoinscurv * rhue + bmoinscurv; khu = amo * rhue + bmo; } else { realchro = lp.chro; + realcurv = chprov; + khu = 1.f; } @@ -3211,14 +3224,20 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { if (rhue >= hueplus - delhu && rhue < hueplus) { realchro = aplus * rhue + bplus; + realcurv = apluscurv * rhue + bpluscurv; + khu = apl * rhue + bpl; } else if (rhue >= huemoins && rhue < huemoins + delhu) { realchro = amoins * rhue + bmoins; + realcurv = amoinscurv * rhue + bmoinscurv; + khu = amo * rhue + bmo; } else { realchro = lp.chro; + realcurv = chprov; + khu = 1.f; } @@ -3267,12 +3286,17 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if (chromaref > 0.f && chromaref < 35.f * multchro) { // detect blue sky if ( (rhue > -2.79f && rhue < -1.11f) && (rchro < 35.f * multchro)) { realchro *= 0.9f; + realcurv *= 0.9f; } else { realchro = 1.f; + realcurv = 1.f; + } } } else { realchro = lp.chro; + realcurv = chprov; + } if (lp.sens < 50.f && lp.chro > 0.f) { @@ -3280,12 +3304,18 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if (chromaref > 0.f && chromaref < 55.f * multchroskin) { // detect skin if ( (rhue > -0.09f && rhue < 1.59f) && (rchro < 55.f * multchroskin)) { realchro *= 0.9f; + realcurv *= 0.9f; + } else { realchro = 1.f; + realcurv = 1.f; + } } } else { realchro = lp.chro; + realcurv = chprov; + } } } @@ -3366,7 +3396,9 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if (lp.curvact) { if (lllocalcurve) { float lumprov = lllocalcurve[lumnew * 1.9f]; - lumnew = 0.526316f * lumprov; + float lumred = 0.526316f * lumprov; + lumnew = lumnew + (lumred - lumnew) / 1.5f;//reduce sensibility + } if (loclhCurve) { @@ -3403,8 +3435,8 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag } float factorx = localFactor; - float fac = (100.f + factorx * realchro * falu) / 100.f; //chroma factor transition - // float diflc = lightcont - bufcolorig->L[loy - begy - 1][lox - begx - 1]; + + float fac = ((100.f + realcurv * factorx * falu) / 100.f) * (100.f + factorx * realchro * falu) / 100.f; //chroma factor transition float diflc = lightcont - original->L[y][x]; kdiff *= fach * kch; diflc *= kdiff ; @@ -3433,7 +3465,8 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if (lp.curvact) { if (lllocalcurve) { float lumprov = lllocalcurve[lumnew * 1.9f]; - lumnew = 0.526316f * lumprov; + float lumred = 0.526316f * lumprov; + lumnew = lumnew + (lumred - lumnew) / 1.5f;//reduce sensibility } if (loclhCurve) { @@ -3462,8 +3495,6 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag if (lp.ligh != 0.f) { - // calclight (original->L[y][x], lp.ligh , lumnew); - // calclight (bufcolorig->L[loy - begy - 1][lox - begx - 1], lp.ligh , lumnew, true);//replace L-curve calclight (lumnew, lp.ligh , lumnew, true);//replace L-curve lightcont = lumnew; @@ -3471,9 +3502,9 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag lightcont = lumnew; } - float fac = (100.f + realchro * falu) / 100.f; //chroma factor transition + float fac = ((100.f + realcurv * falu) / 100.f) * (100.f + realchro * falu) / 100.f; //chroma factor transition7 + float diflc = lightcont - original->L[y][x]; - //float diflc = lightcont - bufcolorig->L[loy - begy - 1][lox - begx - 1]; kdiff *= fach * kch; diflc *= kdiff ; @@ -3571,7 +3602,7 @@ void ImProcFunctions::InverseColorLight_Local (const struct local_params & lp, L } -void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, double & hueref, double & chromaref, double & lumaref) +void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, double & hueref, double & chromaref, double & lumaref) { //general call of others functions : important return hueref, chromaref, lumaref if (params->locallab.enabled) { @@ -4204,8 +4235,31 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * } LabImage *bufcolorig; + float chprov = 1.f; LabImage *bufcoltra; + float adjustr = 1.0f; + + + if (params->icm.working == "ProPhoto") { + adjustr = 1.2f; // 1.2 instead 1.0 because it's very rare to have C>170.. + } else if (params->icm.working == "Adobe RGB") { + adjustr = 1.8f; + } else if (params->icm.working == "sRGB") { + adjustr = 2.0f; + } else if (params->icm.working == "WideGamut") { + adjustr = 1.2f; + } else if (params->icm.working == "Beta RGB") { + adjustr = 1.4f; + } else if (params->icm.working == "BestRGB") { + adjustr = 1.4f; + } else if (params->icm.working == "BruceRGB") { + adjustr = 1.8f; + } + + + + if (call <= 3) { //simpleprocess int GW = transformed->W; int GH = transformed->H; @@ -4241,15 +4295,23 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * bufcolorig->L[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas bufcolorig->a[loy - begy - 1][lox - begx - 1] = original->a[y][x];//fill square buffer with datas bufcolorig->b[loy - begy - 1][lox - begx - 1] = original->b[y][x];//fill square buffer with datas - //float lumprov = bufcolorig->L[loy - begy - 1][lox - begx - 1]; - //float lumnew = lllocalcurve[lumprov]; - //float lumnew = lllocalcurve[bufcolorig->L[loy - begy - 1][lox - begx - 1]]; - //bufcolorig->L[loy - begy - 1][lox - begx - 1] = lumnew; + chprov = 0.f; + + if (cclocalcurve && lp.curvact) { + float chromat = sqrt (SQR (bufcolorig->a[loy - begy - 1][lox - begx - 1]) + SQR (bufcolorig->b[loy - begy - 1][lox - begx - 1])); + float ch; + float ampli = 12.f; + ch = (cclocalcurve[chromat * adjustr]) / ((chromat + 0.00001f) / adjustr); //ch between 0 and 0 50 or more + + if (ch <= 1.f) {//convert data curve near values of slider -100 + 100, to be used after to detection shape + chprov = 100.f * ch - 100.f; + } else { + chprov = ampli * ch - ampli;//ampli = 12.f arbitrary empirical coefficient between 5 and 50 + } + } + - // bufcoltra->L[loy - begy - 1][lox - begx - 1] = transformed->L[y][x];//fill square buffer with datas - // bufcoltra->a[loy - begy - 1][lox - begx - 1] = transformed->a[y][x];//fill square buffer with datas - // bufcoltra->b[loy - begy - 1][lox - begx - 1] = transformed->b[y][x];//fill square buffer with datas } } @@ -4259,11 +4321,18 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * /* if(locallutili) printf("Courbe oui\n"); if(!locallutili) printf("Courbe NON\n"); - if(lllocalcurve) printf("Courbe RE OUI\n"); - if(!lllocalcurve) printf("CouRE NON\n"); + */ + /* + if (cclocalcurve) { + printf ("Courbe RE OUI\n"); + } + + if (!cclocalcurve) { + printf ("CouRE NON\n"); + } */ - ColorLight_Local (call, bufcolorig, bufcoltra, sp, moy, hueplus, huemoins, hueref, dhue, chromaref, lumaref, locallutili, lllocalcurve, loclhCurve, lp, deltE, original, transformed, cx, cy); + ColorLight_Local (call, bufcolorig, bufcoltra, sp, moy, hueplus, huemoins, hueref, dhue, chromaref, lumaref, locallutili, lllocalcurve, loclhCurve, cclocalcurve, chprov, lp, deltE, original, transformed, cx, cy); if (call <= 3) { diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 3388b10f0..099148f5a 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -535,6 +535,7 @@ enum ProcEvent { EvLocenadenoi = 505, EvlocallabLHshape = 506, Evlocallabcurvactiv = 507, + Evlocallabccshape = 508, NUMOFEVENTS diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 568f2ecc6..2a26991b9 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -935,6 +935,8 @@ void LocallabParams::setDefaults() anbspot = 0; llcurve.clear (); llcurve.push_back (DCT_Linear); + cccurve.clear (); + cccurve.push_back (DCT_Linear); expcolor = true; expblur = true; exptonemap = true; @@ -953,6 +955,7 @@ void LocallabParams::setDefaults() getDefaultLocalgainCurveTrab (localTgaincurverab); getDefaultLLCurve (llcurve); getDefaultLHCurve (LHcurve); + getDefaultCCCurve (cccurve); } @@ -1034,6 +1037,21 @@ void LocallabParams::getDefaultLLCurve (std::vector &curve) } } +void LocallabParams::getDefaultCCCurve (std::vector &curve) +{ + double v[4] = { 0.00, 0.00, + // 0.499, 0.501, + 1.00, 1.00 + }; + + curve.resize (5); + curve.at (0) = double (DCT_NURBS); + + for (size_t i = 1; i < curve.size(); ++i) { + curve.at (i) = v[i - 1]; + } +} + void LocallabParams::getCurves (LocretigainCurve &cTgainCurve, LocretigainCurverab &cTgainCurverab, LocLHCurve &lhCurve) const { @@ -2676,6 +2694,11 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b keyFile.set_double_list ("Locallab", "LLCurve", llcurve); } + if (!pedited || pedited->locallab.cccurve) { + Glib::ArrayHandle cccurve = locallab.cccurve; + keyFile.set_double_list ("Locallab", "CCCurve", cccurve); + } + if (!pedited || pedited->locallab.LHcurve) { Glib::ArrayHandle LHcurve = locallab.LHcurve; keyFile.set_double_list ("Locallab", "LHCurve", LHcurve); @@ -4223,6 +4246,14 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } + if (keyFile.has_key ("Locallab", "CCCurve")) { + locallab.cccurve = keyFile.get_double_list ("Locallab", "CCCurve"); + + if (pedited) { + pedited->locallab.cccurve = true; + } + } + if (keyFile.has_key ("Locallab", "LHCurve")) { locallab.LHcurve = keyFile.get_double_list ("Locallab", "LHCurve"); @@ -8866,6 +8897,7 @@ bool ProcParams::operator== (const ProcParams& other) && locallab.localTgaincurve == other.locallab.localTgaincurve && locallab.localTgaincurverab == other.locallab.localTgaincurverab && locallab.llcurve == other.locallab.llcurve + && locallab.cccurve == other.locallab.cccurve && locallab.LHcurve == other.locallab.LHcurve && pcvignette.enabled == other.pcvignette.enabled && pcvignette.strength == other.pcvignette.strength diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 66c679733..47f8b03b7 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -933,6 +933,7 @@ public: std::vector localTgaincurve; std::vector localTgaincurverab; std::vector llcurve; + std::vector cccurve; std::vector LHcurve; double mult[5]; @@ -948,6 +949,7 @@ public: static void getDefaultLocalgainCurveTrab (std::vector &curve); static void getDefaultLLCurve (std::vector &curve); static void getDefaultLHCurve (std::vector &curve); + static void getDefaultCCCurve (std::vector &curve); }; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index bbaa17522..4b267c001 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -534,7 +534,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, //Evlocenacbdl LUMINANCECURVE, //Evlocenadenoi LUMINANCECURVE, //EvlocallabLHshape - LUMINANCECURVE //Evlocallabcurvactiv + LUMINANCECURVE, //Evlocallabcurvactiv + LUMINANCECURVE //Evlocallabccshape diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index d7efdd898..368ae9b80 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -315,8 +315,8 @@ class localListener { public : virtual ~localListener() {} - virtual void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) {} - virtual void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) {} + virtual void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, int sp, int maxdat) {} + virtual void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, int sp, int maxdat) {} }; @@ -376,7 +376,7 @@ public: virtual void endUpdateParams (ProcEvent change) = 0; virtual void endUpdateParams (int changeFlags) = 0; // Starts a minimal update - virtual void startProcessing(int changeCode) = 0; + virtual void startProcessing (int changeCode) = 0; /** Stops image processing. When it returns, the image processing is already stopped. */ virtual void stopProcessing () = 0; /** Sets the scale of the preview image. The larger the number is, the faster the image updates are (typical values are 4-5). @@ -508,7 +508,7 @@ public: * @param img is the result of the last ProcessingJob * @return the next ProcessingJob to process */ virtual ProcessingJob* imageReady (IImage16* img) = 0; - virtual void error(Glib::ustring message) = 0; + virtual void error (Glib::ustring message) = 0; }; /** This function performs all the image processinf steps corresponding to the given ProcessingJob. It runs in the background, thus it returns immediately, * When it finishes, it calls the BatchProcessingListener with the resulting image and asks for the next job. It the listener gives a new job, it goes on diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index f2a6b4e8a..ea755b3c2 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -941,6 +941,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p bool locutili = false; bool locallutili = false; + bool localcutili = false; if (params.locallab.enabled) { MyTime t1, t2; @@ -965,6 +966,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p LocretigainCurverab locRETgainCurverab; LUTf lllocalcurve (65536, 0); + LUTf cclocalcurve (65536, 0); int realspot = params.locallab.nbspot; int maxspot = settings->nspot + 1; @@ -1028,10 +1030,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p std::string *llstrs; llstrs = new std::string[maxspot]; - std::string *lhstrs; + std::string *lhstrs; lhstrs = new std::string[maxspot]; + std::string *ccstrs; + ccstrs = new std::string[maxspot]; + { dataspots[2][0] = params.locallab.circrad; dataspots[3][0] = params.locallab.locX; @@ -1197,6 +1202,29 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p llstrs[0] = ll_str + "@"; + int sizc = params.locallab.cccurve.size(); + + if (sizc > 69) { + sizc = 69; + } + + int s_curc[sizc + 1]; + int s_datcurc[sizc + 1]; + + for (int j = 0; j < sizc; j++) { + s_datcurc[j] = (int) (1000. * params.locallab.cccurve[j]); + } + + std::string cc_str = ""; + + for (int j = 0; j < sizc; j++) { + cc_str = cc_str + std::to_string (s_datcurc[j]) + delim[j]; + } + + ccstrs[0] = cc_str + "@"; + + // + int sizh = params.locallab.LHcurve.size(); if (sizh > 69) { @@ -1234,6 +1262,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p int sizecu; int sizell; int sizelh; + int sizecc; while (getline (fich, line)) { spotline = line; @@ -1325,6 +1354,24 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p //printf("lecture strLH=%s ns=%i si=%i\n", lhstr[ns].c_str(), ns, sizelh); } + if (spotline.substr (0, pos) == "curveCC") { + std::string curstrc; + int longecurc; + std::string strendc = spotline.substr (posend - 1, 1); + std::size_t poszc = spotline.find (strendc); + int longec; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendc) { + longec = sh + 1; + } + } + + ccstrs[ns] = str3; + sizecc = longec; + //printf("lecture strCC=%s ns=%i si=%i\n", ccstr[ns].c_str(), ns, sizecc); + } + } fich.close(); @@ -1484,6 +1531,20 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p delete [] s_datcl; + int *s_datcc; + s_datcc = new int[70]; + int sizc; + + ipf.strcurv_data (ccstrs[sp], s_datcc, sizc); + + + std::vector cccend; + + for (int j = 0; j < sizc; j++) { + cccend.push_back ((double) (s_datcc[j]) / 1000.); + } + + delete [] s_datcc; int *s_datch; s_datch = new int[70]; @@ -1502,19 +1563,26 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p params.locallab.localTgaincurve.clear(); params.locallab.llcurve.clear(); params.locallab.LHcurve.clear(); + params.locallab.cccurve.clear(); params.locallab.localTgaincurve = cretiend; params.locallab.llcurve = cllend; params.locallab.LHcurve = clhend; + params.locallab.cccurve = cccend; params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); bool locallutili = false; - CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, 1); + bool localcutili = false; - ipf.Lab_Local (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, 1); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, 1); + + ipf.Lab_Local (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve.clear(); + cclocalcurve.clear(); + } @@ -1531,6 +1599,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p delete [] retistrs; delete [] llstrs; delete [] lhstrs; + delete [] ccstrs; if (params.locallab.inverssha) { diff --git a/rtgui/edit.cc b/rtgui/edit.cc index 58d856bb5..3e9d298d7 100644 --- a/rtgui/edit.cc +++ b/rtgui/edit.cc @@ -20,7 +20,7 @@ #include "edit.h" #include "rtimage.h" -ObjectMOBuffer::ObjectMOBuffer(EditDataProvider *dataProvider) : objectMap(nullptr), objectMode(OM_255), dataProvider(dataProvider) {} +ObjectMOBuffer::ObjectMOBuffer (EditDataProvider *dataProvider) : objectMap (nullptr), objectMode (OM_255), dataProvider (dataProvider) {} ObjectMOBuffer::~ObjectMOBuffer() { @@ -29,7 +29,7 @@ ObjectMOBuffer::~ObjectMOBuffer() /* Upgrade or downgrade the objectModeType */ -void ObjectMOBuffer::setObjectMode(ObjectMode newType) +void ObjectMOBuffer::setObjectMode (ObjectMode newType) { if (!objectMap) { objectMode = newType; @@ -38,23 +38,27 @@ void ObjectMOBuffer::setObjectMode(ObjectMode newType) int w = objectMap->get_width (); int h = objectMap->get_height (); + if (w && h) { switch (newType) { - case (OM_255): - if (objectMode==OM_65535) { - objectMap->unreference(); - objectMap = Cairo::ImageSurface::create(Cairo::FORMAT_A8, w, h); - } - break; + case (OM_255): + if (objectMode == OM_65535) { + objectMap->unreference(); + objectMap = Cairo::ImageSurface::create (Cairo::FORMAT_A8, w, h); + } - case (OM_65535): - if (objectMode==OM_255) { - objectMap->unreference(); - objectMap = Cairo::ImageSurface::create(Cairo::FORMAT_RGB16_565, w, h); - } - break; + break; + + case (OM_65535): + if (objectMode == OM_255) { + objectMap->unreference(); + objectMap = Cairo::ImageSurface::create (Cairo::FORMAT_RGB16_565, w, h); + } + + break; } } + objectMode = newType; } @@ -65,7 +69,8 @@ void ObjectMOBuffer::flush() } } -EditSubscriber *ObjectMOBuffer::getEditSubscriber () { +EditSubscriber *ObjectMOBuffer::getEditSubscriber () +{ if (dataProvider) { return dataProvider->getCurrSubscriber(); } else { @@ -75,7 +80,7 @@ EditSubscriber *ObjectMOBuffer::getEditSubscriber () { // Resize buffers if they already exist -void ObjectMOBuffer::resize(int newWidth, int newHeight) +void ObjectMOBuffer::resize (int newWidth, int newHeight) { if (!dataProvider) { return; @@ -87,8 +92,8 @@ void ObjectMOBuffer::resize(int newWidth, int newHeight) objectMap.clear(); } - if (!objectMap && newWidth>0 && newHeight>0) { - objectMap = Cairo::ImageSurface::create(objectMode==OM_255?Cairo::FORMAT_A8:Cairo::FORMAT_RGB16_565, newWidth, newHeight); + if (!objectMap && newWidth > 0 && newHeight > 0) { + objectMap = Cairo::ImageSurface::create (objectMode == OM_255 ? Cairo::FORMAT_A8 : Cairo::FORMAT_RGB16_565, newWidth, newHeight); } } else { @@ -99,7 +104,7 @@ void ObjectMOBuffer::resize(int newWidth, int newHeight) } } -int ObjectMOBuffer::getObjectID(const rtengine::Coord& location) +int ObjectMOBuffer::getObjectID (const rtengine::Coord& location) { int id = 0; @@ -108,9 +113,9 @@ int ObjectMOBuffer::getObjectID(const rtengine::Coord& location) } if (objectMode == OM_255) { - id = (unsigned char)(*( objectMap->get_data() + location.y * objectMap->get_stride() + location.x )); + id = (unsigned char) (* ( objectMap->get_data() + location.y * objectMap->get_stride() + location.x )); } else { - id = (unsigned short)(*( objectMap->get_data() + location.y * objectMap->get_stride() + location.x )); + id = (unsigned short) (* ( objectMap->get_data() + location.y * objectMap->get_stride() + location.x )); } return id - 1; @@ -121,7 +126,7 @@ bool ObjectMOBuffer::bufferCreated() EditSubscriber* subscriber; if (dataProvider && (subscriber = dataProvider->getCurrSubscriber())) { - return subscriber->getEditingType() == ET_OBJECTS ? bool(objectMap) : false; + return subscriber->getEditingType() == ET_OBJECTS ? bool (objectMap) : false; } return false; @@ -166,7 +171,7 @@ RGBColor Geometry::getOuterLineColor () return color; } -void Circle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Circle::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && state != INSENSITIVE) { RGBColor color; @@ -178,10 +183,10 @@ void Circle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer } cr->set_source_rgb (color.getR(), color.getG(), color.getB()); - cr->set_line_width( getOuterLineWidth() ); + cr->set_line_width ( getOuterLineWidth() ); rtengine::Coord center_ = center; - double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas(double(radius)) : double(radius); + double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius)) : double (radius); if (datum == IMAGE) { coordSystem.imageCoordToScreen (center.x, center.y, center_.x, center_.y); @@ -191,12 +196,12 @@ void Circle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; } - cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*M_PI); + cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*M_PI); cr->stroke(); } } -void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Circle::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_VISIBLE) { if (state != INSENSITIVE) { @@ -208,13 +213,13 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer color = innerLineColor; } - cr->set_source_rgb(color.getR(), color.getG(), color.getB()); + cr->set_source_rgb (color.getR(), color.getG(), color.getB()); } - cr->set_line_width( innerLineWidth ); + cr->set_line_width ( innerLineWidth ); rtengine::Coord center_ = center; - double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas(double(radius)) : double(radius); + double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius)) : double (radius); if (datum == IMAGE) { coordSystem.imageCoordToScreen (center.x, center.y, center_.x, center_.y); @@ -225,7 +230,7 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer } if (filled && state != INSENSITIVE) { - cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*M_PI); + cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*M_PI); if (innerLineWidth > 0.) { cr->fill_preserve(); @@ -234,18 +239,18 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer cr->fill(); } } else if (innerLineWidth > 0.) { - cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*M_PI); + cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*M_PI); if (state == INSENSITIVE) { - std::valarray ds(1); + std::valarray ds (1); ds[0] = 4; - cr->set_source_rgba(1.0, 1.0, 1.0, 0.618); + cr->set_source_rgba (1.0, 1.0, 1.0, 0.618); cr->stroke_preserve(); - cr->set_source_rgba(0.0, 0.0, 0.0, 0.618); - cr->set_dash(ds, 0); + cr->set_source_rgba (0.0, 0.0, 0.0, 0.618); + cr->set_dash (ds, 0); cr->stroke(); - ds.resize(0); - cr->set_dash(ds, 0); + ds.resize (0); + cr->set_dash (ds, 0); } else { cr->stroke(); } @@ -256,9 +261,9 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer void Circle::drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_HOVERABLE) { - cr->set_line_width( getMouseOverLineWidth() ); + cr->set_line_width ( getMouseOverLineWidth() ); rtengine::Coord center_ = center; - double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas(double(radius)) : double(radius); + double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius)) : double (radius); if (datum == IMAGE) { coordSystem.imageCoordToCropCanvas (center.x, center.y, center_.x, center_.y); @@ -274,7 +279,8 @@ void Circle::drawToMOChannel (Cairo::RefPtr &cr, unsigned short } else { cr->set_source_rgba (0., 0., 0., (id + 1) / 65535.); } - cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0, 2.*M_PI); + + cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, 0, 2.*M_PI); if (filled) { if (innerLineWidth > 0.) { @@ -289,7 +295,7 @@ void Circle::drawToMOChannel (Cairo::RefPtr &cr, unsigned short } } -void Line::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Line::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && state != INSENSITIVE) { RGBColor color; @@ -301,7 +307,7 @@ void Line::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * } cr->set_source_rgb (color.getR(), color.getG(), color.getB()); - cr->set_line_width( getOuterLineWidth() ); + cr->set_line_width ( getOuterLineWidth() ); rtengine::Coord begin_ = begin; rtengine::Coord end_ = end; @@ -317,13 +323,13 @@ void Line::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * end_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; } - cr->move_to(begin_.x + 0.5, begin_.y + 0.5); - cr->line_to(end_.x + 0.5, end_.y + 0.5); + cr->move_to (begin_.x + 0.5, begin_.y + 0.5); + cr->line_to (end_.x + 0.5, end_.y + 0.5); cr->stroke(); } } -void Line::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Line::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && innerLineWidth > 0.) { if (state != INSENSITIVE) { @@ -338,7 +344,7 @@ void Line::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * cr->set_source_rgb (color.getR(), color.getG(), color.getB()); } - cr->set_line_width(innerLineWidth); + cr->set_line_width (innerLineWidth); rtengine::Coord begin_ = begin; rtengine::Coord end_ = end; @@ -354,29 +360,29 @@ void Line::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * end_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; } - cr->move_to(begin_.x + 0.5, begin_.y + 0.5); - cr->line_to(end_.x + 0.5, end_.y + 0.5); + cr->move_to (begin_.x + 0.5, begin_.y + 0.5); + cr->line_to (end_.x + 0.5, end_.y + 0.5); if (state == INSENSITIVE) { - std::valarray ds(1); + std::valarray ds (1); ds[0] = 4; - cr->set_source_rgba(1.0, 1.0, 1.0, 0.618); + cr->set_source_rgba (1.0, 1.0, 1.0, 0.618); cr->stroke_preserve(); - cr->set_source_rgba(0.0, 0.0, 0.0, 0.618); - cr->set_dash(ds, 0); + cr->set_source_rgba (0.0, 0.0, 0.0, 0.618); + cr->set_dash (ds, 0); cr->stroke(); - ds.resize(0); - cr->set_dash(ds, 0); + ds.resize (0); + cr->set_dash (ds, 0); } else { cr->stroke(); } } } -void Line::drawToMOChannel(Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Line::drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_HOVERABLE) { - cr->set_line_width( getMouseOverLineWidth() ); + cr->set_line_width ( getMouseOverLineWidth() ); rtengine::Coord begin_ = begin; rtengine::Coord end_ = end; @@ -397,13 +403,14 @@ void Line::drawToMOChannel(Cairo::RefPtr &cr, unsigned short id, } else { cr->set_source_rgba (0., 0., 0., (id + 1) / 65535.); } - cr->move_to(begin_.x + 0.5, begin_.y + 0.5); - cr->line_to(end_.x + 0.5, end_.y + 0.5); + + cr->move_to (begin_.x + 0.5, begin_.y + 0.5); + cr->line_to (end_.x + 0.5, end_.y + 0.5); cr->stroke(); } } -void Polyline::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Polyline::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && state != INSENSITIVE && points.size() > 1) { RGBColor color; @@ -415,15 +422,15 @@ void Polyline::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuff } cr->set_source_rgb (color.getR(), color.getG(), color.getB()); - cr->set_line_width( getOuterLineWidth() ); + cr->set_line_width ( getOuterLineWidth() ); rtengine::Coord currPos; for (unsigned int i = 0; i < points.size(); ++i) { - currPos = points.at(i); + currPos = points.at (i); if (datum == IMAGE) { - coordSystem.imageCoordToScreen (points.at(i).x, points.at(i).y, currPos.x, currPos.y); + coordSystem.imageCoordToScreen (points.at (i).x, points.at (i).y, currPos.x, currPos.y); } else if (datum == CLICKED_POINT) { currPos += objectBuffer->getDataProvider()->posScreen; } else if (datum == CURSOR) { @@ -431,9 +438,9 @@ void Polyline::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuff } if (!i) { - cr->move_to(currPos.x + 0.5, currPos.y + 0.5); + cr->move_to (currPos.x + 0.5, currPos.y + 0.5); } else { - cr->line_to(currPos.x + 0.5, currPos.y + 0.5); + cr->line_to (currPos.x + 0.5, currPos.y + 0.5); } } @@ -446,7 +453,7 @@ void Polyline::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuff } } -void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Polyline::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && points.size() > 1) { if (state != INSENSITIVE) { @@ -461,16 +468,16 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff cr->set_source_rgb (color.getR(), color.getG(), color.getB()); } - cr->set_line_width( innerLineWidth ); + cr->set_line_width ( innerLineWidth ); if (filled && state != INSENSITIVE) { rtengine::Coord currPos; for (unsigned int i = 0; i < points.size(); ++i) { - currPos = points.at(i); + currPos = points.at (i); if (datum == IMAGE) { - coordSystem.imageCoordToScreen (points.at(i).x, points.at(i).y, currPos.x, currPos.y); + coordSystem.imageCoordToScreen (points.at (i).x, points.at (i).y, currPos.x, currPos.y); } else if (datum == CLICKED_POINT) { currPos += objectBuffer->getDataProvider()->posScreen; } else if (datum == CURSOR) { @@ -478,9 +485,9 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff } if (!i) { - cr->move_to(currPos.x + 0.5, currPos.y + 0.5); + cr->move_to (currPos.x + 0.5, currPos.y + 0.5); } else { - cr->line_to(currPos.x + 0.5, currPos.y + 0.5); + cr->line_to (currPos.x + 0.5, currPos.y + 0.5); } } @@ -494,10 +501,10 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff rtengine::Coord currPos; for (unsigned int i = 0; i < points.size(); ++i) { - currPos = points.at(i); + currPos = points.at (i); if (datum == IMAGE) { - coordSystem.imageCoordToScreen (points.at(i).x, points.at(i).y, currPos.x, currPos.y); + coordSystem.imageCoordToScreen (points.at (i).x, points.at (i).y, currPos.x, currPos.y); } else if (datum == CLICKED_POINT) { currPos += objectBuffer->getDataProvider()->posScreen; } else if (datum == CURSOR) { @@ -505,22 +512,22 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff } if (!i) { - cr->move_to(currPos.x + 0.5, currPos.y + 0.5); + cr->move_to (currPos.x + 0.5, currPos.y + 0.5); } else { - cr->line_to(currPos.x + 0.5, currPos.y + 0.5); + cr->line_to (currPos.x + 0.5, currPos.y + 0.5); } } if (state == INSENSITIVE) { - std::valarray ds(1); + std::valarray ds (1); ds[0] = 4; - cr->set_source_rgba(1.0, 1.0, 1.0, 0.618); + cr->set_source_rgba (1.0, 1.0, 1.0, 0.618); cr->stroke_preserve(); - cr->set_source_rgba(0.0, 0.0, 0.0, 0.618); - cr->set_dash(ds, 0); + cr->set_source_rgba (0.0, 0.0, 0.0, 0.618); + cr->set_dash (ds, 0); cr->stroke(); - ds.resize(0); - cr->set_dash(ds, 0); + ds.resize (0); + cr->set_dash (ds, 0); } else { cr->stroke(); } @@ -541,11 +548,11 @@ void Polyline::drawToMOChannel (Cairo::RefPtr &cr, unsigned shor } for (unsigned int i = 0; i < points.size(); ++i) { - cr->set_line_width( getMouseOverLineWidth() ); - currPos = points.at(i); + cr->set_line_width ( getMouseOverLineWidth() ); + currPos = points.at (i); if (datum == IMAGE) { - coordSystem.imageCoordToCropCanvas (points.at(i).x, points.at(i).y, currPos.x, currPos.y); + coordSystem.imageCoordToCropCanvas (points.at (i).x, points.at (i).y, currPos.x, currPos.y); } else if (datum == CLICKED_POINT) { currPos += objectBuffer->getDataProvider()->posScreen; } else if (datum == CURSOR) { @@ -553,9 +560,9 @@ void Polyline::drawToMOChannel (Cairo::RefPtr &cr, unsigned shor } if (!i) { - cr->move_to(currPos.x + 0.5, currPos.y + 0.5); + cr->move_to (currPos.x + 0.5, currPos.y + 0.5); } else { - cr->line_to(currPos.x + 0.5, currPos.y + 0.5); + cr->line_to (currPos.x + 0.5, currPos.y + 0.5); } } @@ -572,31 +579,31 @@ void Polyline::drawToMOChannel (Cairo::RefPtr &cr, unsigned shor } } -void Rectangle::setXYWH(int left, int top, int width, int height) +void Rectangle::setXYWH (int left, int top, int width, int height) { - topLeft.set(left, top); - bottomRight.set(left + width, top + height); + topLeft.set (left, top); + bottomRight.set (left + width, top + height); } -void Rectangle::setXYXY(int left, int top, int right, int bottom) +void Rectangle::setXYXY (int left, int top, int right, int bottom) { - topLeft.set(left, top); - bottomRight.set(right, bottom); + topLeft.set (left, top); + bottomRight.set (right, bottom); } -void Rectangle::setXYWH(rtengine::Coord topLeft, rtengine::Coord widthHeight) +void Rectangle::setXYWH (rtengine::Coord topLeft, rtengine::Coord widthHeight) { this->topLeft = topLeft; this->bottomRight = topLeft + widthHeight; } -void Rectangle::setXYXY(rtengine::Coord topLeft, rtengine::Coord bottomRight) +void Rectangle::setXYXY (rtengine::Coord topLeft, rtengine::Coord bottomRight) { this->topLeft = topLeft; this->bottomRight = bottomRight; } -void Rectangle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Rectangle::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && state != INSENSITIVE) { RGBColor color; @@ -608,7 +615,7 @@ void Rectangle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuf } cr->set_source_rgb (color.getR(), color.getG(), color.getB()); - cr->set_line_width( getOuterLineWidth() ); + cr->set_line_width ( getOuterLineWidth() ); rtengine::Coord tl, br; @@ -628,7 +635,7 @@ void Rectangle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuf br = bottomRight + objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; } - cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); + cr->rectangle (tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (filled) { cr->fill_preserve(); @@ -639,7 +646,7 @@ void Rectangle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuf } } -void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Rectangle::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_VISIBLE) { if (state != INSENSITIVE) { @@ -654,7 +661,7 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf cr->set_source_rgb (color.getR(), color.getG(), color.getB()); } - cr->set_line_width( innerLineWidth ); + cr->set_line_width ( innerLineWidth ); rtengine::Coord tl, br; @@ -675,7 +682,7 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf } if (filled && state != INSENSITIVE) { - cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); + cr->rectangle (tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (innerLineWidth > 0.) { cr->fill_preserve(); @@ -684,18 +691,18 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf cr->fill(); } } else if (innerLineWidth > 0.) { - cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); + cr->rectangle (tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (state == INSENSITIVE) { - std::valarray ds(1); + std::valarray ds (1); ds[0] = 4; - cr->set_source_rgba(1.0, 1.0, 1.0, 0.618); + cr->set_source_rgba (1.0, 1.0, 1.0, 0.618); cr->stroke_preserve(); - cr->set_source_rgba(0.0, 0.0, 0.0, 0.618); - cr->set_dash(ds, 0); + cr->set_source_rgba (0.0, 0.0, 0.0, 0.618); + cr->set_dash (ds, 0); cr->stroke(); - ds.resize(0); - cr->set_dash(ds, 0); + ds.resize (0); + cr->set_dash (ds, 0); } else { cr->stroke(); } @@ -703,10 +710,10 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf } } -void Rectangle::drawToMOChannel(Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void Rectangle::drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_HOVERABLE) { - cr->set_line_width( getMouseOverLineWidth() ); + cr->set_line_width ( getMouseOverLineWidth() ); rtengine::Coord tl, br; @@ -732,7 +739,8 @@ void Rectangle::drawToMOChannel(Cairo::RefPtr &cr, unsigned shor } else { cr->set_source_rgba (0., 0., 0., (id + 1) / 65535.); } - cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); + + cr->rectangle (tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (filled) { if (innerLineWidth > 0.) { @@ -747,67 +755,67 @@ void Rectangle::drawToMOChannel(Cairo::RefPtr &cr, unsigned shor } } -void OPIcon::drivenPointToRectangle(const rtengine::Coord &pos, - rtengine::Coord &topLeft, rtengine::Coord &bottomRight, int W, int H) +void OPIcon::drivenPointToRectangle (const rtengine::Coord &pos, + rtengine::Coord &topLeft, rtengine::Coord &bottomRight, int W, int H) { switch (drivenPoint) { - case (DP_CENTERCENTER): - topLeft.x = pos.x - W / 2; - topLeft.y = pos.y - H / 2; - break; + case (DP_CENTERCENTER): + topLeft.x = pos.x - W / 2; + topLeft.y = pos.y - H / 2; + break; - case (DP_TOPLEFT): - topLeft.x = pos.x; - topLeft.y = pos.y; - break; + case (DP_TOPLEFT): + topLeft.x = pos.x; + topLeft.y = pos.y; + break; - case (DP_TOPCENTER): - topLeft.x = pos.x - W / 2; - topLeft.y = pos.y; - break; + case (DP_TOPCENTER): + topLeft.x = pos.x - W / 2; + topLeft.y = pos.y; + break; - case (DP_TOPRIGHT): - topLeft.x = pos.x - W; - topLeft.y = pos.y; - break; + case (DP_TOPRIGHT): + topLeft.x = pos.x - W; + topLeft.y = pos.y; + break; - case (DP_CENTERRIGHT): - topLeft.x = pos.x - W; - topLeft.y = pos.y - H / 2; - break; + case (DP_CENTERRIGHT): + topLeft.x = pos.x - W; + topLeft.y = pos.y - H / 2; + break; - case (DP_BOTTOMRIGHT): - topLeft.x = pos.x - W; - topLeft.y = pos.y - H; - break; + case (DP_BOTTOMRIGHT): + topLeft.x = pos.x - W; + topLeft.y = pos.y - H; + break; - case (DP_BOTTOMCENTER): - topLeft.x = pos.x - W / 2; - topLeft.y = pos.y - H; - break; + case (DP_BOTTOMCENTER): + topLeft.x = pos.x - W / 2; + topLeft.y = pos.y - H; + break; - case (DP_BOTTOMLEFT): - topLeft.x = pos.x; - topLeft.y = pos.y - H; - break; + case (DP_BOTTOMLEFT): + topLeft.x = pos.x; + topLeft.y = pos.y - H; + break; - case (DP_CENTERLEFT): - topLeft.x = pos.x; - topLeft.y = pos.y - H / 2; - break; + case (DP_CENTERLEFT): + topLeft.x = pos.x; + topLeft.y = pos.y - H / 2; + break; } bottomRight.x = topLeft.x + W - 1; bottomRight.y = topLeft.y + H - 1; } -OPIcon::OPIcon(const Cairo::RefPtr &normal, - const Cairo::RefPtr &active, - const Cairo::RefPtr &prelight, - const Cairo::RefPtr &dragged, - const Cairo::RefPtr &insensitive, - DrivenPoint drivenPoint) : - drivenPoint(drivenPoint) +OPIcon::OPIcon (const Cairo::RefPtr &normal, + const Cairo::RefPtr &active, + const Cairo::RefPtr &prelight, + const Cairo::RefPtr &dragged, + const Cairo::RefPtr &insensitive, + DrivenPoint drivenPoint) : + drivenPoint (drivenPoint) { if (normal) { normalImg = normal; @@ -830,27 +838,27 @@ OPIcon::OPIcon(const Cairo::RefPtr &normal, } } -OPIcon::OPIcon(Glib::ustring normalImage, Glib::ustring activeImage, Glib::ustring prelightImage, - Glib::ustring draggedImage, Glib::ustring insensitiveImage, DrivenPoint drivenPoint) : drivenPoint(drivenPoint) +OPIcon::OPIcon (Glib::ustring normalImage, Glib::ustring activeImage, Glib::ustring prelightImage, + Glib::ustring draggedImage, Glib::ustring insensitiveImage, DrivenPoint drivenPoint) : drivenPoint (drivenPoint) { if (!normalImage.empty()) { - normalImg = Cairo::ImageSurface::create_from_png( RTImage::findIconAbsolutePath(normalImage) ); + normalImg = Cairo::ImageSurface::create_from_png ( RTImage::findIconAbsolutePath (normalImage) ); } if (!prelightImage.empty()) { - prelightImg = Cairo::ImageSurface::create_from_png( RTImage::findIconAbsolutePath(prelightImage) ); + prelightImg = Cairo::ImageSurface::create_from_png ( RTImage::findIconAbsolutePath (prelightImage) ); } if (!activeImage.empty()) { - activeImg = Cairo::ImageSurface::create_from_png( RTImage::findIconAbsolutePath(activeImage) ); + activeImg = Cairo::ImageSurface::create_from_png ( RTImage::findIconAbsolutePath (activeImage) ); } if (!draggedImage.empty()) { - draggedImg = Cairo::ImageSurface::create_from_png( RTImage::findIconAbsolutePath(draggedImage) ); + draggedImg = Cairo::ImageSurface::create_from_png ( RTImage::findIconAbsolutePath (draggedImage) ); } if (!insensitiveImage.empty()) { - insensitiveImg = Cairo::ImageSurface::create_from_png( RTImage::findIconAbsolutePath(insensitiveImage) ); + insensitiveImg = Cairo::ImageSurface::create_from_png ( RTImage::findIconAbsolutePath (insensitiveImage) ); } } @@ -875,9 +883,9 @@ const Cairo::RefPtr OPIcon::getInsensitiveImg() return insensitiveImg; } -void OPIcon::drawImage(const Cairo::RefPtr &img, - Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, - EditCoordSystem &coordSystem) +void OPIcon::drawImage (const Cairo::RefPtr &img, + Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, + EditCoordSystem &coordSystem) { int imgW = img->get_width(); int imgH = img->get_height(); @@ -885,7 +893,7 @@ void OPIcon::drawImage(const Cairo::RefPtr &img, rtengine::Coord pos; if (datum == IMAGE) { - coordSystem.imageCoordToScreen(position.x, position.y, pos.x, pos.y); + coordSystem.imageCoordToScreen (position.x, position.y, pos.x, pos.y); } else if (datum == CLICKED_POINT) { pos = position + objectBuffer->getDataProvider()->posScreen; } else if (datum == CURSOR) @@ -893,16 +901,16 @@ void OPIcon::drawImage(const Cairo::RefPtr &img, + objectBuffer->getDataProvider()->deltaScreen; rtengine::Coord tl, br; // Coordinate of the rectangle in the CropBuffer coordinate system - drivenPointToRectangle(pos, tl, br, imgW, imgH); + drivenPointToRectangle (pos, tl, br, imgW, imgH); - cr->set_source(img, tl.x, tl.y); - cr->set_line_width(0.); - cr->rectangle(tl.x, tl.y, imgW, imgH); + cr->set_source (img, tl.x, tl.y); + cr->set_line_width (0.); + cr->rectangle (tl.x, tl.y, imgW, imgH); cr->fill(); } -void OPIcon::drawMOImage(const Cairo::RefPtr &img, Cairo::RefPtr &cr, - unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void OPIcon::drawMOImage (const Cairo::RefPtr &img, Cairo::RefPtr &cr, + unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { // test of F_HOVERABLE has already been done @@ -911,16 +919,16 @@ void OPIcon::drawMOImage(const Cairo::RefPtr &img, Cairo::R rtengine::Coord pos; - if (datum == IMAGE) + if (datum == IMAGE) { coordSystem.imageCoordToCropCanvas (position.x, position.y, pos.x, pos.y); - else if (datum == CLICKED_POINT) { + } else if (datum == CLICKED_POINT) { pos = position + objectBuffer->getDataProvider()->posScreen; } else if (datum == CURSOR) pos = position + objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; rtengine::Coord tl, br; // Coordinate of the rectangle in the CropBuffer coordinate system - drivenPointToRectangle(pos, tl, br, imgW, imgH); + drivenPointToRectangle (pos, tl, br, imgW, imgH); // drawing the lower byte's value if (objectBuffer->getObjectMode() == OM_255) { @@ -928,16 +936,17 @@ void OPIcon::drawMOImage(const Cairo::RefPtr &img, Cairo::R } else { cr->set_source_rgba (0., 0., 0., (id + 1) / 65535.); } - cr->set_line_width(0.); - cr->rectangle(tl.x, tl.y, imgW, imgH); + + cr->set_line_width (0.); + cr->rectangle (tl.x, tl.y, imgW, imgH); cr->fill(); } -void OPIcon::drawOuterGeometry(Cairo::RefPtr &cr, - ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) {} +void OPIcon::drawOuterGeometry (Cairo::RefPtr &cr, + ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) {} -void OPIcon::drawInnerGeometry(Cairo::RefPtr &cr, - ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void OPIcon::drawInnerGeometry (Cairo::RefPtr &cr, + ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_VISIBLE) { // Here we will handle fall-back solutions @@ -948,7 +957,7 @@ void OPIcon::drawInnerGeometry(Cairo::RefPtr &cr, if (!insensitiveImg) { tmpState = NORMAL; } else { - OPIcon::drawImage(insensitiveImg, cr, objectBuffer, coordSystem); + OPIcon::drawImage (insensitiveImg, cr, objectBuffer, coordSystem); return; } } @@ -957,7 +966,7 @@ void OPIcon::drawInnerGeometry(Cairo::RefPtr &cr, if (!draggedImg) { tmpState = ACTIVE; } else { - OPIcon::drawImage(draggedImg, cr, objectBuffer, coordSystem); + OPIcon::drawImage (draggedImg, cr, objectBuffer, coordSystem); return; } } @@ -966,7 +975,7 @@ void OPIcon::drawInnerGeometry(Cairo::RefPtr &cr, if (!activeImg) { tmpState = PRELIGHT; } else { - OPIcon::drawImage(activeImg, cr, objectBuffer, coordSystem); + OPIcon::drawImage (activeImg, cr, objectBuffer, coordSystem); return; } } @@ -975,19 +984,19 @@ void OPIcon::drawInnerGeometry(Cairo::RefPtr &cr, if (!prelightImg) { tmpState = NORMAL; } else { - OPIcon::drawImage(prelightImg, cr, objectBuffer, coordSystem); + OPIcon::drawImage (prelightImg, cr, objectBuffer, coordSystem); return; } } if (tmpState == NORMAL && normalImg) { - OPIcon::drawImage(normalImg, cr, objectBuffer, coordSystem); + OPIcon::drawImage (normalImg, cr, objectBuffer, coordSystem); } } } -void OPIcon::drawToMOChannel(Cairo::RefPtr &cr, unsigned short id, - ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +void OPIcon::drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, + ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if (flags & F_HOVERABLE) { // Here we will handle fallback solutions @@ -997,7 +1006,7 @@ void OPIcon::drawToMOChannel(Cairo::RefPtr &cr, unsigned short i if (!insensitiveImg) { tmpState = NORMAL; } else { - OPIcon::drawMOImage(insensitiveImg, cr, id, objectBuffer, coordSystem); + OPIcon::drawMOImage (insensitiveImg, cr, id, objectBuffer, coordSystem); return; } } @@ -1006,7 +1015,7 @@ void OPIcon::drawToMOChannel(Cairo::RefPtr &cr, unsigned short i if (!draggedImg) { tmpState = ACTIVE; } else { - OPIcon::drawMOImage(draggedImg, cr, id, objectBuffer, coordSystem); + OPIcon::drawMOImage (draggedImg, cr, id, objectBuffer, coordSystem); return; } } @@ -1015,7 +1024,7 @@ void OPIcon::drawToMOChannel(Cairo::RefPtr &cr, unsigned short i if (!activeImg) { tmpState = PRELIGHT; } else { - OPIcon::drawMOImage(activeImg, cr, id, objectBuffer, coordSystem); + OPIcon::drawMOImage (activeImg, cr, id, objectBuffer, coordSystem); return; } } @@ -1024,25 +1033,25 @@ void OPIcon::drawToMOChannel(Cairo::RefPtr &cr, unsigned short i if (!prelightImg) { tmpState = NORMAL; } else { - OPIcon::drawMOImage(prelightImg, cr, id, objectBuffer, coordSystem); + OPIcon::drawMOImage (prelightImg, cr, id, objectBuffer, coordSystem); return; } } if (tmpState == NORMAL && normalImg) { - OPIcon::drawMOImage(normalImg, cr, id, objectBuffer, coordSystem); + OPIcon::drawMOImage (normalImg, cr, id, objectBuffer, coordSystem); } } } -EditSubscriber::EditSubscriber (EditType editType) : ID(EUID_None), editingType(editType), bufferType(BT_SINGLEPLANE_FLOAT), provider(nullptr), action(ES_ACTION_NONE) {} +EditSubscriber::EditSubscriber (EditType editType) : ID (EUID_None), editingType (editType), bufferType (BT_SINGLEPLANE_FLOAT), provider (nullptr), action (ES_ACTION_NONE) {} -void EditSubscriber::setEditProvider(EditDataProvider *provider) +void EditSubscriber::setEditProvider (EditDataProvider *provider) { this->provider = provider; } -void EditSubscriber::setEditID(EditUniqueID ID, BufferType buffType) +void EditSubscriber::setEditID (EditUniqueID ID, BufferType buffType) { this->ID = ID; bufferType = buffType; @@ -1063,7 +1072,7 @@ bool EditSubscriber::isCurrentSubscriber() void EditSubscriber::subscribe() { if (provider) { - provider->subscribe(this); + provider->subscribe (this); } } @@ -1107,13 +1116,13 @@ bool EditSubscriber::isPicking() //-------------------------------------------------------------------------------------------------- -EditDataProvider::EditDataProvider() : currSubscriber(nullptr), object(0), posScreen(-1, -1), posImage(-1, -1), - deltaScreen(0, 0), deltaImage(0, 0), deltaPrevScreen(0, 0), deltaPrevImage(0, 0) +EditDataProvider::EditDataProvider() : currSubscriber (nullptr), object (0), posScreen (-1, -1), posImage (-1, -1), + deltaScreen (0, 0), deltaImage (0, 0), deltaPrevScreen (0, 0), deltaPrevImage (0, 0) { pipetteVal[0] = pipetteVal[1] = pipetteVal[2] = 0.f; } -void EditDataProvider::subscribe(EditSubscriber *subscriber) +void EditDataProvider::subscribe (EditSubscriber *subscriber) { if (currSubscriber) { currSubscriber->switchOffEditMode(); @@ -1134,10 +1143,10 @@ void EditDataProvider::switchOffEditMode() } } -CursorShape EditDataProvider::getCursor(int objectID) +CursorShape EditDataProvider::getCursor (int objectID) { if (currSubscriber) { - currSubscriber->getCursor(objectID); + currSubscriber->getCursor (objectID); } return CSOpenHand; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 32da9a0bf..46bfad93e 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -171,6 +171,7 @@ Locallab::Locallab (): FoldableToolPanel (this, "locallab", M ("TP_LOCALLAB_LABE std::vector defaultCurve2; std::vector defaultCurve2rab; std::vector defaultCurve3; + std::vector defaultCurve4; irg = Gtk::manage (new RTImage ("Chanmixer-RG.png")); @@ -186,6 +187,14 @@ Locallab::Locallab (): FoldableToolPanel (this, "locallab", M ("TP_LOCALLAB_LABE llshape->setBottomBarBgGradient (milestones); llshape->setLeftBarBgGradient (milestones); + rtengine::LocallabParams::getDefaultCCCurve (defaultCurve4); + ccshape = static_cast (llCurveEditorG->addCurve (CT_Diagonal, "C(C)")); + ccshape->setResetCurve (DiagonalCurveType (defaultCurve4.at (0)), defaultCurve4); + ccshape->setTooltip (M ("TP_LOCALLAB_CURVEEDITOR_CC_TOOLTIP")); + milestones.push_back ( GradientMilestone (0., 0., 0., 0.) ); + milestones.push_back ( GradientMilestone (1., 1., 1., 1.) ); + ccshape->setBottomBarBgGradient (milestones); + ccshape->setLeftBarBgGradient (milestones); rtengine::LocallabParams::getDefaultLHCurve (defaultCurve3); @@ -909,6 +918,21 @@ bool Locallab::localretComputed_ () llshape->setCurve (cll); + + int *s_datcc; + s_datcc = new int[70]; + int sizc; + ImProcFunctions::strcurv_data (nextcc_str2, s_datcc, sizc); + std::vector ccc; + + for (int j = 0; j < sizc; j++) { + ccc.push_back ((double) (s_datcc[j]) / 1000.); + } + + delete [] s_datcc; + + ccshape->setCurve (ccc); + int *s_datch; s_datch = new int[70]; int sizh; @@ -986,6 +1010,10 @@ bool Locallab::localretComputed_ () listener->panelChanged (Evlocallabllshape, M ("HISTORY_CUSTOMCURVE")); } + if (listener) {//for curve + listener->panelChanged (Evlocallabccshape, M ("HISTORY_CUSTOMCURVE")); + } + if (listener) {//for curve listener->panelChanged (EvlocallabLHshape, M ("HISTORY_CUSTOMCURVE")); } @@ -1165,6 +1193,22 @@ bool Locallab::localComputed_ () delete [] s_datcl; llshape->setCurve (cll); + //CCcurv + int *s_datcc; + s_datcc = new int[70]; + int sizc; + ImProcFunctions::strcurv_data (nextcc_str, s_datcc, sizc); + + + std::vector ccc; + + for (int j = 0; j < sizc; j++) { + ccc.push_back ((double) (s_datcc[j]) / 1000.); + } + + delete [] s_datcc; + ccshape->setCurve (ccc); + //LHcurv int *s_datch; @@ -1289,10 +1333,14 @@ bool Locallab::localComputed_ () listener->panelChanged (EvlocallabLHshape, M ("HISTORY_CUSTOMCURVE")); } + if (listener) {//for curve LH + listener->panelChanged (Evlocallabccshape, M ("HISTORY_CUSTOMCURVE")); + } + return false; } -void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) +void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, int sp, int maxdat) { for (int i = 2; i < 60; i++) { //58 nextdatasp[i] = datasp[i][sp]; @@ -1301,17 +1349,19 @@ void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_ nextstr = datastr; nextll_str = ll_str; nextlh_str = lh_str; + nextcc_str = cc_str; nextlength = maxdat; g_idle_add (localChangedUI, this); } -void Locallab::localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) +void Locallab::localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, int sp, int maxdat) { nextlength = maxdat; nextstr2 = datastr; nextll_str2 = ll_str; nextlh_str2 = lh_str; + nextcc_str2 = cc_str; g_idle_add (localretChangedUI, this); } @@ -1389,6 +1439,7 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) inverssha->set_inconsistent (multiImage && !pedited->locallab.inverssha); cTgainshape->setUnChanged (!pedited->locallab.localTgaincurve); llshape->setUnChanged (!pedited->locallab.llcurve); + ccshape->setUnChanged (!pedited->locallab.cccurve); LHshape->setUnChanged (!pedited->locallab.LHcurve); inversret->set_inconsistent (multiImage && !pedited->locallab.inversret); cTgainshaperab->setUnChanged (!pedited->locallab.localTgaincurverab); @@ -1483,6 +1534,7 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) cTgainshape->setCurve (pp->locallab.localTgaincurve); cTgainshaperab->setCurve (pp->locallab.localTgaincurverab); llshape->setCurve (pp->locallab.llcurve); + ccshape->setCurve (pp->locallab.cccurve); LHshape->setCurve (pp->locallab.LHcurve); lastactivlum = pp->locallab.activlum; lastanbspot = pp->locallab.anbspot; @@ -1726,6 +1778,7 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) pp->locallab.localTgaincurve = cTgainshape->getCurve (); pp->locallab.localTgaincurverab = cTgainshaperab->getCurve (); pp->locallab.llcurve = llshape->getCurve (); + pp->locallab.cccurve = ccshape->getCurve (); pp->locallab.LHcurve = LHshape->getCurve (); pp->locallab.expcolor = expcolor->getEnabled(); pp->locallab.expblur = expblur->getEnabled(); @@ -1798,6 +1851,7 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) pedited->locallab.localTgaincurve = !cTgainshape->isUnChanged (); pedited->locallab.localTgaincurverab = !cTgainshaperab->isUnChanged (); pedited->locallab.llcurve = !llshape->isUnChanged (); + pedited->locallab.cccurve = !ccshape->isUnChanged (); pedited->locallab.LHcurve = !LHshape->isUnChanged (); pedited->locallab.expcolor = !expcolor->get_inconsistent(); pedited->locallab.expblur = !expblur->get_inconsistent(); @@ -1905,6 +1959,17 @@ void Locallab::curveChanged (CurveEditor* ce) adjusterChanged (retrab, strval); + } else if (ce == ccshape) { + listener->panelChanged (Evlocallabccshape, M ("HISTORY_CUSTOMCURVE")); + int strval = retrab->getValue(); + //update MIP + retrab->setValue (strval + 1); + adjusterChanged (retrab, strval + 1); + usleep (10000); //to test + retrab->setValue (strval); + + adjusterChanged (retrab, strval); + } } @@ -1912,9 +1977,11 @@ void Locallab::curveChanged (CurveEditor* ce) void Locallab::retinexMethodChanged() { - retrab->hide(); - LocalcurveEditorgainTrab->hide(); - // llCurveEditorG2->hide(); + if (!batchMode) { + + retrab->hide(); + LocalcurveEditorgainTrab->hide(); + } if (listener) { listener->panelChanged (EvlocallabretinexMethod, retinexMethod->get_active_text ()); @@ -2021,9 +2088,11 @@ void Locallab::inversChanged () if (invers->get_active ()) { sensi->hide(); llCurveEditorG->hide(); + curvactiv->hide(); } else { sensi->show(); llCurveEditorG->show(); + curvactiv->show(); } if (listener) { diff --git a/rtgui/locallab.h b/rtgui/locallab.h index c4202bff1..dd0042c86 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -119,6 +119,7 @@ protected: FlatCurveEditor* cTgainshaperab; CurveEditorGroup* llCurveEditorG; DiagonalCurveEditor* llshape; + DiagonalCurveEditor* ccshape; Gtk::Image* irg; FlatCurveEditor* LHshape; @@ -130,6 +131,8 @@ protected: std::string nextll_str2; std::string nextlh_str; std::string nextlh_str2; + std::string nextcc_str; + std::string nextcc_str2; double draggedPointOldAngle; double draggedPointAdjusterAngle; @@ -174,8 +177,8 @@ public: void inversshaChanged (); void curveChanged (CurveEditor* ce); void autoOpenCurve (); - void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat); - void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat); + void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, int sp, int maxdat); + void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, int sp, int maxdat); bool localComputed_ (); bool localretComputed_ (); void setEditProvider (EditDataProvider* provider); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index e4b5c12e0..53590db4a 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -354,6 +354,7 @@ void ParamsEdited::set (bool v) locallab.localTgaincurve = v; locallab.localTgaincurverab = v; locallab.llcurve = v; + locallab.cccurve = v; locallab.LHcurve = v; for (int i = 0; i < 5; i++) { @@ -914,6 +915,7 @@ void ParamsEdited::initFrom (const std::vector locallab.localTgaincurve = locallab.localTgaincurve && p.locallab.localTgaincurve == other.locallab.localTgaincurve; locallab.localTgaincurverab = locallab.localTgaincurverab && p.locallab.localTgaincurverab == other.locallab.localTgaincurverab; locallab.llcurve = locallab.llcurve && p.locallab.llcurve == other.locallab.llcurve; + locallab.cccurve = locallab.cccurve && p.locallab.cccurve == other.locallab.cccurve; locallab.LHcurve = locallab.LHcurve && p.locallab.LHcurve == other.locallab.LHcurve; locallab.expcolor = locallab.expcolor && p.locallab.expcolor == other.locallab.expcolor; locallab.expblur = locallab.expblur && p.locallab.expblur == other.locallab.expblur; @@ -2384,6 +2386,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.locallab.llcurve = mods.locallab.llcurve; } + if (locallab.cccurve) { + toEdit.locallab.cccurve = mods.locallab.cccurve; + } + if (locallab.LHcurve) { toEdit.locallab.LHcurve = mods.locallab.LHcurve; } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 5f2fb2931..f7d5956ac 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -472,6 +472,7 @@ public: bool localTgaincurve; bool localTgaincurverab; bool llcurve; + bool cccurve; bool LHcurve; bool chrrt; bool mult[5];