Board 0.9.6
Public Types | Public Member Functions | Protected Attributes | List of all members
LibBoard::Path Struct Reference

A path, according to Postscript and SVG definition. More...

#include <Path.h>

Public Types

enum  OpenClosed { Open , Closed }
 The OpenClosed enum. More...
 
typedef std::vector< Point >::size_type size_type
 

Public Member Functions

 Path ()
 
 Path (const std::vector< Point > &points, OpenClosed openClosed)
 Construct a path from a vector of points.
 
 Path (std::initializer_list< Point > points)
 Construct an open path from a list of points.
 
 Path (OpenClosed openClosed)
 Construct an open or closed empty path.
 
void clear ()
 Remove all points of the path.
 
bool isClosed () const
 Is the path closed?
 
bool isOpen () const
 Is the path open?
 
bool empty () const
 Check if the path is empty (i.e. has no points)
 
std::size_t size () const
 The number of points in the path.
 
void close ()
 Close the path.
 
void open ()
 Open the path.
 
OpenClosed openClosed () const
 The open/closed status of the path.
 
void setOpenClosed (OpenClosed openClosed)
 Set the open/closed flag of the path.
 
Point center () const
 Center of the bounding box of the path.
 
Pathoperator<< (const Point &p)
 Add a point at the end of the path.
 
Pathoperator<< (const std::vector< Point > &v)
 Add a vector of points at the end of the path.
 
Pathpop_back ()
 Remove the last point of the path.
 
Pathpush_back (const Point &p)
 Add a point to the path.
 
const Pointfront () const
 The first point of the path.
 
const Pointback () const
 The last point of the path.
 
Pointoperator[] (const std::size_t n)
 Get the n-th point of the path.
 
const Pointoperator[] (const std::size_t n) const
 Get the n-th point of the path (const version).
 
Pathrotate (double angle, const Point &center)
 Rotate the path by a given angle and according to a rotation center.
 
PathrotateDeg (double angle, const Point &center)
 Rotate the path by a given angle, in degrees, and according to a rotation center.
 
Path rotated (double angle, const Point &center) const
 Return a rotated copy of the path, thanks to an angle and a rotation center.
 
Path rotatedDeg (double angle, const Point &center) const
 Return a rotated copy of the path, thanks to an angle and a rotation center.
 
Pathrotate (double angle)
 Rotate the path by a given angle around the center of its bounding box.
 
PathrotateDeg (double angle)
 Rotate the path by a given angle around the center of its bounding box.
 
Path rotated (double angle) const
 Return a rotated copy of the path, around the center of its bounding box.
 
Path rotatedDeg (double angle) const
 Return a rotated copy of the path, around the center of its bounding box.
 
Pathtranslate (double dx, double dy)
 Translate the path.
 
Path translated (double dx, double dy) const
 Return a translated copy of the path.
 
PathmoveCenter (double x, double y)
 Translate the center to a given position.
 
PathmoveCenter (Point p)
 Translate the center to a given position.
 
Pathscale (double sx, double sy)
 Apply a scaling factor to the path along each axis.
 
Pathscale (double s)
 Apply a scaling factor to the path.
 
Path scaled (double sx, double sy) const
 Return a scaled copy of the path.
 
Path scaled (double s) const
 Return a scaled copy of the path.
 
void scaleAll (double s)
 Scale all the points.
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const
 
void flushFIG (std::ostream &stream, const TransformFIG &transform) const
 
void flushSVGPoints (std::ostream &stream, const TransformSVG &transform) const
 
void flushSVGCommands (std::ostream &stream, const TransformSVG &transform) const
 
void flushTikZPoints (std::ostream &stream, const TransformTikZ &transform) const
 
Path transformed (const Transform &transform) const
 Compute the path obtained after a transform.
 
bool isClockwise () const
 Tell if the points of the path are ordered clockwise.
 
bool isCounterclockwise () const
 Tell if the points of the path are ordered counterclockwise.
 
void setClockwise ()
 Make the path clockwise.
 
void setCounterclockwise ()
 Make the path counterclockwise.
 
Path getClockwise () const
 Return a clockwise copy of the path.
 
Path getCounterclockwise () const
 Return a counterclockwise copy of the path.
 
Rect boundingBox () const
 
const std::vector< Point > & points () const
 
