Board  0.9.4
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LibBoard::ShapeList Struct Reference

A group of shapes. More...

#include <ShapeList.h>

Inheritance diagram for LibBoard::ShapeList:
LibBoard::Shape LibBoard::Board LibBoard::Group

Public Types

enum  Direction { Top, Right, Bottom, Left }
 
enum  Alignment {
  AlignTop, AlignBottom, AlignCenter, AlignLeft,
  AlignRight
}
 
- Public Types inherited from LibBoard::Shape
enum  LineCap { ButtCap = 0, RoundCap, SquareCap }
 
enum  LineJoin { MiterJoin = 0, RoundJoin, BevelJoin }
 
enum  LineStyle {
  SolidStyle = 0, DashStyle, DotStyle, DashDotStyle,
  DashDotDotStyle, DashDotDotDotStyle
}
 
enum  LineWidthFlag { IgnoreLineWidth, UseLineWidth }
 

Public Member Functions

 ShapeList (int depth=-1)
 
 ShapeList (const ShapeList &other)
 
ShapeListoperator= (const ShapeList &other)
 
 ShapeList (const Shape &shape, unsigned int times, double dx, double dy, double scale)
 
 ShapeList (const Shape &shape, unsigned int times, double dx, double dy, double scaleX, double scaleY, double angle)
 
const std::string & name () const
 
ShapeListclear ()
 
ShapeListrotate (double angle, const Point &center)
 
ShapeList rotated (double angle, const Point &center)
 
ShapeListrotate (double angle)
 
ShapeList rotated (double angle)
 
ShapeListtranslate (double dx, double dy)
 
ShapeList translated (double dx, double dy)
 
ShapeListscale (double sx, double sy)
 
