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