Ipelib

- Main Page
- Modules
- Classes

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions

# ipe::Shape Class Reference
Ipe Geometry

A geometric shape, consisting of several (open or closed) subpaths. More...

`#include <ipeshape.h>`

List of all members.

## Classes

- struct Imp

## Public Member Functions

- Shape ()
- Shape (const Rect &rect)
- Shape (const Segment &seg)
- Shape (const Vector &center, double radius)
- Shape (const Vector &center, double radius, double alpha0, double alpha1)
- ~Shape ()
- Shape (const Shape &rhs)
- Shape & operator= (const Shape &rhs)
- bool load (String data)
- void save (Stream &stream) const
- void addToBBox (Rect &box, const Matrix &m, bool cp) const
- double distance (const Vector &v, const Matrix &m, double bound) const
- void snapVtx (const Vector &mouse, const Matrix &m, Vector &pos, double &bound) const
- void snapBnd (const Vector &mouse, const Matrix &m, Vector &pos, double &bound) const
- int countSubPaths () const
- const SubPath * subPath (int i) const
- bool isSegment () const
- void appendSubPath (SubPath *sp)
- void draw (Painter &painter) const

## Detailed Description

A geometric shape, consisting of several (open or closed) subpaths.

This class represents vector graphics geometry following the PDF "path", 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).

A Shape consists of a set of subpaths (SubPath), 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.

A subpath is either an Ellipse (a complete, closed ellipse), a ClosedSpline (a closed uniform B-spline curve), or a Curve. A curve consists of a sequence of segments. Segments are either straight, a quadratic Bezier spline, a cubic Bezier spline, an elliptic arc, or a uniform cubic B-spline.

Shape is implemented using reference counting and can be copied and passed by value efficiently. The only mutator methods are appendSubPath() and load(), which can only be called during construction of the Shape (that is, before its implementation has been shared).

## Constructor & Destructor Documentation

Shape::Shape | ( |  | ) |

Construct an empty shape (zero subpaths).

Shape::Shape | ( | const Rect & | rect | ) | `[explicit]`

Convenience function: create a rectangle shape.

Shape::Shape | ( | const Segment & | seg | ) | `[explicit]`

Convenience function: create a single line segment.

Shape::Shape | ( | const Vector & | center,
|  | double | radius
| ) |  | `[explicit]`

Convenience function: create circle with center and radius.

Shape::Shape | ( | const Vector & | center,
|  | double | radius,
|  | double | alpha0,
|  | double | alpha1
| ) |  | `[explicit]`

Convenience function: create circular arc.

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

Shape::~Shape | ( |  | ) |

Destructor (takes care of reference counting).

Shape::Shape | ( | const Shape & | rhs | ) |

Copy constructor (constant time).

## Member Function Documentation

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

Assignment operator (constant-time).

bool Shape::load | ( | String | data | ) |

Create a Shape from XML data.

Appends subpaths from XML data to the current Shape. Returns false if the path syntax is incorrect (the Shape will be in an inconsistent state and must be discarded).

This method can only be used during construction of the Shape. It will panic if the implementation has been shared.

void Shape::save | ( | Stream & | stream | ) | const

Save Shape onto XML stream.

void Shape::addToBBox | ( | Rect & | box,
|  | const Matrix & | m,
|  | bool | cp
| ) |  | const

Add shape (transformed by m) to box.

double Shape::distance | ( | const Vector & | v,
|  | const Matrix & | m,
|  | double | bound
| ) |  | const

void Shape::snapVtx | ( | const Vector & | mouse,
|  | const Matrix & | m,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

void Shape::snapBnd | ( | const Vector & | mouse,
|  | const Matrix & | m,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

int ipe::Shape::countSubPaths | ( |  | ) | const`[inline]`

Return number of subpaths.

const SubPath* ipe::Shape::subPath | ( | int | i | ) | const`[inline]`

Return subpath.

bool Shape::isSegment | ( |  | ) | const

Is this Shape a single straight segment?

void Shape::appendSubPath | ( | SubPath * | sp | ) |

Append a SubPath to shape.

The Shape will take ownership of the subpath. This method can only be used during construction of the Shape. It will panic if the implementation has been shared.

void Shape::draw | ( | Painter & | painter | ) | const

Draw the Shape as a path to painter.

Does not call newPath() on painter.

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

- ipeshape.h
- ipeshape.cpp