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