Board
0.9.4
|
A group of shapes. More...
#include <ShapeList.h>
Public Types | |
enum | Direction { Top, Right, Bottom, Left } |
enum | Alignment { AlignTop, AlignBottom, AlignCenter, AlignLeft, AlignRight } |
![]() | |
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) | |
ShapeList & | operator= (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 |
ShapeList & | clear () |
ShapeList & | rotate (double angle, const Point ¢er) |
ShapeList | rotated (double angle, const Point ¢er) |
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 |
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) |
ShapeList * | clone () const |
ShapeList & | operator<< (const Shape &shape) |
ShapeList & | operator+= (const Shape &shape) |
ShapeList & | append (const Shape &shape, Direction direction, Alignment alignment, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth) |
Group & | addTiling (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) |
ShapeList & | insert (const Shape &shape, int depth) |
ShapeList & | dup (std::size_t copies=1) |
template<typename T > | |
T & | last (const std::size_t position=0) |
Shape & | last (const std::size_t position=0) |
Shape & | top () |
virtual void | accept (ShapeVisitor &visitor) |
Accepts a visitor object. More... | |
virtual void | accept (const ShapeVisitor &visitor) |
Accepts a visitor object. More... | |
![]() | |
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 |
Shape & | rotateDeg (double angle, const Point ¢er) |
Shape & | rotateDeg (double angle) |
Shape & | moveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth) |
Shape & | moveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth) |
Shape & | scaleToWidth (double w, LineWidthFlag lineWidthFlag) |
Shape & | scaleToHeight (double h, LineWidthFlag lineWidthFlag) |
Rect | bbox (LineWidthFlag) const |
Shape & | operator-- () |
Shape & | operator++ () |
int | depth () const |
virtual void | depth (int) |
const Color & | penColor () const |
const Color & | fillColor () const |
Protected Member Functions | |
void | addShape (const Shape &shape, double scaleFactor) |
void | free () |
![]() | |
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 |
![]() | |
int | _depth |
Color | _penColor |
Color | _fillColor |
double | _lineWidth |
LineStyle | _lineStyle |
LineCap | _lineCap |
LineJoin | _lineJoin |
Additional Inherited Members | |
![]() | |
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 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 |
A group of shapes.
The ShapeList structure.
LibBoard::ShapeList::ShapeList | ( | const Shape & | shape, |
unsigned int | times, | ||
double | dx, | ||
double | dy, | ||
double | scale | ||
) |
Create a ShapeList by repeating a shape (translation & scaling)
shape | The shape to be repeated. |
times | The number of repetitions. |
dx | The x shift between two repetitions. |
dy | The y shift between two repetitions. |
scale | The 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)
shape | The shape to be repeated. |
times | The number of repetitions. |
dx | The x shift between two repetitions. |
dy | The y shift between two repetitions. |
scaleX | The x scaling factor between two repetitions. |
scaleY | The y scaling factor between two repetitions. |
angle | The rotation angle between two repetitions. |
References LibBoard::Shape::clone(), LibBoard::Shape::rotate(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().
|
virtual |
Accepts a visitor object.
visitor | A visitor object. |
Reimplemented from LibBoard::Shape.
References _shapes.
Referenced by accept().
|
virtual |
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.
shape | A shape to be repeated. |
topLeftCorner | Position of the top left corner of the tiling. |
columns | Number of columns of the tiling. |
rows | Number of rows of the tiling. |
spacing | Spacing between rows and columns. |
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
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.
shape | A shape. |
direction | The direction where the shape should be appended. |
alignment | The alignement with the current shapelist. |
margin | A margin between the shapelist and the shape. |
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
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.
|
virtual |
Compute the bounding box of the figure.
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by append(), LibBoard::Group::boundingBox(), LibBoard::Board::drawBoundingBox(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), LibBoard::Board::saveSVG(), and LibBoard::Board::saveTikZ().
|
virtual |
Return a copy of the shape.
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
ShapeList & LibBoard::ShapeList::dup | ( | std::size_t | copies = 1 | ) |
|
virtual |
Write the FIG code of the shape in a stream according to a transform.
stream | The output stream. |
transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by LibBoard::Group::flushFIG().
|
virtual |
Write the EPS code of the shape in a stream according to a transform.
stream | The output stream. |
transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by LibBoard::Group::flushPostscript().
|
virtual |
Write the SVG code of the shape in a stream according to a transform.
stream | The output stream. |
transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by LibBoard::Group::flushSVG().
|
virtual |
Write the TikZ code of the shape in a stream according to a transform.
stream | The output stream. |
transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by LibBoard::Group::flushTikZ().
|
protected |
Free the memory used by the shapes in the shape vector.
References _shapes.
Referenced by LibBoard::Board::operator=().
T & LibBoard::ShapeList::last | ( | const std::size_t | position = 0 | ) |
Return the last inserted shape with its actual type, if specified (otherwise, a Shape &).
position | The position. 0 is the last inserted shape, 1 is the one before, etc. |
Referenced by addTiling().
|
virtual |
Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)
Reimplemented from LibBoard::Shape.
Reimplemented in LibBoard::Group.
Adds a shape to the list of shape, always preserving the shape's depth.
shape |
References _shapes, and LibBoard::Shape::clone().
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.
shape |
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)
shape | The shape to be repeated. |
times | The number of repetitions. |
dx | The x shift between two repetitions. |
dy | The y shift between two repetitions. |
scaleX | The x scaling factor between two repetitions. |
scaleY | The y scaling factor between two repetitions. |
angle | The rotation angle between two repetitions. |
References LibBoard::Shape::clone(), LibBoard::Shape::rotate(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().
Rotate the shape around a given center of rotation.
angle | The rotation angle in radian. |
center | The center of rotation. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by rotate(), LibBoard::Board::rotate(), and LibBoard::Group::rotate().
|
virtual |
Rotate the shape around its center.
angle | The rotation angle in radian. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References LibBoard::Shape::center(), and rotate().
|
virtual |
Scale the shape along the x an y axis.
sx | The scaling factor along the x axis. |
sy | The scaling factor along the y axis. |
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().
|
virtual |
Scale the shape along both axis.
s | The scaling factor along both axis. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References scale().
|
virtual |
Scales all the values (positions, dimensions, etc.) associated with the shape.
s | The scaling factor. |
Implements LibBoard::Shape.
References _shapes.
Shape & LibBoard::ShapeList::top | ( | ) |
Convenience function that simply calls last(0).
position |
|
virtual |
Translate the shape by a given offset.
dx | The x offset. |
dy | The y offset. |
Implements LibBoard::Shape.
Reimplemented in LibBoard::Group.
References _shapes.
Referenced by scale(), LibBoard::Board::translate(), and LibBoard::Group::translate().
|
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<<().
|
protected |
The vector of shapes.
Referenced by accept(), append(), boundingBox(), 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(), flushTikZ(), free(), operator+=(), operator<<(), LibBoard::Board::operator=(), rotate(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), LibBoard::Board::saveSVG(), LibBoard::Board::saveTikZ(), scale(), scaleAll(), and translate().