# IpePainter Class Reference
[Ipe Base]

Interface for drawing. More...

List of all members.

## Public Member Functions

- IpePainter (const IpeStyleSheet *style)
- virtual ~IpePainter ()
- virtual void Transform (const IpeMatrix &m)
- virtual void Untransform (bool diret)
- virtual void Translate (const IpeVector &v)
- virtual void BeginPath (const IpeVector &v)
- virtual void BeginClosedPath (const IpeVector &v)
- virtual void LineTo (const IpeVector &v)
- virtual void CurveTo (const IpeVector &v1, const IpeVector &v2, const IpeVector &v3)
- void CurveTo (const IpeBezier &bezier)
- virtual void Rect (const IpeRect &re)
- virtual void EndPath ()
- virtual void EndClosedPath ()
- virtual void Push ()
- virtual void Pop ()
- virtual void DrawPath ()
- virtual void DrawBitmap (IpeBitmap bitmap)
- virtual void DrawText (const IpeText *text)
- void DrawEllipse ()
- void DrawArc (double alpha)
- void SetStroke (IpeAttribute color)
- void SetFill (IpeAttribute color)
- void SetLineWidth (IpeAttribute wid)
- void SetDashStyle (IpeAttribute dash)
- void SetLineCap (IpeAttribute cap)
- void SetLineJoin (IpeAttribute join)
- void SetWindRule (IpeAttribute rule)
- void SetTextSize (IpeAttribute size)
- void SetMarkSize (IpeAttribute size)
- void SetMarkShape (int shape)
- const IpeStyleSheet * StyleSheet () const
- IpeAttribute Stroke () const
- IpeAttribute Fill () const
- const IpeMatrix & Matrix () const
- IpeAttribute LineWidth () const
- IpeAttribute DashStyle () const
- IpeAttribute LineCap () const
- IpeAttribute LineJoin () const
- IpeAttribute WindRule () const
- IpeAttribute TextSize () const
- IpeAttribute MarkSize () const
- int MarkShape () const
- const IpeRepository * Repository () const

## Protected Types

- typedef std::list< State > StateSeq

## Protected Attributes

- StateSeq iState
- const IpeStyleSheet * iStyleSheet

## Detailed Description

Interface for drawing.

IpePainter-derived classes are used for drawing to the screen and for generating PDF output.

The IpePainter maintains a stack of graphics states, which includes stroke and fill color, line width, dash style, miter limit, line cap and line join, and the current transformation matrix. The IpePainter class takes care of maintaining this stack, and setting of the attributes in the current graphics state.

Setting an attribute with a symbolic value is resolved immediately using the IpeStyleSheet attached to the IpePainter, so calling the Stroke() or Fill() methods of IpePainter will return the current absolute color.

Attributes must not be changed after a path has been started. (Although this does not seem to be stated explicitely in the PDF Reference, Acrobat Reader 4 complains if the dash style is set after a path has been defined.)

Derived classes need to implement the functions for drawing paths, images, and texts.

A null color is drawn as if it was void. Ipe objects exploit this: only group objects ever need to explicitly contain a 'void' color.

A null dash style is drawn as solid.

A null line width is drawn as whatever is the standard of the drawing medium.

## Constructor & Destructor Documentation

IpePainter::IpePainter | ( | const IpeStyleSheet * | style | ) |

| Constructor takes a (cascaded) style sheet, which is not owned. The initial graphics state contains null attributes and default line cap and line join.

IpePainter::~IpePainter | ( |  | ) | `[virtual]`

| Virtual destructor.

## Member Function Documentation

void IpePainter::Transform | ( | const IpeMatrix & | m | ) | `[virtual]`

| Concatenate a matrix to current transformation matrix.

void IpePainter::Untransform | ( | bool | direct | ) | `[virtual]`

| Reset transformation to original one, but with different origin/direction. This changes the current transformation matrix to the one set before the first Push operation, but maintaining the current origin. If direct is `true`, then the x-direction is also kept.

void IpePainter::Translate | ( | const IpeVector & | v | ) | `[virtual]`

| Concatenate a translation to current transformation matrix.

void IpePainter::BeginPath | ( | const IpeVector & | v | ) | `[virtual]`

| Start a new open path.

void IpePainter::BeginClosedPath | ( | const IpeVector & | v | ) | `[virtual]`

| Start a new closed path.

void IpePainter::LineTo | ( | const IpeVector & | v | ) | `[virtual]`

| Add line segment to path.

void IpePainter::CurveTo | ( | const IpeVector & | v1,
|  | const IpeVector & | v2,
|  | const IpeVector & | v3
| ) | `[virtual]`

| Add a Bezier segment to path.

void IpePainter::CurveTo | ( | const IpeBezier & | bezier | ) | `[inline]`

| Overloaded function. Assumes current position is `bezier.iV`[0]

void IpePainter::Rect | ( | const IpeRect & | re | ) | `[virtual]`

| Add a rectangle to the path. Has a default implementation in terms of LineTo, but derived classes can reimplement for efficiency.

