Board 0.9.6
Public Member Functions | List of all members
LibBoard::Shape Struct Referenceabstract

Abstract structure for a 2D shape. More...

#include <Shape.h>

Inheritance diagram for LibBoard::Shape:
LibBoard::Image LibBoard::ShapeList LibBoard::ShapeWithStyle LibBoard::Board LibBoard::Group LibBoard::Bezier LibBoard::Dot LibBoard::Ellipse LibBoard::Line LibBoard::Polyline LibBoard::Text

Public Member Functions

 Shape ()
 
virtual ~Shape ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
virtual Shaperotate (double angle, const Point &center)=0
 
virtual Shaperotate (double angle)=0
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
virtual Shapetranslate (double dx, double dy)=0
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
virtual Rect boundingBox (LineWidthFlag) const =0
 
Rect bbox (LineWidthFlag) const
 
virtual void scaleAll (double s)=0
 
virtual void flushPostscript (std::ostream &stream, const TransformEPS &transform) const =0
 
virtual void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const =0
 
virtual void flushSVG (std::ostream &stream, const TransformSVG &transform) const =0
 
virtual void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const =0
 
virtual void accept (ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (const ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform.
 
 Shape (const Shape &other)
 

Detailed Description

Abstract structure for a 2D shape.

Shape structure.

Examples
examples/rough.cpp, and examples/traversal.cpp.

Constructor & Destructor Documentation

◆ Shape() [1/2]

LibBoard::Shape::Shape ( )
inline

Shape constructor.

◆ ~Shape()

LibBoard::Shape::~Shape ( )
virtual

Shape destructor.

◆ Shape() [2/2]

LibBoard::Shape::Shape ( const Shape other)

Member Function Documentation

◆ accept() [1/6]

Shape * LibBoard::Shape::accept ( CompositeShapeTransform transform) const
virtual

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::ShapeList, and LibBoard::Text.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [2/6]

Shape * LibBoard::Shape::accept ( const CompositeShapeTransform transform) const
virtual

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::ShapeList, and LibBoard::Text.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [3/6]

void LibBoard::Shape::accept ( const ConstShapeVisitor visitor) const
virtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::ShapeList, and LibBoard::Text.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [4/6]

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

◆ accept() [5/6]

void LibBoard::Shape::accept ( ConstShapeVisitor visitor) const
virtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::ShapeList, and LibBoard::Text.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [6/6]

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

◆ bbox()

Rect LibBoard::Shape::bbox ( LineWidthFlag  flag) const
inline

◆ boundingBox()

virtual Rect LibBoard::Shape::boundingBox ( LineWidthFlag  ) const
pure virtual

◆ center()

Point LibBoard::Shape::center ( LineWidthFlag  lineWidthFlag = IgnoreLineWidth) const
virtual

Returns the center of the shape.

Parameters
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
The center of the shape, i.e. the center of its bounding box.

Reimplemented in LibBoard::Dot, LibBoard::Ellipse, and LibBoard::Text.

Examples
examples/Huffman.cpp, examples/example1.cpp, examples/images.cpp, and examples/traversal.cpp.

References boundingBox(), and LibBoard::Rect::center().

Referenced by LibBoard::Group::accept(), LibBoard::Group::accept(), LibBoard::Group::accept(), main(), merge(), moveCenter(), moveCenter(), LibBoard::Board::rotate(), LibBoard::Bezier::rotate(), LibBoard::Group::rotate(), LibBoard::Image::rotate(), LibBoard::Line::rotate(), LibBoard::Polyline::rotate(), LibBoard::GouraudTriangle::rotate(), LibBoard::Board::rotate(), LibBoard::Bezier::rotate(), LibBoard::Group::rotate(), LibBoard::Image::rotate(), LibBoard::Line::rotate(), LibBoard::Polyline::rotate(), LibBoard::GouraudTriangle::rotate(), LibBoard::ShapeList::rotated(), LibBoard::Bezier::rotated(), LibBoard::Line::rotated(), LibBoard::Polyline::rotated(), LibBoard::GouraudTriangle::rotated(), LibBoard::Image::rotated(), LibBoard::Board::rotated(), LibBoard::Group::rotated(), LibBoard::Arrow::rotated(), LibBoard::Bezier::rotated(), LibBoard::Line::rotated(), LibBoard::Polyline::rotated(), LibBoard::GouraudTriangle::rotated(), rotateDeg(), rotateDeg(), LibBoard::Board::scale(), LibBoard::Group::scale(), LibBoard::Board::scale(), LibBoard::Group::scale(), LibBoard::Image::scale(), LibBoard::Line::scale(), and LibBoard::ShapeList::scale().

◆ clone()

virtual Shape * LibBoard::Shape::clone ( ) const
pure virtual

◆ flushFIG()

virtual void LibBoard::Shape::flushFIG ( std::ostream &  stream,
const TransformFIG transform,
std::map< Color, int > &  colormap 
) const
pure 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.
colormap

Implemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

◆ flushPostscript()

virtual void LibBoard::Shape::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
pure 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.

Implemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

◆ flushSVG()

virtual void LibBoard::Shape::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
pure 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.

Implemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

◆ flushTikZ()

virtual void LibBoard::Shape::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
pure 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.

Implemented in LibBoard::Arrow, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

◆ moveCenter() [1/2]

Shape & LibBoard::Shape::moveCenter ( double  x,
double  y,
LineWidthFlag  lineWidthFlag = IgnoreLineWidth 
)

Move the center of the shape.

Parameters
xThe new x coordinate of the center.
yThe new y coordinate of the center.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
A reference to the shape itself.
Examples
examples/Huffman.cpp, examples/images.cpp, and examples/xkcd.cpp.

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

Referenced by LibBoard::ShapeList::append(), LibBoard::hachures(), main(), and merge().

◆ moveCenter() [2/2]

Shape & LibBoard::Shape::moveCenter ( Point  p,
LineWidthFlag  lineWidthFlag = IgnoreLineWidth 
)

Move the center of the shape.

Parameters
pThe new center.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
A reference to the shape itself.

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

◆ name()

const std::string & LibBoard::Shape::name ( ) const
virtual

◆ resize()

Shape & LibBoard::Shape::resize ( double  width,
double  height,
LineWidthFlag  lineWidthFlag 
)

Resize the shape.

Parameters
widthThe new width.
heightThe new height.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
The shape itself.

References bbox(), boundingBox(), LibBoard::Rect::height, scale(), and LibBoard::Rect::width.

Referenced by LibBoard::Arrow::resized(), LibBoard::Bezier::resized(), LibBoard::Ellipse::resized(), LibBoard::Line::resized(), LibBoard::Polyline::resized(), and LibBoard::GouraudTriangle::resized().

◆ rotate() [1/2]

virtual Shape & LibBoard::Shape::rotate ( double  angle)
pure virtual

Rotate the shape around its center.

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

Implemented in LibBoard::Board, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

◆ rotate() [2/2]

virtual Shape & LibBoard::Shape::rotate ( double  angle,
const Point center 
)
pure 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.

Implemented in LibBoard::Board, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

Referenced by LibBoard::Board::addDuplicates(), LibBoard::ShapeList::addRepeated(), rotateDeg(), rotateDeg(), and LibBoard::ShapeList::ShapeList().

◆ rotateDeg() [1/2]

Shape & LibBoard::Shape::rotateDeg ( double  angle)
inline

Rotate the shape around its center.

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

References center(), M_PI, and rotate().

◆ rotateDeg() [2/2]

Shape & LibBoard::Shape::rotateDeg ( double  angle,
const Point center 
)
inline

Rotate the shape around a given center of rotation.

Parameters
angleThe rotation angle in degree.
centerThe center of rotation.
Returns
A reference to the shape itself.
Examples
examples/example4.cpp, examples/images.cpp, examples/tilings.cpp, and examples/xkcd.cpp.

References center(), M_PI, and rotate().

Referenced by main().

◆ scale() [1/2]

virtual Shape & LibBoard::Shape::scale ( double  s)
pure virtual

Scale the shape along both axis.

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

Implemented in LibBoard::Board, LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Group, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::ShapeList, and LibBoard::Text.

◆ scale() [2/2]

virtual Shape & LibBoard::Shape::scale ( double  sx,
double  sy 
)
pure virtual

◆ scaleAll()

virtual void LibBoard::Shape::scaleAll ( double  s)
pure virtual

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

Parameters
sThe scaling factor.

Implemented in LibBoard::Bezier, LibBoard::Dot, LibBoard::Ellipse, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::GouraudTriangle, LibBoard::ShapeList, and LibBoard::Text.

Referenced by LibBoard::ShapeList::addShape().

◆ scaleToHeight()

Shape & LibBoard::Shape::scaleToHeight ( double  h,
LineWidthFlag  lineWidthFlag 
)

Scale the shape to a given height.

Parameters
hThe requested new height.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
The shape itself.

References boundingBox(), LibBoard::Rect::height, and scale().

◆ scaleToWidth()

Shape & LibBoard::Shape::scaleToWidth ( double  w,
LineWidthFlag  lineWidthFlag 
)

◆ translate()

virtual Shape & LibBoard::Shape::translate ( double  dx,
double  dy 
)
pure virtual

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