Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes

LibBoard::ShapeList Struct Reference

A group of shapes. More...

#include <ShapeList.h>

Inheritance diagram for LibBoard::ShapeList:
Inheritance graph
[legend]
Collaboration diagram for LibBoard::ShapeList:
Collaboration graph
[legend]

Public Member Functions

 ShapeList (int depth=-1)
 ShapeList (const ShapeList &other)
 ~ShapeList ()
const std::string & name () const
ShapeListclear ()
Point center () const
Shaperotate (double angle, const Point &center)
ShapeList rotated (double angle, const Point &center)
Shaperotate (double angle)
ShapeList rotated (double angle)
Shapetranslate (double dx, double dy)
ShapeList translated (double dx, double dy)
Shapescale (double sx, double sy)
Shapescale (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)
Shapeclone () const
ShapeListoperator= (const ShapeList &other)
ShapeListoperator<< (const Shape &shape)
ShapeListoperator+= (const Shape &shape)
ShapeListinsert (const Shape &shape, int depth)
ShapeListdup (unsigned int copies=1)
template<typename T >
T & last (const unsigned int position=0)
Shapelast (const unsigned int position=0)
Shapetop ()

Protected Member Functions

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

Protected Attributes

std::vector< Shape * > _shapes
int _nextDepth

Static Private Attributes

static const std::string _name

Detailed Description

A group of shapes.

The ShapeList structure.


Constructor & Destructor Documentation

LibBoard::ShapeList::ShapeList ( int  depth = -1  )  [inline]

Referenced by clone(), rotated(), scaled(), and translated().

LibBoard::ShapeList::ShapeList ( const ShapeList other  ) 

References _shapes.

LibBoard::ShapeList::~ShapeList (  ) 

References free().


Member Function Documentation

void LibBoard::ShapeList::addShape ( const Shape shape,
double  scaleFactor 
) [protected]
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.

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(), rotated(), LibBoard::Group::scale(), scale(), and LibBoard::Board::scale().

ShapeList & LibBoard::ShapeList::clear (  ) 

References _nextDepth, _shapes, and free().

Referenced by LibBoard::Board::clear().

Shape * LibBoard::ShapeList::clone (  )  const [virtual]

Return a copy of the shape.

Returns:

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References ShapeList().

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

Duplicates the last inserted shape.

Parameters:
copies The number of copies.

References _shapes, and LibBoard::warning.

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 clear(), operator=(), LibBoard::Board::operator=(), and ~ShapeList().

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:

References LibBoard::warning.

Shape& LibBoard::ShapeList::last ( const unsigned int  position = 0  ) 
template<typename T >
T & LibBoard::ShapeList::last ( const unsigned int  position = 0  ) 

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.
int LibBoard::ShapeList::maxDepth (  )  const [virtual]
int LibBoard::ShapeList::minDepth (  )  const [virtual]
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.

References _name.

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, LibBoard::Shape::clone(), LibBoard::Shape::depth(), and minDepth().

ShapeList & LibBoard::ShapeList::operator= ( const ShapeList other  ) 

References _shapes, and free().

Shape & 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(), and rotated().

Shape & 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::rotated ( double  angle,
const Point center 
)

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

References rotate().

ShapeList LibBoard::ShapeList::rotated ( double  angle  ) 

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

References center(), and ShapeList().

Shape & 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().

Shape & 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().

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.

ShapeList LibBoard::ShapeList::scaled ( double  s  ) 

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

References ShapeList().

ShapeList LibBoard::ShapeList::scaled ( double  sx,
double  sy 
)

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

References ShapeList().

void LibBoard::ShapeList::shiftDepth ( int  shift  )  [virtual]

Reimplemented from LibBoard::Shape.

References _shapes.

Shape & LibBoard::ShapeList::top (  ) 

Convenience function that simply calls last(0).

Parameters:
position 
Returns:
Shape & 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.

References _shapes.

Referenced by scale().

ShapeList LibBoard::ShapeList::translated ( double  dx,
double  dy 
)

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

References ShapeList().


Field Documentation

const std::string LibBoard::ShapeList::_name [static, private]

The generic name of the shape.

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Group.

Referenced by name().

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

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