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