diff --git a/rtdata/languages/default b/rtdata/languages/default index a6c9acb1d..879937c9c 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -857,6 +857,7 @@ TP_RAWCACORR_CABLUE;Blue TP_RAWCACORR_CARED;Red TP_RAWEXPOS_LINEAR;White Point: Linear corr. factor TP_RAWEXPOS_PRESER;White Point: HL preserving corr.(EV) +TP_RAWEXPOS_BLACKS;Black Levels TP_RAWEXPOS_BLACKZERO;Black Level: Green 1 (leader) TP_RAWEXPOS_BLACKONE;Black Level: Red TP_RAWEXPOS_BLACKTWO;Black Level: Blue diff --git a/rtgui/addsetids.h b/rtgui/addsetids.h index b0281b562..4fecf2a21 100644 --- a/rtgui/addsetids.h +++ b/rtgui/addsetids.h @@ -1,6 +1,10 @@ #ifndef _ADDSETIDS_ #define _ADDSETIDS_ + +// UPDATE THE DEFAULT VALUE IN OPTIONS.CC TOO !!! + + #define ADDSET_TC_EXPCOMP 0 #define ADDSET_TC_BRIGHTNESS 1 #define ADDSET_TC_BLACKLEVEL 2 @@ -27,9 +31,21 @@ #define ADDSET_TC_HLCOMPAMOUNT 23 #define ADDSET_TC_HLCOMPTHRESH 24 -#define ADDSET_TC_SHCOMP 25 -// When adding items, make sure to update ADDSET_PARAM_NUM -#define ADDSET_PARAM_NUM 26 // THIS IS USED AS A DELIMITER!! +#define ADDSET_TC_SHCOMP 25 +#define ADDSET_DIRPYREQ 26 +#define ADDSET_DIRPYRDN_CHLUM 27 +#define ADDSET_DIRPYRDN_GAMMA 28 +#define ADDSET_CHMIXER 29 + +#define ADDSET_PREPROCESS_GREENEQUIL 30 +#define ADDSET_PREPROCESS_LINEDENOISE 31 +#define ADDSET_RAWCACORR 32 +#define ADDSET_RAWEXPOS_LINEAR 33 +#define ADDSET_RAWEXPOS_PRESER 34 +#define ADDSET_RAWEXPOS_BLACKS 35 + +// When adding items, make sure to update ADDSET_PARAM_NUM +#define ADDSET_PARAM_NUM 36 // THIS IS USED AS A DELIMITER!! #endif diff --git a/rtgui/adjuster.cc b/rtgui/adjuster.cc index 53ff9c22b..662fc5bf2 100644 --- a/rtgui/adjuster.cc +++ b/rtgui/adjuster.cc @@ -31,6 +31,12 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep afterReset = false; blocked = false; + vMin = vmin; + vMax = vmax; + vStep = vstep; + initialDefaultVal = vdefault; + addMode = false; + // TODO: let the user chose the default value of Adjuster::delay, for slow machines delay = options.adjusterDelay; // delay is no more static, so we can set the delay individually (usefull for the RAW editor tab) @@ -74,11 +80,12 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep setLimits (vmin, vmax, vstep, vdefault); defaultVal = shapeValue (vdefault); + initialDefaultVal = shapeValue (vdefault); editedState = defEditedState = Irrelevant; sliderChange = slider->signal_value_changed().connect( sigc::mem_fun(*this, &Adjuster::sliderChanged) ); spinChange = spin->signal_value_changed().connect ( sigc::mem_fun(*this, &Adjuster::spinChanged), true); - reset->signal_clicked().connect( sigc::mem_fun(*this, &Adjuster::resetPressed) ); + reset->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Adjuster::resetPressed) ); slider->set_update_policy (Gtk::UPDATE_CONTINUOUS); show_all (); @@ -102,7 +109,7 @@ void Adjuster::setDefaultEditedState (EditedState eState) { defEditedState = eState; } -void Adjuster::resetPressed () { +void Adjuster::resetPressed (GdkEventButton* event) { if (editedState!=Irrelevant) { editedState = defEditedState; @@ -114,7 +121,12 @@ void Adjuster::resetPressed () { refreshLabelStyle (); } afterReset = true; - slider->set_value (defaultVal); + if ((event != NULL) && (event->state & GDK_CONTROL_MASK) && (event->button == 1)) + // CTRL pressed : resetting to current default value + slider->set_value (defaultVal); + else + // no modifier key or addMode=true : resetting to initial default value + slider->set_value (initialDefaultVal); } double Adjuster::shapeValue (double a) { @@ -135,11 +147,28 @@ void Adjuster::setLimits (double vmin, double vmax, double vstep, double vdefaul slider->set_increments (vstep, 2.0*vstep); slider->set_range (vmin, vmax); slider->set_value (shapeValue(vdefault)); - defaultVal = shapeValue (vdefault); + //defaultVal = shapeValue (vdefault); sliderChange.block (false); spinChange.block (false); } +void Adjuster::setAddMode(bool addM) { + if (addM != addMode) { + // Switching the Adjuster to the new mode + if (addM) { + // Switching to the relative mode + double range = -vMin + vMax; + if (range < 0.) range = -range; + setLimits(-range, range, vStep, 0); + } + else { + // Switching to the absolute mode + setLimits(vMin, vMax, vStep, defaultVal); + } + addMode = addM; + } +} + void Adjuster::setAdjusterListener (AdjusterListener* alistener) { adjusterListener = alistener; @@ -209,16 +238,19 @@ void Adjuster::setValue (double a) { afterReset = false; } +// return the value trimmed to the limits at construction time double Adjuster::getValue () { return spin->get_value (); } +// return the value trimmed to the limits at construction time int Adjuster::getIntValue () { return spin->get_value_as_int (); } +// method only used by the history manager Glib::ustring Adjuster::getTextValue () { return spin->get_text (); @@ -284,3 +316,25 @@ void Adjuster::editedToggled () { if (adjusterListener && !blocked) adjusterListener->adjusterChanged (this, spin->get_value ()); } + +double Adjuster::trimValue (double& val) { + + if (val > vMax) val = vMax; // shapeValue(vMax) ? + else if (val < vMin) val = vMin; // shapeValue(vMin) ? + return val; +} + +int Adjuster::trimValue (int& val) { + + if (val > (int)vMax) val = (int)vMax; // shapeValue(vMax) ? + else if (val < (int)vMin) val = (int)vMin; // shapeValue(vMin) ? + return val; +} + +float Adjuster::trimValue (float& val) { + + if (val > (float)vMax) val = (float)vMax; // shapeValue(vMax) ? + else if (val < (float)vMin) val = (float)vMin; // shapeValue(vMin) ? + return val; +} + diff --git a/rtgui/adjuster.h b/rtgui/adjuster.h index 5b34e0392..d4da4ebbc 100644 --- a/rtgui/adjuster.h +++ b/rtgui/adjuster.h @@ -44,13 +44,18 @@ class Adjuster : public Gtk::VBox { sigc::connection sliderChange; sigc::connection editedChange; bool listenerReady; - double defaultVal; + double defaultVal; // current default value (it can change when switching from ADD or SET mode) + double initialDefaultVal; // default value at construction time EditedState editedState; EditedState defEditedState; int digits; Gtk::CheckButton* editedCheckBox; bool afterReset; bool blocked; + bool addMode; + double vMin; + double vMax; + double vStep; double shapeValue (double a); void refreshLabelStyle (); @@ -76,12 +81,16 @@ class Adjuster : public Gtk::VBox { void showEditedCB (); void block(bool isBlocked) { blocked = isBlocked; } - + void setAddMode(bool addM); + bool getAddMode() { return addMode; }; void spinChanged (); void sliderChanged (); bool notifyListener (); - void resetPressed (); + void resetPressed (GdkEventButton* event); void editedToggled (); + double trimValue (double& val); + float trimValue (float& val); + int trimValue (int& val); }; #endif diff --git a/rtgui/batchtoolpanelcoord.cc b/rtgui/batchtoolpanelcoord.cc index 2cf3cf29c..c6ace70de 100644 --- a/rtgui/batchtoolpanelcoord.cc +++ b/rtgui/batchtoolpanelcoord.cc @@ -1,313 +1,358 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include -#include -#include -#include -#include - -using namespace rtengine::procparams; - -BatchToolPanelCoordinator::BatchToolPanelCoordinator (FilePanel* parent) : ToolPanelCoordinator(), parent(parent) { - - // remove exif panel and iptc panel - std::vector::iterator epi = std::find (toolPanels.begin(), toolPanels.end(), exifpanel); - if (epi!=toolPanels.end()) - toolPanels.erase (epi); - std::vector::iterator ipi = std::find (toolPanels.begin(), toolPanels.end(), iptcpanel); - if (ipi!=toolPanels.end()) - toolPanels.erase (ipi); - toolPanelNotebook->remove_page (*metadataPanel); - - for (int i=0; isetBatchMode (true); -} - -void BatchToolPanelCoordinator::selectionChanged (const std::vector& selected) { - - if (selected!=this->selected) { - closeSession (); - this->selected = selected; - selFileNames.clear (); - for (int i=0; igetFileName ()); - initSession (); - } -} - -void BatchToolPanelCoordinator::closeSession (bool save) { - - pparamsEdited.set (false); - - for (int i=0; iremoveThumbnailListener (this); - - if (somethingChanged && save) { - - // read new values from the gui - for (int i=0; iwrite (&pparams, &pparamsEdited); - - // combine with initial parameters and set - ProcParams newParams; - for (int i=0; isetProcParams (newParams, BATCHEDITOR, true); - } - } - for (int i=0; iclearParamChanges (); -} - -void BatchToolPanelCoordinator::initSession () { - - somethingChanged = false; - - initialPP.resize (selected.size()); - for (int i=0; igetProcParams (); - selected[i]->applyAutoExp (initialPP[i]); - selected[i]->addThumbnailListener (this); - } - - pparamsEdited.initFrom (initialPP); - -/* curve->setAdjusterBehavior (false, false, false, false); - whitebalance->setAdjusterBehavior (false, false); - vignetting->setAdjusterBehavior (false); - rotate->setAdjusterBehavior (false); - distortion->setAdjusterBehavior (false); - cacorrection->setAdjusterBehavior (false, false); - colorshift->setAdjusterBehavior (false, false); - colorboost->setAdjusterBehavior (false); - lumadenoise->setAdjusterBehavior (false); - sharpening->setAdjusterBehavior (false); - shadowshighlights->setAdjusterBehavior (false, false, false); -*/ - crop->setDimensions (100000, 100000); - -/* if (selected.size()>0) { - pparams = selected[0]->getProcParams (); - for (int i=0; isetDefaults (&pparams, &pparamsEdited); - toolPanels[i]->read (&pparams, &pparamsEdited); - } - for (int i=0; iprocParamsChanged (&pparams, rtengine::EvPhotoLoaded, "batch processing", &pparamsEdited); - } -*/ - - if (selected.size()>0) { - - pparams = selected[0]->getProcParams (); - coarse->initBatchBehavior (); - - toneCurve->setAdjusterBehavior (options.baBehav[ADDSET_TC_EXPCOMP], options.baBehav[ADDSET_TC_HLCOMPAMOUNT],options.baBehav[ADDSET_TC_HLCOMPTHRESH], options.baBehav[ADDSET_TC_BRIGHTNESS], options.baBehav[ADDSET_TC_BLACKLEVEL],options.baBehav[ADDSET_TC_SHCOMP], options.baBehav[ADDSET_TC_CONTRAST], options.baBehav[ADDSET_TC_SATURATION]); - lcurve->setAdjusterBehavior (options.baBehav[ADDSET_LC_BRIGHTNESS], options.baBehav[ADDSET_LC_CONTRAST], options.baBehav[ADDSET_LC_SATURATION]); - whitebalance->setAdjusterBehavior (options.baBehav[ADDSET_WB_TEMPERATURE], options.baBehav[ADDSET_WB_GREEN]); - vignetting->setAdjusterBehavior (options.baBehav[ADDSET_VIGN_AMOUNT]); - rotate->setAdjusterBehavior (options.baBehav[ADDSET_ROTATE_DEGREE]); - distortion->setAdjusterBehavior (options.baBehav[ADDSET_DIST_AMOUNT]); - perspective->setAdjusterBehavior (options.baBehav[ADDSET_PERSPECTIVE]); - cacorrection->setAdjusterBehavior (options.baBehav[ADDSET_CA]); - //colorshift->setAdjusterBehavior (options.baBehav[ADDSET_CS_BLUEYELLOW], options.baBehav[ADDSET_CS_GREENMAGENTA]); - //colorboost->setAdjusterBehavior (options.baBehav[ADDSET_CBOOST_AMOUNT]); - //lumadenoise->setAdjusterBehavior (options.baBehav[ADDSET_LD_EDGETOLERANCE]); - sharpening->setAdjusterBehavior (options.baBehav[ADDSET_SHARP_AMOUNT]); - shadowshighlights->setAdjusterBehavior (options.baBehav[ADDSET_SH_HIGHLIGHTS], options.baBehav[ADDSET_SH_SHADOWS], options.baBehav[ADDSET_SH_LOCALCONTRAST]); - - if (options.baBehav[ADDSET_TC_EXPCOMP]) pparams.toneCurve.expcomp = 0; - if (options.baBehav[ADDSET_TC_HLCOMPAMOUNT]) pparams.toneCurve.hlcompr = 0; - if (options.baBehav[ADDSET_TC_HLCOMPTHRESH]) pparams.toneCurve.hlcomprthresh = 0; - if (options.baBehav[ADDSET_TC_BRIGHTNESS]) pparams.toneCurve.brightness = 0; - if (options.baBehav[ADDSET_TC_BLACKLEVEL]) pparams.toneCurve.black = 0; - if (options.baBehav[ADDSET_TC_SHCOMP]) pparams.toneCurve.shcompr = 0; - if (options.baBehav[ADDSET_TC_CONTRAST]) pparams.toneCurve.contrast = 0; - - if (options.baBehav[ADDSET_SH_HIGHLIGHTS]) pparams.sh.highlights = 0; - if (options.baBehav[ADDSET_SH_SHADOWS]) pparams.sh.shadows = 0; - if (options.baBehav[ADDSET_SH_LOCALCONTRAST]) pparams.sh.localcontrast = 0; - - if (options.baBehav[ADDSET_LC_BRIGHTNESS]) pparams.labCurve.brightness = 0; - if (options.baBehav[ADDSET_LC_CONTRAST]) pparams.labCurve.contrast = 0; - if (options.baBehav[ADDSET_LC_SATURATION]) pparams.labCurve.saturation = 0; - - if (options.baBehav[ADDSET_SHARP_AMOUNT]) pparams.sharpening.amount = 0; - if (options.baBehav[ADDSET_LD_EDGETOLERANCE]) pparams.lumaDenoise.edgetolerance = 0; - - if (options.baBehav[ADDSET_WB_TEMPERATURE]) pparams.wb.temperature = 0; - if (options.baBehav[ADDSET_WB_GREEN]) pparams.wb.green = 0; - - if (options.baBehav[ADDSET_CBOOST_AMOUNT]) pparams.colorBoost.amount = 0; - - if (options.baBehav[ADDSET_CS_BLUEYELLOW]) pparams.colorShift.a = 0; - if (options.baBehav[ADDSET_CS_GREENMAGENTA]) pparams.colorShift.b = 0; - - if (options.baBehav[ADDSET_ROTATE_DEGREE]) pparams.rotate.degree = 0; - if (options.baBehav[ADDSET_DIST_AMOUNT]) pparams.distortion.amount = 0; - if (options.baBehav[ADDSET_PERSPECTIVE]) pparams.perspective.horizontal = pparams.perspective.vertical = 0; - if (options.baBehav[ADDSET_CA]) pparams.cacorrection.red = 0; - if (options.baBehav[ADDSET_CA]) pparams.cacorrection.blue = 0; - if (options.baBehav[ADDSET_VIGN_AMOUNT]) pparams.vignetting.amount = 0; - - for (int i=0; isetDefaults (&pparams, &pparamsEdited); - toolPanels[i]->read (&pparams, &pparamsEdited); - } - for (int i=0; iprocParamsChanged (&pparams, rtengine::EvPhotoLoaded, M("BATCH_PROCESSING"), &pparamsEdited); - } -} - -void BatchToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib::ustring& descr) { - - if (selected.size()==0) - return; - - somethingChanged = true; - - pparamsEdited.set (false); - // read new values from the gui - for (int i=0; iwrite (&pparams, &pparamsEdited); - - // TODO: We may update the crop on coarse rotate events here, like in ToolPanelCoordinator::panelChanged - - if (event==rtengine::EvAutoExp || event==rtengine::EvClip) - for (int i=0; iapplyAutoExp (initialPP[i]); - } - - if (event==rtengine::EvAutoDIST) { - for (int i=0; isetProcParams (newParams, BATCHEDITOR, false); - } - - for (int i=0; iprocParamsChanged (&pparams, event, descr, &pparamsEdited); -} - -void BatchToolPanelCoordinator::getAutoWB (double& temp, double& green) { - - if (selected.size()>0) - selected[0]->getAutoWB (temp, green); -} - -void BatchToolPanelCoordinator::getCamWB (double& temp, double& green) { - - if (selected.size()>0) - selected[0]->getCamWB (temp, green); -} - -void BatchToolPanelCoordinator::optionsChanged () { - - closeSession (); - initSession (); -} - -void BatchToolPanelCoordinator::procParamsChanged (Thumbnail* thm, int whoChangedIt) { - - if (whoChangedIt!=BATCHEDITOR) { - closeSession (false); - initSession (); - } -} - -void BatchToolPanelCoordinator::profileChange (const ProcParams *nparams, rtengine::ProcEvent event, const Glib::ustring& descr, const ParamsEdited* paramsEdited) { - - pparams = *nparams; - if (paramsEdited) - pparamsEdited = *paramsEdited; - - for (int i=0; iread (&pparams, &pparamsEdited); - - somethingChanged = true; - - // read new values from the gui - for (int i=0; iwrite (&pparams, &pparamsEdited); - - // combine with initial parameters and set - ProcParams newParams; - for (int i=0; isetProcParams (newParams, BATCHEDITOR, false); - } - - for (int i=0; iprocParamsChanged (&pparams, event, descr, &pparamsEdited); -} - -void BatchToolPanelCoordinator::cropSelectionReady () { - - toolBar->setTool (TMHand); -} - -CropGUIListener* BatchToolPanelCoordinator::startCropEditing (Thumbnail* thm) { - - if (thm) { - int w, h; - thm->getFinalSize (thm->getProcParams (), w, h); - crop->setDimensions (w, h); - } - return crop; -} - -void BatchToolPanelCoordinator::rotateSelectionReady (double rotate_deg, Thumbnail* thm) { - - toolBar->setTool (TMHand); - if (rotate_deg!=0.0) - rotate->straighten (rotate_deg); -} - -void BatchToolPanelCoordinator::spotWBselected (int x, int y, Thumbnail* thm) { - -// toolBar->setTool (TOOL_HAND); - if (x>0 && y>0 && thm) { - for (int i=0; igetSpotWB (x, y, whitebalance->getSize(), temp, green); - double otemp = initialPP[i].wb.temperature; - double ogreen = initialPP[i].wb.green; - if (options.baBehav[12]) - temp = temp - otemp; - if (options.baBehav[13]) - green = green - ogreen; - whitebalance->setWB (temp, green); - } - } -} - +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include +#include +#include +#include +#include + +using namespace rtengine::procparams; + +BatchToolPanelCoordinator::BatchToolPanelCoordinator (FilePanel* parent) : ToolPanelCoordinator(), parent(parent) { + + // remove exif panel and iptc panel + std::vector::iterator epi = std::find (toolPanels.begin(), toolPanels.end(), exifpanel); + if (epi!=toolPanels.end()) + toolPanels.erase (epi); + std::vector::iterator ipi = std::find (toolPanels.begin(), toolPanels.end(), iptcpanel); + if (ipi!=toolPanels.end()) + toolPanels.erase (ipi); + toolPanelNotebook->remove_page (*metadataPanel); + + for (int i=0; isetBatchMode (true); +} + +void BatchToolPanelCoordinator::selectionChanged (const std::vector& selected) { + + if (selected!=this->selected) { + closeSession (); + this->selected = selected; + selFileNames.clear (); + for (int i=0; igetFileName ()); + initSession (); + } +} + +void BatchToolPanelCoordinator::closeSession (bool save) { + + pparamsEdited.set (false); + + for (int i=0; iremoveThumbnailListener (this); + + if (somethingChanged && save) { + + // read new values from the gui + for (int i=0; iwrite (&pparams, &pparamsEdited); + + // combine with initial parameters and set + ProcParams newParams; + for (int i=0; itrimValues (&newParams); + + selected[i]->setProcParams (newParams, BATCHEDITOR, true); + } + } + for (int i=0; iclearParamChanges (); +} + +void BatchToolPanelCoordinator::initSession () { + + somethingChanged = false; + + initialPP.resize (selected.size()); + for (int i=0; igetProcParams (); + selected[i]->applyAutoExp (initialPP[i]); + selected[i]->addThumbnailListener (this); + } + + pparamsEdited.initFrom (initialPP); + + crop->setDimensions (100000, 100000); + +/* if (selected.size()>0) { + pparams = selected[0]->getProcParams (); + for (int i=0; isetDefaults (&pparams, &pparamsEdited); + toolPanels[i]->read (&pparams, &pparamsEdited); + } + for (int i=0; iprocParamsChanged (&pparams, rtengine::EvPhotoLoaded, "batch processing", &pparamsEdited); + } +*/ + + if (selected.size()>0) { + + // The first selected image (in the thumbnail list, not the click list) is used to populate the EditorPanel and set the default values + pparams = selected[0]->getProcParams (); + + coarse->initBatchBehavior (); + + if (selected.size()==1) { + + toneCurve->setAdjusterBehavior (false, false, false, false, false, false, false, false); + lcurve->setAdjusterBehavior (false, false, false); + whitebalance->setAdjusterBehavior (false, false); + vignetting->setAdjusterBehavior (false); + rotate->setAdjusterBehavior (false); + distortion->setAdjusterBehavior (false); + perspective->setAdjusterBehavior (false); + cacorrection->setAdjusterBehavior (false); + //colorshift->setAdjusterBehavior (false, false); + //colorboost->setAdjusterBehavior (false); + //lumadenoise->setAdjusterBehavior (false); + sharpening->setAdjusterBehavior (false); + chmixer->setAdjusterBehavior (false); + shadowshighlights->setAdjusterBehavior (false, false, false); + dirpyrequalizer->setAdjusterBehavior (false); + dirpyrdenoise->setAdjusterBehavior (false, false); + preprocess->setAdjusterBehavior (false, false); + rawcacorrection->setAdjusterBehavior (false); + rawexposure->setAdjusterBehavior (false, false, false); + } + else { + + toneCurve->setAdjusterBehavior (options.baBehav[ADDSET_TC_EXPCOMP], options.baBehav[ADDSET_TC_HLCOMPAMOUNT],options.baBehav[ADDSET_TC_HLCOMPTHRESH], options.baBehav[ADDSET_TC_BRIGHTNESS], options.baBehav[ADDSET_TC_BLACKLEVEL],options.baBehav[ADDSET_TC_SHCOMP], options.baBehav[ADDSET_TC_CONTRAST], options.baBehav[ADDSET_TC_SATURATION]); + lcurve->setAdjusterBehavior (options.baBehav[ADDSET_LC_BRIGHTNESS], options.baBehav[ADDSET_LC_CONTRAST], options.baBehav[ADDSET_LC_SATURATION]); + whitebalance->setAdjusterBehavior (options.baBehav[ADDSET_WB_TEMPERATURE], options.baBehav[ADDSET_WB_GREEN]); + vignetting->setAdjusterBehavior (options.baBehav[ADDSET_VIGN_AMOUNT]); + rotate->setAdjusterBehavior (options.baBehav[ADDSET_ROTATE_DEGREE]); + distortion->setAdjusterBehavior (options.baBehav[ADDSET_DIST_AMOUNT]); + perspective->setAdjusterBehavior (options.baBehav[ADDSET_PERSPECTIVE]); + cacorrection->setAdjusterBehavior (options.baBehav[ADDSET_CA]); + //colorshift->setAdjusterBehavior (options.baBehav[ADDSET_CS_BLUEYELLOW], options.baBehav[ADDSET_CS_GREENMAGENTA]); + //colorboost->setAdjusterBehavior (options.baBehav[ADDSET_CBOOST_AMOUNT]); + //lumadenoise->setAdjusterBehavior (options.baBehav[ADDSET_LD_EDGETOLERANCE]); + sharpening->setAdjusterBehavior (options.baBehav[ADDSET_SHARP_AMOUNT]); + chmixer->setAdjusterBehavior (options.baBehav[ADDSET_CHMIXER]); + shadowshighlights->setAdjusterBehavior (options.baBehav[ADDSET_SH_HIGHLIGHTS], options.baBehav[ADDSET_SH_SHADOWS], options.baBehav[ADDSET_SH_LOCALCONTRAST]); + dirpyrequalizer->setAdjusterBehavior (options.baBehav[ADDSET_DIRPYREQ]); + dirpyrdenoise->setAdjusterBehavior (options.baBehav[ADDSET_DIRPYRDN_CHLUM], options.baBehav[ADDSET_DIRPYRDN_GAMMA]); + preprocess->setAdjusterBehavior (options.baBehav[ADDSET_PREPROCESS_LINEDENOISE], options.baBehav[ADDSET_PREPROCESS_GREENEQUIL]); + rawcacorrection->setAdjusterBehavior (options.baBehav[ADDSET_RAWCACORR]); + rawexposure->setAdjusterBehavior (options.baBehav[ADDSET_RAWEXPOS_LINEAR], options.baBehav[ADDSET_RAWEXPOS_PRESER], options.baBehav[ADDSET_RAWEXPOS_BLACKS]); + + if (options.baBehav[ADDSET_TC_EXPCOMP]) pparams.toneCurve.expcomp = 0; + if (options.baBehav[ADDSET_TC_HLCOMPAMOUNT]) pparams.toneCurve.hlcompr = 0; + if (options.baBehav[ADDSET_TC_HLCOMPTHRESH]) pparams.toneCurve.hlcomprthresh = 0; + if (options.baBehav[ADDSET_TC_BRIGHTNESS]) pparams.toneCurve.brightness = 0; + if (options.baBehav[ADDSET_TC_BLACKLEVEL]) pparams.toneCurve.black = 0; + if (options.baBehav[ADDSET_TC_SHCOMP]) pparams.toneCurve.shcompr = 0; + if (options.baBehav[ADDSET_TC_CONTRAST]) pparams.toneCurve.contrast = 0; + + if (options.baBehav[ADDSET_SH_HIGHLIGHTS]) pparams.sh.highlights = 0; + if (options.baBehav[ADDSET_SH_SHADOWS]) pparams.sh.shadows = 0; + if (options.baBehav[ADDSET_SH_LOCALCONTRAST]) pparams.sh.localcontrast = 0; + + if (options.baBehav[ADDSET_LC_BRIGHTNESS]) pparams.labCurve.brightness = 0; + if (options.baBehav[ADDSET_LC_CONTRAST]) pparams.labCurve.contrast = 0; + if (options.baBehav[ADDSET_LC_SATURATION]) pparams.labCurve.saturation = 0; + + if (options.baBehav[ADDSET_SHARP_AMOUNT]) pparams.sharpening.amount = 0; + if (options.baBehav[ADDSET_CHMIXER]) for (int i=0; i<3; i++) pparams.chmixer.red[i] = pparams.chmixer.green[i] = pparams.chmixer.blue[i] = 0; + if (options.baBehav[ADDSET_LD_EDGETOLERANCE]) pparams.lumaDenoise.edgetolerance = 0; + + if (options.baBehav[ADDSET_WB_TEMPERATURE]) pparams.wb.temperature = 0; + if (options.baBehav[ADDSET_WB_GREEN]) pparams.wb.green = 0; + + if (options.baBehav[ADDSET_CBOOST_AMOUNT]) pparams.colorBoost.amount = 0; + + if (options.baBehav[ADDSET_CS_BLUEYELLOW]) pparams.colorShift.a = 0; + if (options.baBehav[ADDSET_CS_GREENMAGENTA]) pparams.colorShift.b = 0; + + if (options.baBehav[ADDSET_ROTATE_DEGREE]) pparams.rotate.degree = 0; + if (options.baBehav[ADDSET_DIST_AMOUNT]) pparams.distortion.amount = 0; + if (options.baBehav[ADDSET_PERSPECTIVE]) pparams.perspective.horizontal = pparams.perspective.vertical = 0; + if (options.baBehav[ADDSET_CA]) pparams.cacorrection.red = 0; + if (options.baBehav[ADDSET_CA]) pparams.cacorrection.blue = 0; + if (options.baBehav[ADDSET_VIGN_AMOUNT]) pparams.vignetting.amount = 0; + + if (options.baBehav[ADDSET_DIRPYREQ]) for (int i=0; i<5; i++) pparams.dirpyrequalizer.mult[i] = 0; + if (options.baBehav[ADDSET_DIRPYRDN_CHLUM]) pparams.dirpyrDenoise.luma = pparams.dirpyrDenoise.chroma = 0; + if (options.baBehav[ADDSET_DIRPYRDN_GAMMA]) pparams.dirpyrDenoise.gamma = 0; + + if (options.baBehav[ADDSET_PREPROCESS_GREENEQUIL]) pparams.raw.greenthresh = 0; + if (options.baBehav[ADDSET_PREPROCESS_LINEDENOISE]) pparams.raw.linenoise = 0; + if (options.baBehav[ADDSET_RAWCACORR]) pparams.raw.cablue = pparams.raw.cared = 0; + if (options.baBehav[ADDSET_RAWEXPOS_LINEAR]) pparams.raw.expos = 0; + if (options.baBehav[ADDSET_RAWEXPOS_PRESER]) pparams.raw.preser = 0; + if (options.baBehav[ADDSET_RAWEXPOS_BLACKS]) pparams.raw.blackzero = pparams.raw.blackone = pparams.raw.blacktwo = pparams.raw.blackthree = 0; + } + + for (int i=0; isetDefaults (&pparams, &pparamsEdited); + toolPanels[i]->read (&pparams, &pparamsEdited); + } + for (int i=0; iprocParamsChanged (&pparams, rtengine::EvPhotoLoaded, M("BATCH_PROCESSING"), &pparamsEdited); + } +} + +void BatchToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib::ustring& descr) { + + if (selected.size()==0) + return; + + somethingChanged = true; + + pparamsEdited.set (false); + // read new values from the gui + for (int i=0; iwrite (&pparams, &pparamsEdited); + + // TODO: We may update the crop on coarse rotate events here, like in ToolPanelCoordinator::panelChanged + + if (event==rtengine::EvAutoExp || event==rtengine::EvClip) + for (int i=0; iapplyAutoExp (initialPP[i]); + } + + if (event==rtengine::EvAutoDIST) { + for (int i=0; itrimValues (&newParams); + + selected[i]->setProcParams (newParams, BATCHEDITOR, false); + } + + for (int i=0; iprocParamsChanged (&pparams, event, descr, &pparamsEdited); +} + +void BatchToolPanelCoordinator::getAutoWB (double& temp, double& green) { + + if (selected.size()>0) + selected[0]->getAutoWB (temp, green); +} + +void BatchToolPanelCoordinator::getCamWB (double& temp, double& green) { + + if (selected.size()>0) + selected[0]->getCamWB (temp, green); +} + +void BatchToolPanelCoordinator::optionsChanged () { + + closeSession (); + initSession (); +} + +void BatchToolPanelCoordinator::procParamsChanged (Thumbnail* thm, int whoChangedIt) { + + if (whoChangedIt!=BATCHEDITOR) { + closeSession (false); + initSession (); + } +} + +void BatchToolPanelCoordinator::profileChange (const ProcParams *nparams, rtengine::ProcEvent event, const Glib::ustring& descr, const ParamsEdited* paramsEdited) { + + pparams = *nparams; + if (paramsEdited) + pparamsEdited = *paramsEdited; + + for (int i=0; iread (&pparams, &pparamsEdited); + + somethingChanged = true; + + // read new values from the gui + for (int i=0; iwrite (&pparams, &pparamsEdited); + + // combine with initial parameters and set + ProcParams newParams; + for (int i=0; isetProcParams (newParams, BATCHEDITOR, false); + } + + for (int i=0; iprocParamsChanged (&pparams, event, descr, &pparamsEdited); +} + +void BatchToolPanelCoordinator::cropSelectionReady () { + + toolBar->setTool (TMHand); +} + +CropGUIListener* BatchToolPanelCoordinator::startCropEditing (Thumbnail* thm) { + + if (thm) { + int w, h; + thm->getFinalSize (thm->getProcParams (), w, h); + crop->setDimensions (w, h); + } + return crop; +} + +void BatchToolPanelCoordinator::rotateSelectionReady (double rotate_deg, Thumbnail* thm) { + + toolBar->setTool (TMHand); + if (rotate_deg!=0.0) + rotate->straighten (rotate_deg); +} + +void BatchToolPanelCoordinator::spotWBselected (int x, int y, Thumbnail* thm) { + +// toolBar->setTool (TOOL_HAND); + if (x>0 && y>0 && thm) { + for (int i=0; igetSpotWB (x, y, whitebalance->getSize(), temp, green); + double otemp = initialPP[i].wb.temperature; + double ogreen = initialPP[i].wb.green; + if (options.baBehav[12]) + temp = temp - otemp; + if (options.baBehav[13]) + green = green - ogreen; + whitebalance->setWB (temp, green); + } + } +} + diff --git a/rtgui/cacorrection.cc b/rtgui/cacorrection.cc index 34eef052f..32e32195f 100644 --- a/rtgui/cacorrection.cc +++ b/rtgui/cacorrection.cc @@ -22,7 +22,7 @@ using namespace rtengine; using namespace rtengine::procparams; -CACorrection::CACorrection () : Gtk::VBox(), FoldableToolPanel(this), vAdd(false) { +CACorrection::CACorrection () : Gtk::VBox(), FoldableToolPanel(this) { red = Gtk::manage (new Adjuster (M("TP_CACORRECTION_RED"), -0.005, 0.005, 0.0001, 0)); red->setAdjusterListener (this); @@ -85,12 +85,14 @@ void CACorrection::adjusterChanged (Adjuster* a, double newval) { void CACorrection::setAdjusterBehavior (bool badd) { - if ((!vAdd && badd) || (vAdd && !badd)) { - red->setLimits (-0.005, 0.005, 0.0001, 0); - blue->setLimits (-0.005, 0.005, 0.0001, 0); - } + red->setAddMode(badd); + blue->setAddMode(badd); +} - vAdd = badd; +void CACorrection::trimValues (rtengine::procparams::ProcParams* pp) { + + red->trimValue(pp->cacorrection.red); + blue->trimValue(pp->cacorrection.blue); } void CACorrection::setBatchMode (bool batchMode) { diff --git a/rtgui/cacorrection.h b/rtgui/cacorrection.h index e3ac82a98..a4bee4ea4 100644 --- a/rtgui/cacorrection.h +++ b/rtgui/cacorrection.h @@ -28,7 +28,6 @@ class CACorrection : public Gtk::VBox, public AdjusterListener, public FoldableT protected: Adjuster* red; Adjuster* blue; - bool vAdd; public: @@ -41,6 +40,7 @@ class CACorrection : public Gtk::VBox, public AdjusterListener, public FoldableT void adjusterChanged (Adjuster* a, double newval); void setAdjusterBehavior (bool badd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/chmixer.cc b/rtgui/chmixer.cc index 2ac6355d1..44d7fe2f3 100644 --- a/rtgui/chmixer.cc +++ b/rtgui/chmixer.cc @@ -149,3 +149,21 @@ void ChMixer::setBatchMode (bool batchMode) { blue[i]->showEditedCB (); } } + +void ChMixer::setAdjusterBehavior (bool rgbadd) { + + for (int i=0; i<3; i++) { + red[i]->setAddMode(rgbadd); + green[i]->setAddMode(rgbadd); + blue[i]->setAddMode(rgbadd); + } +} + +void ChMixer::trimValues (rtengine::procparams::ProcParams* pp) { + + for (int i=0; i<3; i++) { + red[i]->trimValue(pp->chmixer.red[i]); + green[i]->trimValue(pp->chmixer.green[i]); + blue[i]->trimValue(pp->chmixer.blue[i]); + } +} diff --git a/rtgui/chmixer.h b/rtgui/chmixer.h index e9707b50f..cbae1ea73 100644 --- a/rtgui/chmixer.h +++ b/rtgui/chmixer.h @@ -40,6 +40,8 @@ class ChMixer : public Gtk::VBox, public AdjusterListener, public FoldableToolPa void setBatchMode (bool batchMode); void adjusterChanged (Adjuster* a, double newval); + void setAdjusterBehavior (bool rgbadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/defringe.cc b/rtgui/defringe.cc index a4a3292c9..af6305bcb 100644 --- a/rtgui/defringe.cc +++ b/rtgui/defringe.cc @@ -138,13 +138,3 @@ void Defringe::setBatchMode (bool batchMode) { radius->showEditedCB (); threshold->showEditedCB (); } - -/*void Defringe::setAdjusterBehavior (bool bthresholdtoladd) { - - if (!thresholdtolAdd && bthresholdtoladd) - threshold->setLimits (-10000, 10000, 100, 0); - else if (thresholdtolAdd && !bthresholdtoladd) - threshold->setLimits (100, 10000, 100, 1000); - - thresholdtolAdd = bthresholdtoladd; -}*/ diff --git a/rtgui/defringe.h b/rtgui/defringe.h index df0c908c6..d03b76851 100644 --- a/rtgui/defringe.h +++ b/rtgui/defringe.h @@ -32,7 +32,6 @@ class Defringe : public Gtk::VBox, public AdjusterListener, public FoldableToolP bool lastEnabled; sigc::connection enaConn; bool edges; - bool thresholdtolAdd; public: @@ -46,7 +45,6 @@ class Defringe : public Gtk::VBox, public AdjusterListener, public FoldableToolP void adjusterChanged (Adjuster* a, double newval); void enabledChanged (); - void setAdjusterBehavior (bool bthresholdtoladd); }; #endif diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index fba51ff25..251dc8d84 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -569,10 +569,10 @@ bool DiagonalCurveEditorSubGroup::curveReset(int cType) { return true; break; case (DCT_Parametric) : - highlights->resetPressed(); - lights->resetPressed(); - darks->resetPressed(); - shadows->resetPressed(); + highlights->resetPressed(NULL); + lights->resetPressed(NULL); + darks->resetPressed(NULL); + shadows->resetPressed(NULL); shcSelector->reset(); paramCurve->reset (); return true; diff --git a/rtgui/dirpyrdenoise.cc b/rtgui/dirpyrdenoise.cc index 809cfdc9d..934fa4dda 100644 --- a/rtgui/dirpyrdenoise.cc +++ b/rtgui/dirpyrdenoise.cc @@ -158,12 +158,16 @@ void DirPyrDenoise::setBatchMode (bool batchMode) { chroma->showEditedCB (); } -/*void DirPyrDenoise::setAdjusterBehavior (bool bedgetoladd) { - - if (!edgetolAdd && bedgetoladd) - edge->setLimits (-10000, 10000, 100, 0); - else if (edgetolAdd && !bedgetoladd) - edge->setLimits (10, 30000, 100, 1500); - - edgetolAdd = bedgetoladd; - }*/ +void DirPyrDenoise::setAdjusterBehavior (bool chrolumaadd, bool gammaadd) { + + luma->setAddMode(chrolumaadd); + chroma->setAddMode(chrolumaadd); + gamma->setAddMode(gammaadd); +} + +void DirPyrDenoise::trimValues (rtengine::procparams::ProcParams* pp) { + + luma->trimValue(pp->dirpyrDenoise.luma); + chroma->trimValue(pp->dirpyrDenoise.chroma); + gamma->trimValue(pp->dirpyrDenoise.gamma); +} diff --git a/rtgui/dirpyrdenoise.h b/rtgui/dirpyrdenoise.h index 714131f37..8fdff51c4 100644 --- a/rtgui/dirpyrdenoise.h +++ b/rtgui/dirpyrdenoise.h @@ -33,7 +33,6 @@ class DirPyrDenoise : public Gtk::VBox, public AdjusterListener, public Foldable Gtk::CheckButton* enabled; bool lastEnabled; sigc::connection enaConn; - bool edgetolAdd; public: @@ -45,9 +44,10 @@ class DirPyrDenoise : public Gtk::VBox, public AdjusterListener, public Foldable void setBatchMode (bool batchMode); void adjusterChanged (Adjuster* a, double newval); - void enabledChanged (); + void enabledChanged (); - void setAdjusterBehavior (bool bedgetoladd); + void setAdjusterBehavior (bool chrolumaadd, bool gammaadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/dirpyrequalizer.cc b/rtgui/dirpyrequalizer.cc index 27e7c5dfa..063224d80 100644 --- a/rtgui/dirpyrequalizer.cc +++ b/rtgui/dirpyrequalizer.cc @@ -220,4 +220,14 @@ void DirPyrEqualizer::lumacontrastMinusPressed () { } } +void DirPyrEqualizer::setAdjusterBehavior (bool multiplieradd) { + for (int i=0; i<5; i++) + multiplier[i]->setAddMode(multiplieradd); +} + +void DirPyrEqualizer::trimValues (rtengine::procparams::ProcParams* pp) { + + for (int i=0; i<5; i++) + multiplier[i]->trimValue(pp->dirpyrequalizer.mult[i]); +} diff --git a/rtgui/dirpyrequalizer.h b/rtgui/dirpyrequalizer.h index c47090dc9..874937636 100644 --- a/rtgui/dirpyrequalizer.h +++ b/rtgui/dirpyrequalizer.h @@ -44,11 +44,13 @@ public: DirPyrEqualizer (); virtual ~DirPyrEqualizer (); - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); - void setBatchMode (bool batchMode); - + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); + void setAdjusterBehavior (bool multiplieradd); + void trimValues (rtengine::procparams::ProcParams* pp); + void adjusterChanged (Adjuster* a, double newval); void enabledToggled (); void lumaneutralPressed (); diff --git a/rtgui/distortion.cc b/rtgui/distortion.cc index f477c03be..a1e7e3589 100644 --- a/rtgui/distortion.cc +++ b/rtgui/distortion.cc @@ -1,109 +1,110 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include - -extern Glib::ustring argv0; - -using namespace rtengine; -using namespace rtengine::procparams; - -Distortion::Distortion (): Gtk::VBox(), FoldableToolPanel(this) { - - rlistener = NULL; - autoDistor = Gtk::manage (new Gtk::Button (M("TP_DISTORTION_AUTO"))); - autoDistor->set_image (*Gtk::manage (new Gtk::Image (argv0+"/images/distortion_auto.png"))); - autoDistor->set_tooltip_text (M("TP_DISTORTION_AUTO_TIP")); - idConn = autoDistor->signal_pressed().connect( sigc::mem_fun(*this, &Distortion::idPressed) ); - autoDistor->show(); - pack_start (*autoDistor); - - distor = Gtk::manage (new Adjuster (M("TP_DISTORTION_AMOUNT"), -0.5, 0.5, 0.001, 0)); - distor->setAdjusterListener (this); - distor->show(); - pack_start (*distor); - distAdd = false; -} - -void Distortion::read (const ProcParams* pp, const ParamsEdited* pedited) { - - disableListener (); - - if (pedited) { - distor->setEditedState (pedited->distortion.amount ? Edited : UnEdited); - } - - distor->setValue (pp->distortion.amount); - - enableListener (); -} - -void Distortion::write (ProcParams* pp, ParamsEdited* pedited) { - - pp->distortion.amount = distor->getValue (); - - if (pedited) { - pedited->distortion.amount = distor->getEditedState (); - } -} - -void Distortion::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { - - distor->setDefault (defParams->distortion.amount); - - if (pedited) { - distor->setDefaultEditedState (pedited->distortion.amount ? Edited : UnEdited); - } - else { - distor->setDefaultEditedState (Irrelevant); - } -} - -void Distortion::adjusterChanged (Adjuster* a, double newval) { - - if (listener) - listener->panelChanged (EvDISTAmount, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), a->getValue())); -} - -void Distortion::setAdjusterBehavior (bool bvadd) { - - if ((!distAdd && bvadd) || (distAdd && !bvadd)) - distor->setLimits (-0.5, 0.5, 0.001, 0); - - distAdd = bvadd; -} - -void Distortion::setBatchMode (bool batchMode) { - - ToolPanel::setBatchMode (batchMode); - if (batchMode) { - autoDistor->set_sensitive(false); - } - distor->showEditedCB (); -} - -void Distortion::idPressed () { - if (!batchMode) { - if (rlistener) { - double new_amount = rlistener->autoDistorRequested(); - distor->setValue(new_amount); - adjusterChanged (distor, new_amount); - } - } -} +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include + +extern Glib::ustring argv0; + +using namespace rtengine; +using namespace rtengine::procparams; + +Distortion::Distortion (): Gtk::VBox(), FoldableToolPanel(this) { + + rlistener = NULL; + autoDistor = Gtk::manage (new Gtk::Button (M("TP_DISTORTION_AUTO"))); + autoDistor->set_image (*Gtk::manage (new Gtk::Image (argv0+"/images/distortion_auto.png"))); + autoDistor->set_tooltip_text (M("TP_DISTORTION_AUTO_TIP")); + idConn = autoDistor->signal_pressed().connect( sigc::mem_fun(*this, &Distortion::idPressed) ); + autoDistor->show(); + pack_start (*autoDistor); + + distor = Gtk::manage (new Adjuster (M("TP_DISTORTION_AMOUNT"), -0.5, 0.5, 0.001, 0)); + distor->setAdjusterListener (this); + distor->show(); + pack_start (*distor); +} + +void Distortion::read (const ProcParams* pp, const ParamsEdited* pedited) { + + disableListener (); + + if (pedited) { + distor->setEditedState (pedited->distortion.amount ? Edited : UnEdited); + } + + distor->setValue (pp->distortion.amount); + + enableListener (); +} + +void Distortion::write (ProcParams* pp, ParamsEdited* pedited) { + + pp->distortion.amount = distor->getValue (); + + if (pedited) { + pedited->distortion.amount = distor->getEditedState (); + } +} + +void Distortion::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { + + distor->setDefault (defParams->distortion.amount); + + if (pedited) { + distor->setDefaultEditedState (pedited->distortion.amount ? Edited : UnEdited); + } + else { + distor->setDefaultEditedState (Irrelevant); + } +} + +void Distortion::adjusterChanged (Adjuster* a, double newval) { + + if (listener) + listener->panelChanged (EvDISTAmount, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), a->getValue())); +} + +void Distortion::setBatchMode (bool batchMode) { + + ToolPanel::setBatchMode (batchMode); + if (batchMode) { + autoDistor->set_sensitive(false); + } + distor->showEditedCB (); +} + +void Distortion::idPressed () { + if (!batchMode) { + if (rlistener) { + double new_amount = rlistener->autoDistorRequested(); + distor->setValue(new_amount); + adjusterChanged (distor, new_amount); + } + } +} + +void Distortion::setAdjusterBehavior (bool vadd) { + + distor->setAddMode(vadd); +} + +void Distortion::trimValues (rtengine::procparams::ProcParams* pp) { + + distor->trimValue(pp->distortion.amount); +} diff --git a/rtgui/distortion.h b/rtgui/distortion.h index a20eac290..7d30d0648 100644 --- a/rtgui/distortion.h +++ b/rtgui/distortion.h @@ -1,51 +1,51 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#ifndef _DISTORTION_H_ -#define _DISTORTION_H_ - -#include -#include -#include -#include - -class Distortion : public Gtk::VBox, public AdjusterListener, public FoldableToolPanel { - - protected: - Gtk::Button* autoDistor; - Adjuster* distor; - bool distAdd; - sigc::connection idConn; - LensGeomListener * rlistener; - - public: - - Distortion (); - - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); - void setBatchMode (bool batchMode); - - void adjusterChanged (Adjuster* a, double newval); - void setAdjusterBehavior (bool bvadd); - void idPressed (); - void setLensGeomListener (LensGeomListener* l) { rlistener = l; } -}; - -#endif +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#ifndef _DISTORTION_H_ +#define _DISTORTION_H_ + +#include +#include +#include +#include + +class Distortion : public Gtk::VBox, public AdjusterListener, public FoldableToolPanel { + + protected: + Gtk::Button* autoDistor; + Adjuster* distor; + sigc::connection idConn; + LensGeomListener * rlistener; + + public: + + Distortion (); + + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); + + void adjusterChanged (Adjuster* a, double newval); + void setAdjusterBehavior (bool vadd); + void trimValues (rtengine::procparams::ProcParams* pp); + void idPressed (); + void setLensGeomListener (LensGeomListener* l) { rlistener = l; } +}; + +#endif diff --git a/rtgui/impulsedenoise.cc b/rtgui/impulsedenoise.cc index aadf6c759..0fd9c4c25 100644 --- a/rtgui/impulsedenoise.cc +++ b/rtgui/impulsedenoise.cc @@ -118,3 +118,13 @@ void ImpulseDenoise::setBatchMode (bool batchMode) { ToolPanel::setBatchMode (batchMode); thresh->showEditedCB (); } + +void ImpulseDenoise::setAdjusterBehavior (bool threshadd) { + + thresh->setAddMode(threshadd); +} + +void ImpulseDenoise::trimValues (rtengine::procparams::ProcParams* pp) { + + thresh->trimValue(pp->impulseDenoise.thresh); +} diff --git a/rtgui/impulsedenoise.h b/rtgui/impulsedenoise.h index e2cba771d..2a8aa6229 100644 --- a/rtgui/impulsedenoise.h +++ b/rtgui/impulsedenoise.h @@ -31,7 +31,6 @@ class ImpulseDenoise : public Gtk::VBox, public AdjusterListener, public Foldabl Gtk::CheckButton* enabled; bool lastEnabled; sigc::connection enaConn; - bool edgetolAdd; public: @@ -45,7 +44,8 @@ class ImpulseDenoise : public Gtk::VBox, public AdjusterListener, public Foldabl void adjusterChanged (Adjuster* a, double newval); void enabledChanged (); - void setAdjusterBehavior (bool bedgetoladd); + void setAdjusterBehavior (bool threshadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc index c01738f65..87098797b 100644 --- a/rtgui/labcurve.cc +++ b/rtgui/labcurve.cc @@ -1,369 +1,368 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include - -using namespace rtengine; -using namespace rtengine::procparams; - -LCurve::LCurve () : Gtk::VBox(), FoldableToolPanel(this), brAdd(false), contrAdd(false), satAdd(false) { - - brightness = Gtk::manage (new Adjuster (M("TP_LABCURVE_BRIGHTNESS"), -100, 100, 0.01, 0)); - contrast = Gtk::manage (new Adjuster (M("TP_LABCURVE_CONTRAST"), -100, 100, 1, 0)); - saturation = Gtk::manage (new Adjuster (M("TP_LABCURVE_SATURATION"), -100, 100, 1, 0)); - - pack_start (*brightness); - brightness->show (); - - pack_start (*contrast); - contrast->show (); - - pack_start (*saturation); - saturation->show (); - - brightness->setAdjusterListener (this); - contrast->setAdjusterListener (this); - saturation->setAdjusterListener (this); - - //%%%%%%%%%%%%%%%%%% - pack_start (*Gtk::manage (new Gtk::HSeparator())); - - avoidclip = Gtk::manage (new Gtk::CheckButton (M("TP_LABCURVE_AVOIDCOLORCLIP"))); - - pack_start (*avoidclip); - pack_start (*Gtk::manage (new Gtk::HSeparator())); - - enablelimiter = Gtk::manage (new Gtk::CheckButton (M("TP_LABCURVE_ENABLESATLIMITER"))); - pack_start (*enablelimiter); - - saturationlimiter = Gtk::manage ( new Adjuster (M("TP_LABCURVE_SATLIMIT"), 0, 100, 1.0, 40) ); - pack_start (*saturationlimiter); - saturationlimiter->show (); - saturationlimiter->reference (); - - //saturation->setAdjusterListener (this); - saturationlimiter->setAdjusterListener (this); - acconn = avoidclip->signal_toggled().connect( sigc::mem_fun(*this, &LCurve::avoidclip_toggled) ); - elconn = enablelimiter->signal_toggled().connect( sigc::mem_fun(*this, &LCurve::enablelimiter_toggled) ); - //%%%%%%%%%%%%%%%%%%% - - Gtk::HSeparator *hsep3 = Gtk::manage (new Gtk::HSeparator()); - hsep3->show (); - pack_start (*hsep3); - - curveEditorG = new CurveEditorGroup (); - curveEditorG->setCurveListener (this); - curveEditorG->setColorProvider (this); - - lshape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, "L"); - ashape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, "a"); - bshape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, "b"); - - // This will add the reset button at the end of the curveType buttons - curveEditorG->curveListComplete(); - - pack_start (*curveEditorG, Gtk::PACK_SHRINK, 4); - -} - -LCurve::~LCurve () { - delete curveEditorG; -} - -void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited) { - - disableListener (); - - if (pedited) { - brightness->setEditedState (pedited->labCurve.brightness ? Edited : UnEdited); - contrast->setEditedState (pedited->labCurve.contrast ? Edited : UnEdited); - saturation->setEditedState (pedited->labCurve.saturation ? Edited : UnEdited); - - //%%%%%%%%%%%%%%%%%%%%%% - saturationlimiter->setEditedState (pedited->labCurve.saturationlimit ? Edited : UnEdited); - avoidclip->set_inconsistent (!pedited->labCurve.avoidclip); - enablelimiter->set_inconsistent (!pedited->labCurve.enable_saturationlimiter); - //%%%%%%%%%%%%%%%%%%%%%% - - lshape->setUnChanged (!pedited->labCurve.lcurve); - ashape->setUnChanged (!pedited->labCurve.acurve); - bshape->setUnChanged (!pedited->labCurve.bcurve); - - } - - brightness->setValue (pp->labCurve.brightness); - contrast->setValue (pp->labCurve.contrast); - saturation->setValue (pp->labCurve.saturation); - - //%%%%%%%%%%%%%%%%%%%%%% - saturationlimiter->setValue (pp->labCurve.saturationlimit); - acconn.block (true); - avoidclip->set_active (pp->labCurve.avoidclip); - acconn.block (false); - elconn.block (true); - enablelimiter->set_active (pp->labCurve.enable_saturationlimiter); - elconn.block (false); - - //removeIfThere (this, saturationlimiter, false); - // if (enablelimiter->get_active () || enablelimiter->get_inconsistent()) - // pack_start (*saturationlimiter); - - lastACVal = pp->labCurve.avoidclip; - lastELVal = pp->labCurve.enable_saturationlimiter; - //%%%%%%%%%%%%%%%%%%%%%% - - lshape->setCurve (pp->labCurve.lcurve); - ashape->setCurve (pp->labCurve.acurve); - bshape->setCurve (pp->labCurve.bcurve); - - // Open up the first curve if selected - bool active = lshape->openIfNonlinear(); - if (!active) ashape->openIfNonlinear(); - if (!active) bshape->openIfNonlinear(); - - enableListener (); -} - -void LCurve::write (ProcParams* pp, ParamsEdited* pedited) { - - pp->labCurve.brightness = brightness->getValue (); - pp->labCurve.contrast = (int)contrast->getValue (); - pp->labCurve.saturation = (int)saturation->getValue (); - - //%%%%%%%%%%%%%%%%%%%%%% - pp->labCurve.avoidclip = avoidclip->get_active (); - pp->labCurve.enable_saturationlimiter = enablelimiter->get_active (); - pp->labCurve.saturationlimit = saturationlimiter->getValue (); - //%%%%%%%%%%%%%%%%%%%%%% - - pp->labCurve.lcurve = lshape->getCurve (); - pp->labCurve.acurve = ashape->getCurve (); - pp->labCurve.bcurve = bshape->getCurve (); - - if (pedited) { - pedited->labCurve.brightness = brightness->getEditedState (); - pedited->labCurve.contrast = contrast->getEditedState (); - pedited->labCurve.saturation = saturation->getEditedState (); - - //%%%%%%%%%%%%%%%%%%%%%% - pedited->labCurve.avoidclip = !avoidclip->get_inconsistent(); - pedited->labCurve.enable_saturationlimiter = !enablelimiter->get_inconsistent(); - pedited->labCurve.saturationlimit = saturationlimiter->getEditedState (); - //%%%%%%%%%%%%%%%%%%%%%% - - pedited->labCurve.lcurve = !lshape->isUnChanged (); - pedited->labCurve.acurve = !ashape->isUnChanged (); - pedited->labCurve.bcurve = !bshape->isUnChanged (); - } -} - -void LCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { - - brightness->setDefault (defParams->labCurve.brightness); - contrast->setDefault (defParams->labCurve.contrast); - saturation->setDefault (defParams->labCurve.saturation); - saturationlimiter->setDefault (defParams->labCurve.saturationlimit); - - if (pedited) { - brightness->setDefaultEditedState (pedited->labCurve.brightness ? Edited : UnEdited); - contrast->setDefaultEditedState (pedited->labCurve.contrast ? Edited : UnEdited); - saturation->setDefaultEditedState (pedited->labCurve.saturation ? Edited : UnEdited); - saturationlimiter->setDefaultEditedState (pedited->labCurve.saturationlimit ? Edited : UnEdited); - - } - else { - brightness->setDefaultEditedState (Irrelevant); - contrast->setDefaultEditedState (Irrelevant); - saturation->setDefaultEditedState (Irrelevant); - saturationlimiter->setDefaultEditedState (Irrelevant); - } -} - -//%%%%%%%%%%%%%%%%%%%%%% -//Clipping control changed -void LCurve::avoidclip_toggled () { - - if (batchMode) { - if (avoidclip->get_inconsistent()) { - avoidclip->set_inconsistent (false); - acconn.block (true); - avoidclip->set_active (false); - acconn.block (false); - } - else if (lastACVal) - avoidclip->set_inconsistent (true); - - lastACVal = avoidclip->get_active (); - } - - if (listener) { - if (avoidclip->get_active ()) - listener->panelChanged (EvLAvoidClip, M("GENERAL_ENABLED")); - else - listener->panelChanged (EvLAvoidClip, M("GENERAL_DISABLED")); - } -} - -void LCurve::enablelimiter_toggled () { - - if (batchMode) { - if (enablelimiter->get_inconsistent()) { - enablelimiter->set_inconsistent (false); - elconn.block (true); - enablelimiter->set_active (false); - elconn.block (false); - } - else if (lastELVal) - enablelimiter->set_inconsistent (true); - - lastELVal = enablelimiter->get_active (); - } - - //removeIfThere (this, saturationlimiter, false); - //if (enablelimiter->get_active () || enablelimiter->get_inconsistent()) - // pack_start (*saturationlimiter); - - if (listener) { - if (enablelimiter->get_active ()) - listener->panelChanged (EvLSatLimiter, M("GENERAL_ENABLED")); - else - listener->panelChanged (EvLSatLimiter, M("GENERAL_DISABLED")); - } -} -//%%%%%%%%%%%%%%%%%%%%%% - - -/* - * Curve listener - * - * If more than one curve has been added, the curve listener is automatically - * set to 'multi=true', and send a pointer of the modified curve in a parameter - */ -void LCurve::curveChanged (CurveEditor* ce) { - - if (listener) { - if (ce == lshape) - listener->panelChanged (EvLLCurve, M("HISTORY_CUSTOMCURVE")); - if (ce == ashape) - listener->panelChanged (EvLaCurve, M("HISTORY_CUSTOMCURVE")); - if (ce == bshape) - listener->panelChanged (EvLbCurve, M("HISTORY_CUSTOMCURVE")); - } -} - -void LCurve::adjusterChanged (Adjuster* a, double newval) { - - if (!listener) - return; - - Glib::ustring costr; - if (a==brightness) - costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), a->getValue()); - else if (a==saturationlimiter) - costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(1), a->getValue()); - else - costr = Glib::ustring::format ((int)a->getValue()); - - if (a==brightness) - listener->panelChanged (EvLBrightness, costr); - else if (a==contrast) - listener->panelChanged (EvLContrast, costr); - else if (a==saturation) - listener->panelChanged (EvLSaturation, costr); - else if (a==saturationlimiter) - listener->panelChanged (EvLSatLimit, costr); -} - -//attempt to hide unused channels -/*void LCurve::channel_changed () { - - removeIfThere (this, lcurve, false); - removeIfThere (this, acurve, false); - removeIfThere (this, bcurve, false); - - if (channel->get_active_row_number()==0) - pack_start (*lcurve); - else if (channel->get_active_row_number()==1) - pack_start (*acurve); - else if (method->get_active_row_number()==2) - pack_start (*bcurve); - - - if (listener && enabled->get_active ()) - listener->panelChanged (EvLabCurvetype, channel->get_active_text ()); - -}*/ - -void LCurve::colorForValue (double valX, double valY) { - - CurveEditor* ce = curveEditorG->getDisplayedCurve(); - - if (ce == lshape) { // L = f(L) - red = (double)valY; - green = (double)valY; - blue = (double)valY; - } - else if (ce == ashape) { // a = f(a) - // TODO: To be implemented - red = (double)valY; - green = (double)valY; - blue = (double)valY; - } - else if (ce == bshape) { // b = f(b) - red = (double)valY; - green = (double)valY; - blue = (double)valY; - } - else { - printf("Error: no curve displayed!\n"); - } - -} - -void LCurve::setBatchMode (bool batchMode) { - - ToolPanel::setBatchMode (batchMode); - brightness->showEditedCB (); - contrast->showEditedCB (); - saturation->showEditedCB (); - saturationlimiter->showEditedCB (); - - curveEditorG->setBatchMode (batchMode); -} - -void LCurve::setAdjusterBehavior (bool bradd, bool contradd, bool satadd) { - - if ((!brAdd && bradd) || (brAdd && !bradd)) - brightness->setLimits (-100, 100, 1, 0); - if ((!contrAdd && contradd) || (contrAdd && !contradd)) - contrast->setLimits (-100, 100, 1, 0); - if ((!satAdd && satadd) || (satAdd && !satadd)) - saturation->setLimits (-100, 100, 1, 0); - - - brAdd = bradd; - contrAdd = contradd; - satAdd = satadd; - -} - -void LCurve::updateCurveBackgroundHistogram (LUTu & hist) { - - lshape->updateBackgroundHistogram (hist); -} +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include + +using namespace rtengine; +using namespace rtengine::procparams; + +LCurve::LCurve () : Gtk::VBox(), FoldableToolPanel(this) { + + brightness = Gtk::manage (new Adjuster (M("TP_LABCURVE_BRIGHTNESS"), -100, 100, 0.01, 0)); + contrast = Gtk::manage (new Adjuster (M("TP_LABCURVE_CONTRAST"), -100, 100, 1, 0)); + saturation = Gtk::manage (new Adjuster (M("TP_LABCURVE_SATURATION"), -100, 100, 1, 0)); + + pack_start (*brightness); + brightness->show (); + + pack_start (*contrast); + contrast->show (); + + pack_start (*saturation); + saturation->show (); + + brightness->setAdjusterListener (this); + contrast->setAdjusterListener (this); + saturation->setAdjusterListener (this); + + //%%%%%%%%%%%%%%%%%% + pack_start (*Gtk::manage (new Gtk::HSeparator())); + + avoidclip = Gtk::manage (new Gtk::CheckButton (M("TP_LABCURVE_AVOIDCOLORCLIP"))); + + pack_start (*avoidclip); + pack_start (*Gtk::manage (new Gtk::HSeparator())); + + enablelimiter = Gtk::manage (new Gtk::CheckButton (M("TP_LABCURVE_ENABLESATLIMITER"))); + pack_start (*enablelimiter); + + saturationlimiter = Gtk::manage ( new Adjuster (M("TP_LABCURVE_SATLIMIT"), 0, 100, 1.0, 40) ); + pack_start (*saturationlimiter); + saturationlimiter->show (); + saturationlimiter->reference (); + + //saturation->setAdjusterListener (this); + saturationlimiter->setAdjusterListener (this); + acconn = avoidclip->signal_toggled().connect( sigc::mem_fun(*this, &LCurve::avoidclip_toggled) ); + elconn = enablelimiter->signal_toggled().connect( sigc::mem_fun(*this, &LCurve::enablelimiter_toggled) ); + //%%%%%%%%%%%%%%%%%%% + + Gtk::HSeparator *hsep3 = Gtk::manage (new Gtk::HSeparator()); + hsep3->show (); + pack_start (*hsep3); + + curveEditorG = new CurveEditorGroup (); + curveEditorG->setCurveListener (this); + curveEditorG->setColorProvider (this); + + lshape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, "L"); + ashape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, "a"); + bshape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, "b"); + + // This will add the reset button at the end of the curveType buttons + curveEditorG->curveListComplete(); + + pack_start (*curveEditorG, Gtk::PACK_SHRINK, 4); + +} + +LCurve::~LCurve () { + delete curveEditorG; +} + +void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited) { + + disableListener (); + + if (pedited) { + brightness->setEditedState (pedited->labCurve.brightness ? Edited : UnEdited); + contrast->setEditedState (pedited->labCurve.contrast ? Edited : UnEdited); + saturation->setEditedState (pedited->labCurve.saturation ? Edited : UnEdited); + + //%%%%%%%%%%%%%%%%%%%%%% + saturationlimiter->setEditedState (pedited->labCurve.saturationlimit ? Edited : UnEdited); + avoidclip->set_inconsistent (!pedited->labCurve.avoidclip); + enablelimiter->set_inconsistent (!pedited->labCurve.enable_saturationlimiter); + //%%%%%%%%%%%%%%%%%%%%%% + + lshape->setUnChanged (!pedited->labCurve.lcurve); + ashape->setUnChanged (!pedited->labCurve.acurve); + bshape->setUnChanged (!pedited->labCurve.bcurve); + + } + + brightness->setValue (pp->labCurve.brightness); + contrast->setValue (pp->labCurve.contrast); + saturation->setValue (pp->labCurve.saturation); + + //%%%%%%%%%%%%%%%%%%%%%% + saturationlimiter->setValue (pp->labCurve.saturationlimit); + acconn.block (true); + avoidclip->set_active (pp->labCurve.avoidclip); + acconn.block (false); + elconn.block (true); + enablelimiter->set_active (pp->labCurve.enable_saturationlimiter); + elconn.block (false); + + //removeIfThere (this, saturationlimiter, false); + // if (enablelimiter->get_active () || enablelimiter->get_inconsistent()) + // pack_start (*saturationlimiter); + + lastACVal = pp->labCurve.avoidclip; + lastELVal = pp->labCurve.enable_saturationlimiter; + //%%%%%%%%%%%%%%%%%%%%%% + + lshape->setCurve (pp->labCurve.lcurve); + ashape->setCurve (pp->labCurve.acurve); + bshape->setCurve (pp->labCurve.bcurve); + + // Open up the first curve if selected + bool active = lshape->openIfNonlinear(); + if (!active) ashape->openIfNonlinear(); + if (!active) bshape->openIfNonlinear(); + + enableListener (); +} + +void LCurve::write (ProcParams* pp, ParamsEdited* pedited) { + + pp->labCurve.brightness = brightness->getValue (); + pp->labCurve.contrast = (int)contrast->getValue (); + pp->labCurve.saturation = (int)saturation->getValue (); + + //%%%%%%%%%%%%%%%%%%%%%% + pp->labCurve.avoidclip = avoidclip->get_active (); + pp->labCurve.enable_saturationlimiter = enablelimiter->get_active (); + pp->labCurve.saturationlimit = saturationlimiter->getValue (); + //%%%%%%%%%%%%%%%%%%%%%% + + pp->labCurve.lcurve = lshape->getCurve (); + pp->labCurve.acurve = ashape->getCurve (); + pp->labCurve.bcurve = bshape->getCurve (); + + if (pedited) { + pedited->labCurve.brightness = brightness->getEditedState (); + pedited->labCurve.contrast = contrast->getEditedState (); + pedited->labCurve.saturation = saturation->getEditedState (); + + //%%%%%%%%%%%%%%%%%%%%%% + pedited->labCurve.avoidclip = !avoidclip->get_inconsistent(); + pedited->labCurve.enable_saturationlimiter = !enablelimiter->get_inconsistent(); + pedited->labCurve.saturationlimit = saturationlimiter->getEditedState (); + //%%%%%%%%%%%%%%%%%%%%%% + + pedited->labCurve.lcurve = !lshape->isUnChanged (); + pedited->labCurve.acurve = !ashape->isUnChanged (); + pedited->labCurve.bcurve = !bshape->isUnChanged (); + } +} + +void LCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { + + brightness->setDefault (defParams->labCurve.brightness); + contrast->setDefault (defParams->labCurve.contrast); + saturation->setDefault (defParams->labCurve.saturation); + saturationlimiter->setDefault (defParams->labCurve.saturationlimit); + + if (pedited) { + brightness->setDefaultEditedState (pedited->labCurve.brightness ? Edited : UnEdited); + contrast->setDefaultEditedState (pedited->labCurve.contrast ? Edited : UnEdited); + saturation->setDefaultEditedState (pedited->labCurve.saturation ? Edited : UnEdited); + saturationlimiter->setDefaultEditedState (pedited->labCurve.saturationlimit ? Edited : UnEdited); + + } + else { + brightness->setDefaultEditedState (Irrelevant); + contrast->setDefaultEditedState (Irrelevant); + saturation->setDefaultEditedState (Irrelevant); + saturationlimiter->setDefaultEditedState (Irrelevant); + } +} + +//%%%%%%%%%%%%%%%%%%%%%% +//Clipping control changed +void LCurve::avoidclip_toggled () { + + if (batchMode) { + if (avoidclip->get_inconsistent()) { + avoidclip->set_inconsistent (false); + acconn.block (true); + avoidclip->set_active (false); + acconn.block (false); + } + else if (lastACVal) + avoidclip->set_inconsistent (true); + + lastACVal = avoidclip->get_active (); + } + + if (listener) { + if (avoidclip->get_active ()) + listener->panelChanged (EvLAvoidClip, M("GENERAL_ENABLED")); + else + listener->panelChanged (EvLAvoidClip, M("GENERAL_DISABLED")); + } +} + +void LCurve::enablelimiter_toggled () { + + if (batchMode) { + if (enablelimiter->get_inconsistent()) { + enablelimiter->set_inconsistent (false); + elconn.block (true); + enablelimiter->set_active (false); + elconn.block (false); + } + else if (lastELVal) + enablelimiter->set_inconsistent (true); + + lastELVal = enablelimiter->get_active (); + } + + //removeIfThere (this, saturationlimiter, false); + //if (enablelimiter->get_active () || enablelimiter->get_inconsistent()) + // pack_start (*saturationlimiter); + + if (listener) { + if (enablelimiter->get_active ()) + listener->panelChanged (EvLSatLimiter, M("GENERAL_ENABLED")); + else + listener->panelChanged (EvLSatLimiter, M("GENERAL_DISABLED")); + } +} +//%%%%%%%%%%%%%%%%%%%%%% + + +/* + * Curve listener + * + * If more than one curve has been added, the curve listener is automatically + * set to 'multi=true', and send a pointer of the modified curve in a parameter + */ +void LCurve::curveChanged (CurveEditor* ce) { + + if (listener) { + if (ce == lshape) + listener->panelChanged (EvLLCurve, M("HISTORY_CUSTOMCURVE")); + if (ce == ashape) + listener->panelChanged (EvLaCurve, M("HISTORY_CUSTOMCURVE")); + if (ce == bshape) + listener->panelChanged (EvLbCurve, M("HISTORY_CUSTOMCURVE")); + } +} + +void LCurve::adjusterChanged (Adjuster* a, double newval) { + + if (!listener) + return; + + Glib::ustring costr; + if (a==brightness) + costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), a->getValue()); + else if (a==saturationlimiter) + costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(1), a->getValue()); + else + costr = Glib::ustring::format ((int)a->getValue()); + + if (a==brightness) + listener->panelChanged (EvLBrightness, costr); + else if (a==contrast) + listener->panelChanged (EvLContrast, costr); + else if (a==saturation) + listener->panelChanged (EvLSaturation, costr); + else if (a==saturationlimiter) + listener->panelChanged (EvLSatLimit, costr); +} + +//attempt to hide unused channels +/*void LCurve::channel_changed () { + + removeIfThere (this, lcurve, false); + removeIfThere (this, acurve, false); + removeIfThere (this, bcurve, false); + + if (channel->get_active_row_number()==0) + pack_start (*lcurve); + else if (channel->get_active_row_number()==1) + pack_start (*acurve); + else if (method->get_active_row_number()==2) + pack_start (*bcurve); + + + if (listener && enabled->get_active ()) + listener->panelChanged (EvLabCurvetype, channel->get_active_text ()); + +}*/ + +void LCurve::colorForValue (double valX, double valY) { + + CurveEditor* ce = curveEditorG->getDisplayedCurve(); + + if (ce == lshape) { // L = f(L) + red = (double)valY; + green = (double)valY; + blue = (double)valY; + } + else if (ce == ashape) { // a = f(a) + // TODO: To be implemented + red = (double)valY; + green = (double)valY; + blue = (double)valY; + } + else if (ce == bshape) { // b = f(b) + red = (double)valY; + green = (double)valY; + blue = (double)valY; + } + else { + printf("Error: no curve displayed!\n"); + } + +} + +void LCurve::setBatchMode (bool batchMode) { + + ToolPanel::setBatchMode (batchMode); + brightness->showEditedCB (); + contrast->showEditedCB (); + saturation->showEditedCB (); + saturationlimiter->showEditedCB (); + + curveEditorG->setBatchMode (batchMode); +} + + +void LCurve::updateCurveBackgroundHistogram (LUTu & hist) { + + lshape->updateBackgroundHistogram (hist); +} + +void LCurve::setAdjusterBehavior (bool bradd, bool contradd, bool satadd) { + + brightness->setAddMode(bradd); + contrast->setAddMode(contradd); + saturation->setAddMode(satadd); +} + +void LCurve::trimValues (rtengine::procparams::ProcParams* pp) { + + brightness->trimValue(pp->labCurve.brightness); + contrast->trimValue(pp->labCurve.contrast); + saturation->trimValue(pp->labCurve.saturation); +} diff --git a/rtgui/labcurve.h b/rtgui/labcurve.h index a223eb38d..226b832e1 100644 --- a/rtgui/labcurve.h +++ b/rtgui/labcurve.h @@ -48,8 +48,6 @@ class LCurve : public Gtk::VBox, public AdjusterListener, public FoldableToolPan bool lastACVal, lastELVal; //%%%%%%%%%%%%%%%% - bool brAdd, contrAdd, satAdd; - public: LCurve (); @@ -59,7 +57,8 @@ class LCurve : public Gtk::VBox, public AdjusterListener, public FoldableToolPan void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); void setBatchMode (bool batchMode); - void setAdjusterBehavior (bool bradd, bool contradd, bool satadd); + void setAdjusterBehavior (bool bradd, bool contradd, bool satadd); + void trimValues (rtengine::procparams::ProcParams* pp); void curveChanged (CurveEditor* ce); void adjusterChanged (Adjuster* a, double newval); diff --git a/rtgui/options.cc b/rtgui/options.cc index 6f7104fd8..bfe76e4cb 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -140,11 +140,48 @@ void Options::setDefaults () { showProfileSelector = true; cutOverlayBrush = std::vector (4); - cutOverlayBrush[3] = 0.667; + cutOverlayBrush[3] = 0.667; // :-p sndLngEditProcDoneSecs=3.0; - int babehav[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0}; + int babehav[] = { + 1, // ADDSET_TC_EXPCOMP + 1, // ADDSET_TC_BRIGHTNESS + 1, // ADDSET_TC_BLACKLEVEL + 1, // ADDSET_TC_CONTRAST + 1, // ADDSET_SH_HIGHLIGHTS + 1, // ADDSET_SH_SHADOWS + 1, // ADDSET_SH_LOCALCONTRAST + 1, // ADDSET_LC_BRIGHTNESS + 1, // ADDSET_LC_CONTRAST + 0, // ADDSET_SHARP_AMOUNT + 0, // ADDSET_LD_EDGETOLERANCE + 1, // ADDSET_WB_TEMPERATURE + 1, // ADDSET_WB_GREEN + 0, // ADDSET_CBOOST_AMOUNT + 0, // ADDSET_CS_BLUEYELLOW + 0, // ADDSET_CS_GREENMAGENTA + 0, // ADDSET_ROTATE_DEGREE + 0, // ADDSET_DIST_AMOUNT + 0, // ADDSET_PERSPECTIVE + 0, // ADDSET_CA + 1, // ADDSET_VIGN_AMOUNT + 1, // ADDSET_LC_SATURATION + 1, // ADDSET_TC_SATURATION + 1, // ADDSET_TC_HLCOMPAMOUNT + 0, // ADDSET_TC_HLCOMPTHRESH + 1, // ADDSET_TC_SHCOMP + 1, // ADDSET_DIRPYREQ + 0, // ADDSET_DIRPYRDN_CHLUM + 0, // ADDSET_DIRPYRDN_GAMMA + 1, // ADDSET_CHMIXER + 1, // ADDSET_PREPROCESS_GREENEQUIL + 0, // ADDSET_PREPROCESS_LINEDENOISE + 0, // ADDSET_RAWCACORR + 1, // ADDSET_RAWEXPOS_LINEAR + 1, // ADDSET_RAWEXPOS_PRESER + 1 // ADDSET_RAWEXPOS_BLACKS + }; baBehav = std::vector (babehav, babehav+ADDSET_PARAM_NUM); rtSettings.dualThreadEnabled = true; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 06f25182e..9cb444602 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -1,520 +1,518 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include -#include -#include - -ParamsEdited::ParamsEdited () { - - set (false); -} - -void ParamsEdited::set (bool v) { - - toneCurve.curve = v; - toneCurve.brightness = v; - toneCurve.black = v; - toneCurve.contrast = v; - toneCurve.saturation = v; - toneCurve.shcompr = v; - toneCurve.hlcompr = v; - toneCurve.hlcomprthresh = v; - toneCurve.autoexp = v; - toneCurve.clip = v; - toneCurve.expcomp = v; - labCurve.lcurve = v; - labCurve.acurve = v; - labCurve.bcurve = v; - labCurve.brightness = v; - labCurve.contrast = v; - labCurve.saturation = v; - labCurve.avoidclip = v; - labCurve.enable_saturationlimiter = v; - labCurve.saturationlimit = v; - sharpening.enabled = v; - sharpening.radius = v; - sharpening.amount = v; - sharpening.threshold = v; - sharpening.edgesonly = v; - sharpening.edges_radius = v; - sharpening.edges_tolerance = v; - sharpening.halocontrol = v; - sharpening.halocontrol_amount= v; - sharpening.method = v; - sharpening.deconvamount = v; - sharpening.deconvradius = v; - sharpening.deconviter = v; - sharpening.deconvdamping = v; - colorBoost.amount = v; - colorBoost.avoidclip = v; - colorBoost.enable_saturationlimiter = v; - colorBoost.saturationlimit = v; - wb.method = v; - wb.green = v; - wb.temperature = v; - colorShift.a = v; - colorShift.b = v; - lumaDenoise.enabled = v; - lumaDenoise.radius = v; - lumaDenoise.edgetolerance = v; - colorDenoise.enabled = v; - colorDenoise.amount = v; - defringe.enabled = v; - defringe.radius = v; - defringe.threshold = v; - impulseDenoise.enabled = v; - impulseDenoise.thresh = v; - dirpyrDenoise.enabled = v; - dirpyrDenoise.luma = v; - dirpyrDenoise.chroma = v; - dirpyrDenoise.gamma = v; - sh.enabled = v; - sh.hq = v; - sh.highlights = v; - sh.htonalwidth = v; - sh.shadows = v; - sh.stonalwidth = v; - sh.localcontrast = v; - sh.radius = v; - crop.enabled = v; - crop.x = v; - crop.y = v; - crop.w = v; - crop.h = v; - crop.fixratio = v; - crop.ratio = v; - crop.orientation = v; - crop.guide = v; - coarse.rotate = v; - coarse.hflip = v; - coarse.vflip = v; - commonTrans.autofill = v; - rotate.degree = v; - distortion.uselensfun = v; - distortion.amount = v; - perspective.horizontal = v; - perspective.vertical = v; - cacorrection.red = v; - cacorrection.blue = v; - vignetting.amount = v; - vignetting.radius = v; - vignetting.strength = v; - vignetting.centerX = v; - vignetting.centerY = v; - chmixer.red[0] = v; - chmixer.red[1] = v; - chmixer.red[2] = v; - chmixer.green[0] = v; - chmixer.green[1] = v; - chmixer.green[2] = v; - chmixer.blue[0] = v; - chmixer.blue[1] = v; - chmixer.blue[2] = v; - hlrecovery.enabled = v; - hlrecovery.method = v; - resize.scale = v; - resize.appliesTo = v; - resize.method = v; - resize.dataspec = v; - resize.width = v; - resize.height = v; - resize.enabled = v; - icm.input = v; - icm.gammaOnInput = v; - icm.working = v; - icm.output = v; - icm.gamma = v; - icm.freegamma = v; - icm.gampos = v; - icm.slpos = v; - raw.ccSteps = v; - raw.dmethod = v; - raw.dcbIterations = v; - raw.dcbEnhance = v; - raw.dfAuto = v; - raw.caCorrection = v; - raw.hotDeadPixel = v; - raw.caBlue = v; - raw.caRed = v; - raw.darkFrame = v; - raw.exPos = v; - raw.exCorrection = v; - raw.exPreser = v; - raw.exBlackzero = v; - raw.exBlackone = v; - raw.exBlacktwo = v; - raw.exBlackthree = v; - raw.exTwoGreen=v; - raw.greenEq = v; - raw.linenoise = v; - raw.ff_file = v; - raw.ff_AutoSelect = v; - raw.ff_BlurRadius = v; - raw.ff_BlurType = v; - equalizer.enabled = v; - dirpyrequalizer.enabled = v; - for(int i = 0; i < 8; i++) { - equalizer.c[i] = v; - } - for(int i = 0; i < 5; i++) { - dirpyrequalizer.mult[i] = v; - } - hsvequalizer.hcurve = v; - hsvequalizer.scurve = v; - hsvequalizer.vcurve = v; - exif.clear (); - iptc.clear (); -} - -using namespace rtengine; -using namespace rtengine::procparams; - -void ParamsEdited::initFrom (const std::vector& src) { - - set (true); - if (src.size()==0) - return; - - const ProcParams& p = src[0]; - for (int i=1; i + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include +#include +#include + +ParamsEdited::ParamsEdited () { + + set (false); +} + +void ParamsEdited::set (bool v) { + + toneCurve.curve = v; + toneCurve.brightness = v; + toneCurve.black = v; + toneCurve.contrast = v; + toneCurve.saturation = v; + toneCurve.shcompr = v; + toneCurve.hlcompr = v; + toneCurve.hlcomprthresh = v; + toneCurve.autoexp = v; + toneCurve.clip = v; + toneCurve.expcomp = v; + labCurve.lcurve = v; + labCurve.acurve = v; + labCurve.bcurve = v; + labCurve.brightness = v; + labCurve.contrast = v; + labCurve.saturation = v; + labCurve.avoidclip = v; + labCurve.enable_saturationlimiter = v; + labCurve.saturationlimit = v; + sharpening.enabled = v; + sharpening.radius = v; + sharpening.amount = v; + sharpening.threshold = v; + sharpening.edgesonly = v; + sharpening.edges_radius = v; + sharpening.edges_tolerance = v; + sharpening.halocontrol = v; + sharpening.halocontrol_amount= v; + sharpening.method = v; + sharpening.deconvamount = v; + sharpening.deconvradius = v; + sharpening.deconviter = v; + sharpening.deconvdamping = v; + colorBoost.amount = v; + colorBoost.avoidclip = v; + colorBoost.enable_saturationlimiter = v; + colorBoost.saturationlimit = v; + wb.method = v; + wb.green = v; + wb.temperature = v; + colorShift.a = v; + colorShift.b = v; + lumaDenoise.enabled = v; + lumaDenoise.radius = v; + lumaDenoise.edgetolerance = v; + colorDenoise.enabled = v; + colorDenoise.amount = v; + defringe.enabled = v; + defringe.radius = v; + defringe.threshold = v; + impulseDenoise.enabled = v; + impulseDenoise.thresh = v; + dirpyrDenoise.enabled = v; + dirpyrDenoise.luma = v; + dirpyrDenoise.chroma = v; + dirpyrDenoise.gamma = v; + sh.enabled = v; + sh.hq = v; + sh.highlights = v; + sh.htonalwidth = v; + sh.shadows = v; + sh.stonalwidth = v; + sh.localcontrast = v; + sh.radius = v; + crop.enabled = v; + crop.x = v; + crop.y = v; + crop.w = v; + crop.h = v; + crop.fixratio = v; + crop.ratio = v; + crop.orientation = v; + crop.guide = v; + coarse.rotate = v; + coarse.hflip = v; + coarse.vflip = v; + commonTrans.autofill = v; + rotate.degree = v; + distortion.uselensfun = v; + distortion.amount = v; + perspective.horizontal = v; + perspective.vertical = v; + cacorrection.red = v; + cacorrection.blue = v; + vignetting.amount = v; + vignetting.radius = v; + vignetting.strength = v; + vignetting.centerX = v; + vignetting.centerY = v; + chmixer.red[0] = v; + chmixer.red[1] = v; + chmixer.red[2] = v; + chmixer.green[0] = v; + chmixer.green[1] = v; + chmixer.green[2] = v; + chmixer.blue[0] = v; + chmixer.blue[1] = v; + chmixer.blue[2] = v; + hlrecovery.enabled = v; + hlrecovery.method = v; + resize.scale = v; + resize.appliesTo = v; + resize.method = v; + resize.dataspec = v; + resize.width = v; + resize.height = v; + resize.enabled = v; + icm.input = v; + icm.gammaOnInput = v; + icm.working = v; + icm.output = v; + icm.gamma = v; + icm.freegamma = v; + icm.gampos = v; + icm.slpos = v; + raw.ccSteps = v; + raw.dmethod = v; + raw.dcbIterations = v; + raw.dcbEnhance = v; + raw.dfAuto = v; + raw.caCorrection = v; + raw.hotDeadPixel = v; + raw.caBlue = v; + raw.caRed = v; + raw.darkFrame = v; + raw.exPos = v; + raw.exCorrection = v; + raw.exPreser = v; + raw.exBlackzero = v; + raw.exBlackone = v; + raw.exBlacktwo = v; + raw.exBlackthree = v; + raw.exTwoGreen=v; + raw.greenEq = v; + raw.linenoise = v; + raw.ff_file = v; + raw.ff_AutoSelect = v; + raw.ff_BlurRadius = v; + raw.ff_BlurType = v; + equalizer.enabled = v; + dirpyrequalizer.enabled = v; + for(int i = 0; i < 8; i++) { + equalizer.c[i] = v; + } + for(int i = 0; i < 5; i++) { + dirpyrequalizer.mult[i] = v; + } + hsvequalizer.hcurve = v; + hsvequalizer.scurve = v; + hsvequalizer.vcurve = v; + exif.clear (); + iptc.clear (); +} + +using namespace rtengine; +using namespace rtengine::procparams; + +void ParamsEdited::initFrom (const std::vector& src) { + + set (true); + if (src.size()==0) + return; + + const ProcParams& p = src[0]; + for (int i=1; i& src); - void combine (rtengine::procparams::ProcParams& toEdit, const rtengine::procparams::ProcParams& mods); + void combine (rtengine::procparams::ProcParams& toEdit, const rtengine::procparams::ProcParams& mods, bool forceSet); bool operator== (const ParamsEdited& other); bool operator!= (const ParamsEdited& other); diff --git a/rtgui/perspective.cc b/rtgui/perspective.cc index 31ef3f4bb..8d1d8cd4e 100644 --- a/rtgui/perspective.cc +++ b/rtgui/perspective.cc @@ -21,7 +21,7 @@ using namespace rtengine; using namespace rtengine::procparams; -PerspCorrection::PerspCorrection () : Gtk::VBox(), FoldableToolPanel(this), vAdd(false) { +PerspCorrection::PerspCorrection () : Gtk::VBox(), FoldableToolPanel(this) { horiz = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_HORIZONTAL"), -100, 100, 1, 0)); horiz->setAdjusterListener (this); @@ -84,12 +84,14 @@ void PerspCorrection::adjusterChanged (Adjuster* a, double newval) { void PerspCorrection::setAdjusterBehavior (bool badd) { - if ((!vAdd && badd) || (vAdd && !badd)) { -// horiz->setLimits (-0.005, 0.005, 0.0001, 0); -// vert->setLimits (-0.005, 0.005, 0.0001, 0); - } + horiz->setAddMode(badd); + vert->setAddMode(badd); +} - vAdd = badd; +void PerspCorrection::trimValues (rtengine::procparams::ProcParams* pp) { + + horiz->trimValue(pp->perspective.horizontal); + vert->trimValue(pp->perspective.vertical); } void PerspCorrection::setBatchMode (bool batchMode) { diff --git a/rtgui/perspective.h b/rtgui/perspective.h index d575f1e5b..07a3ff38a 100644 --- a/rtgui/perspective.h +++ b/rtgui/perspective.h @@ -28,7 +28,6 @@ class PerspCorrection : public Gtk::VBox, public AdjusterListener, public Foldab protected: Adjuster* horiz; Adjuster* vert; - bool vAdd; public: @@ -41,6 +40,7 @@ class PerspCorrection : public Gtk::VBox, public AdjusterListener, public Foldab void adjusterChanged (Adjuster* a, double newval); void setAdjusterBehavior (bool badd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 14f8955fc..22e2c4ce4 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -138,6 +138,9 @@ Gtk::Widget* Preferences::getBatchProcPanel () { // fill model Gtk::TreeModel::iterator mi, ci; + /* + * The TRUE/FALSE values of appendBehavList are replaced by the one defined in options.cc, + */ mi = behModel->append (); mi->set_value (behavColumns.label, M("TP_EXPOSURE_LABEL")); appendBehavList (mi, M("TP_EXPOSURE_EXPCOMP"), ADDSET_TC_EXPCOMP, false); @@ -169,11 +172,20 @@ Gtk::Widget* Preferences::getBatchProcPanel () { //mi->set_value (behavColumns.label, M("TP_LUMADENOISE_LABEL")); //appendBehavList (mi, M("TP_LUMADENOISE_EDGETOLERANCE"), ADDSET_LD_EDGETOLERANCE, true); + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_DIRPYRDENOISE_LABEL")); + appendBehavList (mi, M("TP_DIRPYRDENOISE_LUMA")+", "+M("TP_DIRPYRDENOISE_CHROMA"), ADDSET_DIRPYRDN_CHLUM, true); + appendBehavList (mi, M("TP_DIRPYRDENOISE_GAMMA"), ADDSET_DIRPYRDN_GAMMA, true); + mi = behModel->append (); mi->set_value (behavColumns.label, M("TP_WBALANCE_LABEL")); appendBehavList (mi, M("TP_WBALANCE_TEMPERATURE"), ADDSET_WB_TEMPERATURE, true); appendBehavList (mi, M("TP_WBALANCE_GREEN"), ADDSET_WB_GREEN, true); + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_CHMIXER_LABEL")); + appendBehavList (mi, M("TP_CHMIXER_RED")+", "+M("TP_CHMIXER_GREEN")+", "+M("TP_CHMIXER_BLUE"), ADDSET_CHMIXER, false); + //mi = behModel->append (); //mi->set_value (behavColumns.label, M("TP_COLORBOOST_LABEL")); //appendBehavList (mi, M("TP_COLORBOOST_AMOUNT"), ADDSET_CBOOST_AMOUNT, false); @@ -203,6 +215,25 @@ Gtk::Widget* Preferences::getBatchProcPanel () { mi->set_value (behavColumns.label, M("TP_VIGNETTING_LABEL")); appendBehavList (mi, M("TP_VIGNETTING_AMOUNT"), ADDSET_VIGN_AMOUNT, false); + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_DIRPYREQUALIZER_LABEL")); + appendBehavList (mi, M("TP_EXPOSURE_CONTRAST")+", "+M("TP_DIRPYREQUALIZER_THRESHOLD"), ADDSET_DIRPYREQ, true); + + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_PREPROCESS_LABEL")); + appendBehavList (mi, M("TP_PREPROCESS_GREENEQUIL"), ADDSET_PREPROCESS_GREENEQUIL, false); + appendBehavList (mi, M("TP_PREPROCESS_LINEDENOISE"), ADDSET_PREPROCESS_LINEDENOISE, true); + + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_EXPOSCORR_LABEL")); + appendBehavList (mi, M("TP_RAWEXPOS_LINEAR"), ADDSET_RAWEXPOS_LINEAR, false); + appendBehavList (mi, M("TP_RAWEXPOS_PRESER"), ADDSET_RAWEXPOS_PRESER, false); + appendBehavList (mi, M("TP_RAWEXPOS_BLACKS"), ADDSET_RAWEXPOS_BLACKS, false); + + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_CHROMATABERR_LABEL")); + appendBehavList (mi, M("TP_RAWCACORR_CARED")+", "+M("TP_RAWCACORR_CABLUE"), ADDSET_RAWCACORR, true); + behTreeView->expand_all (); chOverwriteOutputFile = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_OVERWRITEOUTPUTFILE")) ); diff --git a/rtgui/preprocess.cc b/rtgui/preprocess.cc index 7d5cbceb9..ac7ee6834 100644 --- a/rtgui/preprocess.cc +++ b/rtgui/preprocess.cc @@ -136,3 +136,15 @@ void PreProcess::hotDeadPixelChanged () if (listener) listener->panelChanged (EvPreProcessHotDeadPixel, hotDeadPixel->get_active()?M("GENERAL_ENABLED"):M("GENERAL_DISABLED")); } + +void PreProcess::setAdjusterBehavior (bool linedenoiseadd, bool greenequiladd) { + + lineDenoise->setAddMode(linedenoiseadd); + greenEqThreshold->setAddMode(greenequiladd); +} + +void PreProcess::trimValues (rtengine::procparams::ProcParams* pp) { + + lineDenoise->trimValue(pp->raw.linenoise); + greenEqThreshold->trimValue(pp->raw.greenthresh); +} diff --git a/rtgui/preprocess.h b/rtgui/preprocess.h index 5252c41fb..cf1d0107a 100644 --- a/rtgui/preprocess.h +++ b/rtgui/preprocess.h @@ -46,6 +46,8 @@ class PreProcess : public Gtk::VBox, public AdjusterListener, public FoldableToo void adjusterChanged (Adjuster* a, double newval); void hotDeadPixelChanged(); + void setAdjusterBehavior (bool linedenoiseadd, bool greenequiladd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/rawcacorrection.cc b/rtgui/rawcacorrection.cc index 5b3efe17f..a01778edf 100644 --- a/rtgui/rawcacorrection.cc +++ b/rtgui/rawcacorrection.cc @@ -157,3 +157,15 @@ void RAWCACorr::caCorrectionChanged() if (listener) listener->panelChanged (EvPreProcessAutoCA, caAutocorrect->get_active()?M("GENERAL_ENABLED"):M("GENERAL_DISABLED")); } + +void RAWCACorr::setAdjusterBehavior (bool caadd) { + + caRed->setAddMode(caadd); + caBlue->setAddMode(caadd); +} + +void RAWCACorr::trimValues (rtengine::procparams::ProcParams* pp) { + + caRed->trimValue(pp->raw.cared); + caBlue->trimValue(pp->raw.cablue); +} diff --git a/rtgui/rawcacorrection.h b/rtgui/rawcacorrection.h index 868361a38..b61597026 100644 --- a/rtgui/rawcacorrection.h +++ b/rtgui/rawcacorrection.h @@ -37,10 +37,12 @@ public: RAWCACorr (); - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); - void setBatchMode (bool batchMode); - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void setAdjusterBehavior (bool caadd); + void trimValues (rtengine::procparams::ProcParams* pp); void adjusterChanged (Adjuster* a, double newval); void caCorrectionChanged (); diff --git a/rtgui/rawexposure.cc b/rtgui/rawexposure.cc index df7825468..7afe6318d 100644 --- a/rtgui/rawexposure.cc +++ b/rtgui/rawexposure.cc @@ -209,3 +209,23 @@ void RAWExposure::setDefaults(const rtengine::procparams::ProcParams* defParams, } } + +void RAWExposure::setAdjusterBehavior (bool pexposadd, bool pexpreseradd, bool pexblackadd) { + + PexPos->setAddMode(pexposadd); + PexPreser->setAddMode(pexpreseradd); + PexBlackzero->setAddMode(pexblackadd); + PexBlackone->setAddMode(pexblackadd); + PexBlacktwo->setAddMode(pexblackadd); + PexBlackthree->setAddMode(pexblackadd); +} + +void RAWExposure::trimValues (rtengine::procparams::ProcParams* pp) { + + PexPos->trimValue(pp->raw.expos); + PexPreser->trimValue(pp->raw.preser); + PexBlackzero->trimValue(pp->raw.blackzero); + PexBlackone->trimValue(pp->raw.blackone); + PexBlacktwo->trimValue(pp->raw.blacktwo); + PexBlackthree->trimValue(pp->raw.blackthree); +} diff --git a/rtgui/rawexposure.h b/rtgui/rawexposure.h index 452ce96ce..706c7c242 100644 --- a/rtgui/rawexposure.h +++ b/rtgui/rawexposure.h @@ -48,7 +48,9 @@ public: void setBatchMode (bool batchMode); void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); void GreenChanged() ; - void adjusterChanged (Adjuster* a, double newval); + void adjusterChanged (Adjuster* a, double newval); + void setAdjusterBehavior (bool pexposadd, bool pexpreseradd, bool pexblackadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/rotate.cc b/rtgui/rotate.cc index 809139757..cd7c8ef9b 100644 --- a/rtgui/rotate.cc +++ b/rtgui/rotate.cc @@ -25,7 +25,7 @@ extern Glib::ustring argv0; using namespace rtengine; using namespace rtengine::procparams; -Rotate::Rotate () : Gtk::VBox(), FoldableToolPanel(this), degAdd(false) { +Rotate::Rotate () : Gtk::VBox(), FoldableToolPanel(this) { rlistener = NULL; @@ -99,10 +99,12 @@ void Rotate::setBatchMode (bool batchMode) { degree->showEditedCB (); } -void Rotate::setAdjusterBehavior (bool brotadd) { +void Rotate::setAdjusterBehavior (bool rotadd) { - if ((!degAdd && brotadd) || (degAdd && !brotadd)) - degree->setLimits (-45, 45, 0.01, 0); - - degAdd = brotadd; + degree->setAddMode(rotadd); +} + +void Rotate::trimValues (rtengine::procparams::ProcParams* pp) { + + degree->trimValue(pp->rotate.degree); } diff --git a/rtgui/rotate.h b/rtgui/rotate.h index 65bc229a7..a0831e0a1 100644 --- a/rtgui/rotate.h +++ b/rtgui/rotate.h @@ -30,7 +30,6 @@ class Rotate : public Gtk::VBox, public AdjusterListener, public FoldableToolPan Adjuster* degree; Gtk::Button* selectStraight; LensGeomListener* rlistener; - bool degAdd; public: @@ -44,7 +43,8 @@ class Rotate : public Gtk::VBox, public AdjusterListener, public FoldableToolPan void straighten (double deg); void adjusterChanged (Adjuster* a, double newval); - void setAdjusterBehavior (bool brotadd); + void setAdjusterBehavior (bool rotadd); + void trimValues (rtengine::procparams::ProcParams* pp); void selectStraightPressed (); void setLensGeomListener (LensGeomListener* l) { rlistener = l; } }; diff --git a/rtgui/shadowshighlights.cc b/rtgui/shadowshighlights.cc index 9d20e34c8..55dd8645f 100644 --- a/rtgui/shadowshighlights.cc +++ b/rtgui/shadowshighlights.cc @@ -233,22 +233,14 @@ void ShadowsHighlights::setBatchMode (bool batchMode) { void ShadowsHighlights::setAdjusterBehavior (bool hadd, bool sadd, bool lcadd) { - if (!hAdd && hadd) - highlights->setLimits (-100, 100, 1, 0); - else if (hAdd && !hadd) - highlights->setLimits (0, 100, 1, 0); - - if (!sAdd && sadd) - shadows->setLimits (-100, 100, 1, 0); - else if (sAdd && !sadd) - shadows->setLimits (0, 100, 1, 0); - - if (!lcAdd && lcadd) - lcontrast->setLimits (-100, 100, 1, 0); - else if (lcAdd && !lcadd) - lcontrast->setLimits (0, 100, 1, 0); - - hAdd = hadd; - sAdd = sadd; - lcAdd = lcadd; + highlights->setAddMode(hadd); + shadows->setAddMode(sadd); + lcontrast->setAddMode(lcadd); +} + +void ShadowsHighlights::trimValues (rtengine::procparams::ProcParams* pp) { + + highlights->trimValue(pp->sh.highlights); + shadows->trimValue(pp->sh.shadows); + lcontrast->trimValue(pp->sh.localcontrast); } diff --git a/rtgui/shadowshighlights.h b/rtgui/shadowshighlights.h index 6bfc87327..98e993d2e 100644 --- a/rtgui/shadowshighlights.h +++ b/rtgui/shadowshighlights.h @@ -34,7 +34,6 @@ class ShadowsHighlights : public Gtk::VBox, public AdjusterListener, public Fold Adjuster* radius; Gtk::CheckButton* enabled; Gtk::CheckButton* hq; - bool hAdd, sAdd, lcAdd; bool lastEnabled, lastHQ; sigc::connection enaConn, hqConn; @@ -52,6 +51,7 @@ class ShadowsHighlights : public Gtk::VBox, public AdjusterListener, public Fold void hqChanged (); void setAdjusterBehavior (bool hadd, bool sadd, bool lcadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/sharpening.cc b/rtgui/sharpening.cc index 05eb57517..813028279 100644 --- a/rtgui/sharpening.cc +++ b/rtgui/sharpening.cc @@ -447,15 +447,14 @@ void Sharpening::setBatchMode (bool batchMode) { method->append_text (M("GENERAL_UNCHANGED")); } -void Sharpening::setAdjusterBehavior (bool bamountadd) { +void Sharpening::setAdjusterBehavior (bool amountadd) { - if (!amountAdd && bamountadd) { - amount->setLimits (-100, 100, 1, 0); - damount->setLimits (-100, 100, 1, 0); - } - else if (amountAdd && !bamountadd) { - amount->setLimits (1, 1000, 1, 150); - damount->setLimits (0, 100, 1, 75); - } - amountAdd = bamountadd; + amount->setAddMode(amountadd); + damount->setAddMode(amountadd); +} + +void Sharpening::trimValues (rtengine::procparams::ProcParams* pp) { + + amount->trimValue(pp->sharpening.amount); + damount->trimValue(pp->sharpening.deconvamount); } diff --git a/rtgui/sharpening.h b/rtgui/sharpening.h index 49efa72a3..82f4774d3 100644 --- a/rtgui/sharpening.h +++ b/rtgui/sharpening.h @@ -53,7 +53,6 @@ class Sharpening : public Gtk::VBox, public AdjusterListener, public FoldableToo Gtk::CheckButton* halocontrol; bool lastHaloControl; sigc::connection hcConn; - bool amountAdd; @@ -73,7 +72,8 @@ class Sharpening : public Gtk::VBox, public AdjusterListener, public FoldableToo void halocontrol_toggled (); void method_changed (); - void setAdjusterBehavior (bool bamountadd); + void setAdjusterBehavior (bool amountadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/tonecurve.cc b/rtgui/tonecurve.cc index c2bfc6b87..0ac88d03e 100644 --- a/rtgui/tonecurve.cc +++ b/rtgui/tonecurve.cc @@ -1,405 +1,398 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include -#include -#include -#include - -using namespace rtengine; -using namespace rtengine::procparams; - -ToneCurve::ToneCurve () : Gtk::VBox(), FoldableToolPanel(this), expAdd(false),hlcompAdd(false),hlcompthreshAdd(false), blackAdd(false), shcompAdd(false), brAdd(false), contrAdd(false) { - -//----------- Auto Levels ---------------------------------- - abox = Gtk::manage (new Gtk::HBox ()); - abox->set_border_width (2); - - autolevels = Gtk::manage (new Gtk::ToggleButton (M("TP_EXPOSURE_AUTOLEVELS"))); - autoconn = autolevels->signal_toggled().connect( sigc::mem_fun(*this, &ToneCurve::autolevels_toggled) ); - - sclip = Gtk::manage (new Gtk::SpinButton ()); - sclip->set_range (0.0, 0.9999); - sclip->set_increments (0.001, 0.01); - sclip->set_value (0.002); - sclip->set_digits (4); - sclip->signal_value_changed().connect( sigc::mem_fun(*this, &ToneCurve::clip_changed) ); - - abox->pack_start (*autolevels); - abox->pack_end (*sclip); - abox->pack_end (*Gtk::manage (new Gtk::Label (M("TP_EXPOSURE_CLIP")))); - pack_start (*abox); - - pack_start (*Gtk::manage (new Gtk::HSeparator())); - -//----------- Exposure Compensation ------------------------ - expcomp = Gtk::manage (new Adjuster (M("TP_EXPOSURE_EXPCOMP"), -5, 10, 0.05, 0)); - pack_start (*expcomp); - hlcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRHIGHLIGHTS"), 0, 100, 1, 70)); - pack_start (*hlcompr); - hlcomprthresh = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRHIGHLIGHTSTHRESHOLD"), 0, 100, 1, 0)); - pack_start (*hlcomprthresh); - -//----------- Black Level ---------------------------------- - black = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BLACKLEVEL"), -16384, 32768, 50, 0)); - pack_start (*black); - shcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 50)); - pack_start (*shcompr); - - pack_start (*Gtk::manage (new Gtk::HSeparator())); - -//---------Brightness / Contrast ------------------------- - brightness = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BRIGHTNESS"), -100, 100, 1, 0)); - pack_start (*brightness); - contrast = Gtk::manage (new Adjuster (M("TP_EXPOSURE_CONTRAST"), -100, 100, 1, 0)); - pack_start (*contrast); - saturation = Gtk::manage (new Adjuster (M("TP_EXPOSURE_SATURATION"), -100, 100, 1, 0)); - pack_start (*saturation); - -//----------- Curve ------------------------------ - pack_start (*Gtk::manage (new Gtk::HSeparator())); - - curveEditorG = new CurveEditorGroup (M("TP_EXPOSURE_CURVEEDITOR")); - curveEditorG->setCurveListener (this); - - shape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, ""); - - // This will add the reset button at the end of the curveType buttons - curveEditorG->curveListComplete(); - - pack_start (*curveEditorG, Gtk::PACK_SHRINK, 4); - - //curveEditorG->show(); - -// --------- Set Up Listeners ------------- - expcomp->setAdjusterListener (this); - brightness->setAdjusterListener (this); - black->setAdjusterListener (this); - hlcompr->setAdjusterListener (this); - hlcomprthresh->setAdjusterListener (this); - shcompr->setAdjusterListener (this); - contrast->setAdjusterListener (this); - saturation->setAdjusterListener (this); -} - -void ToneCurve::read (const ProcParams* pp, const ParamsEdited* pedited) { - - disableListener (); - - if (pedited) { - expcomp->setEditedState (pedited->toneCurve.expcomp ? Edited : UnEdited); - black->setEditedState (pedited->toneCurve.black ? Edited : UnEdited); - hlcompr->setEditedState (pedited->toneCurve.hlcompr ? Edited : UnEdited); - hlcomprthresh->setEditedState (pedited->toneCurve.hlcomprthresh ? Edited : UnEdited); - shcompr->setEditedState (pedited->toneCurve.shcompr ? Edited : UnEdited); - brightness->setEditedState (pedited->toneCurve.brightness ? Edited : UnEdited); - contrast->setEditedState (pedited->toneCurve.contrast ? Edited : UnEdited); - saturation->setEditedState (pedited->toneCurve.saturation ? Edited : UnEdited); - autolevels->set_inconsistent (!pedited->toneCurve.autoexp); - clipDirty = pedited->toneCurve.clip; - shape->setUnChanged (!pedited->toneCurve.curve); - } - - autoconn.block (true); - autolevels->set_active (pp->toneCurve.autoexp); - autoconn.block (false); - lastAuto = pp->toneCurve.autoexp; - sclip->set_value (pp->toneCurve.clip); - - expcomp->setValue (pp->toneCurve.expcomp); - black->setValue (pp->toneCurve.black); - hlcompr->setValue (pp->toneCurve.hlcompr); - hlcomprthresh->setValue (pp->toneCurve.hlcomprthresh); - shcompr->setValue (pp->toneCurve.shcompr); - if (!blackAdd) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect - brightness->setValue (pp->toneCurve.brightness); - contrast->setValue (pp->toneCurve.contrast); - saturation->setValue (pp->toneCurve.saturation); - shape->setCurve (pp->toneCurve.curve); - - shape->openIfNonlinear(); - - enableListener (); -} - -void ToneCurve::write (ProcParams* pp, ParamsEdited* pedited) { - - pp->toneCurve.autoexp = autolevels->get_active(); - pp->toneCurve.clip = sclip->get_value (); - pp->toneCurve.expcomp = expcomp->getValue (); - pp->toneCurve.black = (int)black->getValue (); - pp->toneCurve.hlcompr = (int)hlcompr->getValue (); - pp->toneCurve.hlcomprthresh = (int)hlcomprthresh->getValue (); - pp->toneCurve.shcompr = (int)shcompr->getValue (); - pp->toneCurve.brightness = (int)brightness->getValue (); - pp->toneCurve.contrast = (int)contrast->getValue (); - pp->toneCurve.saturation = (int)saturation->getValue (); - pp->toneCurve.curve = shape->getCurve (); - - if (pedited) { - pedited->toneCurve.expcomp = expcomp->getEditedState (); - pedited->toneCurve.black = black->getEditedState (); - pedited->toneCurve.hlcompr = hlcompr->getEditedState (); - pedited->toneCurve.hlcomprthresh = hlcomprthresh->getEditedState (); - pedited->toneCurve.shcompr = shcompr->getEditedState (); - pedited->toneCurve.brightness = brightness->getEditedState (); - pedited->toneCurve.contrast = contrast->getEditedState (); - pedited->toneCurve.saturation = saturation->getEditedState (); - pedited->toneCurve.autoexp = !autolevels->get_inconsistent(); - pedited->toneCurve.clip = clipDirty; - pedited->toneCurve.curve = !shape->isUnChanged (); - } -} - -void ToneCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { - - expcomp->setDefault (defParams->toneCurve.expcomp); - brightness->setDefault (defParams->toneCurve.brightness); - black->setDefault (defParams->toneCurve.black); - hlcompr->setDefault (defParams->toneCurve.hlcompr); - hlcomprthresh->setDefault (defParams->toneCurve.hlcomprthresh); - shcompr->setDefault (defParams->toneCurve.shcompr); - contrast->setDefault (defParams->toneCurve.contrast); - saturation->setDefault (defParams->toneCurve.saturation); - - if (pedited) { - expcomp->setDefaultEditedState (pedited->toneCurve.expcomp ? Edited : UnEdited); - black->setDefaultEditedState (pedited->toneCurve.black ? Edited : UnEdited); - hlcompr->setDefaultEditedState (pedited->toneCurve.hlcompr ? Edited : UnEdited); - hlcomprthresh->setDefaultEditedState (pedited->toneCurve.hlcomprthresh ? Edited : UnEdited); - shcompr->setDefaultEditedState (pedited->toneCurve.shcompr ? Edited : UnEdited); - brightness->setDefaultEditedState (pedited->toneCurve.brightness ? Edited : UnEdited); - contrast->setDefaultEditedState (pedited->toneCurve.contrast ? Edited : UnEdited); - saturation->setDefaultEditedState (pedited->toneCurve.saturation ? Edited : UnEdited); - } - else { - expcomp->setDefaultEditedState (Irrelevant); - black->setDefaultEditedState (Irrelevant); - hlcompr->setDefaultEditedState (Irrelevant); - hlcomprthresh->setDefaultEditedState (Irrelevant); - shcompr->setDefaultEditedState (Irrelevant); - brightness->setDefaultEditedState (Irrelevant); - contrast->setDefaultEditedState (Irrelevant); - saturation->setDefaultEditedState (Irrelevant); - } -} - -void ToneCurve::curveChanged () { - - if (listener) listener->panelChanged (EvToneCurve, M("HISTORY_CUSTOMCURVE")); -} - -void ToneCurve::adjusterChanged (Adjuster* a, double newval) { - - // Switch off auto exposure if user changes sliders manually - if (autolevels->get_active() && (a==expcomp || a==black)) { - autolevels->set_active (false); - autolevels->set_inconsistent (false); - } - - if (!listener) - return; - - Glib::ustring costr; - if (a==expcomp) - costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), a->getValue()); - else - costr = Glib::ustring::format ((int)a->getValue()); - - if (a==expcomp) - listener->panelChanged (EvExpComp, costr); - else if (a==brightness) - listener->panelChanged (EvBrightness, costr); - else if (a==black){ - listener->panelChanged (EvBlack, costr); - if (!blackAdd) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect - } - else if (a==contrast) - listener->panelChanged (EvContrast, costr); - else if (a==saturation) - listener->panelChanged (EvSaturation, costr); - else if (a==hlcompr) - listener->panelChanged (EvHLCompr, costr); - else if (a==hlcomprthresh) - listener->panelChanged (EvHLComprThreshold, costr); - else if (a==shcompr) - listener->panelChanged (EvSHCompr, costr); -} - -void ToneCurve::autolevels_toggled () { - - if (batchMode) { - if (autolevels->get_inconsistent()) { - autolevels->set_inconsistent (false); - autoconn.block (true); - autolevels->set_active (false); - autoconn.block (false); - } - else if (lastAuto) - autolevels->set_inconsistent (true); - - lastAuto = autolevels->get_active (); - } - - if (!batchMode && autolevels->get_active() && listener) { - listener->panelChanged (EvAutoExp, M("GENERAL_ENABLED")); - waitForAutoExp (); - if (!blackAdd) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect - } - - if (batchMode) { - expcomp->setEditedState (UnEdited); - black->setEditedState (UnEdited); - if (expAdd) - expcomp->setValue (0); - if (blackAdd) - black->setValue (0); - listener->panelChanged (EvAutoExp, M("GENERAL_ENABLED")); - } -} - -void ToneCurve::clip_changed () { - - clipDirty = true; - if (autolevels->get_active() && listener) - Glib::signal_idle().connect (sigc::mem_fun(*this, &ToneCurve::clip_changed_)); -} - -bool ToneCurve::clip_changed_ () { - - if (listener) { - listener->panelChanged (EvClip, Glib::ustring::format (std::setprecision(5), sclip->get_value())); - if (!batchMode) - waitForAutoExp (); - } - return false; -} - -void ToneCurve::waitForAutoExp () { - - sclip->set_sensitive (false); - expcomp->setEnabled (false); - brightness->setEnabled (false); - black->setEnabled (false); - hlcompr->setEnabled (false); - hlcomprthresh->setEnabled (false); - shcompr->setEnabled (false); - contrast->setEnabled (false); - saturation->setEnabled (false); - curveEditorG->set_sensitive (false); -} - -int aexpcomputed (void* data) { - - gdk_threads_enter(); - ((ToneCurve*)data)->autoExpComputed_ (); - gdk_threads_leave(); - return 0; -} - -void ToneCurve::autoExpChanged (double expcomp, int black) { - - nextBlack = black; - nextExpcomp = expcomp; - g_idle_add (aexpcomputed, this); - -// Glib::signal_idle().connect (sigc::mem_fun(*this, &ToneCurve::autoExpComputed_)); -} - -void ToneCurve::enableAll () { - - sclip->set_sensitive (true); - expcomp->setEnabled (true); - brightness->setEnabled (true); - black->setEnabled (true); - hlcompr->setEnabled (true); - hlcomprthresh->setEnabled (true); - shcompr->setEnabled (true); - contrast->setEnabled (true); - saturation->setEnabled (true); - curveEditorG->set_sensitive (true); -} - -bool ToneCurve::autoExpComputed_ () { - - disableListener (); - enableAll (); - expcomp->setValue (nextExpcomp); - black->setValue (nextBlack); - if (!blackAdd) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect - enableListener (); - - return false; -} - -void ToneCurve::setBatchMode (bool batchMode) { - - removeIfThere (abox, autolevels, false); - autolevels = Gtk::manage (new Gtk::CheckButton (M("TP_EXPOSURE_AUTOLEVELS"))); - autoconn = autolevels->signal_toggled().connect( sigc::mem_fun(*this, &ToneCurve::autolevels_toggled) ); - abox->pack_start (*autolevels); - - ToolPanel::setBatchMode (batchMode); - expcomp->showEditedCB (); - black->showEditedCB (); - hlcompr->showEditedCB (); - hlcomprthresh->showEditedCB (); - shcompr->showEditedCB (); - brightness->showEditedCB (); - contrast->showEditedCB (); - saturation->showEditedCB (); - - curveEditorG->setBatchMode (batchMode); -} - -void ToneCurve::setAdjusterBehavior (bool expadd, bool hlcompadd, bool hlcompthreshadd, bool bradd, bool blackadd, bool shcompadd, bool contradd, bool satadd) { - - if ((!expAdd && expadd) || (expAdd && !expadd)) - expcomp->setLimits (-5, 5, 0.01, 0); - if ((!hlcompAdd && hlcompadd) || (hlcompAdd && !hlcompadd)) - hlcompr->setLimits (0, 100, 1, 0); - if ((!hlcompthreshAdd && hlcompthreshadd) || (hlcompthreshAdd && !hlcompthreshadd)) - hlcomprthresh->setLimits (0, 100, 1, 0); - if (!blackAdd && blackadd) - black->setLimits (0, 16384, 1, 0); - else if (blackAdd && !blackadd) - black->setLimits (0, 32768, 1, 0); - if ((!shcompAdd && shcompadd) || (shcompAdd && !shcompadd)) - shcompr->setLimits (0, 100, 1, 0); - if ((!brAdd && bradd) || (brAdd && !bradd)) - brightness->setLimits (-100, 100, 1, 0); - if ((!contrAdd && contradd) || (contrAdd && !contradd)) - contrast->setLimits (-100, 100, 1, 0); - if ((!satAdd && satadd) || (satAdd && !satadd)) - saturation->setLimits (-100, 100, 1, 0); - - expAdd = expadd; - hlcompAdd = hlcompadd; - hlcompthreshAdd = hlcompthreshadd; - blackAdd = blackadd; - shcompAdd = shcompadd; - brAdd = bradd; - contrAdd = contradd; - satAdd = satadd; -} - -void ToneCurve::updateCurveBackgroundHistogram (LUTu & hist) { - - shape->updateBackgroundHistogram (hist); -} +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include +#include +#include +#include + +using namespace rtengine; +using namespace rtengine::procparams; + +ToneCurve::ToneCurve () : Gtk::VBox(), FoldableToolPanel(this) { + +//----------- Auto Levels ---------------------------------- + abox = Gtk::manage (new Gtk::HBox ()); + abox->set_border_width (2); + + autolevels = Gtk::manage (new Gtk::ToggleButton (M("TP_EXPOSURE_AUTOLEVELS"))); + autoconn = autolevels->signal_toggled().connect( sigc::mem_fun(*this, &ToneCurve::autolevels_toggled) ); + + sclip = Gtk::manage (new Gtk::SpinButton ()); + sclip->set_range (0.0, 0.9999); + sclip->set_increments (0.001, 0.01); + sclip->set_value (0.002); + sclip->set_digits (4); + sclip->signal_value_changed().connect( sigc::mem_fun(*this, &ToneCurve::clip_changed) ); + + abox->pack_start (*autolevels); + abox->pack_end (*sclip); + abox->pack_end (*Gtk::manage (new Gtk::Label (M("TP_EXPOSURE_CLIP")))); + pack_start (*abox); + + pack_start (*Gtk::manage (new Gtk::HSeparator())); + +//----------- Exposure Compensation ------------------------ + expcomp = Gtk::manage (new Adjuster (M("TP_EXPOSURE_EXPCOMP"), -5, 10, 0.05, 0)); + pack_start (*expcomp); + hlcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRHIGHLIGHTS"), 0, 100, 1, 70)); + pack_start (*hlcompr); + hlcomprthresh = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRHIGHLIGHTSTHRESHOLD"), 0, 100, 1, 0)); + pack_start (*hlcomprthresh); + +//----------- Black Level ---------------------------------- + black = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BLACKLEVEL"), -16384, 32768, 50, 0)); + pack_start (*black); + shcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 50)); + pack_start (*shcompr); + + pack_start (*Gtk::manage (new Gtk::HSeparator())); + +//---------Brightness / Contrast ------------------------- + brightness = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BRIGHTNESS"), -100, 100, 1, 0)); + pack_start (*brightness); + contrast = Gtk::manage (new Adjuster (M("TP_EXPOSURE_CONTRAST"), -100, 100, 1, 0)); + pack_start (*contrast); + saturation = Gtk::manage (new Adjuster (M("TP_EXPOSURE_SATURATION"), -100, 100, 1, 0)); + pack_start (*saturation); + +//----------- Curve ------------------------------ + pack_start (*Gtk::manage (new Gtk::HSeparator())); + + curveEditorG = new CurveEditorGroup (M("TP_EXPOSURE_CURVEEDITOR")); + curveEditorG->setCurveListener (this); + + shape = (DiagonalCurveEditor*)curveEditorG->addCurve(CT_Diagonal, ""); + + // This will add the reset button at the end of the curveType buttons + curveEditorG->curveListComplete(); + + pack_start (*curveEditorG, Gtk::PACK_SHRINK, 4); + + //curveEditorG->show(); + +// --------- Set Up Listeners ------------- + expcomp->setAdjusterListener (this); + brightness->setAdjusterListener (this); + black->setAdjusterListener (this); + hlcompr->setAdjusterListener (this); + hlcomprthresh->setAdjusterListener (this); + shcompr->setAdjusterListener (this); + contrast->setAdjusterListener (this); + saturation->setAdjusterListener (this); +} + +void ToneCurve::read (const ProcParams* pp, const ParamsEdited* pedited) { + + disableListener (); + + if (pedited) { + expcomp->setEditedState (pedited->toneCurve.expcomp ? Edited : UnEdited); + black->setEditedState (pedited->toneCurve.black ? Edited : UnEdited); + hlcompr->setEditedState (pedited->toneCurve.hlcompr ? Edited : UnEdited); + hlcomprthresh->setEditedState (pedited->toneCurve.hlcomprthresh ? Edited : UnEdited); + shcompr->setEditedState (pedited->toneCurve.shcompr ? Edited : UnEdited); + brightness->setEditedState (pedited->toneCurve.brightness ? Edited : UnEdited); + contrast->setEditedState (pedited->toneCurve.contrast ? Edited : UnEdited); + saturation->setEditedState (pedited->toneCurve.saturation ? Edited : UnEdited); + autolevels->set_inconsistent (!pedited->toneCurve.autoexp); + clipDirty = pedited->toneCurve.clip; + shape->setUnChanged (!pedited->toneCurve.curve); + } + + autoconn.block (true); + autolevels->set_active (pp->toneCurve.autoexp); + autoconn.block (false); + lastAuto = pp->toneCurve.autoexp; + sclip->set_value (pp->toneCurve.clip); + + expcomp->setValue (pp->toneCurve.expcomp); + black->setValue (pp->toneCurve.black); + hlcompr->setValue (pp->toneCurve.hlcompr); + hlcomprthresh->setValue (pp->toneCurve.hlcomprthresh); + shcompr->setValue (pp->toneCurve.shcompr); + if (!black->getAddMode()) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect + brightness->setValue (pp->toneCurve.brightness); + contrast->setValue (pp->toneCurve.contrast); + saturation->setValue (pp->toneCurve.saturation); + shape->setCurve (pp->toneCurve.curve); + + shape->openIfNonlinear(); + + enableListener (); +} + +void ToneCurve::write (ProcParams* pp, ParamsEdited* pedited) { + + pp->toneCurve.autoexp = autolevels->get_active(); + pp->toneCurve.clip = sclip->get_value (); + pp->toneCurve.expcomp = expcomp->getValue (); + pp->toneCurve.black = (int)black->getValue (); + pp->toneCurve.hlcompr = (int)hlcompr->getValue (); + pp->toneCurve.hlcomprthresh = (int)hlcomprthresh->getValue (); + pp->toneCurve.shcompr = (int)shcompr->getValue (); + pp->toneCurve.brightness = (int)brightness->getValue (); + pp->toneCurve.contrast = (int)contrast->getValue (); + pp->toneCurve.saturation = (int)saturation->getValue (); + pp->toneCurve.curve = shape->getCurve (); + + if (pedited) { + pedited->toneCurve.expcomp = expcomp->getEditedState (); + pedited->toneCurve.black = black->getEditedState (); + pedited->toneCurve.hlcompr = hlcompr->getEditedState (); + pedited->toneCurve.hlcomprthresh = hlcomprthresh->getEditedState (); + pedited->toneCurve.shcompr = shcompr->getEditedState (); + pedited->toneCurve.brightness = brightness->getEditedState (); + pedited->toneCurve.contrast = contrast->getEditedState (); + pedited->toneCurve.saturation = saturation->getEditedState (); + pedited->toneCurve.autoexp = !autolevels->get_inconsistent(); + pedited->toneCurve.clip = clipDirty; + pedited->toneCurve.curve = !shape->isUnChanged (); + } +} + +void ToneCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { + + expcomp->setDefault (defParams->toneCurve.expcomp); + brightness->setDefault (defParams->toneCurve.brightness); + black->setDefault (defParams->toneCurve.black); + hlcompr->setDefault (defParams->toneCurve.hlcompr); + hlcomprthresh->setDefault (defParams->toneCurve.hlcomprthresh); + shcompr->setDefault (defParams->toneCurve.shcompr); + contrast->setDefault (defParams->toneCurve.contrast); + saturation->setDefault (defParams->toneCurve.saturation); + + if (pedited) { + expcomp->setDefaultEditedState (pedited->toneCurve.expcomp ? Edited : UnEdited); + black->setDefaultEditedState (pedited->toneCurve.black ? Edited : UnEdited); + hlcompr->setDefaultEditedState (pedited->toneCurve.hlcompr ? Edited : UnEdited); + hlcomprthresh->setDefaultEditedState (pedited->toneCurve.hlcomprthresh ? Edited : UnEdited); + shcompr->setDefaultEditedState (pedited->toneCurve.shcompr ? Edited : UnEdited); + brightness->setDefaultEditedState (pedited->toneCurve.brightness ? Edited : UnEdited); + contrast->setDefaultEditedState (pedited->toneCurve.contrast ? Edited : UnEdited); + saturation->setDefaultEditedState (pedited->toneCurve.saturation ? Edited : UnEdited); + } + else { + expcomp->setDefaultEditedState (Irrelevant); + black->setDefaultEditedState (Irrelevant); + hlcompr->setDefaultEditedState (Irrelevant); + hlcomprthresh->setDefaultEditedState (Irrelevant); + shcompr->setDefaultEditedState (Irrelevant); + brightness->setDefaultEditedState (Irrelevant); + contrast->setDefaultEditedState (Irrelevant); + saturation->setDefaultEditedState (Irrelevant); + } +} + +void ToneCurve::curveChanged () { + + if (listener) listener->panelChanged (EvToneCurve, M("HISTORY_CUSTOMCURVE")); +} + +void ToneCurve::adjusterChanged (Adjuster* a, double newval) { + + // Switch off auto exposure if user changes sliders manually + if (autolevels->get_active() && (a==expcomp || a==black)) { + autolevels->set_active (false); + autolevels->set_inconsistent (false); + } + + if (!listener) + return; + + Glib::ustring costr; + if (a==expcomp) + costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), a->getValue()); + else + costr = Glib::ustring::format ((int)a->getValue()); + + if (a==expcomp) + listener->panelChanged (EvExpComp, costr); + else if (a==brightness) + listener->panelChanged (EvBrightness, costr); + else if (a==black){ + listener->panelChanged (EvBlack, costr); + if (!black->getAddMode()) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect + } + else if (a==contrast) + listener->panelChanged (EvContrast, costr); + else if (a==saturation) + listener->panelChanged (EvSaturation, costr); + else if (a==hlcompr) + listener->panelChanged (EvHLCompr, costr); + else if (a==hlcomprthresh) + listener->panelChanged (EvHLComprThreshold, costr); + else if (a==shcompr) + listener->panelChanged (EvSHCompr, costr); +} + +void ToneCurve::autolevels_toggled () { + + if (batchMode) { + if (autolevels->get_inconsistent()) { + autolevels->set_inconsistent (false); + autoconn.block (true); + autolevels->set_active (false); + autoconn.block (false); + } + else if (lastAuto) + autolevels->set_inconsistent (true); + + lastAuto = autolevels->get_active (); + } + + if (!batchMode && autolevels->get_active() && listener) { + listener->panelChanged (EvAutoExp, M("GENERAL_ENABLED")); + waitForAutoExp (); + if (!black->getAddMode()) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect + } + + if (batchMode) { + expcomp->setEditedState (UnEdited); + black->setEditedState (UnEdited); + if (expcomp->getAddMode()) + expcomp->setValue (0); + if (black->getAddMode()) + black->setValue (0); + listener->panelChanged (EvAutoExp, M("GENERAL_ENABLED")); + } +} + +void ToneCurve::clip_changed () { + + clipDirty = true; + if (autolevels->get_active() && listener) + Glib::signal_idle().connect (sigc::mem_fun(*this, &ToneCurve::clip_changed_)); +} + +bool ToneCurve::clip_changed_ () { + + if (listener) { + listener->panelChanged (EvClip, Glib::ustring::format (std::setprecision(5), sclip->get_value())); + if (!batchMode) + waitForAutoExp (); + } + return false; +} + +void ToneCurve::waitForAutoExp () { + + sclip->set_sensitive (false); + expcomp->setEnabled (false); + brightness->setEnabled (false); + black->setEnabled (false); + hlcompr->setEnabled (false); + hlcomprthresh->setEnabled (false); + shcompr->setEnabled (false); + contrast->setEnabled (false); + saturation->setEnabled (false); + curveEditorG->set_sensitive (false); +} + +int aexpcomputed (void* data) { + + gdk_threads_enter(); + ((ToneCurve*)data)->autoExpComputed_ (); + gdk_threads_leave(); + return 0; +} + +void ToneCurve::autoExpChanged (double expcomp, int black) { + + nextBlack = black; + nextExpcomp = expcomp; + g_idle_add (aexpcomputed, this); + +// Glib::signal_idle().connect (sigc::mem_fun(*this, &ToneCurve::autoExpComputed_)); +} + +void ToneCurve::enableAll () { + + sclip->set_sensitive (true); + expcomp->setEnabled (true); + brightness->setEnabled (true); + black->setEnabled (true); + hlcompr->setEnabled (true); + hlcomprthresh->setEnabled (true); + shcompr->setEnabled (true); + contrast->setEnabled (true); + saturation->setEnabled (true); + curveEditorG->set_sensitive (true); +} + +bool ToneCurve::autoExpComputed_ () { + + disableListener (); + enableAll (); + expcomp->setValue (nextExpcomp); + black->setValue (nextBlack); + if (!black->getAddMode()) shcompr->set_sensitive(!((int)black->getValue ()==0)); //at black=0 shcompr value has no effect + enableListener (); + + return false; +} + +void ToneCurve::setBatchMode (bool batchMode) { + + removeIfThere (abox, autolevels, false); + autolevels = Gtk::manage (new Gtk::CheckButton (M("TP_EXPOSURE_AUTOLEVELS"))); + autoconn = autolevels->signal_toggled().connect( sigc::mem_fun(*this, &ToneCurve::autolevels_toggled) ); + abox->pack_start (*autolevels); + + ToolPanel::setBatchMode (batchMode); + expcomp->showEditedCB (); + black->showEditedCB (); + hlcompr->showEditedCB (); + hlcomprthresh->showEditedCB (); + shcompr->showEditedCB (); + brightness->showEditedCB (); + contrast->showEditedCB (); + saturation->showEditedCB (); + + curveEditorG->setBatchMode (batchMode); +} + +void ToneCurve::setAdjusterBehavior (bool expadd, bool hlcompadd, bool hlcompthreshadd, bool bradd, bool blackadd, bool shcompadd, bool contradd, bool satadd) { + + expcomp->setAddMode(expadd); + hlcompr->setAddMode(hlcompadd); + hlcomprthresh->setAddMode(hlcompthreshadd); + brightness->setAddMode(bradd); + black->setAddMode(blackadd); + shcompr->setAddMode(shcompadd); + contrast->setAddMode(contradd); + saturation->setAddMode(satadd); +} + +void ToneCurve::trimValues (rtengine::procparams::ProcParams* pp) { + + expcomp->trimValue(pp->toneCurve.expcomp); + hlcompr->trimValue(pp->toneCurve.hlcompr); + hlcomprthresh->trimValue(pp->toneCurve.hlcomprthresh); + brightness->trimValue(pp->toneCurve.brightness); + black->trimValue(pp->toneCurve.black); + shcompr->trimValue(pp->toneCurve.shcompr); + contrast->trimValue(pp->toneCurve.contrast); + saturation->trimValue(pp->toneCurve.saturation); +} + +void ToneCurve::updateCurveBackgroundHistogram (LUTu & hist) { + + shape->updateBackgroundHistogram (hist); +} diff --git a/rtgui/tonecurve.h b/rtgui/tonecurve.h index b7d88e268..cb86423bf 100644 --- a/rtgui/tonecurve.h +++ b/rtgui/tonecurve.h @@ -41,7 +41,7 @@ class ToneCurve : public Gtk::VBox, public AdjusterListener, public FoldableTool Adjuster* contrast; Adjuster* saturation; - bool expAdd,hlcompAdd,hlcompthreshAdd, blackAdd, shcompAdd, brAdd, contrAdd, satAdd, clipDirty, lastAuto; + bool clipDirty, lastAuto; sigc::connection autoconn; CurveEditorGroup* curveEditorG; DiagonalCurveEditor* shape; @@ -54,11 +54,13 @@ class ToneCurve : public Gtk::VBox, public AdjusterListener, public FoldableTool ToneCurve (); - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); - void setBatchMode (bool batchMode); + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); void setAdjusterBehavior (bool expadd, bool hlcompadd, bool hlcompthreshadd, bool bradd, bool blackadd, bool shcompadd, bool contradd, bool satadd); + void trimValues (rtengine::procparams::ProcParams* pp); + void adjusterChanged (Adjuster* a, double newval); void autolevels_toggled (); diff --git a/rtgui/toolpanel.h b/rtgui/toolpanel.h index 7423d1c09..4ed872431 100644 --- a/rtgui/toolpanel.h +++ b/rtgui/toolpanel.h @@ -52,6 +52,7 @@ class ToolPanel { void setListener (ToolPanelListener* tpl) { listener = tpl; } virtual void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL) {} virtual void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL) {} + virtual void trimValues (rtengine::procparams::ProcParams* pp) { return; } virtual void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL) {} void disableListener () { if (tmp==NULL) tmp = listener; listener = NULL; } diff --git a/rtgui/vignetting.cc b/rtgui/vignetting.cc index 85f44a397..ea2a418e5 100644 --- a/rtgui/vignetting.cc +++ b/rtgui/vignetting.cc @@ -22,7 +22,7 @@ using namespace rtengine; using namespace rtengine::procparams; -Vignetting::Vignetting () : Gtk::VBox(), FoldableToolPanel(this), vigAdd(false) { +Vignetting::Vignetting () : Gtk::VBox(), FoldableToolPanel(this) { amount = Gtk::manage (new Adjuster (M("TP_VIGNETTING_AMOUNT"), -100, 100, 1, 0)); amount->setAdjusterListener (this); @@ -96,12 +96,14 @@ void Vignetting::adjusterChanged (Adjuster* a, double newval) { listener->panelChanged (EvVignetting, Glib::ustring::compose ("%1=%5\n%2=%6\n%3=%7\n%4=%8 %9", M("TP_VIGNETTING_AMOUNT"), M("TP_VIGNETTING_RADIUS"), M("TP_VIGNETTING_STRENGTH"), M("TP_VIGNETTING_CENTER"), (int)amount->getValue(), (int)radius->getValue(), (int)strength->getValue(), (int)centerX->getValue(), (int)centerY->getValue())); } -void Vignetting::setAdjusterBehavior (bool bvadd) { +void Vignetting::setAdjusterBehavior (bool vadd) { - if ((!vigAdd && bvadd) || (vigAdd && !bvadd)) - amount->setLimits (-100, 100, 1, 0); - - vigAdd = bvadd; + amount->setAddMode(vadd); +} + +void Vignetting::trimValues (rtengine::procparams::ProcParams* pp) { + + amount->trimValue(pp->vignetting.amount); } void Vignetting::setBatchMode (bool batchMode) { diff --git a/rtgui/vignetting.h b/rtgui/vignetting.h index 67220bdfc..0c2997d02 100644 --- a/rtgui/vignetting.h +++ b/rtgui/vignetting.h @@ -31,7 +31,6 @@ class Vignetting : public Gtk::VBox, public AdjusterListener, public FoldableToo Adjuster* strength; Adjuster* centerX; Adjuster* centerY; - bool vigAdd; public: @@ -43,7 +42,8 @@ class Vignetting : public Gtk::VBox, public AdjusterListener, public FoldableToo void setBatchMode (bool batchMode); void adjusterChanged (Adjuster* a, double newval); - void setAdjusterBehavior (bool bvadd); + void setAdjusterBehavior (bool vadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif diff --git a/rtgui/whitebalance.cc b/rtgui/whitebalance.cc index 1a96f5b20..28359f5f3 100644 --- a/rtgui/whitebalance.cc +++ b/rtgui/whitebalance.cc @@ -29,7 +29,7 @@ extern Glib::ustring argv0; using namespace rtengine; using namespace rtengine::procparams; -WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL), wblistener(NULL), tempAdd(false), greenAdd (false) { +WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL), wblistener(NULL) { Gtk::HBox* hbox = Gtk::manage (new Gtk::HBox ()); hbox->show (); @@ -114,8 +114,8 @@ void WhiteBalance::optChanged () { if (opt==0 && wbp) { double ctemp; double cgreen; wbp->getCamWB (ctemp, cgreen); - temp->setValue (tempAdd ? 0.0 : (int)ctemp); - green->setValue (greenAdd ? 0.0 : cgreen); + temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp); + green->setValue (green->getAddMode() ? 0.0 : cgreen); meth = M("TP_WBALANCE_CAMERA"); if (batchMode) { temp->setEditedState (UnEdited); @@ -125,8 +125,8 @@ void WhiteBalance::optChanged () { else if (opt==1 && wbp) { double ctemp; double cgreen; wbp->getAutoWB (ctemp, cgreen); - temp->setValue (tempAdd ? 0.0 : (int)ctemp); - green->setValue (greenAdd ? 0.0 : cgreen); + temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp); + green->setValue (green->getAddMode() ? 0.0 : cgreen); meth = M("TP_WBALANCE_AUTO"); if (batchMode) { temp->setEditedState (UnEdited); @@ -175,8 +175,8 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) { if (wbp) { double ctemp; double cgreen; wbp->getCamWB (ctemp, cgreen); - temp->setValue (tempAdd ? 0.0 : (int)ctemp); - green->setValue (greenAdd ? 0.0 : cgreen); + temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp); + green->setValue (green->getAddMode() ? 0.0 : cgreen); } opt = 0; } @@ -185,8 +185,8 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) { if (wbp) { double ctemp; double cgreen; wbp->getAutoWB (ctemp, cgreen); - temp->setValue (tempAdd ? 0.0 : (int)ctemp); - green->setValue (greenAdd ? 0.0 : cgreen); + temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp); + green->setValue (green->getAddMode() ? 0.0 : cgreen); } opt = 1; } @@ -230,14 +230,14 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited* if (wbp && defParams->wb.method == "Camera") { double ctemp; double cgreen; wbp->getCamWB (ctemp, cgreen); - temp->setDefault (tempAdd ? 0 : (int)ctemp); - green->setDefault (greenAdd ? 0 : cgreen); + temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp); + green->setDefault (green->getAddMode() ? 0 : cgreen); } else if (wbp && defParams->wb.method == "Auto") { double ctemp; double cgreen; wbp->getAutoWB (ctemp, cgreen); - temp->setDefault (tempAdd ? 0 : (int)ctemp); - green->setDefault (greenAdd ? 0 : cgreen); + temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp); + green->setDefault (green->getAddMode() ? 0 : cgreen); } else if (defParams->wb.method == "Custom") { temp->setDefault (defParams->wb.temperature); @@ -279,19 +279,14 @@ void WhiteBalance::setWB (int vtemp, double vgreen) { if (listener) listener->panelChanged (EvWBTemp, Glib::ustring::compose("%1, %2", (int)temp->getValue(), Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), green->getValue()))); } -void WhiteBalance::setAdjusterBehavior (bool btempadd, bool bgreenadd) { +void WhiteBalance::setAdjusterBehavior (bool tempadd, bool greenadd) { - if (!tempAdd && btempadd) - temp->setLimits (-4000, +4000, 1, 0); - else if (tempAdd && !btempadd) - temp->setLimits (MINTEMP, MAXTEMP, 1, 4750); - - if (!greenAdd && bgreenadd) - green->setLimits (-1.0, +1.0, 0.001, 0); - else if (greenAdd && bgreenadd) - green->setLimits (MINGREEN, MAXGREEN, 0.001, 1.2); - - tempAdd = btempadd; - greenAdd = bgreenadd; + temp->setAddMode(tempadd); + green->setAddMode(greenadd); } +void WhiteBalance::trimValues (rtengine::procparams::ProcParams* pp) { + + temp->trimValue(pp->wb.temperature); + green->trimValue(pp->wb.green); +} diff --git a/rtgui/whitebalance.h b/rtgui/whitebalance.h index 12658dd9d..8a4c0afc4 100644 --- a/rtgui/whitebalance.h +++ b/rtgui/whitebalance.h @@ -44,7 +44,6 @@ class WhiteBalance : public Gtk::VBox, public AdjusterListener, public FoldableT WBProvider *wbp; SpotWBListener* wblistener; sigc::connection methconn; - bool tempAdd, greenAdd; public: @@ -65,7 +64,8 @@ class WhiteBalance : public Gtk::VBox, public AdjusterListener, public FoldableT void setSpotWBListener (SpotWBListener* l) { wblistener = l; } void setWB (int temp, double green); - void setAdjusterBehavior (bool btempadd, bool bgreenadd); + void setAdjusterBehavior (bool tempadd, bool greenadd); + void trimValues (rtengine::procparams::ProcParams* pp); }; #endif