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 #ifndef _DE_CURVES_PANEL_H
20 #define _DE_CURVES_PANEL_H
21 
22 #define CURVES_PANEL_SIZE_X 384
23 #define CURVES_PANEL_SIZE_Y 256
24 
25 #include "wx/wx.h"
26 class deCurvesLayer;
27 class deLayerProcessor;
28 class deChannelManager;
29 class deCanvas;
30 class dePropertyCurves;
31 #include "value.h"
32 #include "histogram.h"
33 #include "color_space.h"
34 #include "size.h"
35 
36 class deCurvesPanel:public wxPanel
37 {
38 private:
39     wxBitmap bitmap;
40     wxBitmap* backgroundBitmap;
41     int sizeX;
42     int sizeY;
43     int channel;
44 
45     bool realtime;
46 
47     void drawPoint(wxDC& dc, deValue x, deValue y);
48     void drawCurve(wxDC& dc);
49 
50 	void click(wxMouseEvent &event);
51 	void release(wxMouseEvent &event);
52 	void move(wxMouseEvent &event);
53     void update(bool finished);
54 
55     int selectedPoint;
56     int lastSelectedPoint;
57 
58     deValue grabX;
59     deValue grabY;
60 
61     void getPosition(wxMouseEvent &event, deValue& x, deValue &y);
62     void setInfo(deValue x, deValue y);
63 
64     deValue marker;
65 
66     int clickPosition;
67 
68     deLayerProcessor& layerProcessor;
69 
70     int layerIndex;
71 
72     dePropertyCurves& property;
73 
74     deColorSpace colorSpace;
75 
76     wxStaticText* infoEntry;
77 
78     void drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2);
79     void drawLines(wxDC& dc);
80 
81 public:
82     deCurvesPanel(wxWindow* parent, deLayerProcessor& _layerProcessor, int _layerIndex, dePropertyCurves& _property, deColorSpace _colorSpace, wxStaticText* _infoEntry);
83     ~deCurvesPanel();
84 
85 	void paintEvent(wxPaintEvent & evt);
86 	void render(wxDC& dc);
87     void paint();
88 
89     void changeChannel(int _channel);
90     void onImageClick(deValue x, deValue y, const deValue* c, const deSize& size);
91 
92     void setMarker(const deValue* c, int n);
93 
94     void generateBackground(const deValue* c, int n);
95     int getClickPosition() const;
96 
97     bool removeSelectedPoint();
98 
99 	DECLARE_EVENT_TABLE()
100 
101 };
102 
103 #endif
104