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 <gtkmm.h>
23 #include "adjuster.h"
24 #include "toolpanel.h"
25 #include "curveeditor.h"
26 #include "curveeditorgroup.h"
27 #include "mycurve.h"
28 #include "guiutils.h"
29 
30 class ToneCurve: public ToolParamBlock, public FoldableToolPanel, public CurveListener, public AdjusterListener
31 {
32 private:
33     IdleRegister idle_register;
34 
35 protected:
36     Adjuster *contrast;
37     MyComboBoxText* toneCurveMode;
38     MyComboBoxText* toneCurveMode2;
39     Gtk::ToggleButton *histmatching;
40     bool fromHistMatching;
41 
42     sigc::connection tcmodeconn, tcmode2conn;
43     sigc::connection histmatchconn;
44     CurveEditorGroup* curveEditorG;
45     CurveEditorGroup* curveEditorG2;
46     DiagonalCurveEditor* shape;
47     DiagonalCurveEditor* shape2;
48     CurveEditorGroup *satcurveG;
49     FlatCurveEditor *satcurve;
50     Adjuster *perceptualStrength;
51 
52     rtengine::ProcEvent EvHistMatching;
53     rtengine::ProcEvent EvHistMatchingBatch;
54     rtengine::ProcEvent EvSatCurve;
55     rtengine::ProcEvent EvPerceptualStrength;
56 
57     // used temporarily in eventing
58     std::vector<double> nextToneCurve;
59     std::vector<double> nextToneCurve2;
60 
61     void setHistmatching(bool enabled);
62     void showPerceptualStrength();
63 
64     rtengine::procparams::ToneCurveParams initial_params;
65 
66 public:
67     ToneCurve();
68     ~ToneCurve() override;
69 
70     void read(const rtengine::procparams::ProcParams* pp) override;
71     void write(rtengine::procparams::ProcParams* pp) override;
72     void setDefaults(const rtengine::procparams::ProcParams* defParams) override;
73     void trimValues(rtengine::procparams::ProcParams* pp) override;
74     void autoOpenCurve() override;
75     void setEditProvider(EditDataProvider *provider) override;
76 
77     float blendPipetteValues(CurveEditor *ce, float chan1, float chan2, float chan3) override;
78 
79     void enableAll(bool yes=true);
80     void curveChanged (CurveEditor* ce) override;
81     void curveMode1Changed ();
82     bool curveMode1Changed_ ();
83     void curveMode2Changed ();
84     bool curveMode2Changed_ ();
85     void expandCurve (bool isExpanded);
86     bool isCurveExpanded ();
87     void updateCurveBackgroundHistogram(
88         const LUTu& histToneCurve,
89         const LUTu& histLCurve,
90         const LUTu& histCCurve,
91         const LUTu& histLCAM,
92         const LUTu& histCCAM,
93         const LUTu& histRed,
94         const LUTu& histGreen,
95         const LUTu& histBlue,
96         const LUTu& histLuma,
97         const LUTu& histLRETI
98     );
99 
100     void histmatchingToggled();
101     void autoMatchedToneCurveChanged(const std::vector<double> &curve, const std::vector<double> &curve2);
102     void setRaw (bool raw);
103 
104     void adjusterChanged(Adjuster *a, double newval) override;
105 
106     void toolReset(bool to_initial) override;
107 };
108