Board  0.9.5
Public Member Functions | Protected Attributes | List of all members
LibBoard::Polyline Struct Reference

A polygonal line described by a series of 2D points. More...

#include <Polyline.h>

Inheritance diagram for LibBoard::Polyline:
LibBoard::ShapeWithStyle LibBoard::Shape LibBoard::GouraudTriangle

Public Member Functions

 Polyline (const std::vector< Point > &points, Path::OpenClosed openClosed, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Polyline (const std::vector< Point > &points, Path::OpenClosed openClosed, const Style &style)
 
 Polyline (const Path &path, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Polyline (const Path &path, const Style &style)
 
 Polyline (Path::OpenClosed openClosed, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Polyline (Path::OpenClosed openClosed, const Style &style)
 
const std::string & name () const override
 
Polylineoperator<< (const Point &p)
 
Pointoperator[] (const std::size_t n)
 
const Pointoperator[] (const std::size_t n) const
 
Polylinerotate (double angle, const Point &center) override
 
Polyline rotated (double angle, const Point &center) const
 
Polylinerotate (double angle) override
 
Polyline rotated (double angle) const
 
Polylinetranslate (double dx, double dy) override
 
Polyline translated (double dx, double dy) const
 
Polylinescale (double sx, double sy) override
 
Polylinescale (double s) override
 
Polyline scaled (double sx, double sy) const
 
Polyline scaled (double s) const
 
void scaleAll (double s) override
 
Polyline resized (double w, double h, LineWidthFlag lineWidthFlag) const
 
void addHole (const Path &path)
 Add a hole to the path. Warning: Hole share the polyline line style. More...
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const override
 
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override
 
void flushSVG (std::ostream &stream, const TransformSVG &transform) const override
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const override
 
virtual void accept (ShapeVisitor &visitor) override
 Accepts a visitor object. More...
 
virtual void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object. More...
 
virtual void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object. More...
 
virtual void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object. More...
 
virtual Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform. More...
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform. More...
 
Rect boundingBox (LineWidthFlag) const override
 
Polylineclone () const override
 
std::size_t vertexCount () const
 
const Pathpath () const
 
void setRectangleFlag ()
 
 Polyline (const Polyline &)=default
 
 Polyline (Polyline &&)=default
 
Polylineoperator= (Polyline &&)=default
 
Polylineoperator= (const Polyline &)=default
 
- Public Member Functions inherited from LibBoard::ShapeWithStyle
 ShapeWithStyle (Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join)
 
 ShapeWithStyle (const Style &style)
 
 ShapeWithStyle (const ShapeWithStyle &other)
 
ShapeWithStyleoperator= (const ShapeWithStyle &other)
 
 ~ShapeWithStyle ()
 
const std::string & name () const
 
const ColorpenColor () const
 
ShapeWithStylesetPenColor (const Color &)
 
const ColorfillColor () const
 
ShapeWithStylesetFillColor (const Color &)
 
double lineWidth () const
 
ShapeWithStylesetLineWidth (double)
 
LineStyle lineStyle () const
 
ShapeWithStylesetLineStyle (LineStyle)
 
LineCap lineCap () const
 
ShapeWithStylesetLineCap (LineCap)
 
LineJoin lineJoin () const
 
ShapeWithStylesetLineJoin (LineJoin)
 
Style style () const
 
ShapeWithStylesetStyle (const Style &)
 
bool filled () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape ()
 
virtual ~Shape ()
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
Rect bbox (LineWidthFlag) const
 
 Shape (const Shape &other)
 

Protected Attributes

Path _path
 
std::vector< Path_holes
 
- Protected Attributes inherited from LibBoard::ShapeWithStyle
Style _style
 

Additional Inherited Members

- Static Public Member Functions inherited from LibBoard::ShapeWithStyle
static void setLineWidthScaling (bool)
 
- Protected Member Functions inherited from LibBoard::ShapeWithStyle
void updateLineWidth (double s)
 

Detailed Description

A polygonal line described by a series of 2D points.

The polyline structure.

Examples
examples/arrows.cpp, examples/bezier.cpp, examples/example4.cpp, examples/holes.cpp, examples/hull.cpp, examples/images.cpp, examples/koch.cpp, examples/stroke_path.cpp, examples/tilings.cpp, and examples/traversal.cpp.

Member Function Documentation

◆ accept() [1/6]

Shape * LibBoard::Polyline::accept ( CompositeShapeTransform transform) const
overridevirtual

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented from LibBoard::Shape.

◆ accept() [2/6]

Shape * LibBoard::Polyline::accept ( const CompositeShapeTransform transform) const
overridevirtual

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented from LibBoard::Shape.

◆ accept() [3/6]

void LibBoard::Polyline::accept ( const ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

◆ accept() [4/6]

void LibBoard::Polyline::accept ( const ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

◆ accept() [5/6]

void LibBoard::Polyline::accept ( ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

◆ accept() [6/6]

void LibBoard::Polyline::accept ( ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

◆ addHole()

void LibBoard::Polyline::addHole ( const Path path)

Add a hole to the path. Warning: Hole share the polyline line style.

Parameters
pathVertices of the polyline
Examples
examples/holes.cpp.

◆ boundingBox()

Rect LibBoard::Polyline::boundingBox ( LineWidthFlag  ) const
overridevirtual

Compute the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

Referenced by LibBoard::Image::boundingBox(), and LibBoard::Image::flushFIG().

◆ clone()

Polyline * LibBoard::Polyline::clone ( ) const
overridevirtual

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

Reimplemented in LibBoard::GouraudTriangle.

◆ flushFIG()

void LibBoard::Polyline::flushFIG ( std::ostream &  stream,
const TransformFIG transform,
std::map< Color, int > &  colormap 
) const
overridevirtual

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

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

Referenced by LibBoard::Image::flushFIG(), and LibBoard::GouraudTriangle::flushFIG().

◆ flushPostscript()

void LibBoard::Polyline::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
overridevirtual

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

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

References LibBoard::ShapeWithStyle::filled(), LibBoard::Path::getClockwise(), and LibBoard::Style::postscriptProperties().

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

◆ flushSVG()

void LibBoard::Polyline::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
overridevirtual

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

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

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

◆ flushTikZ()

void LibBoard::Polyline::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
overridevirtual

Write the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

References LibBoard::Style::tikzProperties().

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

◆ name()

const std::string & LibBoard::Polyline::name ( ) const
overridevirtual

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

◆ operator<<()

Polyline & LibBoard::Polyline::operator<< ( const Point p)

Add a point to the polyline.

Parameters
p
Returns

◆ operator[]() [1/2]

Point& LibBoard::Polyline::operator[] ( const std::size_t  n)
inline

Returns the n-th point of the polyline.

Parameters
n
Returns
A reference to the n-th point of the polyline.

◆ operator[]() [2/2]

const Point& LibBoard::Polyline::operator[] ( const std::size_t  n) const
inline

Returns the n-th point of the polyline.

Parameters
n
Returns
A constant reference to the n-th point of the polyline.

◆ resized()

Polyline LibBoard::Polyline::resized ( double  w,
double  h,
LineWidthFlag  lineWidthFlag 
) const

Returns a resized copy of the polyline.

Parameters
wWidth of the new polyline.
hHeight of the new polyline.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
A resized copy of the polyline.

References LibBoard::Shape::resize().

◆ rotate() [1/2]

Polyline & LibBoard::Polyline::rotate ( double  angle)
overridevirtual

Rotate the shape around its center.

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

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

References LibBoard::Shape::center(), and rotate().

◆ rotate() [2/2]

Polyline & LibBoard::Polyline::rotate ( double  angle,
const Point center 
)
overridevirtual

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.

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

References LibBoard::Shape::center(), and LibBoard::Path::rotate().

Referenced by LibBoard::Image::rotate(), rotate(), and rotated().

◆ rotated() [1/2]

Polyline LibBoard::Polyline::rotated ( double  angle) const
Parameters
angle
Returns

References LibBoard::Shape::center(), and rotate().

◆ rotated() [2/2]

Polyline LibBoard::Polyline::rotated ( double  angle,
const Point center 
) const
Parameters
angle
center
Returns
Examples
examples/example4.cpp.

References LibBoard::Shape::center(), and rotate().

◆ scale() [1/2]

Polyline & LibBoard::Polyline::scale ( double  s)
overridevirtual

Scale the polyline, given a scaling factor.

Parameters
sScaling factor.
Returns
A reference to the polyline itself, once scaled.

Implements LibBoard::Shape.

References scale().

◆ scale() [2/2]

Polyline & LibBoard::Polyline::scale ( double  sx,
double  sy 
)
overridevirtual

Scale the polyline, given two scaling factors.

Parameters
sxScaling factor along the x axis.
syScaling factor along the y axis.
Returns
A reference to the polyline itself, once scaled.

Implements LibBoard::Shape.

References LibBoard::Path::center(), LibBoard::Path::moveCenter(), LibBoard::Path::scale(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scale(), LibBoard::Image::scale(), scaled(), and LibBoard::GouraudTriangle::scaled().

◆ scaleAll()

void LibBoard::Polyline::scaleAll ( double  s)
overridevirtual

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

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

Reimplemented in LibBoard::GouraudTriangle.

References LibBoard::Path::scaleAll().

Referenced by LibBoard::Image::scaleAll().

◆ scaled() [1/2]

Polyline LibBoard::Polyline::scaled ( double  s) const

Returns a scaled copy of the line.

Parameters
sThe scaling factor.
Returns
A scaled copy of the line.

References scale().

◆ scaled() [2/2]

Polyline LibBoard::Polyline::scaled ( double  sx,
double  sy 
) const

Returns a scaled copy of the line.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
A scaled copy of the line.

References scale().

◆ translate()

Polyline & LibBoard::Polyline::translate ( double  dx,
double  dy 
)
overridevirtual

Translate the polyline by a given offset.

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

Implements LibBoard::Shape.

References LibBoard::Path::translate().

Referenced by LibBoard::Image::translate(), translated(), and LibBoard::GouraudTriangle::translated().

◆ translated()

Polyline LibBoard::Polyline::translated ( double  dx,
double  dy 
) const

Returns a translated copy of the polyline.

Parameters
dxShift of the first coordinate.
dyShift of the second coordinate.
Returns
A copy of the polyline, translated.
Examples
examples/example4.cpp.

References translate().


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