diff --git a/rtdata/languages/default b/rtdata/languages/default index 48372a552..f28000f0a 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -741,6 +741,25 @@ HISTORY_MSG_490;DRC - Amount HISTORY_MSG_491;White Balance HISTORY_MSG_492;RGB Curves HISTORY_MSG_493;L*a*b* Adjustments +HISTORY_MSG_495;L*a*b Spot created +HISTORY_MSG_496;L*a*b Spot deleted +HISTORY_MSG_497;L*a*b Spot selected +HISTORY_MSG_498;L*a*b Spot name +HISTORY_MSG_499;L*a*b Spot visibility +HISTORY_MSG_500;L*a*b Spot shape +HISTORY_MSG_501;L*a*b Spot method +HISTORY_MSG_502;L*a*b Spot shape method +HISTORY_MSG_503;L*a*b Spot locX +HISTORY_MSG_504;L*a*b Spot locXL +HISTORY_MSG_505;L*a*b Spot locY +HISTORY_MSG_506;L*a*b Spot locYT +HISTORY_MSG_507;L*a*b Spot center +HISTORY_MSG_508;L*a*b Spot circrad +HISTORY_MSG_509;L*a*b Spot quality method +HISTORY_MSG_510;L*a*b Spot transit +HISTORY_MSG_511;L*a*b Spot thresh +HISTORY_MSG_512;L*a*b Spot iter + HISTORY_MSG_CLAMPOOG;Out-of-gamut color clipping HISTORY_MSG_LOCLOCX;Local - Right HISTORY_MSG_LOCCENTER;Local - Center diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 10cf4277e..d42b90d2e 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -52,7 +52,7 @@ extern const Settings* settings; Crop::Crop(ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool isDetailWindow) : PipetteBuffer(editDataProvider), origCrop(nullptr), laboCrop(nullptr), labnCrop(nullptr), reservCrop(nullptr), - cropImg (nullptr), shbuf_real(nullptr), transCrop (nullptr), cieCrop (nullptr), shbuffer(nullptr), + cropImg(nullptr), shbuf_real(nullptr), transCrop(nullptr), cieCrop(nullptr), shbuffer(nullptr), updating(false), newUpdatePending(false), skip(10), cropx(0), cropy(0), cropw(-1), croph(-1), trafx(0), trafy(0), trafw(-1), trafh(-1), @@ -823,7 +823,7 @@ void Crop::update(int todo) DCPProfile *dcpProf = parent->imgsrc->getDCP(params.icm, as); LUTu histToneCurve; - parent->ipf.rgbProc (baseCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, + parent->ipf.rgbProc(baseCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, params.toneCurve.saturation, parent->rCurve, parent->gCurve, parent->bCurve, parent->colourToningSatLimit, parent->colourToningSatLimitOpacity, parent->ctColorCurve, parent->ctOpacityCurve, parent->opautili, parent->clToningcurve, parent->cl2Toningcurve, parent->customToneCurve1, parent->customToneCurve2, parent->beforeToneCurveBW, parent->afterToneCurveBW, rrm, ggm, bbm, parent->bwAutoR, parent->bwAutoG, parent->bwAutoB, dcpProf, as, histToneCurve); @@ -890,6 +890,8 @@ void Crop::update(int todo) // bool tyty = false; int maxspot = settings->nspot + 1; + // TODO Locallab + /* if (needslocal) { // if (tyty ) { @@ -1775,6 +1777,7 @@ void Crop::update(int todo) } } + */ // int moderetinex; // parent->ipf.MSR(labnCrop, labnCrop->W, labnCrop->H, 1); @@ -1800,7 +1803,7 @@ void Crop::update(int todo) if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { parent->ipf.MLmicrocontrast(labnCrop); - parent->ipf.sharpening (labnCrop, params.sharpening, parent->sharpMask); + parent->ipf.sharpening(labnCrop, params.sharpening, parent->sharpMask); } } @@ -1929,8 +1932,8 @@ void Crop::update(int todo) } float d, dj, yb; // not used after this block - parent->ipf.ciecam_02float (cieCrop, float (adap), 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, - dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, d, dj, yb, 1, parent->sharpMask); + parent->ipf.ciecam_02float(cieCrop, float (adap), 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, + dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, d, dj, yb, 1, parent->sharpMask); } else { // CIECAM is disabled, we free up its image buffer to save some space if (cieCrop) { @@ -2036,7 +2039,8 @@ void Crop::freeAll() } PipetteBuffer::flush(); - } + } + cropAllocated = false; } @@ -2228,7 +2232,8 @@ bool Crop::setCropSizes(int rcx, int rcy, int rcw, int rch, int skip, bool inter if (shbuffer) { delete [] shbuffer; - } + } + if (shbuf_real) { delete [] shbuf_real; } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index ab72b6acb..fb48c7e5d 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -41,8 +41,8 @@ extern const Settings* settings; ImProcCoordinator::ImProcCoordinator() : orig_prev(nullptr), oprevi(nullptr), oprevl(nullptr), nprevl(nullptr), reserv(nullptr), fattal_11_dcrop_cache(nullptr), previmg(nullptr), workimg(nullptr), - ncie (nullptr), imgsrc (nullptr), lastAwbEqual (0.), lastAwbTempBias (0.0), ipf (¶ms, true), monitorIntent (RI_RELATIVE), - softProof (false), gamutCheck (false), sharpMask(false), scale (10), highDetailPreprocessComputed (false), highDetailRawComputed (false), + ncie(nullptr), imgsrc(nullptr), lastAwbEqual(0.), lastAwbTempBias(0.0), ipf(¶ms, true), monitorIntent(RI_RELATIVE), + softProof(false), gamutCheck(false), sharpMask(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), ctColorCurve(), hltonecurve(65536), @@ -280,6 +280,7 @@ DetailedCrop* ImProcCoordinator::createCrop(::EditDataProvider *editDataProvider // cropCall: calling crop, used to prevent self-updates ...doesn't seem to be used void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) { + printf("updatePreviewImage\n"); MyMutex::MyLock processingLock(mProcessing); int numofphases = 14; @@ -358,7 +359,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) // If high detail (=100%) is newly selected, do a demosaic update, since the last was just with FAST if (imageTypeListener) { - imageTypeListener->imageTypeChanged (imgsrc->isRAW(), imgsrc->getSensorType() == ST_BAYER, imgsrc->getSensorType() == ST_FUJI_XTRANS, imgsrc->isMono()); + imageTypeListener->imageTypeChanged(imgsrc->isRAW(), imgsrc->getSensorType() == ST_BAYER, imgsrc->getSensorType() == ST_FUJI_XTRANS, imgsrc->isMono()); } if ((todo & M_RAW) @@ -696,7 +697,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) DCPProfile::ApplyState as; DCPProfile *dcpProf = imgsrc->getDCP(params.icm, as); - ipf.rgbProc (oprevi, oprevl, nullptr, hltonecurve, shtonecurve, tonecurve, params.toneCurve.saturation, + ipf.rgbProc(oprevi, oprevl, nullptr, hltonecurve, shtonecurve, tonecurve, params.toneCurve.saturation, rCurve, gCurve, bCurve, colourToningSatLimit, colourToningSatLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, beforeToneCurveBW, afterToneCurveBW, rrm, ggm, bbm, bwAutoR, bwAutoG, bwAutoB, params.toneCurve.expcomp, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, dcpProf, as, histToneCurve); if (params.blackwhite.enabled && params.blackwhite.autoc && abwListener) { @@ -774,7 +775,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) int maxspot = settings->nspot + 1; progress("Applying Color Boost...", 100 * readyphase / numofphases); - + // TODO Locallab if (params.locallab.enabled) { /* * This file is part of RawTherapee. @@ -796,7 +797,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) * 2017 2018 Jacques Desmis */ - + /* //********************************************************* //advertissment //we can probably put all these function outside main process @@ -807,43 +808,55 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) //there are probably errors... //*********************************************************** - bool isascii = true; + // Get image file MD5 std::string mdfive = getMD5(imgsrc->getFileName()); + // Check if new image file has been loaded + bool newimage = false; - 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 possible..switch to Profiles\n"); - isascii = false; - } else { - printf("ascii Mip file possible!\n"); + if (prevmdfive == "" || prevmdfive != mdfive) { + printf("New image loaded\n"); + newimage = true; + prevmdfive = mdfive; } - finterm.close(); + // Check if destination folder is writable and get .mip file path + if (newimage) { // To avoid systematic access to hard disk + bool isascii = true; + Glib::ustring datainterm = imgsrc->getFileName() + ".ii";//extansion ii arbitrary to test if mip file is possible - if (isascii == true) { - if (std::remove(datainterm.c_str()) != 0) { - perror("Error deleting test ii file"); + ofstream finterm(datainterm, ios::out); + + if (finterm.fail()) { + printf("Non ascii Mip file possible..switch to Profiles\n"); + isascii = false; } else { - puts("Test ii file successfully deleted"); + 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"); + } + } + + Glib::ustring pop = options.cacheBaseDir + "/mip/"; + + if (options.mip == MI_opt || !isascii) { + datal = pop + Glib::path_get_basename(imgsrc->getFileName() + "." + mdfive + ".mip"); + } + + if (options.mip == MI_prev && isascii) {//&& isascii + datal = imgsrc->getFileName() + ".mip"; } } - Glib::ustring pop = options.cacheBaseDir + "/mip/"; - - Glib::ustring datal; - - if (options.mip == MI_opt || !isascii) { - datal = pop + Glib::path_get_basename(imgsrc->getFileName() + "." + mdfive + ".mip"); - } - - if (options.mip == MI_prev && isascii) {//&& isascii - datal = imgsrc->getFileName() + ".mip"; - } - + printf("mip files in=%s\n", datal.c_str()); + */ /* //test to see if wofstream and wifstream works with NON ASCII, but it's bad wofstream test(datal, ios::out); @@ -851,9 +864,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) else ("ca va bien\n"); test.close(); */ + /* ifstream fic0(datal, ios::in); - printf("mip files in=%s\n", datal.c_str()); // if(! fic0.fail()) { float **shbuffer = nullptr; versionmip = 0; @@ -1223,7 +1236,8 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) skinstr = new std::string[maxspot]; pthstr = new std::string[maxspot]; exstr = new std::string[maxspot]; - + */ + /* //****************************************************************** //initialize data[xx][0] and Lut cache with params //****************************************************************** @@ -1765,8 +1779,8 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) maxind = 69; } -// I have forgotten 10010 ==> probably crash...but now it's passed... -//enabled this code after... + // I have forgotten 10010 ==> probably crash...but now it's passed... + //enabled this code after... if (versionmip == 10011) { maxind = 70; } @@ -3277,7 +3291,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) psthresholds[sp * 500] = s_datcps[0]; psthresholds[sp * 500 + 1] = s_datcps[1]; -// printf("B 0=%i 1=%i\n", s_datcps[0], s_datcps[1]); + // printf("B 0=%i 1=%i\n", s_datcps[0], s_datcps[1]); std::string ps_str2 = ""; ps_str2 = ps_str2 + std::to_string(s_datcps[0]) + delim[0] + std::to_string(s_datcps[1]) + delim[1]; @@ -3655,25 +3669,25 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) delete [] pthstr; delete [] exstr; - } + } - //************************************************************* - // end locallab - //************************************************************* + //************************************************************* + // end locallab + //************************************************************* - histCCurve.clear(); - histLCurve.clear(); - ipf.chromiLuminanceCurve(nullptr, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histLCurve); - ipf.vibrance(nprevl); + histCCurve.clear(); + histLCurve.clear(); + ipf.chromiLuminanceCurve(nullptr, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histLCurve); + ipf.vibrance(nprevl); - if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { ipf.EPDToneMap(nprevl, 5, scale); - } + } - // for all treatments Defringe, Sharpening, Contrast detail , Microcontrast they are activated if "CIECAM" function are disabled - readyphase++; + // for all treatments Defringe, Sharpening, Contrast detail , Microcontrast they are activated if "CIECAM" function are disabled + readyphase++; - /* Issue 2785, disabled some 1:1 tools + /* Issue 2785, disabled some 1:1 tools if (scale==1) { if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)){ progress ("Denoising luminance impulse...",100*readyphase/numofphases); @@ -3711,8 +3725,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) delete [] buffer; readyphase++; } - } - */ + */ + } + if (params.dirpyrequalizer.cbdlMethod == "aft") { if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled))) { progress("Pyramid wavelet...", 100 * readyphase / numofphases); @@ -4205,7 +4220,7 @@ void ImProcCoordinator::getSoftProofing(bool & softProof, bool & gamutCheck) gamutCheck = this->gamutCheck; } -void ImProcCoordinator::setSharpMask (bool sharpMask) +void ImProcCoordinator::setSharpMask(bool sharpMask) { this->sharpMask = sharpMask; } diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index c51504017..8b06c85cb 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -242,6 +242,8 @@ protected: bool HHutili; bool curveutili; + std::string prevmdfive; + Glib::ustring datal; int **dataspot; int maxdata; std::string *retistr; @@ -252,6 +254,7 @@ protected: std::string *skinstr; std::string *pthstr; std::string *exstr; + std::string *name; LUTi circrads; LUTi centerx; @@ -467,7 +470,7 @@ public: void getMonitorProfile(Glib::ustring& profile, RenderingIntent& intent) const; void setSoftProofing(bool softProof, bool gamutCheck); void getSoftProofing(bool &softProof, bool &gamutCheck); - void setSharpMask (bool sharpMask); + void setSharpMask(bool sharpMask); bool updateTryLock() { return updaterThreadStart.trylock(); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 1d70f381f..896adeaff 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -47,7 +47,8 @@ #undef CLIPD #define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f) -namespace { +namespace +{ using namespace rtengine; @@ -183,7 +184,7 @@ void proPhotoBlue(float *rtemp, float *gtemp, float *btemp, int istart, int tH, float g = gtemp[ti * tileSize + tj + k]; float b = btemp[ti * tileSize + tj + k]; - + if ((r == 0.0f || g == 0.0f) && rtengine::min(r, g, b) >= 0.f) { float h, s, v; Color::rgb2hsv(r, g, b, h, s, v); @@ -215,19 +216,22 @@ void customToneCurve(const ToneCurve &customToneCurve, ToneCurveParams::TcMode c { if (curveMode == ToneCurveParams::TcMode::STD) { // Standard - const StandardToneCurve& userToneCurve = static_cast (customToneCurve); + const StandardToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); } } else if (curveMode == ToneCurveParams::TcMode::FILMLIKE) { // Adobe like - const AdobeToneCurve& userToneCurve = static_cast (customToneCurve); + const AdobeToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } else if (curveMode == ToneCurveParams::TcMode::SATANDVALBLENDING) { // apply the curve on the saturation and value channels - const SatAndValueBlendingToneCurve& userToneCurve = static_cast (customToneCurve); + const SatAndValueBlendingToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); @@ -235,6 +239,7 @@ void customToneCurve(const ToneCurve &customToneCurve, ToneCurveParams::TcMode c } } else if (curveMode == ToneCurveParams::TcMode::WEIGHTEDSTD) { // apply the curve to the rgb channels, weighted const WeightedStdToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); } @@ -248,6 +253,7 @@ void customToneCurve(const ToneCurve &customToneCurve, ToneCurveParams::TcMode c } } else if (curveMode == ToneCurveParams::TcMode::PERCEPTUAL) { // apply curve while keeping color appearance constant const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve); + for (int i = istart, ti = 0; i < tH; i++, ti++) { userToneCurve.BatchApply(0, tW - jstart, &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize], ptcApplyState); } @@ -295,6 +301,7 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R if (monitorTransform) { cmsDeleteTransform(monitorTransform); } + gamutWarning.reset(nullptr); monitorTransform = nullptr; @@ -323,20 +330,24 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R if (softProof) { cmsHPROFILE oprof = nullptr; RenderingIntent outIntent; - + flags = cmsFLAGS_SOFTPROOFING | cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; if (!settings->printerProfile.empty()) { oprof = ICCStore::getInstance()->getProfile(settings->printerProfile); + if (settings->printerBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + outIntent = settings->printerIntent; } else { oprof = ICCStore::getInstance()->getProfile(params->icm.output); + if (params->icm.outputBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + outIntent = params->icm.outputIntent; } @@ -361,9 +372,11 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R if (gamutCheck) { gamutprof = oprof; + if (params->icm.outputBPC) { gamutbpc = cmsFLAGS_BLACKPOINTCOMPENSATION; } + gamutintent = outIntent; } } @@ -379,9 +392,11 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R // softProofCreated = true; // } gamutprof = monitor; + if (settings->monitorBPC) { gamutbpc = cmsFLAGS_BLACKPOINTCOMPENSATION; } + gamutintent = monitorIntent; } @@ -392,7 +407,7 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } - monitorTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_FLT, monitorIntent, flags); + monitorTransform = cmsCreateTransform(iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_FLT, monitorIntent, flags); } if (gamutCheck && gamutprof) { @@ -473,8 +488,8 @@ void ImProcFunctions::firstAnalysis(const Imagefloat* const original, const Proc void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb, LabImage* lab, const ProcParams* params, const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3, - LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt, - bool showSharpMask) + LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt, + bool showSharpMask) { if (params->colorappearance.enabled) { @@ -1495,7 +1510,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Ciecam02::jch2xyz_ciecam02float(xx, yy, zz, J, C, h, xw2, yw2, zw2, - c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); + c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); float x, y, z; x = xx * 655.35f; y = yy * 655.35f; @@ -1661,7 +1676,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb const bool hotbad = params->dirpyrequalizer.skinprotect != 0.0; lab->deleteLab(); - ImProcFunctions::badpixcam (ncie, artifact / scale, 5, 2, chrom, hotbad); //enabled remove artifacts for cbDL + ImProcFunctions::badpixcam(ncie, artifact / scale, 5, 2, chrom, hotbad); //enabled remove artifacts for cbDL lab->reallocLab(); } @@ -1669,7 +1684,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb if (params->colorappearance.badpixsl > 0 && execsharp) { int mode = params->colorappearance.badpixsl; lab->deleteLab(); - ImProcFunctions::badpixcam (ncie, 3.0, 10, mode, 0, true);//for bad pixels CIECAM + ImProcFunctions::badpixcam(ncie, 3.0, 10, mode, 0, true); //for bad pixels CIECAM lab->reallocLab(); } @@ -1688,7 +1703,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb if (params->sharpening.enabled) if (execsharp) { float **buffer = lab->L; // We can use the L-buffer from lab as buffer to save some memory - ImProcFunctions::sharpeningcam (ncie, buffer, showSharpMask); // sharpening adapted to CIECAM + ImProcFunctions::sharpeningcam(ncie, buffer, showSharpMask); // sharpening adapted to CIECAM } //if(params->dirpyrequalizer.enabled) if(execsharp) { @@ -1828,7 +1843,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb Ciecam02::jch2xyz_ciecam02float(xx, yy, zz, ncie->J_p[i][j], ncie_C_p, ncie->h_p[i][j], xw2, yw2, zw2, - c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); + c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); float x = (float)xx * 655.35f; float y = (float)yy * 655.35f; float z = (float)zz * 655.35f; @@ -2028,15 +2043,15 @@ filmlike_clip(float *r, float *g, float *b) void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, - int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clToningcurve, LUTf & cl2Toningcurve, + int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clToningcurve, LUTf & cl2Toningcurve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, const ToneCurve & customToneCurvebw1, const ToneCurve & customToneCurvebw2, double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, DCPProfile *dcpProf, const DCPProfile::ApplyState &asIn, LUTu &histToneCurve) { - rgbProc (working, lab, pipetteBuffer, hltonecurve, shtonecurve, tonecurve, sat, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, params->toneCurve.expcomp, params->toneCurve.hlcompr, params->toneCurve.hlcomprthresh, dcpProf, asIn, histToneCurve); + rgbProc(working, lab, pipetteBuffer, hltonecurve, shtonecurve, tonecurve, sat, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, params->toneCurve.expcomp, params->toneCurve.hlcompr, params->toneCurve.hlcomprthresh, dcpProf, asIn, histToneCurve); } // Process RGB image and convert to LAB space void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, - int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clToningcurve, LUTf & cl2Toningcurve, + int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clToningcurve, LUTf & cl2Toningcurve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, const ToneCurve & customToneCurvebw1, const ToneCurve & customToneCurvebw2, double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, double expcomp, int hlcompr, int hlcomprthresh, DCPProfile *dcpProf, const DCPProfile::ApplyState &asIn, LUTu &histToneCurve) { BENCHFUN @@ -2464,6 +2479,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer if (OOG(r) || OOG(g) || OOG(b)) { filmlike_clip(&r, &g, &b); } + rtemp[ti * TS + tj] = r; gtemp[ti * TS + tj] = g; btemp[ti * TS + tj] = b; @@ -2480,6 +2496,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer if (OOG(max(r, g, b)) && !OOG(min(r, g, b))) { filmlike_clip(&r, &g, &b); } + setUnlessOOG(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], r, g, b); } } @@ -2504,7 +2521,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer float tmpr[4] ALIGNED16; float tmpg[4] ALIGNED16; float tmpb[4] ALIGNED16; - + for (int i = istart, ti = 0; i < tH; i++, ti++) { int j = jstart, tj = 0; #ifdef __SSE2__ @@ -2514,6 +2531,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer STVF(tmpr[0], tonecurve(LVF(rtemp[ti * TS + tj]))); STVF(tmpg[0], tonecurve(LVF(gtemp[ti * TS + tj]))); STVF(tmpb[0], tonecurve(LVF(btemp[ti * TS + tj]))); + for (int k = 0; k < 4; ++k) { setUnlessOOG(rtemp[ti * TS + tj + k], gtemp[ti * TS + tj + k], btemp[ti * TS + tj + k], tmpr[k], tmpg[k], tmpb[k]); } @@ -2648,17 +2666,17 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly (HH, sincosval, Lpro, Chpro, r, g, b, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly(HH, sincosval, Lpro, Chpro, r, g, b, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly (HH, sincosval, Lpro, Chpro, r, g, b, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly(HH, sincosval, Lpro, Chpro, r, g, b, wip, highlight, 0.15f, 0.96f); #endif //end of gamut control } else { float x_, y_, z_; //calculate RGB with L_2 and old value of a and b Color::Lab2XYZ(L_2, a_1, b_1, x_, y_, z_) ; - Color::xyz2rgb (x_, y_, z_, r, g, b, wip); + Color::xyz2rgb(x_, y_, z_, r, g, b, wip); } setUnlessOOG(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], r, g, b); @@ -2679,11 +2697,13 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer if (sat != 0 || hCurveEnabled || sCurveEnabled || vCurveEnabled) { const float satby100 = sat / 100.f; + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { float h, s, v; Color::rgb2hsvtc(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], h, s, v); h /= 6.f; + if (sat > 0) { s = std::max(0.f, intp(satby100, 1.f - SQR(SQR(1.f - std::min(s, 1.0f))), s)); } else { /*if (sat < 0)*/ @@ -2727,7 +2747,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer valparam *= (1.f - SQR(SQR(1.f - min(s, 1.0f)))); if (valparam > 0.00001f) { - v = (1.f - valparam) * v + valparam * (1.f - SQR (1.f - min (v, 1.0f))); // SQR (SQR to increase action and avoid artifacts + v = (1.f - valparam) * v + valparam * (1.f - SQR(1.f - min(v, 1.0f))); // SQR (SQR to increase action and avoid artifacts if (v < 0) { v = 0; @@ -2783,6 +2803,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer const float kbh = bh / (rh + gh + bh); strProtect = pow_F(strProtect, 0.4f); constexpr int mode = 0; + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { toning2col(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], iplow, iphigh, krl, kgl, kbl, krh, kgh, kbh, SatLow, SatHigh, balanS, balanH, reducac, mode, preser, strProtect); @@ -2795,6 +2816,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer constexpr float reducac = 0.3f; constexpr int mode = 0; strProtect = pow_F(strProtect, 0.4f); + for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { const float r = rtemp[ti * TS + tj]; @@ -2881,7 +2903,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer // Luminance = (0.299f*r + 0.587f*g + 0.114f*b) float s, l; - Color::rgb2slfloat (r, g, b, s, l); + Color::rgb2slfloat(r, g, b, s, l); float l_ = Color::gammatab_srgb1[l * 65535.f]; @@ -2896,9 +2918,9 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer ctColorCurve.getVal(l_, r2, g2, b2); // get the color from the color curve float h2, s2, l2; - Color::rgb2hslfloat (r2, g2, b2, h2, s2, l2); // transform this new color to hsl + Color::rgb2hslfloat(r2, g2, b2, h2, s2, l2); // transform this new color to hsl - Color::hsl2rgbfloat (h2, s + ((1.f - s) * (1.f - l) * 0.7f), l, r2, g2, b2); + Color::hsl2rgbfloat(h2, s + ((1.f - s) * (1.f - l) * 0.7f), l, r2, g2, b2); rtemp[ti * TS + tj] = r + (r2 - r) * opacity; // merge the color to the old color, depending on the opacity gtemp[ti * TS + tj] = g + (g2 - g) * opacity; @@ -3113,9 +3135,9 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_work2xyz); Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2clut); - STVF (clutr[tj], sourceR); - STVF (clutg[tj], sourceG); - STVF (clutb[tj], sourceB); + STVF(clutr[tj], sourceR); + STVF(clutg[tj], sourceG); + STVF(clutb[tj], sourceB); } #endif @@ -3127,7 +3149,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer float x, y, z; Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, wprof); - Color::xyz2rgb (x, y, z, clutr[tj], clutg[tj], clutb[tj], xyz2clut); + Color::xyz2rgb(x, y, z, clutr[tj], clutg[tj], clutb[tj], xyz2clut); } } else { memcpy(clutr, &rtemp[ti * TS], sizeof(float) * TS); @@ -3174,9 +3196,9 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer #ifdef __SSE2__ for (; j < tW - 3; j += 4, tj += 4) { - vfloat sourceR = LVF (clutr[tj]); - vfloat sourceG = LVF (clutg[tj]); - vfloat sourceB = LVF (clutb[tj]); + vfloat sourceR = LVF(clutr[tj]); + vfloat sourceG = LVF(clutg[tj]); + vfloat sourceB = LVF(clutb[tj]); vfloat x; vfloat y; @@ -3184,9 +3206,9 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_clut2xyz); Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2work); - STVF (clutr[tj], sourceR); - STVF (clutg[tj], sourceG); - STVF (clutb[tj], sourceB); + STVF(clutr[tj], sourceR); + STVF(clutg[tj], sourceG); + STVF(clutb[tj], sourceB); } #endif @@ -3230,6 +3252,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = istart, ti = 0; i < tH; i++, ti++) { Color::RGB2Lab(&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], &(lab->L[i][jstart]), &(lab->a[i][jstart]), &(lab->b[i][jstart]), toxyz, tW - jstart); } + if (hasColorToningLabGrid) { colorToningLabGrid(lab, jstart, tW, istart, tH, false); } @@ -3333,7 +3356,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer for (int j = 0; j < tW; j++) { //mix channel - tmpImage->r (i, j) = tmpImage->g (i, j) = tmpImage->b (i, j) = /*CLIP*/ ((bwr * tmpImage->r (i, j) + bwg * tmpImage->g (i, j) + bwb * tmpImage->b (i, j)) * kcorec); + tmpImage->r(i, j) = tmpImage->g(i, j) = tmpImage->b(i, j) = /*CLIP*/ ((bwr * tmpImage->r(i, j) + bwg * tmpImage->g(i, j) + bwb * tmpImage->b(i, j)) * kcorec); #ifndef __SSE2__ @@ -3411,9 +3434,9 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - const float r = tmpImage->r (i, j); - const float g = tmpImage->g (i, j); - const float b = tmpImage->b (i, j); + const float r = tmpImage->r(i, j); + const float g = tmpImage->g(i, j); + const float b = tmpImage->b(i, j); const float lumbefore = 0.299f * r + 0.587f * g + 0.114f * b; @@ -3611,6 +3634,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { Color::RGB2Lab(tmpImage->r(i), tmpImage->g(i), tmpImage->b(i), lab->L[i], lab->a[i], lab->b[i], toxyz, tW); + if (hasColorToningLabGrid) { colorToningLabGrid(lab, 0, tW, i, i + 1, false); } @@ -3757,11 +3781,11 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, if (v > v0) { float aa, bb, cc; - secondeg_end (reducac, v0, aa, bb, cc); + secondeg_end(reducac, v0, aa, bb, cc); kl = aa * v * v + bb * v + cc; //verified ==> exact } else { float aab, bbb; - secondeg_begin (0.7f, v0, aab, bbb); + secondeg_begin(0.7f, v0, aab, bbb); kl = aab * v * v + bbb * v; } } else { //bw coefficient to preserve same results as before for satlimtopacity = 0.5 (default) @@ -3769,6 +3793,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, rlob = strProtect; //0.5 rlm = strProtect * 2.2f; //1.1 rlh = strProtect * 2.4f; //1.2 + if (v > 0.15f) { kl = (-1.f / 0.85f) * v + 1.f / 0.85f; //Low light ==> decrease action after v=0.15 } @@ -3776,6 +3801,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, { const float corr = 20000.f * RedLow * kl * rlo; + if (RedLow > 0.f) { g -= corr; b -= corr; @@ -3790,6 +3816,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, { const float corr = 20000.f * GreenLow * kl * rlo; + if (GreenLow > 0.f) { r -= corr; b -= corr; @@ -3846,6 +3873,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, g -= 20000.f * RedM; b -= 20000.f * RedM; } + // r = CLIP(r); // g = CLIP(g); // b = CLIP(b); @@ -3863,6 +3891,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, g += 10000.f * GreenM; b -= 20000.f * GreenM; } + // r = CLIP(r); // g = CLIP(g); // b = CLIP(b); @@ -3880,6 +3909,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, g -= 20000.f * BlueM; b += 10000.f * BlueM; } + // r = CLIP(r); // g = CLIP(g); // b = CLIP(b); @@ -3891,6 +3921,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, secondeg_begin(reducac, v00, aa0, bb0); float kh; + if (v > v00) { //max action kh = (1.f - v) / (1.f - v00); //High tones } else { @@ -3959,7 +3990,7 @@ void ImProcFunctions::toningsmh(float r, float g, float b, float &ro, float &go, * @param balanH [0..1] balance for highlights (same slider than for balanS) * @param reducac value of the reduction in the middle of the range for second degree, increase or decrease action **/ -void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &go, float &bo, float iplow, float iphigh, float krl, float kgl, float kbl, float krh, float kgh, float kbh, float SatLow, float SatHigh, float balanS, float balanH, float reducac, int mode, int preser, float strProtect) +void ImProcFunctions::toning2col(float r, float g, float b, float &ro, float &go, float &bo, float iplow, float iphigh, float krl, float kgl, float kbl, float krh, float kgh, float kbh, float SatLow, float SatHigh, float balanS, float balanH, float reducac, int mode, int preser, float strProtect) { const float lumbefore = 0.299f * r + 0.587f * g + 0.114f * b; const float v = max(r, g, b) / 65535.f; @@ -3978,15 +4009,18 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g if (SatLow > 0.f) { float kl = 1.f; + if (v > iplow) { kl = aa * v * v + bb * v + cc; } else if (mode == 0) { kl = aab * v * v + bbb * v; } + const float kmgb = min(r, g, b); + if (kmgb < 20000.f) { //I have tested ...0.85 compromise... - kl *= pow_F ((kmgb / 20000.f), 0.85f); + kl *= pow_F((kmgb / 20000.f), 0.85f); } const float factor = 20000.f * SatLow * kl * rlo * balanS; @@ -4023,6 +4057,7 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g if (SatHigh > 0.f) { float kh = 1.f; + if (v > iphigh) { kh = (1.f - v) / (1.f - iphigh); //Low light ==> decrease action after iplow } else { @@ -4030,11 +4065,13 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g } const float kmgb = max(r, g, b); + if (kmgb > 45535.f) { constexpr float cora = 1.f / (45535.f - 65535.f); constexpr float corb = 1.f - cora * 45535.f; kh *= kmgb * cora + corb; } + const float factor = 20000.f * SatHigh * kh * rlh * balanH; r += factor * (krh > 0.f ? krh : 0.f); g += factor * (kgh > 0.f ? kgh : 0.f); @@ -4046,6 +4083,7 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g } float preserv = 1.f; + if (preser == 1) { float lumafter = 0.299f * r + 0.587f * g + 0.114f * b; preserv = lumbefore / lumafter; @@ -4071,10 +4109,10 @@ void ImProcFunctions::labtoning(float r, float g, float b, float &ro, float &go, ro = CLIP(r); go = CLIP(g); bo = CLIP(b); - + float realL; float h, s, l; - Color::rgb2hsl (ro, go, bo, h, s, l); + Color::rgb2hsl(ro, go, bo, h, s, l); float x2, y2, z2; float xl, yl, zl; @@ -4145,7 +4183,7 @@ void ImProcFunctions::luminanceCurve(LabImage* lold, LabImage* lnew, LUTf & curv -void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, LUTf & acurve, LUTf & bcurve, LUTf & satcurve, LUTf & lhskcurve, LUTf & clcurve, LUTf & curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLCurve) +void ImProcFunctions::chromiLuminanceCurve(PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, LUTf & acurve, LUTf & bcurve, LUTf & satcurve, LUTf & lhskcurve, LUTf & clcurve, LUTf & curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLCurve) { if (!params->labCurve.enabled) { if (params->blackwhite.enabled && !params->colorToning.enabled) { @@ -4155,6 +4193,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW } } } + return; } @@ -4539,7 +4578,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float aprov1 = Chprov2 * sincosval.y; float bprov1 = Chprov2 * sincosval.x; - float fy = (Color::c1By116 * Lprov1 ) + Color::c16By116; + float fy = (Color::c1By116 * Lprov1) + Color::c16By116; float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); @@ -5038,44 +5077,44 @@ void ImProcFunctions::defringe(LabImage* lab) if (params->defringe.enabled && lab->W >= 8 && lab->H >= 8) { - PF_correct_RT (lab, params->defringe.radius, params->defringe.threshold); + PF_correct_RT(lab, params->defringe.radius, params->defringe.threshold); } } void ImProcFunctions::defringecam(CieImage* ncie) { if (params->defringe.enabled && ncie->W >= 8 && ncie->H >= 8) { - PF_correct_RTcam (ncie, params->defringe.radius, params->defringe.threshold); + PF_correct_RTcam(ncie, params->defringe.radius, params->defringe.threshold); } } -void ImProcFunctions::badpixcam (CieImage* ncie, double rad, int thr, int mode, float chrom, bool hotbad) +void ImProcFunctions::badpixcam(CieImage* ncie, double rad, int thr, int mode, float chrom, bool hotbad) { if (ncie->W >= 8 && ncie->H >= 8) { - Badpixelscam (ncie, rad, thr, mode, chrom, hotbad); + Badpixelscam(ncie, rad, thr, mode, chrom, hotbad); } } -void ImProcFunctions::badpixlab (LabImage* lab, double rad, int thr, float chrom) +void ImProcFunctions::badpixlab(LabImage* lab, double rad, int thr, float chrom) { if (lab->W >= 8 && lab->H >= 8) { - BadpixelsLab (lab, rad, thr, chrom); + BadpixelsLab(lab, rad, thr, chrom); } } void ImProcFunctions::dirpyrequalizer(LabImage* lab, int scale) { if (params->dirpyrequalizer.enabled && lab->W >= 8 && lab->H >= 8) { - float b_l = static_cast (params->dirpyrequalizer.hueskin.getBottomLeft()) / 100.f; - float t_l = static_cast (params->dirpyrequalizer.hueskin.getTopLeft()) / 100.f; - float t_r = static_cast (params->dirpyrequalizer.hueskin.getTopRight()) / 100.f; + float b_l = static_cast(params->dirpyrequalizer.hueskin.getBottomLeft()) / 100.f; + float t_l = static_cast(params->dirpyrequalizer.hueskin.getTopLeft()) / 100.f; + float t_r = static_cast(params->dirpyrequalizer.hueskin.getTopRight()) / 100.f; // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; if (params->dirpyrequalizer.gamutlab && params->dirpyrequalizer.skinprotect != 0) { constexpr float artifact = 4.f; constexpr float chrom = 50.f; - ImProcFunctions::badpixlab (lab, artifact / scale, 5, chrom); //for artifacts + ImProcFunctions::badpixlab(lab, artifact / scale, 5, chrom); //for artifacts } //dirpyrLab_equalizer(lab, lab, params->dirpyrequalizer.mult); @@ -5187,12 +5226,19 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid void ImProcFunctions::EPDToneMaplocal(LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip) { - + // TODO Locallab + /* float stren = ((float)params->locallab.stren) / 100.f; float edgest = ((float)params->locallab.estop) / 100.f; float sca = ((float)params->locallab.scaltm) / 10.f; float gamm = ((float)params->locallab.gamma) / 100.f; float rew = ((float)params->locallab.rewei); + */ + float stren = 0.f; + float edgest = 0.f; + float sca = 0.f; + float gamm = 0.f; + float rew = 0.f; //Pointers to whole data and size of it. float *L = lab->L[0]; float *a = lab->a[0]; @@ -5798,7 +5844,7 @@ void ImProcFunctions::rgb2lab(const Imagefloat &src, LabImage &dst, const Glib:: } } -void ImProcFunctions::lab2rgb (const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace) +void ImProcFunctions::lab2rgb(const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace) { TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(workingSpace); const float wip[3][3] = { @@ -5879,6 +5925,7 @@ void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, in #ifdef _OPENMP #pragma omp parallel for if (multiThread) #endif + for (int y = ystart; y < yend; ++y) { for (int x = xstart; x < xend; ++x) { lab->a[y][x] += lab->L[y][x] * a_scale + a_base; diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 0207039e5..a5656c3a4 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -329,6 +329,8 @@ static void SobelCannyLuma(float **sobelL, float **luma, int bfw, int bfh, float static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, struct local_params& lp) { + // TODO Locallab + /* int w = oW; int h = oH; int circr = locallab.circrad; @@ -350,7 +352,7 @@ static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, stru double local_dxx = locallab.proxi / 8000.0;//for proxi = 2==> # 1 pixel double local_dyy = locallab.proxi / 8000.0; float iterati = (float) locallab.proxi; -// double local_dyy = locallab.proxi; + // double local_dyy = locallab.proxi; float chromaPastel = float (locallab.pastels) / 100.0f; float chromaSatur = float (locallab.saturated) / 100.0f; @@ -526,6 +528,7 @@ static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, stru lp.sensex = local_sensiex; lp.strucc = local_struc; lp.war = local_warm; + */ } @@ -760,11 +763,14 @@ void ImProcFunctions::ciecamloc_02float(LabImage* lab, LabImage* dest) int tempo; + // TODO Locallab + /* if (params->locallab.warm > 0) { tempo = 5000 - 30 * params->locallab.warm; } else { tempo = 5000 - 49 * params->locallab.warm; } + */ ColorTemp::temp2mulxyz(params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB ColorTemp::temp2mulxyz(tempo, "Custom", Xwout, Zwout); @@ -1026,6 +1032,8 @@ void ImProcFunctions::ciecamloc_02float(LabImage* lab, LabImage* dest) void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve) { + // TODO Locallab + /* if (!params->locallab.expvibrance) { return; } @@ -1033,11 +1041,11 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* const int width = bfw; const int height = bfh; -#ifdef _DEBUG + #ifdef _DEBUG MyTime t1e, t2e; t1e.set(); int negat = 0, moreRGB = 0, negsat = 0, moresat = 0; -#endif + #endif const float chromaPastel = float (params->locallab.pastels) / 100.0f; const float chromaSatur = float (params->locallab.saturated) / 100.0f; @@ -1095,7 +1103,7 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* }; -#ifdef _DEBUG + #ifdef _DEBUG MunsellDebugInfo* MunsDebugInfo = nullptr; if (avoidcolorshift) { @@ -1103,21 +1111,21 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* } #pragma omp parallel default(shared) firstprivate(lab, dest, MunsDebugInfo) reduction(+: negat, moreRGB, negsat, moresat) if (multiThread) -#else + #else #pragma omp parallel default(shared) if (multiThread) -#endif + #endif { float sathue[5], sathue2[4]; // adjust sat in function of hue -#ifdef _OPENMP + #ifdef _OPENMP if (settings->verbose && omp_get_thread_num() == 0) { -#else + #else if (settings->verbose) { -#endif + #endif printf("vibrance: p0=%1.2f p1=%1.2f p2=%1.2f s0=%1.2f s1=%1.2f s2=%1.2f\n", p0, p1, p2, s0, s1, s2); printf(" pastel=%f satur=%f limit= %1.2f chromamean=%0.5f\n", 1.0f + chromaPastel, 1.0f + chromaSatur, limitpastelsatur, chromamean); } @@ -1152,7 +1160,7 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* sincosval.x = lab->b[i][j] / (CC * 327.68f); } -#ifdef _DEBUG + #ifdef _DEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut @@ -1166,10 +1174,10 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* moreRGB++; } -#else + #else //gamut control : Lab values are in gamut Color::gamutLchonly(HH, sincosval, Lprov, Chprov, R, G, B, wip, highlight, 0.15f, 0.98f); -#endif + #endif if (Chprov > 6.0f) { const float saturation = SAT(R, G, B); @@ -1185,487 +1193,489 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* //blue: -1.80 -3.14 green = 2.1 3.14 green-yellow=1.4 2.1 red:0 1.4 blue-purple:-0.7 -1.4 purple: 0 -0.7 //these values allow a better and differential response if (LL < 20.0f) { //more for blue-purple, blue and red modulate - if (/*HH> -3.1415f &&*/ HH < -1.5f) { - sathue[0] = 1.3f; //blue - sathue[1] = 1.2f; - sathue[2] = 1.1f; - sathue[3] = 1.05f; - sathue[4] = 0.4f; - sathue2[0] = 1.05f; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { - sathue[0] = 1.6f; //blue purple 1.2 1.1 - sathue[1] = 1.4f; - sathue[2] = 1.3f; - sathue[3] = 1.2f ; - sathue[4] = 0.4f; - sathue2[0] = 1.2f ; - sathue2[1] = 1.15f; - sathue2[2] = 1.1f ; - sathue2[3] = 1.0f; - } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=1.1f;sathue[1]=1.1f;sathue[2]=1.1f;sathue[3]=1.0f ;sathue[4]=0.4f;sathue2[0]=1.0f ;sathue2[1]=1.0f ;sathue2[2]=1.0f ;sathue2[3]=1.0f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { - sathue[0] = 1.3f; //red 0.8 0.7 - sathue[1] = 1.2f; - sathue[2] = 1.1f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { - sathue[0] = 1.0f; //green yellow 1.2 1.1 - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ - sathue[0] = 1.4f; //green - sathue[1] = 1.3f; - sathue[2] = 1.2f; - sathue[3] = 1.15f; - sathue[4] = 0.4f; - sathue2[0] = 1.15f; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } - } else if (LL < 50.0f) { //more for blue and green, less for red and green-yellow - if (/*HH> -3.1415f &&*/ HH < -1.5f) { - sathue[0] = 1.5f; //blue - sathue[1] = 1.4f; - sathue[2] = 1.3f; - sathue[3] = 1.2f ; - sathue[4] = 0.4f; - sathue2[0] = 1.2f ; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { - sathue[0] = 1.3f; //blue purple 1.2 1.1 - sathue[1] = 1.2f; - sathue[2] = 1.1f; - sathue[3] = 1.05f; - sathue[4] = 0.4f; - sathue2[0] = 1.05f; - sathue2[1] = 1.05f; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f ;sathue[4]=0.4f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { - sathue[0] = 1.1f; //red 0.8 0.7 - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f ; - sathue[4] = 0.4f; - sathue2[0] = 0.8f ; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { - sathue[0] = 1.1f; //green yellow 1.2 1.1 - sathue[1] = 1.1f; - sathue[2] = 1.1f; - sathue[3] = 1.05f; - sathue[4] = 0.4f; - sathue2[0] = 0.9f ; - sathue2[1] = 0.8f ; - sathue2[2] = 0.7f ; - sathue2[3] = 0.6f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ - sathue[0] = 1.5f; //green - sathue[1] = 1.4f; - sathue[2] = 1.3f; - sathue[3] = 1.2f ; - sathue[4] = 0.4f; - sathue2[0] = 1.2f ; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } + if (/*HH> -3.1415f &&*//* HH < -1.5f) { + sathue[0] = 1.3f; //blue + sathue[1] = 1.2f; + sathue[2] = 1.1f; + sathue[3] = 1.05f; + sathue[4] = 0.4f; + sathue2[0] = 1.05f; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { + sathue[0] = 1.6f; //blue purple 1.2 1.1 + sathue[1] = 1.4f; + sathue[2] = 1.3f; + sathue[3] = 1.2f ; + sathue[4] = 0.4f; + sathue2[0] = 1.2f ; + sathue2[1] = 1.15f; + sathue2[2] = 1.1f ; + sathue2[3] = 1.0f; + } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=1.1f;sathue[1]=1.1f;sathue[2]=1.1f;sathue[3]=1.0f ;sathue[4]=0.4f;sathue2[0]=1.0f ;sathue2[1]=1.0f ;sathue2[2]=1.0f ;sathue2[3]=1.0f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { + sathue[0] = 1.3f; //red 0.8 0.7 + sathue[1] = 1.2f; + sathue[2] = 1.1f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { + sathue[0] = 1.0f; //green yellow 1.2 1.1 + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* + sathue[0] = 1.4f; //green + sathue[1] = 1.3f; + sathue[2] = 1.2f; + sathue[3] = 1.15f; + sathue[4] = 0.4f; + sathue2[0] = 1.15f; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } + } else if (LL < 50.0f) { //more for blue and green, less for red and green-yellow + if (/*HH> -3.1415f &&*//* HH < -1.5f) { + sathue[0] = 1.5f; //blue + sathue[1] = 1.4f; + sathue[2] = 1.3f; + sathue[3] = 1.2f ; + sathue[4] = 0.4f; + sathue2[0] = 1.2f ; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { + sathue[0] = 1.3f; //blue purple 1.2 1.1 + sathue[1] = 1.2f; + sathue[2] = 1.1f; + sathue[3] = 1.05f; + sathue[4] = 0.4f; + sathue2[0] = 1.05f; + sathue2[1] = 1.05f; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f ;sathue[4]=0.4f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { + sathue[0] = 1.1f; //red 0.8 0.7 + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f ; + sathue[4] = 0.4f; + sathue2[0] = 0.8f ; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { + sathue[0] = 1.1f; //green yellow 1.2 1.1 + sathue[1] = 1.1f; + sathue[2] = 1.1f; + sathue[3] = 1.05f; + sathue[4] = 0.4f; + sathue2[0] = 0.9f ; + sathue2[1] = 0.8f ; + sathue2[2] = 0.7f ; + sathue2[3] = 0.6f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* + sathue[0] = 1.5f; //green + sathue[1] = 1.4f; + sathue[2] = 1.3f; + sathue[3] = 1.2f ; + sathue[4] = 0.4f; + sathue2[0] = 1.2f ; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } - } else if (LL < 80.0f) { //more for green, less for red and green-yellow - if (/*HH> -3.1415f &&*/ HH < -1.5f) { - sathue[0] = 1.3f; //blue - sathue[1] = 1.2f; - sathue[2] = 1.15f; - sathue[3] = 1.1f ; - sathue[4] = 0.3f; - sathue2[0] = 1.1f ; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { - sathue[0] = 1.3f; //blue purple 1.2 1.1 - sathue[1] = 1.2f; - sathue[2] = 1.15f; - sathue[3] = 1.1f ; - sathue[4] = 0.3f; - sathue2[0] = 1.1f ; - sathue2[1] = 1.05f; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f ; - sathue[3] = 1.0f ; - sathue[4] = 0.3f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f ;sathue[3]=0.8f ;sathue[4]=0.3f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { - sathue[0] = 1.1f; //red 0.8 0.7 - sathue[1] = 1.0f; - sathue[2] = 0.9f ; - sathue[3] = 0.8f ; - sathue[4] = 0.3f; - sathue2[0] = 0.8f ; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { - sathue[0] = 1.3f; //green yellow 1.2 1.1 - sathue[1] = 1.2f; - sathue[2] = 1.1f ; - sathue[3] = 1.05f; - sathue[4] = 0.3f; - sathue2[0] = 1.0f ; - sathue2[1] = 0.9f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.7f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ - sathue[0] = 1.6f; //green - even with Prophoto green are too "little" 1.5 1.3 - sathue[1] = 1.4f; - sathue[2] = 1.3f ; - sathue[3] = 1.25f; - sathue[4] = 0.3f; - sathue2[0] = 1.25f; - sathue2[1] = 1.2f ; - sathue2[2] = 1.15f; - sathue2[3] = 1.05f; - } - } else { /*if (LL>=80.0f)*/ //more for green-yellow, less for red and purple - if (/*HH> -3.1415f &&*/ HH < -1.5f) { - sathue[0] = 1.0f; //blue - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f; - sathue[4] = 0.2f; - sathue2[0] = 0.8f; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { - sathue[0] = 1.0f; //blue purple 1.2 1.1 - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f; - sathue[4] = 0.2f; - sathue2[0] = 0.8f; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 0.9f; - sathue[4] = 0.2f; - sathue2[0] = 0.9f; - sathue2[1] = 0.9f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f;sathue[4]=0.2f;sathue2[0]=0.8f;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { - sathue[0] = 1.1f; //red 0.8 0.7 - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f; - sathue[4] = 0.2f; - sathue2[0] = 0.8f; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { - sathue[0] = 1.6f; //green yellow 1.2 1.1 - sathue[1] = 1.5f; - sathue[2] = 1.4f; - sathue[3] = 1.2f; - sathue[4] = 0.2f; - sathue2[0] = 1.1f; - sathue2[1] = 1.05f; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ - sathue[0] = 1.4f; //green - sathue[1] = 1.3f; - sathue[2] = 1.2f; - sathue[3] = 1.1f; - sathue[4] = 0.2f; - sathue2[0] = 1.1f; - sathue2[1] = 1.05f; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } + } else if (LL < 80.0f) { //more for green, less for red and green-yellow + if (/*HH> -3.1415f &&*//* HH < -1.5f) { + sathue[0] = 1.3f; //blue + sathue[1] = 1.2f; + sathue[2] = 1.15f; + sathue[3] = 1.1f ; + sathue[4] = 0.3f; + sathue2[0] = 1.1f ; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { + sathue[0] = 1.3f; //blue purple 1.2 1.1 + sathue[1] = 1.2f; + sathue[2] = 1.15f; + sathue[3] = 1.1f ; + sathue[4] = 0.3f; + sathue2[0] = 1.1f ; + sathue2[1] = 1.05f; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f ; + sathue[3] = 1.0f ; + sathue[4] = 0.3f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f ;sathue[3]=0.8f ;sathue[4]=0.3f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { + sathue[0] = 1.1f; //red 0.8 0.7 + sathue[1] = 1.0f; + sathue[2] = 0.9f ; + sathue[3] = 0.8f ; + sathue[4] = 0.3f; + sathue2[0] = 0.8f ; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { + sathue[0] = 1.3f; //green yellow 1.2 1.1 + sathue[1] = 1.2f; + sathue[2] = 1.1f ; + sathue[3] = 1.05f; + sathue[4] = 0.3f; + sathue2[0] = 1.0f ; + sathue2[1] = 0.9f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.7f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* + sathue[0] = 1.6f; //green - even with Prophoto green are too "little" 1.5 1.3 + sathue[1] = 1.4f; + sathue[2] = 1.3f ; + sathue[3] = 1.25f; + sathue[4] = 0.3f; + sathue2[0] = 1.25f; + sathue2[1] = 1.2f ; + sathue2[2] = 1.15f; + sathue2[3] = 1.05f; + } + } else { /*if (LL>=80.0f)*//* //more for green-yellow, less for red and purple + if (/*HH> -3.1415f &&*//* HH < -1.5f) { + sathue[0] = 1.0f; //blue + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f; + sathue[4] = 0.2f; + sathue2[0] = 0.8f; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { + sathue[0] = 1.0f; //blue purple 1.2 1.1 + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f; + sathue[4] = 0.2f; + sathue2[0] = 0.8f; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 0.9f; + sathue[4] = 0.2f; + sathue2[0] = 0.9f; + sathue2[1] = 0.9f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f;sathue[4]=0.2f;sathue2[0]=0.8f;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { + sathue[0] = 1.1f; //red 0.8 0.7 + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f; + sathue[4] = 0.2f; + sathue2[0] = 0.8f; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { + sathue[0] = 1.6f; //green yellow 1.2 1.1 + sathue[1] = 1.5f; + sathue[2] = 1.4f; + sathue[3] = 1.2f; + sathue[4] = 0.2f; + sathue2[0] = 1.1f; + sathue2[1] = 1.05f; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* + sathue[0] = 1.4f; //green + sathue[1] = 1.3f; + sathue[2] = 1.2f; + sathue[3] = 1.1f; + sathue[4] = 0.2f; + sathue2[0] = 1.1f; + sathue2[1] = 1.05f; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; } } + } - float chmodpastel = 0.f, chmodsat = 0.f; - // variables to improve transitions - float pa, pb;// transition = pa*saturation + pb - float chl00 = chromaPastel * satredu * sathue[4]; - float chl0 = chromaPastel * satredu * sathue[0]; - float chl1 = chromaPastel * satredu * sathue[1]; - float chl2 = chromaPastel * satredu * sathue[2]; - float chl3 = chromaPastel * satredu * sathue[3]; - float chs0 = chromaSatur * satredu * sathue2[0]; - float chs1 = chromaSatur * satredu * sathue2[1]; - float chs2 = chromaSatur * satredu * sathue2[2]; - float chs3 = chromaSatur * satredu * sathue2[3]; - float s3 = 1.0f; + float chmodpastel = 0.f, chmodsat = 0.f; + // variables to improve transitions + float pa, pb;// transition = pa*saturation + pb + float chl00 = chromaPastel * satredu * sathue[4]; + float chl0 = chromaPastel * satredu * sathue[0]; + float chl1 = chromaPastel * satredu * sathue[1]; + float chl2 = chromaPastel * satredu * sathue[2]; + float chl3 = chromaPastel * satredu * sathue[3]; + float chs0 = chromaSatur * satredu * sathue2[0]; + float chs1 = chromaSatur * satredu * sathue2[1]; + float chs2 = chromaSatur * satredu * sathue2[2]; + float chs3 = chromaSatur * satredu * sathue2[3]; + float s3 = 1.0f; - // We handle only positive values here ; improve transitions - if (saturation < p00) { - chmodpastel = chl00 ; //neutral tones - } else if (saturation < p0) { - pa = (chl00 - chl0) / (p00 - p0); - pb = chl00 - pa * p00; - chmodpastel = pa * saturation + pb; - } else if (saturation < p1) { - pa = (chl0 - chl1) / (p0 - p1); - pb = chl0 - pa * p0; - chmodpastel = pa * saturation + pb; - } else if (saturation < p2) { - pa = (chl1 - chl2) / (p1 - p2); - pb = chl1 - pa * p1; - chmodpastel = pa * saturation + pb; - } else if (saturation < limitpastelsatur) { - pa = (chl2 - chl3) / (p2 - limitpastelsatur); - pb = chl2 - pa * p2; - chmodpastel = pa * saturation + pb; - } else if (saturation < s0) { - pa = (chl3 - chs0) / (limitpastelsatur - s0) ; - pb = chl3 - pa * limitpastelsatur; - chmodsat = pa * saturation + pb; - } else if (saturation < s1) { - pa = (chs0 - chs1) / (s0 - s1); - pb = chs0 - pa * s0; - chmodsat = pa * saturation + pb; - } else if (saturation < s2) { - pa = (chs1 - chs2) / (s1 - s2); - pb = chs1 - pa * s1; - chmodsat = pa * saturation + pb; - } else { - pa = (chs2 - chs3) / (s2 - s3); - pb = chs2 - pa * s2; - chmodsat = pa * saturation + pb; + // We handle only positive values here ; improve transitions + if (saturation < p00) { + chmodpastel = chl00 ; //neutral tones + } else if (saturation < p0) { + pa = (chl00 - chl0) / (p00 - p0); + pb = chl00 - pa * p00; + chmodpastel = pa * saturation + pb; + } else if (saturation < p1) { + pa = (chl0 - chl1) / (p0 - p1); + pb = chl0 - pa * p0; + chmodpastel = pa * saturation + pb; + } else if (saturation < p2) { + pa = (chl1 - chl2) / (p1 - p2); + pb = chl1 - pa * p1; + chmodpastel = pa * saturation + pb; + } else if (saturation < limitpastelsatur) { + pa = (chl2 - chl3) / (p2 - limitpastelsatur); + pb = chl2 - pa * p2; + chmodpastel = pa * saturation + pb; + } else if (saturation < s0) { + pa = (chl3 - chs0) / (limitpastelsatur - s0) ; + pb = chl3 - pa * limitpastelsatur; + chmodsat = pa * saturation + pb; + } else if (saturation < s1) { + pa = (chs0 - chs1) / (s0 - s1); + pb = chs0 - pa * s0; + chmodsat = pa * saturation + pb; + } else if (saturation < s2) { + pa = (chs1 - chs2) / (s1 - s2); + pb = chs1 - pa * s1; + chmodsat = pa * saturation + pb; + } else { + pa = (chs2 - chs3) / (s2 - s3); + pb = chs2 - pa * s2; + chmodsat = pa * saturation + pb; + } + + if (chromaPastel != chromaSatur) { + + // Pastels + if (saturation > p2 && saturation < limitpastelsatur) { + float newchromaPastel = chromaPastel_a * saturation + chromaPastel_b; + chmodpastel = newchromaPastel * satredu * sathue[3]; } - if (chromaPastel != chromaSatur) { + // Saturated + if (saturation < s0 && saturation >= limitpastelsatur) { + float newchromaSatur = chromaSatur_a * saturation + chromaSatur_b; + chmodsat = newchromaSatur * satredu * sathue2[0]; + } + }// end transition - // Pastels - if (saturation > p2 && saturation < limitpastelsatur) { - float newchromaPastel = chromaPastel_a * saturation + chromaPastel_b; - chmodpastel = newchromaPastel * satredu * sathue[3]; - } + if (saturation <= limitpastelsatur) { + if (chmodpastel > 2.0f) { + chmodpastel = 2.0f; //avoid too big values + } else if (chmodpastel < -0.93f) { + chmodpastel = -0.93f; //avoid negative values + } - // Saturated - if (saturation < s0 && saturation >= limitpastelsatur) { - float newchromaSatur = chromaSatur_a * saturation + chromaSatur_b; - chmodsat = newchromaSatur * satredu * sathue2[0]; - } - }// end transition + Chprov *= (1.0f + chmodpastel); - if (saturation <= limitpastelsatur) { - if (chmodpastel > 2.0f) { - chmodpastel = 2.0f; //avoid too big values - } else if (chmodpastel < -0.93f) { - chmodpastel = -0.93f; //avoid negative values - } + if (Chprov < 6.0f) { + Chprov = 6.0f; + } + } else { //if (saturation > limitpastelsatur) + if (chmodsat > 1.8f) { + chmodsat = 1.8f; //saturated + } else if (chmodsat < -0.93f) { + chmodsat = -0.93f; + } - Chprov *= (1.0f + chmodpastel); + Chprov *= 1.0f + chmodsat; - if (Chprov < 6.0f) { - Chprov = 6.0f; - } - } else { //if (saturation > limitpastelsatur) - if (chmodsat > 1.8f) { - chmodsat = 1.8f; //saturated - } else if (chmodsat < -0.93f) { - chmodsat = -0.93f; - } - - Chprov *= 1.0f + chmodsat; - - if (Chprov < 6.0f) { - Chprov = 6.0f; - } + if (Chprov < 6.0f) { + Chprov = 6.0f; } } } - - bool hhModified = false; - - // Vibrance's Skin curve - if (sklocalcurve && localskutili) { - if (HH > skbeg && HH < skend) { - if (Chprov < 60.0f) { //skin hue : todo ==> transition - float HHsk = ask * HH + bsk; - float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hc = (Hn * xx + HH * (1.0f - xx)); - HH = Hc; - hhModified = true; - } else if (Chprov < (60.0f + dchr)) { //transition chroma - float HHsk = ask * HH + bsk; - float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hc = (Hn * xx + HH * (1.0f - xx)); - float aa = (HH - Hc) / dchr ; - float bb = HH - (60.0f + dchr) * aa; - HH = aa * Chprov + bb; - hhModified = true; - } - } - //transition hue - else if (HH > (skbeg - dhue) && HH <= skbeg && Chprov < (60.0f + dchr * 0.5f)) { - float HHsk = ask * skbeg + bsk; - float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hcc = (Hn * xx + skbeg * (1.0f - xx)); - float adh = (Hcc - (skbeg - dhue)) / (dhue); - float bdh = Hcc - adh * skbeg; - HH = adh * HH + bdh; - hhModified = true; - } else if (HH >= skend && HH < (skend + dhue) && Chprov < (60.0f + dchr * 0.5f)) { - float HHsk = ask * skend + bsk; - float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hcc = (Hn * xx + skend * (1.0f - xx)); - float adh = (skend + dhue - Hcc) / (dhue); - float bdh = Hcc - adh * skend; - HH = adh * HH + bdh; - hhModified = true; - } - } // end skin hue - - //Munsell correction - if (!avoidcolorshift && hhModified) { - sincosval = xsincosf(HH); - } - - float aprovn, bprovn; - bool inGamut; - - do { - inGamut = true; - - if (avoidcolorshift) { - float correctionHue = 0.0f; - float correctlum = 0.0f; - -#ifdef _DEBUG - Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum, MunsDebugInfo); -#else - Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum); -#endif - - if (correctionHue != 0.f || hhModified) { - sincosval = xsincosf(HH + correctionHue); - hhModified = false; - } - } - - aprovn = Chprov * sincosval.y; - bprovn = Chprov * sincosval.x; - - float fyy = (Color::c1By116 * Lprov) + Color::c16By116; - float fxx = (0.002f * aprovn) + fyy; - float fzz = fyy - (0.005f * bprovn); - float xx_ = 65535.f * Color::f2xyz(fxx) * Color::D50x; - // float yy_ = 65535.0f * Color::f2xyz(fyy); - float zz_ = 65535.f * Color::f2xyz(fzz) * Color::D50z; - float yy_ = 65535.f * ((Lprov > Color::epskap) ? fyy * fyy*fyy : Lprov / Color::kappa); - - Color::xyz2rgb(xx_, yy_, zz_, R, G, B, wip); - - if (R < 0.0f || G < 0.0f || B < 0.0f) { -#ifdef _DEBUG - negsat++; -#endif - Chprov *= 0.98f; - inGamut = false; - } - - // if "highlight reconstruction" enabled don't control Gamut for highlights - if ((!highlight) && (R > 65535.0f || G > 65535.0f || B > 65535.0f)) { -#ifdef _DEBUG - moresat++; -#endif - Chprov *= 0.98f; - inGamut = false; - } - } while (!inGamut); - - //put new values in Lab - dest->L[i][j] = Lprov * 327.68f; - dest->a[i][j] = aprovn * 327.68f; - dest->b[i][j] = bprovn * 327.68f; } - } // end of parallelization + + bool hhModified = false; + + // Vibrance's Skin curve + if (sklocalcurve && localskutili) { + if (HH > skbeg && HH < skend) { + if (Chprov < 60.0f) { //skin hue : todo ==> transition + float HHsk = ask * HH + bsk; + float Hn = (sklocalcurve[HHsk] - bsk) / ask; + float Hc = (Hn * xx + HH * (1.0f - xx)); + HH = Hc; + hhModified = true; + } else if (Chprov < (60.0f + dchr)) { //transition chroma + float HHsk = ask * HH + bsk; + float Hn = (sklocalcurve[HHsk] - bsk) / ask; + float Hc = (Hn * xx + HH * (1.0f - xx)); + float aa = (HH - Hc) / dchr ; + float bb = HH - (60.0f + dchr) * aa; + HH = aa * Chprov + bb; + hhModified = true; + } + } + //transition hue + else if (HH > (skbeg - dhue) && HH <= skbeg && Chprov < (60.0f + dchr * 0.5f)) { + float HHsk = ask * skbeg + bsk; + float Hn = (sklocalcurve[HHsk] - bsk) / ask; + float Hcc = (Hn * xx + skbeg * (1.0f - xx)); + float adh = (Hcc - (skbeg - dhue)) / (dhue); + float bdh = Hcc - adh * skbeg; + HH = adh * HH + bdh; + hhModified = true; + } else if (HH >= skend && HH < (skend + dhue) && Chprov < (60.0f + dchr * 0.5f)) { + float HHsk = ask * skend + bsk; + float Hn = (sklocalcurve[HHsk] - bsk) / ask; + float Hcc = (Hn * xx + skend * (1.0f - xx)); + float adh = (skend + dhue - Hcc) / (dhue); + float bdh = Hcc - adh * skend; + HH = adh * HH + bdh; + hhModified = true; + } + } // end skin hue + + //Munsell correction + if (!avoidcolorshift && hhModified) { + sincosval = xsincosf(HH); + } + + float aprovn, bprovn; + bool inGamut; + + do { + inGamut = true; + + if (avoidcolorshift) { + float correctionHue = 0.0f; + float correctlum = 0.0f; #ifdef _DEBUG - t2e.set(); + Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum, MunsDebugInfo); +#else + Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum); +#endif - if (settings->verbose) { - printf("Vibrance local (performed in %d usec):\n", t2e.etime(t1e)); - printf(" Gamut: G1negat=%iiter G165535=%iiter G2negsat=%iiter G265535=%iiter\n", negat, moreRGB, negsat, moresat); + if (correctionHue != 0.f || hhModified) { + sincosval = xsincosf(HH + correctionHue); + hhModified = false; + } + } - if (MunsDebugInfo) { - printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad depass=%u\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); + aprovn = Chprov * sincosval.y; + bprovn = Chprov * sincosval.x; + + float fyy = (Color::c1By116 * Lprov) + Color::c16By116; + float fxx = (0.002f * aprovn) + fyy; + float fzz = fyy - (0.005f * bprovn); + float xx_ = 65535.f * Color::f2xyz(fxx) * Color::D50x; + // float yy_ = 65535.0f * Color::f2xyz(fyy); + float zz_ = 65535.f * Color::f2xyz(fzz) * Color::D50z; + float yy_ = 65535.f * ((Lprov > Color::epskap) ? fyy * fyy*fyy : Lprov / Color::kappa); + + Color::xyz2rgb(xx_, yy_, zz_, R, G, B, wip); + + if (R < 0.0f || G < 0.0f || B < 0.0f) { +#ifdef _DEBUG + negsat++; +#endif + Chprov *= 0.98f; + inGamut = false; + } + + // if "highlight reconstruction" enabled don't control Gamut for highlights + if ((!highlight) && (R > 65535.0f || G > 65535.0f || B > 65535.0f)) { +#ifdef _DEBUG + moresat++; +#endif + Chprov *= 0.98f; + inGamut = false; + } + } while (!inGamut); + + //put new values in Lab + dest->L[i][j] = Lprov * 327.68f; + dest->a[i][j] = aprovn * 327.68f; + dest->b[i][j] = bprovn * 327.68f; } - } +} // end of parallelization + +#ifdef _DEBUG +t2e.set(); + +if (settings->verbose) { + printf("Vibrance local (performed in %d usec):\n", t2e.etime(t1e)); + printf(" Gamut: G1negat=%iiter G165535=%iiter G2negsat=%iiter G265535=%iiter\n", negat, moreRGB, negsat, moresat); if (MunsDebugInfo) { - delete MunsDebugInfo; + printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad depass=%u\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); } +} + +if (MunsDebugInfo) { + delete MunsDebugInfo; +} #endif - +*/ } void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabImage* bufexporig, LabImage* lab, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve) { + // TODO Locallab + /* //exposure local float maxran = 65536.f; //65536 @@ -1675,11 +1685,11 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm const float hlrange = maxran - shoulder; -#define TSE 112 + #define TSE 112 -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel if (multiThread) -#endif + #endif { char *buffer; @@ -1695,9 +1705,9 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm int tW; int tH; -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp for schedule(dynamic) collapse(2) -#endif + #endif for (int ii = 0; ii < bfh; ii += TSE) for (int jj = 0; jj < bfw; jj += TSE) { @@ -1741,13 +1751,13 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - + Ltemp[ti * TSE + tj] = tonecurve[Ltemp[ti * TSE + tj] ]; } } -/* + /* if (lp.chro != 0) { for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { @@ -1761,29 +1771,29 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm } } } -*/ + *//* - bool vasy = true; + bool vasy = true; - if (vasy) { - // ready, fill lab - for (int i = istart, ti = 0; i < tH; i++, ti++) { - for (int j = jstart, tj = 0; j < tW; j++, tj++) { + if (vasy) { + // ready, fill lab + for (int i = istart, ti = 0; i < tH; i++, ti++) { + for (int j = jstart, tj = 0; j < tW; j++, tj++) { - lab->L[i][j] = Ltemp[ti * TSE + tj]; - lab->a[i][j] = atemp[ti * TSE + tj]; - lab->b[i][j] = btemp[ti * TSE + tj]; - } + lab->L[i][j] = Ltemp[ti * TSE + tj]; + lab->a[i][j] = atemp[ti * TSE + tj]; + lab->b[i][j] = btemp[ti * TSE + tj]; } } } + } - free(buffer); + free(buffer); - } - +} +*/ } @@ -4844,17 +4854,17 @@ void ImProcFunctions::InverseContrast_Local(float ave, struct local_contra & lco static void calclight(float lum, float koef, float & lumnew, bool inv, LUTf & lightCurveloc) //replace L-curve that does not work in local or bad { -/* - float blac = 0.3f; + /* + float blac = 0.3f; - if (inv == false) { - blac = 0.99f; - } else { - if (koef < -90.f) { - blac = -0.069f * koef - 5.91f; + if (inv == false) { + blac = 0.99f; + } else { + if (koef < -90.f) { + blac = -0.069f * koef - 5.91f; + } } - } -*/ + */ if (koef >= 0.f) { // lumnew = lum + 0.2f * (33000.f - lum) * koef / 100.f; lumnew = lightCurveloc[lum]; @@ -11438,11 +11448,15 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L // } //sharpen only square area instaed of all image + // TODO Locallab + /* ImProcFunctions::deconvsharpeningloc(bufsh, hbuffer, bfw, bfh, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); + */ } else { //call from dcrop.cc - + // TODO Locallab + /* ImProcFunctions::deconvsharpeningloc(original->L, shbuffer, bfw, bfh, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); - + */ } float hueplus = hueref + dhuesha; @@ -11464,7 +11478,10 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L int GH = original->H; JaggedArray loctemp(GW, GH); + // TODO Locallab + /* ImProcFunctions::deconvsharpeningloc(original->L, shbuffer, GW, GH, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); + */ float hueplus = hueref + dhuesha; float huemoins = hueref - dhuesha; @@ -11628,13 +11645,15 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L InverseReti_Local(lp, original, transformed, tmpl, cx, cy, 0); } + // TODO Locallab + /* if (params->locallab.chrrt > 0) { if (!lp.invret && call <= 3) { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) -#endif + #endif for (int ir = 0; ir < Hd; ir += 1) for (int jr = 0; jr < Wd; jr += 1) { @@ -11645,9 +11664,9 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } else { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) -#endif + #endif for (int ir = 0; ir < GH; ir += 1) for (int jr = 0; jr < GW; jr += 1) { @@ -11661,9 +11680,9 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L if (!lp.invret && call <= 3) { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel for -#endif + #endif for (int ir = 0; ir < Hd; ir += 1) for (int jr = 0; jr < Wd; jr += 1) { @@ -11688,9 +11707,9 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } else { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) -#endif + #endif for (int ir = 0; ir < Hd; ir += 1) for (int jr = 0; jr < Wd; jr += 1) { @@ -11713,6 +11732,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } + */ delete tmpl; delete [] origBuffer; @@ -11728,6 +11748,8 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L // Gamut and Munsell control - very important do not desactivated to avoid crash + // TODO Locallab + /* if (params->locallab.avoid) { TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.working); float wip[3][3] = { @@ -11737,29 +11759,29 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L }; const bool highlight = params->toneCurve.hrenabled; const bool needHH = (lp.chro != 0.f); -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel if (multiThread) -#endif + #endif { -#ifdef __SSE2__ + #ifdef __SSE2__ float atan2Buffer[transformed->W] ALIGNED16; float sqrtBuffer[transformed->W] ALIGNED16; float sincosyBuffer[transformed->W] ALIGNED16; float sincosxBuffer[transformed->W] ALIGNED16; vfloat c327d68v = F2V(327.68f); vfloat onev = F2V(1.f); -#endif + #endif -#ifdef _OPENMP -#ifdef _DEBUG + #ifdef _OPENMP + #ifdef _DEBUG #pragma omp for schedule(dynamic,16) firstprivate(MunsDebugInfo) -#else + #else #pragma omp for schedule(dynamic,16) -#endif -#endif + #endif + #endif for (int y = 0; y < transformed->H; y++) { -#ifdef __SSE2__ + #ifdef __SSE2__ int i = 0; for (; i < transformed->W - 3; i += 4) { @@ -11802,19 +11824,19 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } -#endif + #endif for (int x = 0; x < transformed->W; x++) { float Lprov1 = transformed->L[y][x] / 327.68f; float2 sincosval; -#ifdef __SSE2__ + #ifdef __SSE2__ float HH = atan2Buffer[x]; // reading HH from line buffer even if line buffer is not filled is faster than branching float Chprov1 = sqrtBuffer[x]; sincosval.y = sincosyBuffer[x]; sincosval.x = sincosxBuffer[x]; float chr = 0.f; -#else + #else float aa = transformed->a[y][x]; float bb = transformed->b[y][x]; float HH = 0.f, chr = 0.f; @@ -11833,19 +11855,19 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L sincosval.x = bb / (Chprov1 * 327.68f); } -#endif + #endif -#ifdef _DEBUG + #ifdef _DEBUG bool neg = false; bool more_rgb = false; Chprov1 = min(Chprov1, chr); Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.92f, neg, more_rgb); -#else + #else Color::pregamutlab(Lprov1, HH, chr); Chprov1 = min(Chprov1, chr); Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.92f); -#endif + #endif transformed->L[y][x] = Lprov1 * 327.68f; transformed->a[y][x] = 327.68f * Chprov1 * sincosval.y; @@ -11857,11 +11879,11 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L float correctlum = 0.f; float memChprov = sqrtf(SQR(original->a[y][x]) + SQR(original->b[y][x])) / 327.68f; float Chprov = sqrtf(SQR(transformed->a[y][x]) + SQR(transformed->b[y][x])) / 327.68f; -#ifdef _DEBUG + #ifdef _DEBUG Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); -#else + #else Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum); -#endif + #endif if (fabs(correctionHue) < 0.015f) { HH += correctlum; // correct only if correct Munsell chroma very little. @@ -11876,6 +11898,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } } + */ #ifdef _DEBUG diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 8ff1357f3..daff210d2 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -804,6 +804,8 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e void ImProcFunctions::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) { + // TODO Locallab + /* BENCHFUN bool py = true; @@ -872,9 +874,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co const double shradius = mapmet == 4 ? 40 : 40.; constexpr int it = 1;//in case of !! -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel for -#endif + #endif for (int i = 0; i < H_L; i++) for (int j = 0; j < W_L; j++) { @@ -901,9 +903,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co float *buffer = new float[W_L * H_L]; for (int scale = scal - 1; scale >= 0; scale--) { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel -#endif + #endif { if (scale == scal - 1) @@ -914,9 +916,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co // out was modified in last iteration => restore it if (((mapmet == 4)) && it == 1) { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp for -#endif + #endif for (int i = 0; i < H_L; i++) { for (int j = 0; j < W_L; j++) { @@ -931,9 +933,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co if ((mapmet == 4) && it == 1 && scale > 0) { // out will be modified => store it for use in next iteration. We even don't need a new buffer because 'buffer' is free after gaussianBlur :) -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp for -#endif + #endif for (int i = 0; i < H_L; i++) { for (int j = 0; j < W_L; j++) { @@ -956,9 +958,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co if ((mapmet == 4) && it == 1) { -#ifdef _OPENMP + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) -#endif + #endif for (int i = 0; i < H_L; i++) { for (int j = 0; j < W_L; j++) { @@ -974,20 +976,20 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co } -#ifdef __SSE2__ + #ifdef __SSE2__ vfloat pondv = F2V(pond); vfloat limMinv = F2V(ilimD); vfloat limMaxv = F2V(limD); -#endif -#ifdef _OPENMP + #endif + #ifdef _OPENMP #pragma omp parallel for -#endif + #endif for (int i = 0; i < H_L; i++) { int j = 0; -#ifdef __SSE2__ + #ifdef __SSE2__ if (useHslLin) { //keep in case of ?? for (; j < W_L - 3; j += 4) { @@ -999,7 +1001,7 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co } } -#endif + #endif if (useHslLin) { for (; j < W_L; j++) { @@ -1067,173 +1069,173 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co // luminance[i][j] *= (-1.f + 4.f * wavRETCcurve[absciss]); //new transmission } - */ - // median filter on transmission ==> reduce artifacts - bool ty = false; + *//* + // median filter on transmission ==> reduce artifacts + bool ty = false; - if (ty) {//not used here to simplify interface - int wid = W_L; - int hei = H_L; - float *tmL[hei] ALIGNED16; - float *tmLBuffer = new float[wid * hei]; - int borderL = 1; - - for (int i = 0; i < hei; i++) { - tmL[i] = &tmLBuffer[i * wid]; - } - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = borderL; i < hei - borderL; i++) { - // float pp[9], temp; - - for (int j = borderL; j < wid - borderL; j++) { - tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 - } - } - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = borderL; i < hei - borderL; i++) { - for (int j = borderL; j < wid - borderL; j++) { - luminance[i][j] = tmL[i][j]; - } - } - - delete [] tmLBuffer; + if (ty) {//not used here to simplify interface + int wid = W_L; + int hei = H_L; + float *tmL[hei] ALIGNED16; + float *tmLBuffer = new float[wid * hei]; + int borderL = 1; + for (int i = 0; i < hei; i++) { + tmL[i] = &tmLBuffer[i * wid]; } - // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - // mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); - mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); - - } - - float epsil = 0.1f; - - mini = mean - vart * stddv; - - if (mini < mintr) { - mini = mintr + epsil; - } - - maxi = mean + vart * stddv; - - if (maxi > maxtr) { - maxi = maxtr - epsil; - } - - delta = maxi - mini; - //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); - - if (!delta) { - delta = 1.0f; - } - - float cdfactor = 32768.f / delta; - maxCD = -9999999.f; - minCD = 9999999.f; - - //prepare work for curve gain #ifdef _OPENMP - #pragma omp parallel for + #pragma omp parallel for #endif - for (int i = 0; i < H_L; i++) { - for (int j = 0; j < W_L; j++) { - luminance[i][j] = luminance[i][j] - mini; + for (int i = borderL; i < hei - borderL; i++) { + // float pp[9], temp; + + for (int j = borderL; j < wid - borderL; j++) { + tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 + } } + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = borderL; i < hei - borderL; i++) { + for (int j = borderL; j < wid - borderL; j++) { + luminance[i][j] = tmL[i][j]; + } + } + + delete [] tmLBuffer; + } - mean = 0.f; - stddv = 0.f; // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - + // mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); - float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; - // bool gaincurve = false; //wavRETgainCcurve - const bool hasWavRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f; - - if (hasWavRetGainCurve) { //if curve - asig = 0.166666f / stddv; - bsig = 0.5f - asig * mean; - amax = 0.333333f / (maxtr - mean - stddv); - bmax = 1.f - amax * maxtr; - amin = 0.333333f / (mean - stddv - mintr); - bmin = -amin * mintr; - - asig *= 500.f; - bsig *= 500.f; - amax *= 500.f; - bmax *= 500.f; - amin *= 500.f; - bmin *= 500.f; - cdfactor *= 2.f; - } - - - const float maxclip = (chrome == 0 ? 32768.f : 50000.f); - float str = strength * (chrome == 0 ? 1.f : chrT); -#ifdef _OPENMP - #pragma omp parallel -#endif - { - // float absciss; - float cdmax = -999999.f, cdmin = 999999.f; - float gan = 0.5f; -#ifdef _OPENMP - #pragma omp for schedule(dynamic,16) -#endif - - for (int i = 0; i < H_L; i ++) - for (int j = 0; j < W_L; j++) { - if (hasWavRetGainCurve) { - float absciss; - - if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { - absciss = asig * luminance[i][j] + bsig; - } else if (luminance[i][j] >= mean) { - absciss = amax * luminance[i][j] + bmax; - } else { - absciss = amin * luminance[i][j] + bmin; - } - - gan = locRETgainCcurve[absciss]; //new gain function transmission - } - - float cd = gan * cdfactor * luminance[i][j] + offse; - - cdmax = cd > cdmax ? cd : cdmax; - cdmin = cd < cdmin ? cd : cdmin; - luminance[i][j] = LIM(cd, 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j]; - // templ[i][j] = LIM( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; - // luminance[i][j] = LIM( cd, 0.f, maxclip ); - } - -#ifdef _OPENMP - #pragma omp critical -#endif - { - maxCD = maxCD > cdmax ? maxCD : cdmax; - minCD = minCD < cdmin ? minCD : cdmin; - } - - } - - Tmean = mean; - Tsigma = stddv; - Tmin = mintr; - Tmax = maxtr; - } + float epsil = 0.1f; + + mini = mean - vart * stddv; + + if (mini < mintr) { + mini = mintr + epsil; + } + + maxi = mean + vart * stddv; + + if (maxi > maxtr) { + maxi = maxtr - epsil; + } + + delta = maxi - mini; + //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); + + if (!delta) { + delta = 1.0f; + } + + float cdfactor = 32768.f / delta; + maxCD = -9999999.f; + minCD = 9999999.f; + + //prepare work for curve gain +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H_L; i++) { + for (int j = 0; j < W_L; j++) { + luminance[i][j] = luminance[i][j] - mini; + } + } + + mean = 0.f; + stddv = 0.f; + // I call mean_stddv2 instead of mean_stddv ==> logBetaGain + + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); + float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; + // bool gaincurve = false; //wavRETgainCcurve + const bool hasWavRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f; + + if (hasWavRetGainCurve) { //if curve + asig = 0.166666f / stddv; + bsig = 0.5f - asig * mean; + amax = 0.333333f / (maxtr - mean - stddv); + bmax = 1.f - amax * maxtr; + amin = 0.333333f / (mean - stddv - mintr); + bmin = -amin * mintr; + + asig *= 500.f; + bsig *= 500.f; + amax *= 500.f; + bmax *= 500.f; + amin *= 500.f; + bmin *= 500.f; + cdfactor *= 2.f; + } + + + const float maxclip = (chrome == 0 ? 32768.f : 50000.f); + float str = strength * (chrome == 0 ? 1.f : chrT); +#ifdef _OPENMP + #pragma omp parallel +#endif + { + // float absciss; + float cdmax = -999999.f, cdmin = 999999.f; + float gan = 0.5f; +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int i = 0; i < H_L; i ++) + for (int j = 0; j < W_L; j++) { + if (hasWavRetGainCurve) { + float absciss; + + if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { + absciss = asig * luminance[i][j] + bsig; + } else if (luminance[i][j] >= mean) { + absciss = amax * luminance[i][j] + bmax; + } else { + absciss = amin * luminance[i][j] + bmin; + } + + gan = locRETgainCcurve[absciss]; //new gain function transmission + } + + float cd = gan * cdfactor * luminance[i][j] + offse; + + cdmax = cd > cdmax ? cd : cdmax; + cdmin = cd < cdmin ? cd : cdmin; + luminance[i][j] = LIM(cd, 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j]; + // templ[i][j] = LIM( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; + // luminance[i][j] = LIM( cd, 0.f, maxclip ); + } + +#ifdef _OPENMP + #pragma omp critical +#endif + { + maxCD = maxCD > cdmax ? maxCD : cdmax; + minCD = minCD < cdmin ? minCD : cdmin; + } + + } + + Tmean = mean; + Tsigma = stddv; + Tmin = mintr; + Tmax = maxtr; } -} \ No newline at end of file + + +*/ +} +} diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 0829f9ac4..eb90a5038 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -521,6 +521,24 @@ enum ProcEventCode { EvRGBEnabled = 491, EvLEnabled = 492, // EvPixelShiftOneGreen = 493, can be reused + EvLocallabSpotCreated = 494, + EvLocallabSpotDeleted = 495, + EvLocallabSpotSelected = 496, + EvLocallabSpotName = 497, + EvLocallabSpotVisibility = 498, + EvLocallabSpotShape = 499, + EvLocallabSpotSpotMethod = 500, + EvLocallabSpotShapeMethod = 501, + EvLocallabSpotLocX = 502, + EvLocallabSpotLocXL = 503, + EvLocallabSpotLocY = 504, + EvLocallabSpotLocYT = 505, + EvLocallabSpotCenter = 506, + EvLocallabSpotCircrad = 507, + EvLocallabSpotQualityMethod = 508, + EvLocallabSpotTransit = 509, + EvLocallabSpotThresh = 510, + EvLocallabSpotIter = 511, NUMOFEVENTS diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 65590b3d8..387e03858 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -330,9 +330,9 @@ curveMode(ToneCurveParams::TcMode::STD), saturation(0), shcompr(50), hlcompr(0), - hlcomprthresh(33), - histmatching(false), - clampOOG(true) + hlcomprthresh(33), + histmatching(false), + clampOOG(true) { } @@ -645,11 +645,11 @@ colorCurve{ 0.25 }, satProtectionThreshold(30), -saturatedOpacity(80), -strength(50), -balance(0), -hlColSat(60, 80, false), -shadowsColSat(80, 208, false), + saturatedOpacity(80), + strength(50), + balance(0), + hlColSat(60, 80, false), + shadowsColSat(80, 208, false), clcurve{ DCT_NURBS, 0.00, @@ -681,11 +681,11 @@ greenhigh(0.0), bluehigh(0.0), satlow(0.0), sathigh(0.0), - lumamode(true), - labgridALow(0.0), - labgridBLow(0.0), - labgridAHigh(0.0), - labgridBHigh(0.0) +lumamode(true), +labgridALow(0.0), +labgridBLow(0.0), +labgridAHigh(0.0), +labgridBHigh(0.0) { } @@ -1849,7 +1849,7 @@ autoc(false), enabledcc(true), enabled(false), filter("None"), - setting("RGB-Rel"), +setting("RGB-Rel"), method("Desaturation"), mixerRed(33), mixerOrange(33), @@ -2091,7 +2091,7 @@ enabled(false), expfinal(false), exptoning(false), expnoise(false), - Lmethod(4), + Lmethod(4), CLmethod("all"), Backmethod("grey"), Tilesmethod("full"), @@ -2261,6 +2261,28 @@ void WaveletParams::getCurves( } LocallabParams::LocallabParams() : + enabled(false), + nbspot(0), + selspot(0), + // Control spot settings + id(), + name(), + isvisible(), + shape(), + spotMethod(), + shapeMethod(), + locX(), + locXL(), + locY(), + locYT(), + centerX(), + centerY(), + circrad(), + qualityMethod(), + transit(), + thresh(), + iter(), + llcurve{ DCT_NURBS, 0.0, @@ -2368,7 +2390,8 @@ HHcurve{ }, skintonescurve { DCT_Linear -}, +} +/* enabled(false), degree(0), locY(250), @@ -2477,67 +2500,72 @@ expdenoi(false), threshold(20), chromacbdl(0), spotduplicated(false) +*/ { } bool LocallabParams::operator ==(const LocallabParams& other) const { - + return enabled == other.enabled - && avoid == other.avoid - && invers == other.invers - && spotduplicated == other.spotduplicated - && cutpast == other.cutpast - && lastdust == other.lastdust - && curvactiv == other.curvactiv - && activlum == other.activlum - && inversrad == other.inversrad - && inversret == other.inversret - && inverssha == other.inverssha - && degree == other.degree - && Smethod == other.Smethod - && Exclumethod == other.Exclumethod - && shapemethod == other.shapemethod - && retinexMethod == other.retinexMethod - && blurMethod == other.blurMethod - && dustMethod == other.dustMethod - && qualityMethod == other.qualityMethod - && qualitycurveMethod == other.qualitycurveMethod - && locY == other.locY + && nbspot == other.nbspot + && selspot == other.selspot + // Control spot settings + && id == other.id + && name == other.name + && isvisible == other.isvisible + && shape == other.shape + && spotMethod == other.spotMethod + && shapeMethod == other.shapeMethod && locX == other.locX - && locYT == other.locYT && locXL == other.locXL + && locY == other.locY + && locYT == other.locYT && centerX == other.centerX && centerY == other.centerY && circrad == other.circrad - && centerXbuf == other.centerXbuf - && centerYbuf == other.centerYbuf - && adjblur == other.adjblur - && thres == other.thres - && proxi == other.proxi - && lightness == other.lightness - && contrast == other.contrast - && chroma == other.chroma - && warm == other.warm - && expcomp == other.expcomp - && hlcompr == other.hlcompr - && hlcomprthresh == other.hlcomprthresh - && shcompr == other.shcompr - && black == other.black - && pastels == other.pastels - && sensiv == other.sensiv - && saturated == other.saturated - && psthreshold == other.psthreshold + && qualityMethod == other.qualityMethod + && transit == other.transit + && thresh == other.thresh + && iter == other.iter; + /* + && qualityMethod == other.qualityMethod + && qualitycurveMethod == other.qualitycurveMethod + && locY == other.locY + && locX == other.locX + && locYT == other.locYT + && locXL == other.locXL + && centerX == other.centerX + && centerY == other.centerY + && circrad == other.circrad + && centerXbuf == other.centerXbuf + && centerYbuf == other.centerYbuf + && adjblur == other.adjblur + && thres == other.thres + && proxi == other.proxi + && lightness == other.lightness + && contrast == other.contrast + && chroma == other.chroma + && warm == other.warm + && expcomp == other.expcomp + && hlcompr == other.hlcompr + && hlcomprthresh == other.hlcomprthresh + && shcompr == other.shcompr + && black == other.black + && pastels == other.pastels + && sensiv == other.sensiv + && saturated == other.saturated + && psthreshold == other.psthreshold && [this, &other]() -> bool { - for (unsigned int i = 0; i < 5; ++i) - { - if (mult[i] != other.mult[i]) { - return false; - } + for (unsigned int i = 0; i < 5; ++i) + { + if (mult[i] != other.mult[i]) { + return false; } + } - return true; + return true; }() && protectskins == other.protectskins && avoidcolorshift == other.avoidcolorshift @@ -2602,7 +2630,11 @@ bool LocallabParams::operator ==(const LocallabParams& other) const && llcurve == other.llcurve && cccurve == other.cccurve && LHcurve == other.LHcurve - && HHcurve == other.HHcurve; + && HHcurve == other.HHcurve + && id == other.id + && name == other.name + && isvisible == other.isvisible; + */ } @@ -3079,6 +3111,9 @@ void ProcParams::setDefaults() int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bool fnameAbsolute, ParamsEdited* pedited) { + // TODO Locallab printf + printf("Save to .pp3 file\n"); + if (fname.empty() && fname2.empty()) { return 0; } @@ -3473,6 +3508,31 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo // Locallab saveToKeyfile(!pedited || pedited->locallab.enabled, "Locallab", "Enabled", locallab.enabled, keyFile); + saveToKeyfile(!pedited || pedited->locallab.nbspot, "Locallab", "Nbspot", locallab.nbspot, keyFile); + saveToKeyfile(!pedited || pedited->locallab.selspot, "Locallab", "Selspot", locallab.selspot, keyFile); + + for (int i = 0; i < locallab.nbspot; i++) { + // Control spot settings + saveToKeyfile(!pedited || pedited->locallab.id, "Locallab", "Id_" + std::to_string(i), locallab.id.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.name, "Locallab", "Name_" + std::to_string(i), locallab.name.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.isvisible, "Locallab", "Isvisible_" + std::to_string(i), locallab.isvisible.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.shape, "Locallab", "Shape_" + std::to_string(i), locallab.shape.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.spotMethod, "Locallab", "SpotMethod_" + std::to_string(i), locallab.spotMethod.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.shapeMethod, "Locallab", "ShapeMethod_" + std::to_string(i), locallab.shapeMethod.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.locX, "Locallab", "LocX_" + std::to_string(i), locallab.locX.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.locXL, "Locallab", "LocXL_" + std::to_string(i), locallab.locXL.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.locY, "Locallab", "LocY_" + std::to_string(i), locallab.locY.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.locYT, "Locallab", "LocYT_" + std::to_string(i), locallab.locYT.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.centerX, "Locallab", "CenterX_" + std::to_string(i), locallab.centerX.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.centerY, "Locallab", "CenterY_" + std::to_string(i), locallab.centerY.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.circrad, "Locallab", "Circrad_" + std::to_string(i), locallab.circrad.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.qualityMethod, "Locallab", "QualityMethod_" + std::to_string(i), locallab.qualityMethod.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.transit, "Locallab", "Transit_" + std::to_string(i), locallab.transit.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.thresh, "Locallab", "Thresh_" + std::to_string(i), locallab.thresh.at(i), keyFile); + saveToKeyfile(!pedited || pedited->locallab.iter, "Locallab", "Iter_" + std::to_string(i), locallab.iter.at(i), keyFile); + } + + /* saveToKeyfile(!pedited || pedited->locallab.expcolor, "Locallab", "Expcolor", locallab.expcolor, keyFile); saveToKeyfile(!pedited || pedited->locallab.expexpose, "Locallab", "Expexpose", locallab.expexpose, keyFile); saveToKeyfile(!pedited || pedited->locallab.expvibrance, "Locallab", "Expvibrance", locallab.expvibrance, keyFile); @@ -3590,8 +3650,10 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.scaltm, "Locallab", "Scaltm", locallab.scaltm, keyFile); saveToKeyfile(!pedited || pedited->locallab.rewei, "Locallab", "Rewei", locallab.rewei, keyFile); saveToKeyfile(!pedited || pedited->locallab.spotduplicated, "Locallab", "Spotduplicated", locallab.spotduplicated, keyFile); - - + saveToKeyfile(!pedited || pedited->locallab.id, "Locallab", "Id", locallab.id, keyFile); + saveToKeyfile(!pedited || pedited->locallab.name, "Locallab", "Name", locallab.name, keyFile); + saveToKeyfile(!pedited || pedited->locallab.isvisible, "Locallab", "Isvisible", locallab.isvisible, keyFile); + */ // Post-crop vignette saveToKeyfile(!pedited || pedited->pcvignette.enabled, "PCVignette", "Enabled", pcvignette.enabled, keyFile); @@ -3998,6 +4060,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Exposure", "Curve", pedited, toneCurve.curve, pedited->toneCurve.curve); assignFromKeyfile(keyFile, "Exposure", "Curve2", pedited, toneCurve.curve2, pedited->toneCurve.curve2); } + assignFromKeyfile(keyFile, "Exposure", "HistogramMatching", pedited, toneCurve.histmatching, pedited->toneCurve.histmatching); assignFromKeyfile(keyFile, "Exposure", "ClampOOG", pedited, toneCurve.clampOOG, pedited->toneCurve.clampOOG); } @@ -4204,14 +4267,17 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) if (keyFile.has_group("Sharpening")) { assignFromKeyfile(keyFile, "Sharpening", "Enabled", pedited, sharpening.enabled, pedited->sharpening.enabled); + if (ppVersion >= 334) { assignFromKeyfile(keyFile, "Sharpening", "Contrast", pedited, sharpening.contrast, pedited->sharpening.contrast); } else { sharpening.contrast = 0; + if (pedited) { pedited->sharpening.contrast = true; } } + assignFromKeyfile(keyFile, "Sharpening", "Radius", pedited, sharpening.radius, pedited->sharpening.radius); assignFromKeyfile(keyFile, "Sharpening", "Amount", pedited, sharpening.amount, pedited->sharpening.amount); @@ -4255,14 +4321,17 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "SharpenMicro", "Enabled", pedited, sharpenMicro.enabled, pedited->sharpenMicro.enabled); assignFromKeyfile(keyFile, "SharpenMicro", "Matrix", pedited, sharpenMicro.matrix, pedited->sharpenMicro.matrix); assignFromKeyfile(keyFile, "SharpenMicro", "Strength", pedited, sharpenMicro.amount, pedited->sharpenMicro.amount); + if (ppVersion >= 334) { assignFromKeyfile(keyFile, "SharpenMicro", "Contrast", pedited, sharpenMicro.contrast, pedited->sharpenMicro.contrast); } else { sharpenMicro.contrast = 0; + if (pedited) { pedited->sharpenMicro.contrast = true; } } + assignFromKeyfile(keyFile, "SharpenMicro", "Uniformity", pedited, sharpenMicro.uniformity, pedited->sharpenMicro.uniformity); } @@ -4443,7 +4512,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "FattalToneMapping", "Anchor", pedited, fattal.anchor, pedited->fattal.anchor); } - if (keyFile.has_group ("Shadows & Highlights") && ppVersion >= 333) { + if (keyFile.has_group("Shadows & Highlights") && ppVersion >= 333) { assignFromKeyfile(keyFile, "Shadows & Highlights", "Enabled", pedited, sh.enabled, pedited->sh.enabled); assignFromKeyfile(keyFile, "Shadows & Highlights", "Highlights", pedited, sh.highlights, pedited->sh.highlights); assignFromKeyfile(keyFile, "Shadows & Highlights", "HighlightTonalWidth", pedited, sh.htonalwidth, pedited->sh.htonalwidth); @@ -4599,6 +4668,52 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) if (keyFile.has_group("Locallab")) { assignFromKeyfile(keyFile, "Locallab", "Enabled", pedited, locallab.enabled, pedited->locallab.enabled); + assignFromKeyfile(keyFile, "Locallab", "Nbspot", pedited, locallab.nbspot, pedited->locallab.nbspot); + assignFromKeyfile(keyFile, "Locallab", "Selspot", pedited, locallab.selspot, pedited->locallab.selspot); + + // Resize locallab settings if required + if (locallab.nbspot > (int)locallab.id.size()) { + locallab.id.resize(locallab.nbspot); + locallab.name.resize(locallab.nbspot); + locallab.isvisible.resize(locallab.nbspot); + locallab.shape.resize(locallab.nbspot); + locallab.spotMethod.resize(locallab.nbspot); + locallab.shapeMethod.resize(locallab.nbspot); + locallab.locX.resize(locallab.nbspot); + locallab.locXL.resize(locallab.nbspot); + locallab.locY.resize(locallab.nbspot); + locallab.locYT.resize(locallab.nbspot); + locallab.centerX.resize(locallab.nbspot); + locallab.centerY.resize(locallab.nbspot); + locallab.circrad.resize(locallab.nbspot); + locallab.qualityMethod.resize(locallab.nbspot); + locallab.transit.resize(locallab.nbspot); + locallab.thresh.resize(locallab.nbspot); + locallab.iter.resize(locallab.nbspot); + } + + for (int i = 0; i < locallab.nbspot; i++) { + // Control spot settings + assignFromKeyfile(keyFile, "Locallab", "Id_" + std::to_string(i), pedited, locallab.id.at(i), pedited->locallab.id); + assignFromKeyfile(keyFile, "Locallab", "Name_" + std::to_string(i), pedited, locallab.name.at(i), pedited->locallab.name); + assignFromKeyfile(keyFile, "Locallab", "Isvisible_" + std::to_string(i), pedited, locallab.isvisible.at(i), pedited->locallab.isvisible); + assignFromKeyfile(keyFile, "Locallab", "Shape_" + std::to_string(i), pedited, locallab.shape.at(i), pedited->locallab.shape); + assignFromKeyfile(keyFile, "Locallab", "SpotMethod_" + std::to_string(i), pedited, locallab.spotMethod.at(i), pedited->locallab.spotMethod); + assignFromKeyfile(keyFile, "Locallab", "ShapeMethod_" + std::to_string(i), pedited, locallab.shapeMethod.at(i), pedited->locallab.shapeMethod); + assignFromKeyfile(keyFile, "Locallab", "LocX_" + std::to_string(i), pedited, locallab.locX.at(i), pedited->locallab.locX); + assignFromKeyfile(keyFile, "Locallab", "LocXL_" + std::to_string(i), pedited, locallab.locXL.at(i), pedited->locallab.locXL); + assignFromKeyfile(keyFile, "Locallab", "LocY_" + std::to_string(i), pedited, locallab.locY.at(i), pedited->locallab.locY); + assignFromKeyfile(keyFile, "Locallab", "LocYT_" + std::to_string(i), pedited, locallab.locYT.at(i), pedited->locallab.locYT); + assignFromKeyfile(keyFile, "Locallab", "CenterX_" + std::to_string(i), pedited, locallab.centerX.at(i), pedited->locallab.centerX); + assignFromKeyfile(keyFile, "Locallab", "CenterY_" + std::to_string(i), pedited, locallab.centerY.at(i), pedited->locallab.centerY); + assignFromKeyfile(keyFile, "Locallab", "Circrad_" + std::to_string(i), pedited, locallab.circrad.at(i), pedited->locallab.circrad); + assignFromKeyfile(keyFile, "Locallab", "QualityMethod_" + std::to_string(i), pedited, locallab.qualityMethod.at(i), pedited->locallab.qualityMethod); + assignFromKeyfile(keyFile, "Locallab", "Transit_" + std::to_string(i), pedited, locallab.transit.at(i), pedited->locallab.transit); + assignFromKeyfile(keyFile, "Locallab", "Thresh_" + std::to_string(i), pedited, locallab.thresh.at(i), pedited->locallab.thresh); + assignFromKeyfile(keyFile, "Locallab", "Iter_" + std::to_string(i), pedited, locallab.iter.at(i), pedited->locallab.iter); + } + + /* assignFromKeyfile(keyFile, "Locallab", "Expcolor", pedited, locallab.expcolor, pedited->locallab.expcolor); assignFromKeyfile(keyFile, "Locallab", "Expcbdl", pedited, locallab.expcbdl, pedited->locallab.expcbdl); assignFromKeyfile(keyFile, "Locallab", "Expexpose", pedited, locallab.expexpose, pedited->locallab.expexpose); @@ -4733,7 +4848,10 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Threshold", pedited, locallab.threshold, pedited->locallab.threshold); assignFromKeyfile(keyFile, "Locallab", "Chromacbdl", pedited, locallab.chromacbdl, pedited->locallab.chromacbdl); assignFromKeyfile(keyFile, "Locallab", "Spotduplicated", pedited, locallab.spotduplicated, pedited->locallab.spotduplicated); - + assignFromKeyfile(keyFile, "Locallab", "Id", pedited, locallab.id, pedited->locallab.id); + assignFromKeyfile(keyFile, "Locallab", "Name", pedited, locallab.name, pedited->locallab.name); + assignFromKeyfile(keyFile, "Locallab", "Isvisible", pedited, locallab.isvisible, pedited->locallab.isvisible); + */ } @@ -4862,15 +4980,18 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Wavelet", "Lipst", pedited, wavelet.lipst, pedited->wavelet.lipst); assignFromKeyfile(keyFile, "Wavelet", "AvoidColorShift", pedited, wavelet.avoid, pedited->wavelet.avoid); assignFromKeyfile(keyFile, "Wavelet", "TMr", pedited, wavelet.tmr, pedited->wavelet.tmr); + if (ppVersion < 331) { // wavelet.Lmethod was a string before version 331 Glib::ustring temp; assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, temp, pedited->wavelet.Lmethod); + if (!temp.empty()) { wavelet.Lmethod = std::stoi(temp); } } else { assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, wavelet.Lmethod, pedited->wavelet.Lmethod); } + assignFromKeyfile(keyFile, "Wavelet", "ChoiceLevMethod", pedited, wavelet.CLmethod, pedited->wavelet.CLmethod); assignFromKeyfile(keyFile, "Wavelet", "BackMethod", pedited, wavelet.Backmethod, pedited->wavelet.Backmethod); assignFromKeyfile(keyFile, "Wavelet", "TilesMethod", pedited, wavelet.Tilesmethod, pedited->wavelet.Tilesmethod); @@ -5337,12 +5458,15 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "RAW Bayer", "PreBlack3", pedited, raw.bayersensor.black3, pedited->raw.bayersensor.exBlack3); assignFromKeyfile(keyFile, "RAW Bayer", "PreTwoGreen", pedited, raw.bayersensor.twogreen, pedited->raw.bayersensor.exTwoGreen); assignFromKeyfile(keyFile, "RAW Bayer", "LineDenoise", pedited, raw.bayersensor.linenoise, pedited->raw.bayersensor.linenoise); + if (keyFile.has_key("RAW Bayer", "LineDenoiseDirection")) { raw.bayersensor.linenoiseDirection = RAWParams::BayerSensor::LineNoiseDirection(keyFile.get_integer("RAW Bayer", "LineDenoiseDirection")); + if (pedited) { pedited->raw.bayersensor.linenoiseDirection = true; } } + assignFromKeyfile(keyFile, "RAW Bayer", "GreenEqThreshold", pedited, raw.bayersensor.greenthresh, pedited->raw.bayersensor.greenEq); assignFromKeyfile(keyFile, "RAW Bayer", "DCBIterations", pedited, raw.bayersensor.dcb_iterations, pedited->raw.bayersensor.dcbIterations); assignFromKeyfile(keyFile, "RAW Bayer", "DCBEnhance", pedited, raw.bayersensor.dcb_enhance, pedited->raw.bayersensor.dcbEnhance); @@ -5358,9 +5482,11 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) } assignFromKeyfile(keyFile, "RAW Bayer", "PixelShiftEperIso", pedited, raw.bayersensor.pixelShiftEperIso, pedited->raw.bayersensor.pixelShiftEperIso); + if (ppVersion < 332) { raw.bayersensor.pixelShiftEperIso += 1.0; } + assignFromKeyfile(keyFile, "RAW Bayer", "PixelShiftSigma", pedited, raw.bayersensor.pixelShiftSigma, pedited->raw.bayersensor.pixelShiftSigma); assignFromKeyfile(keyFile, "RAW Bayer", "PixelShiftShowMotion", pedited, raw.bayersensor.pixelShiftShowMotion, pedited->raw.bayersensor.pixelShiftShowMotion); assignFromKeyfile(keyFile, "RAW Bayer", "PixelShiftShowMotionMaskOnly", pedited, raw.bayersensor.pixelShiftShowMotionMaskOnly, pedited->raw.bayersensor.pixelShiftShowMotionMaskOnly); @@ -5375,12 +5501,14 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) if (ppVersion < 336) { if (keyFile.has_key("RAW Bayer", "pixelShiftLmmse")) { - bool useLmmse = keyFile.get_boolean ("RAW Bayer", "pixelShiftLmmse"); + bool useLmmse = keyFile.get_boolean("RAW Bayer", "pixelShiftLmmse"); + if (useLmmse) { raw.bayersensor.pixelShiftDemosaicMethod = raw.bayersensor.getPSDemosaicMethodString(RAWParams::BayerSensor::PSDemosaicMethod::LMMSE); } else { raw.bayersensor.pixelShiftDemosaicMethod = raw.bayersensor.getPSDemosaicMethodString(RAWParams::BayerSensor::PSDemosaicMethod::AMAZE); } + if (pedited) { pedited->raw.bayersensor.pixelShiftDemosaicMethod = true; } diff --git a/rtengine/procparams.h b/rtengine/procparams.h index b2ba036dd..d8880ab0b 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -899,6 +899,28 @@ struct GradientParams { * Parameters of the Local Lab */ struct LocallabParams { + bool enabled; + int nbspot; + int selspot; + // Control spot settings + std::vector id; + std::vector name; + std::vector isvisible; + std::vector shape; // ELI, RECT + std::vector spotMethod; // norm, exc + std::vector shapeMethod; // IND, SYM, INDSL, SYMSL + std::vector locX; + std::vector locXL; + std::vector locY; + std::vector locYT; + std::vector centerX; + std::vector centerY; + std::vector circrad; + std::vector qualityMethod; // std, enh, enhden + std::vector transit; + std::vector thresh; + std::vector iter; + std::vector llcurve; std::vector cccurve; std::vector excurve; @@ -908,6 +930,7 @@ struct LocallabParams { std::vector HHcurve; std::vector skintonescurve; + /* bool enabled; double degree; int locY; @@ -1009,8 +1032,12 @@ struct LocallabParams { bool expdenoi; double threshold; int chromacbdl; - bool spotduplicated; - + bool spotduplicated; + int id; + Glib::ustring name; + bool isvisible; + */ + LocallabParams(); bool operator ==(const LocallabParams& other) const; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 69b8c95da..1bd23ad7f 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -74,7 +74,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = { 0, // EvLDNEdgeTolerance: obsolete, 0, // EvCDNEnabled:obsolete, 0, // free entry - RGBCURVE|M_AUTOEXP, // EvDCPToneCurve, + RGBCURVE | M_AUTOEXP, // EvDCPToneCurve, ALLNORAW, // EvDCPIlluminant, RETINEX, // EvSHEnabled, RGBCURVE, // EvSHHighlights, @@ -419,8 +419,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { DIRPYREQUALIZER, // EvWavgreenlow DIRPYREQUALIZER, // EvWavbluelow DIRPYREQUALIZER, // EvWavNeutral - RGBCURVE|M_AUTOEXP, // EvDCPApplyLookTable, - RGBCURVE|M_AUTOEXP, // EvDCPApplyBaselineExposureOffset, + RGBCURVE | M_AUTOEXP, // EvDCPApplyLookTable, + RGBCURVE | M_AUTOEXP, // EvDCPApplyBaselineExposureOffset, ALLNORAW, // EvDCPApplyHueSatMap DIRPYREQUALIZER, // EvWavenacont DIRPYREQUALIZER, // EvWavenachrom @@ -519,7 +519,25 @@ int refreshmap[rtengine::NUMOFEVENTS] = { HDR, // EvTMFattalAmount ALLNORAW, // EvWBEnabled RGBCURVE, // EvRGBEnabled - LUMINANCECURVE // EvLEnabled + LUMINANCECURVE, // EvLEnabled + LUMINANCECURVE, // EvLocallabSpotCreated + LUMINANCECURVE, // EvLocallabSpotDeleted + M_VOID, // EvLocallabSpotSelected + M_VOID, // EvLocallabSpotName + M_VOID, // EvLocallabSpotVisibility + LUMINANCECURVE, // EvLocallabSpotShape + LUMINANCECURVE, // EvLocallabSpotSpotMethod + LUMINANCECURVE, // EvLocallabSpotShapeMethod + LUMINANCECURVE, // EvLocallabSpotLocX + LUMINANCECURVE, // EvLocallabSpotLocXL + LUMINANCECURVE, // EvLocallabSpotLocY + LUMINANCECURVE, // EvLocallabSpotLocYT + LUMINANCECURVE, // EvLocallabSpotCenter + LUMINANCECURVE, // EvLocallabSpotCircrad + LUMINANCECURVE, // EvLocallabSpotQualityMethod + LUMINANCECURVE, // EvLocallabSpotTransit + LUMINANCECURVE, // EvLocallabSpotThresh + LUMINANCECURVE // EvLocallabSpotIter }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 9f76b0ba3..c991293bb 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -966,7 +966,7 @@ private: LUTu histToneCurve; - ipf.rgbProc (baseImg, labView, nullptr, curve1, curve2, curve, params.toneCurve.saturation, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, expcomp, hlcompr, hlcomprthresh, dcpProf, as, histToneCurve); + ipf.rgbProc(baseImg, labView, nullptr, curve1, curve2, curve, params.toneCurve.saturation, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, expcomp, hlcompr, hlcomprthresh, dcpProf, as, histToneCurve); if (settings->verbose) { printf("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob); @@ -1040,6 +1040,8 @@ private: // bool localcutili = false; reservView->CopyFrom(labView); + // TODO Locallab + /* if (params.locallab.enabled) { MyTime t1, t2; t1.set(); @@ -2208,6 +2210,7 @@ private: } } + */ delete reservView; reservView = nullptr; @@ -2242,7 +2245,7 @@ private: } if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) && params.sharpening.enabled) { - ipf.sharpening (labView, params.sharpening); + ipf.sharpening(labView, params.sharpening); } @@ -2325,7 +2328,7 @@ private: float CAMMean = NAN; float d, dj, yb; - ipf.ciecam_02float (cieView, float (adap), 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1); + ipf.ciecam_02float(cieView, float (adap), 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1); } delete cieView; @@ -2375,13 +2378,14 @@ private: } if (labResize) { // resize lab data - if(labView->W != imw || labView->H != imh) { + if (labView->W != imw || labView->H != imh) { // resize image - tmplab = new LabImage (imw, imh); - ipf.Lanczos (labView, tmplab, tmpScale); + tmplab = new LabImage(imw, imh); + ipf.Lanczos(labView, tmplab, tmpScale); delete labView; labView = tmplab; } + cw = labView->W; ch = labView->H; @@ -2391,7 +2395,8 @@ private: labView->L[i][j] = labView->L[i][j] < 0.f ? 0.f : labView->L[i][j]; } } - ipf.sharpening (labView, params.prsharpening); + + ipf.sharpening(labView, params.prsharpening); } } diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index c86eae49f..09d5f75d3 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -8,6 +8,7 @@ #include using namespace rtengine; +using namespace rtengine::procparams; //----------------------------------------------------------------------------- // ControlSpotPanel @@ -15,82 +16,89 @@ using namespace rtengine; ControlSpotPanel::ControlSpotPanel(): EditSubscriber(ET_OBJECTS), + FoldableToolPanel(this, "controlspotpanel", M("TP_LOCALLAB_SETTINGS")), - button_add_ ("Add"), - button_delete_ ("Delete"), - button_rename_ ("Rename"), - shape_ (Gtk::manage (new MyComboBoxText ())), - spotMethod_ (Gtk::manage (new MyComboBoxText ())), - shapeMethod_ (Gtk::manage (new MyComboBoxText ())), - qualityMethod_ (Gtk::manage (new MyComboBoxText ())), + button_add_("Add"), + button_delete_("Delete"), + button_rename_("Rename"), - locX_ (Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH"), 0, 2250, 1, 250))), - locXL_ (Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH_L"), 0, 2250, 1, 250))), - locY_ (Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT"), 0, 2250, 1, 250))), - locYT_ (Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT_T"), 0, 2250, 1, 250))), - centerX_ (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CENTER_X"), -1000, 1000, 1, 0))), - centerY_ (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CENTER_Y"), -1000, 1000, 1, 0))), - circrad_ (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CIRCRADIUS"), 2, 150, 1, 18))), - transit_ (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_TRANSIT"), 5, 95, 1, 60))), - thresh_ (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_THRES"), 1, 35, 1, 18))), - iter_ (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_PROXI"), 0, 60, 1, 0))), + shape_(Gtk::manage(new MyComboBoxText())), + spotMethod_(Gtk::manage(new MyComboBoxText())), + shapeMethod_(Gtk::manage(new MyComboBoxText())), + qualityMethod_(Gtk::manage(new MyComboBoxText())), - lastObject_ (-1), - lastCoord_ (new Coord ()) + locX_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH"), 0, 2250, 1, 250))), + locXL_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH_L"), 0, 2250, 1, 250))), + locY_(Gtk::manage(new Adjuster(M("TP_LOCAL_HEIGHT"), 0, 2250, 1, 250))), + locYT_(Gtk::manage(new Adjuster(M("TP_LOCAL_HEIGHT_T"), 0, 2250, 1, 250))), + centerX_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CENTER_X"), -1000, 1000, 1, 0))), + centerY_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CENTER_Y"), -1000, 1000, 1, 0))), + circrad_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CIRCRADIUS"), 2, 150, 1, 18))), + transit_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_TRANSIT"), 5, 95, 1, 60))), + thresh_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_THRES"), 1, 35, 1, 18))), + iter_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_PROXI"), 0, 60, 1, 0))), + + lastObject_(-1), + lastCoord_(new Coord()), + + eventType(0) { - treeview_.set_grid_lines (Gtk::TREE_VIEW_GRID_LINES_VERTICAL); + treeview_.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_VERTICAL); - scrolledwindow_.add (treeview_); - scrolledwindow_.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + scrolledwindow_.add(treeview_); + scrolledwindow_.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrolledwindow_.set_min_content_height(150); - pack_start (buttonbox_); - pack_start (scrolledwindow_); + pack_start(buttonbox_); + pack_start(scrolledwindow_); buttonbox_.pack_start(button_add_, Gtk::PACK_SHRINK, 4); buttonbox_.pack_start(button_delete_, Gtk::PACK_SHRINK, 4); buttonbox_.pack_start(button_rename_); buttonbox_.set_layout(Gtk::BUTTONBOX_START); - button_add_.signal_clicked().connect ( - sigc::mem_fun (*this, &ControlSpotPanel::on_button_add)); - button_delete_.signal_clicked().connect ( - sigc::mem_fun (*this, &ControlSpotPanel::on_button_delete)); - button_rename_.signal_clicked().connect ( - sigc::mem_fun (*this, &ControlSpotPanel::on_button_rename)); + buttonaddconn_ = button_add_.signal_clicked().connect( + sigc::mem_fun(*this, &ControlSpotPanel::on_button_add)); + buttondeleteconn_ = button_delete_.signal_clicked().connect( + sigc::mem_fun(*this, &ControlSpotPanel::on_button_delete)); + buttonrenameconn_ = button_rename_.signal_clicked().connect( + sigc::mem_fun(*this, &ControlSpotPanel::on_button_rename)); - treemodel_ = Gtk::ListStore::create (spots_); + treemodel_ = Gtk::ListStore::create(spots_); - treeview_.set_model (treemodel_); - treeview_.get_selection()->signal_changed().connect( - sigc::mem_fun ( - *this, &ControlSpotPanel::controlspotChanged)); + treeview_.set_model(treemodel_); + treeviewconn_ = treeview_.get_selection()->signal_changed().connect( + sigc::mem_fun( + *this, &ControlSpotPanel::controlspotChanged)); - auto cell = Gtk::manage (new Gtk::CellRendererText()); - int cols_count = treeview_.append_column ("ID", *cell); + auto cell = Gtk::manage(new Gtk::CellRendererText()); + int cols_count = treeview_.append_column("ID", *cell); auto col = treeview_.get_column(cols_count - 1); + if (col) { - col->set_cell_data_func ( - *cell, sigc::mem_fun ( + col->set_cell_data_func( + *cell, sigc::mem_fun( *this, &ControlSpotPanel::render_id)); } - cell = Gtk::manage (new Gtk::CellRendererText()); + cell = Gtk::manage(new Gtk::CellRendererText()); cols_count = treeview_.append_column("Name", *cell); col = treeview_.get_column(cols_count - 1); + if (col) { - col->set_cell_data_func ( - *cell, sigc::mem_fun ( + col->set_cell_data_func( + *cell, sigc::mem_fun( *this, &ControlSpotPanel::render_name)); } - cell = Gtk::manage (new Gtk::CellRendererText()); + cell = Gtk::manage(new Gtk::CellRendererText()); cols_count = treeview_.append_column("Status", *cell); col = treeview_.get_column(cols_count - 1); + if (col) { - col->set_cell_data_func ( - *cell, sigc::mem_fun ( + col->set_cell_data_func( + *cell, sigc::mem_fun( *this, &ControlSpotPanel::render_isvisible)); } @@ -98,269 +106,235 @@ ControlSpotPanel::ControlSpotPanel(): // TODO Rectangle - Gtk::HBox* const ctboxshape = Gtk::manage (new Gtk::HBox ()); - Gtk::Label* const labelshape = Gtk::manage (new Gtk::Label (M ("TP_LOCALLAB_SHAPETYPE") + ":")); - ctboxshape->pack_start (*labelshape, Gtk::PACK_SHRINK, 4); - shape_->append (M ("TP_LOCALLAB_ELI")); - shape_->append (M ("TP_LOCALLAB_RECT")); - shape_->set_active (0); - shapeconn_ = shape_->signal_changed ().connect ( - sigc::mem_fun ( + Gtk::HBox* const ctboxshape = Gtk::manage(new Gtk::HBox()); + Gtk::Label* const labelshape = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_SHAPETYPE") + ":")); + ctboxshape->pack_start(*labelshape, Gtk::PACK_SHRINK, 4); + shape_->append(M("TP_LOCALLAB_ELI")); + shape_->append(M("TP_LOCALLAB_RECT")); + shape_->set_active(0); + shapeconn_ = shape_->signal_changed().connect( + sigc::mem_fun( *this, &ControlSpotPanel::shapeChanged)); - ctboxshape->pack_start (*shape_); - pack_start (*ctboxshape); + ctboxshape->pack_start(*shape_); + pack_start(*ctboxshape); - Gtk::HBox* const ctboxspotmethod = Gtk::manage (new Gtk::HBox ()); - Gtk::Label* const labelspotmethod = Gtk::manage (new Gtk::Label (M ("TP_LOCALLAB_EXCLUTYPE") + ":")); - ctboxspotmethod->pack_start (*labelspotmethod, Gtk::PACK_SHRINK, 4); - ctboxspotmethod->set_tooltip_markup (M ("TP_LOCALLAB_EXCLUTYPE_TOOLTIP")); - spotMethod_->append (M ("TP_LOCALLAB_EXNORM")); - spotMethod_->append (M ("TP_LOCALLAB_EXECLU")); - spotMethod_->set_active (0); - spotMethodconn_ = spotMethod_->signal_changed ().connect ( - sigc::mem_fun ( - *this, &ControlSpotPanel::save_ControlSpot_param)); + Gtk::HBox* const ctboxspotmethod = Gtk::manage(new Gtk::HBox()); + Gtk::Label* const labelspotmethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_EXCLUTYPE") + ":")); + ctboxspotmethod->pack_start(*labelspotmethod, Gtk::PACK_SHRINK, 4); + ctboxspotmethod->set_tooltip_markup(M("TP_LOCALLAB_EXCLUTYPE_TOOLTIP")); + spotMethod_->append(M("TP_LOCALLAB_EXNORM")); + spotMethod_->append(M("TP_LOCALLAB_EXECLU")); + spotMethod_->set_active(0); + spotMethodconn_ = spotMethod_->signal_changed().connect( + sigc::mem_fun( + *this, &ControlSpotPanel::spotMethodChanged)); ctboxspotmethod->pack_start(*spotMethod_); pack_start(*ctboxspotmethod); - Gtk::HBox* const ctboxshapemethod = Gtk::manage (new Gtk::HBox ()); - Gtk::Label* const labelshapemethod = Gtk::manage (new Gtk::Label (M ("TP_LOCALLAB_STYPE") + ":")); - ctboxshapemethod->pack_start (*labelshapemethod, Gtk::PACK_SHRINK, 4); - ctboxshapemethod->set_tooltip_markup (M ("TP_LOCALLAB_STYPE_TOOLTIP")); - shapeMethod_->append (M ("TP_LOCALLAB_IND")); - shapeMethod_->append (M ("TP_LOCALLAB_SYM")); - shapeMethod_->append (M ("TP_LOCALLAB_INDSL")); - shapeMethod_->append (M ("TP_LOCALLAB_SYMSL")); - shapeMethod_->set_active (0); - shapeMethodconn_ = shapeMethod_->signal_changed ().connect ( - sigc::mem_fun ( - *this, &ControlSpotPanel::shapeMethodeChanged)); - ctboxshapemethod->pack_start (*shapeMethod_); - pack_start (*ctboxshapemethod); + Gtk::HBox* const ctboxshapemethod = Gtk::manage(new Gtk::HBox()); + Gtk::Label* const labelshapemethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_STYPE") + ":")); + ctboxshapemethod->pack_start(*labelshapemethod, Gtk::PACK_SHRINK, 4); + ctboxshapemethod->set_tooltip_markup(M("TP_LOCALLAB_STYPE_TOOLTIP")); + shapeMethod_->append(M("TP_LOCALLAB_IND")); + shapeMethod_->append(M("TP_LOCALLAB_SYM")); + shapeMethod_->append(M("TP_LOCALLAB_INDSL")); + shapeMethod_->append(M("TP_LOCALLAB_SYMSL")); + shapeMethod_->set_active(0); + shapeMethodconn_ = shapeMethod_->signal_changed().connect( + sigc::mem_fun( + *this, &ControlSpotPanel::shapeMethodChanged)); + ctboxshapemethod->pack_start(*shapeMethod_); + pack_start(*ctboxshapemethod); - pack_start (*locX_); - locX_->setAdjusterListener (this); + pack_start(*locX_); + locX_->setAdjusterListener(this); - pack_start (*locXL_); - locXL_->setAdjusterListener (this); + pack_start(*locXL_); + locXL_->setAdjusterListener(this); - pack_start (*locY_); - locY_->setAdjusterListener (this); + pack_start(*locY_); + locY_->setAdjusterListener(this); - pack_start (*locYT_); - locYT_->setAdjusterListener (this); + pack_start(*locYT_); + locYT_->setAdjusterListener(this); - pack_start (*centerX_); - centerX_->setAdjusterListener (this); + pack_start(*centerX_); + centerX_->setAdjusterListener(this); - pack_start (*centerY_); - centerY_->setAdjusterListener (this); + pack_start(*centerY_); + centerY_->setAdjusterListener(this); - pack_start (*circrad_); - circrad_->setAdjusterListener (this); + pack_start(*circrad_); + circrad_->setAdjusterListener(this); - Gtk::HBox* const ctboxqualitymethod = Gtk::manage (new Gtk::HBox ()); - Gtk::Label* const labelqualitymethod = Gtk::manage (new Gtk::Label (M ("TP_LOCALLAB_QUAL_METHOD") + ":")); - ctboxqualitymethod->pack_start (*labelqualitymethod, Gtk::PACK_SHRINK, 4); + Gtk::HBox* const ctboxqualitymethod = Gtk::manage(new Gtk::HBox()); + Gtk::Label* const labelqualitymethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUAL_METHOD") + ":")); + ctboxqualitymethod->pack_start(*labelqualitymethod, Gtk::PACK_SHRINK, 4); ctboxqualitymethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP")); - qualityMethod_->append (M ("TP_LOCALLAB_STD")); - qualityMethod_->append (M ("TP_LOCALLAB_ENH")); - qualityMethod_->append (M ("TP_LOCALLAB_ENHDEN")); + qualityMethod_->append(M("TP_LOCALLAB_STD")); + qualityMethod_->append(M("TP_LOCALLAB_ENH")); + qualityMethod_->append(M("TP_LOCALLAB_ENHDEN")); qualityMethod_->set_active(0); - qualityMethodconn_ = qualityMethod_->signal_changed ().connect ( - sigc::mem_fun ( - *this, &ControlSpotPanel::save_ControlSpot_param)); - ctboxqualitymethod->pack_start (*qualityMethod_); - pack_start (*ctboxqualitymethod); + qualityMethodconn_ = qualityMethod_->signal_changed().connect( + sigc::mem_fun( + *this, &ControlSpotPanel::qualityMethodChanged)); + ctboxqualitymethod->pack_start(*qualityMethod_); + pack_start(*ctboxqualitymethod); - pack_start (*transit_); - transit_->set_tooltip_text (M ("TP_LOCALLAB_TRANSIT_TOOLTIP")); - transit_->setAdjusterListener (this); + pack_start(*transit_); + transit_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP")); + transit_->setAdjusterListener(this); - Gtk::Frame* const artifFrame = Gtk::manage (new Gtk::Frame (M ("TP_LOCALLAB_ARTIF"))); - artifFrame->set_label_align (0.025, 0.5); - artifFrame->set_tooltip_text (M ("TP_LOCALLAB_ARTIF_TOOLTIP")); - ToolParamBlock* const artifBox = Gtk::manage (new ToolParamBlock ()); - artifBox->pack_start (*thresh_); - thresh_->setAdjusterListener (this); - artifBox->pack_start (*iter_); - iter_->setAdjusterListener (this); - artifFrame->add (*artifBox); - pack_start (*artifFrame); + Gtk::Frame* const artifFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_ARTIF"))); + artifFrame->set_label_align(0.025, 0.5); + artifFrame->set_tooltip_text(M("TP_LOCALLAB_ARTIF_TOOLTIP")); + ToolParamBlock* const artifBox = Gtk::manage(new ToolParamBlock()); + artifBox->pack_start(*thresh_); + thresh_->setAdjusterListener(this); + artifBox->pack_start(*iter_); + iter_->setAdjusterListener(this); + artifFrame->add(*artifBox); + pack_start(*artifFrame); // Set param widgets sensitive if there is at least one control spot auto s = treeview_.get_selection(); - if (!s->count_selected_rows ()) { - setParamEditable (false); + + if (!s->count_selected_rows()) { + setParamEditable(false); } else { - setParamEditable (true); + setParamEditable(true); } - show_all (); + show_all(); } -void ControlSpotPanel::setEditProvider (EditDataProvider* provider) +void ControlSpotPanel::setEditProvider(EditDataProvider* provider) { - EditSubscriber::setEditProvider (provider); + EditSubscriber::setEditProvider(provider); } -namespace -{ - -template -Glib::ustring to_str (V n, int precision = 1) -{ - std::ostringstream buf; - buf << std::setprecision (precision) << std::fixed << n; - return buf.str (); -} - -} // namespace - -void ControlSpotPanel::render_id ( +void ControlSpotPanel::render_id( Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter) { auto row = *iter; - Gtk::CellRendererText *ct = static_cast (cell); + Gtk::CellRendererText *ct = static_cast(cell); int value = row[spots_.id]; - ct->property_text() = to_str (value); + ct->property_text() = std::to_string(value); } -void ControlSpotPanel::render_name ( +void ControlSpotPanel::render_name( Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter) { auto row = *iter; - Gtk::CellRendererText *ct = static_cast (cell); + Gtk::CellRendererText *ct = static_cast(cell); auto value = row[spots_.name]; ct->property_text() = value; } -void ControlSpotPanel::render_isvisible ( +void ControlSpotPanel::render_isvisible( Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter) { auto row = *iter; - Gtk::CellRendererText *ct = static_cast (cell); + Gtk::CellRendererText *ct = static_cast(cell); auto value = row[spots_.isvisible]; + if (value) { - ct->property_text () = "Visible"; + ct->property_text() = "Visible"; } else { - ct->property_text () = "Not visible"; + ct->property_text() = "Not visible"; } } -void ControlSpotPanel::on_button_add () +void ControlSpotPanel::on_button_add() { printf("on_button_add\n"); - // Looking for maximum used id - int max_row_id = 0; - Gtk::TreeModel::Children children = treemodel_->children (); - Gtk::TreeModel::Children::iterator iter; - for (iter = children.begin (); iter != children.end (); iter++) - { - Gtk::TreeModel::Row row = *iter; - int iter_id = row[spots_.id]; - max_row_id = std::max (max_row_id, iter_id); - } - // Adding row - Gtk::TreeModel::Row row = * (treemodel_->append ()); - row[spots_.id] = max_row_id + 1; - row[spots_.name] = "Control Spot #" + to_str(row[spots_.id]); - row[spots_.isvisible] = true; - row[spots_.curveid] = 0; // No associated curve - row[spots_.shape] = 0; - row[spots_.spotMethod] = 0; - row[spots_.shapeMethod] = 2; - row[spots_.locX] = 250; - row[spots_.locXL] = 250; - row[spots_.locY] = 250; - row[spots_.locYT] = 250; - row[spots_.centerX] = 0; - row[spots_.centerY] = 0; - row[spots_.circrad] = 18; - row[spots_.qualityMethod] = 0; - row[spots_.transit] = 60; - row[spots_.thresh] = 18; - row[spots_.iter] = 0; - setParamEditable (true); - - // Select newly added row - treeview_.set_cursor (treemodel_->get_path (row)); - - // Add associated control spot curve - addControlSpotCurve (row); - updateControlSpotCurve (row); - subscribe (); -} - -void ControlSpotPanel::on_button_delete () -{ - auto s = treeview_.get_selection (); - if (!s->count_selected_rows ()) { + if (!listener) { return; } - auto iter = s->get_selected (); - Gtk::TreeModel::Row row = *iter; - deleteControlSpotCurve (row); - treemodel_->erase (iter); - // Set param widgets unsensitive and unsubscribe if there is no more control spot - s = treeview_.get_selection (); - if (!s->count_selected_rows ()) { - unsubscribe (); - setParamEditable (false); - } + // Raise event + eventType = 1; // 1 = Spot creation event + const int newId = getNewId(); + listener->panelChanged(EvLocallabSpotCreated, "ID#" + std::to_string(newId)); } -void ControlSpotPanel::on_button_rename () +void ControlSpotPanel::on_button_delete() { + printf("on_button_delete\n"); + + if (!listener) { + return; + } + + // Raise event + eventType = 2; // 2 = Spot deletion event + const int delId = getSelectedSpot(); + listener->panelChanged(EvLocallabSpotDeleted, "ID#" + std::to_string(delId)); +} + +void ControlSpotPanel::on_button_rename() +{ + printf("on_button_rename\n"); + + if (!listener) { + return; + } + // Get actual control spot name - const auto s = treeview_.get_selection (); - if (!s->count_selected_rows ()) { + const auto s = treeview_.get_selection(); + + if (!s->count_selected_rows()) { return; } - const auto iter = s->get_selected (); + + const auto iter = s->get_selected(); const Gtk::TreeModel::Row row = *iter; const Glib::ustring actualname = row[spots_.name]; - RenameDialog d (actualname, - static_cast (*get_toplevel ())); - int status = d.run (); + // Launch windows to update spot name + RenameDialog d(actualname, + static_cast(*get_toplevel())); + int status = d.run(); + // Update actual name and raise event if (status == 1) { - const auto newname = d.get_new_name (); + const auto newname = d.get_new_name(); row[spots_.name] = newname; + treeview_.columns_autosize(); + listener->panelChanged(EvLocallabSpotName, newname); } - - treeview_.columns_autosize (); } -void ControlSpotPanel::save_ControlSpot_param () +// TODO Locallab To be deleted (not used) +void ControlSpotPanel::save_ControlSpot_param() { printf("save_ControlSpot_param\n"); // Get selected control spot const auto s = treeview_.get_selection(); + if (!s->count_selected_rows()) { return; } + const auto iter = s->get_selected(); const Gtk::TreeModel::Row row = *iter; // Save param in selected control spot - row[spots_.shape] = shape_->get_active_row_number (); - row[spots_.spotMethod] = spotMethod_->get_active_row_number (); - row[spots_.shapeMethod] = shapeMethod_->get_active_row_number (); - row[spots_.locX] = static_cast (locX_->getValue ()); - row[spots_.locXL] = static_cast (locXL_->getValue ()); - row[spots_.locY] = static_cast (locY_->getValue ()); - row[spots_.locYT] = static_cast (locYT_->getValue ()); - row[spots_.centerX] = static_cast (centerX_->getValue ()); - row[spots_.centerY] = static_cast (centerY_->getValue ()); - row[spots_.circrad] = static_cast (circrad_->getValue ()); - row[spots_.qualityMethod] = qualityMethod_->get_active_row_number (); - row[spots_.transit] = static_cast (transit_->getValue ()); - row[spots_.thresh] = static_cast (thresh_->getValue ()); - row[spots_.iter] = static_cast (iter_->getValue ()); + row[spots_.shape] = shape_->get_active_row_number(); + row[spots_.spotMethod] = spotMethod_->get_active_row_number(); + row[spots_.shapeMethod] = shapeMethod_->get_active_row_number(); + row[spots_.locX] = static_cast(locX_->getValue()); + row[spots_.locXL] = static_cast(locXL_->getValue()); + row[spots_.locY] = static_cast(locY_->getValue()); + row[spots_.locYT] = static_cast(locYT_->getValue()); + row[spots_.centerX] = static_cast(centerX_->getValue()); + row[spots_.centerY] = static_cast(centerY_->getValue()); + row[spots_.circrad] = static_cast(circrad_->getValue()); + row[spots_.qualityMethod] = qualityMethod_->get_active_row_number(); + row[spots_.transit] = static_cast(transit_->getValue()); + row[spots_.thresh] = static_cast(thresh_->getValue()); + row[spots_.iter] = static_cast(iter_->getValue()); } void ControlSpotPanel::load_ControlSpot_param() @@ -368,116 +342,185 @@ void ControlSpotPanel::load_ControlSpot_param() printf("load_ControlSpot_param\n"); // Get selected control spot const auto s = treeview_.get_selection(); + if (!s->count_selected_rows()) { return; } + const auto iter = s->get_selected(); const Gtk::TreeModel::Row row = *iter; - // Listener are deactivated to avoid unexpected even during param load - disableParamlistener (true); - // Load param in selected control spot - shape_->set_active (row[spots_.shape]); - spotMethod_->set_active (row[spots_.spotMethod]); - shapeMethod_->set_active (row[spots_.shapeMethod]); - locX_->setValue (static_cast (row[spots_.locX])); - locXL_->setValue (static_cast (row[spots_.locXL])); - locY_->setValue (static_cast (row[spots_.locY])); - locYT_->setValue (static_cast (row[spots_.locYT])); - centerX_->setValue (static_cast (row[spots_.centerX])); - centerY_->setValue (static_cast (row[spots_.centerY])); - circrad_->setValue (static_cast (row[spots_.circrad])); - qualityMethod_->set_active (row[spots_.qualityMethod]); - transit_->setValue (static_cast (row[spots_.transit])); - thresh_->setValue (static_cast (row[spots_.thresh])); - iter_->setValue (static_cast (row[spots_.iter])); - - // Listener are reactivated - disableParamlistener (false); - - updateParamVisibility (); + shape_->set_active(row[spots_.shape]); + spotMethod_->set_active(row[spots_.spotMethod]); + shapeMethod_->set_active(row[spots_.shapeMethod]); + locX_->setValue(static_cast(row[spots_.locX])); + locXL_->setValue(static_cast(row[spots_.locXL])); + locY_->setValue(static_cast(row[spots_.locY])); + locYT_->setValue(static_cast(row[spots_.locYT])); + centerX_->setValue(static_cast(row[spots_.centerX])); + centerY_->setValue(static_cast(row[spots_.centerY])); + circrad_->setValue(static_cast(row[spots_.circrad])); + qualityMethod_->set_active(row[spots_.qualityMethod]); + transit_->setValue(static_cast(row[spots_.transit])); + thresh_->setValue(static_cast(row[spots_.thresh])); + iter_->setValue(static_cast(row[spots_.iter])); } -void ControlSpotPanel::controlspotChanged () +void ControlSpotPanel::controlspotChanged() { printf("controlspotChanged\n"); - load_ControlSpot_param(); + + if (!listener) { + return; + } + + // Raise event + eventType = 3; // 3 = Spot selection event + const int selId = getSelectedSpot(); + listener->panelChanged(EvLocallabSpotSelected, "ID#" + std::to_string(selId)); } -void ControlSpotPanel::shapeChanged () +void ControlSpotPanel::shapeChanged() { - save_ControlSpot_param(); - printf("shapeChanged\n"); + + // Get selected control spot const auto s = treeview_.get_selection(); + if (!s->count_selected_rows()) { return; } + const auto iter = s->get_selected(); Gtk::TreeModel::Row row = *iter; - updateControlSpotCurve (row); + + row[spots_.shape] = shape_->get_active_row_number(); + updateControlSpotCurve(row); + + // Raise event + if (listener) { + listener->panelChanged(EvLocallabSpotShape, shape_->get_active_text()); + } } -void ControlSpotPanel::shapeMethodeChanged () +void ControlSpotPanel::spotMethodChanged() { - printf("shapeMethodeChanged\n"); - const int method = shapeMethod_->get_active_row_number (); + printf("spotMethodChanged\n"); - if (method == 1 || method == 3) { // Symmetrical cases - locXL_->setValue (locX_->getValue ()); - locYT_->setValue (locY_->getValue ()); + // Get selected control spot + const auto s = treeview_.get_selection(); - // Update associated control spot curve - const auto s = treeview_.get_selection(); - if (!s->count_selected_rows()) { - return; - } - const auto iter = s->get_selected(); - Gtk::TreeModel::Row row = *iter; - save_ControlSpot_param (); - updateControlSpotCurve (row); - } else { - save_ControlSpot_param (); + if (!s->count_selected_rows()) { + return; } - updateParamVisibility (); + const auto iter = s->get_selected(); + Gtk::TreeModel::Row row = *iter; + + row[spots_.spotMethod] = spotMethod_->get_active_row_number(); + + // Raise event + if (listener) { + listener->panelChanged(EvLocallabSpotSpotMethod, spotMethod_->get_active_text()); + } } -void ControlSpotPanel::updateParamVisibility () +void ControlSpotPanel::shapeMethodChanged() { - printf("updateParamVisibility\n"); - const int method = shapeMethod_->get_active_row_number (); + printf("shapeMethodChanged\n"); + const int method = shapeMethod_->get_active_row_number(); + + // Get selected control spot + const auto s = treeview_.get_selection(); + + if (!s->count_selected_rows()) { + return; + } + + const auto iter = s->get_selected(); + Gtk::TreeModel::Row row = *iter; if (method == 1 || method == 3) { // Symmetrical cases - locXL_->hide (); - locYT_->hide (); + disableParamlistener(true); + locXL_->setValue(locX_->getValue()); + locYT_->setValue(locY_->getValue()); + disableParamlistener(false); + + row[spots_.shapeMethod] = shapeMethod_->get_active_row_number(); + row[spots_.locXL] = static_cast(locX_->getValue()); + row[spots_.locYT] = static_cast(locY_->getValue()); + + updateControlSpotCurve(row); + } else { + row[spots_.shapeMethod] = shapeMethod_->get_active_row_number(); + } + + updateParamVisibility(); + + // Raise event + if (listener) { + listener->panelChanged(EvLocallabSpotShapeMethod, shapeMethod_->get_active_text()); + } +} + +void ControlSpotPanel::qualityMethodChanged() +{ + printf("qualityMethodChanged\n"); + + // Get selected control spot + const auto s = treeview_.get_selection(); + + if (!s->count_selected_rows()) { + return; + } + + const auto iter = s->get_selected(); + Gtk::TreeModel::Row row = *iter; + + row[spots_.qualityMethod] = qualityMethod_->get_active_row_number(); + + // Raise event + if (listener) { + listener->panelChanged(EvLocallabSpotQualityMethod, qualityMethod_->get_active_text()); + } +} + +void ControlSpotPanel::updateParamVisibility() +{ + printf("updateParamVisibility\n"); + const int method = shapeMethod_->get_active_row_number(); + + if (method == 1 || method == 3) { // Symmetrical cases + locXL_->hide(); + locYT_->hide(); + if (method == 1) { // 1 = Symmetrical (mouse) - locX_->hide (); - locY_->hide (); - centerX_->hide (); - centerY_->hide (); + locX_->hide(); + locY_->hide(); + centerX_->hide(); + centerY_->hide(); } else { // 3 = Symmetrical (mouse + sliders) - locX_->show (); - locY_->show (); - centerX_->show (); - centerY_->show (); + locX_->show(); + locY_->show(); + centerX_->show(); + centerY_->show(); } } else { // Independent cases if (method == 0) { // 0 = Independent (mouse) - locX_->hide (); - locXL_->hide (); - locY_->hide (); - locYT_->hide (); - centerX_->hide (); - centerY_->hide (); + locX_->hide(); + locXL_->hide(); + locY_->hide(); + locYT_->hide(); + centerX_->hide(); + centerY_->hide(); } else { // 2 = Independent (mouse + sliders) - locX_->show (); - locXL_->show (); - locY_->show (); - locYT_->show (); - centerX_->show (); - centerY_->show (); + locX_->show(); + locXL_->show(); + locY_->show(); + locYT_->show(); + centerX_->show(); + centerY_->show(); } } } @@ -485,27 +528,139 @@ void ControlSpotPanel::updateParamVisibility () void ControlSpotPanel::adjusterChanged(Adjuster* a, double newval) { printf("adjusterChanged\n"); - const int method = shapeMethod_->get_active_row_number (); - if (method == 1 || method == 3) { // Symmetrical cases - locXL_->setValue (locX_->getValue ()); - locYT_->setValue (locY_->getValue ()); - } + const int method = shapeMethod_->get_active_row_number(); - save_ControlSpot_param(); - - // Update associated control spot curve + // Get selected control spot const auto s = treeview_.get_selection(); + if (!s->count_selected_rows()) { return; } + const auto iter = s->get_selected(); Gtk::TreeModel::Row row = *iter; - updateControlSpotCurve (row); + + if (a == locX_) { + row[spots_.locX] = (int) locX_->getValue(); + + if (method == 1 || method == 3) { // Symmetrical cases + disableParamlistener(true); + locXL_->setValue(locX_->getValue()); + disableParamlistener(false); + row[spots_.locXL] = (int) locXL_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocX, locX_->getTextValue()); + } + } + + if (a == locXL_) { + row[spots_.locXL] = (int) locXL_->getValue(); + + if (method == 1 || method == 3) { // Symmetrical cases + disableParamlistener(true); + locX_->setValue(locXL_->getValue()); + disableParamlistener(false); + row[spots_.locX] = (int) locX_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocXL, locXL_->getTextValue()); + } + } + + if (a == locY_) { + row[spots_.locY] = (int) locY_->getValue(); + + if (method == 1 || method == 3) { // Symmetrical cases + disableParamlistener(true); + locYT_->setValue(locY_->getValue()); + disableParamlistener(false); + row[spots_.locYT] = (int) locYT_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocY, locY_->getTextValue()); + } + } + + if (a == locYT_) { + row[spots_.locYT] = (int) locYT_->getValue(); + + if (method == 1 || method == 3) { // Symmetrical cases + disableParamlistener(true); + locY_->setValue(locYT_->getValue()); + disableParamlistener(false); + row[spots_.locY] = (int) locY_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocYT, locYT_->getTextValue()); + } + } + + if (a == centerX_ || a == centerY_) { + row[spots_.centerX] = (int) centerX_->getValue(); + row[spots_.centerY] = (int) centerY_->getValue(); + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotCenter, "X=" + centerX_->getTextValue() + ", Y=" + centerY_->getTextValue()); + } + } + + if (a == circrad_) { + row[spots_.circrad] = (int) circrad_->getValue(); + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotCircrad, circrad_->getTextValue()); + } + } + + if (a == transit_) { + row[spots_.transit] = (int) transit_->getValue(); + + if (listener) { + listener->panelChanged(EvLocallabSpotTransit, transit_->getTextValue()); + } + } + + if (a == thresh_) { + row[spots_.thresh] = (int) thresh_->getValue(); + + if (listener) { + listener->panelChanged(EvLocallabSpotThresh, thresh_->getTextValue()); + } + } + + if (a == iter_) { + row[spots_.iter] = (int) iter_->getValue(); + + if (listener) { + listener->panelChanged(EvLocallabSpotIter, iter_->getTextValue()); + } + } } void ControlSpotPanel::disableParamlistener(bool cond) { printf("disableParamlistener: %d\n", cond); + treeviewconn_.block(cond); + buttonaddconn_.block(cond); + buttondeleteconn_.block(cond); + buttonrenameconn_.block(cond); shapeconn_.block(cond); spotMethodconn_.block(cond); shapeMethodconn_.block(cond); @@ -541,56 +696,57 @@ void ControlSpotPanel::setParamEditable(bool cond) iter_->set_sensitive(cond); } -void ControlSpotPanel::addControlSpotCurve (Gtk::TreeModel::Row row) +void ControlSpotPanel::addControlSpotCurve(Gtk::TreeModel::Row row) { printf("addControlSpotCurve\n"); + if (row[spots_.curveid] > 0) { // Row has already an associated curve return; } // Creation of visibleGeometry Line* lineX; - lineX = new Line (); + lineX = new Line(); lineX->innerLineWidth = 2.5; lineX->datum = Geometry::IMAGE; Line* lineXL; - lineXL = new Line (); + lineXL = new Line(); lineXL->innerLineWidth = 2.5; lineXL->datum = Geometry::IMAGE; Line* lineY; - lineY = new Line (); + lineY = new Line(); lineY->innerLineWidth = 2.5; lineY->datum = Geometry::IMAGE; Line* lineYT; - lineYT = new Line (); + lineYT = new Line(); lineYT->innerLineWidth = 2.5; lineYT->datum = Geometry::IMAGE; Circle* centerCircle; - centerCircle = new Circle (); + centerCircle = new Circle(); centerCircle->datum = Geometry::IMAGE; centerCircle->radiusInImageSpace = true; Arcellipse* arc1; - arc1 = new Arcellipse (); + arc1 = new Arcellipse(); arc1->innerLineWidth = 0.7; arc1->datum = Geometry::IMAGE; arc1->radiusInImageSpace = true; Arcellipse* arc2; - arc2 = new Arcellipse (); + arc2 = new Arcellipse(); arc2->innerLineWidth = 0.7; arc2->datum = Geometry::IMAGE; arc2->radiusInImageSpace = true; Arcellipse* arc3; - arc3 = new Arcellipse (); + arc3 = new Arcellipse(); arc3->innerLineWidth = 0.7; arc3->datum = Geometry::IMAGE; arc3->radiusInImageSpace = true; Arcellipse* arc4; - arc4 = new Arcellipse (); + arc4 = new Arcellipse(); arc4->innerLineWidth = 0.7; arc4->datum = Geometry::IMAGE; arc4->radiusInImageSpace = true; Rectangle* rec; - rec = new Rectangle (); + rec = new Rectangle(); rec->innerLineWidth = 0.7; rec->datum = Geometry::IMAGE; EditSubscriber::visibleGeometry.push_back(lineX); // (curveid - 1) * 10 @@ -605,38 +761,38 @@ void ControlSpotPanel::addControlSpotCurve (Gtk::TreeModel::Row row) EditSubscriber::visibleGeometry.push_back(rec); // (curveid - 1) * 10 + 9 // Creation of mouseOverGeometry - lineX = new Line (); + lineX = new Line(); lineX->innerLineWidth = 2.5; lineX->datum = Geometry::IMAGE; - lineXL = new Line (); + lineXL = new Line(); lineXL->innerLineWidth = 2.5; lineXL->datum = Geometry::IMAGE; - lineY = new Line (); + lineY = new Line(); lineY->innerLineWidth = 2.5; lineY->datum = Geometry::IMAGE; - lineYT = new Line (); + lineYT = new Line(); lineYT->innerLineWidth = 2.5; lineYT->datum = Geometry::IMAGE; - centerCircle = new Circle (); + centerCircle = new Circle(); centerCircle->datum = Geometry::IMAGE; centerCircle->radiusInImageSpace = true; - arc1 = new Arcellipse (); + arc1 = new Arcellipse(); arc1->innerLineWidth = 0.7; arc1->datum = Geometry::IMAGE; arc1->radiusInImageSpace = true; - arc2 = new Arcellipse (); + arc2 = new Arcellipse(); arc2->innerLineWidth = 0.7; arc2->datum = Geometry::IMAGE; arc2->radiusInImageSpace = true; - arc3 = new Arcellipse (); + arc3 = new Arcellipse(); arc3->innerLineWidth = 0.7; arc3->datum = Geometry::IMAGE; arc3->radiusInImageSpace = true; - arc4 = new Arcellipse (); + arc4 = new Arcellipse(); arc4->innerLineWidth = 0.7; arc4->datum = Geometry::IMAGE; arc4->radiusInImageSpace = true; - rec = new Rectangle (); + rec = new Rectangle(); rec->innerLineWidth = 0.7; rec->datum = Geometry::IMAGE; EditSubscriber::mouseOverGeometry.push_back(lineX); // (curveid - 1) * 10 @@ -650,23 +806,25 @@ void ControlSpotPanel::addControlSpotCurve (Gtk::TreeModel::Row row) EditSubscriber::mouseOverGeometry.push_back(arc4); // (curveid - 1) * 10 + 8 EditSubscriber::mouseOverGeometry.push_back(rec); // (curveid - 1) * 10 + 9 - row[spots_.curveid] = EditSubscriber::visibleGeometry.size () / 10; + row[spots_.curveid] = EditSubscriber::visibleGeometry.size() / 10; } -void ControlSpotPanel::updateControlSpotCurve (Gtk::TreeModel::Row row) +void ControlSpotPanel::updateControlSpotCurve(Gtk::TreeModel::Row row) { - const int curveid_ = static_cast (row[spots_.curveid]); + const int curveid_ = static_cast(row[spots_.curveid]); + if (curveid_ == 0) { // Row has no associated curve return; } - const int centerX_ = static_cast (row[spots_.centerX]); - const int centerY_ = static_cast (row[spots_.centerY]); - const int circrad_ = static_cast (row[spots_.circrad]); - const int locX_ = static_cast (row[spots_.locX]); - const int locXL_ = static_cast (row[spots_.locXL]); - const int locY_ = static_cast (row[spots_.locY]); - const int locYT_ = static_cast (row[spots_.locYT]); - const int shape_ = static_cast (row[spots_.shape]); + + const int centerX_ = static_cast(row[spots_.centerX]); + const int centerY_ = static_cast(row[spots_.centerY]); + const int circrad_ = static_cast(row[spots_.circrad]); + const int locX_ = static_cast(row[spots_.locX]); + const int locXL_ = static_cast(row[spots_.locXL]); + const int locY_ = static_cast(row[spots_.locY]); + const int locYT_ = static_cast(row[spots_.locYT]); + const int shape_ = static_cast(row[spots_.shape]); printf("updateControlSpotCurve: %d\n", curveid_); @@ -675,9 +833,11 @@ void ControlSpotPanel::updateControlSpotCurve (Gtk::TreeModel::Row row) if (!dataProvider) { return; } + int imW = 0; int imH = 0; dataProvider->getImageSize(imW, imH); + if (!imW || !imH) { return; } @@ -686,24 +846,24 @@ void ControlSpotPanel::updateControlSpotCurve (Gtk::TreeModel::Row row) const double decayXL = (locXL_) * (double (imW)) / 2000.; const double decayY = (locY_) * double (imH) / 2000.; const double decayYT = (locYT_) * double (imH) / 2000.; - rtengine::Coord origin (imW / 2 + centerX_ * imW / 2000.f, imH / 2 + centerY_ * imH / 2000.f); + rtengine::Coord origin(imW / 2 + centerX_ * imW / 2000.f, imH / 2 + centerY_ * imH / 2000.f); const auto updateLineWithDecay = [&](Geometry * geometry, const float radius, const float decal, const float offSetAngle, const double decay) { const auto line = static_cast(geometry); // 180 - line->begin = PolarCoord (radius, decal) + PolarCoord (decay, offSetAngle); + line->begin = PolarCoord(radius, decal) + PolarCoord(decay, offSetAngle); line->begin += origin; // 0 line->end = PolarCoord(radius, decal - 180) + PolarCoord(decay, offSetAngle); line->end += origin; }; const auto updateCircle = [&](Geometry * geometry) { - const auto circle = static_cast (geometry); + const auto circle = static_cast(geometry); circle->center = origin; circle->radius = circrad_; }; const auto updateArcellipse = [&](Geometry * geometry, const double dRad_, const double dRad2_, const double begang_, const double endang_) { - const auto arcellipse = static_cast (geometry); + const auto arcellipse = static_cast(geometry); arcellipse->center = origin; arcellipse->begang = begang_; arcellipse->endang = endang_; @@ -712,7 +872,7 @@ void ControlSpotPanel::updateControlSpotCurve (Gtk::TreeModel::Row row) }; const auto updateRectangle = [&](Geometry * geometry) { - const auto rectangle = static_cast (geometry); + const auto rectangle = static_cast(geometry); rectangle->bottomRight.x = origin.x + (int) decayX; rectangle->bottomRight.y = origin.y + (int) decayY; rectangle->topLeft.x = origin.x - (int) decayXL; @@ -734,12 +894,12 @@ void ControlSpotPanel::updateControlSpotCurve (Gtk::TreeModel::Row row) updateCircle(visibleGeometry.at((curveid_ - 1) * 10 + 4)); updateCircle(mouseOverGeometry.at((curveid_ - 1) * 10 + 4)); - updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 5), decayX, decayYT, 3*RT_PI_2, 2 * RT_PI); - updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 6), decayXL, decayYT, RT_PI, 3*RT_PI_2); + updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 5), decayX, decayYT, 3 * RT_PI_2, 2 * RT_PI); + updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 6), decayXL, decayYT, RT_PI, 3 * RT_PI_2); updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 7), decayXL, decayY, RT_PI_2, RT_PI); updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 8), decayX, decayY, 0., RT_PI_2); - updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 5), decayX, decayYT, 3*RT_PI_2, 2 * RT_PI); - updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 6), decayXL, decayYT, RT_PI, 3*RT_PI_2); + updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 5), decayX, decayYT, 3 * RT_PI_2, 2 * RT_PI); + updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 6), decayXL, decayYT, RT_PI, 3 * RT_PI_2); updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 7), decayXL, decayY, RT_PI_2, RT_PI); updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 8), decayX, decayY, 0., RT_PI_2); @@ -774,84 +934,99 @@ void ControlSpotPanel::updateControlSpotCurve (Gtk::TreeModel::Row row) } } -void ControlSpotPanel::deleteControlSpotCurve (Gtk::TreeModel::Row row) +void ControlSpotPanel::deleteControlSpotCurve(Gtk::TreeModel::Row row) { - const int curveid_ = static_cast (row[spots_.curveid]); + const int curveid_ = static_cast(row[spots_.curveid]); + if (curveid_ == 0) { // Row has no associated curve return; } + printf("deleteControlSpotCurve: %d\n", curveid_); // visibleGeometry - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 9); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 8); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 7); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 6); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 5); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 4); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 3); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 2); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10 + 1); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin () + (curveid_ - 1) * 10); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 9); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 8); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 7); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 6); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 5); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 4); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 3); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 2); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 1); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10); // mouseOverGeometry - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 9); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 8); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 7); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 6); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 5); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 4); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 3); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 2); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10 + 1); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin () + (curveid_ - 1) * 10); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 9); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 8); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 7); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 6); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 5); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 4); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 3); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 2); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 1); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10); row[spots_.curveid] = 0; // Reset associated curve id // Reordering curve id - Gtk::TreeModel::Children children = treemodel_->children (); - for (auto iter = children.begin (); iter != children.end (); iter++) { + Gtk::TreeModel::Children children = treemodel_->children(); + + for (auto iter = children.begin(); iter != children.end(); iter++) { Gtk::TreeModel::Row r = *iter; + if (r[spots_.curveid] > curveid_) { r[spots_.curveid] = r[spots_.curveid] - 1; } } } -CursorShape ControlSpotPanel::getCursor (int objectID) +CursorShape ControlSpotPanel::getCursor(int objectID) { - printf ("Object ID: %d\n", objectID); + printf("Object ID: %d\n", objectID); int rem_ = objectID % 10; switch (rem_) { - case (0): // LocX: (curveid_ - 1) * 10 - return CSMove1DH; - case (1): // LocXL: (curveid_ - 1) * 10 + 1 - return CSMove1DH; - case (2): // LocY: (curveid_ - 1) * 10 + 2 - return CSMove1DV; - case (3): // LocYT: (curveid_ - 1) * 10 + 3 - return CSMove1DV; - case (4): // centerCircle: (curveid_ - 1) * 10 + 4 - return CSMove2D; - case (5): // arc1: (curveid_ - 1) * 10 + 5 - return CSMove2D; - case (6): // arc2: (curveid_ - 1) * 10 + 6 - return CSMove2D; - case (7): // arc3: (curveid_ - 1) * 10 + 7 - return CSMove2D; - case (8): // arc4: (curveid_ - 1) * 10 + 8 - return CSMove2D; - case (9): // rec: (curveid_ - 1) * 10 + 9 - return CSMove2D; - default: - return CSOpenHand; + case (0): // LocX: (curveid_ - 1) * 10 + return CSMove1DH; + + case (1): // LocXL: (curveid_ - 1) * 10 + 1 + return CSMove1DH; + + case (2): // LocY: (curveid_ - 1) * 10 + 2 + return CSMove1DV; + + case (3): // LocYT: (curveid_ - 1) * 10 + 3 + return CSMove1DV; + + case (4): // centerCircle: (curveid_ - 1) * 10 + 4 + return CSMove2D; + + case (5): // arc1: (curveid_ - 1) * 10 + 5 + return CSMove2D; + + case (6): // arc2: (curveid_ - 1) * 10 + 6 + return CSMove2D; + + case (7): // arc3: (curveid_ - 1) * 10 + 7 + return CSMove2D; + + case (8): // arc4: (curveid_ - 1) * 10 + 8 + return CSMove2D; + + case (9): // rec: (curveid_ - 1) * 10 + 9 + return CSMove2D; + + default: + return CSOpenHand; } } -bool ControlSpotPanel::mouseOver (int modifierKey) +bool ControlSpotPanel::mouseOver(int modifierKey) { EditDataProvider* editProvider_ = getEditProvider(); + if (!editProvider_) { return false; } @@ -860,22 +1035,24 @@ bool ControlSpotPanel::mouseOver (int modifierKey) if (object_ != lastObject_) { if (object_ == -1) { - for (int it_ = 0; it_ < (int) EditSubscriber::visibleGeometry.size (); it_++) { + for (int it_ = 0; it_ < (int) EditSubscriber::visibleGeometry.size(); it_++) { EditSubscriber::visibleGeometry.at(it_)->state = Geometry::NORMAL; } + lastObject_ = object_; return false; } int curveId_ = object_ / 10 + 1; int rem = object_ % 10; - for (int it_ = 0; it_ < (int) EditSubscriber::visibleGeometry.size (); it_++) { + + for (int it_ = 0; it_ < (int) EditSubscriber::visibleGeometry.size(); it_++) { if ((it_ < ((curveId_ - 1) * 10)) || (it_ > ((curveId_ - 1) * 10) + 9)) { // it_ does not belong to cursor pointed curve EditSubscriber::visibleGeometry.at(it_)->state = Geometry::NORMAL; } } - const int method = shapeMethod_->get_active_row_number (); + const int method = shapeMethod_->get_active_row_number(); // LocX if (rem == 0) { @@ -949,142 +1126,487 @@ bool ControlSpotPanel::mouseOver (int modifierKey) return false; } -bool ControlSpotPanel::button1Pressed (int modifierKey) +bool ControlSpotPanel::button1Pressed(int modifierKey) { printf("button1Pressed\n"); - EditDataProvider *provider = getEditProvider (); + EditDataProvider *provider = getEditProvider(); + if (!provider || lastObject_ == -1) { return false; } // Select associated control spot int curveId_ = lastObject_ / 10 + 1; - Gtk::TreeModel::Children children = treemodel_->children (); - for (auto iter = children.begin (); iter != children.end (); iter++) { + Gtk::TreeModel::Children children = treemodel_->children(); + + for (auto iter = children.begin(); iter != children.end(); iter++) { Gtk::TreeModel::Row r = *iter; + if (r[spots_.curveid] == curveId_) { - treeview_.set_cursor (treemodel_->get_path (r)); + treeview_.set_cursor(treemodel_->get_path(r)); break; } } - lastCoord_->set (provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y); + lastCoord_->set(provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y); EditSubscriber::action = ES_ACTION_DRAGGING; return true; } -bool ControlSpotPanel::button1Released () +bool ControlSpotPanel::button1Released() { printf("button1Released\n"); EditSubscriber::action = ES_ACTION_NONE; return true; } -bool ControlSpotPanel::drag1 (int modifierKey) +bool ControlSpotPanel::drag1(int modifierKey) { printf("drag1\n"); - EditDataProvider *provider = getEditProvider (); + EditDataProvider *provider = getEditProvider(); + if (!provider || lastObject_ == -1) { return false; } // Get associated control spot const auto s = treeview_.get_selection(); + if (!s->count_selected_rows()) { return false; } + const auto iter = s->get_selected(); Gtk::TreeModel::Row row = *iter; int imW, imH; - provider->getImageSize (imW, imH); + provider->getImageSize(imW, imH); int rem = lastObject_ % 10; - int method = shapeMethod_->get_active_row_number (); - Coord* newCoord = new Coord (provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y); + int method = shapeMethod_->get_active_row_number(); + Coord* newCoord = new Coord(provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y); // LocX if (rem == 0) { double deltaX = (double (newCoord->x) - double (lastCoord_->x)) * 2000. / double (imW); - locX_->setValue (locX_->getValue () + deltaX); + locX_->setValue(locX_->getValue() + deltaX); + row[spots_.locX] = (int) locX_->getValue(); + if (method == 1 || method == 3) { // Symmetrical cases - locXL_->setValue (locX_->getValue ()); + disableParamlistener(true); + locXL_->setValue(locX_->getValue()); + disableParamlistener(false); + row[spots_.locXL] = (int) locXL_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocX, locX_->getTextValue()); } - save_ControlSpot_param (); - updateControlSpotCurve (row); } // LocXL if (rem == 1) { double deltaXL = (double (lastCoord_->x) - double (newCoord->x)) * 2000. / double (imW); - locXL_->setValue (locXL_->getValue () + deltaXL); + locXL_->setValue(locXL_->getValue() + deltaXL); + row[spots_.locXL] = (int) locXL_->getValue(); + if (method == 1 || method == 3) { // Symmetrical cases - locX_->setValue (locXL_->getValue ()); + disableParamlistener(true); + locX_->setValue(locXL_->getValue()); + disableParamlistener(false); + row[spots_.locX] = (int) locX_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocXL, locXL_->getTextValue()); } - save_ControlSpot_param (); - updateControlSpotCurve (row); } // LocY if (rem == 2) { double deltaY = (double (newCoord->y) - double (lastCoord_->y)) * 2000. / double (imH); - locY_->setValue (locY_->getValue () + deltaY); + locY_->setValue(locY_->getValue() + deltaY); + row[spots_.locY] = (int) locY_->getValue(); + if (method == 1 || method == 3) { // Symmetrical cases - locYT_->setValue (locY_->getValue ()); + disableParamlistener(true); + locYT_->setValue(locY_->getValue()); + disableParamlistener(false); + row[spots_.locYT] = (int) locYT_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocY, locY_->getTextValue()); } - save_ControlSpot_param (); - updateControlSpotCurve (row); } // LocYT if (rem == 3) { double deltaYT = (double (lastCoord_->y) - double (newCoord->y)) * 2000. / double (imH); - locYT_->setValue (locYT_->getValue () + deltaYT); + locYT_->setValue(locYT_->getValue() + deltaYT); + row[spots_.locYT] = (int) locYT_->getValue(); + if (method == 1 || method == 3) { // Symmetrical cases - locY_->setValue (locYT_->getValue ()); + disableParamlistener(true); + locY_->setValue(locYT_->getValue()); + disableParamlistener(false); + row[spots_.locY] = (int) locY_->getValue(); + } + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotLocYT, locYT_->getTextValue()); } - save_ControlSpot_param (); - updateControlSpotCurve (row); } // Circle, Arcellipses and Rectangle if (rem >= 4) { double deltaX = (double (newCoord->x) - double (lastCoord_->x)) * 2000. / double (imW); double deltaY = (double (newCoord->y) - double (lastCoord_->y)) * 2000. / double (imH); - centerX_->setValue (centerX_->getValue () + deltaX); - centerY_->setValue (centerY_->getValue () + deltaY); - save_ControlSpot_param (); - updateControlSpotCurve (row); + centerX_->setValue(centerX_->getValue() + deltaX); + centerY_->setValue(centerY_->getValue() + deltaY); + row[spots_.centerX] = (int) centerX_->getValue(); + row[spots_.centerY] = (int) centerY_->getValue(); + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotCenter, "X=" + centerX_->getTextValue() + ", Y=" + centerY_->getTextValue()); + } } - lastCoord_->set (newCoord->x, newCoord->y); + lastCoord_->set(newCoord->x, newCoord->y); return true; } +int ControlSpotPanel::getEventType() +{ + const int tmp = eventType; + eventType = 0; // Re-initialization at 0 if event type gotten + return tmp; +} + +ControlSpotPanel::SpotRow* ControlSpotPanel::getSpot(int id) +{ + printf("getSpot: %d\n", id); + + SpotRow* r = new SpotRow(); + + Gtk::TreeModel::Children children = treemodel_->children(); + Gtk::TreeModel::Children::iterator iter; + + for (iter = children.begin(); iter != children.end(); iter++) { + Gtk::TreeModel::Row row = *iter; + + if (row[spots_.id] == id) { + r->id = row[spots_.id]; + r->name = row[spots_.name]; + r->isvisible = row[spots_.isvisible]; + r->shape = row[spots_.shape]; + r->spotMethod = row[spots_.spotMethod]; + r->shapeMethod = row[spots_.shapeMethod]; + r->locX = row[spots_.locX]; + r->locXL = row[spots_.locXL]; + r->locY = row[spots_.locY]; + r->locYT = row[spots_.locYT]; + r->centerX = row[spots_.centerX]; + r->centerY = row[spots_.centerY]; + r->circrad = row[spots_.circrad]; + r->qualityMethod = row[spots_.qualityMethod]; + r->transit = row[spots_.transit]; + r->thresh = row[spots_.thresh]; + r->iter = row[spots_.iter]; + + return r; + } + } + + return nullptr; +} + +std::vector* ControlSpotPanel::getSpotIdList() +{ + std::vector* r = new std::vector(); + + Gtk::TreeModel::Children children = treemodel_->children(); + Gtk::TreeModel::Children::iterator iter; + + for (iter = children.begin(); iter != children.end(); iter++) { + Gtk::TreeModel::Row row = *iter; + r->push_back(row[spots_.id]); + } + + return r; +} + +int ControlSpotPanel::getSelectedSpot() +{ + printf("getSelectedSpot\n"); + + const auto s = treeview_.get_selection(); + + // Check if treeview has row, otherwise return 0 + if (!s->count_selected_rows()) { + return 0; + } + + auto iter = s->get_selected(); + Gtk::TreeModel::Row row = *iter; + int id = row[spots_.id]; + + return id; +} + +void ControlSpotPanel::setSelectedSpot(int id) +{ + printf("setSelectedSpot: %d\n", id); + + disableParamlistener(true); + + Gtk::TreeModel::Children children = treemodel_->children(); + Gtk::TreeModel::Children::iterator iter; + + for (iter = children.begin(); iter != children.end(); iter++) { + Gtk::TreeModel::Row row = *iter; + + if (row[spots_.id] == id) { + treeview_.set_cursor(treemodel_->get_path(row)); + load_ControlSpot_param(); + updateParamVisibility(); + } + } + + disableParamlistener(false); +} + +int ControlSpotPanel::getNewId() +{ + // Looking for maximum used id + int max_row_id = 0; + Gtk::TreeModel::Children children = treemodel_->children(); + Gtk::TreeModel::Children::iterator iter; + + for (iter = children.begin(); iter != children.end(); iter++) { + Gtk::TreeModel::Row row = *iter; + int iter_id = row[spots_.id]; + max_row_id = std::max(max_row_id, iter_id); + } + + max_row_id++; + + return max_row_id; +} + + +void ControlSpotPanel::addControlSpot(SpotRow* newSpot) +{ + printf("addControlSpot: %d\n", newSpot->id); + + disableParamlistener(true); + Gtk::TreeModel::Row row = * (treemodel_->append()); + row[spots_.id] = newSpot->id; + row[spots_.name] = newSpot->name; + row[spots_.isvisible] = newSpot->isvisible; + row[spots_.curveid] = 0; // No associated curve + row[spots_.shape] = newSpot->shape; + row[spots_.spotMethod] = newSpot->spotMethod; + row[spots_.shapeMethod] = newSpot->shapeMethod; + row[spots_.locX] = newSpot->locX; + row[spots_.locXL] = newSpot->locXL; + row[spots_.locY] = newSpot->locY; + row[spots_.locYT] = newSpot->locYT; + row[spots_.centerX] = newSpot->centerX; + row[spots_.centerY] = newSpot->centerY; + row[spots_.circrad] = newSpot->circrad; + row[spots_.qualityMethod] = newSpot->qualityMethod; + row[spots_.transit] = newSpot->transit; + row[spots_.thresh] = newSpot->thresh; + row[spots_.iter] = newSpot->iter; + setParamEditable(true); + updateParamVisibility(); + disableParamlistener(false); + + // Add associated control spot curve + addControlSpotCurve(row); + updateControlSpotCurve(row); +} + +int ControlSpotPanel::updateControlSpot(SpotRow* spot) +{ + printf("updateControlSpot: %d\n", spot->id); + + disableParamlistener(true); + + Gtk::TreeModel::Children children = treemodel_->children(); + Gtk::TreeModel::Children::iterator iter; + + for (iter = children.begin(); iter != children.end(); iter++) { + Gtk::TreeModel::Row row = *iter; + + if (row[spots_.id] == spot->id) { + row[spots_.name] = spot->name; + row[spots_.isvisible] = spot->isvisible; + row[spots_.shape] = spot->shape; + row[spots_.spotMethod] = spot->spotMethod; + row[spots_.shapeMethod] = spot->shapeMethod; + row[spots_.locX] = spot->locX; + row[spots_.locXL] = spot->locXL; + row[spots_.locY] = spot->locY; + row[spots_.locYT] = spot->locYT; + row[spots_.centerX] = spot->centerX; + row[spots_.centerY] = spot->centerY; + row[spots_.circrad] = spot->circrad; + row[spots_.qualityMethod] = spot->qualityMethod; + row[spots_.transit] = spot->transit; + row[spots_.thresh] = spot->thresh; + row[spots_.iter] = spot->iter; + + updateControlSpotCurve(row); + updateParamVisibility(); + disableParamlistener(false); + + return 1; + } + } + + disableParamlistener(false); + return 0; +} + +void ControlSpotPanel::deleteControlSpot(int id) +{ + printf("deleteControlSpot: %d\n", id); + + disableParamlistener(true); + + Gtk::TreeModel::Children children = treemodel_->children(); + Gtk::TreeModel::Children::iterator iter; + + for (iter = children.begin(); iter != children.end(); iter++) { + Gtk::TreeModel::Row row = *iter; + + if (row[spots_.id] == id) { + deleteControlSpotCurve(row); + treemodel_->erase(iter); + } + } + + // Set param widgets unsensitive if there is no more control spot + auto s = treeview_.get_selection(); + + if (!s->count_selected_rows()) { + setParamEditable(false); + } + + disableParamlistener(false); +} + +ControlSpotPanel::SpotEdited* ControlSpotPanel::getEditedStates() +{ + printf("getEditedStates\n"); + + SpotEdited* se = new SpotEdited(); + + se->treeview = treeview_.is_sensitive(); + se->addbutton = button_add_.is_sensitive(); + se->deletebutton = button_delete_.is_sensitive(); + se->name = button_rename_.is_sensitive(); + se->isvisible = false; // TODO isvisible + se->shape = shape_->get_active_row_number() != 2; + se->spotMethod = spotMethod_->get_active_row_number() != 2; + se->shapeMethod = shapeMethod_->get_active_row_number() != 4; + se->locX = locX_->getEditedState(); + se->locXL = locXL_->getEditedState(); + se->locY = locY_->getEditedState(); + se->locYT = locYT_->getEditedState(); + se->centerX = centerX_->getEditedState(); + se-> centerY = centerY_->getEditedState(); + se->circrad = circrad_->getEditedState(); + se->qualityMethod = qualityMethod_->get_active_row_number() != 4; + se->transit = transit_->getEditedState(); + se->thresh = thresh_->getEditedState(); + se->iter = iter_->getEditedState(); + + return se; +} + +void ControlSpotPanel::setEditedStates(SpotEdited* se) +{ + printf("setEditedStates\n"); + + // Disable params listeners + disableParamlistener(true); + + // Set widgets edited states + treeview_.set_sensitive(se->treeview); + button_add_.set_sensitive(se->addbutton); + button_delete_.set_sensitive(se->deletebutton); + button_rename_.set_sensitive(se->name); + + // TODO Add isvisible + if (!se->shape) { + shape_->set_active(2); + } + + if (!se->spotMethod) { + spotMethod_->set_active(2); + } + + if (!se->shapeMethod) { + shapeMethod_->set_active(4); + } + + locX_->setEditedState(se->locX ? Edited : UnEdited); + locXL_->setEditedState(se->locXL ? Edited : UnEdited); + locY_->setEditedState(se->locY ? Edited : UnEdited); + locYT_->setEditedState(se->locYT ? Edited : UnEdited); + centerX_->setEditedState(se->centerX ? Edited : UnEdited); + centerY_->setEditedState(se->centerY ? Edited : UnEdited); + circrad_->setEditedState(se->circrad ? Edited : UnEdited); + + if (!se->qualityMethod) { + qualityMethod_->set_active(4); + } + + transit_->setEditedState(se->transit ? Edited : UnEdited); + thresh_->setEditedState(se->thresh ? Edited : UnEdited); + iter_->setEditedState(se->iter ? Edited : UnEdited); + + // Enable params listeners + disableParamlistener(false); +} + //----------------------------------------------------------------------------- // ControlSpots //----------------------------------------------------------------------------- ControlSpotPanel::ControlSpots::ControlSpots() { - add (id); - add (name); - add (isvisible); - add (curveid); - add (shape); - add (spotMethod); - add (shapeMethod); - add (locX); - add (locXL); - add (locYT); - add (locY); - add (centerX); - add (centerY); - add (circrad); - add (qualityMethod); - add (transit); - add (thresh); - add (iter); + add(id); + add(name); + add(isvisible); + add(curveid); + add(shape); + add(spotMethod); + add(shapeMethod); + add(locX); + add(locXL); + add(locYT); + add(locY); + add(centerX); + add(centerY); + add(circrad); + add(qualityMethod); + add(transit); + add(thresh); + add(iter); } //----------------------------------------------------------------------------- @@ -1092,18 +1614,18 @@ ControlSpotPanel::ControlSpots::ControlSpots() //----------------------------------------------------------------------------- ControlSpotPanel::RenameDialog::RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent): - Gtk::Dialog ("Renaming Control Spot", parent) + Gtk::Dialog("Renaming Control Spot", parent) { - Gtk::HBox *hb = Gtk::manage (new Gtk::HBox()); - hb->pack_start (*Gtk::manage (new Gtk::Label ("Enter the new Control Spot name")), false, false, 4); + Gtk::HBox *hb = Gtk::manage(new Gtk::HBox()); + hb->pack_start(*Gtk::manage(new Gtk::Label("Enter the new Control Spot name")), false, false, 4); newname_.set_text(actualname); hb->pack_start(newname_); - get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4); + get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4); - add_button (M ("GENERAL_OK"), 1); - add_button (M ("GENERAL_CANCEL"), 2); + add_button(M("GENERAL_OK"), 1); + add_button(M("GENERAL_CANCEL"), 2); show_all_children(); } diff --git a/rtgui/controlspotpanel.h b/rtgui/controlspotpanel.h index c1400954b..831b69e94 100644 --- a/rtgui/controlspotpanel.h +++ b/rtgui/controlspotpanel.h @@ -16,17 +16,82 @@ class ControlSpotPanel: public ToolParamBlock, public AdjusterListener, - public EditSubscriber + public EditSubscriber, + public FoldableToolPanel { public: + /** A SpotRow structure allows exchanges from and to ControlSpotClass */ + struct SpotRow { + int id; // Control spot id + Glib::ustring name; + bool isvisible; + int shape; // 0 = Ellipse, 1 = Rectangle + int spotMethod; // 0 = Normal, 1 = Excluding + int shapeMethod; // 0 = Independent (mouse), 1 = Symmetrical (mouse), 2 = Independent (mouse + sliders), 3 = Symmetrical (mouse + sliders) + int locX; + int locXL; + int locY; + int locYT; + int centerX; + int centerY; + int circrad; + int qualityMethod; // 0 = Standard, 1 = Enhanced, 2 = Enhanced + chroma denoise + int transit; + int thresh; + int iter; + }; + + /** A SpotEdited structure allows exchanges of spot panel widgets edited states from and to ControlSpotClass */ + struct SpotEdited { + bool addbutton; + bool deletebutton; + bool treeview; + bool name; + bool isvisible; + bool shape; + bool spotMethod; + bool shapeMethod; + bool locX; + bool locXL; + bool locY; + bool locYT; + bool centerX; + bool centerY; + bool circrad; + bool qualityMethod; + bool transit; + bool thresh; + bool iter; + }; + + // Constructor and management functions ControlSpotPanel(); void setEditProvider(EditDataProvider* provider); + int getEventType(); + SpotRow* getSpot(int id); + std::vector* getSpotIdList(); + int getSelectedSpot(); + void setSelectedSpot(int id); + + // Control spot creation functions + int getNewId(); + void addControlSpot(SpotRow* newSpot); + + // Control spot update function + int updateControlSpot(SpotRow* spot); + + // Control spot delete function + void deleteControlSpot(int id); + + // Panel widgets edited states management functions + SpotEdited* getEditedStates(); + void setEditedStates(SpotEdited* se); private: // cell renderer - void render_id (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); - void render_name (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); - void render_isvisible (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); + void render_id(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); + void render_name(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); + void render_isvisible(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); void on_button_add(); void on_button_delete(); @@ -40,7 +105,9 @@ private: void controlspotChanged(); void shapeChanged(); - void shapeMethodeChanged(); + void spotMethodChanged(); + void shapeMethodChanged(); + void qualityMethodChanged(); void updateParamVisibility(); void adjusterChanged(Adjuster* a, double newval); void disableParamlistener(bool cond); @@ -85,7 +152,7 @@ private: public Gtk::Dialog { public: - RenameDialog (const Glib::ustring &actualname, Gtk::Window &parent); + RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent); Glib::ustring get_new_name(); private: @@ -97,12 +164,16 @@ private: // Child widgets Gtk::ScrolledWindow scrolledwindow_; Gtk::TreeView treeview_; + sigc::connection treeviewconn_; Glib::RefPtr treemodel_; Gtk::ButtonBox buttonbox_; Gtk::Button button_add_; + sigc::connection buttonaddconn_; Gtk::Button button_delete_; + sigc::connection buttondeleteconn_; Gtk::Button button_rename_; + sigc::connection buttonrenameconn_; MyComboBoxText* const shape_; sigc::connection shapeconn_; @@ -126,6 +197,8 @@ private: int lastObject_; rtengine::Coord* lastCoord_; + + int eventType; // 0 = No event, 1 = Spot creation event, 2 = Spot deletion event, 3 = Spot selection event }; #endif // _CONTROLSPOTPANEL_H_ diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 11a44497d..da7fc6997 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -40,13 +40,13 @@ using namespace rtengine; -using namespace rtengine::procparams; + extern Options options; Locallab::Locallab(): FoldableToolPanel(this, "locallab", M("TP_LOCALLAB_LABEL"), false, true), - EditSubscriber(ET_OBJECTS), lastObject(-1), + lastObject(-1), expcolor(new MyExpander(true, M("TP_LOCALLAB_COFR"))), expexpose(new MyExpander(true, M("TP_LOCALLAB_EXPOSE"))), expvibrance(new MyExpander(true, M("TP_LOCALLAB_VIBRANCE"))), @@ -56,7 +56,7 @@ Locallab::Locallab(): expsharp(new MyExpander(true, M("TP_LOCALLAB_SHARP"))), expcbdl(new MyExpander(true, M("TP_LOCALLAB_CBDL"))), expdenoi(new MyExpander(true, M("TP_LOCALLAB_DENOIS"))), - expsettings(new MyExpander(false, M("TP_LOCALLAB_SETTINGS"))), + expsettings(new ControlSpotPanel()), LocalcurveEditorgainT(new CurveEditorGroup(options.lastlocalCurvesDir, M("TP_LOCALLAB_TRANSMISSIONGAIN"))), LocalcurveEditorgainTrab(new CurveEditorGroup(options.lastlocalCurvesDir, M("TP_LOCALLAB_TRANSMISSIONGAINRAB"))), @@ -132,8 +132,6 @@ Locallab::Locallab(): blurMethod(Gtk::manage(new MyComboBoxText())), dustMethod(Gtk::manage(new MyComboBoxText())), - excluFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_EXCLUF")))), - artifFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_ARTIF")))), shapeFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_SHFR")))), superFrame(Gtk::manage(new Gtk::Frame())), dustFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_DUST")))), @@ -141,17 +139,12 @@ Locallab::Locallab(): labmdh(Gtk::manage(new Gtk::Label(M("TP_LOCRETI_METHOD") + ":"))), - labqual(Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUAL_METHOD") + ":"))), labqualcurv(Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUALCURV_METHOD") + ":"))), labmS(Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_STYPE") + ":"))), labmEx(Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_EXCLUTYPE") + ":"))), labmshape(Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_SHAPETYPE") + ":"))), - ctboxS(Gtk::manage(new Gtk::HBox())), - ctboxshape(Gtk::manage(new Gtk::HBox())), - ctboxEx(Gtk::manage(new Gtk::HBox())), dhbox(Gtk::manage(new Gtk::HBox())), - qualbox(Gtk::manage(new Gtk::HBox())), qualcurvbox(Gtk::manage(new Gtk::HBox())), avoid(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_AVOID")))), @@ -162,8 +155,7 @@ Locallab::Locallab(): inversret(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_INVERS")))), inverssha(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_INVERS")))), cutpast(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_CUTPAST")))), - lastdust(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_LASTDUST")))), - draggedPointOldAngle(-1000.) + lastdust(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_LASTDUST")))) { CurveListener::setMulti(true); @@ -278,17 +270,9 @@ Locallab::Locallab(): Evlocallabbilateral = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_LOCBILATERAL");// = 598, Evlocallabnoiselequal = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_LOCNOISELEQUAL");// = 599, Evlocallabshapemethod = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_LOCSHAPEMETH");// = 600, - Evlocallabspotduplicated = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_LOCSPOTDUP"); + Evlocallabspotduplicated = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_LOCSPOTDUP");// = 601 + Evlocallabspotcreated = m->newEvent(LUMINANCECURVE, "Spot creation");// = 602 - spotPanel = Gtk::manage(new ControlSpotPanel()); - expsettings->add(*spotPanel); - editHBox = Gtk::manage(new Gtk::HBox()); - edit = Gtk::manage(new Gtk::ToggleButton()); - edit->add(*Gtk::manage(new RTImage("editmodehand.png"))); - edit->set_tooltip_text(M("EDIT_OBJECT_TOOLTIP")); - editConn = edit->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::editToggled)); - editHBox->pack_start(*edit, Gtk::PACK_SHRINK, 0); - pack_start(*editHBox, Gtk::PACK_SHRINK, 0); int realnbspot; @@ -304,17 +288,9 @@ Locallab::Locallab(): const LocallabParams default_params; - nbspot->setAdjusterListener(this); - nbspot->set_tooltip_text(M("TP_LOCALLAB_NBSPOT_TOOLTIP")); - - - anbspot->setAdjusterListener(this); - anbspot->set_tooltip_text(M("TP_LOCALLAB_ANBSPOT_TOOLTIP")); - shapeFrame->set_label_align(0.025, 0.5); - expsettings->signal_button_release_event().connect_notify(sigc::bind(sigc::mem_fun(this, &Locallab::foldAllButMe), expsettings)); - + expsettings->getExpander()->signal_button_release_event().connect_notify(sigc::bind(sigc::mem_fun(this, &Locallab::foldAllButMe), expsettings->getExpander())); expcolor->signal_button_release_event().connect_notify(sigc::bind(sigc::mem_fun(this, &Locallab::foldAllButMe), expcolor)); enablecolorConn = expcolor->signal_enabled_toggled().connect(sigc::bind(sigc::mem_fun(this, &Locallab::enableToggled), expcolor)); @@ -343,73 +319,26 @@ Locallab::Locallab(): expdenoi->signal_button_release_event().connect_notify(sigc::bind(sigc::mem_fun(this, &Locallab::foldAllButMe), expdenoi)); enabledenoiConn = expdenoi->signal_enabled_toggled().connect(sigc::bind(sigc::mem_fun(this, &Locallab::enableToggled), expdenoi)); - - ctboxshape->pack_start(*labmshape, Gtk::PACK_SHRINK, 4); - - ctboxEx->pack_start(*labmEx, Gtk::PACK_SHRINK, 4); - ctboxEx->set_tooltip_markup(M("TP_LOCALLAB_EXCLUTYPE_TOOLTIP")); - shapemethod->append(M("TP_LOCALLAB_ELI")); shapemethod->append(M("TP_LOCALLAB_RECT")); shapemethod->set_active(0); - shapemethodconn = shapemethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::shapemethodChanged)); - - Exclumethod->append(M("TP_LOCALLAB_EXNORM")); Exclumethod->append(M("TP_LOCALLAB_EXECLU")); Exclumethod->set_active(0); - Exclumethodconn = Exclumethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::ExclumethodChanged)); - - sensiexclu->set_tooltip_text(M("TP_LOCALLAB_SENSIEXCLU_TOOLTIP")); - sensiexclu->setAdjusterListener(this); struc->set_tooltip_text(M("TP_LOCALLAB_STRUC_TOOLTIP")); struc->setAdjusterListener(this); - ctboxS->pack_start(*labmS, Gtk::PACK_SHRINK, 4); - ctboxS->set_tooltip_markup(M("TP_LOCALLAB_STYPE_TOOLTIP")); - - Smethod->append(M("TP_LOCALLAB_IND")); Smethod->append(M("TP_LOCALLAB_SYM")); Smethod->append(M("TP_LOCALLAB_INDSL")); Smethod->append(M("TP_LOCALLAB_SYMSL")); Smethod->set_active(0); - Smethodconn = Smethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::SmethodChanged)); - - - locX->setAdjusterListener(this); - - locXL->setAdjusterListener(this); - - degree->setAdjusterListener(this); - - locY->setAdjusterListener(this); - - locYT->setAdjusterListener(this); - - centerX->setAdjusterListener(this); - - centerY->setAdjusterListener(this); - - circrad->setAdjusterListener(this); - - spotduplicated = Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_SPOTDUPLI"))); - spotduplicated->set_active(false); - spotduplicatedConn = spotduplicated->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::spotduplicatedChanged)); - spotduplicated->set_tooltip_markup(M("TP_LOCALLAB_SPOTDUPLI_TOOLTIP")); - // labspotdup = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_SPOTDUP_ENA"))); - qualityMethod->append(M("TP_LOCALLAB_STD")); qualityMethod->append(M("TP_LOCALLAB_ENH")); qualityMethod->append(M("TP_LOCALLAB_ENHDEN")); qualityMethod->set_active(0); - qualityMethodConn = qualityMethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::qualityMethodChanged)); - qualityMethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP")); - thres->setAdjusterListener(this); - - proxi->setAdjusterListener(this); std::vector milestones; std::vector defaultCurve; std::vector defaultCurve2; @@ -529,9 +458,6 @@ Locallab::Locallab(): activlum->set_active(false); activlumConn = activlum->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::activlumChanged)); - transit->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP")); - transit->setAdjusterListener(this); - invers->set_active(false); inversConn = invers->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::inversChanged)); @@ -616,10 +542,8 @@ Locallab::Locallab(): // end reti - ToolParamBlock* const shapeBox = Gtk::manage(new ToolParamBlock()); avoid->set_active(false); avoidConn = avoid->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::avoidChanged)); - shapeBox->pack_start(*nbspot); pack_start(*anbspot); hueref->setAdjusterListener(this); @@ -640,55 +564,10 @@ Locallab::Locallab(): chromaref->hide(); lumaref->hide(); sobelref->hide(); - ctboxshape->pack_start(*shapemethod); - shapeBox->pack_start(*ctboxshape); - ctboxEx->pack_start(*Exclumethod); - shapeBox->pack_start(*ctboxEx); - - excluFrame->set_label_align(0.025, 0.5); - excluFrame->set_tooltip_text(M("TP_LOCALLAB_EXCLUF_TOOLTIP")); - ToolParamBlock* const excluBox = Gtk::manage(new ToolParamBlock()); - - excluBox->pack_start(*sensiexclu); - //excluBox->pack_start(*struc); - excluFrame->add(*excluBox); - shapeBox->pack_start(*excluFrame); - - -// ctboxS->pack_start(*shapemethod); - ctboxS->pack_start(*Smethod); - shapeBox->pack_start(*ctboxS); - - - shapeBox->pack_start(*locX); - shapeBox->pack_start(*locXL); - //pack_start (*degree); - shapeBox->pack_start(*locY); - shapeBox->pack_start(*locYT); - shapeBox->pack_start(*centerX); - shapeBox->pack_start(*centerY); - shapeBox->pack_start(*circrad); - shapeBox->pack_start(*spotduplicated); - //shapeBox->pack_start (*labspotdup); - qualbox->pack_start(*labqual, Gtk::PACK_SHRINK, 4); - qualbox->pack_start(*qualityMethod); - shapeBox->pack_start(*qualbox); - shapeBox->pack_start(*transit); - - artifFrame->set_label_align(0.025, 0.5); - artifFrame->set_tooltip_text(M("TP_LOCALLAB_ARTIF_TOOLTIP")); - - ToolParamBlock* const artifBox = Gtk::manage(new ToolParamBlock()); - - artifBox->pack_start(*thres); - artifBox->pack_start(*proxi); - artifFrame->add(*artifBox); - shapeBox->pack_start(*artifFrame); - - expsettings->add(*shapeBox); + // expsettings->add(*spotPanel); expsettings->setLevel(2); - pack_start(*expsettings); + pack_start(*expsettings->getExpander()); @@ -1094,255 +973,11 @@ Locallab::Locallab(): neutrHBox->pack_start(*neutral); pack_start(*neutrHBox); - - // Instantiating the Editing geometry; positions will be initialized later -// Line *hLine, *vLine, *locYLine[2], *locXLine[2]; - Line *locYLine[2], *locXLine[2]; - Circle *centerCircle; -// Arcellipse *oneellipse; - - Beziers *onebeziers[4] = {}; - Beziers *twobeziers[4] = {}; - Beziers *thrbeziers[4] = {}; - Beziers *foubeziers[4] = {}; - float innw = 0.7f; - // Visible geometry - locXLine[0] = new Line(); - locXLine[0]->innerLineWidth = 2; - locXLine[1] = new Line(); - locXLine[1]->innerLineWidth = 2; - locXLine[0]->datum = locXLine[1]->datum = Geometry::IMAGE; - - locYLine[0] = new Line(); - locYLine[0]->innerLineWidth = 2; - locYLine[1] = new Line(); - locYLine[1]->innerLineWidth = 2; - locYLine[0]->datum = locYLine[1]->datum = Geometry::IMAGE; - - centerCircle = new Circle(); - centerCircle->datum = Geometry::IMAGE; - centerCircle->radiusInImageSpace = true; - centerCircle->radius = circrad->getValue(); //19; - centerCircle->filled = false; - - if (options.showdelimspot) { - onebeziers[0] = new Beziers(); - onebeziers[0]->datum = Geometry::IMAGE; - onebeziers[0]->innerLineWidth = innw; - - onebeziers[1] = new Beziers(); - onebeziers[1]->datum = Geometry::IMAGE; - onebeziers[1]->innerLineWidth = innw; - - onebeziers[2] = new Beziers(); - onebeziers[2]->datum = Geometry::IMAGE; - onebeziers[2]->innerLineWidth = innw; - - onebeziers[3] = new Beziers(); - onebeziers[3]->datum = Geometry::IMAGE; - onebeziers[3]->innerLineWidth = innw; - - twobeziers[0] = new Beziers(); - twobeziers[0]->datum = Geometry::IMAGE; - twobeziers[0]->innerLineWidth = innw; - - twobeziers[1] = new Beziers(); - twobeziers[1]->datum = Geometry::IMAGE; - twobeziers[1]->innerLineWidth = innw; - - twobeziers[2] = new Beziers(); - twobeziers[2]->datum = Geometry::IMAGE; - twobeziers[2]->innerLineWidth = innw; - - twobeziers[3] = new Beziers(); - twobeziers[3]->datum = Geometry::IMAGE; - twobeziers[3]->innerLineWidth = innw; - - thrbeziers[0] = new Beziers(); - thrbeziers[0]->datum = Geometry::IMAGE; - thrbeziers[0]->innerLineWidth = innw; - - thrbeziers[1] = new Beziers(); - thrbeziers[1]->datum = Geometry::IMAGE; - thrbeziers[1]->innerLineWidth = innw; - - thrbeziers[2] = new Beziers(); - thrbeziers[2]->datum = Geometry::IMAGE; - thrbeziers[2]->innerLineWidth = innw; - - thrbeziers[3] = new Beziers(); - thrbeziers[3]->datum = Geometry::IMAGE; - thrbeziers[3]->innerLineWidth = innw; - - foubeziers[0] = new Beziers(); - foubeziers[0]->datum = Geometry::IMAGE; - foubeziers[0]->innerLineWidth = innw; - - foubeziers[1] = new Beziers(); - foubeziers[1]->datum = Geometry::IMAGE; - foubeziers[1]->innerLineWidth = innw; - - foubeziers[2] = new Beziers(); - foubeziers[2]->datum = Geometry::IMAGE; - foubeziers[2]->innerLineWidth = innw; - - foubeziers[3] = new Beziers(); - foubeziers[3]->datum = Geometry::IMAGE; - foubeziers[3]->innerLineWidth = innw; - } - - - EditSubscriber::visibleGeometry.push_back(locXLine[0]); - EditSubscriber::visibleGeometry.push_back(locXLine[1]); - EditSubscriber::visibleGeometry.push_back(locYLine[0]); - EditSubscriber::visibleGeometry.push_back(locYLine[1]); - EditSubscriber::visibleGeometry.push_back(centerCircle); - - if (options.showdelimspot) { - EditSubscriber::visibleGeometry.push_back(onebeziers[0]); - EditSubscriber::visibleGeometry.push_back(onebeziers[1]); - EditSubscriber::visibleGeometry.push_back(onebeziers[2]); - EditSubscriber::visibleGeometry.push_back(onebeziers[3]); - EditSubscriber::visibleGeometry.push_back(twobeziers[0]); - EditSubscriber::visibleGeometry.push_back(twobeziers[1]); - EditSubscriber::visibleGeometry.push_back(twobeziers[2]); - EditSubscriber::visibleGeometry.push_back(twobeziers[3]); - EditSubscriber::visibleGeometry.push_back(thrbeziers[0]); - EditSubscriber::visibleGeometry.push_back(thrbeziers[1]); - EditSubscriber::visibleGeometry.push_back(thrbeziers[2]); - EditSubscriber::visibleGeometry.push_back(thrbeziers[3]); - EditSubscriber::visibleGeometry.push_back(foubeziers[0]); - EditSubscriber::visibleGeometry.push_back(foubeziers[1]); - EditSubscriber::visibleGeometry.push_back(foubeziers[2]); - EditSubscriber::visibleGeometry.push_back(foubeziers[3]); - } - - // MouseOver geometry - locXLine[0] = new Line(); - locXLine[0]->innerLineWidth = 2; - locXLine[1] = new Line(); - locXLine[1]->innerLineWidth = 2; - locXLine[0]->datum = locXLine[1]->datum = Geometry::IMAGE; - - locYLine[0] = new Line(); - locYLine[0]->innerLineWidth = 2; - locYLine[1] = new Line(); - locYLine[1]->innerLineWidth = 2; - locYLine[0]->datum = locYLine[1]->datum = Geometry::IMAGE; - - centerCircle = new Circle(); - centerCircle->datum = Geometry::IMAGE; - centerCircle->radiusInImageSpace = true; - centerCircle->radius = circrad->getValue();//19; - centerCircle->filled = true; - - if (options.showdelimspot) { - onebeziers[0] = new Beziers(); - onebeziers[0]->datum = Geometry::IMAGE; - onebeziers[0]->innerLineWidth = innw; - - onebeziers[1] = new Beziers(); - onebeziers[1]->datum = Geometry::IMAGE; - onebeziers[1]->innerLineWidth = innw; - - onebeziers[2] = new Beziers(); - onebeziers[2]->datum = Geometry::IMAGE; - onebeziers[2]->innerLineWidth = innw; - - onebeziers[3] = new Beziers(); - onebeziers[3]->datum = Geometry::IMAGE; - onebeziers[3]->innerLineWidth = innw; - - twobeziers[0] = new Beziers(); - twobeziers[0]->datum = Geometry::IMAGE; - twobeziers[0]->innerLineWidth = innw; - - twobeziers[1] = new Beziers(); - twobeziers[1]->datum = Geometry::IMAGE; - twobeziers[1]->innerLineWidth = innw; - - twobeziers[2] = new Beziers(); - twobeziers[2]->datum = Geometry::IMAGE; - twobeziers[2]->innerLineWidth = innw; - - twobeziers[3] = new Beziers(); - twobeziers[3]->datum = Geometry::IMAGE; - twobeziers[3]->innerLineWidth = innw; - - thrbeziers[0] = new Beziers(); - thrbeziers[0]->datum = Geometry::IMAGE; - thrbeziers[0]->innerLineWidth = innw; - - thrbeziers[1] = new Beziers(); - thrbeziers[1]->datum = Geometry::IMAGE; - thrbeziers[1]->innerLineWidth = innw; - - thrbeziers[2] = new Beziers(); - thrbeziers[2]->datum = Geometry::IMAGE; - thrbeziers[2]->innerLineWidth = innw; - - thrbeziers[3] = new Beziers(); - thrbeziers[3]->datum = Geometry::IMAGE; - thrbeziers[3]->innerLineWidth = innw; - - foubeziers[0] = new Beziers(); - foubeziers[0]->datum = Geometry::IMAGE; - foubeziers[0]->innerLineWidth = innw; - - foubeziers[1] = new Beziers(); - foubeziers[1]->datum = Geometry::IMAGE; - foubeziers[1]->innerLineWidth = innw; - - foubeziers[2] = new Beziers(); - foubeziers[2]->datum = Geometry::IMAGE; - foubeziers[2]->innerLineWidth = innw; - - foubeziers[3] = new Beziers(); - foubeziers[3]->datum = Geometry::IMAGE; - foubeziers[3]->innerLineWidth = innw; - - } - - EditSubscriber::mouseOverGeometry.push_back(locXLine[0]); - EditSubscriber::mouseOverGeometry.push_back(locXLine[1]); - - EditSubscriber::mouseOverGeometry.push_back(locYLine[0]); - EditSubscriber::mouseOverGeometry.push_back(locYLine[1]); - - EditSubscriber::mouseOverGeometry.push_back(centerCircle); - - if (options.showdelimspot) { - EditSubscriber::mouseOverGeometry.push_back(onebeziers[0]); - EditSubscriber::mouseOverGeometry.push_back(onebeziers[1]); - EditSubscriber::mouseOverGeometry.push_back(onebeziers[2]); - EditSubscriber::mouseOverGeometry.push_back(onebeziers[3]); - EditSubscriber::mouseOverGeometry.push_back(twobeziers[0]); - EditSubscriber::mouseOverGeometry.push_back(twobeziers[1]); - EditSubscriber::mouseOverGeometry.push_back(twobeziers[2]); - EditSubscriber::mouseOverGeometry.push_back(twobeziers[3]); - EditSubscriber::mouseOverGeometry.push_back(thrbeziers[0]); - EditSubscriber::mouseOverGeometry.push_back(thrbeziers[1]); - EditSubscriber::mouseOverGeometry.push_back(thrbeziers[2]); - EditSubscriber::mouseOverGeometry.push_back(thrbeziers[3]); - EditSubscriber::mouseOverGeometry.push_back(foubeziers[0]); - EditSubscriber::mouseOverGeometry.push_back(foubeziers[1]); - EditSubscriber::mouseOverGeometry.push_back(foubeziers[2]); - EditSubscriber::mouseOverGeometry.push_back(foubeziers[3]); - } - show_all(); } Locallab::~Locallab() { - for (std::vector::const_iterator i = visibleGeometry.begin(); i != visibleGeometry.end(); ++i) { - delete *i; - } - - for (std::vector::const_iterator i = mouseOverGeometry.begin(); i != mouseOverGeometry.end(); ++i) { - delete *i; - } - delete LocalcurveEditorgainT; delete LocalcurveEditorgainTrab; delete llCurveEditorG; @@ -1351,7 +986,7 @@ Locallab::~Locallab() void Locallab::foldAllButMe(GdkEventButton* event, MyExpander *expander) { if (event->button == 3) { - expsettings->set_expanded(expsettings == expander); + expsettings->setExpanded(expsettings->getExpander() == expander); expcolor->set_expanded(expcolor == expander); expexpose->set_expanded(expexpose == expander); expvibrance->set_expanded(expvibrance == expander); @@ -1405,7 +1040,7 @@ void Locallab::enableToggled(MyExpander *expander) void Locallab::writeOptions(std::vector &tpOpen) { - tpOpen.push_back(expsettings->get_expanded()); + tpOpen.push_back(expsettings->getExpanded()); tpOpen.push_back(expcolor->get_expanded()); tpOpen.push_back(expexpose->get_expanded()); tpOpen.push_back(expvibrance->get_expanded()); @@ -1421,7 +1056,7 @@ void Locallab::writeOptions(std::vector &tpOpen) void Locallab::updateToolState(std::vector &tpOpen) { if (tpOpen.size() >= 10) { - expsettings->set_expanded(tpOpen.at(0)); + expsettings->setExpanded(tpOpen.at(0)); expcolor->set_expanded(tpOpen.at(1)); expexpose->set_expanded(tpOpen.at(2)); expvibrance->set_expanded(tpOpen.at(3)); @@ -2473,6 +2108,128 @@ void Locallab::localretChanged(int **datasp, std::string datastr, std::string ll void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) { + printf("Locallab read\n"); + + // Disable all listeners + disableListener(); + + if (pedited) { + set_inconsistent(multiImage && !pedited->locallab.enabled); + + ControlSpotPanel::SpotEdited* const se = new ControlSpotPanel::SpotEdited(); + + if (pedited->locallab.nbspot) { + se->addbutton = true; + se->deletebutton = true; + } else { + se->addbutton = false; + se->deletebutton = false; + } + + se->treeview = pedited->locallab.nbspot || pedited->locallab.selspot; + se->name = pedited->locallab.name; + se->isvisible = pedited->locallab.isvisible; + se->shape = pedited->locallab.shape; + se->spotMethod = pedited->locallab.spotMethod; + se->shapeMethod = pedited->locallab.shapeMethod; + se->locX = pedited->locallab.locX; + se->locXL = pedited->locallab.locXL; + se->locY = pedited->locallab.locY; + se->locYT = pedited->locallab.locYT; + se->centerX = pedited->locallab.centerX; + se->centerY = pedited->locallab.centerY; + se->circrad = pedited->locallab.circrad; + se->qualityMethod = pedited->locallab.qualityMethod; + se->transit = pedited->locallab.transit; + se->thresh = pedited->locallab.thresh; + se->iter = pedited->locallab.iter; + expsettings->setEditedStates(se); + } + + setEnabled(pp->locallab.enabled); + + // Add non existent spots and update existent ones + ControlSpotPanel::SpotRow* const r = new ControlSpotPanel::SpotRow(); + + for (int i = 0; i < pp->locallab.nbspot; i++) { + r->id = pp->locallab.id.at(i); + r->name = pp->locallab.name.at(i); + r->isvisible = pp->locallab.isvisible.at(i); + + if (pp->locallab.shape.at(i) == "ELI") { + r->shape = 0; + } else { + r->shape = 1; + } + + if (pp->locallab.spotMethod.at(i) == "norm") { + r->spotMethod = 0; + } else { + r->spotMethod = 1; + } + + if (pp->locallab.shapeMethod.at(i) == "IND") { + r->shapeMethod = 0; + } else if (pp->locallab.shapeMethod.at(i) == "SYM") { + r->shapeMethod = 1; + } else if (pp->locallab.shapeMethod.at(i) == "INDSL") { + r->shapeMethod = 2; + } else { + r->shapeMethod = 3; + } + + r->locX = pp->locallab.locX.at(i); + r->locXL = pp->locallab.locXL.at(i); + r->locY = pp->locallab.locY.at(i); + r->locYT = pp->locallab.locYT.at(i); + r->centerX = pp->locallab.centerX.at(i); + r->centerY = pp->locallab.centerY.at(i); + r->circrad = pp->locallab.circrad.at(i); + + if (pp->locallab.qualityMethod.at(i) == "std") { + r->qualityMethod = 0; + } else if (pp->locallab.qualityMethod.at(i) == "enh") { + r->qualityMethod = 1; + } else { + r->qualityMethod = 2; + } + + r->transit = pp->locallab.transit.at(i); + r->thresh = pp->locallab.thresh.at(i); + r->iter = pp->locallab.iter.at(i); + + if (!expsettings->updateControlSpot(r)) { + expsettings->addControlSpot(r); + } + } + + // Delete not anymore existent spots + std::vector* const list = expsettings->getSpotIdList(); + bool ispresent; + + for (int i = 0; i < (int)list->size(); i++) { + ispresent = false; + + for (int j = 0; j < pp->locallab.nbspot; j++) { + if (list->at(i) == pp->locallab.id.at(j)) { + ispresent = true; + break; + } + } + + if (!ispresent) { + expsettings->deleteControlSpot(list->at(i)); + } + } + + // Select active spot + printf("%d\n", pp->locallab.selspot); + expsettings->setSelectedSpot(pp->locallab.selspot); + + // Enable all listeners + enableListener(); + + /* anbspot->hide(); hueref->hide(); huerefblur->hide(); @@ -2483,6 +2240,7 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) centerYbuf->hide(); disableListener(); + enablecolorConn.block(true); enablevibranceConn.block(true); enableblurConn.block(true); @@ -2494,6 +2252,7 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) if (pedited) { + degree->setEditedState(pedited->locallab.degree ? Edited : UnEdited); locY->setEditedState(pedited->locallab.locY ? Edited : UnEdited); locX->setEditedState(pedited->locallab.locX ? Edited : UnEdited); @@ -2541,7 +2300,7 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) pastSatTog->set_inconsistent(!pedited->locallab.pastsattog); skinTonesCurve->setUnChanged(!pedited->locallab.skintonescurve); sensiv->setEditedState(pedited->locallab.sensiv ? Edited : UnEdited); - spotduplicated->set_inconsistent(!pedited->locallab.spotduplicated); + // spotduplicated->set_inconsistent(!pedited->locallab.spotduplicated); for (int i = 0; i < 5; i++) { multiplier[i]->setEditedState(pedited->locallab.mult[i] ? Edited : UnEdited); @@ -2641,11 +2400,7 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) setEnabled(pp->locallab.enabled); - shapemethodconn.block(true); - Smethodconn.block(true); - Exclumethodconn.block(true); retinexMethodConn.block(true); - qualityMethodConn.block(true); qualitycurveMethodConn.block(true); blurMethodConn.block(true); dustMethodConn.block(true); @@ -2769,13 +2524,9 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) ashiftconn.block(false); lastAvoidColorShift = pp->locallab.avoidcolorshift; - - spotduplicatedConn.block(true); - spotduplicated->set_active(pp->locallab.spotduplicated); - spotduplicatedConn.block(false); + // spotduplicated->set_active(pp->locallab.spotduplicated); lastspotduplicated = pp->locallab.spotduplicated; - pastsattogconn.block(true); pastSatTog->set_active(pp->locallab.pastsattog); pastsattogconn.block(false); @@ -2831,7 +2582,7 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) inversretChanged(); inversshaChanged(); - updateGeometry(pp->locallab.centerX, pp->locallab.centerY, pp->locallab.circrad, pp->locallab.locY, pp->locallab.degree, pp->locallab.locX, pp->locallab.locYT, pp->locallab.locXL); + // updateGeometry(pp->locallab.centerX, pp->locallab.centerY, pp->locallab.circrad, pp->locallab.locY, pp->locallab.degree, pp->locallab.locX, pp->locallab.locYT, pp->locallab.locXL); if (pp->locallab.shapemethod == "ELI") { shapemethod->set_active(0); @@ -2840,8 +2591,6 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) } shapemethodChanged(); - shapemethodconn.block(false); - if (pp->locallab.Smethod == "IND") { Smethod->set_active(0); @@ -2855,7 +2604,6 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) SmethodChanged(); - Smethodconn.block(false); if (pp->locallab.Exclumethod == "norm") { Exclumethod->set_active(0); @@ -2864,7 +2612,6 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) } ExclumethodChanged(); - Exclumethodconn.block(false); if (pp->locallab.retinexMethod == "low") { retinexMethod->set_active(0); @@ -2875,7 +2622,6 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) } retinexMethodChanged(); - retinexMethodConn.block(false); if (pp->locallab.blurMethod == "norm") { blurMethod->set_active(0); @@ -2897,7 +2643,6 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) } dustMethodChanged(); - dustMethodConn.block(false); if (pp->locallab.qualityMethod == "std") { qualityMethod->set_active(0); @@ -2908,7 +2653,6 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) } qualityMethodChanged(); - qualityMethodConn.block(false); if (pp->locallab.qualitycurveMethod == "none") { qualitycurveMethod->set_active(0); @@ -2955,205 +2699,198 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) enabledenoiConn.block(false); enableListener(); -} - -void Locallab::updateGeometry(const int centerX_, const int centerY_, const int circrad_, const int locY_, const double degree_, const int locX_, const int locYT_, const int locXL_, const int fullWidth, const int fullHeight) -{ - EditDataProvider* dataProvider = getEditProvider(); - - - if (!dataProvider) { - return; - } - - int imW = 0; - int imH = 0; - - if (fullWidth != -1 && fullHeight != -1) { - imW = fullWidth; - imH = fullHeight; - } else { - dataProvider->getImageSize(imW, imH); - - if (!imW || !imH) { - return; - } - } - - PolarCoord polCoord1, polCoord2, polCoord0; - // dataProvider->getImageSize(imW, imH); - double decayY = (locY_) * double (imH) / 2000.; - double decayYT = (locYT_) * double (imH) / 2000.; - double decayX = (locX_) * (double (imW)) / 2000.; - double decayXL = (locXL_) * (double (imW)) / 2000.; - rtengine::Coord origin(imW / 2 + centerX_ * imW / 2000.f, imH / 2 + centerY_ * imH / 2000.f); -// printf("deX=%f dexL=%f deY=%f deyT=%f locX=%i locY=%i\n", decayX, decayXL, decayY, decayYT, locX_, locY_); - - if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - decayYT = decayY; - decayXL = decayX; - } - -// Line *currLine; -// Circle *currCircle; -// Beziers *currBeziers; - double decay; - /* - const auto updateLine = [&] (Geometry * geometry, const float radius, const float begin, const float end) { - const auto line = static_cast (geometry); - line->begin = PolarCoord (radius, -degree_ + begin); - line->begin += origin; - line->end = PolarCoord (radius, -degree_ + end); - line->end += origin; - }; */ - const auto updateLineWithDecay = [&](Geometry * geometry, const float radius, const float decal, const float offSetAngle) { - const auto line = static_cast(geometry); //180 - line->begin = PolarCoord(radius, -degree_ + decal) + PolarCoord(decay, -degree_ + offSetAngle); - line->begin += origin;//0 - line->end = PolarCoord(radius, -degree_ + (decal - 180)) + PolarCoord(decay, -degree_ + offSetAngle); - line->end += origin; - }; - - const auto updateCircle = [&](Geometry * geometry) { - const auto circle = static_cast(geometry); - circle->center = origin; - circle->radius = circrad_; - }; - - const auto updateBeziers = [&](Geometry * geometry, const double dX_, const double dI_, const double dY_, const float begi, const float inte, const float en) { - const auto beziers = static_cast(geometry); - beziers->begin = PolarCoord(dX_, begi); - beziers->begin += origin;//0 - beziers->inter = PolarCoord(dI_, inte); - beziers->inter += origin;//0 - beziers->end = PolarCoord(dY_, en); - beziers->end += origin; - // printf("dX=%f dI=%f dY=%f begx=%i begy=%i intx=%i inty=%i endx=%i endy=%i\n", dX_, dI_, dY_, beziers->begin.x, beziers->begin.y, beziers->inter.x, beziers->inter.y, beziers->end.x, beziers->end.y); - }; - - double dimline = 100.; - - if (options.showdelimspot) { - dimline = 500.; - } - - - decay = decayX; - updateLineWithDecay(visibleGeometry.at(0), dimline, 90., 0.); - updateLineWithDecay(mouseOverGeometry.at(0), dimline, 90., 0.); - - decay = decayXL; - - updateLineWithDecay(visibleGeometry.at(1), dimline, 90., 180.); - updateLineWithDecay(mouseOverGeometry.at(1), dimline, 90., 180.); - - decay = decayYT; - updateLineWithDecay(visibleGeometry.at(2), dimline, 180., 270.); - updateLineWithDecay(mouseOverGeometry.at(2), dimline, 180., 270.); - - decay = decayY; - - updateLineWithDecay(visibleGeometry.at(3), dimline, 180, 90.); - updateLineWithDecay(mouseOverGeometry.at(3), dimline, 180., 90.); - - - updateCircle(visibleGeometry.at(4)); - updateCircle(mouseOverGeometry.at(4)); - - if (options.showdelimspot) { - //this decayww evaluate approximation of a point in the ellipse for an angle alpha - //this decayww evaluate approximation of a point in the ellipse for an angle alpha - double decay5 = 1.003819 * ((decayX * decayY) / sqrt(0.00765 * SQR(decayX) + SQR(decayY))); //0.07179 = SQR(sin(15)/cos(15)) 1.0038 = 1 / cos(5) - double decay15 = 1.03527 * ((decayX * decayY) / sqrt(0.07179 * SQR(decayX) + SQR(decayY))); //0.07179 = SQR(sin(15)/cos(15)) 1.03527 = 1 / cos(15) - double decay30 = 1.15473 * ((decayX * decayY) / sqrt(0.33335 * SQR(decayX) + SQR(decayY))); - double decay60 = 2. * ((decayX * decayY) / sqrt(3.0 * SQR(decayX) + SQR(decayY))); - double decay75 = 3.86398 * ((decayX * decayY) / sqrt(13.929 * SQR(decayX) + SQR(decayY))); - double decay85 = 11.473 * ((decayX * decayY) / sqrt(130.64 * SQR(decayX) + SQR(decayY))); - - double decay5L = 1.003819 * ((decayXL * decayY) / sqrt(0.00765 * SQR(decayXL) + SQR(decayY))); //0.07179 = SQR(sin(15)/cos(15)) 1.0038 = 1 / cos(5) - double decay15L = 1.03527 * ((decayXL * decayY) / sqrt(0.07179 * SQR(decayXL) + SQR(decayY))); - double decay30L = 1.15473 * ((decayXL * decayY) / sqrt(0.33335 * SQR(decayXL) + SQR(decayY))); - double decay60L = 2. * ((decayXL * decayY) / sqrt(3.0 * SQR(decayXL) + SQR(decayY))); - double decay75L = 3.86398 * ((decayXL * decayY) / sqrt(13.929 * SQR(decayXL) + SQR(decayY))); - double decay85L = 11.473 * ((decayXL * decayY) / sqrt(130.64 * SQR(decayXL) + SQR(decayY))); - - double decay5LT = 1.003819 * ((decayXL * decayYT) / sqrt(0.00765 * SQR(decayXL) + SQR(decayYT))); //0.07179 = SQR(sin(15)/cos(15)) 1.0038 = 1 / cos(5) - double decay15LT = 1.03527 * ((decayXL * decayYT) / sqrt(0.07179 * SQR(decayXL) + SQR(decayYT))); - double decay30LT = 1.15473 * ((decayXL * decayYT) / sqrt(0.33335 * SQR(decayXL) + SQR(decayYT))); - double decay60LT = 2. * ((decayXL * decayYT) / sqrt(3.0 * SQR(decayXL) + SQR(decayYT))); - double decay75LT = 3.86398 * ((decayXL * decayYT) / sqrt(13.929 * SQR(decayXL) + SQR(decayYT))); - double decay85LT = 11.473 * ((decayXL * decayYT) / sqrt(130.64 * SQR(decayXL) + SQR(decayYT))); - - double decay5T = 1.003819 * ((decayX * decayYT) / sqrt(0.00765 * SQR(decayX) + SQR(decayYT))); //0.07179 = SQR(sin(15)/cos(15)) 1.0038 = 1 / cos(5) - double decay15T = 1.03527 * ((decayX * decayYT) / sqrt(0.07179 * SQR(decayX) + SQR(decayYT))); - double decay30T = 1.15473 * ((decayX * decayYT) / sqrt(0.33335 * SQR(decayX) + SQR(decayYT))); - double decay60T = 2. * ((decayX * decayYT) / sqrt(3.0 * SQR(decayX) + SQR(decayYT))); - double decay75T = 3.86398 * ((decayX * decayYT) / sqrt(13.929 * SQR(decayX) + SQR(decayYT))); - double decay85T = 11.473 * ((decayX * decayYT) / sqrt(130.64 * SQR(decayX) + SQR(decayYT))); - - double decay45 = (1.414 * decayX * decayY) / sqrt(SQR(decayX) + SQR(decayY)); - double decay45L = (1.414 * decayXL * decayY) / sqrt(SQR(decayXL) + SQR(decayY)); - double decay45LT = (1.414 * decayXL * decayYT) / sqrt(SQR(decayXL) + SQR(decayYT)); - double decay45T = (1.414 * decayX * decayYT) / sqrt(SQR(decayX) + SQR(decayYT)); - - //printf("decayX=%f decayY=%f decay10=%f decay45=%f oriX=%i origY=%i\n", decayX, decayY, decay10, decay45, origin.x, origin.y); - updateBeziers(visibleGeometry.at(5), decayX, decay5, decay15, 0., 5., 15.); - updateBeziers(mouseOverGeometry.at(5), decayX, decay5, decay15, 0., 5., 15.); - - updateBeziers(visibleGeometry.at(6), decay15, decay30, decay45, 15., 30., 45.); - updateBeziers(mouseOverGeometry.at(6), decay15, decay30, decay45, 15., 30., 45.); - - updateBeziers(visibleGeometry.at(7), decay45, decay60, decay75, 45., 60., 75.); - updateBeziers(mouseOverGeometry.at(7), decay45, decay60, decay75, 45., 60., 75.); - - updateBeziers(visibleGeometry.at(8), decay75, decay85, decayY, 75., 85., 90.); - updateBeziers(mouseOverGeometry.at(8), decay75, decay85, decayY, 75., 85., 90.); - - updateBeziers(visibleGeometry.at(9), decayY, decay85L, decay75L, 90., 95., 105.); - updateBeziers(mouseOverGeometry.at(9), decayY, decay85L, decay75L, 90., 95., 105.); - - updateBeziers(visibleGeometry.at(10), decay75L, decay60L, decay45L, 105., 120., 135.); - updateBeziers(mouseOverGeometry.at(10), decay75L, decay60L, decay45L, 105., 120., 135.); - - updateBeziers(visibleGeometry.at(11), decay45L, decay30L, decay15L, 135., 150., 165.); - updateBeziers(mouseOverGeometry.at(11), decay45L, decay30L, decay15L, 135., 150., 165.); - - updateBeziers(visibleGeometry.at(12), decay15L, decay5L, decayXL, 165., 175., 180.); - updateBeziers(mouseOverGeometry.at(12), decay15L, decay5L, decayXL, 165., 175., 180.); - - - updateBeziers(visibleGeometry.at(13), decayXL, decay5LT, decay15LT, 180., 185., 195.); - updateBeziers(mouseOverGeometry.at(13), decayXL, decay5LT, decay15LT, 180., 185., 195.); - - updateBeziers(visibleGeometry.at(14), decay15LT, decay30LT, decay45LT, 195., 210., 225.); - updateBeziers(mouseOverGeometry.at(14), decay15LT, decay30LT, decay45LT, 195., 210., 225.); - - updateBeziers(visibleGeometry.at(15), decay45LT, decay60LT, decay75LT, 225., 240., 255.); - updateBeziers(mouseOverGeometry.at(15), decay45LT, decay60LT, decay75LT, 225., 240., 255.); - - updateBeziers(visibleGeometry.at(16), decay75LT, decay85LT, decayYT, 255., 265., 270.); - updateBeziers(mouseOverGeometry.at(16), decay75LT, decay85LT, decayYT, 255., 265., 270.); - - updateBeziers(visibleGeometry.at(17), decayYT, decay85T, decay75T, 270., 275., 285.); - updateBeziers(mouseOverGeometry.at(17), decayYT, decay85T, decay75T, 270., 275., 285.); - - updateBeziers(visibleGeometry.at(18), decay75T, decay60T, decay45T, 285., 300., 315.); - updateBeziers(mouseOverGeometry.at(18), decay75T, decay60T, decay45T, 285., 300., 315.); - - updateBeziers(visibleGeometry.at(19), decay45T, decay30T, decay15T, 315., 330., 345.); - updateBeziers(mouseOverGeometry.at(19), decay45T, decay30T, decay15T, 315., 330., 345.); - - updateBeziers(visibleGeometry.at(20), decay15T, decay5T, decayX, 345., 355., 360.); - updateBeziers(mouseOverGeometry.at(20), decay15T, decay5T, decayX, 345., 355., 360.); - - } - - } void Locallab::write(ProcParams* pp, ParamsEdited* pedited) { + printf("Locallab write\n"); + + pp->locallab.enabled = getEnabled(); + + const int spotPanelEvent = expsettings->getEventType(); + int spotId; + ControlSpotPanel::SpotRow* r; + + switch (spotPanelEvent) { + case (1): // 1 = Spot creation event + // Spot creation (default initialization) + spotId = expsettings->getNewId(); + r = new ControlSpotPanel::SpotRow(); + r->id = spotId; + r->name = "Control Spot #" + std::to_string(spotId); + r->isvisible = true; + r->shape = 0; + r->spotMethod = 0; + r->shapeMethod = 2; + r->locX = 250; + r->locXL = 250; + r->locY = 250; + r->locYT = 250; + r->centerX = 0; + r->centerY = 0; + r->circrad = 18; + r->qualityMethod = 0; + r->transit = 60; + r->thresh = 18; + r->iter = 0; + expsettings->addControlSpot(r); + expsettings->setSelectedSpot(spotId); + + // ProcParams update + pp->locallab.nbspot++; + pp->locallab.selspot = spotId; + pp->locallab.id.push_back(r->id); + pp->locallab.name.push_back(r->name); + pp->locallab.isvisible.push_back(r->isvisible); + pp->locallab.shape.push_back("ELI"); + pp->locallab.spotMethod.push_back("norm"); + pp->locallab.shapeMethod.push_back("INDSL"); + pp->locallab.locX.push_back(r->locX); + pp->locallab.locXL.push_back(r->locXL); + pp->locallab.locY.push_back(r->locY); + pp->locallab.locYT.push_back(r->locYT); + pp->locallab.centerX.push_back(r->centerX); + pp->locallab.centerY.push_back(r->centerY); + pp->locallab.circrad.push_back(r->circrad); + pp->locallab.qualityMethod.push_back("std"); + pp->locallab.transit.push_back(r->transit); + pp->locallab.thresh.push_back(r->thresh); + pp->locallab.iter.push_back(r->iter); + + break; + + case (2): // 2 = Spot deletion event + // Get deleted spot index in ProcParams and update it + spotId = expsettings->getSelectedSpot(); + + for (int i = 0; i < pp->locallab.nbspot; i++) { + if (pp->locallab.id.at(i) == spotId) { + // ProcParams update + pp->locallab.nbspot--; + pp->locallab.id.erase(pp->locallab.id.begin() + i); + pp->locallab.name.erase(pp->locallab.name.begin() + i); + pp->locallab.isvisible.erase(pp->locallab.isvisible.begin() + i); + pp->locallab.shape.erase(pp->locallab.shape.begin() + i); + pp->locallab.spotMethod.erase(pp->locallab.spotMethod.begin() + i); + pp->locallab.shapeMethod.erase(pp->locallab.shapeMethod.begin() + i); + pp->locallab.locX.erase(pp->locallab.locX.begin() + i); + pp->locallab.locXL.erase(pp->locallab.locXL.begin() + i); + pp->locallab.locY.erase(pp->locallab.locY.begin() + i); + pp->locallab.locYT.erase(pp->locallab.locYT.begin() + i); + pp->locallab.centerX.erase(pp->locallab.centerX.begin() + i); + pp->locallab.centerY.erase(pp->locallab.centerY.begin() + i); + pp->locallab.circrad.erase(pp->locallab.circrad.begin() + i); + pp->locallab.qualityMethod.erase(pp->locallab.qualityMethod.begin() + i); + pp->locallab.transit.erase(pp->locallab.transit.begin() + i); + pp->locallab.thresh.erase(pp->locallab.thresh.begin() + i); + pp->locallab.iter.erase(pp->locallab.iter.begin() + i); + expsettings->deleteControlSpot(spotId); + + // Select one remaining spot + if (pp->locallab.nbspot >= 1) { + pp->locallab.selspot = 1; + expsettings->setSelectedSpot(1); + } else { + pp->locallab.selspot = 0; + } + + break; + } + } + + break; + + case (3): // 3 = Spot selection event + spotId = expsettings->getSelectedSpot(); + pp->locallab.selspot = spotId; + expsettings->setSelectedSpot(spotId); + + break; + + default: // Spot or locallab GUI updated + spotId = expsettings->getSelectedSpot(); + r = expsettings->getSpot(spotId); + + for (int i = 0; i < pp->locallab.nbspot; i++) { + if (pp->locallab.id.at(i) == spotId) { + // ProcParams update + pp->locallab.name.at(i) = r->name; + pp->locallab.isvisible.at(i) = r->isvisible; + + if (r->shape == 0) { + pp->locallab.shape.at(i) = "ELI"; + } else { + pp->locallab.shape.at(i) = "RECT"; + } + + if (r->spotMethod == 0) { + pp->locallab.spotMethod.at(i) = "norm"; + } else { + pp->locallab.spotMethod.at(i) = "exc"; + } + + if (r->shapeMethod == 0) { + pp->locallab.shapeMethod.at(i) = "IND"; + } else if (r->shapeMethod == 1) { + pp->locallab.shapeMethod.at(i) = "SYM"; + } else if (r->shapeMethod == 2) { + pp->locallab.shapeMethod.at(i) = "INDSL"; + } else { + pp->locallab.shapeMethod.at(i) = "SYMSL"; + } + + pp->locallab.locX.at(i) = r->locX; + pp->locallab.locXL.at(i) = r->locXL; + pp->locallab.locY.at(i) = r->locY; + pp->locallab.locYT.at(i) = r->locYT; + pp->locallab.centerX.at(i) = r->centerX; + pp->locallab.centerY.at(i) = r->centerY; + pp->locallab.circrad.at(i) = r->circrad; + + if (r->qualityMethod == 0) { + pp->locallab.qualityMethod.at(i) = "std"; + } else if (r->qualityMethod == 1) { + pp->locallab.qualityMethod.at(i) = "enh"; + } else { + pp->locallab.qualityMethod.at(i) = "enhden"; + } + + pp->locallab.transit.at(i) = r->transit; + pp->locallab.thresh.at(i) = r->thresh; + pp->locallab.iter.at(i) = r->iter; + + break; + } + } + } + + if (pedited) { + pedited->locallab.enabled = !get_inconsistent(); + + ControlSpotPanel::SpotEdited* const se = expsettings->getEditedStates(); + pedited->locallab.nbspot = se->addbutton || se->deletebutton; + pedited->locallab.selspot = se->treeview; + pedited->locallab.id = se->addbutton || se->deletebutton; + pedited->locallab.name = se->name; + pedited->locallab.isvisible = se->isvisible; + pedited->locallab.shape = se->shape; + pedited->locallab.spotMethod = se->spotMethod; + pedited->locallab.shapeMethod = se->shapeMethod; + pedited->locallab.locX = se->locX; + pedited->locallab.locXL = se->locXL; + pedited->locallab.locY = se->locY; + pedited->locallab.locYT = se->locYT; + pedited->locallab.centerX = se->centerX; + pedited->locallab.centerY = se->centerY; + pedited->locallab.circrad = se->circrad; + pedited->locallab.qualityMethod = se->qualityMethod; + pedited->locallab.transit = se->transit; + pedited->locallab.thresh = se->thresh; + pedited->locallab.iter = se->iter; + } + + /* pp->locallab.degree = degree->getValue(); pp->locallab.locY = locY->getIntValue(); pp->locallab.locX = locX->getValue(); @@ -3260,7 +2997,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.pastsattog = pastSatTog->get_active(); pp->locallab.skintonescurve = skinTonesCurve->getCurve(); pp->locallab.sensiv = sensiv->getIntValue(); - pp->locallab.spotduplicated = spotduplicated->get_active(); + // pp->locallab.spotduplicated = spotduplicated->get_active(); if (pedited) { @@ -3381,7 +3118,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.pastsattog = !pastSatTog->get_inconsistent(); pedited->locallab.skintonescurve = !skinTonesCurve->isUnChanged(); pedited->locallab.sensiv = sensiv->getEditedState(); - pedited->locallab.spotduplicated = !spotduplicated->get_inconsistent(); + // pedited->locallab.spotduplicated = !spotduplicated->get_inconsistent(); } @@ -3449,7 +3186,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) } if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { -// if(Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 1) { + // if(Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 1) { pp->locallab.locX = locX->getValue(); pp->locallab.locY = locY->getValue(); @@ -3462,12 +3199,14 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.locY=pp->locallab.locX; } */ + /* else { pp->locallab.locXL = locXL->getValue(); pp->locallab.locX = locX->getValue(); pp->locallab.locY = locY->getValue(); pp->locallab.locYT = locYT->getValue(); } + */ } void Locallab::protectskins_toggled() @@ -3535,7 +3274,7 @@ bool Locallab::spotdupComputed_() { disableListener(); - spotduplicated->set_active(nextspotdup); + // spotduplicated->set_active(nextspotdup); if (nextspotdup) { //labspotdup->show(); @@ -3552,12 +3291,11 @@ bool Locallab::spotdupComputed_() void Locallab::spotduplicatedChanged() { + /* if (batchMode) { if (spotduplicated->get_inconsistent()) { spotduplicated->set_inconsistent(false); - spotduplicatedConn.block(true); - spotduplicated->set_active(false); - spotduplicatedConn.block(false); + spotduplicated->set_active(false);; } else if (lastspotduplicated) { spotduplicated->set_inconsistent(true); } @@ -3573,6 +3311,7 @@ void Locallab::spotduplicatedChanged() listener->panelChanged(Evlocallabspotduplicated, M("GENERAL_DISABLED")); } } + */ } void Locallab::pastsattog_toggled() @@ -3780,9 +3519,7 @@ void Locallab::ExclumethodChanged() { if (!batchMode) { if (Exclumethod->get_active_row_number() == 0) { - excluFrame->hide(); } else if (Exclumethod->get_active_row_number() == 1) { - excluFrame->show(); } } @@ -3891,7 +3628,6 @@ void Locallab::inversChanged() llCurveEditorG->hide(); curvactiv->hide(); qualitycurveMethod->hide(); - artifFrame->show(); labqualcurv->hide(); } else { @@ -3900,7 +3636,6 @@ void Locallab::inversChanged() llCurveEditorG->show(); curvactiv->show(); qualitycurveMethod->show(); - artifFrame->show(); labqualcurv->show(); } @@ -4116,9 +3851,10 @@ void Locallab::inversretChanged() } } - +// TODO void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pedited) { + /* degree->setDefault(defParams->locallab.degree); locY->setDefault(defParams->locallab.locY); locX->setDefault(defParams->locallab.locX); @@ -4357,6 +4093,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe sensiv->setDefaultEditedState(Irrelevant); } + */ } void Locallab::adjusterChanged(ThresholdAdjuster* a, int newBottom, int newTop) @@ -4369,7 +4106,7 @@ void Locallab::adjusterChanged(ThresholdAdjuster* a, int newBottom, int newTop) void Locallab::adjusterChanged(Adjuster * a, double newval) { - updateGeometry(int (centerX->getValue()), int (centerY->getValue()), int (circrad->getValue()), (int)locY->getValue(), degree->getValue(), (int)locX->getValue(), (int)locYT->getValue(), (int)locXL->getValue()); + // updateGeometry(int (centerX->getValue()), int (centerY->getValue()), int (circrad->getValue()), (int)locY->getValue(), degree->getValue(), (int)locX->getValue(), (int)locYT->getValue(), (int)locXL->getValue()); anbspot->hide(); hueref->hide(); huerefblur->hide(); @@ -4648,8 +4385,10 @@ void Locallab::setAdjusterBehavior(bool degreeadd, bool locYadd, bool locXadd, b } +// TODO void Locallab::trimValues(rtengine::procparams::ProcParams * pp) { + /* degree->trimValue(pp->locallab.degree); locY->trimValue(pp->locallab.locY); locX->trimValue(pp->locallab.locX); @@ -4726,13 +4465,13 @@ void Locallab::trimValues(rtengine::procparams::ProcParams * pp) pastels->trimValue(pp->locallab.pastels); saturated->trimValue(pp->locallab.saturated); sensiv->trimValue(pp->locallab.sensiv); - + */ } void Locallab::setBatchMode(bool batchMode) { - removeIfThere(this, edit, false); ToolPanel::setBatchMode(batchMode); + printf("BatchMode : %d\n", batchMode); hueref->hide(); huerefblur->hide(); @@ -4878,19 +4617,19 @@ std::vector Locallab::getCurvePoints(ThresholdSelector* tAdjuster) const void Locallab::setEditProvider(EditDataProvider * provider) { - EditSubscriber::setEditProvider(provider); cTgainshape->setEditProvider(provider); cTgainshaperab->setEditProvider(provider); - spotPanel->setEditProvider(provider); + expsettings->setEditProvider(provider); } -void Locallab::editToggled() +void Locallab::subscribe() { - if (edit->get_active()) { - subscribe(); - } else { - unsubscribe(); - } + expsettings->subscribe(); +} + +void Locallab::unsubscribe() +{ + expsettings->unsubscribe(); } void Locallab::colorForValue(double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) @@ -4935,743 +4674,8 @@ void Locallab::colorForValue(double valX, double valY, enum ColorCaller::ElemTyp caller->ccBlue = double (B); } - - -CursorShape Locallab::getCursor(int objectID) +void Locallab::setListener(ToolPanelListener* tpl) { - switch (objectID) { - case (2): { - int angle = degree->getIntValue(); - - if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { - return CSMove1DV; - } - - return CSMove1DH; - } - - case (3): { - int angle = degree->getIntValue(); - - if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { - return CSMove1DV; - } - - return CSMove1DH; - } - - case (0): { - int angle = degree->getIntValue(); - - if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { - return CSMove1DH; - } - - return CSMove1DV; - } - - case (1): { - int angle = degree->getIntValue(); - - if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { - return CSMove1DH; - } - - return CSMove1DV; - } - - case (4): - return CSMove2D; - - default: - return CSOpenHand; - } + this->listener = tpl; + expsettings->setListener(tpl); } - -bool Locallab::mouseOver(int modifierKey) -{ - EditDataProvider* editProvider = getEditProvider(); - - if (editProvider && editProvider->object != lastObject) { - if (lastObject > -1) { - if (lastObject == 2 || lastObject == 3) { - EditSubscriber::visibleGeometry.at(2)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at(3)->state = Geometry::NORMAL; - - } else if (lastObject == 0 || lastObject == 1) { - EditSubscriber::visibleGeometry.at(0)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at(1)->state = Geometry::NORMAL; - - } - - else { - EditSubscriber::visibleGeometry.at(4)->state = Geometry::NORMAL; -// EditSubscriber::visibleGeometry.at (lastObject)->state = Geometry::NORMAL; - } - } - - if (editProvider->object > -1) { - if (editProvider->object == 2 || editProvider->object == 3) { - EditSubscriber::visibleGeometry.at(2)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at(3)->state = Geometry::PRELIGHT; - - } else if (editProvider->object == 0 || editProvider->object == 1) { - EditSubscriber::visibleGeometry.at(0)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at(1)->state = Geometry::PRELIGHT; - - } - - else { - EditSubscriber::visibleGeometry.at(4)->state = Geometry::PRELIGHT; - // EditSubscriber::visibleGeometry.at (editProvider->object)->state = Geometry::PRELIGHT; - } - } - - lastObject = editProvider->object; - return true; - } - - return false; -} - -bool Locallab::button1Pressed(int modifierKey) -{ - if (lastObject < 0) { - return false; - } - - EditDataProvider *provider = getEditProvider(); - - if (!(modifierKey & GDK_CONTROL_MASK)) { - // button press is valid (no modifier key) - PolarCoord pCoord; - // EditDataProvider *provider = getEditProvider(); - int imW, imH; - provider->getImageSize(imW, imH); - double halfSizeW = imW / 2.; - double halfSizeH = imH / 2.; - draggedCenter.set(int (halfSizeW + halfSizeW * (centerX->getValue() / 1000.)), int (halfSizeH + halfSizeH * (centerY->getValue() / 1000.))); - - // trick to get the correct angle (clockwise/counter-clockwise) - rtengine::Coord p1 = draggedCenter; - rtengine::Coord p2 = provider->posImage; - int p = p1.y; - p1.y = p2.y; - p2.y = p; - pCoord = p2 - p1; - draggedPointOldAngle = pCoord.angle; - draggedPointAdjusterAngle = degree->getValue(); - - if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { - if (lastObject == 2) { - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage; - rtengine::Coord centerPos = draggedCenter; - double verti = double (imH); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - // compute the projected value of the dragged point - draggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI); - - if (lastObject == 2) { - //draggedlocYOffset = -draggedlocYOffset; - draggedlocYOffset -= (locYT->getValue() / 2000. * verti); - - } - } else if (lastObject == 3) { - // Dragging a line to change the angle - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage; - rtengine::Coord centerPos = draggedCenter; - - double verti = double (imH); - - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - // compute the projected value of the dragged point - draggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI); - - if (lastObject == 3) { - draggedlocYOffset = -draggedlocYOffset; - draggedlocYOffset -= (locY->getValue() / 2000. * verti); - - } - - } - - } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - if (lastObject == 2 || lastObject == 3) { - // Dragging a line to change the angle - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage; - rtengine::Coord centerPos = draggedCenter; - double verti = double (imH); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - // compute the projected value of the dragged point - draggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI); - - if (lastObject == 3) { - draggedlocYOffset = -draggedlocYOffset; - } - - draggedlocYOffset -= (locY->getValue() / 2000. * verti); - } - } - - if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { - if (lastObject == 0) { - // Dragging a line to change the angle - - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage; - rtengine::Coord centerPos = draggedCenter; - - double horiz = double (imW); - - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - // compute the projected value of the dragged point - //printf ("rad=%f ang=%f\n", draggedPoint.radius, draggedPoint.angle - degree->getValue()); - draggedlocXOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue() + 90.) / 180.*rtengine::RT_PI); - // if (lastObject==1) - // draggedlocXOffset = -draggedlocXOffset;//- - draggedlocXOffset -= (locX->getValue() / 2000. * horiz); - } else if (lastObject == 1) { - - // Dragging a line to change the angle - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage; - rtengine::Coord centerPos = draggedCenter; - double horiz = double (imW); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - // printf ("rad=%f ang=%f\n", draggedPoint.radius, draggedPoint.angle - degree->getValue()); - draggedlocXOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue() + 90.) / 180.*rtengine::RT_PI); - - if (lastObject == 1) { - draggedlocXOffset = -draggedlocXOffset; //- - } - - draggedlocXOffset -= (locXL->getValue() / 2000. * horiz); - } - - } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - - if (lastObject == 0 || lastObject == 1) { - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage; - rtengine::Coord centerPos = draggedCenter; - double horiz = double (imW); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - //printf ("rad=%f ang=%f\n", draggedPoint.radius, draggedPoint.angle - degree->getValue()); - draggedlocXOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue() + 90.) / 180.*rtengine::RT_PI); - - if (lastObject == 1) { - draggedlocXOffset = -draggedlocXOffset; //- - } - - draggedlocXOffset -= (locX->getValue() / 2000. * horiz); - } - } - - /* else if(Smethod->get_active_row_number()==2) { - if (lastObject==0 || lastObject==1 || lastObject==2 || lastObject==3) { - if (lastObject==2 || lastObject==3) { - // Dragging a line to change the angle - PolarCoord draggedPoint; - Coord currPos; - currPos = provider->posImage; - Coord centerPos = draggedCenter; - double verti = double(imH); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - - draggedPoint.setFromCartesian(centerPos, currPos); - // compute the projected value of the dragged point - draggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue())/180.*M_PI); - if (lastObject==3) - draggedlocYOffset = -draggedlocYOffset; - draggedlocYOffset -= (locY->getValue() / 200. * verti); - } - - - if (lastObject==0 || lastObject==1) { - PolarCoord draggedPoint; - Coord currPos; - currPos = provider->posImage; - Coord centerPos = draggedCenter; - double horiz = double(imW); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint.setFromCartesian(centerPos, currPos); - printf("rad=%f ang=%f\n",draggedPoint.radius,draggedPoint.angle-degree->getValue()); - draggedlocXOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue()+90.)/180.*M_PI); - if (lastObject==1) - draggedlocXOffset = -draggedlocXOffset;//- - draggedlocXOffset -= (locX->getValue() / 200. * horiz); - } - - } - } - */ - // EditSubscriber::dragging = true; - EditSubscriber::action = ES_ACTION_DRAGGING; - return false; - } else { - // this will let this class ignore further drag events - if (lastObject > -1) { // should theoretically always be true - if (lastObject == 2 || lastObject == 3) { - EditSubscriber::visibleGeometry.at(2)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at(3)->state = Geometry::NORMAL; - } - - if (lastObject == 0 || lastObject == 1) { - EditSubscriber::visibleGeometry.at(0)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at(1)->state = Geometry::NORMAL; - - } else { - EditSubscriber::visibleGeometry.at(4)->state = Geometry::NORMAL; -// EditSubscriber::visibleGeometry.at (lastObject)->state = Geometry::NORMAL; - } - } - - lastObject = -1; - return true; - } -} - -bool Locallab::button1Released() -{ - draggedPointOldAngle = -1000.; - EditSubscriber::action = ES_ACTION_NONE; - - return true; -} - -bool Locallab::drag1(int modifierKey) -{ - // compute the polar coordinate of the mouse position - EditDataProvider *provider = getEditProvider(); - int imW, imH; - provider->getImageSize(imW, imH); - double halfSizeW = imW / 2.; - double halfSizeH = imH / 2.; - - if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { - if (lastObject == 2) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage + provider->deltaImage; - rtengine::Coord centerPos = draggedCenter; - double verti = double (imH); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI); - - if (lastObject == 2) { - currDraggedlocYOffset -= draggedlocYOffset; - } - - //else if (lastObject==3) - // Dragging the lower locY bar - // currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; - currDraggedlocYOffset = currDraggedlocYOffset * 2000. / verti; - - if (int (currDraggedlocYOffset) != locYT->getIntValue()) { - locYT->setValue((int (currDraggedlocYOffset))); - double centX, centY; - centX = centerX->getValue(); - centY = centerY->getValue(); - updateGeometry(centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - listener->panelChanged(EvlocallablocY, locYT->getTextValue()); - } - - return true; - } - } else if (lastObject == 3) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage + provider->deltaImage; - rtengine::Coord centerPos = draggedCenter; - double verti = double (imH); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI); - - // if (lastObject==2) - // Dragging the upper locY bar - // currDraggedlocYOffset -= draggedlocYOffset; - // else - if (lastObject == 3) - // Dragging the lower locY bar - { - currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; - } - - currDraggedlocYOffset = currDraggedlocYOffset * 2000. / verti; - - if (int (currDraggedlocYOffset) != locY->getIntValue()) { - - locY->setValue((int (currDraggedlocYOffset))); - double centX, centY; - centX = centerX->getValue(); - centY = centerY->getValue(); - - updateGeometry(centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - listener->panelChanged(EvlocallablocY, locY->getTextValue()); - } - - return true; - } - } - - } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - if (lastObject == 2 || lastObject == 3) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage + provider->deltaImage; - rtengine::Coord centerPos = draggedCenter; - double verti = double (imH); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI); - - if (lastObject == 2) - // Dragging the upper locY bar - { - currDraggedlocYOffset -= draggedlocYOffset; - } else if (lastObject == 3) - // Dragging the lower locY bar - { - currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; - } - - currDraggedlocYOffset = currDraggedlocYOffset * 2000. / verti; - - if (int (currDraggedlocYOffset) != locY->getIntValue()) { - locY->setValue((int (currDraggedlocYOffset))); - //Smethod->get_active_row_number()==2 - double centX, centY; - centX = centerX->getValue(); - centY = centerY->getValue(); - - updateGeometry(centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - listener->panelChanged(EvlocallablocY, locY->getTextValue()); - } - - // else listener->panelChanged (EvlocallablocY, locX->getTextValue()); - - } - - return true; - } - } - - } - - if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { - //else if (lastObject==0) { - if (lastObject == 0) {// >=4 - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage + provider->deltaImage; - rtengine::Coord centerPos = draggedCenter; - double horiz = double (imW); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue() + 90.) / 180.*rtengine::RT_PI); - - if (lastObject == 0) //>=4 - // Dragging the upper locY bar - { - currDraggedStrOffset -= draggedlocXOffset; - } else if (lastObject == 1) - // Dragging the lower locY bar - { - currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset; //- - } - - currDraggedStrOffset = currDraggedStrOffset * 2000. / horiz; - - if (int (currDraggedStrOffset) != locX->getIntValue()) { - locX->setValue((int (currDraggedStrOffset))); - double centX, centY; - centX = centerX->getValue(); - centY = centerY->getValue(); - updateGeometry(centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - listener->panelChanged(EvlocallablocX, locX->getTextValue()); - } - - return true; - } - } else if (lastObject == 1) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage + provider->deltaImage; - rtengine::Coord centerPos = draggedCenter; - double horiz = double (imW); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - //draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue() + 90.) / 180.*rtengine::RT_PI); - - if (lastObject == 0) - // Dragging the upper locY bar - { - currDraggedStrOffset -= draggedlocXOffset; - } else if (lastObject == 1) - // Dragging the lower locY bar - { - currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset; //- - } - - currDraggedStrOffset = currDraggedStrOffset * 2000. / horiz; - - if (int (currDraggedStrOffset) != locXL->getIntValue()) { - locXL->setValue((int (currDraggedStrOffset))); - double centX, centY; - centX = centerX->getValue(); - centY = centerY->getValue(); - updateGeometry(centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - listener->panelChanged(EvlocallablocX, locX->getTextValue()); - } - - return true; - } - } - - } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - if (lastObject == 0 || lastObject == 1) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - rtengine::Coord currPos; - currPos = provider->posImage + provider->deltaImage; - rtengine::Coord centerPos = draggedCenter; - double horiz = double (imW); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint = currPos - centerPos; - - // draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue() + 90.) / 180.*rtengine::RT_PI); - - if (lastObject == 0) - // Dragging the upper locY bar - { - currDraggedStrOffset -= draggedlocXOffset; - } else if (lastObject == 1) - // Dragging the lower locY bar - { - currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset; //- - } - - currDraggedStrOffset = currDraggedStrOffset * 2000. / horiz; - - if (int (currDraggedStrOffset) != locX->getIntValue()) { - locX->setValue((int (currDraggedStrOffset))); - double centX, centY; - centX = centerX->getValue(); - centY = centerY->getValue(); - updateGeometry(centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - listener->panelChanged(EvlocallablocX, locX->getTextValue()); - } - - return true; - } - } - } - - /* else if(Smethod->get_active_row_number()==2) { - if (lastObject==0 || lastObject==1 || lastObject==2 || lastObject==3) { - if (lastObject==2 || lastObject==3) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - Coord currPos; - currPos = provider->posImage+provider->deltaImage; - Coord centerPos = draggedCenter; - double verti = double(imH); - // trick to get the correct angle (clockwise/counter-clockwise) - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue())/180.*M_PI); - double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue() +90.)/180.*M_PI); - - if (lastObject==2) - currDraggedlocYOffset -= draggedlocYOffset; - else if (lastObject==3) - currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; - currDraggedlocYOffset = currDraggedlocYOffset * 200. / verti; - // if (int(currDraggedlocYOffset) != locY->getIntValue()) { - // locY->setValue((int(currDraggedlocYOffset))); - if (int(currDraggedlocYOffset) != locX->getIntValue()) {//locX - // if (int(currDraggedStrOffset) != locX->getIntValue()) {//locX - locX->setValue((int(currDraggedlocYOffset))); - double centX,centY; - centX=centerX->getValue(); - centY=centerY->getValue(); - - // updateGeometry (centX, centY, locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - updateGeometry (centX, centY, locX->getValue(), degree->getValue(), locX->getValue(), locX->getValue(), locX->getValue()); - if (listener) { - if(Smethod->get_active_row_number()==1) listener->panelChanged (EvlocallablocY, locY->getTextValue()); - - } - return true; - } - } - if (lastObject==0 || lastObject==1) { - // Dragging the upper or lower locY bar - PolarCoord draggedPoint; - Coord currPos; - currPos = provider->posImage+provider->deltaImage; - Coord centerPos = draggedCenter; - double horiz = double(imW); - int p = centerPos.y; - centerPos.y = currPos.y; - currPos.y = p; - draggedPoint.setFromCartesian(centerPos, currPos); - double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue() +90.)/180.*M_PI); - if (lastObject==0) - currDraggedStrOffset -= draggedlocXOffset; - else if (lastObject==1) - currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset;//- - currDraggedStrOffset = currDraggedStrOffset * 200. / horiz; - - if (int(currDraggedStrOffset) != locX->getIntValue()) { - locX->setValue((int(currDraggedStrOffset))); - double centX,centY; - centX=centerX->getValue(); - centY=centerY->getValue(); - updateGeometry (centX, centY, locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(),locXL->getValue()); - if (listener) - listener->panelChanged (EvlocallablocX, locX->getTextValue()); - return true; - } - } - - - } - } - */ - //else if (lastObject==4) { - if (lastObject == 4) { - - // Dragging the circle to change the center - rtengine::Coord currPos; - draggedCenter += provider->deltaPrevImage; - currPos = draggedCenter; - currPos.clip(imW, imH); - int newCenterX = int ((double (currPos.x) - halfSizeW) / halfSizeW * 1000.); - int newCenterY = int ((double (currPos.y) - halfSizeH) / halfSizeH * 1000.); - - if (newCenterX != centerX->getIntValue() || newCenterY != centerY->getIntValue()) { - centerX->setValue(newCenterX); - centerY->setValue(newCenterY); - updateGeometry(newCenterX, newCenterY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); - - if (listener) { - listener->panelChanged(EvlocallabCenter, Glib::ustring::compose("X=%1\nY=%2", centerX->getTextValue(), centerY->getTextValue())); - } - - return true; - } - } - - return false; -} - -void Locallab::switchOffEditMode() -{ - if (edit->get_active()) { - // switching off the toggle button - bool wasBlocked = editConn.block(true); - edit->set_active(false); - - if (!wasBlocked) { - editConn.block(false); - } - } - - EditSubscriber::switchOffEditMode(); // disconnect -} - diff --git a/rtgui/locallab.h b/rtgui/locallab.h index f5aef8116..8d7477201 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -24,14 +24,12 @@ class Locallab : public FoldableToolPanel, public rtengine::localListener, public CurveListener, - public EditSubscriber, public ColorProvider, public ThresholdCurveProvider, public ThresholdAdjusterListener { private: - rtengine::ProcEvent EvLocenacolor;//548 rtengine::ProcEvent EvLocenaexpose;//572 rtengine::ProcEvent EvLocenavibrance;//563 @@ -140,7 +138,8 @@ private: rtengine::ProcEvent Evlocallabbilateral;// = 598, rtengine::ProcEvent Evlocallabnoiselequal;// = 599, rtengine::ProcEvent Evlocallabshapemethod;// = 600, - rtengine::ProcEvent Evlocallabspotduplicated; + rtengine::ProcEvent Evlocallabspotduplicated;// = 601 + rtengine::ProcEvent Evlocallabspotcreated;// = 602 IdleRegister idle_register; @@ -159,33 +158,14 @@ private: MyExpander* const expsharp; MyExpander* const expcbdl; MyExpander* const expdenoi; - MyExpander* const expsettings; + ControlSpotPanel* const expsettings; CurveEditorGroup* const LocalcurveEditorgainT; CurveEditorGroup* const LocalcurveEditorgainTrab; CurveEditorGroup* const llCurveEditorG; - ControlSpotPanel *spotPanel; - Gtk::HBox *editHBox; - Gtk::ToggleButton* edit; - - Adjuster* nbspot; Adjuster* multiplier[5]; - Adjuster* const anbspot; - Adjuster* const locX; - Adjuster* const locXL; - Adjuster* const degree; - Adjuster* const locY; - Adjuster* const locYT; - Adjuster* const centerX; - Adjuster* const centerY; - Adjuster* const circrad; - Adjuster* const sensiexclu; - Adjuster* const struc; - - Adjuster* const thres; - Adjuster* const proxi; Adjuster* const lightness; Adjuster* const contrast; Adjuster* const chroma; @@ -196,16 +176,10 @@ private: Adjuster* const hlcomprthresh; Adjuster* const black; Adjuster* const shcompr; - /* - Adjuster* const lightnessex; - Adjuster* const contrastex; - Adjuster* const chromaex; - */ Adjuster* const sensiex; Adjuster* const radius; Adjuster* const strength; Adjuster* const sensibn; - Adjuster* const transit; Adjuster* const stren; Adjuster* const gamma; Adjuster* const estop; @@ -237,38 +211,24 @@ private: Adjuster* const sobelref; Adjuster* const centerXbuf; Adjuster* const centerYbuf; -// Adjuster* const adjblur; - MyComboBoxText* const shapemethod; - MyComboBoxText* const Smethod; - MyComboBoxText* const Exclumethod; MyComboBoxText* const retinexMethod; - MyComboBoxText* const qualityMethod; MyComboBoxText* const qualitycurveMethod; MyComboBoxText* const blurMethod; MyComboBoxText* const dustMethod; - Gtk::Frame* const excluFrame; - - Gtk::Frame* const artifFrame; Gtk::Frame* const shapeFrame; Gtk::Frame* const superFrame; Gtk::Frame* const dustFrame; Gtk::Frame* const wavFrame; Gtk::Label* const labmdh; - Gtk::Label* const labqual; Gtk::Label* const labqualcurv; Gtk::Label* const labmS; Gtk::Label* const labmEx; Gtk::Label* const labmshape; - Gtk::HBox* const ctboxS; - Gtk::HBox* const ctboxshape; - Gtk::HBox* const ctboxEx; - Gtk::HBox* const dhbox; - Gtk::HBox* const qualbox; Gtk::HBox* const qualcurvbox; Gtk::CheckButton* const avoid; @@ -281,7 +241,6 @@ private: Gtk::CheckButton* const cutpast; Gtk::CheckButton* const lastdust; - Gtk::CheckButton* spotduplicated; Gtk::Label* labspotdup; Gtk::Button* neutral; @@ -328,25 +287,20 @@ private: sigc::connection ashiftconn; sigc::connection pastsattogconn; - - sigc::connection lumaneutralPressedConn; sigc::connection lumacontrastPlusPressedConn; sigc::connection lumacontrastMinusPressedConn; sigc::connection enablecolorConn, enableexposeConn, enablevibranceConn, enableblurConn, enabletonemapConn; sigc::connection enableretiConn, enablesharpConn, enablecbdlConn; sigc::connection enabledenoiConn; - sigc::connection editConn, avoidConn, inversConn, cutpastConn, lastdustConn, curvactivConn, activlumConn, inversradConn, inversretConn, inversshaConn, neutralconn, neutralconn1; - sigc::connection Smethodconn, shapemethodconn, Exclumethodconn, spotduplicatedConn; + sigc::connection avoidConn, inversConn, cutpastConn, lastdustConn, curvactivConn, activlumConn, inversradConn, inversretConn, inversshaConn, neutralconn, neutralconn1; sigc::connection retinexMethodConn; - sigc::connection qualityMethodConn; sigc::connection qualitycurveMethodConn; sigc::connection blurMethodConn; sigc::connection dustMethodConn; bool lastspotduplicated; - int nextdatasp[102]; int nextlength; bool nextspotdup; @@ -367,18 +321,32 @@ private: std::string nextex_str; std::string nextex_str2; - double draggedPointOldAngle; - double draggedPointAdjusterAngle; - double draggedFeatherOffset; - double draggedlocYOffset; - double draggedlocXOffset; - double draggedlocYTOffset; - double draggedlocXLOffset; - rtengine::Coord draggedCenter; bool lastavoid, lastinvers, lastcutpast, lastlastdust, lastinversrad, lastinversret, lastactivlum, lastinverssha, lastcurvactiv; int lastanbspot; - void editToggled(); + // To be deleted + Adjuster* const locX; + Adjuster* const locXL; + Adjuster* const degree; + Adjuster* const locY; + Adjuster* const locYT; + Adjuster* const centerX; + Adjuster* const centerY; + Adjuster* const circrad; + Adjuster* const sensiexclu; + Adjuster* const struc; + Adjuster* nbspot; + MyComboBoxText* const shapemethod; + MyComboBoxText* const Smethod; + MyComboBoxText* const Exclumethod; + Gtk::CheckButton* spotduplicated; + Adjuster* const thres; + Adjuster* const proxi; + Adjuster* const transit; + MyComboBoxText* const qualityMethod; + + // To be deleted ?? + Adjuster* const anbspot; public: @@ -391,10 +359,9 @@ public: void setBatchMode(bool batchMode); - void updateGeometry(const int centerX_, const int centerY_, const int circrad_, const int locY_, const double degree_, const int locX_, const int locYT_, const int locXL_, const int fullWidth = -1, const int fullHeight = -1); - void SmethodChanged(); - void shapemethodChanged(); - void ExclumethodChanged(); + void SmethodChanged(); // TODO To be deleted + void shapemethodChanged(); // TODO To be deleted + void ExclumethodChanged(); // TODO To be deleted void writeOptions(std::vector &tpOpen); void updateToolState(std::vector &tpOpen); @@ -424,10 +391,12 @@ public: bool localComputed_(); bool localretComputed_(); void setEditProvider(EditDataProvider* provider); + void subscribe(); + void unsubscribe(); void retinexMethodChanged(); void blurMethodChanged(); void dustMethodChanged(); - void qualityMethodChanged(); + void qualityMethodChanged(); // TODO To be deleted void qualitycurveMethodChanged(); void lumaneutralPressed(); void lumacontrastPlusPressed(); @@ -439,12 +408,6 @@ public: void pastsattog_toggled(); std::vector getCurvePoints(ThresholdSelector* tAdjuster) const; - // EditSubscriber interface - CursorShape getCursor(int objectID); - bool mouseOver(int modifierKey); - bool button1Pressed(int modifierKey); - bool button1Released(); - bool drag1(int modifierKey); - void switchOffEditMode(); + void setListener(ToolPanelListener* tpl); }; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 0cf024234..a8a7b9c7f 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -325,6 +325,27 @@ void ParamsEdited::set(bool v) gradient.centerX = v; gradient.centerY = v; locallab.enabled = v; + locallab.nbspot = v; + locallab.selspot = v; + locallab.id = v; + locallab.name = v; + locallab.isvisible = v; + locallab.shape = v; + locallab.spotMethod = v; + locallab.shapeMethod = v; + locallab.locX = v; + locallab.locXL = v; + locallab.locY = v; + locallab.locYT = v; + locallab.centerX = v; + locallab.centerY = v; + locallab.circrad = v; + locallab.qualityMethod = v; + locallab.transit = v; + locallab.thresh = v; + locallab.iter = v; + + /* locallab.expcolor = v; locallab.expexpose = v; locallab.expvibrance = v; @@ -439,7 +460,10 @@ void ParamsEdited::set(bool v) locallab.skintonescurve = v; locallab.sensiv = v; locallab.spotduplicated = v; - + locallab.id = v; + locallab.name = v; + locallab.isvisible = v; + */ pcvignette.enabled = v; pcvignette.strength = v; @@ -994,7 +1018,30 @@ void ParamsEdited::initFrom(const std::vector& gradient.strength = gradient.strength && p.gradient.strength == other.gradient.strength; gradient.centerX = gradient.centerX && p.gradient.centerX == other.gradient.centerX; gradient.centerY = gradient.centerY && p.gradient.centerY == other.gradient.centerY; + locallab.enabled = locallab.enabled && p.locallab.enabled == other.locallab.enabled; + locallab.nbspot = locallab.nbspot && p.locallab.nbspot == other.locallab.nbspot; + locallab.selspot = locallab.selspot && p.locallab.selspot == other.locallab.selspot; + // Control spot settings + locallab.id = locallab.id && p.locallab.id == other.locallab.id; + locallab.name = locallab.name && p.locallab.name == other.locallab.name; + locallab.isvisible = locallab.isvisible && p.locallab.isvisible == other.locallab.isvisible; + locallab.shape = locallab.shape && p.locallab.shape == other.locallab.shape; + locallab.spotMethod = locallab.spotMethod && p.locallab.spotMethod == other.locallab.spotMethod; + locallab.shapeMethod = locallab.shapeMethod && p.locallab.shapeMethod == other.locallab.shapeMethod; + locallab.locX = locallab.locX && p.locallab.locX == other.locallab.locX; + locallab.locXL = locallab.locXL && p.locallab.locXL == other.locallab.locXL; + locallab.locY = locallab.locY && p.locallab.locY == other.locallab.locY; + locallab.locYT = locallab.locYT && p.locallab.locYT == other.locallab.locYT; + locallab.centerX = locallab.centerX && p.locallab.centerX == other.locallab.centerX; + locallab.centerY = locallab.centerY && p.locallab.centerY == other.locallab.centerY; + locallab.circrad = locallab.circrad && p.locallab.circrad == other.locallab.circrad; + locallab.qualityMethod = locallab.qualityMethod && p.locallab.qualityMethod == other.locallab.qualityMethod; + locallab.transit = locallab.transit && p.locallab.transit == other.locallab.transit; + locallab.thresh = locallab.thresh && p.locallab.thresh == other.locallab.thresh; + locallab.iter = locallab.iter && p.locallab.iter == other.locallab.iter; + + /* locallab.avoid = locallab.avoid && p.locallab.avoid == other.locallab.avoid; locallab.invers = locallab.invers && p.locallab.invers == other.locallab.invers; locallab.cutpast = locallab.cutpast && p.locallab.cutpast == other.locallab.cutpast; @@ -1109,8 +1156,8 @@ void ParamsEdited::initFrom(const std::vector& locallab.skintonescurve = locallab.skintonescurve && p.locallab.skintonescurve == other.locallab.skintonescurve; locallab.sensiv = locallab.sensiv && p.locallab.sensiv == other.locallab.sensiv; locallab.spotduplicated = locallab.spotduplicated && p.locallab.spotduplicated == other.locallab.spotduplicated; + */ - pcvignette.enabled = pcvignette.enabled && p.pcvignette.enabled == other.pcvignette.enabled; pcvignette.strength = pcvignette.strength && p.pcvignette.strength == other.pcvignette.strength; pcvignette.feather = pcvignette.feather && p.pcvignette.feather == other.pcvignette.feather; @@ -1423,7 +1470,7 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng if (toneCurve.clampOOG) { toEdit.toneCurve.clampOOG = mods.toneCurve.clampOOG; } - + if (retinex.enabled) { toEdit.retinex.enabled = mods.retinex.enabled; } @@ -1770,12 +1817,15 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng if (colorToning.labgridALow) { toEdit.colorToning.labgridALow = mods.colorToning.labgridALow; } + if (colorToning.labgridBLow) { toEdit.colorToning.labgridBLow = mods.colorToning.labgridBLow; } + if (colorToning.labgridAHigh) { toEdit.colorToning.labgridAHigh = mods.colorToning.labgridAHigh; } + if (colorToning.labgridBHigh) { toEdit.colorToning.labgridBHigh = mods.colorToning.labgridBHigh; } @@ -2301,7 +2351,8 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng if (fattal.amount) { toEdit.fattal.amount = mods.fattal.amount; - } + } + if (fattal.anchor) { toEdit.fattal.anchor = mods.fattal.anchor; } @@ -2458,6 +2509,84 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.enabled = mods.locallab.enabled; } + if (locallab.nbspot) { + toEdit.locallab.nbspot = mods.locallab.nbspot; + } + + if (locallab.selspot) { + toEdit.locallab.selspot = mods.locallab.selspot; + } + + // Control spot settings + if (locallab.id) { + toEdit.locallab.id = mods.locallab.id; + } + + if (locallab.name) { + toEdit.locallab.name = mods.locallab.name; + } + + if (locallab.isvisible) { + toEdit.locallab.isvisible = mods.locallab.isvisible; + } + + if (locallab.shape) { + toEdit.locallab.shape = mods.locallab.shape; + } + + if (locallab.spotMethod) { + toEdit.locallab.spotMethod = mods.locallab.spotMethod; + } + + if (locallab.shapeMethod) { + toEdit.locallab.shapeMethod = mods.locallab.shapeMethod; + } + + if (locallab.locX) { + toEdit.locallab.locX = mods.locallab.locX; + } + + if (locallab.locXL) { + toEdit.locallab.locXL = mods.locallab.locXL; + } + + if (locallab.locY) { + toEdit.locallab.locY = mods.locallab.locY; + } + + if (locallab.locYT) { + toEdit.locallab.locYT = mods.locallab.locYT; + } + + if (locallab.centerX) { + toEdit.locallab.centerX = mods.locallab.centerX; + } + + if (locallab.centerY) { + toEdit.locallab.centerY = mods.locallab.centerY; + } + + if (locallab.circrad) { + toEdit.locallab.circrad = mods.locallab.circrad; + } + + if (locallab.qualityMethod) { + toEdit.locallab.qualityMethod = mods.locallab.qualityMethod; + } + + if (locallab.transit) { + toEdit.locallab.transit = mods.locallab.transit; + } + + if (locallab.thresh) { + toEdit.locallab.thresh = mods.locallab.thresh; + } + + if (locallab.iter) { + toEdit.locallab.iter = mods.locallab.iter; + } + + /* if (locallab.expcolor) { toEdit.locallab.expcolor = mods.locallab.expcolor; } @@ -2685,7 +2814,7 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng if (locallab.spotduplicated) { toEdit.locallab.spotduplicated = mods.locallab.spotduplicated; } - + if (locallab.sensiex) { toEdit.locallab.sensiex = mods.locallab.sensiex; } @@ -2895,6 +3024,7 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng if (locallab.chromacbdl) { toEdit.locallab.chromacbdl = mods.locallab.chromacbdl; } + */ if (pcvignette.enabled) { toEdit.pcvignette.enabled = mods.pcvignette.enabled; @@ -3249,7 +3379,7 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng if (raw.bayersensor.linenoiseDirection) { toEdit.raw.bayersensor.linenoiseDirection = mods.raw.bayersensor.linenoiseDirection; } - + if (raw.bayersensor.pdafLinesFilter) { toEdit.raw.bayersensor.pdafLinesFilter = mods.raw.bayersensor.pdafLinesFilter; } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 4c5e8dacc..4673a0257 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -455,9 +455,31 @@ public: }; class LocallabParamsEdited { - +// TODO To be manage by vector public: bool enabled; + bool nbspot; + bool selspot; + // Control spot settings + bool id; + bool name; + bool isvisible; + bool shape; + bool spotMethod; + bool shapeMethod; + bool locX; + bool locXL; + bool locY; + bool locYT; + bool centerX; + bool centerY; + bool circrad; + bool qualityMethod; + bool transit; + bool thresh; + bool iter; + + /* bool degree; bool locY; bool locX; @@ -567,7 +589,11 @@ public: bool pastsattog; bool skintonescurve; bool sensiv; - bool spotduplicated; + bool spotduplicated; + bool id; + bool name; + bool isvisible; + */ }; @@ -913,7 +939,8 @@ public: }; -class MetaDataParamsEdited { +class MetaDataParamsEdited +{ public: bool mode; }; diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index 1fb34ca0a..ea908835c 100644 --- a/rtgui/ppversion.h +++ b/rtgui/ppversion.h @@ -1,11 +1,13 @@ #pragma once // This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes -#define PPVERSION 336 +#define PPVERSION 337 #define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified /* Log of version changes + 337 2018-07-26 + Added Locallab tool parameters 336 2018-06-01 new demosaic method combobox for pixelshift 335 2018-05-30 diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 32e500582..9e5ac3d19 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -28,7 +28,7 @@ using namespace rtengine::procparams; -ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChanged(false), editDataProvider(nullptr) +ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChanged(false), editDataProvider(nullptr), photoLoadedOnce(false) { exposurePanel = Gtk::manage(new ToolVBox()); @@ -36,7 +36,7 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange colorPanel = Gtk::manage(new ToolVBox()); transformPanel = Gtk::manage(new ToolVBox()); rawPanel = Gtk::manage(new ToolVBox()); - advancedPanel = Gtk::manage (new ToolVBox ()); + advancedPanel = Gtk::manage(new ToolVBox()); locallabPanel = Gtk::manage(new ToolVBox()); coarse = Gtk::manage(new CoarsePanel()); @@ -107,7 +107,7 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange addPanel(colorPanel, blackwhite); addPanel(exposurePanel, shadowshighlights); addPanel(detailsPanel, sharpening); - addPanel (detailsPanel, localContrast); + addPanel(detailsPanel, localContrast); addPanel(detailsPanel, sharpenEdge); addPanel(detailsPanel, sharpenMicro); addPanel(colorPanel, hsvequalizer); @@ -116,16 +116,16 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange addPanel(colorPanel, colortoning); addPanel(exposurePanel, epd); addPanel(exposurePanel, fattal); - addPanel (advancedPanel, retinex); + addPanel(advancedPanel, retinex); addPanel(exposurePanel, pcvignette); addPanel(exposurePanel, gradient); addPanel(exposurePanel, lcurve); - addPanel (advancedPanel, colorappearance); + addPanel(advancedPanel, colorappearance); addPanel(detailsPanel, impulsedenoise); addPanel(detailsPanel, dirpyrdenoise); addPanel(detailsPanel, defringe); addPanel(detailsPanel, dirpyrequalizer); - addPanel (advancedPanel, wavelet); + addPanel(advancedPanel, wavelet); addPanel(locallabPanel, locallab); addPanel(transformPanel, crop); addPanel(transformPanel, resize); @@ -166,7 +166,7 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange colorPanelSW = Gtk::manage(new MyScrolledWindow()); transformPanelSW = Gtk::manage(new MyScrolledWindow()); rawPanelSW = Gtk::manage(new MyScrolledWindow()); - advancedPanelSW = Gtk::manage (new MyScrolledWindow ()); + advancedPanelSW = Gtk::manage(new MyScrolledWindow()); locallabPanelSW = Gtk::manage(new MyScrolledWindow()); updateVScrollbars(options.hideTPVScrollbar); @@ -191,9 +191,9 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange colorPanel->pack_start(*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); colorPanel->pack_start(*vbPanelEnd[2], Gtk::PACK_SHRINK, 4); - advancedPanelSW->add (*advancedPanel); - advancedPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); - advancedPanel->pack_start (*vbPanelEnd[5], Gtk::PACK_SHRINK, 0); + advancedPanelSW->add(*advancedPanel); + advancedPanel->pack_start(*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + advancedPanel->pack_start(*vbPanelEnd[5], Gtk::PACK_SHRINK, 0); locallabPanelSW->add(*locallabPanel); locallabPanel->pack_start(*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); @@ -213,7 +213,7 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange 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 ("atom.png", M ("MAIN_TAB_ADVANCED"), M ("MAIN_TAB_ADVANCED_TOOLTIP"), type)); + toiW = Gtk::manage(new TextOrIcon("atom.png", M("MAIN_TAB_ADVANCED"), M("MAIN_TAB_ADVANCED_TOOLTIP"), type)); toiL = Gtk::manage(new TextOrIcon("openhand.png", M("MAIN_TAB_LOCALLAB"), M("MAIN_TAB_LOCALLAB_TOOLTIP"), type)); toiT = Gtk::manage(new TextOrIcon("transform.png", M("MAIN_TAB_TRANSFORM"), M("MAIN_TAB_TRANSFORM_TOOLTIP"), type)); @@ -223,7 +223,7 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange toolPanelNotebook->append_page(*exposurePanelSW, *toiE); toolPanelNotebook->append_page(*detailsPanelSW, *toiD); toolPanelNotebook->append_page(*colorPanelSW, *toiC); - toolPanelNotebook->append_page (*advancedPanelSW, *toiW); + toolPanelNotebook->append_page(*advancedPanelSW, *toiW); toolPanelNotebook->append_page(*locallabPanelSW, *toiL); toolPanelNotebook->append_page(*transformPanelSW, *toiT); toolPanelNotebook->append_page(*rawPanelSW, *toiR); @@ -234,6 +234,9 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange toolPanelNotebook->set_scrollable(); toolPanelNotebook->show_all(); + notebookconn = toolPanelNotebook->signal_switch_page().connect( + sigc::mem_fun(*this, &ToolPanelCoordinator::notebookPageChanged)); + for (auto toolPanel : toolPanels) { toolPanel->setListener(this); } @@ -252,6 +255,19 @@ ToolPanelCoordinator::ToolPanelCoordinator(bool batch) : ipc(nullptr), hasChange toolBar->setToolBarListener(this); } +void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num) +{ + // Locallab spot curves are set visible if at least one photo has been loaded (to avoid + // segfault) and locallab panel is active + if (photoLoadedOnce) { + if (page == locallabPanelSW) { + locallab->subscribe(); + } else { + locallab->unsubscribe(); + } + } +} + void ToolPanelCoordinator::addPanel(Gtk::Box* where, FoldableToolPanel* panel, int level) { @@ -269,18 +285,22 @@ ToolPanelCoordinator::~ToolPanelCoordinator() closeImage(); + // When deleting toolPanelNotebook, pages removal activates notebookPageChanged function + // which is responsible of segfault if listener isn't deactivated before + notebookconn.block(true); + delete toolPanelNotebook; delete toolBar; } -void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXtrans, bool isMono) +void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtrans, bool isMono) { if (isRaw) { if (isBayer) { const auto func = [](gpointer data) -> gboolean { ToolPanelCoordinator* const self = static_cast(data); - self->rawPanelSW->set_sensitive (true); + self->rawPanelSW->set_sensitive(true); self->sensorxtrans->FoldableToolPanel::hide(); self->sensorbayer->FoldableToolPanel::show(); self->preprocess->FoldableToolPanel::show(); @@ -289,12 +309,11 @@ void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXt return FALSE; }; idle_register.add(func, this); - } - else if (isXtrans) { + } else if (isXtrans) { const auto func = [](gpointer data) -> gboolean { ToolPanelCoordinator* const self = static_cast(data); - self->rawPanelSW->set_sensitive (true); + self->rawPanelSW->set_sensitive(true); self->sensorxtrans->FoldableToolPanel::show(); self->sensorbayer->FoldableToolPanel::hide(); self->preprocess->FoldableToolPanel::show(); @@ -303,12 +322,11 @@ void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXt return FALSE; }; idle_register.add(func, this); - } - else if (isMono) { + } else if (isMono) { const auto func = [](gpointer data) -> gboolean { ToolPanelCoordinator* const self = static_cast(data); - self->rawPanelSW->set_sensitive (true); + self->rawPanelSW->set_sensitive(true); self->sensorbayer->FoldableToolPanel::hide(); self->sensorxtrans->FoldableToolPanel::hide(); self->preprocess->FoldableToolPanel::hide(); @@ -321,7 +339,7 @@ void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXt const auto func = [](gpointer data) -> gboolean { ToolPanelCoordinator* const self = static_cast(data); - self->rawPanelSW->set_sensitive (true); + self->rawPanelSW->set_sensitive(true); self->sensorbayer->FoldableToolPanel::hide(); self->sensorxtrans->FoldableToolPanel::hide(); self->preprocess->FoldableToolPanel::hide(); @@ -335,7 +353,7 @@ void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXt const auto func = [](gpointer data) -> gboolean { ToolPanelCoordinator* const self = static_cast(data); - self->rawPanelSW->set_sensitive (false); + self->rawPanelSW->set_sensitive(false); return FALSE; }; @@ -347,6 +365,9 @@ void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXt void ToolPanelCoordinator::panelChanged(rtengine::ProcEvent event, const Glib::ustring& descr) { + // TODO Locallab printf + printf("panelChanged\n"); + printf("panelChanged event: %d\n", (int)event); if (!ipc) { return; @@ -385,7 +406,6 @@ void ToolPanelCoordinator::panelChanged(rtengine::ProcEvent event, const Glib::u int fw, fh; ipc->getInitialImage()->getImageSource()->getFullSize(fw, fh, tr); gradient->updateGeometry(params->gradient.centerX, params->gradient.centerY, params->gradient.feather, params->gradient.degree, fw, fh); - locallab->updateGeometry(params->locallab.centerX, params->locallab.centerY, params->locallab.circrad, params->locallab.locY, params->locallab.degree, params->locallab.locX, params->locallab.locYT, params->locallab.locXL, fw, fh); } // some transformations make the crop change for convenience @@ -412,10 +432,33 @@ void ToolPanelCoordinator::panelChanged(rtengine::ProcEvent event, const Glib::u for (auto paramcListener : paramcListeners) { paramcListener->procParamsChanged(params, event, descr); } + + // Locallab spot curves are set visible if at least one photo has been loaded (to avoid + // segfault) and locallab panel is active + // When a new photo is loaded, Locallab spot curves need to be set visible again + const auto func = [](gpointer data) -> gboolean { + ToolPanelCoordinator* const self = static_cast(data); + + if (self->photoLoadedOnce && (self->toolPanelNotebook->get_nth_page(self->toolPanelNotebook->get_current_page()) == self->locallabPanelSW)) + { + self->locallab->subscribe(); + } + + return FALSE; + }; + + if (event == rtengine::EvPhotoLoaded) { + idle_register.add(func, this); + } + + photoLoadedOnce = true; } void ToolPanelCoordinator::profileChange(const PartialProfile *nparams, rtengine::ProcEvent event, const Glib::ustring& descr, const ParamsEdited* paramsEdited) { + // TODO Locallab printf + printf("profileChanged\n"); + printf("profileChanged event: %d\n", (int)event); int fw, fh, tr; @@ -480,8 +523,6 @@ void ToolPanelCoordinator::profileChange(const PartialProfile *nparams, rtengine if (event == rtengine::EvPhotoLoaded || event == rtengine::EvProfileChanged || event == rtengine::EvHistoryBrowsed || event == rtengine::EvCTRotate) { // updating the "on preview" geometry gradient->updateGeometry(params->gradient.centerX, params->gradient.centerY, params->gradient.feather, params->gradient.degree, fw, fh); - locallab->updateGeometry(params->locallab.centerX, params->locallab.centerY, params->locallab.circrad, params->locallab.locY, params->locallab.degree, params->locallab.locX, params->locallab.locYT, params->locallab.locXL, fw, fh); - } // start the IPC processing @@ -496,6 +537,26 @@ void ToolPanelCoordinator::profileChange(const PartialProfile *nparams, rtengine for (auto paramcListener : paramcListeners) { paramcListener->procParamsChanged(params, event, descr); } + + // Locallab spot curves are set visible if at least one photo has been loaded (to avoid + // segfault) and locallab panel is active + // When a new photo is loaded, Locallab spot curves need to be set visible again + const auto func = [](gpointer data) -> gboolean { + ToolPanelCoordinator* const self = static_cast(data); + + if (self->photoLoadedOnce && (self->toolPanelNotebook->get_nth_page(self->toolPanelNotebook->get_current_page()) == self->locallabPanelSW)) + { + self->locallab->subscribe(); + } + + return FALSE; + }; + + if (event == rtengine::EvPhotoLoaded) { + idle_register.add(func, this); + } + + photoLoadedOnce = true; } void ToolPanelCoordinator::setDefaults(ProcParams* defparams) @@ -685,9 +746,10 @@ void ToolPanelCoordinator::sharpMaskSelected(bool sharpMask) if (!ipc) { return; } - ipc->beginUpdateParams (); + + ipc->beginUpdateParams(); ipc->setSharpMask(sharpMask); - ipc->endUpdateParams (rtengine::EvShrEnabled); + ipc->endUpdateParams(rtengine::EvShrEnabled); } @@ -876,7 +938,7 @@ bool ToolPanelCoordinator::handleShortcutKey(GdkEventKey* event) return true; case GDK_KEY_w: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*advancedPanelSW)); + toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*advancedPanelSW)); return true; case GDK_KEY_o: @@ -901,7 +963,7 @@ void ToolPanelCoordinator::updateVScrollbars(bool hide) colorPanelSW->set_policy(Gtk::POLICY_AUTOMATIC, policy); transformPanelSW->set_policy(Gtk::POLICY_AUTOMATIC, policy); rawPanelSW->set_policy(Gtk::POLICY_AUTOMATIC, policy); - advancedPanelSW->set_policy (Gtk::POLICY_AUTOMATIC, policy); + advancedPanelSW->set_policy(Gtk::POLICY_AUTOMATIC, policy); locallabPanelSW->set_policy(Gtk::POLICY_AUTOMATIC, policy); for (auto currExp : expList) { diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index c046c67ee..cc56fed4d 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -194,10 +194,13 @@ protected: void foldThemAll(GdkEventButton* event); void updateVScrollbars(bool hide); void updateTabsHeader(bool useIcons); + void notebookPageChanged(Gtk::Widget* page, guint page_num); private: EditDataProvider *editDataProvider; + sigc::connection notebookconn; + bool photoLoadedOnce; // Used to indicated that a photo has been loaded yet public: @@ -223,7 +226,7 @@ public: // toolpanellistener interface void panelChanged(rtengine::ProcEvent event, const Glib::ustring& descr); - void imageTypeChanged (bool isRaw, bool isBayer, bool isXtrans, bool isMono = false); + void imageTypeChanged(bool isRaw, bool isBayer, bool isXtrans, bool isMono = false); // 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); @@ -285,7 +288,7 @@ public: // imageareatoollistener interface void spotWBselected(int x, int y, Thumbnail* thm = nullptr); - void sharpMaskSelected (bool sharpMask); + void sharpMaskSelected(bool sharpMask); void cropSelectionReady(); void rotateSelectionReady(double rotate_deg, Thumbnail* thm = nullptr); ToolBar* getToolBar() @@ -306,7 +309,7 @@ public: void toolSelected(ToolMode tool); void editModeSwitchedOff(); - void setEditProvider (EditDataProvider *provider); + void setEditProvider(EditDataProvider *provider); private: IdleRegister idle_register;