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 <multilangmgr.h>
20 #include <toolpanelcoord.h>
24 using namespace rtengine::procparams
;
26 ToolPanelCoordinator::ToolPanelCoordinator () : ipc(NULL
) {
28 exposurePanel
= Gtk::manage (new Gtk::VBox ());
29 detailsPanel
= Gtk::manage (new Gtk::VBox ());
30 colorPanel
= Gtk::manage (new Gtk::VBox ());
31 transformPanel
= Gtk::manage (new Gtk::VBox ());
33 coarse
= Gtk::manage (new CoarsePanel ());
34 curve
= Gtk::manage (new ToneCurve ());
35 shadowshighlights
= Gtk::manage (new ShadowsHighlights ());
36 lumadenoise
= Gtk::manage (new LumaDenoise ());
37 colordenoise
= Gtk::manage (new ColorDenoise ());
38 sharpening
= Gtk::manage (new Sharpening ());
39 // lcurve = Gtk::manage (new LCurve ());
40 colorboost
= Gtk::manage (new ColorBoost ());
41 colorshift
= Gtk::manage (new ColorShift ());
42 distortion
= Gtk::manage (new Distortion ());
43 rotate
= Gtk::manage (new Rotate ());
44 whitebalance
= Gtk::manage (new WhiteBalance ());
45 vignetting
= Gtk::manage (new Vignetting ());
46 cacorrection
= Gtk::manage (new CACorrection ());
47 hlrecovery
= Gtk::manage (new HLRecovery ());
48 chmixer
= Gtk::manage (new ChMixer ());
49 resize
= Gtk::manage (new Resize ());
50 crop
= Gtk::manage (new Crop ());
51 icm
= Gtk::manage (new ICMPanel ());
52 exifpanel
= Gtk::manage (new ExifPanel ());
53 iptcpanel
= Gtk::manage (new IPTCPanel ());
55 addPanel (colorPanel
, whitebalance
, M("TP_WBALANCE_LABEL")); toolPanels
.push_back (whitebalance
);
56 addPanel (exposurePanel
, curve
, M("TP_EXPOSURE_LABEL")); toolPanels
.push_back (curve
);
57 addPanel (exposurePanel
, hlrecovery
, M("TP_HLREC_LABEL")); toolPanels
.push_back (hlrecovery
);
58 addPanel (colorPanel
, chmixer
, M("TP_CHMIXER_LABEL")); toolPanels
.push_back (chmixer
);
59 addPanel (exposurePanel
, shadowshighlights
, M("TP_SHADOWSHLIGHTS_LABEL")); toolPanels
.push_back (shadowshighlights
);
60 addPanel (detailsPanel
, sharpening
, M("TP_SHARPENING_LABEL")); toolPanels
.push_back (sharpening
);
61 addPanel (colorPanel
, colorboost
, M("TP_COLORBOOST_LABEL")); toolPanels
.push_back (colorboost
);
62 addPanel (colorPanel
, colorshift
, M("TP_COLORSHIFT_LABEL")); toolPanels
.push_back (colorshift
);
63 /* addPanel (exposurePanel, lcurve, M("TP_LUMACURVE_LABEL")); toolPanels.push_back (lcurve);*/
64 addPanel (detailsPanel
, lumadenoise
, M("TP_LUMADENOISE_LABEL")); toolPanels
.push_back (lumadenoise
);
65 addPanel (detailsPanel
, colordenoise
, M("TP_COLORDENOISE_LABEL")); toolPanels
.push_back (colordenoise
);
66 addPanel (transformPanel
, crop
, M("TP_CROP_LABEL")); toolPanels
.push_back (crop
);
67 addPanel (transformPanel
, rotate
, M("TP_ROTATE_LABEL")); toolPanels
.push_back (rotate
);
68 addPanel (transformPanel
, distortion
, M("TP_DISTORTION_LABEL")); toolPanels
.push_back (distortion
);
69 addPanel (transformPanel
, cacorrection
, M("TP_CACORRECTION_LABEL")); toolPanels
.push_back (cacorrection
);
70 addPanel (transformPanel
, vignetting
, M("TP_VIGNETTING_LABEL")); toolPanels
.push_back (vignetting
);
71 addPanel (transformPanel
, resize
, M("TP_RESIZE_LABEL")); toolPanels
.push_back (resize
);
72 addPanel (colorPanel
, icm
, M("TP_ICM_LABEL")); toolPanels
.push_back (icm
);
74 toolPanels
.push_back (coarse
);
75 toolPanels
.push_back (exifpanel
);
76 toolPanels
.push_back (iptcpanel
);
78 metadataPanel
= Gtk::manage (new Gtk::Notebook ());
79 toolPanelNotebook
= new Gtk::Notebook ();
81 metadataPanel
->append_page (*exifpanel
, M("MAIN_TAB_EXIF"));
82 metadataPanel
->append_page (*iptcpanel
, M("MAIN_TAB_IPTC"));
84 Gtk::ScrolledWindow
* exposurePanelSW
= Gtk::manage (new Gtk::ScrolledWindow ());
85 Gtk::ScrolledWindow
* detailsPanelSW
= Gtk::manage (new Gtk::ScrolledWindow ());
86 Gtk::ScrolledWindow
* colorPanelSW
= Gtk::manage (new Gtk::ScrolledWindow ());
87 Gtk::ScrolledWindow
* transformPanelSW
= Gtk::manage (new Gtk::ScrolledWindow ());
88 exposurePanelSW
->set_policy (Gtk::POLICY_AUTOMATIC
, Gtk::POLICY_AUTOMATIC
);
89 detailsPanelSW
->set_policy (Gtk::POLICY_AUTOMATIC
, Gtk::POLICY_AUTOMATIC
);
90 colorPanelSW
->set_policy (Gtk::POLICY_AUTOMATIC
, Gtk::POLICY_AUTOMATIC
);
91 transformPanelSW
->set_policy (Gtk::POLICY_AUTOMATIC
, Gtk::POLICY_AUTOMATIC
);
93 exposurePanelSW
->add (*exposurePanel
);
94 detailsPanelSW
->add (*detailsPanel
);
95 colorPanelSW
->add (*colorPanel
);
96 transformPanelSW
->add (*transformPanel
);
98 toolPanelNotebook
->append_page (*exposurePanelSW
, M("MAIN_TAB_EXPOSURE"));
99 toolPanelNotebook
->append_page (*detailsPanelSW
, M("MAIN_TAB_DETAIL"));
100 toolPanelNotebook
->append_page (*colorPanelSW
, M("MAIN_TAB_COLOR"));
101 toolPanelNotebook
->append_page (*transformPanelSW
, M("MAIN_TAB_TRANSFORM"));
102 toolPanelNotebook
->append_page (*metadataPanel
, M("MAIN_TAB_METADATA"));
103 toolPanelNotebook
->set_current_page (0);
105 toolPanelNotebook
->set_scrollable ();
106 toolPanelNotebook
->show_all ();
108 for (int i
=0; i
<toolPanels
.size(); i
++)
109 toolPanels
[i
]->setListener (this);
111 whitebalance
->setWBProvider (this);
112 whitebalance
->setSpotWBListener (this);
113 rotate
->setRotateListener (this);
114 crop
->setCropPanelListener (this);
115 icm
->setICMPanelListener (this);
117 toolBar
= new ToolBar ();
120 void ToolPanelCoordinator::addPanel (Gtk::Box
* where
, Gtk::Container
* panel
, Glib::ustring label
) {
122 Gtk::HSeparator
*hsep
= Gtk::manage (new Gtk::HSeparator());
123 where
->pack_start(*hsep
, Gtk::PACK_SHRINK
, 0);
126 // Gtk::Expander* exp = new Gtk::Expander ();
127 // exp->set_label_widget (*(new ILabel (Glib::ustring("<b>") + label + "</b>")));
128 Gtk::Expander
* exp
= Gtk::manage (new Gtk::Expander (Glib::ustring("<b>") + label
+ "</b>"));
129 exp
->set_border_width (4);
130 exp
->set_use_markup (true);
131 expList
.push_back (exp
);
133 Gtk::Frame
* pframe
= Gtk::manage (new Gtk::Frame ());
135 pframe
->set_name ("ToolPanel");
137 pframe
->add (*panel
);
141 pframe
->set_shadow_type (Gtk::SHADOW_ETCHED_IN
);
145 where
->pack_start(*exp
, false, false);
148 ToolPanelCoordinator::~ToolPanelCoordinator () {
152 delete toolPanelNotebook
;
156 void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event
, const Glib::ustring
& descr
) {
160 ProcParams
* params
= ipc
->getParamsForUpdate (event
);
161 for (int i
=0; i
<toolPanels
.size(); i
++)
162 toolPanels
[i
]->write (params
);
164 // some transformations make the crop change for convinience
165 if (event
==rtengine::EvResizeScale
) {
166 crop
->resizeScaleChanged (params
->resize
.scale
);
167 crop
->write (params
);
169 else if (event
==rtengine::EvCTHFlip
) {
171 crop
->write (params
);
173 else if (event
==rtengine::EvCTVFlip
) {
175 crop
->write (params
);
177 else if (event
==rtengine::EvCTRotate
) {
178 crop
->rotateCrop (params
->coarse
.rotate
);
179 crop
->write (params
);
182 ipc
->paramsUpdateReady ();
186 for (int i
=0; i
<paramcListeners
.size(); i
++)
187 paramcListeners
[i
]->procParamsChanged (params
, event
, descr
);
190 void ToolPanelCoordinator::profileChange (const ProcParams
*nparams
, rtengine::ProcEvent event
, const Glib::ustring
& descr
, const ParamsEdited
* paramsEdited
) {
193 ProcParams
* params
= ipc
->getParamsForUpdate (event
);
195 for (int i
=0; i
<toolPanels
.size(); i
++)
196 toolPanels
[i
]->read (nparams
);
198 ipc
->paramsUpdateReady ();
200 hasChanged
= event
!= rtengine::EvProfileChangeNotification
;
202 for (int i
=0; i
<paramcListeners
.size(); i
++)
203 paramcListeners
[i
]->procParamsChanged (params
, event
, descr
);
206 void ToolPanelCoordinator::setDefaults (ProcParams
* defparams
) {
209 for (int i
=0; i
<toolPanels
.size(); i
++)
210 toolPanels
[i
]->setDefaults (defparams
);
213 CropGUIListener
* ToolPanelCoordinator::getCropGUIListener () {
218 void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor
* ipc_
, bool raw
) {
221 curve
->disableListener ();
223 curve
->enableListener ();
226 exifpanel
->setImageData (ipc
->getInitialImage()->getMetaData());
227 iptcpanel
->setImageData (ipc
->getInitialImage()->getMetaData());
230 ipc
->setAutoExpListener (curve
);
231 ipc
->setSizeListener (crop
);
232 ipc
->setSizeListener (resize
);
236 hlrecovery
->setRaw (raw
);
241 void ToolPanelCoordinator::closeImage () {
244 ipc
->stopProcessing ();
249 void ToolPanelCoordinator::readOptions () {
251 crop
->readOptions ();
252 /* for (int i=0; i<options.tpOpen.size(); i++)
253 if (i<expList.size())
254 expList[i]->set_expanded (options.tpOpen[i]);
256 if (options.crvOpen.size()>1) {
257 curve->expandCurve (options.crvOpen[0]);
258 lcurve->expandCurve (options.crvOpen[1]);
262 void ToolPanelCoordinator::writeOptions () {
264 crop
->writeOptions ();
265 /* options.tpOpen.clear ();
266 for (int i=0; i<expList.size(); i++)
267 options.tpOpen.push_back (expList[i]->get_expanded ());
269 options.crvOpen.clear ();
270 options.crvOpen.push_back (curve->isCurveExpanded());
271 options.crvOpen.push_back (lcurve->isCurveExpanded());*/
275 void ToolPanelCoordinator::cropSelectionReady () {
277 toolBar
->setTool (TMHand
);
283 void ToolPanelCoordinator::rotateSelectionReady (double rotate_deg
, Thumbnail
* thm
) {
285 toolBar
->setTool (TMHand
);
291 rotate
->straighten (rotate_deg
);
294 void ToolPanelCoordinator::spotWBselected (int x
, int y
, Thumbnail
* thm
) {
299 // toolBar->setTool (TOOL_HAND);
303 ipc
->getSpotWB (x
, y
, whitebalance
->getSize (), temp
, green
);
304 whitebalance
->setWB (temp
, green
);
308 void ToolPanelCoordinator::autoCropRequested () {
313 int x1
, y1
, x2
, y2
, w
, h
;
314 ipc
->getAutoCrop (crop
->getRatio(), x1
, y1
, w
, h
);
317 crop
->cropInit (x1
, y1
, w
, h
);
318 crop
->cropResized (x1
, y1
, x2
, y2
);
319 crop
->cropManipReady ();
322 void ToolPanelCoordinator::straightenRequested () {
327 toolBar
->setTool (TMStraighten
);
330 void ToolPanelCoordinator::spotWBRequested (int size
) {
335 toolBar
->setTool (TMSpotWB
);
338 void ToolPanelCoordinator::cropSelectRequested () {
343 toolBar
->setTool (TMCropSelect
);
346 void ToolPanelCoordinator::saveInputICCReference (Glib::ustring fname
) {
349 ipc
->saveInputICCReference (fname
);
352 int ToolPanelCoordinator::getSpotWBRectSize () {
354 return whitebalance
->getSize ();