2 #ifndef __pLogicalFunction_h__
3 #define __pLogicalFunction_h__
5 // ----------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // ----------------------------------------------------------------------------
10 #include <wx/wxprec.h>
19 //----------------------------------------------------------------------------
21 //----------------------------------------------------------------------------
23 #include "pFunctionPoint.h"
30 class pLogicalFunction;
31 //----------------------------------------------------------------------------
33 //----------------------------------------------------------------------------
36 //if your are going to change se sensible region you have to change MOVE in pPlotterLayer
37 #define SENSIBLE_REGION 5
40 class pLogicalFunction: public wxObject
44 //----------------------------------------------------------------------------
46 //----------------------------------------------------------------------------
54 /*virtual void Rewind()
56 node = realPoints.GetFirst();
60 /** Get locus value for next N.
61 Override this function in your implementation.
62 @param x Returns X value
63 @param y Returns Y value
65 /*virtual bool GetNextXY(double & x, double & y)
69 pFunctionPoint* p=(pFunctionPoint*)node->GetData();
80 Get Point list of the funcion
84 void GetPoints(wxList &points)
89 * 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
90 * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
92 int validPointOnFunction(wxPoint realPoint);
94 //returns the index in the list of the point
95 int getIndexOf(wxPoint realpoint);
98 * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
99 * @param: int movingPointIndex, Is the index value of the searched node.
100 * @return: Return a pointer to the node corresponding to the index value by parameter.
102 wxNode* GetPointAt( int movingPointIndex);
105 * Includes a point between two existing points of the this function. The new point (x,y) was not defined when the function was created.
106 *@ return Returns true is the point was succcesfully added to the funcion.
108 bool AddNewPoint(int x,int y);
111 * this method add a new logical point to the function, this point is one of those used to draw the function
113 bool AddPoint(int aX, int aY,bool order=true);
116 * deletes the point given by the user from the collection of logical points of the function
118 bool DeletePoint(int aX, int aY);
121 * 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.
123 bool changePoint(wxPoint newCoords, int movingIndexPoint);
126 * Evaluates if the given point belongs to the function.
129 //bool hasPoint(wxPoint aAPoint);
132 * Returns the real x values of the control points of the function. It dont includes the points calculated by interpolation.
134 double * getX_RealValues();
137 * Returns the real y values of the control points of the function. It dont includes the points calculated by interpolation.
139 double* getY_RealValues();
141 * This method orders the list of points taking into account that the last appended node in the list (realPoint) is the only one disordered.
142 * @return Returns true if the last point included has a valid value for x and was ordered, according to the definition of function.
147 * This method get a pointer to the node in the real points list that is inmediately previous to the searched by parameter.
148 * @pre The seached point (realX, realY) is not the first point of the list.
153 //wxNode * findPreviousNodeTo( int realX, int realY );
156 * sets the start point of the function
158 void setStartPoints();
161 * sets the end point of the function
166 * set the max value in x and y between all the points of the function
172 * set the min value in x and y between all the points of the function
176 * Set Up startPoint, endPoint, maxY,maxX points
181 //set if the function has to draw the points
182 //void SetShowPoints(bool showPoints);
184 //get the paramater showPointsF
185 //bool getShowPoints();
187 //-----------------------
189 //-----------------------
192 Save the points of the function
194 void save(wxString fileName);
196 Load the points of a function
198 void load(wxString fileName);
200 //----------------------------
201 //Getters and Setters
202 //----------------------------
204 void setStartX(double aStartX);
208 void setStartY(double aStartY);
212 void setEndX(double aEndX);
216 void setEndY(double aEndY);
220 void setScaleX(double aScaleX);
224 void setScaleY(double aScaleY);
228 void setMinX(double aMinX);
232 void setMinY(double aMinY);
236 void setMaxX(double aMaxX);
240 void setMaxY(double aMaxY);
244 void setOffsetX(double aOffsetX);
248 void setOffsetY(double aOffsetY);
252 void setType(int aType);
256 int getValidPointRange();
258 void setValidPointRange(int theRange);
261 * Deletes a point of the function given its index
263 bool deletePointAt(int index);
265 * Returns the number of points that the function
270 void getDirection(bool &dir);
277 * Is the initial discrete point on x axis of the drawed function.
281 * Is the initial discrete point on y axis of the drawed function.
285 * Is the last discrete point on x axis of the drawed function.
289 * Is the last discrete point on y axis of the drawed function.
293 * Is the x-scale percentage according to the context device.
297 * Is the y-scale percentage according to the context device.
301 * Is the minimun x-real value reacheable by the function.
305 * Is the minimun y-real value reacheable by the function.
309 * Is the maximun y-real value reacheable by the function.
314 * Is the maximun y-real value reacheable by the function.
319 * Is the logical x-offset of the drawed function.
323 * Is the logical y-offset of the drawed function.
327 * Is the way of how points are going to be connected. It could be smooth, line.
331 * The list of the function points
338 double x_Values[MAX_POINTS];
342 double y_Values[MAX_POINTS];
344 * node of the realPoints where are we
349 * Number that determines the radius range for the valid area the point (sensible radius). Default value 5.
354 * 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.
355 * It is initialized when the second point is included in the funcion.
360 * Indicates if the user is drawing the function
365 DECLARE_CLASS (pLogicalFunction)