Board  0.9.5
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 { OpenPath, ClosedPath }
 
typedef std::vector< Point >::size_type size_type
 

Public Member Functions

 Path (const std::vector< Point > &points, OpenClosed openClosed)
 
 Path (std::initializer_list< Point > points)
 
 Path (OpenClosed openClosed)
 
void clear ()
 
bool isClosed () const
 
bool isOpen () const
 
bool empty () const
 
std::size_t size () const
 
void close ()
 
OpenClosed openClosed () const
 
void open ()
 
void setOpenClosed (OpenClosed openClosed)
 
Point center () const
 
Pathoperator<< (const Point &p)
 
Pathoperator<< (const std::vector< Point > &v)
 
Pathpop_back ()
 
Pathpush_back (const Point &p)
 
const Pointfront () const
 
const Pointback () const
 
Pointoperator[] (const std::size_t n)
 
const Pointoperator[] (const std::size_t n) const
 
Pathrotate (double angle, const Point &center)
 
PathrotateDeg (double angle, const Point &center)
 
Path rotated (double angle, const Point &center) const
 
Path rotatedDeg (double angle, const Point &center) const
 
Pathrotate (double angle)
 
PathrotateDeg (double angle)
 
Path rotated (double angle) const
 
Path rotatedDeg (double angle) const
 
Pathtranslate (double dx, double dy)
 
Path translated (double dx, double dy) const
 
PathmoveCenter (double x, double y)
 Translate the center to a given position. More...
 
PathmoveCenter (Point p)
 Translate the center to a given position. More...
 
Pathscale (double sx, double sy)
 
Pathscale (double s)
 
Path scaled (double sx, double sy) const
 
Path scaled (double s) const
 
void scaleAll (double s)
 
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
 
bool isClockwise () const
 Tell if the points of the path are ordered clockwise. More...
 
bool isCounterclockwise () const
 Tell if the points of the path are ordered counterclockwise. More...
 
void setClockwise ()
 Make the path clockwise.
 
void setCounterclockwise ()
 Make the path counterclockwise.
 
Path getClockwise () const
 Return a clockwise copy of the path. More...
 
Path getCounterclockwise () const
 Return a counterclockwise copy of the path. More...
 
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/stroke_path.cpp, and examples/traversal.cpp.

Member Function Documentation

◆ back()

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

The last point of the path.

Returns
The last point of the path.

Referenced by LibBoard::bezierControls().

◆ boundingBox()

Rect LibBoard::Path::boundingBox ( ) const

Compute the bounding box of the path.

Returns
The bounding box of the path.

Referenced by LibBoard::Group::boundingBox(), LibBoard::Text::boundingBox(), and center().

◆ center()

Point LibBoard::Path::center ( ) const

Center of the bounding box of the path.

Returns
The center of the bounding box of the path.

References boundingBox().

Referenced by LibBoard::Text::center(), moveCenter(), rotate(), rotated(), LibBoard::Group::scale(), LibBoard::Polyline::scale(), LibBoard::Board::scale(), and scale().

◆ front()

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

The first point of the path.

Returns
The first point of the path.

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

◆ 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 LibBoard::Point::x, and LibBoard::Point::y.

Referenced by isCounterclockwise(), and setCounterclockwise().

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

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

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

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

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

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

◆ pop_back()

Path & LibBoard::Path::pop_back ( )

Remove the last point of the path.

Returns
The path itself.

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

◆ push_back()

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

Add a point to the path.

Returns
The path itself.

◆ 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 center().

Referenced by LibBoard::Group::rotate(), LibBoard::Polyline::rotate(), LibBoard::Text::rotate(), LibBoard::Bezier::rotate(), LibBoard::Board::rotate(), rotate(), rotated(), rotatedDeg(), 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 rotate().

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

References center().

Referenced by 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 rotate().

◆ 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 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 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 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 center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.

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

◆ scaleAll()

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

Scale all the points.

Parameters
sThe scaling factor.

Referenced by LibBoard::Text::scaleAll(), LibBoard::Polyline::scaleAll(), and LibBoard::Bezier::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 scale().

◆ 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 scale().

◆ translate()

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

Translate the path.

Parameters
dxThe shift along the x axis.
dyThe shift along the y axis.
Returns
The path itself.

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

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

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