1 /* -*- C++ -*- 2 * 3 * This file is part of RawTherapee. 4 * 5 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com> 6 * 7 * RawTherapee is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * RawTherapee is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #pragma once 21 22 #include "../rtengine/rtengine.h" 23 #include "toolpanel.h" 24 #include <vector> 25 #include "pparamschangelistener.h" 26 #include "profilechangelistener.h" 27 #include "imageareatoollistener.h" 28 #include <gtkmm.h> 29 #include "whitebalance.h" 30 #include "coarsepanel.h" 31 #include "exposure.h" 32 #include "saturation.h" 33 #include "tonecurve.h" 34 #include "toneequalizer.h" 35 #include "impulsedenoise.h" 36 #include "defringe.h" 37 #include "denoise.h" 38 #include "textureboost.h" 39 #include "sharpening.h" 40 #include "labcurve.h" 41 #include "metadatapanel.h" 42 #include "crop.h" 43 #include "icmpanel.h" 44 #include "resize.h" 45 #include "chmixer.h" 46 #include "blackwhite.h" 47 #include "cacorrection.h" 48 #include "lensprofile.h" 49 #include "distortion.h" 50 #include "perspective.h" 51 #include "rotate.h" 52 #include "vignetting.h" 53 #include "gradient.h" 54 #include "pcvignette.h" 55 #include "toolbar.h" 56 #include "lensgeom.h" 57 #include "lensgeomlistener.h" 58 //#include "dirpyrequalizer.h" 59 #include "preprocess.h" 60 #include "bayerpreprocess.h" 61 #include "bayerprocess.h" 62 #include "xtransprocess.h" 63 #include "darkframe.h" 64 #include "flatfield.h" 65 #include "sensorbayer.h" 66 #include "sensorxtrans.h" 67 #include "rawcacorrection.h" 68 #include "rawexposure.h" 69 #include "bayerrawexposure.h" 70 #include "xtransrawexposure.h" 71 #include "rgbcurves.h" 72 #include "filmsimulation.h" 73 #include "prsharpening.h" 74 #include "fattaltonemap.h" 75 #include "localcontrast.h" 76 #include "softlight.h" 77 #include "dehaze.h" 78 #include "grain.h" 79 #include "logencoding.h" 80 #include "smoothing.h" 81 #include "colorcorrection.h" 82 #include "hslequalizer.h" 83 #include "filmnegative.h" 84 #include "guiutils.h" 85 #include "../rtengine/noncopyable.h" 86 #include "spot.h" 87 88 class ImageEditorCoordinator; 89 90 class ToolPanelCoordinator : 91 public ToolPanelListener, 92 public ToolBarListener, 93 public ProfileChangeListener, 94 public WBProvider, 95 public DFProvider, 96 public FFProvider, 97 public LensGeomListener, 98 public SpotWBListener, 99 public CropPanelListener, 100 public PerspCorrectionPanelListener, 101 public ICMPanelListener, 102 public ImageAreaToolListener, 103 public rtengine::ImageTypeListener, 104 public rtengine::AutoExpListener, 105 public FilmNegProvider, 106 public AreaDrawListenerProvider, 107 public DeltaEColorProvider, 108 public rtengine::NonCopyable 109 { 110 protected: 111 WhiteBalance* whitebalance; 112 Vignetting* vignetting; 113 Gradient* gradient; 114 PCVignette* pcvignette; 115 LensGeometry* lensgeom; 116 LensProfilePanel* lensProf; 117 Rotate* rotate; 118 Distortion* distortion; 119 PerspCorrection* perspective; 120 CACorrection* cacorrection; 121 ChMixer* chmixer; 122 BlackWhite* blackwhite; 123 HSLEqualizer *hsl; 124 Resize* resize; 125 PrSharpening* prsharpening; 126 ICMPanel* icm; 127 Crop* crop; 128 Exposure *exposure; 129 Saturation *saturation; 130 ToneCurve* toneCurve; 131 ToneEqualizer *toneEqualizer; 132 LocalContrast *localContrast; 133 Spot* spot; 134 Defringe* defringe; 135 ImpulseDenoise* impulsedenoise; 136 Denoise* denoise; 137 TextureBoost *textureBoost; 138 Sharpening* sharpening; 139 LabCurve* lcurve; 140 RGBCurves* rgbcurves; 141 SoftLight *softlight; 142 Dehaze *dehaze; 143 FilmGrain *grain; 144 FilmSimulation *filmSimulation; 145 SensorBayer * sensorbayer; 146 SensorXTrans * sensorxtrans; 147 BayerProcess* bayerprocess; 148 XTransProcess* xtransprocess; 149 BayerPreProcess* bayerpreprocess; 150 PreProcess* preprocess; 151 DarkFrame* darkframe; 152 FlatField* flatfield; 153 RAWCACorr* rawcacorrection; 154 RAWExposure* rawexposure; 155 BayerRAWExposure* bayerrawexposure; 156 XTransRAWExposure* xtransrawexposure; 157 FattalToneMapping *fattal; 158 LogEncoding *logenc; 159 MetaDataPanel* metadata; 160 Smoothing *smoothing; 161 ColorCorrection *colorcorrection; 162 // DirPyrEqualizer *cbdl; 163 FilmNegative *filmNegative; 164 165 std::vector<PParamsChangeListener*> paramcListeners; 166 167 rtengine::StagedImageProcessor* ipc; 168 169 std::vector<ToolPanel*> toolPanels; 170 std::vector<FoldableToolPanel*> favorites; 171 ToolVBox* favoritePanel; 172 ToolVBox* exposurePanel; 173 ToolVBox* detailsPanel; 174 ToolVBox* colorPanel; 175 ToolVBox* transformPanel; 176 ToolVBox* rawPanel; 177 // ToolVBox* advancedPanel; 178 ToolVBox *localPanel; 179 ToolVBox *effectsPanel; 180 ToolBar* toolBar; 181 182 TextOrIcon* toiF; 183 TextOrIcon* toiE; 184 TextOrIcon* toiD; 185 TextOrIcon* toiC; 186 TextOrIcon* toiT; 187 TextOrIcon* toiR; 188 TextOrIcon* toiM; 189 TextOrIcon* toiW; 190 TextOrIcon *toiL; 191 TextOrIcon *toiFx; 192 193 Gtk::Image* imgPanelEnd[8]; 194 Gtk::VBox* vbPanelEnd[8]; 195 196 Gtk::ScrolledWindow* favoritePanelSW; 197 Gtk::ScrolledWindow* exposurePanelSW; 198 Gtk::ScrolledWindow* detailsPanelSW; 199 Gtk::ScrolledWindow* colorPanelSW; 200 Gtk::ScrolledWindow* transformPanelSW; 201 Gtk::ScrolledWindow* rawPanelSW; 202 // Gtk::ScrolledWindow* advancedPanelSW; 203 Gtk::ScrolledWindow *localPanelSW; 204 Gtk::ScrolledWindow *effectsPanelSW; 205 206 std::vector<MyExpander*> expList; 207 208 bool hasChanged; 209 210 void addPanel (Gtk::Box* where, FoldableToolPanel* panel, int level = 1); 211 void foldThemAll (GdkEventButton* event); 212 void updateVScrollbars (bool hide); 213 void addfavoritePanel (Gtk::Box* where, FoldableToolPanel* panel, int level = 1); 214 215 private: 216 EditDataProvider *editDataProvider; 217 218 public: 219 CoarsePanel* coarse; 220 Gtk::Notebook* toolPanelNotebook; 221 222 ToolPanelCoordinator (bool batch = false); 223 ~ToolPanelCoordinator () override; 224 getChangedState()225 bool getChangedState () 226 { 227 return hasChanged; 228 } 229 void updateCurveBackgroundHistogram( 230 const LUTu& histToneCurve, 231 const LUTu& histLCurve, 232 const LUTu& histCCurve, 233 const LUTu& histLCAM, 234 const LUTu& histCCAM, 235 const LUTu& histRed, 236 const LUTu& histGreen, 237 const LUTu& histBlue, 238 const LUTu& histLuma, 239 const LUTu& histLRETI 240 ); 241 void foldAllButOne (Gtk::Box* parent, FoldableToolPanel* openedSection); 242 243 // multiple listeners can be added that are notified on changes (typical: profile panel and the history) addPParamsChangeListener(PParamsChangeListener * pp)244 void addPParamsChangeListener (PParamsChangeListener* pp) 245 { 246 paramcListeners.push_back (pp); 247 } 248 249 // toolpanellistener interface 250 void refreshPreview(const rtengine::ProcEvent& event) override; 251 void panelChanged(const rtengine::ProcEvent& event, const Glib::ustring& descr) override; 252 void setTweakOperator (rtengine::TweakOperator *tOperator) override; 253 void unsetTweakOperator (rtengine::TweakOperator *tOperator) override; 254 255 void imageTypeChanged (bool isRaw, bool isBayer, bool isXtrans, bool isMono = false) override; 256 257 // void autoContrastChanged (double autoContrast); 258 // profilechangelistener interface 259 void profileChange( 260 const rtengine::procparams::PartialProfile *nparams, 261 const rtengine::ProcEvent& event, 262 const Glib::ustring& descr, 263 const ParamsEdited* paramsEdited = nullptr, 264 bool fromLastSave = false 265 ) override; 266 void setDefaults(const rtengine::procparams::ProcParams* defparams) override; 267 268 // DirSelectionListener interface 269 void dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile); 270 271 // to support the GUI: 272 CropGUIListener* getCropGUIListener (); // through the CropGUIListener the editor area can notify the "crop" ToolPanel when the crop selection changes 273 274 // init the toolpanelcoordinator with an image & close it 275 void initImage (rtengine::StagedImageProcessor* ipc_, bool israw); 276 void closeImage (); 277 278 // update the "expanded" state of the Tools 279 void updateToolState (); 280 void openAllTools (); 281 void closeAllTools (); 282 // read/write the "expanded" state of the expanders & read/write the crop panel settings (ratio, guide type, etc.) 283 void readOptions (); 284 void writeOptions (); 285 void writeToolExpandedStatus (std::vector<int> &tpOpen); 286 287 288 // wbprovider interface getAutoWB(double & temp,double & green,double equal)289 void getAutoWB (double& temp, double& green, double equal) override 290 { 291 if (ipc) { 292 ipc->getAutoWB (temp, green, equal); 293 } 294 } getCamWB(double & temp,double & green)295 void getCamWB (double& temp, double& green) override 296 { 297 if (ipc) { 298 ipc->getCamWB (temp, green); 299 } 300 } 301 302 std::vector<WBPreset> getWBPresets() const override; 303 304 //DFProvider interface 305 rtengine::RawImage* getDF() override; 306 307 //FFProvider interface 308 rtengine::RawImage* getFF() override; 309 Glib::ustring GetCurrentImageFilePath() override; 310 bool hasEmbeddedFF() override; 311 312 // FilmNegProvider interface 313 bool getFilmNegativeExponents(rtengine::Coord spotA, rtengine::Coord spotB, std::array<float, 3>& newExps) override; 314 bool getImageSpotValues(rtengine::Coord spot, int spotSize, std::array<float, 3>& rawValues) override; 315 316 // rotatelistener interface 317 void straightenRequested () override; 318 void autoCropRequested () override; 319 double autoDistorRequested () override; 320 void autoPerspectiveRequested(bool horiz, bool vert, double &angle, double &horizontal, double &vertical, double &shear, const std::vector<rtengine::ControlLine> *lines=nullptr) override; 321 void updateTransformPreviewRequested (rtengine::ProcEvent event, bool render_perspective) override; 322 323 // spotwblistener interface 324 void spotWBRequested (int size) override; 325 326 // croppanellistener interface 327 void cropSelectRequested() override; 328 // void cropResetRequested() override; 329 void cropEnableChanged(bool enabled) override; 330 331 // PerspCorrectionPanelListener interface 332 void controlLineEditModeChanged(bool active) override; 333 334 // icmpanellistener interface 335 void saveInputICCReference(const Glib::ustring& fname, bool apply_wb) override; 336 337 // imageareatoollistener interface 338 void spotWBselected(int x, int y, Thumbnail* thm = nullptr) override; 339 void sharpMaskSelected(bool sharpMask) override; 340 int getSpotWBRectSize() const override; 341 void cropSelectionReady() override; 342 void rotateSelectionReady(double rotate_deg, Thumbnail* thm = nullptr) override; 343 ToolBar* getToolBar() const override; 344 CropGUIListener* startCropEditing(Thumbnail* thm = nullptr) override; 345 346 void updateTPVScrollbar (bool hide); 347 bool handleShortcutKey (GdkEventKey* event); 348 349 // ToolBarListener interface 350 void toolSelected(ToolMode tool) override; 351 void toolDeselected(ToolMode tool) override; 352 void editModeSwitchedOff() override; 353 354 void setEditProvider(EditDataProvider *provider); 355 356 // AutoExpListener interface 357 void autoExpChanged(double expcomp, int bright, int contr, int black, int hlcompr, int hlcomprthresh, bool hlrecons) override; 358 void autoMatchedToneCurveChanged(const std::vector<double> &curve, const std::vector<double> &curve2) override; 359 360 void setAreaDrawListener(AreaDrawListener *listener) override; 361 362 // DeltaEColorProvider interface 363 bool getDeltaELCH(EditUniqueID id, rtengine::Coord pos, float &L, float &C, float &H) override; 364 365 void setProgressListener(rtengine::ProgressListener *pl); 366 367 private: 368 IdleRegister idle_register; 369 }; 370 371