Board  0.9.2
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LibBoard::Shape Struct Referenceabstract

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

#include <Shapes.h>

Inheritance diagram for LibBoard::Shape:
LibBoard::Dot LibBoard::Ellipse LibBoard::Image LibBoard::Line LibBoard::Polyline LibBoard::ShapeList LibBoard::Text LibBoard::Circle LibBoard::Arrow LibBoard::GouraudTriangle LibBoard::Rectangle LibBoard::Triangle LibBoard::Board LibBoard::Group

Public Types

enum  LineCap { ButtCap = 0, RoundCap, SquareCap }
 
enum  LineJoin { MiterJoin = 0, RoundJoin, BevelJoin }
 
enum  LineStyle {
  SolidStyle = 0, DashStyle, DotStyle, DashDotStyle,
  DashDotDotStyle, DashDotDotDotStyle
}
 

Public Member Functions

 Shape (Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join, int depth)
 
virtual ~Shape ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
bool filled () const
 
virtual Point center () 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)
 
ShapemoveCenter (Point p)
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
virtual Rect boundingBox () const =0
 
Rect bbox () const
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
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
 
int depth () const
 
virtual void depth (int)
 
virtual void shiftDepth (int shift)
 
const ColorpenColor () const
 
const ColorfillColor () const
 

Protected Member Functions

std::string svgProperties (const TransformSVG &transform) const
 
std::string postscriptProperties () const
 
std::string tikzProperties (const TransformTikZ &transform) const
 

Protected Attributes

int _depth
 
Color _penColor
 
Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

Detailed Description

Abstract structure for a 2D shape.

Shape structure.

Constructor & Destructor Documentation

LibBoard::Shape::Shape ( Color  penColor,
Color  fillColor,
double  lineWidth,
LineStyle  style,
const LineCap  cap,
const LineJoin  join,
int  depth 
)
inline

Shape constructor.

Parameters
penColorThe pen color of the shape.
fillColorThe fill color of the shape.
lineWidthThe line thickness.
depthThe depth of the shape.
virtual LibBoard::Shape::~Shape ( )
inlinevirtual

Shape destructor.

Member Function Documentation

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

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

Examples:
examples/koch.cpp.

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

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

Compute the bounding box of the figure.

Returns
The rectangle of the bounding box.

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

Referenced by LibBoard::ShapeList::addTiling(), LibBoard::ShapeList::append(), and center().

Point LibBoard::Shape::center ( ) const
virtual
virtual Shape* LibBoard::Shape::clone ( ) const
pure virtual
bool LibBoard::Shape::filled ( ) const
inline
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.

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

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

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

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

Shape & LibBoard::Shape::moveCenter ( double  x,
double  y 
)

Move the center of the shape.

Parameters
xThe new x coordinate of the center.
yThe new y coordinate of the center.
Returns
A reference to the shape itself.

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

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

Shape & LibBoard::Shape::moveCenter ( Point  p)

Move the center of the shape.

Parameters
pThe new center.
Returns
A reference to the shape itself.

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

const std::string & LibBoard::Shape::name ( ) const
virtual
Shape& LibBoard::Shape::operator++ ( )
inline

Increment the depth of the shape. (Push the shape toward the background.)

Returns
A reference to the shape itself.
Shape& LibBoard::Shape::operator-- ( )
inline

Decrement the depth of the shape. (Pull the shape toward the foreground.)

Returns
A reference to the shape itself.
std::string LibBoard::Shape::postscriptProperties ( ) const
protected

Return a string of the properties lineWidth, penColor, lineCap, and lineJoin as Postscript commands.

Returns
A string of the Postscript commands.

References _lineCap, _lineJoin, _lineStyle, and _lineWidth.

Referenced by LibBoard::Dot::flushPostscript(), LibBoard::Line::flushPostscript(), LibBoard::Arrow::flushPostscript(), LibBoard::Polyline::flushPostscript(), and LibBoard::Ellipse::flushPostscript().

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

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

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

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.
Shape& LibBoard::Shape::rotateDeg ( double  angle)
inline

Rotate the shape around its center.

Parameters
angleThe rotation angle in degree.
centerThe center of rotation.
Returns
A reference to the shape itself.
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::Text, LibBoard::Circle, LibBoard::Ellipse, LibBoard::Polyline, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::Image, LibBoard::Board, and LibBoard::ShapeList.

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

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

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

std::string LibBoard::Shape::svgProperties ( const TransformSVG transform) const
protected

Return a string of the svg properties lineWidth, opacity, penColor, fillColor, lineCap, and lineJoin.

Returns
A string of the properties suitable for inclusion in an svg tag.

References _fillColor, _lineCap, _lineJoin, _lineStyle, _lineWidth, _penColor, and LibBoard::Color::svgAlpha().

Referenced by LibBoard::Dot::flushSVG(), LibBoard::Line::flushSVG(), LibBoard::Polyline::flushSVG(), LibBoard::Rectangle::flushSVG(), LibBoard::Ellipse::flushSVG(), and LibBoard::Circle::flushSVG().

std::string LibBoard::Shape::tikzProperties ( const TransformTikZ transform) const
protected

Return a string of the properties lineWidth, penColor, lineCap, and lineJoin as TikZ commands.

Returns
A string of the TikZ commands.

References _fillColor, _lineCap, _lineJoin, _lineStyle, _lineWidth, _penColor, and LibBoard::Color::tikz().

Referenced by LibBoard::Line::flushTikZ(), LibBoard::Arrow::flushTikZ(), LibBoard::Polyline::flushTikZ(), LibBoard::Ellipse::flushTikZ(), LibBoard::Circle::flushTikZ(), and LibBoard::Text::flushTikZ().

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

Translate the shape by a given offset.

Parameters
dxThe x offset.
dyThe y offset.
Returns
A reference to the shape itself.

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

Referenced by LibBoard::Board::addDuplicates(), LibBoard::ShapeList::addTiling(), moveCenter(), and LibBoard::ShapeList::ShapeList().

Member Data Documentation

int LibBoard::Shape::_depth
protected
Color LibBoard::Shape::_fillColor
protected
LineCap LibBoard::Shape::_lineCap
protected
LineJoin LibBoard::Shape::_lineJoin
protected
LineStyle LibBoard::Shape::_lineStyle
protected
double LibBoard::Shape::_lineWidth
protected
Color LibBoard::Shape::_penColor
protected

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