7 // ----------------------------------------------------------------------------
8 // wx headers inclusion.
9 // For compilers that support precompilation, includes <wx/wx.h>.
10 // ----------------------------------------------------------------------------
11 #include <wx/wxprec.h>
21 #include "pFunctionPoint.h"
22 #include "vtkImageData.h"
23 #include "pHistogram.h"
24 #include "pPlotterScaleY.h"
25 #include "pPlotterScaleX.h"
28 #define NUM_POINTS 100
29 #define WINDOW_SIZE 10
31 class creaMaracasVisu_EXPORT HistogramWidget:public wxPanel
34 //---------------------
36 //----------------------
38 //HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag );
41 HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData,int type);
43 HistogramWidget( wxWindow *parent, wxWindowID id);
48 Draw the histogram in the plotter
52 Draw the transference function in the plotter
54 void drawTransferenceFunction();
56 if the user resize the window
58 void OnSize( wxSizeEvent &WXUNUSED(event) );
59 //---------------------------------------
60 // Get Information from the widget
61 //---------------------------------------
63 get number of points of the transference function
65 int getSizeTransferenceFunction();
67 get number of points of the barColor
69 int getSizeBarColor();
71 get a point of the transference function
73 void getTransferenceFunctionPoint(int index,int& x,int& y);
75 get a color int the bqr color
77 void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
79 get a point of the Histogram
82 int getHistogramPoint(int gValue);
84 //--------------------
86 //---------------------
88 Get the porcentage of the positions of
89 the min,max and actual in the bar range
91 float getMaxShowedPorcentage();
92 float getMinShowedPorcentage();
93 float getActualShowedPorcentage();
95 //---------------------------------------
96 // setting data in transferences function
98 //----------------------------------------
100 Adds a point to the transference function
102 bool addPointToTransferenceFunction(double x, double y);
104 add a color point to the histogram
105 @param x the level of grey to which the color is assigned
106 @param red the level of red for the color
107 @param green the level of red for the color
108 @param blue the level of red for the color
110 bool addColorPoint(double x,int red,int green, int blue);
111 //--------------------
112 // plotter Information
113 //---------------------
114 void updatePlotter();
116 //------------------------
118 //------------------------
122 Erase all the points that are in the transference function
124 void erasePointsTransferenceFunction();
126 Erase the color points in the plotter
128 void eraseColorPoints();
130 //-------------------
131 // Getter and setters
132 //-------------------
134 void setTransferenceFunctionHasPoints(bool hasPoints);
135 void setTransferenceFunctionHasColor(bool hasColorPoints);
136 int getHistogramSize();
137 void setType(int type);
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);
161 pHistogram* histogram;
163 int idTransferenceFunction;
167 if the image has already a transference
168 function and color defines to that function
169 we have to draw it in the widget
171 bool transferenceFunctionHasPoints;
172 bool transferenceFunctionHasColor;
173 wxPanel* getControls();
175 * type=1 with transference function for moving
176 * type=2 without transference function for moving
180 DECLARE_CLASS(HistogramWidget);
181 //----------------------------------------------------------------------------
182 // wxWidget macro use declaration for handdling events
183 //----------------------------------------------------------------------------
184 DECLARE_EVENT_TABLE()