]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
#3472 TDx
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / HistogramDialog.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26
27 #ifndef __HISTOGRAMSDIALOG__
28 #define __HISTOGRAMSDIALOG__
29
30
31 // ----------------------------------------------------------------------------
32 // wx headers inclusion.
33 // For compilers that support precompilation, includes <wx/wx.h>.
34 // ----------------------------------------------------------------------------
35 #include <wx/wxprec.h>
36 #ifdef __BORLANDC__
37 #pragma hdrstop
38 #endif
39 #ifndef WX_PRECOMP
40 #include <wx/wx.h>
41 #endif
42
43  //---------------------
44  // Includes
45  //----------------------
46  #include "HistogramWidget.h"
47  #include "vtkImageData.h"      
48  //#include <vector>
49  #include <vtkPiecewiseFunction.h>
50  #include <vtkColorTransferFunction.h>
51 #if (VTK_MAJOR_VERSION <= 7) 
52         #include <vtkVolumeRayCastMapper.h>
53 #else 
54         #include <vtkFixedPointVolumeRayCastMapper.h>
55 #endif
56  #include <vtkVolume.h>
57  //#include "../wxMPRWidget.h"
58
59 #include "HistogramDialogComboBoxItem.h"
60 #include <wx/checkbox.h>
61 #include <wx/statbmp.h>
62
63 class HistogramDialog:public wxDialog
64 {
65 public:
66         /*
67          Constructor
68         */
69         HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,bool extracontrols=false);
70         /*
71          Constructor
72         */
73         HistogramDialog(wxWindow *parent,wxString title,bool extracontrols=false);
74         ~HistogramDialog();
75         /*
76          Methods
77         */
78         /*
79                 get number of points of the transference function
80         */
81         int getSizeTransferenceFunction();
82         /*
83                 get number of points of the barColor
84         */
85         int getSizeBarColor();
86         /*
87                 get a point of the transference function
88         */
89         void getTransferenceFunctionPoint(int index,int& x,int& y);
90         /*
91                 get a  color int the bqr color
92         */
93         void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
94         /*
95                 get a point of the Histogram
96                 given the grey value
97         */
98         int getHistogramPoint(int gValue);
99
100         //--------------------
101         // bar Information
102         //---------------------
103         /*
104          Get the porcentage of the positions of 
105          the min,max and actual in the bar range
106         */
107         float getMaxShowedPorcentage();
108         float getMinShowedPorcentage(); 
109         float getActualShowedPorcentage();
110
111         //---------------------------------------
112         // setting data in transferences function
113         // and in bar color
114         //----------------------------------------
115         /*
116           Adds a point to the transference function
117         */
118         bool addPointToTransferenceFunction(double x, double y);
119         /*
120                 add a color point to the histogram
121                 @param x the level of grey to which the color is assigned
122                 @param red the level of red for the color
123                 @param green the level of red for the color
124                 @param blue the level of red for the color
125         */
126         bool addColorPoint(double x,int red,int green, int blue);
127         //------------------------
128         //Erase data
129         //------------------------
130         
131         /*
132          Erase all the points that are in the transference function
133         */
134         void erasePointsTransferenceFunction();
135         void eraseColorPoints();
136         //-------------------
137         // Getter and setters
138         //-------------------
139
140         void setTransferenceFunctionHasPoints(bool hasPoints);
141         void setTransferenceFunctionHasColor(bool hasColorPoints);
142         
143         //returns if the user has pressed refresh       
144         
145         bool getRefreshed();
146         void setCTF(vtkColorTransferFunction* cf);
147         void setTF(vtkPiecewiseFunction* tf);
148 #if (VTK_MAJOR_VERSION <= 7) 
149         void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
150 #else 
151         void setVolumeMapper(vtkFixedPointVolumeRayCastMapper* volMapper);
152 #endif
153         void setVolume(vtkVolume* vol);
154         //void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
155         //void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
156
157         //--------------------
158         // plotter Information
159         //---------------------
160         void updatePlotter();
161         
162         //-----------------------
163         //Handling events
164         //-----------------------
165
166         void OnSaveData(wxCommandEvent& event);
167         void OnLoadData(wxCommandEvent& event);
168         void OnRefreshBtn(wxCommandEvent& event);
169         
170
171         /**
172         **      Initialize the histogram 
173         */
174         void initializeHistogram(vtkImageData* img);
175         /**
176         **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
177         **/
178         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
179
180         /**
181         **      Returns two vectors, the grey level of the point and its value, the red, green
182         **      and blue value is between [0,1]
183         **/
184         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
185                                                                         std::vector<double>& red,
186                                                                         std::vector<double>& green,
187                                                                         std::vector<double>& blue);
188         void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
189
190         /**
191         ** Set to true in the constructor
192         **/
193         void setInfoPanExtraControls(std::vector<HistogramDialogComboBoxItem*> comboitems);
194         
195
196         /**
197         *
198         */
199         void OnEditColorsCombo(wxCommandEvent& event);
200         void OnDeleteColor(wxCommandEvent& event);
201
202         std::vector<HistogramDialogComboBoxItem*> getComboBoxItems(){return _comboitems;}
203
204         void UpdateCurrentComboElement();
205         
206 private:
207         /*
208         Histogram Widget
209         */
210         HistogramWidget*  histogramW;
211 /**
212 **      
213 **/
214         /*
215          ok Button
216         */
217         //wxButton                      *okBtn;
218         wxBitmapButton          *okBtn;
219         /*
220          cancel Button
221         */
222         //wxButton                                                      *cancelBtn;
223         wxBitmapButton                                          *cancelBtn;
224         /*
225          save Button
226         */
227         wxButton                                                        *saveDataBtn;   
228         /*
229         Load Button
230         */
231         wxButton                                                        *loadDataBtn;
232         /*
233         Refresh Button
234         */
235         wxButton                                                        *refreshBtn;
236         wxPanel                                                         *_panextracontrols;
237         
238         // the user had pressed refresh
239         bool refreshed;
240         
241         vtkColorTransferFunction                        *_ctfun;
242         vtkPiecewiseFunction                            *_tfun;
243 #if (VTK_MAJOR_VERSION <= 7) 
244         vtkVolumeRayCastMapper                          *volumeMapper; 
245 #else 
246         vtkFixedPointVolumeRayCastMapper        *volumeMapper; 
247 #endif
248         vtkVolume                                                       *newvol;
249
250         //things to refresh
251         //wxVtkMPR3DView                                        *wxvtkmpr3Dview;
252         //wxVtkClipping3DView                           *wxvtkclipping3Dview;
253
254         
255         wxSizer* getControls(bool extracontrols = false);
256
257         
258         
259 //      DECLARE_CLASS(HistogramDialog);
260         // any class wishing to process wxWindows events must use this macro
261         //DECLARE_EVENT_TABLE()
262
263         void initializeHistogramDialog(bool extracontrols);
264
265          wxPanel* getPanExtraControls();
266
267          std::vector<wxBitmapButton*> bitmapbuttonsvect;
268          std::vector<HistogramDialogComboBoxItem*> _comboitems;
269
270          void setCurrentColorConfigurationIntoButton();
271          void AddNewBitmapButton();
272          wxSizer* getBitmapButtonDelete(wxBitmap bitmap);
273          std::vector<wxBitmapButton*> _deletebuttonsvector;
274
275          int _maxgreyvalue;
276          int _currentcolorselectedbitmap;
277 };
278
279 #endif
280
281
282