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"
29 #include "HistogramDialogComboBoxItem.h"
31 #include <wx/bmpcbox.h>
34 #define FILENAME "/Data/colorsfunction.txt"
36 class HistogramDialog:public wxDialog
42 HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,int type);
46 HistogramDialog(wxWindow *parent,wxString title);
51 get number of points of the transference function
53 int getSizeTransferenceFunction();
55 get number of points of the barColor
57 int getSizeBarColor();
59 get a point of the transference function
61 void getTransferenceFunctionPoint(int index,int& x,int& y);
63 get a color int the bqr color
65 void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
67 get a point of the Histogram
70 int getHistogramPoint(int gValue);
72 //--------------------
74 //---------------------
76 Get the porcentage of the positions of
77 the min,max and actual in the bar range
79 float getMaxShowedPorcentage();
80 float getMinShowedPorcentage();
81 float getActualShowedPorcentage();
83 //---------------------------------------
84 // setting data in transferences function
86 //----------------------------------------
88 Adds a point to the transference function
90 bool addPointToTransferenceFunction(double x, double y);
92 add a color point to the histogram
93 @param x the level of grey to which the color is assigned
94 @param red the level of red for the color
95 @param green the level of red for the color
96 @param blue the level of red for the color
98 bool addColorPoint(double x,int red,int green, int blue);
99 //------------------------
101 //------------------------
104 Erase all the points that are in the transference function
106 void erasePointsTransferenceFunction();
107 void eraseColorPoints();
108 //-------------------
109 // Getter and setters
110 //-------------------
112 void setTransferenceFunctionHasPoints(bool hasPoints);
113 void setTransferenceFunctionHasColor(bool hasColorPoints);
115 //returns if the user has pressed refresh
118 void setCTF(vtkColorTransferFunction* cf);
119 void setTF(vtkPiecewiseFunction* tf);
120 void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
121 void setVolume(vtkVolume* vol);
122 void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
123 void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
125 //--------------------
126 // plotter Information
127 //---------------------
128 void updatePlotter();
130 //-----------------------
132 //-----------------------
134 void OnSaveData(wxCommandEvent& event);
135 void OnLoadData(wxCommandEvent& event);
136 void OnRefreshBtn(wxCommandEvent& event);
137 void OnEditBitmapCombo(wxCommandEvent& event);
140 ** Initialize the histogram
142 void initializeHistogram(vtkImageData* img);
144 ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
146 void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
149 ** Returns two vectors, the grey level of the point and its value, the red, green
150 ** and blue value is between [0,1]
152 void GetValuesColorPointsFunction(std::vector<double>& greylevel,
153 std::vector<double>& red,
154 std::vector<double>& green,
155 std::vector<double>& blue);
156 void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
158 void OnBitmapComboItemSelected(wxCommandEvent& event);
163 HistogramWidget* histogramW;
167 double _maxgreyvalue;
172 wxBitmapButton *okBtn;
176 //wxButton *cancelBtn;
177 wxBitmapButton *cancelBtn;
181 wxButton *saveDataBtn;
185 wxButton *loadDataBtn;
189 wxButton *refreshBtn;
191 wxSizer* _bitmapsizer;
193 // the user had pressed refresh
196 vtkColorTransferFunction *_ctfun;
197 vtkPiecewiseFunction *_tfun;
198 vtkVolumeRayCastMapper *volumeMapper;
202 wxVtkMPR3DView *wxvtkmpr3Dview;
203 wxVtkClipping3DView *wxvtkclipping3Dview;
205 wxBitmapComboBox* _bitmapcombo;
206 std::vector<HistogramDialogComboBoxItem*> _bitmapsitems;
207 wxSizer* getControls();
208 wxSizer* getBitmapCombo();
209 wxBitmapComboBox* getBitmapComboElements();
210 void OnLoadComboBoxData(std::vector<HistogramDialogComboBoxItem*>& itembitmaps, std::string filename,std::vector<double>& greyvect, std::vector<int>& redvect, std::vector<int>& greenvect, std::vector<int>& bluevect);
211 std::vector<wxBitmap*> GetBitmapsList(std::vector<double> greyvect, std::vector<int> redvect, std::vector<int> greenvect, std::vector<int> bluevect);
212 // DECLARE_CLASS(HistogramDialog);
213 // any class wishing to process wxWindows events must use this macro
214 //DECLARE_EVENT_TABLE()
216 void initializeHistogramDialog();