]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / HistogramWidget.h
1
2
3 #ifndef __HISTOGRAMW__
4 #define __HISTOGRAMW__
5
6
7 // ----------------------------------------------------------------------------
8 // wx headers inclusion.
9 // For compilers that support precompilation, includes <wx/wx.h>.
10 // ----------------------------------------------------------------------------
11 #include <wx/wxprec.h>
12 #ifdef __BORLANDC__
13 #pragma hdrstop
14 #endif
15 #ifndef WX_PRECOMP
16 #include <wx/wx.h>
17 #endif
18
19 #include "marTypes.h"
20 #include "pPlotter.h"
21 #include "pFunctionPoint.h"
22 #include  "vtkImageData.h"
23 #include "pHistogram.h"
24 #include "pPlotterScaleY.h"
25 #include "pPlotterScaleX.h"
26
27 //#define MAX 500
28 #define NUM_POINTS 100
29 #define WINDOW_SIZE 10
30
31 class creaMaracasVisu_EXPORT HistogramWidget:public wxPanel
32 {
33 public:
34         //---------------------
35         // Constructor
36         //----------------------
37
38         //HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag );
39         
40  
41         HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData,int type);
42
43         HistogramWidget( wxWindow *parent, wxWindowID id);
44         
45         ~HistogramWidget();
46
47         /*
48         Draw the histogram in the plotter
49         */
50         void drawHistogram();
51         /*
52         Draw the transference function in the plotter
53         */
54         void drawTransferenceFunction();
55         /*
56                 if the user resize the window   
57         */
58         void OnSize( wxSizeEvent &WXUNUSED(event) );
59         //---------------------------------------
60         // Get Information from the widget
61         //---------------------------------------
62         /*
63                 get number of points of the transference function
64         */
65         int getSizeTransferenceFunction();
66         /*
67                 get number of points of the barColor
68         */
69         int getSizeBarColor();
70         /*
71                 get a point of the transference function
72         */
73         void getTransferenceFunctionPoint(int index,int& x,int& y);
74         /*
75                 get a  color int the bqr color
76         */
77         void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
78         /*
79                 get a point of the Histogram
80                 given the grey value
81         */
82         int getHistogramPoint(int gValue);
83
84         //--------------------
85         // bar Information
86         //---------------------
87         /*
88          Get the porcentage of the positions of 
89          the min,max and actual in the bar range
90         */
91         float getMaxShowedPorcentage();
92         float getMinShowedPorcentage(); 
93         float getActualShowedPorcentage();      
94
95         //---------------------------------------
96         // setting data in transferences function
97         // and in bar color
98         //----------------------------------------
99         /*
100           Adds a point to the transference function
101         */
102         bool addPointToTransferenceFunction(double x, double y);
103         /*
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
109         */
110         bool addColorPoint(double x,int red,int green, int blue);
111         //--------------------
112         // plotter Information
113         //---------------------
114         void updatePlotter();
115         
116         //------------------------
117         //Erase data
118         //------------------------
119         
120
121         /*
122          Erase all the points that are in the transference function
123         */
124         void erasePointsTransferenceFunction();
125         /*
126         Erase the  color points in the plotter
127         */
128         void eraseColorPoints();
129
130         //-------------------
131         // Getter and setters
132         //-------------------
133
134         void setTransferenceFunctionHasPoints(bool hasPoints);
135         void setTransferenceFunctionHasColor(bool hasColorPoints);
136         int getHistogramSize();
137         void setType(int type);
138
139         /**
140         **      Initialize the histogram 
141         */
142         void initializeHistogram(vtkImageData* img);
143         /**
144         **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
145         **/
146         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
147
148         /**
149         **      Returns two vectors, the grey level of the point and its value, the red, green
150         **      and blue value is between [0,1]
151         **/
152         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
153                                                                         std::vector<double>& red,
154                                                                         std::vector<double>& green,
155                                                                         std::vector<double>& blue);
156
157
158 private:
159         
160          pHistogram* histogram;
161          pPlotter* plotter;
162          int idTransferenceFunction;
163          int histogramSize;
164          int idHistogram;
165          /*
166           if the image has already a transference
167           function and color defines to that function
168           we have to draw it in the widget
169          */
170          bool transferenceFunctionHasPoints;
171          bool transferenceFunctionHasColor;
172          /*
173          * type=1 with transference function for moving
174          * type=2 without transference function for moving
175          */
176          int type;
177          
178          DECLARE_CLASS(HistogramWidget);
179          //----------------------------------------------------------------------------
180         // wxWidget macro use declaration for handdling events
181         //----------------------------------------------------------------------------
182         DECLARE_EVENT_TABLE()
183         
184 };
185 #endif
186
187