Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes

LibBoard::Shape Struct Reference

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

#include <Shapes.h>

Inheritance diagram for LibBoard::Shape:
Inheritance graph
[legend]
Collaboration diagram for LibBoard::Shape:
Collaboration graph
[legend]

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 =0
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
virtual Shapescale (double sx, double sy)=0
virtual Shapescale (double s)=0
virtual Rect boundingBox () const =0
Rect bbox ()
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
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

Protected Attributes

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

Static Private Attributes

static const std::string _name

Detailed Description

Abstract structure for a 2D shape.

Shape structure.


Member Enumeration Documentation

Enumerator:
ButtCap 
RoundCap 
SquareCap 
Enumerator:
MiterJoin 
RoundJoin 
BevelJoin 
Enumerator:
SolidStyle 
DashStyle 
DotStyle 
DashDotStyle 
DashDotDotStyle 
DashDotDotDotStyle 

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:
penColor The pen color of the shape.
fillColor The fill color of the shape.
lineWidth The line thickness.
depth The depth of the shape.
virtual LibBoard::Shape::~Shape (  )  [inline, virtual]

Shape destructor.


Member Function Documentation

Rect LibBoard::Shape::bbox (  )  [inline]

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

References boundingBox().

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

Returns the bounding box of the figure.

Returns:
The rectangle of the bounding box.

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

Referenced by bbox().

virtual Point LibBoard::Shape::center (  )  const [pure virtual]

Returns the gravity center of the shape.

Returns:
The center of the shape.

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

Referenced by rotateDeg().

virtual Shape* LibBoard::Shape::clone (  )  const [pure virtual]
int LibBoard::Shape::depth (  )  const [inline]
void LibBoard::Shape::depth ( int  d  )  [virtual]

References _depth.

const Color & LibBoard::Shape::fillColor (  )  const [inline]

References _fillColor.

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]

Writes the FIG code of the shape in a stream according to a transform.

Parameters:
stream The output stream.
transform A 2D transform to be applied.

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

virtual void LibBoard::Shape::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const [pure virtual]

Writes the EPS code of the shape in a stream according to a transform.

Parameters:
stream The output stream.
transform A 2D transform to be applied.

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

virtual void LibBoard::Shape::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const [pure virtual]

Writes the SVG code of the shape in a stream according to a transform.

Parameters:
stream The output stream.
transform A 2D transform to be applied.

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

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:

References _depth.

Shape & LibBoard::Shape::operator-- (  )  [inline]

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

Returns:

References _depth.

const Color & LibBoard::Shape::penColor (  )  const [inline]

References _penColor.

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::Polyline::flushPostscript(), LibBoard::Ellipse::flushPostscript(), LibBoard::Arrow::flushPostscript(), LibBoard::Line::flushPostscript(), and LibBoard::Dot::flushPostscript().

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

Rotate the shape around its center.

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

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

virtual Shape& LibBoard::Shape::rotate ( double  angle,
const Point center 
) [pure virtual]

Rotate the shape around a given center of rotation.

Parameters:
angle The rotation angle in radian.
center The center of rotation.
Returns:
A reference to the shape itself.

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

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

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

Rotate the shape around its center.

Parameters:
angle The rotation angle in degree.
center The center of rotation.
Returns:
A reference to the shape itself.

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

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

Rotate the shape around a given center of rotation.

Parameters:
angle The rotation angle in degree.
center The center of rotation.
Returns:
A reference to the shape itself.

References M_PI, and rotate().

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

Scale the shape along both axis.

Parameters:
s The scale factor along both axis.
Returns:
The shape itself.

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

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

Scale the shape along the x an y axis.

Parameters:
sx The scale factor along the x axis.
sy The scale factor along the y axis.
Returns:
The shape itself.

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

Referenced by LibBoard::Board::addDuplicates().

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

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

Parameters:
s The scaling factor.

Implemented in LibBoard::ShapeList, LibBoard::Dot, LibBoard::Line, LibBoard::Polyline, LibBoard::Rectangle, LibBoard::GouraudTriangle, LibBoard::Ellipse, LibBoard::Circle, and LibBoard::Text.

Referenced by LibBoard::ShapeList::addShape(), and LibBoard::Board::State::unit().

void LibBoard::Shape::shiftDepth ( int  shift  )  [virtual]

Reimplemented in LibBoard::ShapeList.

References _depth.

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, LibBoard::TransformSVG::mapWidth(), LibBoard::Color::None, SolidStyle, LibBoard::Color::svg(), and LibBoard::Color::svgAlpha().

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

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

Translate the shape by a given offset.

Parameters:
dx The x offset.
dy The y offset.
Returns:
A reference to the shape itself.

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

Referenced by LibBoard::Board::addDuplicates().


Field Documentation

int LibBoard::Shape::_depth [protected]
double LibBoard::Shape::_lineWidth [protected]
const std::string LibBoard::Shape::_name [static, private]

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