1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
27 #ifndef __HISTOGRAMSDIALOG__
28 #define __HISTOGRAMSDIALOG__
31 // ----------------------------------------------------------------------------
32 // wx headers inclusion.
33 // For compilers that support precompilation, includes <wx/wx.h>.
34 // ----------------------------------------------------------------------------
35 #include <wx/wxprec.h>
43 //---------------------
45 //----------------------
46 #include "HistogramWidget.h"
47 #include "vtkImageData.h"
49 #include <vtkPiecewiseFunction.h>
50 #include <vtkColorTransferFunction.h>
51 #if (VTK_MAJOR_VERSION <= 7)
52 #include <vtkVolumeRayCastMapper.h>
54 #include <vtkFixedPointVolumeRayCastMapper.h>
56 #include <vtkVolume.h>
57 //#include "../wxMPRWidget.h"
59 #include "HistogramDialogComboBoxItem.h"
60 #include <wx/checkbox.h>
61 #include <wx/statbmp.h>
63 class HistogramDialog:public wxDialog
69 HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,bool extracontrols=false);
73 HistogramDialog(wxWindow *parent,wxString title,bool extracontrols=false);
79 get number of points of the transference function
81 int getSizeTransferenceFunction();
83 get number of points of the barColor
85 int getSizeBarColor();
87 get a point of the transference function
89 void getTransferenceFunctionPoint(int index,int& x,int& y);
91 get a color int the bqr color
93 void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
95 get a point of the Histogram
98 int getHistogramPoint(int gValue);
100 //--------------------
102 //---------------------
104 Get the porcentage of the positions of
105 the min,max and actual in the bar range
107 float getMaxShowedPorcentage();
108 float getMinShowedPorcentage();
109 float getActualShowedPorcentage();
111 //---------------------------------------
112 // setting data in transferences function
114 //----------------------------------------
116 Adds a point to the transference function
118 bool addPointToTransferenceFunction(double x, double y);
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
126 bool addColorPoint(double x,int red,int green, int blue);
127 //------------------------
129 //------------------------
132 Erase all the points that are in the transference function
134 void erasePointsTransferenceFunction();
135 void eraseColorPoints();
136 //-------------------
137 // Getter and setters
138 //-------------------
140 void setTransferenceFunctionHasPoints(bool hasPoints);
141 void setTransferenceFunctionHasColor(bool hasColorPoints);
143 //returns if the user has pressed refresh
146 void setCTF(vtkColorTransferFunction* cf);
147 void setTF(vtkPiecewiseFunction* tf);
148 #if (VTK_MAJOR_VERSION <= 7)
149 void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
151 void setVolumeMapper(vtkFixedPointVolumeRayCastMapper* volMapper);
153 void setVolume(vtkVolume* vol);
154 //void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
155 //void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
157 //--------------------
158 // plotter Information
159 //---------------------
160 void updatePlotter();
162 //-----------------------
164 //-----------------------
166 void OnSaveData(wxCommandEvent& event);
167 void OnLoadData(wxCommandEvent& event);
168 void OnRefreshBtn(wxCommandEvent& event);
172 ** Initialize the histogram
174 void initializeHistogram(vtkImageData* img);
176 ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
178 void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
181 ** Returns two vectors, the grey level of the point and its value, the red, green
182 ** and blue value is between [0,1]
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);
191 ** Set to true in the constructor
193 void setInfoPanExtraControls(std::vector<HistogramDialogComboBoxItem*> comboitems);
199 void OnEditColorsCombo(wxCommandEvent& event);
200 void OnDeleteColor(wxCommandEvent& event);
202 std::vector<HistogramDialogComboBoxItem*> getComboBoxItems(){return _comboitems;}
204 void UpdateCurrentComboElement();
210 HistogramWidget* histogramW;
218 wxBitmapButton *okBtn;
222 //wxButton *cancelBtn;
223 wxBitmapButton *cancelBtn;
227 wxButton *saveDataBtn;
231 wxButton *loadDataBtn;
235 wxButton *refreshBtn;
236 wxPanel *_panextracontrols;
238 // the user had pressed refresh
241 vtkColorTransferFunction *_ctfun;
242 vtkPiecewiseFunction *_tfun;
243 #if (VTK_MAJOR_VERSION <= 7)
244 vtkVolumeRayCastMapper *volumeMapper;
246 vtkFixedPointVolumeRayCastMapper *volumeMapper;
251 //wxVtkMPR3DView *wxvtkmpr3Dview;
252 //wxVtkClipping3DView *wxvtkclipping3Dview;
255 wxSizer* getControls(bool extracontrols = false);
259 // DECLARE_CLASS(HistogramDialog);
260 // any class wishing to process wxWindows events must use this macro
261 //DECLARE_EVENT_TABLE()
263 void initializeHistogramDialog(bool extracontrols);
265 wxPanel* getPanExtraControls();
267 std::vector<wxBitmapButton*> bitmapbuttonsvect;
268 std::vector<HistogramDialogComboBoxItem*> _comboitems;
270 void setCurrentColorConfigurationIntoButton();
271 void AddNewBitmapButton();
272 wxSizer* getBitmapButtonDelete(wxBitmap bitmap);
273 std::vector<wxBitmapButton*> _deletebuttonsvector;
276 int _currentcolorselectedbitmap;