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