]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
011314d19e71d17e5e0fc5f4d64435b4a78e016d
[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 #include "HistogramDialogComboBoxItem.h"
30
31 #include <wx/bmpcbox.h>
32
33
34 #define FILENAME "/Data/colorsfunction.txt"
35
36 class HistogramDialog:public wxDialog
37 {
38 public:
39         /*
40          Constructor
41         */
42         HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,int type);
43         /*
44          Constructor
45         */
46         HistogramDialog(wxWindow *parent,wxString title);
47         /*
48          Methods
49         */
50         /*
51                 get number of points of the transference function
52         */
53         int getSizeTransferenceFunction();
54         /*
55                 get number of points of the barColor
56         */
57         int getSizeBarColor();
58         /*
59                 get a point of the transference function
60         */
61         void getTransferenceFunctionPoint(int index,int& x,int& y);
62         /*
63                 get a  color int the bqr color
64         */
65         void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
66         /*
67                 get a point of the Histogram
68                 given the grey value
69         */
70         int getHistogramPoint(int gValue);
71
72         //--------------------
73         // bar Information
74         //---------------------
75         /*
76          Get the porcentage of the positions of 
77          the min,max and actual in the bar range
78         */
79         float getMaxShowedPorcentage();
80         float getMinShowedPorcentage(); 
81         float getActualShowedPorcentage();
82
83         //---------------------------------------
84         // setting data in transferences function
85         // and in bar color
86         //----------------------------------------
87         /*
88           Adds a point to the transference function
89         */
90         bool addPointToTransferenceFunction(double x, double y);
91         /*
92                 add a color point to the histogram
93                 @param x the level of grey to which the color is assigned
94                 @param red the level of red for the color
95                 @param green the level of red for the color
96                 @param blue the level of red for the color
97         */
98         bool addColorPoint(double x,int red,int green, int blue);
99         //------------------------
100         //Erase data
101         //------------------------
102         
103         /*
104          Erase all the points that are in the transference function
105         */
106         void erasePointsTransferenceFunction();
107         void eraseColorPoints();
108         //-------------------
109         // Getter and setters
110         //-------------------
111
112         void setTransferenceFunctionHasPoints(bool hasPoints);
113         void setTransferenceFunctionHasColor(bool hasColorPoints);
114         
115         //returns if the user has pressed refresh       
116         
117         bool getRefreshed();
118         void setCTF(vtkColorTransferFunction* cf);
119         void setTF(vtkPiecewiseFunction* tf);
120         void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
121         void setVolume(vtkVolume* vol);
122         void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
123         void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
124
125         //--------------------
126         // plotter Information
127         //---------------------
128         void updatePlotter();
129         
130         //-----------------------
131         //Handling events
132         //-----------------------
133
134         void OnSaveData(wxCommandEvent& event);
135         void OnLoadData(wxCommandEvent& event);
136         void OnRefreshBtn(wxCommandEvent& event);
137         void OnEditBitmapCombo(wxCommandEvent& event);
138
139         /**
140         **      Initialize the histogram 
141         */
142         void initializeHistogram(vtkImageData* img);
143         /**
144         **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
145         **/
146         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
147
148         /**
149         **      Returns two vectors, the grey level of the point and its value, the red, green
150         **      and blue value is between [0,1]
151         **/
152         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
153                                                                         std::vector<double>& red,
154                                                                         std::vector<double>& green,
155                                                                         std::vector<double>& blue);
156         void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
157
158         void OnBitmapComboItemSelected(wxCommandEvent& event);
159 private:
160         /*
161         Histogram Widget
162         */
163         HistogramWidget*  histogramW;
164 /**
165 **      
166 **/
167         double _maxgreyvalue;
168         /*
169          ok Button
170         */
171         //wxButton              *okBtn;
172         wxBitmapButton          *okBtn;
173         /*
174          cancel Button
175         */
176         //wxButton              *cancelBtn;
177         wxBitmapButton          *cancelBtn;
178         /*
179          save Button
180         */
181         wxButton                *saveDataBtn;   
182         /*
183         Load Button
184         */
185         wxButton                *loadDataBtn;
186         /*
187         Refresh Button
188         */
189         wxButton                *refreshBtn;
190
191         wxSizer* _bitmapsizer;
192         
193         // the user had pressed refresh
194         bool refreshed;
195         
196         vtkColorTransferFunction                        *_ctfun;
197         vtkPiecewiseFunction                            *_tfun;
198         vtkVolumeRayCastMapper                          *volumeMapper; 
199         vtkVolume                                                       *newvol;
200
201         //things to refresh
202         wxVtkMPR3DView                                          *wxvtkmpr3Dview;
203         wxVtkClipping3DView                                     *wxvtkclipping3Dview;
204
205         wxBitmapComboBox*       _bitmapcombo;   
206         std::vector<HistogramDialogComboBoxItem*> _bitmapsitems;
207         wxSizer* getControls();
208         wxSizer* getBitmapCombo();
209         wxBitmapComboBox* getBitmapComboElements();
210         void OnLoadComboBoxData(std::vector<HistogramDialogComboBoxItem*>& itembitmaps, std::string filename,std::vector<double>& greyvect, std::vector<int>& redvect, std::vector<int>& greenvect, std::vector<int>& bluevect);
211         std::vector<wxBitmap*> GetBitmapsList(std::vector<double> greyvect, std::vector<int> redvect, std::vector<int> greenvect, std::vector<int> bluevect);
212 //      DECLARE_CLASS(HistogramDialog);
213         // any class wishing to process wxWindows events must use this macro
214         //DECLARE_EVENT_TABLE()
215
216         void initializeHistogramDialog();
217 };
218
219 #endif
220
221
222