From 192c9b118f4bbb9a36c1905d914bc8b6ba4d0f27 Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Thu, 23 Apr 2020 19:38:53 +0200 Subject: [PATCH] Update storage method in .pp3 files for RT-spot points RT-spot points are now stored as integer vector (instead of four dedicated integer) to allow future improvements. --- rtengine/improccoordinator.cc | 8 +++--- rtengine/iplocallab.cc | 8 +++--- rtengine/procparams.cc | 30 ++++++++++------------ rtengine/procparams.h | 5 +--- rtgui/controlspotpanel.cc | 8 +++--- rtgui/locallab.cc | 48 +++++++++++++++++------------------ rtgui/paramsedited.cc | 31 ++++------------------ rtgui/paramsedited.h | 5 +--- 8 files changed, 57 insertions(+), 86 deletions(-) diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 8ef72e2cb..db7f33290 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -834,10 +834,10 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) sourceg[sp] = params->locallab.spots.at(sp).sourceGray; Autogr[sp] = params->locallab.spots.at(sp).Autogray; targetg[sp] = params->locallab.spots.at(sp).targetGray; - locx[sp] = params->locallab.spots.at(sp).locX / 2000.0; - locy[sp] = params->locallab.spots.at(sp).locY / 2000.0; - locxL[sp] = params->locallab.spots.at(sp).locXL / 2000.0; - locyT[sp] = params->locallab.spots.at(sp).locYT / 2000.0; + locx[sp] = params->locallab.spots.at(sp).loc.at(0) / 2000.0; + locy[sp] = params->locallab.spots.at(sp).loc.at(2) / 2000.0; + locxL[sp] = params->locallab.spots.at(sp).loc.at(1) / 2000.0; + locyT[sp] = params->locallab.spots.at(sp).loc.at(3) / 2000.0; centx[sp] = params->locallab.spots.at(sp).centerX / 2000.0 + 0.5; centy[sp] = params->locallab.spots.at(sp).centerY / 2000.0 + 0.5; diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 4e2e77eba..392fca0e6 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -553,10 +553,10 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall thre = 2.f; } - double local_x = locallab.spots.at(sp).locX / 2000.0; - double local_y = locallab.spots.at(sp).locY / 2000.0; - double local_xL = locallab.spots.at(sp).locXL / 2000.0; - double local_yT = locallab.spots.at(sp).locYT / 2000.0; + double local_x = locallab.spots.at(sp).loc.at(0) / 2000.0; + double local_y = locallab.spots.at(sp).loc.at(2) / 2000.0; + double local_xL = locallab.spots.at(sp).loc.at(1) / 2000.0; + double local_yT = locallab.spots.at(sp).loc.at(3) / 2000.0; double local_center_x = locallab.spots.at(sp).centerX / 2000.0 + 0.5; double local_center_y = locallab.spots.at(sp).centerY / 2000.0 + 0.5; double local_center_xbuf = 0.0; // Provision diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index d215fc864..6130cc255 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -132,6 +132,16 @@ void getFromKeyfile( value = keyfile.get_string(group_name, key); } +void getFromKeyfile( + const Glib::KeyFile& keyfile, + const Glib::ustring& group_name, + const Glib::ustring& key, + std::vector& value +) +{ + value = keyfile.get_integer_list(group_name, key); +} + void getFromKeyfile( const Glib::KeyFile& keyfile, const Glib::ustring& group_name, @@ -2494,10 +2504,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : structexclu(0), struc(4.0), shapeMethod("IND"), - locX(150), - locXL(150), - locY(150), - locYT(150), + loc{150, 150, 150, 150}, centerX(0), centerY(0), circrad(18), @@ -2930,10 +2937,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && structexclu == other.structexclu && struc == other.struc && shapeMethod == other.shapeMethod - && locX == other.locX - && locXL == other.locXL - && locY == other.locY - && locYT == other.locYT + && loc == other.loc && centerX == other.centerX && centerY == other.centerY && circrad == other.circrad @@ -4369,10 +4373,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).structexclu, "Locallab", "StructExclu_" + std::to_string(i), spot.structexclu, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).struc, "Locallab", "Struc_" + std::to_string(i), spot.struc, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).shapeMethod, "Locallab", "ShapeMethod_" + std::to_string(i), spot.shapeMethod, keyFile); - saveToKeyfile(!pedited || pedited->locallab.spots.at(i).locX, "Locallab", "LocX_" + std::to_string(i), spot.locX, keyFile); - saveToKeyfile(!pedited || pedited->locallab.spots.at(i).locXL, "Locallab", "LocXL_" + std::to_string(i), spot.locXL, keyFile); - saveToKeyfile(!pedited || pedited->locallab.spots.at(i).locY, "Locallab", "LocY_" + std::to_string(i), spot.locY, keyFile); - saveToKeyfile(!pedited || pedited->locallab.spots.at(i).locYT, "Locallab", "LocYT_" + std::to_string(i), spot.locYT, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).loc, "Locallab", "Loc_" + std::to_string(i), spot.loc, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).centerX, "Locallab", "CenterX_" + std::to_string(i), spot.centerX, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).centerY, "Locallab", "CenterY_" + std::to_string(i), spot.centerY, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).circrad, "Locallab", "Circrad_" + std::to_string(i), spot.circrad, keyFile); @@ -5952,10 +5953,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "StructExclu_" + std::to_string(i), pedited, spot.structexclu, spotEdited.structexclu); assignFromKeyfile(keyFile, "Locallab", "Struc_" + std::to_string(i), pedited, spot.struc, spotEdited.struc); assignFromKeyfile(keyFile, "Locallab", "ShapeMethod_" + std::to_string(i), pedited, spot.shapeMethod, spotEdited.shapeMethod); - assignFromKeyfile(keyFile, "Locallab", "LocX_" + std::to_string(i), pedited, spot.locX, spotEdited.locX); - assignFromKeyfile(keyFile, "Locallab", "LocXL_" + std::to_string(i), pedited, spot.locXL, spotEdited.locXL); - assignFromKeyfile(keyFile, "Locallab", "LocY_" + std::to_string(i), pedited, spot.locY, spotEdited.locY); - assignFromKeyfile(keyFile, "Locallab", "LocYT_" + std::to_string(i), pedited, spot.locYT, spotEdited.locYT); + assignFromKeyfile(keyFile, "Locallab", "Loc_" + std::to_string(i), pedited, spot.loc, spotEdited.loc); assignFromKeyfile(keyFile, "Locallab", "CenterX_" + std::to_string(i), pedited, spot.centerX, spotEdited.centerX); assignFromKeyfile(keyFile, "Locallab", "CenterY_" + std::to_string(i), pedited, spot.centerY, spotEdited.centerY); assignFromKeyfile(keyFile, "Locallab", "Circrad_" + std::to_string(i), pedited, spot.circrad, spotEdited.circrad); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 6a343feaa..8909b4d15 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -970,10 +970,7 @@ struct LocallabParams { int structexclu; double struc; Glib::ustring shapeMethod; // IND, SYM, INDSL, SYMSL - int locX; - int locXL; - int locY; - int locYT; + std::vector loc; // For ellipse/rectangle: {locX, locXL, locY, locYT} int centerX; int centerY; int circrad; diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index e7edb9522..0c1d81250 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -2321,10 +2321,10 @@ void ControlSpotPanel::setDefaults(const rtengine::procparams::ProcParams * defP // Set default values for adjuster widgets sensiexclu_->setDefault((double)defSpot.sensiexclu); structexclu_->setDefault((double)defSpot.structexclu); - locX_->setDefault((double)defSpot.locX); - locXL_->setDefault((double)defSpot.locXL); - locY_->setDefault((double)defSpot.locY); - locYT_->setDefault((double)defSpot.locYT); + locX_->setDefault((double)defSpot.loc.at(0)); + locXL_->setDefault((double)defSpot.loc.at(1)); + locY_->setDefault((double)defSpot.loc.at(2)); + locYT_->setDefault((double)defSpot.loc.at(3)); centerX_->setDefault((double)defSpot.centerX); centerY_->setDefault((double)defSpot.centerY); circrad_->setDefault((double)defSpot.circrad); diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 76c787d66..625ff87ff 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -278,10 +278,10 @@ void Locallab::read(const rtengine::procparams::ProcParams* pp, const ParamsEdit r->shapeMethod = 0; } - r->locX = pp->locallab.spots.at(i).locX; - r->locXL = pp->locallab.spots.at(i).locXL; - r->locY = pp->locallab.spots.at(i).locY; - r->locYT = pp->locallab.spots.at(i).locYT; + r->locX = pp->locallab.spots.at(i).loc.at(0); + r->locXL = pp->locallab.spots.at(i).loc.at(1); + r->locY = pp->locallab.spots.at(i).loc.at(2); + r->locYT = pp->locallab.spots.at(i).loc.at(3); r->centerX = pp->locallab.spots.at(i).centerX; r->centerY = pp->locallab.spots.at(i).centerY; r->circrad = pp->locallab.spots.at(i).circrad; @@ -438,17 +438,17 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited newSpot->centerX = rtengine::LIM(int(int((double)prX - (double)imW / 2.) * 2000. / (double)imW), -1000, 1000); newSpot->centerY = rtengine::LIM(int(int((double)prY - (double)imH / 2.) * 2000. / (double)imH), -1000, 1000); // Ellipse/rectangle size computation - newSpot->locX = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->locX); - newSpot->locXL = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->locXL); - newSpot->locY = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->locY); - newSpot->locYT = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->locYT); + newSpot->loc.at(0) = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->loc.at(0)); + newSpot->loc.at(1) = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->loc.at(1)); + newSpot->loc.at(2) = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->loc.at(2)); + newSpot->loc.at(3) = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->loc.at(3)); } } - r->locX = newSpot->locX; - r->locXL = newSpot->locXL; - r->locY = newSpot->locY; - r->locYT = newSpot->locYT; + r->locX = newSpot->loc.at(0); + r->locXL = newSpot->loc.at(1); + r->locY = newSpot->loc.at(2); + r->locYT = newSpot->loc.at(3); r->centerX = newSpot->centerX; r->centerY = newSpot->centerY; @@ -722,17 +722,17 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited newSpot->centerX = rtengine::LIM(int(int((double)prX - (double)imW / 2.) * 2000. / (double)imW), -1000, 1000); newSpot->centerY = rtengine::LIM(int(int((double)prY - (double)imH / 2.) * 2000. / (double)imH), -1000, 1000); // Ellipse/rectangle size computation - newSpot->locX = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->locX); - newSpot->locXL = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->locXL); - newSpot->locY = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->locY); - newSpot->locYT = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->locYT); + newSpot->loc.at(0) = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->loc.at(0)); + newSpot->loc.at(1) = rtengine::LIM(int(((double)prW / 2. - 5.) * 2000. / (double)imW), 2, newSpot->loc.at(1)); + newSpot->loc.at(2) = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->loc.at(2)); + newSpot->loc.at(3) = rtengine::LIM(int(((double)prH / 2. - 5.) * 2000. / (double)imH), 2, newSpot->loc.at(3)); } } - r->locX = newSpot->locX; - r->locXL = newSpot->locXL; - r->locY = newSpot->locY; - r->locYT = newSpot->locYT; + r->locX = newSpot->loc.at(0); + r->locXL = newSpot->loc.at(1); + r->locY = newSpot->loc.at(2); + r->locYT = newSpot->loc.at(3); r->centerX = newSpot->centerX; r->centerY = newSpot->centerY; @@ -871,10 +871,10 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pp->locallab.spots.at(pp->locallab.selspot).shapeMethod = "SYMSL"; } - pp->locallab.spots.at(pp->locallab.selspot).locX = r->locX; - pp->locallab.spots.at(pp->locallab.selspot).locXL = r->locXL; - pp->locallab.spots.at(pp->locallab.selspot).locY = r->locY; - pp->locallab.spots.at(pp->locallab.selspot).locYT = r->locYT; + pp->locallab.spots.at(pp->locallab.selspot).loc.at(0) = r->locX; + pp->locallab.spots.at(pp->locallab.selspot).loc.at(1) = r->locXL; + pp->locallab.spots.at(pp->locallab.selspot).loc.at(2) = r->locY; + pp->locallab.spots.at(pp->locallab.selspot).loc.at(3) = r->locYT; pp->locallab.spots.at(pp->locallab.selspot).centerX = r->centerX; pp->locallab.spots.at(pp->locallab.selspot).centerY = r->centerY; pp->locallab.spots.at(pp->locallab.selspot).circrad = r->circrad; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index e9ec0843a..6de3dc550 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -993,10 +993,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).structexclu = locallab.spots.at(j).structexclu && pSpot.structexclu == otherSpot.structexclu; locallab.spots.at(j).struc = locallab.spots.at(j).struc && pSpot.struc == otherSpot.struc; locallab.spots.at(j).shapeMethod = locallab.spots.at(j).shapeMethod && pSpot.shapeMethod == otherSpot.shapeMethod; - locallab.spots.at(j).locX = locallab.spots.at(j).locX && pSpot.locX == otherSpot.locX; - locallab.spots.at(j).locXL = locallab.spots.at(j).locXL && pSpot.locXL == otherSpot.locXL; - locallab.spots.at(j).locY = locallab.spots.at(j).locY && pSpot.locY == otherSpot.locY; - locallab.spots.at(j).locYT = locallab.spots.at(j).locYT && pSpot.locYT == otherSpot.locYT; + locallab.spots.at(j).loc = locallab.spots.at(j).loc && pSpot.loc == otherSpot.loc; locallab.spots.at(j).centerX = locallab.spots.at(j).centerX && pSpot.centerX == otherSpot.centerX; locallab.spots.at(j).centerY = locallab.spots.at(j).centerY && pSpot.centerY == otherSpot.centerY; locallab.spots.at(j).circrad = locallab.spots.at(j).circrad && pSpot.circrad == otherSpot.circrad; @@ -2941,20 +2938,8 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).shapeMethod = mods.locallab.spots.at(i).shapeMethod; } - if (locallab.spots.at(i).locX) { - toEdit.locallab.spots.at(i).locX = mods.locallab.spots.at(i).locX; - } - - if (locallab.spots.at(i).locXL) { - toEdit.locallab.spots.at(i).locXL = mods.locallab.spots.at(i).locXL; - } - - if (locallab.spots.at(i).locY) { - toEdit.locallab.spots.at(i).locY = mods.locallab.spots.at(i).locY; - } - - if (locallab.spots.at(i).locYT) { - toEdit.locallab.spots.at(i).locYT = mods.locallab.spots.at(i).locYT; + if (locallab.spots.at(i).loc) { + toEdit.locallab.spots.at(i).loc = mods.locallab.spots.at(i).loc; } if (locallab.spots.at(i).centerX) { @@ -5671,10 +5656,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : structexclu(v), struc(v), shapeMethod(v), - locX(v), - locXL(v), - locY(v), - locYT(v), + loc(v), centerX(v), centerY(v), circrad(v), @@ -6105,10 +6087,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) structexclu = v; struc = v; shapeMethod = v; - locX = v; - locXL = v; - locY = v; - locYT = v; + loc = v; centerX = v; centerY = v; circrad = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 6a4b1ce01..e27c6e455 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -397,10 +397,7 @@ public: bool structexclu; bool struc; bool shapeMethod; - bool locX; - bool locXL; - bool locY; - bool locYT; + bool loc; bool centerX; bool centerY; bool circrad;