Board  0.9.5
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. More...
 
virtual void accept (const ShapeVisitor &visitor)
 Accepts a visitor object. More...
 
virtual void accept (ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object. More...
 
virtual void accept (const ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object. More...
 
virtual Shapeaccept (CompositeShapeTransform &transform) const
 Accept a composite shape transform. More...
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform. More...
 
 Shape (const Shape &other)
 

Detailed Description

Abstract structure for a 2D shape.

Shape structure.

Examples
examples/traversal.cpp.

Constructor & Destructor Documentation

◆ Shape()

LibBoard::Shape::Shape ( )
inline

Shape constructor.

◆ ~Shape()

LibBoard::Shape::~Shape ( )
virtual

Shape destructor.

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::ShapeList, LibBoard::Bezier, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

◆ 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::ShapeList, LibBoard::Bezier, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

◆ 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::ShapeList, LibBoard::Bezier, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::Ellipse, and LibBoard::Dot.

◆ accept() [4/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

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

◆ 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::ShapeList, LibBoard::Bezier, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::Ellipse, and LibBoard::Dot.

◆ accept() [6/6]

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

◆ bbox()

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

Compute the bounding box of the figure. (Convenience method to call "boundingBox" with a short name.)

References boundingBox().

Referenced by LibBoard::Board::drawBoundingBox(), LibBoard::Group::flushFIG(), LibBoard::Image::flushFIG(), resize(), LibBoard::Board::saveFIG(), and LibBoard::Board::saveSVG().

◆ boundingBox()

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

◆ center()

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

◆ 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::GouraudTriangle, LibBoard::Bezier, LibBoard::Line, LibBoard::Image, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::ShapeList, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

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

◆ 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::GouraudTriangle, LibBoard::Bezier, LibBoard::Line, LibBoard::Image, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::ShapeList, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

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

◆ 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::GouraudTriangle, LibBoard::Bezier, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::ShapeList, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

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

◆ 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::GouraudTriangle, LibBoard::Bezier, LibBoard::Image, LibBoard::Line, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Text, LibBoard::ShapeList, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

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

◆ 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/images.cpp.

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

◆ 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::Ellipse::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::GouraudTriangle, LibBoard::Bezier, LibBoard::Board, LibBoard::ShapeList, LibBoard::Line, LibBoard::Text, LibBoard::Image, LibBoard::Polyline, LibBoard::Dot, LibBoard::Ellipse, and LibBoard::Group.

◆ 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::GouraudTriangle, LibBoard::Board, LibBoard::Bezier, LibBoard::ShapeList, LibBoard::Text, LibBoard::Line, LibBoard::Image, LibBoard::Polyline, LibBoard::Ellipse, LibBoard::Dot, and LibBoard::Group.

Referenced by LibBoard::Board::addDuplicates(), LibBoard::ShapeList::repeat(), 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 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, and examples/tilings.cpp.

References rotate().

◆ 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::Bezier, LibBoard::Line, LibBoard::Board, LibBoard::Image, LibBoard::Polyline, LibBoard::ShapeList, LibBoard::Text, LibBoard::Dot, LibBoard::Ellipse, and LibBoard::Group.

◆ scale() [2/2]

virtual Shape& LibBoard::Shape::scale ( double  sx,
double  sy 
)
pure 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.

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

Referenced by LibBoard::Board::addDuplicates(), LibBoard::ShapeList::repeat(), resize(), scaleToHeight(), scaleToWidth(), and LibBoard::ShapeList::ShapeList().

◆ 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::GouraudTriangle, LibBoard::Bezier, LibBoard::Line, LibBoard::Image, LibBoard::Polyline, LibBoard::Text, LibBoard::ShapeList, LibBoard::Dot, and LibBoard::Ellipse.

◆ 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: