]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
13f7f3d5a0d47d964ac9e14b12ca3e622e3c29c9
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / HistogramDialog.h
1
2 #ifndef __HISTOGRAMSDIALOG__
3 #define __HISTOGRAMSDIALOG__
4
5
6 // ----------------------------------------------------------------------------
7 // wx headers inclusion.
8 // For compilers that support precompilation, includes <wx/wx.h>.
9 // ----------------------------------------------------------------------------
10 #include <wx/wxprec.h>
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14 #ifndef WX_PRECOMP
15 #include <wx/wx.h>
16 #endif
17
18  //---------------------
19  // Includes
20  //----------------------
21  #include "HistogramWidget.h"
22  #include "vtkImageData.h"      
23  //#include <vector>
24  #include <vtkPiecewiseFunction.h>
25  #include <vtkColorTransferFunction.h>
26  #include <vtkVolumeRayCastMapper.h>
27  #include <vtkVolume.h>
28  //#include "../wxMPRWidget.h"
29
30 #include "HistogramDialogComboBoxItem.h"
31 #include <wx/checkbox.h>
32 #include <wx/statbmp.h>
33
34 class HistogramDialog:public wxDialog
35 {
36 public:
37         /*
38          Constructor
39         */
40         HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,bool extracontrols=false);
41         /*
42          Constructor
43         */
44         HistogramDialog(wxWindow *parent,wxString title,bool extracontrols=false);
45         ~HistogramDialog();
46         /*
47          Methods
48         */
49         /*
50                 get number of points of the transference function
51         */
52         int getSizeTransferenceFunction();
53         /*
54                 get number of points of the barColor
55         */
56         int getSizeBarColor();
57         /*
58                 get a point of the transference function
59         */
60         void getTransferenceFunctionPoint(int index,int& x,int& y);
61         /*
62                 get a  color int the bqr color
63         */
64         void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
65         /*
66                 get a point of the Histogram
67                 given the grey value
68         */
69         int getHistogramPoint(int gValue);
70
71         //--------------------
72         // bar Information
73         //---------------------
74         /*
75          Get the porcentage of the positions of 
76          the min,max and actual in the bar range
77         */
78         float getMaxShowedPorcentage();
79         float getMinShowedPorcentage(); 
80         float getActualShowedPorcentage();
81
82         //---------------------------------------
83         // setting data in transferences function
84         // and in bar color
85         //----------------------------------------
86         /*
87           Adds a point to the transference function
88         */
89         bool addPointToTransferenceFunction(double x, double y);
90         /*
91                 add a color point to the histogram
92                 @param x the level of grey to which the color is assigned
93                 @param red the level of red for the color
94                 @param green the level of red for the color
95                 @param blue the level of red for the color
96         */
97         bool addColorPoint(double x,int red,int green, int blue);
98         //------------------------
99         //Erase data
100         //------------------------
101         
102         /*
103          Erase all the points that are in the transference function
104         */
105         void erasePointsTransferenceFunction();
106         void eraseColorPoints();
107         //-------------------
108         // Getter and setters
109         //-------------------
110
111         void setTransferenceFunctionHasPoints(bool hasPoints);
112         void setTransferenceFunctionHasColor(bool hasColorPoints);
113         
114         //returns if the user has pressed refresh       
115         
116         bool getRefreshed();
117         void setCTF(vtkColorTransferFunction* cf);
118         void setTF(vtkPiecewiseFunction* tf);
119         void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
120         void setVolume(vtkVolume* vol);
121         //void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
122         //void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
123
124         //--------------------
125         // plotter Information
126         //---------------------
127         void updatePlotter();
128         
129         //-----------------------
130         //Handling events
131         //-----------------------
132
133         void OnSaveData(wxCommandEvent& event);
134         void OnLoadData(wxCommandEvent& event);
135         void OnRefreshBtn(wxCommandEvent& event);
136         
137
138         /**
139         **      Initialize the histogram 
140         */
141         void initializeHistogram(vtkImageData* img);
142         /**
143         **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
144         **/
145         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
146
147         /**
148         **      Returns two vectors, the grey level of the point and its value, the red, green
149         **      and blue value is between [0,1]
150         **/
151         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
152                                                                         std::vector<double>& red,
153                                                                         std::vector<double>& green,
154                                                                         std::vector<double>& blue);
155         void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
156
157         /**
158         ** Set to true in the constructor
159         **/
160         void setInfoPanExtraControls(std::vector<HistogramDialogComboBoxItem*> comboitems);
161         
162
163         /**
164         *
165         */
166         void OnEditColorsCombo(wxCommandEvent& event);
167         void OnDeleteColor(wxCommandEvent& event);
168
169         std::vector<HistogramDialogComboBoxItem*> getComboBoxItems(){return _comboitems;}
170
171         void UpdateCurrentComboElement();
172         
173 private:
174         /*
175         Histogram Widget
176         */
177         HistogramWidget*  histogramW;
178 /**
179 **      
180 **/
181         /*
182          ok Button
183         */
184         //wxButton              *okBtn;
185         wxBitmapButton          *okBtn;
186         /*
187          cancel Button
188         */
189         //wxButton              *cancelBtn;
190         wxBitmapButton          *cancelBtn;
191         /*
192          save Button
193         */
194         wxButton                *saveDataBtn;   
195         /*
196         Load Button
197         */
198         wxButton                *loadDataBtn;
199         /*
200         Refresh Button
201         */
202         wxButton                *refreshBtn;
203
204         wxPanel* _panextracontrols;
205         
206         
207         // the user had pressed refresh
208         bool refreshed;
209         
210         vtkColorTransferFunction                        *_ctfun;
211         vtkPiecewiseFunction                            *_tfun;
212         vtkVolumeRayCastMapper                          *volumeMapper; 
213         vtkVolume                                                       *newvol;
214
215         //things to refresh
216         //wxVtkMPR3DView                                                *wxvtkmpr3Dview;
217         //wxVtkClipping3DView                                   *wxvtkclipping3Dview;
218
219         
220         wxSizer* getControls(bool extracontrols = false);
221
222         
223         
224 //      DECLARE_CLASS(HistogramDialog);
225         // any class wishing to process wxWindows events must use this macro
226         //DECLARE_EVENT_TABLE()
227
228         void initializeHistogramDialog(bool extracontrols);
229
230          wxPanel* getPanExtraControls();
231
232          std::vector<wxBitmapButton*> bitmapbuttonsvect;
233          std::vector<HistogramDialogComboBoxItem*> _comboitems;
234
235          void setCurrentColorConfigurationIntoButton();
236          void AddNewBitmapButton();
237          wxSizer* getBitmapButtonDelete(wxBitmap bitmap);
238          std::vector<wxBitmapButton*> _deletebuttonsvector;
239
240          int _maxgreyvalue;
241          int _currentcolorselectedbitmap;
242 };
243
244 #endif
245
246
247