2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #include <cacorrection.h>
22 using namespace rtengine
;
23 using namespace rtengine::procparams
;
25 CACorrection::CACorrection () : valaAdd(false), valbAdd(false) {
27 red
= Gtk::manage (new Adjuster (M("TP_CACORRECTION_RED"), -0.005, 0.005, 0.0001, 0));
28 red
->setAdjusterListener (this);
30 blue
= Gtk::manage (new Adjuster (M("TP_CACORRECTION_BLUE"), -0.005, 0.005, 0.0001, 0));
31 blue
->setAdjusterListener (this);
39 void CACorrection::read (const ProcParams
* pp
, const ParamsEdited
* pedited
) {
44 red
->setEditedState (pedited
->cacorrection
.red
? Edited
: UnEdited
);
45 blue
->setEditedState (pedited
->cacorrection
.blue
? Edited
: UnEdited
);
48 red
->setValue (pp
->cacorrection
.red
);
49 blue
->setValue (pp
->cacorrection
.blue
);
54 void CACorrection::write (ProcParams
* pp
, ParamsEdited
* pedited
) {
56 pp
->cacorrection
.red
= red
->getValue ();
57 pp
->cacorrection
.blue
= blue
->getValue ();
60 pedited
->cacorrection
.red
= red
->getEditedState ();
61 pedited
->cacorrection
.blue
= blue
->getEditedState ();
65 void CACorrection::setDefaults (const ProcParams
* defParams
, const ParamsEdited
* pedited
) {
67 red
->setDefault (defParams
->cacorrection
.red
);
68 blue
->setDefault (defParams
->cacorrection
.blue
);
71 red
->setDefaultEditedState (pedited
->cacorrection
.red
? Edited
: UnEdited
);
72 blue
->setDefaultEditedState (pedited
->cacorrection
.blue
? Edited
: UnEdited
);
75 red
->setDefaultEditedState (Irrelevant
);
76 blue
->setDefaultEditedState (Irrelevant
);
80 void CACorrection::adjusterChanged (Adjuster
* a
, double newval
) {
83 listener
->panelChanged (EvCACorr
, Glib::ustring::compose ("%1=%3\n%2=%4", M("TP_CACORRECTION_RED"), M("TP_CACORRECTION_BLUE"), Glib::ustring::format (std::setw(5), std::fixed
, std::setprecision(4), red
->getValue()), Glib::ustring::format (std::setw(5), std::fixed
, std::setprecision(4), blue
->getValue())));
86 void CACorrection::setAdjusterBehavior (bool baadd
, bool bbadd
) {
88 if (!valaAdd
&& baadd
|| valaAdd
&& !baadd
)
89 red
->setLimits (-0.005, 0.005, 0.0001, 0);
91 if (!valbAdd
&& bbadd
|| valbAdd
&& !bbadd
)
92 blue
->setLimits (-0.005, 0.005, 0.0001, 0);
98 void CACorrection::setBatchMode (bool batchMode
) {
100 ToolPanel::setBatchMode (batchMode
);
101 red
->showEditedCB ();
102 blue
->showEditedCB ();