Laxkit  0.0.7.1
Public Member Functions | Public Attributes
LaxInterfaces::PathsData Class Reference

Basically a stack of Path objects with extra fill rules. More...

Inheritance diagram for LaxInterfaces::PathsData:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 PathsData (unsigned long ns=FILL_NONZERO)
virtual ~PathsData ()
virtual const charwhattype ()
virtual void FindBBox ()
 Sets SomeData::minx,etc, based on the union of all the paths.
virtual SomeDataduplicate (SomeData *dup)
virtual int line (double width, int cap=-1, int join=-1, Laxkit::ScreenColor *color=NULL)
 Make this the new line style.
virtual int fill (Laxkit::ScreenColor *color)
 Fill with this color, or none if color==NULL.
virtual int hasCoord (Coordinate *co)
 Return the index on the paths stack of the path that contains c, or -1.
virtual int pathHasCoord (int pathindex, Coordinate *co)
 Return 1 if the given path contains co, else 0.
virtual void appendCoord (Coordinate *coord, int whichpath=-1)
virtual void append (double x, double y, unsigned long flags=POINT_VERTEX, SegmentControls *ctl=NULL, int whichpath=-1)
 Append a point to whichpath via Coordinate::append.
virtual void append (flatpoint p, unsigned long flags=POINT_VERTEX, SegmentControls *ctl=NULL, int whichpath=-1)
 Just calls append(p.x,p.y,...).
virtual void appendRect (double x, double y, double w, double h, SegmentControls *ctl=NULL, int whichpath=-1)
 Convenience to add a rectangle at (x,y) with width and height to whichpath.
virtual void appendBezArc (flatpoint center, double angle, int num_vertices)
virtual void moveTo (flatpoint p, int whichpath=-1)
virtual void lineTo (flatpoint p, int whichpath=-1)
virtual void curveTo (flatpoint c1, flatpoint c2, flatpoint p2, int whichpath=-1)
virtual void close (int whichpath=-1)
 Close the whichpath.
virtual CoordinateLastVertex ()
 Return the last point of the top path, or NULL if that doesn't exist.
virtual void pushEmpty (int where=-1, LineStyle *nls=NULL)
 This creates an empty path and puts it on top of the stack.
virtual void InstallLineStyle (LineStyle *newlinestyle)
virtual void fixpath (int index)
virtual void clear (int which=-1)
virtual void ApplyTransform ()
 Transform each point by m(), and make m() be identity.
virtual void MatchTransform (Affine &affine)
virtual void MatchTransform (const double *mm)
virtual flatpoint ClosestPoint (flatpoint point, double *disttopath, double *distalongpath, double *tdist, int *pathi)
 Return the point on any of the paths closest to p.
virtual int Intersect (int pathindex, flatpoint p1, flatpoint p2, int isline, double startt, flatpoint *pts, int ptsn, double *t, int tn)
 Intersect a line with one subpath. p1 and p2 are in path coordinates.
virtual int PointAlongPath (int pathindex, double t, int tisdistance, flatpoint *point, flatpoint *tangent)
 Find the point lying on subpath pathindex, at t.
virtual CoordinateGetCoordinate (int pathi, double t)
 Return the coordinate after which t points to.
virtual int ReversePath (int pathindex)
virtual double Length (int pathi, double tstart, double tend)
virtual void dump_out (FILE *f, int indent, int what, Laxkit::anObject *context)
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *context)
 Basically reverse of dump_out..
- Public Member Functions inherited from LaxInterfaces::SomeData
virtual void touchContents ()
virtual Laxkit::LaxImageGetPreview ()
 If usepreview==1 and preview, then return preview.
virtual void GeneratePreview (int w, int h)
 Create a preview image with transparency for a cached screen preview.
virtual int renderToBuffer (unsigned char *buffer, int bufw, int bufh, int bufstride, int bufdepth, int bufchannels)
 Render the object to a buffer.
virtual const charId ()
virtual const charId (const char *newid)
 SomeData ()
 SomeData (double nminx, double nmaxx, double nminy, double nmaxy)
 Constructor, setting the bounds.
virtual flatpoint BBoxPoint (double x, double y, bool transform_to_parent)
virtual flatpoint ReferencePoint (int which, bool transform_to_parent)
virtual int pointin (flatpoint pp, int pin=1)
 Return if pp transformed to data coords is within the bounds.
virtual int fitto (double *boxm, DoubleBBox *box, double alignx, double aligny, int whentoscale=2)
 Fit this data to box.
virtual SomeDataGetParent ()
virtual void dump_in (FILE *f, int indent, Laxkit::anObject *context, LaxFiles::Attribute **Att=NULL)
 Dump in an attribute, then call dump_in_atts(thatatt,0).
