2 #ifndef __HISTOGRAMSDIALOG__
3 #define __HISTOGRAMSDIALOG__
6 // ----------------------------------------------------------------------------
7 // wx headers inclusion.
8 // For compilers that support precompilation, includes <wx/wx.h>.
9 // ----------------------------------------------------------------------------
10 #include <wx/wxprec.h>
18 //---------------------
20 //----------------------
21 #include "HistogramWidget.h"
22 #include "vtkImageData.h"
24 #include <vtkPiecewiseFunction.h>
25 #include <vtkColorTransferFunction.h>
26 #include <vtkVolumeRayCastMapper.h>
27 #include <vtkVolume.h>
28 #include "../wxMPRWidget.h"
30 #include "HistogramDialogComboBoxItem.h"
31 #include <wx/checkbox.h>
32 #include <wx/statbmp.h>
34 class HistogramDialog:public wxDialog
40 HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,bool extracontrols=false);
44 HistogramDialog(wxWindow *parent,wxString title,bool extracontrols=false);
50 get number of points of the transference function
52 int getSizeTransferenceFunction();
54 get number of points of the barColor
56 int getSizeBarColor();
58 get a point of the transference function
60 void getTransferenceFunctionPoint(int index,int& x,int& y);
62 get a color int the bqr color
64 void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
66 get a point of the Histogram
69 int getHistogramPoint(int gValue);
71 //--------------------
73 //---------------------
75 Get the porcentage of the positions of
76 the min,max and actual in the bar range
78 float getMaxShowedPorcentage();
79 float getMinShowedPorcentage();
80 float getActualShowedPorcentage();
82 //---------------------------------------
83 // setting data in transferences function
85 //----------------------------------------
87 Adds a point to the transference function
89 bool addPointToTransferenceFunction(double x, double y);
91 add a color point to the histogram
92 @param x the level of grey to which the color is assigned
93 @param red the level of red for the color
94 @param green the level of red for the color
95 @param blue the level of red for the color
97 bool addColorPoint(double x,int red,int green, int blue);
98 //------------------------
100 //------------------------
103 Erase all the points that are in the transference function
105 void erasePointsTransferenceFunction();
106 void eraseColorPoints();
107 //-------------------
108 // Getter and setters
109 //-------------------
111 void setTransferenceFunctionHasPoints(bool hasPoints);
112 void setTransferenceFunctionHasColor(bool hasColorPoints);
114 //returns if the user has pressed refresh
117 void setCTF(vtkColorTransferFunction* cf);
118 void setTF(vtkPiecewiseFunction* tf);
119 void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
120 void setVolume(vtkVolume* vol);
121 void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
122 void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
124 //--------------------
125 // plotter Information
126 //---------------------
127 void updatePlotter();
129 //-----------------------
131 //-----------------------
133 void OnSaveData(wxCommandEvent& event);
134 void OnLoadData(wxCommandEvent& event);
135 void OnRefreshBtn(wxCommandEvent& event);
139 ** Initialize the histogram
141 void initializeHistogram(vtkImageData* img);
143 ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
145 void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
148 ** Returns two vectors, the grey level of the point and its value, the red, green
149 ** and blue value is between [0,1]
151 void GetValuesColorPointsFunction(std::vector<double>& greylevel,
152 std::vector<double>& red,
153 std::vector<double>& green,
154 std::vector<double>& blue);
155 void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
158 ** Set to true in the constructor
160 void setInfoPanExtraControls(std::vector<HistogramDialogComboBoxItem*> comboitems);
166 void OnEditColorsCombo(wxCommandEvent& event);
167 void OnDeleteColor(wxCommandEvent& event);
169 std::vector<HistogramDialogComboBoxItem*> getComboBoxItems(){return _comboitems;}
171 void UpdateCurrentComboElement();
177 HistogramWidget* histogramW;
185 wxBitmapButton *okBtn;
189 //wxButton *cancelBtn;
190 wxBitmapButton *cancelBtn;
194 wxButton *saveDataBtn;
198 wxButton *loadDataBtn;
202 wxButton *refreshBtn;
204 wxPanel* _panextracontrols;
207 // the user had pressed refresh
210 vtkColorTransferFunction *_ctfun;
211 vtkPiecewiseFunction *_tfun;
212 vtkVolumeRayCastMapper *volumeMapper;
216 wxVtkMPR3DView *wxvtkmpr3Dview;
217 wxVtkClipping3DView *wxvtkclipping3Dview;
220 wxSizer* getControls(bool extracontrols = false);
224 // DECLARE_CLASS(HistogramDialog);
225 // any class wishing to process wxWindows events must use this macro
226 //DECLARE_EVENT_TABLE()
228 void initializeHistogramDialog(bool extracontrols);
230 wxPanel* getPanExtraControls();
232 std::vector<wxBitmapButton*> bitmapbuttonsvect;
233 std::vector<HistogramDialogComboBoxItem*> _comboitems;
235 void setCurrentColorConfigurationIntoButton();
236 void AddNewBitmapButton();
237 wxSizer* getBitmapButtonDelete(wxBitmap bitmap);
238 std::vector<wxBitmapButton*> _deletebuttonsvector;
241 int _currentcolorselectedbitmap;