- Main Page
- Modules
- Classes

- Class List
- Class Hierarchy
- Class Members

# IpePathSegment Class Reference
[Ipe Objects]

A segment on an IpeSubPath. More...

List of all members.

## Public Types

- enum TType {
  EArc, ESegment, EQuad, EBezier,
  ESpline
  }

## Public Member Functions

- TType Type () const
- int NumCP () const
- IpeVector CP (int i) const
- IpeVector Last () const
- IpeMatrix Matrix () const
- IpeBezier Bezier () const
- IpeArc Arc () const
- void Beziers (std::vector< IpeBezier > &bez) const
- void Draw (IpePainter &painter) const
- void AddToBBox (IpeRect &box, const IpeMatrix &m) const
- double Distance (const IpeVector &v, const IpeMatrix &m, double bound) const
- void SnapVtx (const IpeVector &mouse, const IpeMatrix &m, IpeVector &pos, double &bound) const
- void SnapBnd (const IpeVector &mouse, const IpeMatrix &m, IpeVector &pos, double &bound) const

## Friends

- class IpeSegmentSubPath

## Detailed Description

A segment on an IpeSubPath.

A segment is either an elliptic arc, a straight segment, a quadratic Bezier spline, a cubic Bezier spline, or a B-spline curve, depending on its Type(). This is a lightweight object, created on the fly by IpeSegmentSubPath::Segment(). There is no public constructor, so the only way to create such an object is through that method.

The Type() is one of the following:

- `ESegment:` the segment has two control points, and represents a line segment.

- `EQuad:` a quadratic Bezier spline with three control points.

- `EBezier:` a cubic Bezier spline with four control points.

- `ESpline:` a B-spline curve with n control points. The first and last control point's knot value is repeated three times, so the curve begins and ends in these points.

- `EArc:` an elliptic arc, with begin and end point. The supporting ellipse is defined by the Matrix(), it is the image under the affine transformation Matrix() of the unit circle. Matrix() is such that its inverse transforms both start and end position to points (nearly) on the unit circle. The arc is the image of the positively (counter-clockwise) directed arc from the pre-image of the start position to the pre-image of the end position. Whether this is a positively or negatively oriented arc in user space depends on the matrix.

## Member Function Documentation

TType IpePathSegment::Type | ( |  | ) | const`[inline]`

Type of segment.

int IpePathSegment::NumCP | ( |  | ) | const`[inline]`

Number of control points.

IpeVector IpePathSegment::CP | ( | int | i | ) | const`[inline]`

Return control point.

IpeVector IpePathSegment::Last | ( |  | ) | const`[inline]`

Return last control point.

IpeMatrix IpePathSegment::Matrix | ( |  | ) | const`[inline]`

Matrix (if Type() == EArc).

IpeBezier IpePathSegment::Bezier | ( |  | ) | const

Return segment as IpeBezier.

Panics if segment is not a quadratic or cubic Bezier spline.

IpeArc IpePathSegment::Arc | ( |  | ) | const

Return segment as IpeArc.

Panics if segment is not an arc.

void IpePathSegment::Beziers | ( | std::vector< IpeBezier > & | bez | ) | const

Convert B-spline to a sequence of Bezier splines.

void IpePathSegment::Draw | ( | IpePainter & | painter | ) | const

Draw the segment.

Current position of the painter is already on first control point.

void IpePathSegment::AddToBBox | ( | IpeRect & | box,
|  | const IpeMatrix & | m |
| ) |  |  | const

Add segment to bounding box.

Does not assume that first control point has already been added. Centers of arcs are included in the bbox, to make sure snapping finds them.

double IpePathSegment::Distance | ( | const IpeVector & | v,
|  | const IpeMatrix & | m,
|  | double | bound |
| ) |  |  | const

Return distance to the segment.

void IpePathSegment::SnapVtx | ( | const IpeVector & | mouse,
|  | const IpeMatrix & | m,
|  | IpeVector & | pos,
|  | double & | bound |
| ) |  |  | const

Snap to vertex of the segment.

The method assumes that the first control point has already been tested.

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

- ipepath.h
- ipepath.cpp