virtual LaxFiles::Attributedump_out_atts (LaxFiles::Attribute *att, int what, Laxkit::anObject *savecontext)
- Public Member Functions inherited from Laxkit::anObject
 anObject ()
 Set object_id=getUniqueNumber().
virtual ~anObject ()
 Empty virtual destructor.
virtual anObjectduplicate (anObject *ref=NULL)
virtual int inc_count ()
 Increment the data's count by 1. Returns count.
virtual int dec_count ()
 Decrement the count of the data, deleting if count is less than or equal to 0.
virtual int the_count ()
- Public Member Functions inherited from Laxkit::Affine
 Affine (const double *m)
 If mm==NULL, set identity.
 Affine (const Affine &m)
 Affine (double xx, double xy, double yx, double yy, double tx, double ty)
Affineoperator= (Affine const &m)
Affineoperator*= (Affine const &m)
Affine operator* (Affine const m)
virtual void set (Affine a)
virtual void setIdentity ()
virtual bool isIdentity ()
virtual void setRotation (double angle)
virtual void setScale (double sx, double sy)
virtual void setBasis (flatpoint o, flatpoint x, flatpoint y)
virtual void setBasics (double x, double y, double sx, double sy, double angle, double shear)
virtual void getBasics (double *x, double *y, double *sx, double *sy, double *angle, double *shear)
virtual void Translate (flatvector d)
virtual void Rotate (double angle)
virtual void Rotate (double angle, flatpoint around_point)
virtual void RotatePointed (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2)
virtual void RotateScale (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2)
 Rotate and scale so that anchor1 stays fixed, but anchor2 is shifted to newanchor2.
virtual void Stretch (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2)
virtual void AnchorShear (flatpoint anchor1, flatpoint anchor2, flatpoint anchor3, flatpoint newanchor3)
 Transform so that anchor1 and 2 stay fixed, but anchor3 is shifted to newanchor3.
virtual void Scale (double s)
virtual void Scale (flatpoint o, double s)
 Scale around point o.
virtual void Scale (flatpoint o, double sx, double sy)
virtual void Scale (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2)
 Scale as if you move anchor2 to newanchor2, while anchor1 stays the same.
virtual void FlipH ()
virtual void FlipV ()
virtual void Flip (flatpoint f1, flatpoint f2)
 Flip across the axis of f1 to f2.
virtual void Multiply (Affine &m)
 this=this*m
virtual void PreMultiply (Affine &m)
 this=m*this
virtual Affine Inversion ()
 Return a new matrix that is the inverse of this, if possible.
virtual void Invert ()
 Make this the inverse of whatever it is.
virtual flatpoint transformPoint (flatpoint p)
virtual flatpoint transformPointInverse (flatpoint p)
virtual flatpoint transformVector (flatpoint p)
 Apply the transfrom, but ignore this's translation component.
virtual const double * m () const
virtual void m (const double *mm)
virtual void m (double xx, double xy, double yx, double yy, double tx, double ty)
virtual double m (int c)
virtual void m (int c, double v)
virtual void Unshear (int preserve_x, int normalize)
 Clear shearing and unequal scaling. Null vectors stay null vectors.
virtual void Normalize ()
 Make x and y both be unit vectors, but point in the same direction as before.
virtual flatpoint origin ()
virtual void origin (flatpoint o)
virtual flatpoint xaxis ()
virtual void xaxis (flatpoint x)
virtual flatpoint yaxis ()
virtual void yaxis (flatpoint y)
- Public Member Functions inherited from Laxkit::DoubleBBox
 DoubleBBox ()
 Create empty invalid bbox (maxx<minx and maxy<miny).
 DoubleBBox (flatpoint p)
 Create box whose bounds are p.
 DoubleBBox (double mix, double max, double miy, double may)
 Create box whose bounds are as given.
virtual void clear ()
 Make box invalid: set minx=miny=0 and maxx=maxy=-1.
virtual void addtobounds (double x, double y)
virtual void addtobounds (flatpoint p)
 Expand bounds to contain p. Set the bounds to p if current bounds are invalid.
virtual void addtobounds (DoubleBBox *bbox)
 Add the bbox to the bounds. Set the bounds if current bounds are invalid.
virtual void addtobounds (const double *m, DoubleBBox *bbox)
 Add bbox to bounds, first transforming it by 6 element transform matrix m.
virtual void setbounds (DoubleBBox *bbox)
 Just copy over the bounds.
virtual void setbounds (flatpoint *pts, int n)
 Make this bbox be the bounds for the given n points. (does not add to previous bounds)
