Board
0.9.4
|
Abstract structure for a 2D shape. More...
#include <Shapes.h>
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 Shape * | clone () const =0 |
bool | filled () const |
virtual Point | center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const |
virtual Shape & | rotate (double angle, const Point ¢er)=0 |
virtual Shape & | rotate (double angle)=0 |
Shape & | rotateDeg (double angle, const Point ¢er) |
Shape & | rotateDeg (double angle) |
virtual Shape & | translate (double dx, double dy)=0 |
Shape & | moveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth) |
Shape & | moveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth) |
virtual Shape & | scale (double sx, double sy)=0 |
virtual Shape & | scale (double s)=0 |
Shape & | scaleToWidth (double w, LineWidthFlag lineWidthFlag) |
Shape & | scaleToHeight (double h, LineWidthFlag lineWidthFlag) |
virtual Rect | boundingBox (LineWidthFlag) const =0 |
Rect | bbox (LineWidthFlag) const |
Shape & | operator-- () |
Shape & | operator++ () |
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 Color & | penColor () const |
const Color & | fillColor () const |
virtual void | accept (ShapeVisitor &visitor) |
Accepts a visitor object. More... | |
virtual void | accept (const ShapeVisitor &visitor) |
Accepts a visitor object. More... | |
Static Public Member Functions | |
static void | enableLineWidthScaling () |
static void | disableLineWidthScaling () |
static void | setLineWidthScaling (bool) |
static void | setDefaultLineWidth (double) |
static void | setDefaultPenColor (Color) |
static void | setDefaultFillColor (Color) |
static void | setDefaultLineStyle (Shape::LineStyle) |
static void | setDefaultLineCap (Shape::LineCap) |
static void | setDefaultLineJoin (Shape::LineJoin) |
static double | defaultLineWidth () |
defaultLineWidth More... | |
static Color | defaultPenColor () |
defaultPenColor More... | |
static Color | defaultFillColor () |
defaultFillColor More... | |
static Shape::LineStyle | defaultLineStyle () |
defaultLineStyle More... | |
static Shape::LineCap | defaultLineCap () |
defaultLineCap More... | |
static Shape::LineJoin | defaultLineJoin () |
defaultLineJoin More... | |
Protected Member Functions | |
void | updateLineWidth (double s) |
std::string | svgProperties (const TransformSVG &transform) const |
std::string | postscriptProperties (const TransformEPS &transform) const |
std::string | tikzProperties (const TransformTikZ &transform) const |
Protected Attributes | |
int | _depth |
Color | _penColor |
Color | _fillColor |
double | _lineWidth |
LineStyle | _lineStyle |
LineCap | _lineCap |
LineJoin | _lineJoin |
Static Protected Attributes | |
static bool | _lineWidthScaling = true |
static double | _defaultLineWidth = 1.0 |
static Color | _defaultPenColor = Color::Black |
static Color | _defaultFillColor = Color::Null |
static Shape::LineStyle | _defaultLineStyle = Shape::SolidStyle |
static Shape::LineCap | _defaultLineCap = Shape::ButtCap |
static Shape::LineJoin | _defaultLineJoin = Shape::MiterJoin |
Abstract structure for a 2D shape.
Shape structure.
|
inline |
Shape constructor.
penColor | The pen color of the shape. |
fillColor | The fill color of the shape. |
lineWidth | The line thickness. |
depth | The depth of the shape. |
|
inlinevirtual |
Shape destructor.
|
virtual |
|
virtual |
|
inline |
Compute the bounding box of the figure. (Convenience method to call "boundingBox" with a short name.)
Referenced by LibBoard::Board::drawBoundingBox(), LibBoard::Image::flushFIG(), LibBoard::Group::flushFIG(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), and LibBoard::Board::saveSVG().
|
pure virtual |
Compute the bounding box of the figure.
Implemented in LibBoard::Text, LibBoard::Ellipse, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::Image, and LibBoard::ShapeList.
Referenced by LibBoard::ShapeList::addTiling(), LibBoard::ShapeList::append(), center(), scaleToHeight(), and scaleToWidth().
|
virtual |
Returns the center of the shape.
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
Reimplemented in LibBoard::Text, LibBoard::Circle, LibBoard::Ellipse, and LibBoard::Dot.
References boundingBox().
Referenced by moveCenter(), LibBoard::Image::rotate(), LibBoard::ShapeList::rotate(), LibBoard::Board::rotate(), LibBoard::Group::rotate(), LibBoard::Line::rotate(), LibBoard::Polyline::rotate(), LibBoard::GouraudTriangle::rotate(), LibBoard::Line::rotated(), LibBoard::Arrow::rotated(), LibBoard::Polyline::rotated(), LibBoard::Rectangle::rotated(), LibBoard::ShapeList::scale(), LibBoard::Board::scale(), LibBoard::Image::scale(), LibBoard::Group::scale(), and LibBoard::Line::scale().
|
pure virtual |
Return a copy of the shape.
Implemented in LibBoard::Text, LibBoard::Circle, LibBoard::Ellipse, LibBoard::GouraudTriangle, LibBoard::Triangle, LibBoard::Rectangle, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::ShapeList, and LibBoard::Image.
Referenced by LibBoard::Board::addDuplicates(), LibBoard::ShapeList::addTiling(), LibBoard::ShapeList::append(), LibBoard::ShapeList::operator+=(), LibBoard::ShapeList::operator<<(), LibBoard::ShapeList::repeat(), and LibBoard::ShapeList::ShapeList().
|
static |
defaultFillColor
|
static |
defaultLineCap
|
static |
defaultLineJoin
|
static |
defaultLineStyle
|
static |
defaultLineWidth
|
static |
defaultPenColor
|
static |
Globally disable linewidth scaling when using scale functions.
References _lineWidthScaling.
|
static |
Globally enable linewidth scaling when using scale functions.
References _lineWidthScaling.
|
inline |
Checks whether a shape is filled with a color or not.
References _fillColor.
Referenced by LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Ellipse::flushFIG(), LibBoard::Arrow::flushPostscript(), LibBoard::Polyline::flushPostscript(), and LibBoard::Ellipse::flushPostscript().
|
pure virtual |
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. |
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.
|
pure virtual |
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. |
Implemented in LibBoard::Text, LibBoard::Ellipse, LibBoard::GouraudTriangle, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::Image, and LibBoard::ShapeList.
|
pure virtual |
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. |
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.
|
pure virtual |
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. |
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, | ||
LineWidthFlag | lineWidthFlag = IgnoreLineWidth |
||
) |
Move the center of the shape.
x | The new x coordinate of the center. |
y | The new y coordinate of the center. |
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
References center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.
Referenced by LibBoard::ShapeList::append().
Move the center of the shape.
p | The new center. |
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
References center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.
|
virtual |
Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)
Reimplemented in LibBoard::Text, LibBoard::Circle, LibBoard::Ellipse, LibBoard::GouraudTriangle, LibBoard::Triangle, LibBoard::Rectangle, LibBoard::Polyline, LibBoard::Arrow, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::ShapeList, and LibBoard::Image.
|
inline |
Increment the depth of the shape. (Push the shape toward the background.)
|
inline |
Decrement the depth of the shape. (Pull the shape toward the foreground.)
|
protected |
Return a string of the properties lineWidth, penColor, lineCap, and lineJoin as 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().
Rotate the shape around a given center of rotation.
angle | The rotation angle in radian. |
center | The center of rotation. |
Implemented in LibBoard::Text, LibBoard::Circle, LibBoard::Ellipse, LibBoard::GouraudTriangle, LibBoard::Polyline, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::Board, LibBoard::ShapeList, and LibBoard::Image.
Referenced by LibBoard::Board::addDuplicates(), LibBoard::ShapeList::repeat(), and LibBoard::ShapeList::ShapeList().
|
pure virtual |
Rotate the shape around its center.
angle | The rotation angle in radian. |
Implemented in LibBoard::Text, LibBoard::Circle, LibBoard::Ellipse, LibBoard::GouraudTriangle, LibBoard::Polyline, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::Board, LibBoard::ShapeList, and LibBoard::Image.
Rotate the shape around a given center of rotation.
angle | The rotation angle in degree. |
center | The center of rotation. |
|
inline |
Rotate the shape around its center.
angle | The rotation angle in degree. |
center | The center of rotation. |
|
pure virtual |
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. |
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::repeat(), scaleToHeight(), scaleToWidth(), and LibBoard::ShapeList::ShapeList().
|
pure virtual |
Scale the shape along both axis.
s | The scaling factor along both axis. |
Implemented in LibBoard::Text, LibBoard::Circle, LibBoard::Ellipse, LibBoard::Polyline, LibBoard::Line, LibBoard::Dot, LibBoard::Group, LibBoard::Image, LibBoard::Board, and LibBoard::ShapeList.
|
pure virtual |
Scale all the values (positions, dimensions, etc.) associated with the shape.
s | The 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.
Shape & LibBoard::Shape::scaleToHeight | ( | double | h, |
Shape::LineWidthFlag | lineWidthFlag | ||
) |
Scale the shape to a given height.
h | The requested new height. |
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
References boundingBox(), LibBoard::Rect::height, and scale().
Shape & LibBoard::Shape::scaleToWidth | ( | double | w, |
Shape::LineWidthFlag | lineWidthFlag | ||
) |
Scale the shape to a given width.
w | The requested new width. |
lineWidthFlag | Should the line width be considered when computing bounding boxes. |
References boundingBox(), scale(), and LibBoard::Rect::width.
|
static |
Globally enable/disable linewidth scaling when using scale functions.
References _lineWidthScaling.
|
protected |
Return a string of the svg properties lineWidth, opacity, penColor, fillColor, lineCap, and lineJoin.
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().
|
protected |
Return a string of the properties lineWidth, penColor, lineCap, and lineJoin as 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().
|
pure virtual |
Translate the shape by a given offset.
dx | The x offset. |
dy | The y offset. |
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(), LibBoard::ShapeList::repeat(), and LibBoard::ShapeList::ShapeList().
|
protected |
The depth of the shape.
Referenced by LibBoard::Image::flushFIG(), LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Ellipse::flushFIG(), LibBoard::Text::flushFIG(), LibBoard::GouraudTriangle::flushPostscript(), and LibBoard::GouraudTriangle::flushSVG().
|
protected |
The color of the shape.
Referenced by filled(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Ellipse::flushFIG(), LibBoard::Arrow::flushPostscript(), LibBoard::Polyline::flushPostscript(), LibBoard::Ellipse::flushPostscript(), LibBoard::Arrow::flushSVG(), svgProperties(), and tikzProperties().
|
protected |
The linecap attribute. (The way line terminates.)
Referenced by LibBoard::Line::boundingBox(), LibBoard::Arrow::boundingBox(), LibBoard::Polyline::boundingBox(), LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), postscriptProperties(), svgProperties(), and tikzProperties().
|
protected |
The linejoin attribute. (The shape of line junctions.)
Referenced by LibBoard::Line::boundingBox(), LibBoard::Arrow::boundingBox(), LibBoard::Polyline::boundingBox(), LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), postscriptProperties(), svgProperties(), and tikzProperties().
|
protected |
The line style (solid, dashed, etc.).
Referenced by LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Ellipse::flushFIG(), LibBoard::Arrow::flushSVG(), postscriptProperties(), svgProperties(), and tikzProperties().
|
protected |
The line thickness.
Referenced by LibBoard::Dot::boundingBox(), LibBoard::Line::boundingBox(), LibBoard::Arrow::boundingBox(), LibBoard::Polyline::boundingBox(), LibBoard::Ellipse::boundingBox(), LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Ellipse::flushFIG(), LibBoard::Arrow::flushPostscript(), LibBoard::Arrow::flushSVG(), postscriptProperties(), svgProperties(), and tikzProperties().
|
staticprotected |
Linewidth should be scaled by scaling functions.
Referenced by disableLineWidthScaling(), enableLineWidthScaling(), and setLineWidthScaling().
|
protected |
The color of the shape.
Referenced by LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Ellipse::flushFIG(), LibBoard::Text::flushFIG(), LibBoard::Dot::flushPostscript(), LibBoard::Line::flushPostscript(), LibBoard::Arrow::flushPostscript(), LibBoard::Polyline::flushPostscript(), LibBoard::Ellipse::flushPostscript(), LibBoard::Text::flushPostscript(), LibBoard::Arrow::flushSVG(), LibBoard::Text::flushSVG(), svgProperties(), and tikzProperties().