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 __pLogicalFunction_h__
28 #define __pLogicalFunction_h__
30 // ----------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // ----------------------------------------------------------------------------
35 #include <wx/wxprec.h>
44 //----------------------------------------------------------------------------
46 //----------------------------------------------------------------------------
48 #include "pFunctionPoint.h"
55 class pLogicalFunction;
56 //----------------------------------------------------------------------------
58 //----------------------------------------------------------------------------
61 //if your are going to change se sensible region you have to change MOVE in pPlotterLayer
62 #define SENSIBLE_REGION 5
65 class pLogicalFunction: public wxObject
69 //----------------------------------------------------------------------------
71 //----------------------------------------------------------------------------
79 /*virtual void Rewind()
81 node = realPoints.GetFirst();
85 /** Get locus value for next N.
86 Override this function in your implementation.
87 @param x Returns X value
88 @param y Returns Y value
90 /*virtual bool GetNextXY(double & x, double & y)
94 pFunctionPoint* p=(pFunctionPoint*)node->GetData();
105 Get Point list of the funcion
109 void GetPoints(wxList &points)
114 * validate if the function has that point in a sensible area returning the index where the point was found or -1 if is in not part of the function: define the sensible area is
115 * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
117 int validPointOnFunction(wxPoint realPoint);
119 //returns the index in the list of the point
120 int getIndexOf(wxPoint realpoint);
123 * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
124 * @param: int movingPointIndex, Is the index value of the searched node.
125 * @return: Return a pointer to the node corresponding to the index value by parameter.
127 wxNode* GetPointAt( int movingPointIndex);
130 * Includes a point between two existing points of the this function. The new point (x,y) was not defined when the function was created.
131 *@ return Returns true is the point was succcesfully added to the funcion.
133 bool AddNewPoint(int x,int y);
136 * this method add a new logical point to the function, this point is one of those used to draw the function
138 bool AddPoint(int aX, int aY,bool order=true);
141 * deletes the point given by the user from the collection of logical points of the function
143 bool DeletePoint(int aX, int aY);
146 * Change de coordinates of the given point if it is possible and return the result of the invoked action. True if it was possible to do the change.
148 bool changePoint(wxPoint newCoords, int movingIndexPoint);
151 * Evaluates if the given point belongs to the function.
154 //bool hasPoint(wxPoint aAPoint);
157 * Returns the real x values of the control points of the function. It dont includes the points calculated by interpolation.
159 double * getX_RealValues();
162 * Returns the real y values of the control points of the function. It dont includes the points calculated by interpolation.
164 double* getY_RealValues();
166 * This method orders the list of points taking into account that the last appended node in the list (realPoint) is the only one disordered.
167 * @return Returns true if the last point included has a valid value for x and was ordered, according to the definition of function.
172 * This method get a pointer to the node in the real points list that is inmediately previous to the searched by parameter.
173 * @pre The seached point (realX, realY) is not the first point of the list.
178 //wxNode * findPreviousNodeTo( int realX, int realY );
181 * sets the start point of the function
183 void setStartPoints();
186 * sets the end point of the function
191 * set the max value in x and y between all the points of the function
197 * set the min value in x and y between all the points of the function
201 * Set Up startPoint, endPoint, maxY,maxX points
206 //set if the function has to draw the points
207 //void SetShowPoints(bool showPoints);
209 //get the paramater showPointsF
210 //bool getShowPoints();
212 //-----------------------
214 //-----------------------
217 Save the points of the function
219 void save(wxString fileName);
221 Load the points of a function
223 void load(wxString fileName);
225 //----------------------------
226 //Getters and Setters
227 //----------------------------
229 void setStartX(double aStartX);
233 void setStartY(double aStartY);
237 void setEndX(double aEndX);
241 void setEndY(double aEndY);
245 void setScaleX(double aScaleX);
249 void setScaleY(double aScaleY);
253 void setMinX(double aMinX);
257 void setMinY(double aMinY);
261 void setMaxX(double aMaxX);
265 void setMaxY(double aMaxY);
269 void setOffsetX(double aOffsetX);
273 void setOffsetY(double aOffsetY);
277 void setType(int aType);
281 int getValidPointRange();
283 void setValidPointRange(int theRange);
286 * Deletes a point of the function given its index
288 bool deletePointAt(int index);
290 * Returns the number of points that the function
295 void getDirection(bool &dir);
302 * Is the initial discrete point on x axis of the drawed function.
306 * Is the initial discrete point on y axis of the drawed function.
310 * Is the last discrete point on x axis of the drawed function.
314 * Is the last discrete point on y axis of the drawed function.
318 * Is the x-scale percentage according to the context device.
322 * Is the y-scale percentage according to the context device.
326 * Is the minimun x-real value reacheable by the function.
330 * Is the minimun y-real value reacheable by the function.
334 * Is the maximun y-real value reacheable by the function.
339 * Is the maximun y-real value reacheable by the function.
344 * Is the logical x-offset of the drawed function.
348 * Is the logical y-offset of the drawed function.
352 * Is the way of how points are going to be connected. It could be smooth, line.
356 * The list of the function points
363 double x_Values[MAX_POINTS];
367 double y_Values[MAX_POINTS];
369 * node of the realPoints where are we
374 * Number that determines the radius range for the valid area the point (sensible radius). Default value 5.
379 * Indicates the way the function is being drawed when defining it. So that it is true if the direction is from left-to-right, and false if it is from right-to-left.
380 * It is initialized when the second point is included in the funcion.
385 * Indicates if the user is drawing the function
390 DECLARE_CLASS (pLogicalFunction)