virtual void setbounds (double mix, double max, double miy, double may)
 Set the bounds to the specified values.
virtual int validbounds ()
 Returns maxx>=minx && maxy>=miny.
virtual int intersect (double mix, double max, double miy, double may, int settointersection=0)
 Intersect the given bounds with this's bounds. Return 1 for non-empty intersection.
virtual int intersect (DoubleBBox *bbox, int settointersection=0)
 Just return intersect(bbox.minx,...,settointersection).
virtual int intersect (double *m, DoubleBBox *bbox, int touching, int settointersection)
 Does the transformed box touch. **** incomplete implementation.
virtual int boxcontains (double x, double y)
 Return whether the given point is contained within or on the bounds.
virtual flatpoint BBoxPoint (double x, double y)

Public Attributes

unsigned long style
Laxkit::PtrStack< Pathpaths
LineStylelinestyle
 This is the default line style for any paths that are added.
FillStylefillstyle
 This is the fill style for the collection of paths.
- Public Attributes inherited from LaxInterfaces::SomeData
Laxkit::LaxImagepreview
 A preview image potentially to be used to not have to rerender on each refresh.
int usepreview
 Flag for whether to use SomeData::preview rather than rendering.
std::time_t previewtime
 The time the preview was generated, if at all, as returned by time().
std::time_t modtime
 The time of last modification through a SomeData function.
int bboxstyle
flatpoint centerpoint
unsigned int flags
int iid
 Id of the interface that should handle this data.
charnameid
- Public Attributes inherited from Laxkit::anObject
int suppress_debug
DeleteRefCountedFunc deleteMe
 Called when the count is decremented to 0.
unsigned long object_id
charobject_idstr
- Public Attributes inherited from Laxkit::DoubleBBox
double minx
double maxx
double miny
double maxy

Detailed Description

Basically a stack of Path objects with extra fill rules.

#include <lax/interfaces/pathinterface.h>

This is the main vehicle for Path data.

Each subpath can have its own linestyle, but any fill style in Path::linestyle is preempted by the fill style defined in PathsData::fillstyle.

See also Path, and Coordinate.

Here are the fill defines, these might get defined somewhere else later....:

FILL_NONZERO
FILL_ZERO
FILL_EVEN_ODD
FILL_ODD_EVEN
FILL_NONE

Constructor & Destructor Documentation

LaxInterfaces::PathsData::~PathsData ( )
virtual

Dec count of linestyle and fillstyle.

References Laxkit::anObject::dec_count(), fillstyle, and linestyle.


Member Function Documentation

void LaxInterfaces::PathsData::append ( double  x,
double  y,
unsigned long  flags = POINT_VERTEX,
SegmentControls ctl = NULL,
int  whichpath = -1 
)
virtual

Append a point to whichpath via Coordinate::append.

If which==-1, then append to path with greatest index. If there is not any path, than a new path is created. If there is an empty path, then the point replaces the empty path.

This is really a convenience function to allow easy construction of simple lines.

References Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, and Laxkit::PtrStack< T >::push().

Referenced by append(), appendBezArc(), appendRect(), moveTo(), and LaxInterfaces::SvgToPathsData().

void LaxInterfaces::PathsData::appendBezArc ( flatpoint  center,
double  angle,
int  num_vertices 
)
virtual

Create a circular arc, with center, and last point determines radius. Sweep out angle radians. Add at least one new vertex point, and associated control points.

References append(), and LastVertex().

void LaxInterfaces::PathsData::appendRect ( double  x,
double  y,
double  w,
double  h,
SegmentControls ctl = NULL,
int  whichpath = -1 
)
virtual

Convenience to add a rectangle at (x,y) with width and height to whichpath.

This also calls FindBBox().

References append(), close(), and FindBBox().

void LaxInterfaces::PathsData::clear ( int  which = -1)
virtual

If which==-1, flush all paths. If not, then remove path with that index.

References Laxkit::PtrStack< T >::flush(), Laxkit::PtrStack< T >::n, and Laxkit::PtrStack< T >::remove().

void LaxInterfaces::PathsData::close ( int  whichpath = -1)
virtual

Close the whichpath.

If which==-1, then close the path with greatest index. If the path is closed already, then nothing is done.

This is really a convenience function to allow easy construction of simple lines.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

Referenced by appendRect(), and LaxInterfaces::SvgToPathsData().

flatpoint LaxInterfaces::PathsData::ClosestPoint ( flatpoint  point,
double *  disttopath,
double *  distalongpath,
double *  tdist,
int pathi 
)
virtual

Return the point on any of the paths closest to p.

point is assumed to already be in data coordinates.

