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();
78 Get Point list of the funcion
82 void GetPoints(wxList &points)
87 * 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
88 * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
90 int validPointOnFunction(wxPoint realPoint);
92 //returns the index in the list of the point
93 int getIndexOf(wxPoint realpoint);
96 * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
97 * @param: int movingPointIndex, Is the index value of the searched node.
98 * @return: Return a pointer to the node corresponding to the index value by parameter.
100 wxNode* GetPointAt( int movingPointIndex);
103 * Includes a point between two existing points of the this function. The new point (x,y) was not defined when the function was created.
104 *@ return Returns true is the point was succcesfully added to the funcion.
106 bool AddNewPoint(int x,int y);
109 * this method add a new logical point to the function, this point is one of those used to draw the function
111 bool AddPoint(int aX, int aY,bool order=true);
114 * deletes the point given by the user from the collection of logical points of the function
116 bool DeletePoint(int aX, int aY);
119 * 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.
121 bool changePoint(wxPoint newCoords, int movingIndexPoint);
124 * Evaluates if the given point belongs to the function.
127 //bool hasPoint(wxPoint aAPoint);
130 * Returns the real x values of the control points of the function. It dont includes the points calculated by interpolation.
132 double * getX_RealValues();
135 * Returns the real y values of the control points of the function. It dont includes the points calculated by interpolation.
137 double* getY_RealValues();
139 * This method orders the list of points taking into account that the last appended node in the list (realPoint) is the only one disordered.
140 * @return Returns true if the last point included has a valid value for x and was ordered, according to the definition of function.
145 * This method get a pointer to the node in the real points list that is inmediately previous to the searched by parameter.
146 * @pre The seached point (realX, realY) is not the first point of the list.
151 //wxNode * findPreviousNodeTo( int realX, int realY );
154 * sets the start point of the function
156 void setStartPoints();
159 * sets the end point of the function
164 * set the max value in x and y between all the points of the function
170 * set the min value in x and y between all the points of the function
174 * Set Up startPoint, endPoint, maxY,maxX points
179 //set if the function has to draw the points
180 //void SetShowPoints(bool showPoints);
182 //get the paramater showPointsF
183 //bool getShowPoints();
185 //-----------------------
187 //-----------------------
190 Save the points of the function
192 void save(wxString fileName);
194 Load the points of a function
196 void load(wxString fileName);
198 //----------------------------
199 //Getters and Setters
200 //----------------------------
202 void setStartX(double aStartX);
206 void setStartY(double aStartY);
210 void setEndX(double aEndX);
214 void setEndY(double aEndY);
218 void setScaleX(double aScaleX);
222 void setScaleY(double aScaleY);
226 void setMinX(double aMinX);
230 void setMinY(double aMinY);
234 void setMaxX(double aMaxX);
238 void setMaxY(double aMaxY);
242 void setOffsetX(double aOffsetX);
246 void setOffsetY(double aOffsetY);
250 void setType(int aType);
254 int getValidPointRange();
256 void setValidPointRange(int theRange);
259 * Deletes a point of the function given its index
261 bool deletePointAt(int index);
263 * Returns the number of points that the function
268 void getDirection(bool &dir);
275 * Is the initial discrete point on x axis of the drawed function.
279 * Is the initial discrete point on y axis of the drawed function.
283 * Is the last discrete point on x axis of the drawed function.
287 * Is the last discrete point on y axis of the drawed function.
291 * Is the x-scale percentage according to the context device.
295 * Is the y-scale percentage according to the context device.
299 * Is the minimun x-real value reacheable by the function.
303 * Is the minimun y-real value reacheable by the function.
307 * Is the maximun y-real value reacheable by the function.
312 * Is the maximun y-real value reacheable by the function.
317 * Is the logical x-offset of the drawed function.
321 * Is the logical y-offset of the drawed function.
325 * Is the way of how points are going to be connected. It could be smooth, line.
329 * The list of the function points
336 double x_Values[MAX_POINTS];
340 double y_Values[MAX_POINTS];
342 * node of the realPoints where are we
347 * Number that determines the radius range for the valid area the point (sensible radius). Default value 5.
352 * 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.
353 * It is initialized when the second point is included in the funcion.
358 * Indicates if the user is drawing the function
363 DECLARE_CLASS (pLogicalFunction)