1 /*
2  *  This file is part of RawTherapee.
3  *
4  *  Copyright (c) 2018 Jacques DESMIS <jdesmis@gmail.com>
5  *  Copyright (c) 2018 Jean-Christophe FRISCH <natureh.510@gmail.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 <https://www.gnu.org/licenses/>.
19  */
20 #pragma once
21 
22 #include <lcms2.h>
23 
24 #include <gtkmm.h>
25 #include "adjuster.h"
26 #include <vector>
27 
28 class RTWindow;
29 
30 class ICCProfileCreator : public Gtk::Dialog, public AdjusterListener
31 {
32 
33 private:
34 
35     enum class ColorTemp {
36         D50 = 5003,  // for Widegamut, Prophoto Best, Beta -> D50
37         D60 = 6005,  // for ACESc                          -> D60
38         D65 = 6504   // for sRGB, AdobeRGB, Bruce Rec2020  -> D65
39     };
40 
41     cmsFloat64Number ga[7]; // 7 parameters for smoother curves
42 
43     //------------------------ Params -----------------------
44     Glib::ustring primariesPreset;
45     double redPrimaryX;
46     double redPrimaryY;
47     double greenPrimaryX;
48     double greenPrimaryY;
49     double bluePrimaryX;
50     double bluePrimaryY;
51     Glib::ustring gammaPreset;
52     double gamma;
53     double slope;
54     bool appendParamsToDesc;
55     bool v2except;
56     Glib::ustring profileVersion;
57     Glib::ustring illuminant;
58     Glib::ustring description;
59     Glib::ustring copyright;
60     //-------------------------------------------------------
61 
62     RTWindow *parent;
63 
64     Adjuster* aGamma;
65     Adjuster* aSlope;
66     Adjuster* aPrimariesRedX;
67     Adjuster* aPrimariesRedY;
68     Adjuster* aPrimariesGreenX;
69     Adjuster* aPrimariesGreenY;
70     Adjuster* aPrimariesBlueX;
71     Adjuster* aPrimariesBlueY;
72 
73     Gtk::Grid* primariesGrid;
74     MyComboBoxText* iccVersion;
75     MyComboBoxText* trcPresets;
76     sigc::connection trcpresetsconn;
77     MyComboBoxText* primaries;
78     sigc::connection primariesconn;
79     MyComboBoxText* cIlluminant;
80     sigc::connection illconn;
81     Gtk::Entry* eDescription;
82     Gtk::Entry* eCopyright;
83     Gtk::Button* resetCopyright;
84     Gtk::CheckButton *cAppendParamsToDesc;
85 
86     //Glib::ustring lastPath;
87 
88     void initWithDefaults ();
89     void storeDefaults ();
90     void storeValues();
91 
92     void updateICCVersion();
93     void primariesChanged();
94     void illuminantChanged();
95     void trcPresetsChanged();
96     void adjusterChanged(Adjuster* a, double newval) override;
97     static std::vector<Glib::ustring> getGamma();
98     Glib::ustring getPrimariesPresetName(const Glib::ustring &preset);
99     void getPrimaries(const Glib::ustring &preset, double *p, ColorTemp &temp);
100     Glib::ustring getGammaPresetName(const Glib::ustring &preset);
101     void getGamma(const Glib::ustring &preset, double &gamma, double &slope);
102     void savePressed();
103     void closePressed();
104     void onResetCopyright();
105 
106 public:
107     explicit ICCProfileCreator (RTWindow *rtwindow);
108 };
109