Classes | Public Member Functions | List of all members
ipe::Shape Class Reference

#include <ipeshape.h>

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)
Shapeoperator= (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, bool cp) const
void snapBnd (const Vector &mouse, const Matrix &m, Vector &pos, double &bound) const
int countSubPaths () const
const SubPathsubPath (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).

Referenced by ipe::ClosedSpline::snapBnd().

Shape::Shape ( const Rect rect)
Shape::Shape ( const Segment seg)

Convenience function: create a single line segment.

References ipe::Curve::appendSegment(), ipe::Segment::iP, and ipe::Segment::iQ.

Shape::Shape ( const Vector center,
double  radius 

Convenience function: create circle with center and radius.

References ipe::Ellipse::Ellipse(), ipe::Vector::x, and ipe::Vector::y.

Shape::Shape ( const Vector center,
double  radius,
double  alpha0,
double  alpha1 

Convenience function: create circular arc.

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

References ipe::Curve::appendArc(), ipe::Vector::x, and ipe::Vector::y.

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.

References ipe::Curve::appendArc(), ipe::Curve::appendOldSpline(), ipe::Curve::appendSegment(), ipe::Curve::appendSpline(), ipe::Matrix::determinant(), ipe::Ellipse::Ellipse(), ipe::Lex::eos(), ipe::Lex::nextToken(), ipe::Curve::setClosed(), ipe::Lex::skipWhitespace(), ipe::Lex::token(), and ipe::Ellipse::type().

Referenced by ipe::Group::Group().

void Shape::save ( Stream stream) const

Save Shape onto XML stream.

Referenced by ipe::Group::saveAsXml(), and ipe::Path::saveAsXml().

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

Add shape (transformed by m) to box.

Referenced by ipe::Path::addToBBox().

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

Referenced by ipe::Path::distance().

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

Referenced by ipe::Path::snapBnd().

int ipe::Shape::countSubPaths ( ) const

Return number of subpaths.

Referenced by ipe::Path::clone(), and ipe::Group::saveAsXml().

const SubPath* ipe::Shape::subPath ( int  i) const

Return subpath.

References ipe::CurveSegment::draw().

Referenced by ipe::Path::clone(), and ipe::Path::draw().

bool Shape::isSegment ( ) const
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.

References ipe::Matrix::a, ipe::Vector::x, and ipe::Vector::y.

Referenced by ipe::Path::draw(), and ipe::Path::drawSimple().

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