# IpePath Class Reference
[Ipe Objects]

The path object (polylines, polygons, and generalizations). More...

Inherits IpeFillable.

List of all members.

## Public Member Functions

- IpePath (IpeRepository *rep, const IpeXmlAttributes &attr, IpeString data)
- IpePath (const IpeAllAttributes &attr)
- IpePath (const IpeAllAttributes &attr, const IpeRect &rect)
- IpePath (const IpeAllAttributes &attr, const IpeSegment &seg)
- IpePath (const IpeAllAttributes &attr, const IpeVector &center, double radius)
- IpePath (const IpeAllAttributes &attr, const IpeVector &center, double radius, double alpha0, double alpha1)
- IpePath (const IpePath &rhs)
- ~IpePath ()
- IpePath & operator= (const IpePath &rhs)
- virtual IpeObject * Clone () const
- virtual IpePath * AsPath ()
- virtual void SaveAsXml (IpePainter &painter, IpeStream &stream, IpeString layer) const
- virtual void Draw (IpePainter &painter) const
- virtual void Accept (IpeVisitor &visitor) const
- virtual void AddToBBox (IpeRect &box, const IpeMatrix &m) const
- virtual double Distance (const IpeVector &v, const IpeMatrix &m, double bound) const
- virtual void SnapVtx (const IpeVector &mouse, const IpeMatrix &m, IpeVector &pos, double &bound) const
- virtual void SnapBnd (const IpeVector &mouse, const IpeMatrix &m, IpeVector &pos, double &bound) const
- virtual void CheckStyle (const IpeStyleSheet *sheet, IpeAttributeSeq &seq) const
- IpeAttribute ForwardArrow () const
- IpeAttribute BackwardArrow () const
- void SetForwardArrow (IpeAttribute size)
- void SetBackwardArrow (IpeAttribute size)
- void DrawSpline (IpePainter &painter, int n, const IpeVector *v) const
- void DrawClosedSpline (IpePainter &painter, int n, const IpeVector *v) const
- int NumSubPaths () const
- const IpeSubPath * SubPath (int i) const
- void AddSubPath (IpeSubPath *sp)

## Static Public Member Functions

- static void DrawArrow (IpePainter &painter, IpeVector pos, IpeAngle alpha, IpeAttribute size)

## Detailed Description

The path object (polylines, polygons, and generalizations).

This object follows the PDF rendering model, but is actually a bit more complicated since we add new subtypes: arcs, parabolas, uniform B-splines (in PDF, all of these are converted to cubic Bezier splines). Unlike Ipe 5, we can now represent objects consisting of more than one subpath. Note that Ipe 5's spline and arc objects are now represented as IpePath objects.

A path object consists of a set of subpaths (IpeSubPath), each of which is either open or closed, and which are rendered by stroking and filling as a whole. The distinction between open and closed is meaningful for stroking only, for filling any open subpath is implicitely closed. Stroking a set of subpaths is identical to stroking them individually. This is not true for filling: using several subpaths, one can construct objects with holes, and more complicated pattern. The filling algorithm is the even-odd rule of PDF: To determine whether a point lies inside the filled shape, draw a ray from that point in any direction, and count the number of path segments that cross the ray. If this number is odd, the point is inside; if even, the point is outside. (IpePath objects can also render using the winding fill rule by setting the StrokeStyle attribute. This isn't really supported by the Ipe user interface, which doesn't show the orientation of paths.)

A subpath consists of a sequence of segments. (A complete ellipse and a closed B-spline curve can appear as special cases of subpaths that cannot be further decomposed into segments.) Segments are either straight, a quadratic Bezier spline, a cubic Bezier spline, an elliptic arc, or a uniform cubic B-spline. The segmented subpath class IpeSegmentSubPath returns segments as IpePathSegment (but they are not internally stored that way).

## Constructor & Destructor Documentation

IpePath::IpePath | ( | IpeRepository * | rep,
|  | const IpeXmlAttributes & | attr,
|  | IpeString | data |
| ) |  |  | `[explicit]`

Construct from XML data.

IpePath::IpePath | ( | const IpeAllAttributes & | attr | ) | `[explicit]`

Create empty path object, and null/default attributes.

IpePath::IpePath | ( | const IpeAllAttributes & | attr,
|  | const IpeRect & | rect |
| ) |  |  | `[explicit]`

Create a rectangle.

IpePath::IpePath | ( | const IpeAllAttributes & | attr,
|  | const IpeSegment & | seg |
| ) |  |  | `[explicit]`

Create a single line segment from `seg.iP` to `seg.iQ`.

