Laxkit
0.0.7.1
|
Path contains only one path. More...
Public Member Functions | |
Path (Coordinate *np, LineStyle *nls=NULL) | |
virtual | ~Path () |
Destructor always deletes path. | |
virtual Path * | duplicate () |
virtual void | fixpath () |
Make sure that path points to the first vertex point of the line, if possible. | |
virtual Coordinate * | lastPoint (int v=0) |
Return the last point (vertex or control) that occurs at the end, or just before path. | |
virtual void | append (double x, double y, unsigned long flags=POINT_VERTEX, SegmentControls *ctl=NULL) |
virtual void | append (flatpoint p, unsigned long flags=POINT_VERTEX, SegmentControls *ctl=NULL) |
virtual void | append (Coordinate *coord) |
The path takes possession of coord. Calling code should not delete it. | |
virtual void | appendBezFromStr (const char *value) |
Append bezier points taken from the string. | |
virtual void | moveTo (flatpoint p) |
virtual void | lineTo (flatpoint p) |
virtual void | curveTo (flatpoint c1, flatpoint c2, flatpoint p2) |
virtual void | close () |
Make sure the path is closed. | |
virtual void | clear () |
Flush all points. | |
virtual int | Intersect (flatpoint p1, flatpoint p2, int isline, double startt, flatpoint *pts, int ptsn, double *t, int tn) |
Find the intersection(s) of the segment (or infinite line) from p1 to p2 and the curve. | |
virtual int | PointAlongPath (double t, int tisdistance, flatpoint *point, flatpoint *tangent) |
virtual flatpoint | ClosestPoint (flatpoint point, double *disttopath, double *distalongpath, double *tdist) |
Find the point on any of the paths closests to point. | |
virtual int | Reverse () |
Reverse the direction of the path. | |
virtual double | Length (double tstart, double tend) |
Find the distance along the path between the bounds, or whole length if tend<tstart. | |
virtual double | distance_to_t (double distance, int *err) |
virtual double | t_to_distance (double t, int *err) |
virtual void | dump_out (FILE *f, int indent, int what, Laxkit::anObject *context) |
Dump out path contents. | |
virtual void | dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *context) |
Public Member Functions inherited from LaxFiles::DumpUtility | |
virtual Attribute * | dump_out_atts (Attribute *att, int what, Laxkit::anObject *savecontext) |
Default is return NULL. what==0 means write out normal Attribute formatted things. | |
virtual void | dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att) |
Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts. | |
virtual | ~DumpUtility () |
Empty virtual destructor. |
Public Attributes | |
Coordinate * | path |
LineStyle * | linestyle |
Static Public Attributes | |
static Laxkit::PtrStack < PathOperator > | basepathops |
A reference pool of PathOperator classes. |
Path contains only one path.
Paths can use any PathOperator object found in basepathops to aid in constructing and maintaining path data. Straight lines and bezier lines are handled without any special PathOperators.
Path class exists just to contain a single (connected) path with its own linestyle. PathsData holds objects with multiple paths.
LaxInterfaces::Path::Path | ( | Coordinate * | np, |
LineStyle * | nls = NULL |
||
) |
Incs count of linestyle.
References Laxkit::anObject::inc_count().
|
virtual |
|
virtual |
ctl count will be incremented.
|
virtual |
The path takes possession of coord. Calling code should not delete it.
coord can be a string of points or a single point, open or closed.
References LaxInterfaces::Coordinate::insert(), and LaxInterfaces::Coordinate::lastPoint().
|
virtual |
Append bezier points taken from the string.
The string must be something like "1 2 p 3 4 n 5 6 7 8". Any pair of numbers not prefaced by a 'n' or 'p' is a vertex point. A 'n' indicates it is a control point for the following point (which must be a vertex). A 'p' is for control points for a previous vertex point. Any violation of these terms stops the appending of points.
On path vertices may be tagged with 'v', and an optional point type indicator, one of 'c','s','S', or 'e'.
References LaxFiles::DoubleListAttribute().
Referenced by dump_in_atts().
|
virtual |
Find the point on any of the paths closests to point.
point is assumed to already be in data coordinates. Returns the distance between those, and the t parameter to that path point.
References Laxkit::bez_closest_point(), Laxkit::bez_segment_length(), LaxInterfaces::Coordinate::firstPoint(), and norm().
If no existing points, first do a lineTo(c1). Else, is a shortcut for:
append(c1,POINT_TOPREV,NULL)
append(c2,POINT_TONEXT,NULL)
append(p2,POINT_VERTEX,NULL)
|
virtual |
If the tt is on the path, set *err=1. else *err=0.
References Laxkit::bez_distance_to_t(), Laxkit::bez_segment_length(), LaxInterfaces::Coordinate::firstPoint(), and norm().
|
virtual |
Dump in the linestyle and coordinates..
If a linestyle is listed, then dec_count of old and install a new one.
See dump_out() for format expected.
Implements LaxFiles::DumpUtility.
References appendBezFromStr(), basepathops, LaxInterfaces::Coordinate::close(), Laxkit::anObject::dec_count(), LaxInterfaces::LineStyle::dump_in_atts(), Laxkit::PtrStack< T >::e, LaxFiles::Attribute::find(), isblank(), LaxInterfaces::Coordinate::lastPoint(), and Laxkit::PtrStack< T >::n.
Referenced by LaxInterfaces::PathsData::dump_in_atts().
|
virtual |
Dump out path contents.
If what==-1, then dump out pseudocode mockup of format.
Dumps out something like:
linestyle ... #standard linestyle attributes closed #flag to indicate that this path is a closed path points \ 1 2 #a vertex point p 1.5 2.5 #a control point of the previous vertex n 3 5 #a control point of the next vertex segment controllername #a non-straight-line and non-bezier segment asbezier p 3 5 n 2 4 5 6 # Important! bezier approximation of the segment.if not present and the controller cannot be found,
then this segment is ignored.
... #any further attributes defining the segment. exactly what #they are is dependent of the actual controller of the segment. #If for some reason the segment controller is not found, then #the bezier approximation is appended to the path as bezier points
Implements LaxFiles::DumpUtility.
References basepathops, LaxInterfaces::LineStyle::dump_out(), Laxkit::PtrStack< T >::e, LaxInterfaces::Coordinate::lastPoint(), and Laxkit::PtrStack< T >::n.
Referenced by LaxInterfaces::PathsData::dump_out().
|
virtual |
Return the last point (vertex or control) that occurs at the end, or just before path.
If v!=0, then return the last vertex, rather than the last of any kind of point.
References LaxInterfaces::Coordinate::lastPoint().
|
virtual |
same as append(p,POINT_VERTEX,NULL).
Referenced by moveTo().
|
virtual |
|
virtual |
t is measured from path->firstVertex(1), and thus should be positive.
Returns 1 for point found, -1 for point clamped to beginning point, -2 clamped to end, or 0 if t is not on the line, path doesn't exist.
be able to wind around the path if continuous, or go backwards (for negative t)
must implement find tangent at clamped endpoints
*** note that if you have a loop of null points, and you are going along based on distance, than this will not break!!
References Laxkit::bez_distance_to_t(), Laxkit::bez_point(), Laxkit::bez_segment_length(), LaxInterfaces::Coordinate::direction(), LaxInterfaces::Coordinate::firstPoint(), LaxInterfaces::Coordinate::lastPoint(), and norm().
|
virtual |
Reverse the direction of the path.
Return 0 for success or 1 for some error.
References LaxInterfaces::Coordinate::firstPoint().
|
virtual |
If the tt is on the path, set *err=1. else *err=0.
References Laxkit::bez_segment_length(), Laxkit::bez_t_to_distance(), LaxInterfaces::Coordinate::firstPoint(), and norm().
|
static |
A reference pool of PathOperator classes.
This static pool is necessary to allow Path or PathsData, for instance, to figure out their actual bounds and to dump_out properly, independently of any particular PathInterface or PathOperator instance.
Referenced by dump_in_atts(), dump_out(), LaxInterfaces::PathInterface::getPathOpFromId(), and LaxInterfaces::PathInterface::Refresh().