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 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
106 #if wxMAJOR_VERSION <= 2
108 Get Point list of the funcion
112 void GetPoints(wxList &points)
118 Get Point list of the funcion
119 @param return pointsPtr
122 wxList* GetPointsPtr()
130 * 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
131 * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
133 int validPointOnFunction(wxPoint realPoint);
135 //returns the index in the list of the point
136 int getIndexOf(wxPoint realpoint);
139 * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
140 * @param: int movingPointIndex, Is the index value of the searched node.
141 * @return: Return a pointer to the node corresponding to the index value by parameter.
143 wxNode* GetPointAt( int movingPointIndex);
146 * Includes a point between two existing points of the this function. The new point (x,y) was not defined when the function was created.
147 *@ return Returns true is the point was succcesfully added to the funcion.
149 bool AddNewPoint(int x,int y);
152 * this method add a new logical point to the function, this point is one of those used to draw the function
154 bool AddPoint(int aX, int aY,bool order=true);
157 * deletes the point given by the user from the collection of logical points of the function
159 bool DeletePoint(int aX, int aY);
162 * 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.
164 bool changePoint(wxPoint newCoords, int movingIndexPoint);
167 * Evaluates if the given point belongs to the function.
170 //bool hasPoint(wxPoint aAPoint);
173 * Returns the real x values of the control points of the function. It dont includes the points calculated by interpolation.
175 double * getX_RealValues();
178 * Returns the real y values of the control points of the function. It dont includes the points calculated by interpolation.
180 double* getY_RealValues();
182 * This method orders the list of points taking into account that the last appended node in the list (realPoint) is the only one disordered.
183 * @return Returns true if the last point included has a valid value for x and was ordered, according to the definition of function.
188 * This method get a pointer to the node in the real points list that is inmediately previous to the searched by parameter.
189 * @pre The seached point (realX, realY) is not the first point of the list.
194 //wxNode * findPreviousNodeTo( int realX, int realY );
197 * sets the start point of the function
199 void setStartPoints();
202 * sets the end point of the function
207 * set the max value in x and y between all the points of the function
213 * set the min value in x and y between all the points of the function
217 * Set Up startPoint, endPoint, maxY,maxX points
222 //set if the function has to draw the points
223 //void SetShowPoints(bool showPoints);
225 //get the paramater showPointsF
226 //bool getShowPoints();
228 //-----------------------
230 //-----------------------
233 Save the points of the function
235 void save(wxString fileName);
237 Load the points of a function
239 void load(wxString fileName);
241 //----------------------------
242 //Getters and Setters
243 //----------------------------
245 void setStartX(double aStartX);
249 void setStartY(double aStartY);
253 void setEndX(double aEndX);
257 void setEndY(double aEndY);
261 void setScaleX(double aScaleX);
265 void setScaleY(double aScaleY);
269 void setMinX(double aMinX);
273 void setMinY(double aMinY);
277 void setMaxX(double aMaxX);
281 void setMaxY(double aMaxY);
285 void setOffsetX(double aOffsetX);
289 void setOffsetY(double aOffsetY);
293 void setType(int aType);
297 int getValidPointRange();
299 void setValidPointRange(int theRange);
302 * Deletes a point of the function given its index
304 bool deletePointAt(int index);
306 * Returns the number of points that the function
311 void getDirection(bool &dir);
318 * Is the initial discrete point on x axis of the drawed function.
322 * Is the initial discrete point on y axis of the drawed function.
326 * Is the last discrete point on x axis of the drawed function.
330 * Is the last discrete point on y axis of the drawed function.
334 * Is the x-scale percentage according to the context device.
338 * Is the y-scale percentage according to the context device.
342 * Is the minimun x-real value reacheable by the function.
346 * Is the minimun y-real value reacheable by the function.
350 * Is the maximun y-real value reacheable by the function.
355 * Is the maximun y-real value reacheable by the function.
360 * Is the logical x-offset of the drawed function.
364 * Is the logical y-offset of the drawed function.
368 * Is the way of how points are going to be connected. It could be smooth, line.
372 * The list of the function points
379 double x_Values[MAX_POINTS];
383 double y_Values[MAX_POINTS];
385 * node of the realPoints where are we
390 * Number that determines the radius range for the valid area the point (sensible radius). Default value 5.
395 * 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.
396 * It is initialized when the second point is included in the funcion.
401 * Indicates if the user is drawing the function
406 DECLARE_CLASS (pLogicalFunction)