std::ostream & flush (std::ostream &) const
 
std::vector< Point >::const_iterator begin () const
 
std::vector< Point >::const_iterator cbegin () const
 
std::vector< Point >::const_iterator end () const
 
std::vector< Point >::const_iterator cend () const
 

Protected Attributes

std::vector< Point_points
 
OpenClosed _openClosed
 

Detailed Description

A path, according to Postscript and SVG definition.

The path structure.

Examples
examples/bezier.cpp, examples/clipping.cpp, examples/holes.cpp, examples/interpolate.cpp, examples/rough.cpp, examples/stroke_path.cpp, and examples/traversal.cpp.

Member Typedef Documentation

◆ size_type

typedef std::vector<Point>::size_type LibBoard::Path::size_type

Member Enumeration Documentation

◆ OpenClosed

The OpenClosed enum.

Enumerator
Open 

The path is open.

Closed 

The is closed.

Constructor & Destructor Documentation

◆ Path() [1/4]

LibBoard::Path::Path ( )
inline

Referenced by rotated(), rotatedDeg(), scaled(), and scaled().

◆ Path() [2/4]

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

Construct a path from a vector of points.

Parameters
pointsA vector of points
openClosedThe open/closed status of the path

◆ Path() [3/4]

LibBoard::Path::Path ( std::initializer_list< Point points)

Construct an open path from a list of points.

Parameters
pointsA list of points

References _openClosed, _points, Open, and points().

◆ Path() [4/4]

LibBoard::Path::Path ( OpenClosed  openClosed)
inlineexplicit

Construct an open or closed empty path.

Parameters
openClosedThe open/closed flag

Member Function Documentation

◆ back()

const Point & LibBoard::Path::back ( ) const
inline

The last point of the path.

Returns
The last point of the path.

References _points.

Referenced by LibBoard::bezierControls(), LibBoard::Bezier::operator+=(), LibBoard::Bezier::pathThroughLocalExtremums(), and LibBoard::Bezier::smoothedPolyline().

◆ begin()

std::vector< Point >::const_iterator LibBoard::Path::begin ( ) const
inline

◆ boundingBox()

Rect LibBoard::Path::boundingBox ( ) const

◆ cbegin()

std::vector< Point >::const_iterator LibBoard::Path::cbegin ( ) const
inline

References _points.

◆ cend()

std::vector< Point >::const_iterator LibBoard::Path::cend ( ) const
inline

References _points.

◆ center()

Point LibBoard::Path::center ( ) const

◆ clear()

void LibBoard::Path::clear ( )
inline

◆ close()

void LibBoard::Path::close ( )
inline

◆ empty()

bool LibBoard::Path::empty ( ) const
inline

Check if the path is empty (i.e. has no points)

Returns
true if the path is empty, otherwise false

References _points.

Referenced by LibBoard::Polyline::flushFIG(), LibBoard::Bezier::flushPostscript(), LibBoard::Polyline::flushPostscript(), LibBoard::Bezier::flushSVG(), LibBoard::Polyline::flushSVG(), and LibBoard::Polyline::flushTikZ().

◆ end()

std::vector< Point >::const_iterator LibBoard::Path::end ( ) const
inline

◆ flush()

std::ostream & LibBoard::Path::flush ( std::ostream &  out) const

References _points.

Referenced by operator<<().

◆ flushFIG()

void LibBoard::Path::flushFIG ( std::ostream &  stream,
const TransformFIG transform 
) const

◆ flushPostscript()

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

◆ flushSVGCommands()

void LibBoard::Path::flushSVGCommands ( std::ostream &  stream,
const TransformSVG transform 
) const

◆ flushSVGPoints()

void LibBoard::Path::flushSVGPoints ( std::ostream &  stream,
const TransformSVG transform 
) const

◆ flushTikZPoints()

void LibBoard::Path::flushTikZPoints ( std::ostream &  stream,
const TransformTikZ transform 
) const

◆ front()

const Point & LibBoard::Path::front ( ) const
inline

The first point of the path.

Returns
The first point of the path.

References _points.

Referenced by LibBoard::Bezier::operator+=().

◆ getClockwise()

Path LibBoard::Path::getClockwise ( ) const

Return a clockwise copy of the path.

Returns
A clockwise copy of the path

