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 #include <vtkVolumeRayCastMapper.h>
52 #include <vtkVolume.h>
53 //#include "../wxMPRWidget.h"
55 #include "HistogramDialogComboBoxItem.h"
56 #include <wx/checkbox.h>
57 #include <wx/statbmp.h>
59 class HistogramDialog:public wxDialog
65 HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,bool extracontrols=false);
69 HistogramDialog(wxWindow *parent,wxString title,bool extracontrols=false);
75 get number of points of the transference function
77 int getSizeTransferenceFunction();
79 get number of points of the barColor
81 int getSizeBarColor();
83 get a point of the transference function
85 void getTransferenceFunctionPoint(int index,int& x,int& y);
87 get a color int the bqr color
89 void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
91 get a point of the Histogram
94 int getHistogramPoint(int gValue);
96 //--------------------
98 //---------------------
100 Get the porcentage of the positions of
101 the min,max and actual in the bar range
103 float getMaxShowedPorcentage();
104 float getMinShowedPorcentage();
105 float getActualShowedPorcentage();
107 //---------------------------------------
108 // setting data in transferences function
110 //----------------------------------------
112 Adds a point to the transference function
114 bool addPointToTransferenceFunction(double x, double y);
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
122 bool addColorPoint(double x,int red,int green, int blue);
123 //------------------------
125 //------------------------
128 Erase all the points that are in the transference function
130 void erasePointsTransferenceFunction();
131 void eraseColorPoints();
132 //-------------------
133 // Getter and setters
134 //-------------------
136 void setTransferenceFunctionHasPoints(bool hasPoints);
137 void setTransferenceFunctionHasColor(bool hasColorPoints);
139 //returns if the user has pressed refresh
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);
149 //--------------------
150 // plotter Information
151 //---------------------
152 void updatePlotter();
154 //-----------------------
156 //-----------------------
158 void OnSaveData(wxCommandEvent& event);
159 void OnLoadData(wxCommandEvent& event);
160 void OnRefreshBtn(wxCommandEvent& event);
164 ** Initialize the histogram
166 void initializeHistogram(vtkImageData* img);
168 ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
170 void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
173 ** Returns two vectors, the grey level of the point and its value, the red, green
174 ** and blue value is between [0,1]
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);
183 ** Set to true in the constructor
185 void setInfoPanExtraControls(std::vector<HistogramDialogComboBoxItem*> comboitems);
191 void OnEditColorsCombo(wxCommandEvent& event);
192 void OnDeleteColor(wxCommandEvent& event);
194 std::vector<HistogramDialogComboBoxItem*> getComboBoxItems(){return _comboitems;}
196 void UpdateCurrentComboElement();
202 HistogramWidget* histogramW;
210 wxBitmapButton *okBtn;
214 //wxButton *cancelBtn;
215 wxBitmapButton *cancelBtn;
219 wxButton *saveDataBtn;
223 wxButton *loadDataBtn;
227 wxButton *refreshBtn;
229 wxPanel *_panextracontrols;
232 // the user had pressed refresh
235 vtkColorTransferFunction *_ctfun;
236 vtkPiecewiseFunction *_tfun;
237 vtkVolumeRayCastMapper *volumeMapper;
241 //wxVtkMPR3DView *wxvtkmpr3Dview;
242 //wxVtkClipping3DView *wxvtkclipping3Dview;
245 wxSizer* getControls(bool extracontrols = false);
249 // DECLARE_CLASS(HistogramDialog);
250 // any class wishing to process wxWindows events must use this macro
251 //DECLARE_EVENT_TABLE()
253 void initializeHistogramDialog(bool extracontrols);
255 wxPanel* getPanExtraControls();
257 std::vector<wxBitmapButton*> bitmapbuttonsvect;
258 std::vector<HistogramDialogComboBoxItem*> _comboitems;
260 void setCurrentColorConfigurationIntoButton();
261 void AddNewBitmapButton();
262 wxSizer* getBitmapButtonDelete(wxBitmap bitmap);
263 std::vector<wxBitmapButton*> _deletebuttonsvector;
266 int _currentcolorselectedbitmap;