]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h
e648a9ab55b4507edebf1c829e0dd05d4d2b46de
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotter.h
1 #ifndef __pPlotter_h__
2 #define __pPlotter_h__
3
4 // --------------------------------------------------------------------------------------------
5 // WX headers inclusion.
6 // For compilers that support precompilation, includes <wx/wx.h>.
7 // --------------------------------------------------------------------------------------------
8
9 #include <wx/wxprec.h>
10 #ifdef __BORLANDC__
11 #pragma hdrstop
12 #endif
13 #ifndef WX_PRECOMP
14 #include <wx/wx.h>
15 #endif
16
17
18 //--------------------------------------------------------------------------------------------
19 // Includes
20 //--------------------------------------------------------------------------------------------
21
22 #include "pColorBar.h"
23 #include "mBarRange.h"
24 #include "mathplot.h"
25 #include "pFunctionPoint.h"
26 #include "pGraphicalFunction.h"
27 #include "pPlotterLayer.h"
28 #include "pPlotterWindow.h"
29 #include "pPlotterScaleY.h"
30 #include "pPlotterScaleX.h"
31 #include <iostream>
32 #include <vector>
33
34 //-------------------------------------------------------------------------------------------------------------
35 // Enum declarations
36 //-------------------------------------------------------------------------------------------------------------
37 /** Command IDs used by pColorPoint */
38
39 //--------------------------------------------------------------------------------------------
40 // Class definition
41 //--------------------------------------------------------------------------------------------
42
43 /*
44 * Represents the integrated plotter that consists of the a drawing area, and control bars (min-max bar, degrade bar)
45 */
46 /** @file pPlotter.h */
47 class pPlotter : public wxPanel{
48
49 public:
50
51         //------------------------------------------------------------------------------------------------------------
52         // Constructors & Destructors
53         //------------------------------------------------------------------------------------------------------------
54         /*
55         * Creates an integrated plotter instance 
56         * @param *parent Container window
57         */
58         pPlotter (wxWindow *parent,int nWidth, int nHeight);
59
60         ~pPlotter ();
61
62     //----------------------------------------------------------------------------------------
63         // Methods definition
64         //----------------------------------------------------------------------------------------
65
66         // Plotter received events      
67         void            onChangeFunction (wxCommandEvent& event);
68         void            onAddedPoint_Plotter (wxCommandEvent& event);
69         void            onRemovedPoint_Plotter (wxCommandEvent& event);
70         void            onMovePoint_Plotter (wxCommandEvent& event);
71         void            onGuideLines (wxCommandEvent& event);
72
73         // Color bar received events
74         void            onAdded_ColorPoint ( wxCommandEvent& event );
75         void            onRemoved_ColorPoint ( wxCommandEvent& event );
76         void            onMoved_ColorPoint( wxCommandEvent& event );
77         void            onChanged_ColorPoint( wxCommandEvent& event );
78         void            onColorBar( wxCommandEvent& event );
79
80         // Min-Max Barrange received events
81         void         onBarrange(wxCommandEvent& event);
82         void         onActualChange_Bar(wxCommandEvent& event);
83         void         onStartChange_Bar(wxCommandEvent& event);
84         void         onEndChange_Bar(wxCommandEvent& event);
85         void         onSelectionEnd(wxCommandEvent& event);
86         void         onMovedBar(wxCommandEvent& event);
87
88         /*
89         * Method for sending a text message to the container window
90         * @param theText Is the text of the message
91         */
92         void             sendTMessage(wxString theText);
93
94         // Other methods
95         wxWindow*       initialize(wxWindow *parent);
96
97         /*
98         * Sets the text message
99         * @param nMessage Is the text message to set
100         */
101         void setTextMessage(wxString nMessage);
102
103         /*
104         * Gets the text message
105         * @param text Is the actual text message 
106         */
107         wxString getTextMessage();
108         /**
109         * Creates and returns a graphical funcion according to the indicated vectors.
110         */
111         pGraphicalFunction* getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY );
112         /**
113         * Add a function to the plotter
114         * when the function doesnt come from window
115         */
116         int addFunction(pGraphicalFunction * function);
117         /*
118          Set Type
119         */
120         void setType(int t);
121         /*
122          Get a function in the plotter given the index
123         */
124         pGraphicalFunction* getFunction(int index);
125         
126         /*
127                 if the user resize the window   
128         */
129         void OnSize( wxSizeEvent &WXUNUSED(event) );
130         /*
131          Get a function in the plotter given the index
132         */
133         //pGraphicalFunction* getFunction(int index);
134         
135         /*
136           move the functions that the user wants to move
137           and that were setted in functionsToMove
138           @param porcentageMinX:the porcentage that the minShowed
139           of the funcntions have to be move
140           @param porcentageMaxX:the porcentage that the maxShowed
141           of the funcntions have to be move
142
143         */
144         void moveFunctions(float porcentageMinX,float porcentageMaxX);
145
146         /*
147          Adds  function to move with the bar min max
148         */
149         int addFunctionToMove(pGraphicalFunction * function);
150         /*
151         Set the bars according to the actual function 
152         */
153
154         void setAll();
155         /*
156         * deletes the function from the plotter
157         */
158         //bool deleteFunction(pGraphicalFunction* function);
159
160         
161         //--------------------
162         // Color information
163         //---------------------
164
165         /**
166                 Returns the number of points that the bar color has
167         */
168         int getColorPointsSize();
169
170         /*
171          Get the RGB values of the color point that is in the
172          index given
173         */
174         void getBarColorDataAt(int index,double&x,int& red,int& green,int& blue);
175         /*
176          add a color Point 
177          returns true if the point was succesfully added
178          PRE: 0<=red<=255 0<=green<=255 0<=blue<=255
179         */
180         bool addColorPoint (int x,int red,int green, int blue);
181
182         void eraseColorPoints();
183
184                 
185         //--------------------
186         // bar Information
187         //---------------------
188         float getMaxShowedPorcentage();
189         float getMinShowedPorcentage(); 
190         float getActualShowedPorcentage();      
191         //--------------------
192         // plotter Information
193         //---------------------
194         void setActual(pGraphicalFunction* nActual);
195         void update();
196         
197         //----------------------------
198         //Handling Options Menu
199         //----------------------------
200         /*
201         if any parameter is true, is going to be remove from the popUp menu
202         */
203         void setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
204                                           bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
205                                           bool delPoint,bool load,bool save);
206
207
208         /**
209         **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
210         **/
211         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize);
212
213         /**
214         **      Returns two vectors, the grey level of the point and its value, the red, green
215         **      and blue value is between [0,1]
216         **/
217         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
218                                                                         std::vector<double>& red,
219                                                                         std::vector<double>& green,
220                                                                         std::vector<double>& blue);
221         
222         //----------------------------------------------------------------------------------------
223         // Attributes declration
224         //----------------------------------------------------------------------------------------
225 private: 
226
227         /*
228         * Represents the plotter widget drawing area
229         */
230         pPlotterWindow  *m_plot;
231         /*
232         * Represents the color bar instance
233         */
234         pColorBar       *color_bar;
235         /*
236         * Represents the barrange instance
237         */
238         mBarRange       *barrange;
239         /*
240         * Represents the pointer to the actual funtion in the unified plotter
241         */
242         pGraphicalFunction* actualFunction;
243
244         /*
245         * Represents the text message 
246         */
247         wxString text;
248
249         /*
250         * Declaring the existence of the class
251         */
252         DECLARE_CLASS (pPlotter)
253         /*
254         * Declaring the use of events
255         */
256         DECLARE_EVENT_TABLE()
257 };
258
259 #endif
260
261