1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 #ifndef __pPlotterWindow_h__
28 #define __pPlotterWindow_h__
30 // ----------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // ----------------------------------------------------------------------------
35 #include <wx/wxprec.h>
43 //----------------------------------------------------------------------------
45 //----------------------------------------------------------------------------
48 #include "pPlotterLayer.h"
49 #include "pGraphicalFunction.h"
55 /** Command IDs used by pPlotterWindow */
58 pwID_ADDPOINT = 2010, //!< add a point to the function
59 pwID_DELPOINT, //!< delete a point of the function
60 pwID_SHOWPOINTS, //!<shows the points that the function has
61 pwID_STARTDRAWING, //!<let to the user to start drawing the curve
62 pwID_DELFUNCTION, //!<delete a function that is in the plotter
63 pwID_STOPDRAWING,//!<Stops the drawing of the function
64 pwID_ADDNEWPOINT,//!<add a new point to the function.
65 pwID_NOSHOWPOINTS, //!<No show the points of the function.
66 pwID_MYZOOMIN,//!<Zoom in the function
67 pwID_MYZOOMOUT,//!<Zoom out the points of the function.
68 pwID_SPLINE,//!<Spline the actual curve.
69 pwID_LINE,//!<Piecewise the actual curve.
70 pwID_SAVE,//!<Save the function in a .txt file.
71 pwID_LOAD, //!<Load the function from a .txt file.
72 pwID_CHANGECOLOR, //!<Change the color of the function
73 pwID_TRASLATEACTUALFUNCTION, //!<move the actual function
74 pwID_LEFTUP//!<listening a click up
78 #define MAX_FUNCTIONS 7
80 this scale, scales each function with its maximum x, and maximum y
83 #define DEFAULT_SCALE 1
85 this scale with the maximun x and y of all the functions defined
89 this scales with the scale giving by the user of the widget
97 Lets to the user to plot any number of the
100 #define DEFAULT_PLOTTER 1
102 Dont let draw on the plotter, but lets to edit
103 the functions that are editables in the plotter
105 #define HISTOGRAM_PLOTTER 2
107 * THE FACTOR TO ZOOM (IN,OUT)
109 //#define ZOOM_FACTOR 2
110 //----------------------------------------------------------------------------
112 //----------------------------------------------------------------------------
114 class creaMaracasVisu_EXPORT pPlotterWindow: public mpWindow
118 * Constructors and destructor
120 pPlotterWindow( wxWindow *parent, wxWindowID id,
121 const wxPoint &pos = wxDefaultPosition,
122 const wxSize &size = wxDefaultSize,
126 //----------------------------
127 //Handling Options Menu
128 //----------------------------
130 if any parameter is true, is going to be remove from the popUp menu
132 void setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
133 bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
134 bool delPoint,bool load,bool save);
137 //-------------------------------
138 //Traslating the actual function
139 //-------------------------------
141 Manipulating clicks on the plotter
143 void onLeftUp(wxMouseEvent& event);
146 Move the actual function when the user
149 void onMoveFunction(wxCommandEvent& aEvent);
153 * Change the color of the function
155 void onChangeColor(wxCommandEvent& aEvent);
159 * Load the function from a .txt file
161 void onLoad(wxCommandEvent& aEvent);
164 * Save the points of the function in a .txt file
166 void onSave(wxCommandEvent& aEvent);
170 * Change the type of drawing of the actual function
171 * to a piecewise function
173 void onLine(wxCommandEvent& aEvent);
177 * Spline the points of the actual curve
179 void onSplinePoints(wxCommandEvent& aEvent);
183 * Zoom out the functions
185 void onMyZoomOut(wxCommandEvent& aEvent);
188 * Zoom in the functions
190 void onMyZoomIn(wxCommandEvent& aEvent);
193 * Transform the point clicked from window
194 * to the real value,given by the scale
196 wxPoint getRealPoint(wxPoint pixelPoint);
199 * The user doesnt want see the points of the function
201 void onNoShowPoints(wxCommandEvent& aEvent);
204 Stop the drawing of the actual function
206 void onStopDrawing(wxCommandEvent& aEvent);
209 * Adds a point to the function after the definition of the initial points of the function
210 * know this point is a point of the function
213 void onAddNewPoint(wxCommandEvent& aEvent);
216 * Let to the user to start drawing
218 void onStartDrawing(wxCommandEvent& aEvent);
221 * 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.
223 void onMouseMove(wxMouseEvent& event);
226 * Listens the event mouse left button double click.
227 * if the user give us a double click is because he wants to change
228 * the actual function to the function that has that point
230 void onChangeActual(wxMouseEvent& event);
233 * Add a new point to the function and then repaint
235 void onAddPoint(wxMouseEvent& aEvent);
238 * Deletes a point of the function and then repaint
240 void onDeletePoint(wxCommandEvent& aEvent);
243 * Shows graphicly the discrete points that the function has
245 void onShowPoints(wxCommandEvent& aEvent);
248 * 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.
251 void changeFuntionType(int aTheType, bool aForAll);
254 * Add a function to the plotter
255 * when the function doesnt come from window
257 int addFunction(pGraphicalFunction * function);
260 * Delete a point of a function
261 * @param point: is the real value that the functon takes, and is gointg to be deleted
263 bool DeletePointFunction(pGraphicalFunction* function,wxPoint point);
266 * Delete a function of the plotter
268 bool deleteFunction(pGraphicalFunction * f);
270 * Sets the actual function
271 * @param newActual: new function
273 void setActualFunction(pGraphicalFunction* newActual);
275 * Get the actual function
277 pGraphicalFunction* getActualFunction();
280 * Creates and returns a graphical funcion according to the indicated vectors.
282 void InitFunctionForVectors( pGraphicalFunction *ff );
283 pGraphicalFunction * getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY );
284 pGraphicalFunction * getFunctionForVectors( std::vector<double> *vectorX, std::vector<double> *vectorY );
287 Set the scales according to the size of the window
288 and the maximum given by the user
291 void setActualScales();
297 void setmLog(wxTextCtrl *m_log1)
303 * Actualizes the view range of the plotter and the actual function
304 * @param newMinX Is the min-value to be shown in the x-scale
305 * @param newMaxX Is the max-value to be shown in the x-scale
307 void actualizeViewRange(int newMinX, int newMaxX);
310 * Sets the condition for drawing or not the guide lines
311 * @param ifDrawing The new condition to assing
313 void setLineGuidesCondition(bool ifDrawing)
315 drawGuides = ifDrawing;
320 * Gets the condition for drawing or not the guide lines
321 * @retval drawGuides The assigned condition
323 bool drawGuideLines()
328 * Guide lines menu handler method that reacts to the mpID_LINE_GUIDES cimmand event
329 * event The corresponding event to handle
331 void OnGuideLines (wxCommandEvent &event);
334 writes in t information
336 void writeInText(wxString &t)
342 Get a function in the plotter given the index
344 pGraphicalFunction* getFunction(int index);
347 move the functions that the user wants to move
348 and that were setted in functionsToMove
349 @param porcentageMinX:the porcentage that the minShowed
350 of the funcntions have to be move
351 @param porcentageMaxX:the porcentage that the maxShowed
352 of the funcntions have to be move
355 void moveFunctions(float porcentageMinX,float porcentageMaxX);
357 * Add a function to the plotter
358 * when the function doesnt come from window
360 int addFunctionToMove(pGraphicalFunction * function);
368 pGraphicalFunction* actual;
375 * If is drawing the function
379 * Index of the movig point, if the user is moving
382 int movingPointIndex;
394 Use to Show Information
401 Functions to be move at the same time
403 wxList functionsToMove;
405 the user is moving the function
410 int initialMovingCLick;
413 saving the initial function
415 std::vector<double> backUpActualVector;
417 wants to move the points of the function
421 DECLARE_CLASS (pPlotterWindow)
422 //----------------------------------------------------------------------------
423 // wxWidget macro use declaration for handdling events
424 //----------------------------------------------------------------------------
425 DECLARE_EVENT_TABLE()