With wxEcPlot, you can draw 4 types of curves :
- cartesian : y = f(x) marked as wxECT_CARTESIAN.
- parametric : x = f(t) and y = f(t) marked as wxECT_PARAMETRIC.
- polar : r = f(t) marked as wxECT_POLAR.
- cloud : array of (x,y) as wxECT_CLOUD.
To parse a formula automatically, a syntax must be adopted. You can restrict the definition of the curve by using wildcards. Because of theta, parametric and polar curves will be restricted in any case.
- cartesian normal : "3*x+2"
- cartesian restricted : "sqr(x) $ -5 5"
- parametric : "t+2 ; t/2 $ -pi pi"
- polar : "t $ 0 2*pi"
- cloud : (unapplicable)
These strings must be parsed using wxEcCurve::Parse(), but you can also define a wxEcCurve on your own via the constructor or the methods (required for wxECT_CLOUD).
- If the expression is polar, wxEcCurve::Parse() takes a second parameter ! Else it will be considered as being parametric.
As you can see :
- ";" delimits the two members of an equation.
- "$" defines a domain, min and max are separated with a space.
- if these characters are not found, the expression will be treated as a non-restricted cartesian curve.
If no domain is given, default values will be chosen. The use of the range will be set accordingly.
When you parse an expression, a default colour is randomly chosen among twenty pre-defined colours. It is a good thing to randomize this automatic choice in your wxApp::OnInit() :
When dealing with a point cloud, you will have to define the curve on your own (data, style, color...). Let's see how to do with a shortened sample :
curve(wxEmptyString, wxEmptyString, wxECT_CLOUD
, *wxRED, 1, false
, 0, 10, 10, &(m_cloud));
As the cloud uses a pointer, any modification in m_cloud will affect the plot. Do use wxEcPlot::Refresh() to update your view. It is not sure it will be performed automatically.
- The number of points declared in wxEcCurve::NumPoints must be lower or equal than the capacity of your buffer. If not, it will result in unexpected bugs.