Board
0.9.5
|
A group of shapes. More...
#include <ShapeList.h>
Classes | |
struct | BreadthFirstIterator |
The BreadthFirstIterator struct allows to traverse the shape tree using a breadth-first strategy. More... | |
struct | DepthFirstIterator |
The DepthFirstIterator struct allows to traverse the shape tree using a depth-first strategy. More... | |
struct | TopLevelConstIterator |
The TopLevelConstIterator struct. More... | |
struct | TopLevelIterator |
The TopLevelIterator struct. More... | |
Public Types | |
enum | Direction { Top, Right, Bottom, Left } |
enum | Alignment { AlignTop, AlignBottom, AlignCenter, AlignLeft, AlignRight } |
typedef std::vector< Shape * >::size_type | size_type |
Public Member Functions | |
ShapeList (const ShapeList &other) | |
ShapeList & | operator= (const ShapeList &other) |
ShapeList (ShapeList &&other) | |
ShapeList & | operator= (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 override |
ShapeList & | clear () |
ShapeList & | rotate (double angle, const Point ¢er) override |
ShapeList | rotated (double angle, const Point ¢er) |
ShapeList & | rotate (double angle) override |
ShapeList | rotated (double angle) |
ShapeList & | translate (double dx, double dy) override |
ShapeList | translated (double dx, double dy) |
ShapeList & | scale (double sx, double sy) override |
ShapeList & | scale (double s) override |
ShapeList | scaled (double sx, double sy) const |
ShapeList | scaled (double s) const |
void | scaleAll (double s) override |
void | flushPostscript (std::ostream &stream, const TransformEPS &transform) const override |
void | flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override |
void | flushSVG (std::ostream &stream, const TransformSVG &transform) const override |
void | flushTikZ (std::ostream &stream, const TransformTikZ &transform) const override |
Rect | boundingBox (LineWidthFlag) const override |
ShapeList * | clone () const override |
ShapeList & | push_back (Shape *shape) |
ShapeList & | operator<< (const Shape &shape) |
ShapeList & | operator+= (const Shape &shape) |
ShapeList & | append (const Shape &shape, Direction direction=ShapeList::Right, Alignment alignment=ShapeList::AlignCenter, 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 & | 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) |
template<typename T > | |
T & | topLevelFindLast (std::size_t position=0) |
Shape & | top () |
void | accept (ShapeVisitor &visitor) override |
Accepts a visitor object. More... | |
void | accept (const ShapeVisitor &visitor) override |
Accepts a visitor object. More... | |
void | accept (ConstShapeVisitor &visitor) const override |
Accepts a const-shape visitor object. More... | |
void | accept (const ConstShapeVisitor &visitor) const override |
Accepts a const-shape visitor object. More... | |
Shape * | accept (CompositeShapeTransform &transform) const override |
Accept a composite shape transform. More... | |
Shape * | accept (const CompositeShapeTransform &transform) const override |
Accept a constant composite shape transform. More... | |
TopLevelIterator | begin () |
begin More... | |
TopLevelIterator | end () |
end More... | |
TopLevelConstIterator | begin () const |
begin More... | |
TopLevelConstIterator | cbegin () const |
cbegin More... | |
TopLevelConstIterator | end () const |
end More... | |
TopLevelConstIterator | cend () const |
cend More... | |
DepthFirstIterator | depthFirstBegin () |
depthFirstBegin More... | |
DepthFirstIterator | depthFirstEnd () |
depthFirstEnd More... | |
BreadthFirstIterator | breadthFirstBegin () |
breadthFirstBegin More... | |
BreadthFirstIterator | breadthFirstEnd () |
breadthFirstEnd More... | |
std::size_t | deepSize () const |
Recursively counts the number of shapes in the list. More... | |
std::size_t | size () const |
The number of shapes in the list (at top level). More... | |
Public Member Functions inherited from LibBoard::Shape | |
Shape () | |
virtual | ~Shape () |
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 & | resize (double width, double height, LineWidthFlag lineWidthFlag) |
Shape & | scaleToWidth (double w, LineWidthFlag lineWidthFlag) |
Shape & | scaleToHeight (double h, LineWidthFlag lineWidthFlag) |
Rect | bbox (LineWidthFlag) const |
Shape (const Shape &other) | |
Protected Member Functions | |
void | addShape (const Shape &shape, double scaleFactor) |
void | deleteShapes () |
Protected Attributes | |
std::vector< Shape * > | _shapes |
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(), scale(), 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().
|
overridevirtual |
Accept a composite shape transform.
transform | A composite shape transform object. |
Reimplemented from LibBoard::Shape.
References _shapes, LibBoard::Shape::accept(), and push_back().
|
overridevirtual |
Accept a constant composite shape transform.
transform | A constant composite shape transform object.. |
Reimplemented from LibBoard::Shape.
References _shapes, LibBoard::Shape::accept(), and push_back().
|
overridevirtual |
Accepts a const-shape visitor object.
visitor | A const-shape visitor object. |
Reimplemented from LibBoard::Shape.
References _shapes, LibBoard::Shape::accept(), and end().
|
overridevirtual |
|
overridevirtual |
Accepts a const-shape visitor object.
visitor | A const-shape visitor object. |
Reimplemented from LibBoard::Shape.
References _shapes, LibBoard::Shape::accept(), and end().
|
overridevirtual |
Accepts a visitor object.
visitor | A visitor object. |
Reimplemented from LibBoard::Shape.
References _shapes, and end().
Referenced by accept(), and deepSize().
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::Right , |
||
ShapeList::Alignment | alignment = ShapeList::AlignCenter , |
||
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::Rect::top, LibBoard::Rect::width, LibBoard::Point::x, and LibBoard::Point::y.
Referenced by findAll().
|
inline |
|
inline |
begin
|
overridevirtual |
Compute the bounding box of the figure.
Implements LibBoard::Shape.
References _shapes, and end().
Referenced by append(), LibBoard::Group::boundingBox(), LibBoard::Board::drawBoundingBox(), LibBoard::Board::saveFIG(), LibBoard::Board::saveSVG(), and LibBoard::Board::saveTikZ().
|
inline |
breadthFirstBegin
|
inline |
breadthFirstEnd
|
inline |
|
inline |
ShapeList & LibBoard::ShapeList::clear | ( | ) |
Remove all shapes from the list.
References _shapes, and deleteShapes().
Referenced by LibBoard::Board::clear().
|
overridevirtual |
std::size_t LibBoard::ShapeList::deepSize | ( | ) | const |
Recursively counts the number of shapes in the list.
References accept().
|
protected |
Free the memory used by the shapes in the shape vector.
References _shapes.
Referenced by clear(), and LibBoard::Board::operator=().
|
inline |
depthFirstBegin
|
inline |
depthFirstEnd
ShapeList & LibBoard::ShapeList::dup | ( | std::size_t | copies = 1 | ) |
|
inline |
end
References _shapes.
Referenced by LibBoard::Group::accept(), accept(), boundingBox(), operator+=(), LibBoard::Board::operator=(), rotate(), scale(), scaleAll(), LibBoard::Group::setClippingPath(), LibBoard::Board::setClippingPath(), and translate().
|
inline |
end
|
overridevirtual |
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. |
colormap |
Implements LibBoard::Shape.
References _shapes, and LibBoard::Shape::flushFIG().
|
overridevirtual |
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.
References _shapes, and LibBoard::Shape::flushPostscript().
Referenced by LibBoard::Group::flushPostscript().
|
overridevirtual |
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.
References _shapes, and LibBoard::Shape::flushSVG().
Referenced by LibBoard::Group::flushSVG().
|
overridevirtual |
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.
References _shapes, and LibBoard::Shape::flushTikZ().
Referenced by LibBoard::Group::flushTikZ().
T & LibBoard::ShapeList::last | ( | const std::size_t | position = 0 | ) |
Return the last inserted shape with its actual type.
position | The position. 0 is the last inserted shape, 1 is the one before, etc. |
References _shapes.
Referenced by addTiling().
Shape & LibBoard::ShapeList::last | ( | const std::size_t | position = 0 | ) |
Return a reference to the last inserted Shape.
position | The position. 0 is the last inserted shape, 1 is the one before, etc. |
|
overridevirtual |
Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)
Reimplemented from LibBoard::Shape.
Referenced by topLevelFindLast().
Adds a shape to the list of shape, always preserving the shape's depth.
shape |
References _shapes, LibBoard::Shape::clone(), and end().
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 _shapes, and LibBoard::Shape::clone().
Add a shape to the list, taking ownership.
shape | The shape to be inserted. |
References _shapes.
Referenced by LibBoard::Group::accept(), and accept().
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().
|
overridevirtual |
Rotate the shape around its center.
angle | The rotation angle in radian. |
Implements LibBoard::Shape.
References LibBoard::Shape::center(), and rotate().
Rotate the shape around a given center of rotation.
angle | The rotation angle in radian. |
center | The center of rotation. |
Implements LibBoard::Shape.
References _shapes, LibBoard::Shape::center(), and end().
Referenced by LibBoard::Group::rotate(), rotate(), LibBoard::Board::rotate(), and rotated().
ShapeList LibBoard::ShapeList::rotated | ( | double | angle | ) |
Get a rotated copy of the shape list around its bounding box's center.
angle | Rotation angle in radian |
References LibBoard::Shape::center(), and rotate().
Get a rotated copy of the shape list around a specified rotation center.
angle | Rotation angle in radian |
center | Center of rotation |
References LibBoard::Shape::center(), and rotate().
|
overridevirtual |
Scale the shape along both axis.
s | The scaling factor along both axis. |
Implements LibBoard::Shape.
References scale().
|
overridevirtual |
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.
References _shapes, LibBoard::Shape::center(), end(), translate(), LibBoard::Point::x, and LibBoard::Point::y.
Referenced by LibBoard::Group::scale(), scale(), LibBoard::Board::scale(), scaled(), and ShapeList().
|
overridevirtual |
Scales all the values (positions, dimensions, etc.) associated with the shape.
s | The scaling factor. |
Implements LibBoard::Shape.
ShapeList LibBoard::ShapeList::scaled | ( | double | s | ) | const |
ShapeList LibBoard::ShapeList::scaled | ( | double | sx, |
double | sy | ||
) | const |
Get a scaled copy of the shape list.
sx | x scaling factor |
sy | y scaling factor |
References scale().
|
inline |
The number of shapes in the list (at top level).
References _shapes.
Referenced by LibBoard::Board::save(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), LibBoard::Board::saveSVG(), and LibBoard::Board::saveTikZ().
Shape & LibBoard::ShapeList::top | ( | ) |
Convenience function that simply calls last(0).
T & LibBoard::ShapeList::topLevelFindLast | ( | std::size_t | position = 0 | ) |
Find the n-th most recently inserted shape with type T.
References _shapes, and name().
Referenced by findAll().
|
overridevirtual |
Translate the shape by a given offset.
dx | The x offset. |
dy | The y offset. |
Implements LibBoard::Shape.
References _shapes, and end().
Referenced by scale(), LibBoard::Group::translate(), LibBoard::Board::translate(), and translated().
ShapeList LibBoard::ShapeList::translated | ( | double | dx, |
double | dy | ||
) |
Get a translated copy of the shape list.
dx | x shift value |
dy | y shift value |
References translate().
|
protected |
The vector of shapes (back to front).
Referenced by LibBoard::Group::accept(), accept(), append(), begin(), boundingBox(), cbegin(), cend(), clear(), deleteShapes(), LibBoard::Board::drawArrow(), 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(), end(), LibBoard::Board::fillCircle(), LibBoard::Board::fillEllipse(), LibBoard::Board::fillGouraudTriangle(), LibBoard::Board::fillPolyline(), LibBoard::Board::fillRectangle(), LibBoard::Board::fillTriangle(), flushFIG(), flushPostscript(), flushSVG(), flushTikZ(), last(), operator+=(), operator<<(), LibBoard::Board::operator=(), push_back(), rotate(), scale(), scaleAll(), size(), topLevelFindLast(), and translate().