ShapeListscale (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
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const
 
Rect boundingBox (LineWidthFlag) const
 
virtual int minDepth () const
 
virtual int maxDepth () const
 
void shiftDepth (int shift)
 
ShapeListclone () const
 
ShapeListoperator<< (const Shape &shape)
 
ShapeListoperator+= (const Shape &shape)
 
ShapeListappend (const Shape &shape, Direction direction, Alignment alignment, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
 
GroupaddTiling (const Shape &shape, Point topLeftCorner, std::size_t columns, std::size_t rows, double spacing=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
 
void repeat (const Shape &shape, unsigned int times, double dx, double dy, double scaleX=1.0, double scaleY=1.0, double angle=0.0)
 
ShapeListinsert (const Shape &shape, int depth)
 
ShapeListdup (std::size_t copies=1)
 
template<typename T >
T & last (const std::size_t position=0)
 
Shapelast (const std::size_t position=0)
 
Shapetop ()
 
virtual void accept (ShapeVisitor &visitor)
 Accepts a visitor object. More...
 
virtual void accept (const ShapeVisitor &visitor)
 Accepts a visitor object. More...
 
- Public Member Functions inherited from LibBoard::Shape
 Shape (Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join, int depth)
 
virtual ~Shape ()
 
bool filled () const
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
Rect bbox (LineWidthFlag) const
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
int depth () const
 
virtual void depth (int)
 
const ColorpenColor () const
 
const ColorfillColor () const
 

Protected Member Functions

void addShape (const Shape &shape, double scaleFactor)
 
void free ()
 
- Protected Member Functions inherited from LibBoard::Shape
void updateLineWidth (double s)
 
std::string svgProperties (const TransformSVG &transform) const
 
std::string postscriptProperties (const TransformEPS &transform) const
 
std::string tikzProperties (const TransformTikZ &transform) const
 

Protected Attributes

std::vector< Shape * > _shapes
 
int _nextDepth
 
- Protected Attributes inherited from LibBoard::Shape
int _depth
 
Color _penColor
 
Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

Additional Inherited Members

- Static Public Member Functions inherited from LibBoard::Shape
static void enableLineWidthScaling ()
 
static void disableLineWidthScaling ()
 
static void setLineWidthScaling (bool)
 
static void setDefaultLineWidth (double)
 
static void setDefaultPenColor (Color)
 
static void setDefaultFillColor (Color)
 
static void setDefaultLineStyle (Shape::LineStyle)
 
static void setDefaultLineCap (Shape::LineCap)
 
static void setDefaultLineJoin (Shape::LineJoin)
 
static double defaultLineWidth ()
 defaultLineWidth More...
 
static Color defaultPenColor ()
 defaultPenColor More...
 
static Color defaultFillColor ()
 defaultFillColor More...
 
static Shape::LineStyle defaultLineStyle ()
 defaultLineStyle More...
 
static Shape::LineCap defaultLineCap ()
 defaultLineCap More...
 
static Shape::LineJoin defaultLineJoin ()
 defaultLineJoin More...
 
- Static Protected Attributes inherited from LibBoard::Shape
static bool _lineWidthScaling = true
 
static double _defaultLineWidth = 1.0
 
static Color _defaultPenColor = Color::Black
 
static Color _defaultFillColor = Color::Null
 
static Shape::LineStyle _defaultLineStyle = Shape::SolidStyle
 
static Shape::LineCap _defaultLineCap = Shape::ButtCap
 
static Shape::LineJoin _defaultLineJoin = Shape::MiterJoin
 

Detailed Description

A group of shapes.

The ShapeList structure.

Examples:
examples/example4.cpp, and examples/stroke_path.cpp.

Constructor & Destructor Documentation

LibBoard::ShapeList::ShapeList ( const Shape shape,
unsigned int  times,
double  dx,
double  dy,
double  scale 
)

Create a ShapeList by repeating a shape (translation & scaling)

Parameters
shapeThe shape to be repeated.
timesThe number of repetitions.
dxThe x shift between two repetitions.
dyThe y shift between two repetitions.
scaleThe scaling factor between two repetitions.

References LibBoard::Shape::clone(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().

LibBoard::ShapeList::ShapeList ( const Shape shape,
unsigned int  times,
double  dx,
double  dy,
double  scaleX,
double  scaleY,
double  angle 
)

Create a ShapeList by repeating a shape (translation, scaling & rotation)

Parameters
shapeThe shape to be repeated.
timesThe number of repetitions.
dxThe x shift between two repetitions.
dyThe y shift between two repetitions.
scaleXThe x scaling factor between two repetitions.
scaleYThe y scaling factor between two repetitions.
angleThe rotation angle between two repetitions.

References LibBoard::Shape::clone(), LibBoard::Shape::rotate(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().

Member Function Documentation

void LibBoard::ShapeList::accept ( ShapeVisitor visitor)
virtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References _shapes.

Referenced by accept().

void LibBoard::ShapeList::accept ( const ShapeVisitor visitor)
virtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References _shapes, and accept().

Group & LibBoard::ShapeList::addTiling ( const Shape shape,
Point  topLeftCorner,
std::size_t  columns,
std::size_t  rows,
double  spacing = 0.0,
LineWidthFlag  lineWidthFlag = UseLineWidth 
)

Insert a tiling based on a shape by repeating this shape along its bounding box.

Parameters
shapeA shape to be repeated.
topLeftCornerPosition of the top left corner of the tiling.
columnsNumber of columns of the tiling.
rowsNumber of rows of the tiling.
spacingSpacing between rows and columns.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
A reference to the tiling that has been added, as a Group.
Examples:
examples/tilings.cpp.

References LibBoard::Shape::boundingBox(), LibBoard::Shape::clone(), LibBoard::Rect::height, last(), LibBoard::Rect::left, LibBoard::Rect::top, LibBoard::Shape::translate(), LibBoard::Rect::width, LibBoard::Point::x, and LibBoard::Point::y.

ShapeList & LibBoard::ShapeList::append ( const Shape shape,
ShapeList::Direction  direction,
ShapeList::Alignment  alignment,
double  margin = 0.0,
LineWidthFlag  lineWidthFlag = UseLineWidth 
)

Append a shape beside the shapelist.

Parameters
shapeA shape.
directionThe direction where the shape should be appended.
alignmentThe alignement with the current shapelist.
marginA margin between the shapelist and the shape.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
The shapelist itself, after the shape has been appended.
Examples:
examples/stroke_path.cpp, and examples/tilings.cpp.

References _shapes, boundingBox(), LibBoard::Shape::boundingBox(), LibBoard::Shape::clone(), LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Shape::moveCenter(), LibBoard::Rect::top, LibBoard::Rect::width, LibBoard::Point::x, and LibBoard::Point::y.

Rect LibBoard::ShapeList::boundingBox ( LineWidthFlag  ) const
virtual
ShapeList * LibBoard::ShapeList::clone ( ) const
virtual

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

ShapeList & LibBoard::ShapeList::dup ( std::size_t  copies = 1)

Duplicates the last inserted shape.

Parameters
copiesThe number of copies.

References _shapes.

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

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

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

Referenced by LibBoard::Group::flushFIG().

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

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

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

Referenced by LibBoard::Group::flushPostscript().

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

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

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

Referenced by LibBoard::Group::flushSVG().

void LibBoard::ShapeList::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
virtual

Write the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

Referenced by LibBoard::Group::flushTikZ().

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 >
T & LibBoard::ShapeList::last ( const std::size_t  position = 0)

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

Parameters
positionThe position. 0 is the last inserted shape, 1 is the one before, etc.
Returns
A reference to the addressed shape.
Examples:
examples/arrows.cpp, examples/example2.cpp, examples/logo.cpp, and examples/ruler.cpp.

Referenced by addTiling().

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

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

void LibBoard::ShapeList::repeat ( const Shape shape,
unsigned int  times,
double  dx,
double  dy,
double  scaleX = 1.0,
double  scaleY = 1.0,
double  angle = 0.0 
)

A a repeated shape (with translation, scaling & rotation)

Parameters
shapeThe shape to be repeated.
timesThe number of repetitions.
dxThe x shift between two repetitions.
dyThe y shift between two repetitions.
scaleXThe x scaling factor between two repetitions.
scaleYThe y scaling factor between two repetitions.
angleThe rotation angle between two repetitions.

References LibBoard::Shape::clone(), LibBoard::Shape::rotate(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().

ShapeList & LibBoard::ShapeList::rotate ( double  angle,
const Point center 
)
virtual

Rotate the shape around a given center of rotation.

Parameters
angleThe rotation angle in radian.
centerThe center of rotation.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References _shapes.

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

ShapeList & LibBoard::ShapeList::rotate ( double  angle)
virtual

Rotate the shape around its center.

Parameters
angleThe rotation angle in radian.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References LibBoard::Shape::center(), and rotate().

ShapeList & LibBoard::ShapeList::scale ( double  sx,
double  sy 
)
virtual

Scale the shape along the x an y axis.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
The shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

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

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

ShapeList & LibBoard::ShapeList::scale ( double  s)
virtual

Scale the shape along both axis.

Parameters
sThe scaling factor along both axis.
Returns
The shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

References scale().

void LibBoard::ShapeList::scaleAll ( double  s)
virtual

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

Parameters
sThe 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
dxThe x offset.
dyThe y offset.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Group.

Examples:
examples/example4.cpp.

References _shapes.

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

Member Data Documentation

int LibBoard::ShapeList::_nextDepth
protected
std::vector<Shape*> LibBoard::ShapeList::_shapes
protected

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