References setClockwise().

Referenced by LibBoard::Polyline::flushPostscript(), and LibBoard::Polyline::flushSVG().

◆ getCounterclockwise()

Path LibBoard::Path::getCounterclockwise ( ) const

Return a counterclockwise copy of the path.

Returns
A counterclockwise copy of the path

References setCounterclockwise().

◆ isClockwise()

bool LibBoard::Path::isClockwise ( ) const

Tell if the points of the path are ordered clockwise.

Returns
true if the points are ordered clockwise, otherwise false.

References _points, end(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by isCounterclockwise(), and setCounterclockwise().

◆ isClosed()

bool LibBoard::Path::isClosed ( ) const
inline

◆ isCounterclockwise()

bool LibBoard::Path::isCounterclockwise ( ) const

Tell if the points of the path are ordered counterclockwise.

Returns
true if the points are ordered counterclockwise, otherwise false.

References isClockwise().

Referenced by setClockwise().

◆ isOpen()

bool LibBoard::Path::isOpen ( ) const
inline

Is the path open?

Returns
true if the path is open, otherwise false

References _openClosed, and Open.

◆ moveCenter() [1/2]

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

Translate the center to a given position.

Parameters
x
y
Returns
The (translated) path itself

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

Referenced by LibBoard::Ellipse::sampledPath(), and LibBoard::Polyline::scale().

◆ moveCenter() [2/2]

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

Translate the center to a given position.

Parameters
p
Returns
The (translated) path itself

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

◆ open()

void LibBoard::Path::open ( )
inline

Open the path.

References _openClosed, and Open.

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

◆ openClosed()

Path::OpenClosed LibBoard::Path::openClosed ( ) const
inline

The open/closed status of the path.

Returns
The open/closed flag

References _openClosed.

Referenced by LibBoard::mix(), and setOpenClosed().

◆ operator<<() [1/2]

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

Add a point at the end of the path.

Parameters
pA point.
Returns
The path itself.

References _points.

◆ operator<<() [2/2]

Path & LibBoard::Path::operator<< ( const std::vector< Point > &  v)

Add a vector of points at the end of the path.

Parameters
vA vector of points.
Returns
The path itself.

References _points.

◆ operator[]() [1/2]

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

Get the n-th point of the path.

Parameters
nIndex of a point in the path.
Returns
A reference to the n-th point.

References _points.

◆ operator[]() [2/2]

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

Get the n-th point of the path (const version).

Parameters
nIndex of a point in the path.
Returns
A (const) reference to the n-th point.

References _points.

◆ points()

const std::vector< Point > & LibBoard::Path::points ( ) const

◆ pop_back()

Path & LibBoard::Path::pop_back ( )

Remove the last point of the path.

Returns
The path itself.

References _points.

Referenced by LibBoard::Ellipse::sampledPath(), LibBoard::Board::setClippingPath(), and LibBoard::Group::setClippingPath().

◆ push_back()

Path & LibBoard::Path::push_back ( const Point p)

◆ rotate() [1/2]

Path & LibBoard::Path::rotate ( double  angle)

Rotate the path by a given angle around the center of its bounding box.

Parameters
angleThe rotation angle (in radians).
Returns
The path itself.

References center(), and rotate().

◆ rotate() [2/2]

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

Rotate the path by a given angle and according to a rotation center.

Parameters
angleThe rotation angle (in radians).
centerThe rotation center.
Returns
The path itself.

References _points, center(), and end().

Referenced by rotate(), LibBoard::Board::rotate(), LibBoard::Bezier::rotate(), LibBoard::Group::rotate(), LibBoard::Text::rotate(), LibBoard::Board::rotate(), LibBoard::Bezier::rotate(), LibBoard::Group::rotate(), LibBoard::Polyline::rotate(), LibBoard::GouraudTriangle::rotate(), LibBoard::Text::rotate(), rotateDeg(), and rotateDeg().

◆ rotated() [1/2]

Path LibBoard::Path::rotated ( double  angle) const

Return a rotated copy of the path, around the center of its bounding box.

Parameters
angleThe rotation angle (in radians).
Returns
A rotated copy of the point.

References center(), and Path().

◆ rotated() [2/2]

Path LibBoard::Path::rotated ( double  angle,
const Point center 
) const

Return a rotated copy of the path, thanks to an angle and a rotation center.

Parameters
angleThe rotation angle (in radians).
centerThe rotation center.
Returns
A rotated copy of the path.
Examples
examples/bezier.cpp.

References _points, center(), and end().

Referenced by LibBoard::hachures(), main(), and rotatedDeg().

◆ rotatedDeg() [1/2]

Path LibBoard::Path::rotatedDeg ( double  angle) const

Return a rotated copy of the path, around the center of its bounding box.

Parameters
angleThe rotation angle (in degrees).
Returns
A rotated copy of the point.

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

◆ rotatedDeg() [2/2]

Path LibBoard::Path::rotatedDeg ( double  angle,
const Point center 
) const

Return a rotated copy of the path, thanks to an angle and a rotation center.

Parameters
angleThe rotation angle (in degrees).
centerThe rotation center.
Returns
A rotated copy of the path.

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

◆ rotateDeg() [1/2]

Path & LibBoard::Path::rotateDeg ( double  angle)

Rotate the path by a given angle around the center of its bounding box.

Parameters
angleThe rotation angle (in degrees).
Returns
The path itself.

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

◆ rotateDeg() [2/2]

Path & LibBoard::Path::rotateDeg ( double  angle,
const Point center 
)

Rotate the path by a given angle, in degrees, and according to a rotation center.

Parameters
angleThe rotation angle (in degrees).
centerThe rotation center.
Returns
The path itself.

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

◆ scale() [1/2]

Path & LibBoard::Path::scale ( double  s)

Apply a scaling factor to the path.

Parameters
sThe scaling factor.
Returns
The path itself, once scaled.

References scale().

◆ scale() [2/2]

Path & LibBoard::Path::scale ( double  sx,
double  sy 
)

Apply a scaling factor to the path along each axis.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
The path itself, once scaled.
Examples
examples/holes.cpp.

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

Referenced by main(), scale(), LibBoard::Board::scale(), LibBoard::Group::scale(), LibBoard::Text::scale(), LibBoard::Board::scale(), LibBoard::Bezier::scale(), LibBoard::Group::scale(), LibBoard::Polyline::scale(), and LibBoard::Text::scale().

◆ scaleAll()

void LibBoard::Path::scaleAll ( double  s)

Scale all the points.

Parameters
sThe scaling factor.

References _points, and end().

Referenced by LibBoard::Bezier::scaleAll(), LibBoard::Polyline::scaleAll(), LibBoard::GouraudTriangle::scaleAll(), and LibBoard::Text::scaleAll().

◆ scaled() [1/2]

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

Return a scaled copy of the path.

Parameters
sThe scaling factor along both axis's.
Returns
The scaled copy of the path.

References Path().

◆ scaled() [2/2]

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

Return a scaled copy of the path.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
The scaled copy of the path.

References Path().

◆ setClockwise()

void LibBoard::Path::setClockwise ( )

Make the path clockwise.

References _points, and isCounterclockwise().

Referenced by getClockwise().

◆ setCounterclockwise()

void LibBoard::Path::setCounterclockwise ( )

Make the path counterclockwise.

References _points, and isClockwise().

Referenced by LibBoard::Polyline::flushSVG(), and getCounterclockwise().

◆ setOpenClosed()

void LibBoard::Path::setOpenClosed ( Path::OpenClosed  openClosed)
inline

Set the open/closed flag of the path.

Parameters
openClosedThe open/closed flag

References _openClosed, and openClosed().

◆ size()

std::size_t LibBoard::Path::size ( ) const
inline

◆ transformed()

Path LibBoard::Path::transformed ( const Transform transform) const

Compute the path obtained after a transform.

Parameters
transformA transform
Returns
The transformed path

References _openClosed, _points, LibBoard::Transform::map(), and push_back().

◆ translate()

Path & LibBoard::Path::translate ( double  dx,
double  dy 
)

◆ translated()

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

Return a translated copy of the path.

Parameters
dxThe shift along the x axis.
dyThe shift along the y axis.
Returns
A translated copy of the path.

References _points, and end().

Member Data Documentation

◆ _openClosed

OpenClosed LibBoard::Path::_openClosed
protected

◆ _points

std::vector<Point> LibBoard::Path::_points
protected

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