void IpePainter::EndPath | ( |  | ) | `[virtual]`

| End open path.

void IpePainter::EndClosedPath | ( |  | ) | `[virtual]`

| End closed path.

void IpePainter::Push | ( |  | ) | `[virtual]`

| Save current graphics state.

void IpePainter::Pop | ( |  | ) | `[virtual]`

| Restore previous graphics state.

void IpePainter::DrawPath | ( |  | ) | `[virtual]`

| Fill and/or stroke a path (depending on color). As in PDF, an "path" can consist of several components that are defined by sequences of BeginClosedPath() and EndClosedPath().

void IpePainter::DrawBitmap | ( | IpeBitmap | bitmap | ) | `[virtual]`

| Render a bitmap. Assumes the transformation matrix has been set up to map the unit square to the image area on the paper.

void IpePainter::DrawText | ( | const IpeText * | text | ) | `[virtual]`

| Render a text object. Stroke color is already set, and the origin is the lower-left corner of the text box.

void IpePainter::DrawEllipse | ( |  | ) |

Draw the unit circle.

PDF does not have an "arc" or "circle" primitive, so to draw an arc, circle, or ellipse, Ipe has to translate it into a sequence of Bezier curves.

The approximation is based on the following: The unit circle arc from (1,0) to (cos a, sin a) be approximated by a Bezier spline with control points (1, 0), (1, beta) and their mirror images along the line with slope a/2, where beta = 4.0 * (1.0 - cos(a/2)) / (3 * sin(a/2))

Ipe draws circles by drawing four Bezier curves for the quadrants, and arcs by patching together quarter circle approximations with a piece computed from the formula above.

This does not modify the transformation matrix. The path is generated as a sequence BeginClosedPath .. CurveTo .. EndClosedPath, but is not actually drawn (DrawPath is not called).

void IpePainter::DrawArc | ( | double | alpha | ) |

Draw an arc of the unit circle of length alpha.

alpha is normalized to [0, 2 pi], and applied starting from the point (1,0).

The function works by generating a sequence of Bezier splines (see DrawEllipse for details of the transformation). It only generates calls to CurveTo. It is assumed that the caller has already executed a MoveTo to the beginning of the arc at (1,0).

This function may modify the transformation matrix.

void IpePainter::SetStroke | ( | IpeAttribute | color | ) |

| Set stroke color, resolving symbolic color.

void IpePainter::SetFill | ( | IpeAttribute | color | ) |

| Set fill color, resolving symbolic color.

void IpePainter::SetLineWidth | ( | IpeAttribute | wid | ) |

| Set line width, resolving symbolic value.

void IpePainter::SetDashStyle | ( | IpeAttribute | dash | ) |

| Set dash style, resolving symbolic value.

void IpePainter::SetLineCap | ( | IpeAttribute | cap | ) |

| Set line cap.

void IpePainter::SetLineJoin | ( | IpeAttribute | join | ) |

| Set line join.

void IpePainter::SetWindRule | ( | IpeAttribute | rule | ) |

| Set wind rule (wind or even-odd).

void IpePainter::SetTextSize | ( | IpeAttribute | size | ) |

| Set font size of text objects. Paradoxically, this isn't actually used to render text, but for saving Ipegroup objects! Text goes through the Pdflatex interface, and the visitor that scans for text objects and writes them to the Latex source file finds the text size information itself.

void IpePainter::SetMarkSize | ( | IpeAttribute | size | ) |

| Set size of mark objects.

void IpePainter::SetMarkShape | ( | int | shape | ) |

| Set shape of mark objects.

const IpeStyleSheet* IpePainter::StyleSheet | ( |  | ) | const`[inline]`

| Return style sheet.

IpeAttribute IpePainter::Stroke | ( |  | ) | const`[inline]`

| Return current stroke color (always absolute).

IpeAttribute IpePainter::Fill | ( |  | ) | const`[inline]`

| Return current fill color (always absolute).

const IpeMatrix& IpePainter::Matrix | ( |  | ) | const`[inline]`

| Return current transformation matrix.

IpeAttribute IpePainter::LineWidth | ( |  | ) | const`[inline]`

| Return current line width (always absolute).

IpeAttribute IpePainter::DashStyle | ( |  | ) | const`[inline]`

| Return current dash style (always absolute).

IpeAttribute IpePainter::LineCap | ( |  | ) | const`[inline]`

| Return current line cap.

IpeAttribute IpePainter::LineJoin | ( |  | ) | const`[inline]`

| Return current line join.

IpeAttribute IpePainter::WindRule | ( |  | ) | const`[inline]`

| Return current wind rule.

IpeAttribute IpePainter::TextSize | ( |  | ) | const`[inline]`

| Return current text font size.

IpeAttribute IpePainter::MarkSize | ( |  | ) | const`[inline]`

| Return current mark size.

int IpePainter::MarkShape | ( |  | ) | const`[inline]`

| Return current mark shape.

const IpeRepository* IpePainter::Repository | ( |  | ) | const`[inline]`

| Return repository.

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

- ipepainter.h
- ipepainter.cpp