2 #ifndef __pPlotterWindow_h__
3 #define __pPlotterWindow_h__
5 // ----------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // ----------------------------------------------------------------------------
10 #include <wx/wxprec.h>
18 //----------------------------------------------------------------------------
20 //----------------------------------------------------------------------------
23 #include "pPlotterLayer.h"
24 #include "pGraphicalFunction.h"
30 /** Command IDs used by pPlotterWindow */
33 pwID_ADDPOINT = 2010, //!< add a point to the function
34 pwID_DELPOINT, //!< delete a point of the function
35 pwID_SHOWPOINTS, //!<shows the points that the function has
36 pwID_STARTDRAWING, //!<let to the user to start drawing the curve
37 pwID_DELFUNCTION, //!<delete a function that is in the plotter
38 pwID_STOPDRAWING,//!<Stops the drawing of the function
39 pwID_ADDNEWPOINT,//!<add a new point to the function.
40 pwID_NOSHOWPOINTS, //!<No show the points of the function.
41 pwID_MYZOOMIN,//!<Zoom in the function
42 pwID_MYZOOMOUT,//!<Zoom out the points of the function.
43 pwID_SPLINE,//!<Spline the actual curve.
44 pwID_LINE,//!<Piecewise the actual curve.
45 pwID_SAVE,//!<Save the function in a .txt file.
46 pwID_LOAD, //!<Load the function from a .txt file.
47 pwID_CHANGECOLOR, //!<Change the color of the function
48 pwID_TRASLATEACTUALFUNCTION, //!<move the actual function
49 pwID_LEFTUP//!<listening a click up
53 #define MAX_FUNCTIONS 7
55 this scale, scales each function with its maximum x, and maximum y
58 #define DEFAULT_SCALE 1
60 this scale with the maximun x and y of all the functions defined
64 this scales with the scale giving by the user of the widget
72 Lets to the user to plot any number of the
75 #define DEFAULT_PLOTTER 1
77 Dont let draw on the plotter, but lets to edit
78 the functions that are editables in the plotter
80 #define HISTOGRAM_PLOTTER 2
82 * THE FACTOR TO ZOOM (IN,OUT)
84 //#define ZOOM_FACTOR 2
85 //----------------------------------------------------------------------------
87 //----------------------------------------------------------------------------
89 class creaMaracasVisu_EXPORT pPlotterWindow: public mpWindow
93 * Constructors and destructor
95 pPlotterWindow( wxWindow *parent, wxWindowID id,
96 const wxPoint &pos = wxDefaultPosition,
97 const wxSize &size = wxDefaultSize,
101 //----------------------------
102 //Handling Options Menu
103 //----------------------------
105 if any parameter is true, is going to be remove from the popUp menu
107 void setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
108 bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
109 bool delPoint,bool load,bool save);
112 //-------------------------------
113 //Traslating the actual function
114 //-------------------------------
116 Manipulating clicks on the plotter
118 void onLeftUp(wxMouseEvent& event);
121 Move the actual function when the user
124 void onMoveFunction(wxCommandEvent& aEvent);
128 * Change the color of the function
130 void onChangeColor(wxCommandEvent& aEvent);
134 * Load the function from a .txt file
136 void onLoad(wxCommandEvent& aEvent);
139 * Save the points of the function in a .txt file
141 void onSave(wxCommandEvent& aEvent);
145 * Change the type of drawing of the actual function
146 * to a piecewise function
148 void onLine(wxCommandEvent& aEvent);
152 * Spline the points of the actual curve
154 void onSplinePoints(wxCommandEvent& aEvent);
158 * Zoom out the functions
160 void onMyZoomOut(wxCommandEvent& aEvent);
163 * Zoom in the functions
165 void onMyZoomIn(wxCommandEvent& aEvent);
168 * Transform the point clicked from window
169 * to the real value,given by the scale
171 wxPoint getRealPoint(wxPoint pixelPoint);
174 * The user doesnt want see the points of the function
176 void onNoShowPoints(wxCommandEvent& aEvent);
179 Stop the drawing of the actual function
181 void onStopDrawing(wxCommandEvent& aEvent);
184 * Adds a point to the function after the definition of the initial points of the function
185 * know this point is a point of the function
188 void onAddNewPoint(wxCommandEvent& aEvent);
191 * Let to the user to start drawing
193 void onStartDrawing(wxCommandEvent& aEvent);
196 * Listens the event of the mouse when it is moving, this is use to know if the user is moving a pont of the function and in tha way to know when repainting.
198 void onMouseMove(wxMouseEvent& event);
201 * Listens the event mouse left button double click.
202 * if the user give us a double click is because he wants to change
203 * the actual function to the function that has that point
205 void onChangeActual(wxMouseEvent& event);
208 * Add a new point to the function and then repaint
210 void onAddPoint(wxMouseEvent& aEvent);
213 * Deletes a point of the function and then repaint
215 void onDeletePoint(wxCommandEvent& aEvent);
218 * Shows graphicly the discrete points that the function has
220 void onShowPoints(wxCommandEvent& aEvent);
223 * Changes the type according to the specified number of the type. If the second parameter, the boolean one is true indicates that this action must be done in all the funtion, if not it will be applied only to the actual selected function.
226 void changeFuntionType(int aTheType, bool aForAll);
229 * Add a function to the plotter
230 * when the function doesnt come from window
232 int addFunction(pGraphicalFunction * function);
235 * Delete a point of a function
236 * @param point: is the real value that the functon takes, and is gointg to be deleted
238 bool DeletePointFunction(pGraphicalFunction* function,wxPoint point);
241 * Delete a function of the plotter
243 bool deleteFunction(pGraphicalFunction * f);
245 * Sets the actual function
246 * @param newActual: new function
248 void setActualFunction(pGraphicalFunction* newActual);
250 * Get the actual function
252 pGraphicalFunction* getActualFunction();
255 * Creates and returns a graphical funcion according to the indicated vectors.
257 void InitFunctionForVectors( pGraphicalFunction *ff );
258 pGraphicalFunction * getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY );
259 pGraphicalFunction * getFunctionForVectors( std::vector<double> *vectorX, std::vector<double> *vectorY );
262 Set the scales according to the size of the window
263 and the maximum given by the user
266 void setActualScales();
272 void setmLog(wxTextCtrl *m_log1)
278 * Actualizes the view range of the plotter and the actual function
279 * @param newMinX Is the min-value to be shown in the x-scale
280 * @param newMaxX Is the max-value to be shown in the x-scale
282 void actualizeViewRange(int newMinX, int newMaxX);
285 * Sets the condition for drawing or not the guide lines
286 * @param ifDrawing The new condition to assing
288 void setLineGuidesCondition(bool ifDrawing)
290 drawGuides = ifDrawing;
295 * Gets the condition for drawing or not the guide lines
296 * @retval drawGuides The assigned condition
298 bool drawGuideLines()
303 * Guide lines menu handler method that reacts to the mpID_LINE_GUIDES cimmand event
304 * event The corresponding event to handle
306 void OnGuideLines (wxCommandEvent &event);
309 writes in t information
311 void writeInText(wxString &t)
317 Get a function in the plotter given the index
319 pGraphicalFunction* getFunction(int index);
322 move the functions that the user wants to move
323 and that were setted in functionsToMove
324 @param porcentageMinX:the porcentage that the minShowed
325 of the funcntions have to be move
326 @param porcentageMaxX:the porcentage that the maxShowed
327 of the funcntions have to be move
330 void moveFunctions(float porcentageMinX,float porcentageMaxX);
332 * Add a function to the plotter
333 * when the function doesnt come from window
335 int addFunctionToMove(pGraphicalFunction * function);
343 pGraphicalFunction* actual;
350 * If is drawing the function
354 * Index of the movig point, if the user is moving
357 int movingPointIndex;
369 Use to Show Information
376 Functions to be move at the same time
378 wxList functionsToMove;
380 the user is moving the function
385 int initialMovingCLick;
388 saving the initial function
390 std::vector<double> backUpActualVector;
392 wants to move the points of the function
396 DECLARE_CLASS (pPlotterWindow)
397 //----------------------------------------------------------------------------
398 // wxWidget macro use declaration for handdling events
399 //----------------------------------------------------------------------------
400 DECLARE_EVENT_TABLE()