1 /*
2 *  This file is part of RawTherapee.
3 *
4 *  Copyright (c) 2012 Oliver Duis <oduis@oliverduis.de>
5 *
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.
10 *
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.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
18 */
19 #pragma once
20 
21 #include <gtkmm.h>
22 
23 #include "guiutils.h"
24 #include "toolpanel.h"
25 
26 class LensProfilePanel final :
27     public ToolParamBlock,
28     public FoldableToolPanel
29 {
30 public:
31     LensProfilePanel();
32 
33     void read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override;
34     void write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override;
35     void setRawMeta(bool raw, const rtengine::FramesMetaData* pMeta);
36 
37     void onLCPFileChanged();
38     void onUseDistChanged();
39     void onUseVignChanged();
40     void onUseCAChanged();
41 
42     void setBatchMode(bool yes) override;
43 
44     void onLensfunCameraChanged();
45     void onLensfunLensChanged();
46     void onCorrModeChanged(const Gtk::RadioButton* rbChanged);
47 
48 private:
49     class LFDbHelper final
50     {
51     public:
52         class LFModelCam final :
53             public Gtk::TreeModel::ColumnRecord
54         {
55         public:
LFModelCam()56             LFModelCam()
57             {
58                 add(make);
59                 add(model);
60             }
61             Gtk::TreeModelColumn<Glib::ustring> make;
62             Gtk::TreeModelColumn<Glib::ustring> model;
63         };
64 
65         class LFModelLens final :
66             public Gtk::TreeModel::ColumnRecord
67         {
68         public:
LFModelLens()69             LFModelLens()
70             {
71                 add(lens);
72                 add(prettylens);
73             }
74             Gtk::TreeModelColumn<Glib::ustring> lens;
75             Gtk::TreeModelColumn<Glib::ustring> prettylens;
76         };
77 
78         LFModelCam lensfunModelCam;
79         LFModelLens lensfunModelLens;
80 
81         Glib::RefPtr<Gtk::TreeStore> lensfunCameraModel;
82         Glib::RefPtr<Gtk::TreeStore> lensfunLensModel;
83 
84         LFDbHelper();
85 
86         void fillLensfunCameras();
87         void fillLensfunLenses();
88     };
89 
90     void updateDisabled(bool enable);
91 
92     bool setLensfunCamera(const Glib::ustring& make, const Glib::ustring& model);
93     bool setLensfunLens(const Glib::ustring& lens);
94     bool checkLensfunCanCorrect(bool automatch);
95     void setManualParamsVisibility(bool setVisible);
96     void updateLensfunWarning();
97 
98     bool lcModeChanged;
99     bool lcpFileChanged;
100     bool useDistChanged;
101     bool useVignChanged;
102     bool useCAChanged;
103     bool useLensfunChanged;
104     bool lensfunAutoChanged;
105     bool lensfunCameraChanged;
106     bool lensfunLensChanged;
107     sigc::connection conLCPFile;
108     sigc::connection conUseDist;
109     sigc::connection conUseVign;
110     sigc::connection conUseCA;
111     bool allowFocusDep;
112     bool isRaw;
113     const rtengine::FramesMetaData* metadata;
114 
115     Gtk::Grid* const modesGrid;
116     Gtk::Grid* const distGrid;
117     Gtk::RadioButton* const corrUnchangedRB;
118     Gtk::RadioButton::Group corrGroup;
119     Gtk::RadioButton* const corrOffRB;
120     Gtk::RadioButton* const corrLensfunAutoRB;
121     Gtk::RadioButton* const corrLensfunManualRB;
122     Gtk::RadioButton* const corrLcpFileRB;
123     MyFileChooserButton* const corrLcpFileChooser;
124     Gtk::Label* const lensfunCamerasLbl;
125     MyComboBox* const lensfunCameras;
126     Gtk::Label* const lensfunLensesLbl;
127     MyComboBox* const lensfunLenses;
128     Gtk::Image* const warning;
129     Gtk::CheckButton* const ckbUseDist;
130     Gtk::CheckButton* const ckbUseVign;
131     Gtk::CheckButton* const ckbUseCA;
132 
133     static LFDbHelper* lf;
134 };
135