# LibBoard::ShapeList Struct Reference

A group of shapes. More...

`#include <ShapeList.h>`

Inheritance diagram for LibBoard::ShapeList:

List of all members.

## Public Member Functions

| ShapeList (int depth=-1)
| ShapeList (const ShapeList &other)
const std::string & | name () const
ShapeList & | clear ()
Point | center () const
ShapeList & | rotate (double angle, const Point &center)
ShapeList | rotated (double angle, const Point &center)
ShapeList & | rotate (double angle)
ShapeList | rotated (double angle)
ShapeList & | translate (double dx, double dy)
ShapeList | translated (double dx, double dy)
ShapeList & | scale (double sx, double sy)
ShapeList & | scale (double s)
ShapeList | scaled (double sx, double sy)
ShapeList | scaled (double s)
void | scaleAll (double s)
void | flushPostscript (std::ostream &stream, const TransformEPS &transform) const
void | flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const
void | flushSVG (std::ostream &stream, const TransformSVG &transform) const
Rect | boundingBox () const
virtual int | minDepth () const
virtual int | maxDepth () const
void | shiftDepth (int shift)
ShapeList * | clone () const
ShapeList & | operator= (const ShapeList &other)
ShapeList & | operator<< (const Shape &shape)
ShapeList & | operator+= (const Shape &shape)
ShapeList & | insert (const Shape &shape, int depth)
ShapeList & | dup (unsigned int copies=1)
template<typename T >
T & | last (const unsigned int position=0)
Shape & | last (const unsigned int position=0)
Shape & | top ()

## Protected Member Functions

void | addShape (const Shape &shape, double scaleFactor)
void | free ()

## Protected Attributes

std::vector< Shape * > | _shapes
int | _nextDepth

## Detailed Description

A group of shapes.

The ShapeList structure.

Examples:

  examples/example4.cpp, and examples/koch.cpp.

## Member Function Documentation

Rect LibBoard::ShapeList::boundingBox | ( |  | ) | const`[virtual]`

Returns the bounding box of the figure.

Returns:
  The rectangle of the bounding box.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

Examples:
  examples/ellipse.cpp.

References _shapes.

Referenced by LibBoard::Group::boundingBox(), LibBoard::Board::drawBoundingBox(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), and LibBoard::Board::saveSVG().

Point LibBoard::ShapeList::center | ( |  | ) | const`[virtual]`

Returns the gravity center of the shape.

Returns:
  The center of the shape.

Implements LibBoard::Shape.

References _shapes.

Referenced by LibBoard::Group::rotate(), rotate(), LibBoard::Board::rotate(), LibBoard::Group::scale(), scale(), and LibBoard::Board::scale().

ShapeList * LibBoard::ShapeList::clone | ( |  | ) | const`[virtual]`

Return a copy of the shape.

Returns:

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

ShapeList & LibBoard::ShapeList::dup | ( | unsigned int | copies = `1` | ) |

Duplicates the last inserted shape.

Parameters:

  | copies | The number of copies.

Examples:
  examples/koch.cpp.

References _shapes.

void LibBoard::ShapeList::flushFIG | ( | std::ostream & | stream,
|  | const TransformFIG & | transform,
|  | std::map< Color, int > & | colormap |
| ) |  |  | const`[virtual]`

Writes the FIG code of the shape in a stream according to a transform.

Parameters:

  | stream | The output stream.
  | transform | A 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

void LibBoard::ShapeList::flushPostscript | ( | std::ostream & | stream,
|  | const TransformEPS & | transform |
| ) |  |  | const`[virtual]`

Writes the EPS code of the shape in a stream according to a transform.

Parameters:

  | stream | The output stream.
  | transform | A 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

void LibBoard::ShapeList::flushSVG | ( | std::ostream & | stream,
|  | const TransformSVG & | transform |
| ) |  |  | const`[virtual]`

Writes the SVG code of the shape in a stream according to a transform.

Parameters:

  | stream | The output stream.
  | transform | A 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

void LibBoard::ShapeList::free | ( |  | ) | `[protected]`

Free the memory used by the shapes in the shape vector.

References _shapes.

Referenced by LibBoard::Board::operator=().

ShapeList & LibBoard::ShapeList::insert | ( | const Shape & | shape,
|  | int | depth |
| ) |  |  |

Insert the shape at a given depth. If the shape is ShapeList or a Board, then all shapes above it will be shifted.

Parameters:

  | shape |
  | depth |

Returns:

template<typename T >

Shape & LibBoard::ShapeList::last | ( | const unsigned int | position = `0` | ) | `[inline]`

Return the last inserted shape with its actual type, if specified (otherwise, a Shape &).

Parameters:

  | position | The position. 0 is the last inserted shape, 1 is the one before, etc.

Returns:
  A reference to the addressed shape.

Examples:
  examples/example2.cpp, examples/koch.cpp, examples/logo.cpp, and examples/ruler.cpp.

