1 /*
2     delaboratory - color correction utility
3     Copyright (C) 2011 Jacek Poplawski
4 
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "gui.h"
20 #include "view_mode_panel.h"
21 #include "layer_grid_panel.h"
22 #include "layer_frame_manager.h"
23 #include "window_wx.h"
24 #include "base_layer.h"
25 #include "generic_layer_frame.h"
26 #include "histogram_mode_panel.h"
27 #include "image_area_panel.h"
28 #include "logger.h"
29 
deGUI()30 deGUI::deGUI()
31 {
32     viewModePanel = NULL;
33     layerGridPanel = NULL;
34     histogramModePanel = NULL;
35     imageAreaPanel = NULL;
36 }
37 
~deGUI()38 deGUI::~deGUI()
39 {
40 }
41 
setViewModePanel(deViewModePanel * _viewModePanel)42 void deGUI::setViewModePanel(deViewModePanel* _viewModePanel)
43 {
44     viewModePanel = _viewModePanel;
45 }
46 
setLayerGridPanel(deLayerGridPanel * _panel)47 void deGUI::setLayerGridPanel(deLayerGridPanel* _panel)
48 {
49     layerGridPanel = _panel;
50 }
51 
setHistogramModePanel(deHistogramModePanel * _histogramModePanel)52 void deGUI::setHistogramModePanel(deHistogramModePanel* _histogramModePanel)
53 {
54     histogramModePanel = _histogramModePanel;
55 }
56 
57 
updateViewModePanelMode()58 void deGUI::updateViewModePanelMode()
59 {
60     if (viewModePanel)
61     {
62         viewModePanel->updateMode();
63     }
64 }
65 
updateViewModePanelNames()66 void deGUI::updateViewModePanelNames()
67 {
68     if (viewModePanel)
69     {
70         viewModePanel->updateNames();
71     }
72 }
73 
updateLayerGrid()74 void deGUI::updateLayerGrid()
75 {
76     if (layerGridPanel)
77     {
78         layerGridPanel->update();
79     }
80 }
81 
openLayerFrame(deBaseLayer & layer,deLayerProcessor & layerProcessor,deLayerFrameManager & layerFrameManager,int index)82 void deGUI::openLayerFrame(deBaseLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& layerFrameManager, int index)
83 {
84     if (!layerFrameManager.checkLayerFrame(index))
85     {
86         deWindowWX window(layerGridPanel);
87         const std::string name = layer.getType();
88 
89         deFrame* frame = new deGenericLayerFrame(window, name, layer, layerProcessor, layerFrameManager, index);
90         if (frame)
91         {
92             frame->show();
93         }
94     }
95 }
96 
updateHistogramMode(int channel)97 void deGUI::updateHistogramMode(int channel)
98 {
99     if (histogramModePanel)
100     {
101         histogramModePanel->updateMode(channel);
102     }
103 }
104 
updateHistogramNames()105 void deGUI::updateHistogramNames()
106 {
107     if (histogramModePanel)
108     {
109         histogramModePanel->updateNames();
110     }
111 }
112 
setImageAreaPanel(deImageAreaPanel * _imageAreaPanel)113 void deGUI::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel)
114 {
115     imageAreaPanel = _imageAreaPanel;
116 }
117 
updateImageAreaSize()118 void deGUI::updateImageAreaSize()
119 {
120     if (imageAreaPanel)
121     {
122         imageAreaPanel->updateSize(false);
123     }
124 }
125 
lockSize()126 void deGUI::lockSize()
127 {
128     if (imageAreaPanel)
129     {
130         imageAreaPanel->lockSize();
131     }
132     else
133     {
134         logError("can't lockSize, no imageAreaPanel");
135     }
136 }
137 
unlockSize()138 void deGUI::unlockSize()
139 {
140     if (imageAreaPanel)
141     {
142         imageAreaPanel->unlockSize();
143     }
144     else
145     {
146         logError("can't unlockSize, no imageAreaPanel");
147     }
148 }
149 
150