Board 0.9.6
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.
 
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.
 
virtual void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
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
 
 ~Polyline () override=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
 
Shapeclone () const =0
 
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 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.
 
virtual void accept (const ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform.
 
 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/Huffman.cpp, examples/arrows.cpp, examples/bezier.cpp, examples/example4.cpp, examples/holes.cpp, examples/hull.cpp, examples/images.cpp, examples/interpolate.cpp, examples/koch.cpp, examples/rough.cpp, examples/sandbox.cpp, examples/sierpinski.cpp, examples/stroke_path.cpp, examples/test_depth.cpp, examples/tilings.cpp, examples/traversal.cpp, and examples/triangles.cpp.

Constructor & Destructor Documentation

◆ Polyline() [1/8]

LibBoard::Polyline::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() 
)
inline

◆ Polyline() [2/8]

LibBoard::Polyline::Polyline ( const std::vector< Point > &  points,
Path::OpenClosed  openClosed,
const Style style 
)
inline

◆ Polyline() [3/8]

LibBoard::Polyline::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() 
)
inline

◆ Polyline() [4/8]

LibBoard::Polyline::Polyline ( const Path path,
const Style style 
)
inline

◆ Polyline() [5/8]

LibBoard::Polyline::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() 
)
inline

◆ Polyline() [6/8]

LibBoard::Polyline::Polyline ( Path::OpenClosed  openClosed,
const Style style 
)
inline

◆ Polyline() [7/8]

LibBoard::Polyline::Polyline ( const Polyline )
default

◆ Polyline() [8/8]

LibBoard::Polyline::Polyline ( Polyline &&  )
default

◆ ~Polyline()

LibBoard::Polyline::~Polyline ( )
overridedefault

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.

References LibBoard::CompositeShapeTransform::map().

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

References LibBoard::CompositeShapeTransform::map().

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

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [4/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ShapeVisitor::visit().

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

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [6/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ShapeVisitor::visit().

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

References _holes, and path().

Referenced by main().

◆ boundingBox()

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

◆ clone()

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

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

Referenced by LibBoard::Board::drawBoundingBox(), LibBoard::Board::drawRectangle(), and LibBoard::Board::drawRectangle().

◆ flushFIG()

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

◆ flushPostscript()

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

◆ flushSVG()

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

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

References _path, LibBoard::ShapeWithStyle::_style, LibBoard::Path::empty(), LibBoard::Path::flushTikZPoints(), LibBoard::Path::isClosed(), and LibBoard::Style::tikzProperties().

Referenced by LibBoard::Image::flushTikZ(), and LibBoard::Board::saveTikZ().

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

◆ operator<<()

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

Add a point to the polyline.

Parameters
p
Returns

References _path.

◆ operator=() [1/2]

Polyline & LibBoard::Polyline::operator= ( const Polyline )
default

◆ operator=() [2/2]

Polyline & LibBoard::Polyline::operator= ( Polyline &&  )
default

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

References _path.

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

References _path.

◆ path()

const Path & LibBoard::Polyline::path ( ) const
inline

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

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.

Examples
examples/rough.cpp.

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

Referenced by hachures(), polygons(), LibBoard::Image::rotate(), rotate(), LibBoard::Image::rotate(), rotated(), 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, and examples/sandbox.cpp.

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

Referenced by main().

◆ 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 _holes, _path, LibBoard::Path::center(), LibBoard::Path::moveCenter(), LibBoard::Path::scale(), LibBoard::ShapeWithStyle::updateLineWidth(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scale(), LibBoard::Image::scale(), scaled(), LibBoard::GouraudTriangle::scaled(), 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.

References _holes, _path, and 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().

◆ setRectangleFlag()

void LibBoard::Polyline::setRectangleFlag ( )

Referenced by LibBoard::rectangle().

◆ 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 _holes, _path, and 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, examples/sandbox.cpp, and examples/test_depth.cpp.

References translate().

Referenced by main().

◆ vertexCount()

std::size_t LibBoard::Polyline::vertexCount ( ) const
inline

Member Data Documentation

◆ _holes

std::vector<Path> LibBoard::Polyline::_holes
protected

◆ _path

Path LibBoard::Polyline::_path
protected

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