IpePath::IpePath | ( | const IpeAllAttributes & | attr,
|  | const IpeVector & | center,
|  | double | radius |
| ) |  |  | `[explicit]`

Create circle with center and radius.

IpePath::IpePath | ( | const IpeAllAttributes & | attr,
|  | const IpeVector & | center,
|  | double | radius,
|  | double | alpha0,
|  | double | alpha1 |
| ) |  |  | `[explicit]`

Create circular arc with center, radius, between given angles.

If alpha1 is larger than alpha0, the arc is oriented positively, otherwise negatively.

IpePath::IpePath | ( | const IpePath & | rhs | ) |

Copy constructor (takes care of reference counting).

IpePath::~IpePath | ( |  | ) |

Destructor (takes care of reference counting).

## Member Function Documentation

IpePath & IpePath::operator= | ( | const IpePath & | rhs | ) |

Assignment operator (constant-time).

IpeObject * IpePath::Clone | ( |  | ) | const`[virtual]`

Return a clone (constant-time).

Implements IpeObject.

IpePath * IpePath::AsPath | ( |  | ) | `[virtual]`

Return pointer to this object.

Reimplemented from IpeObject.

void IpePath::SaveAsXml | ( | IpePainter & | painter,
|  | IpeStream & | stream,
|  | IpeString | layer |
| ) |  |  | const`[virtual]`

Save the object in XML format.

Implements IpeObject.

void IpePath::Draw | ( | IpePainter & | painter | ) | const`[virtual]`

Draw the object.

Implements IpeObject.

void IpePath::Accept | ( | IpeVisitor & | visitor | ) | const`[virtual]`

Call VisitPath of visitor.

Implements IpeObject.

void IpePath::AddToBBox | ( | IpeRect & | box,
|  | const IpeMatrix & | m |
| ) |  |  | const`[virtual]`

Extend box to include the object transformed by m.

For Ipe objects in a page, don't call this directly. The IpePgObject caches the bounding box, so it is far more efficient to call IpePgObject::BBox.

If called with an empty box, the result of this function is a tight bounding box for the object, with a little leeway in case the boundary is determined by a spline (it has to be approximated to perform this operation).

Implements IpeObject.

double IpePath::Distance | ( | const IpeVector & | v,
|  | const IpeMatrix & | m,
|  | double | bound |
| ) |  |  | const`[virtual]`

Return distance of transformed object to point v. If larger than bound, can just return bound.

Implements IpeObject.

void IpePath::SnapVtx | ( | const IpeVector & | mouse,
|  | const IpeMatrix & | m,
|  | IpeVector & | pos,
|  | double & | bound |
| ) |  |  | const`[virtual]`

Compute possible vertex snapping position for transformed object.

Looks only for positions closer than bound. If successful, modify pos and bound.

Implements IpeObject.

void IpePath::SnapBnd | ( | const IpeVector & | mouse,
|  | const IpeMatrix & | m,
|  | IpeVector & | pos,
|  | double & | bound |
| ) |  |  | const`[virtual]`

Compute boundary snapping position for transformed object.

Looks only for positions closer than bound. If successful, modify pos and bound. The default implementation does nothing.

Reimplemented from IpeObject.

void IpePath::CheckStyle | ( | const IpeStyleSheet * | sheet,
|  | IpeAttributeSeq & | seq |
| ) |  |  | const`[virtual]`

Check all symbolic attributes.

Reimplemented from IpeFillable.

IpeAttribute IpePath::ForwardArrow | ( |  | ) | const`[inline]`

Return arrow of the object.

IpeAttribute IpePath::BackwardArrow | ( |  | ) | const`[inline]`

Return backward arrow of the object.

void IpePath::SetForwardArrow | ( | IpeAttribute | size | ) |

Set forward arrow (if the object can take it).

void IpePath::SetBackwardArrow | ( | IpeAttribute | size | ) |

Set backward arrow (if the object can take it).

void IpePath::DrawArrow | ( | IpePainter & | painter,
|  | IpeVector | pos,
|  | IpeAngle | alpha,
|  | IpeAttribute | size |
| ) |  |  | `[static]`

Draw an arrow of size with tip at v1 directed from v0 to v1.

int IpePath::NumSubPaths | ( |  | ) | const`[inline]`

Return number of subpaths.

const IpeSubPath* IpePath::SubPath | ( | int | i | ) | const`[inline]`

Return subpath.

void IpePath::AddSubPath | ( | IpeSubPath * | sp | ) |

Add a subpath to object.

This can only be used directly after the creation of this path object. Once the object has been copied or assigned, this method will panic.

IpePath takes ownership of the subpath.

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

- ipepath.h
- ipepath.cpp