const std::string & LibBoard::ShapeList::name | ( |  | ) | const`[virtual]`

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns:

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Group.

ShapeList & LibBoard::ShapeList::operator+= | ( | const Shape & | shape | ) |

Adds a shape to the list of shape, always preserving the shape's depth.

Parameters:

  | shape |

Returns:

References _shapes, and LibBoard::Shape::clone().

ShapeList & LibBoard::ShapeList::operator<< | ( | const Shape & | shape | ) |

Adds a shape to the shape list. If the shape has no given depth or is a compound shape (ShapeList) then it is placed on top of the shapes stack. Otherwise, the shape depth is left unchanged.

Parameters:

  | shape |

Returns:

Reimplemented in LibBoard::Board.

References _nextDepth, _shapes, and LibBoard::Shape::clone().

ShapeList & LibBoard::ShapeList::rotate | ( | double | angle | ) | `[virtual]`

Rotate the shape around its center.

Parameters:

  | angle | The rotation angle in radian.

Returns:
  A reference to the shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Board, and LibBoard::Group.

References center(), and rotate().

ShapeList & LibBoard::ShapeList::rotate | ( | double | angle,
|  | const Point & | center |
| ) |  |  | `[virtual]`

Rotate the shape around a given center of rotation.

Parameters:

  | angle | The rotation angle in radian.
  | center | The center of rotation.

Returns:
  A reference to the shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Board, and LibBoard::Group.

References _shapes.

Referenced by rotate().

ShapeList & LibBoard::ShapeList::scale | ( | double | s | ) | `[virtual]`

Scale the shape along both axis.

Parameters:

  | s | The scale factor along both axis.

Returns:
  The shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Board, and LibBoard::Group.

References scale().

ShapeList & LibBoard::ShapeList::scale | ( | double | sx,
|  | double | sy |
| ) |  |  | `[virtual]`

Scale the shape along the x an y axis.

Parameters:

  | sx | The scale factor along the x axis.
  | sy | The scale factor along the y axis.

Returns:
  The shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Board, and LibBoard::Group.

References _shapes, center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scale().

void LibBoard::ShapeList::scaleAll | ( | double | s | ) | `[virtual]`

Scales all the values (positions, dimensions, etc.) associated with the shape.

Parameters:

  | s | The scaling factor.

Implements LibBoard::Shape.

References _shapes.

Shape & LibBoard::ShapeList::top | ( |  | ) |

Convenience function that simply calls last(0).

Parameters:

  | position |

Returns:

ShapeList & LibBoard::ShapeList::translate | ( | double | dx,
|  | double | dy |
| ) |  |  | `[virtual]`

Translate the shape by a given offset.

Parameters:

  | dx | The x offset.
  | dy | The y offset.

Returns:
  A reference to the shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Board, and LibBoard::Group.

Examples:
  examples/example4.cpp.

References _shapes.

Referenced by scale().

## Member Data Documentation

int LibBoard::ShapeList::_nextDepth `[protected]`

The depth of the next figure to be added.

Referenced by LibBoard::Board::drawArrow(), LibBoard::Board::drawBoundingBox(), LibBoard::Board::drawCircle(), LibBoard::Board::drawClosedPolyline(), LibBoard::Board::drawDot(), LibBoard::Board::drawEllipse(), LibBoard::Board::drawLine(), LibBoard::Board::drawPolyline(), LibBoard::Board::drawRectangle(), LibBoard::Board::drawText(), LibBoard::Board::drawTriangle(), LibBoard::Board::fillCircle(), LibBoard::Board::fillEllipse(), LibBoard::Board::fillGouraudTriangle(), LibBoard::Board::fillPolyline(), LibBoard::Board::fillRectangle(), LibBoard::Board::fillTriangle(), and operator<<().

std::vector<Shape*> LibBoard::ShapeList::_shapes `[protected]`

The vector of shapes.

Referenced by boundingBox(), center(), LibBoard::Board::drawArrow(), LibBoard::Board::drawBoundingBox(), LibBoard::Board::drawCircle(), LibBoard::Board::drawClosedPolyline(), LibBoard::Board::drawDot(), LibBoard::Board::drawEllipse(), LibBoard::Board::drawLine(), LibBoard::Board::drawPolyline(), LibBoard::Board::drawRectangle(), LibBoard::Board::drawText(), LibBoard::Board::drawTriangle(), dup(), LibBoard::Board::fillCircle(), LibBoard::Board::fillEllipse(), LibBoard::Board::fillGouraudTriangle(), LibBoard::Board::fillPolyline(), LibBoard::Board::fillRectangle(), LibBoard::Board::fillTriangle(), flushFIG(), flushPostscript(), flushSVG(), free(), operator+=(), operator<<(), LibBoard::Board::operator=(), rotate(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), LibBoard::Board::saveSVG(), scale(), scaleAll(), and translate().

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

- include/board/ShapeList.h
- src/ShapeList.cpp