Optionally return that distance from the path in dist, the t parameter in tdist, and the path index in pathi.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

Referenced by LaxInterfaces::PathInterface::CutNear(), and LaxInterfaces::PathInterface::scanHover().

void LaxInterfaces::PathsData::dump_in_atts ( LaxFiles::Attribute att,
int  flag,
Laxkit::anObject context 
)
virtual

Basically reverse of dump_out..

If the dump is supposed to replace the current settings, then they should have been flushed previously. New paths read in here are appended to paths stack.

Reimplemented from LaxInterfaces::SomeData.

References Laxkit::anObject::dec_count(), LaxInterfaces::FillStyle::dump_in_atts(), LaxInterfaces::LineStyle::dump_in_atts(), LaxInterfaces::Path::dump_in_atts(), Laxkit::PtrStack< T >::e, fillstyle, FindBBox(), linestyle, LaxFiles::LongAttribute(), Laxkit::PtrStack< T >::n, Laxkit::PtrStack< T >::push(), and LaxInterfaces::SvgToPathsData().

void LaxInterfaces::PathsData::fixpath ( int  index)
virtual

If index==-1, then call Path::fixpath() on only the top subpath. If index==-2, then fixpath on all subpaths. else fixpath() on only the specified index.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

int LaxInterfaces::PathsData::hasCoord ( Coordinate co)
virtual

Return the index on the paths stack of the path that contains c, or -1.

v=1 means c must be a vertex also.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

Referenced by LaxInterfaces::PathInterface::DeletePoint(), LaxInterfaces::PathInterface::MergeEndpoints(), LaxInterfaces::PathInterface::SetCurvertex(), and LaxInterfaces::PathInterface::toggleclosed().

int LaxInterfaces::PathsData::Intersect ( int  pathindex,
flatpoint  p1,
flatpoint  p2,
int  isline,
double  startt,
flatpoint pts,
int  ptsn,
double *  t,
int  tn 
)
virtual

Intersect a line with one subpath. p1 and p2 are in path coordinates.

ptsn is the number of points allocated in pts, and tn is the number allocated for t. Search will commence for as many intersection points as will fill pts and t.

t is for t parameters, when a t unit of 1 is the length between any two adjacent vertices.

If isline==0, then interesect with segment [p1,p2]. Else interesect with an infinite line that goes through points p1 and p2.

Return value is the number of intersections parsed.

References Laxkit::PtrStack< T >::e.

int LaxInterfaces::PathsData::line ( double  width,
int  cap = -1,
int  join = -1,
Laxkit::ScreenColor color = NULL 
)
virtual

Make this the new line style.

If cap, join, or width are less than 0, then do not change.

See LaxCapStyle and LaxJoinStyle.

References LaxInterfaces::LineStyle::Color(), and linestyle.

void LaxInterfaces::PathsData::MatchTransform ( const double *  newm)
virtual

Change the path transform, and change point coordinates so they stay in the same places.

Say the old transform is O. Then each point gets transformed by: O*inverse(mm)

References Laxkit::PtrStack< T >::e, FindBBox(), Laxkit::PtrStack< T >::n, Laxkit::transform_invert(), Laxkit::transform_mult(), and Laxkit::transform_point().

void LaxInterfaces::PathsData::moveTo ( flatpoint  p,
int  whichpath = -1 
)
virtual

Starts a new subpath. If whichpath>=0, then make the subpath at that index, otherwise add to end.

References append(), Laxkit::PtrStack< T >::n, and pushEmpty().

int LaxInterfaces::PathsData::PointAlongPath ( int  pathindex,
double  t,
int  tisdistance,
flatpoint point,
flatpoint tangent 
)
virtual

Find the point lying on subpath pathindex, at t.

If tisdistance==0, then t is the usual t parameter. Else it is physical distance, starting from subpath->path.

Return 1 for point found, otherwise 0.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

void LaxInterfaces::PathsData::pushEmpty ( int  where = -1,
LineStyle nls = NULL 
)
virtual

This creates an empty path and puts it on top of the stack.

This is handy when creating page layout views, for instance, so you can just do pathsdata->append.... pathsdata->pushempty(); pathsdata->append.... to simply create several paths.

Count of nls is incremented.

References Laxkit::PtrStack< T >::push().

Referenced by LaxInterfaces::PathInterface::AddPoint(), moveTo(), and LaxInterfaces::SvgToPathsData().

int LaxInterfaces::PathsData::ReversePath ( int  pathindex)
virtual

Return 0 for success or 1 for some error.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

Referenced by LaxInterfaces::PathInterface::MergeEndpoints().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:58, Laxkit