Board 0.9.6
|
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. | |
Path & | operator<< (const Point &p) |
Add a point at the end of the path. | |
Path & | operator<< (const std::vector< Point > &v) |
Add a vector of points at the end of the path. | |
Path & | pop_back () |
Remove the last point of the path. | |
Path & | push_back (const Point &p) |
Add a point to the path. | |
const Point & | front () const |
The first point of the path. | |
const Point & | back () const |
The last point of the path. | |
Point & | operator[] (const std::size_t n) |
Get the n-th point of the path. | |
const Point & | operator[] (const std::size_t n) const |
Get the n-th point of the path (const version). | |
Path & | rotate (double angle, const Point ¢er) |
Rotate the path by a given angle and according to a rotation center. | |
Path & | rotateDeg (double angle, const Point ¢er) |
Rotate the path by a given angle, in degrees, and according to a rotation center. | |
Path | rotated (double angle, const Point ¢er) const |
Return a rotated copy of the path, thanks to an angle and a rotation center. | |
Path | rotatedDeg (double angle, const Point ¢er) const |
Return a rotated copy of the path, thanks to an angle and a rotation center. | |
Path & | rotate (double angle) |
Rotate the path by a given angle around the center of its bounding box. | |
Path & | rotateDeg (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. | |
Path & | translate (double dx, double dy) |
Translate the path. | |
Path | translated (double dx, double dy) const |
Return a translated copy of the path. | |
Path & | moveCenter (double x, double y) |
Translate the center to a given position. | |
Path & | moveCenter (Point p) |
Translate the center to a given position. | |
Path & | scale (double sx, double sy) |
Apply a scaling factor to the path along each axis. | |
Path & | scale (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 |
A path, according to Postscript and SVG definition.
The path structure.
typedef std::vector<Point>::size_type LibBoard::Path::size_type |
|
inline |
Referenced by rotated(), rotatedDeg(), scaled(), and scaled().
|
inline |
Construct a path from a vector of points.
points | A vector of points |
openClosed | The open/closed status of the path |
LibBoard::Path::Path | ( | std::initializer_list< Point > | points | ) |
Construct an open path from a list of points.
points | A list of points |
References _openClosed, _points, Open, and points().
|
inlineexplicit |
Construct an open or closed empty path.
openClosed | The open/closed flag |
|
inline |
The last point of the path.
References _points.
Referenced by LibBoard::bezierControls(), LibBoard::Bezier::operator+=(), LibBoard::Bezier::pathThroughLocalExtremums(), and LibBoard::Bezier::smoothedPolyline().
|
inline |
References _points.
Referenced by LibBoard::bezierControls(), LibBoard::RoughVisitor::map(), LibBoard::mix(), and LibBoard::Bezier::scale().
Rect LibBoard::Path::boundingBox | ( | ) | const |
Compute the bounding box of the path.
References _points, LibBoard::Rect::growToContain(), and LibBoard::Tools::warning.
Referenced by LibBoard::Bezier::boundingBox(), LibBoard::Group::boundingBox(), LibBoard::Line::boundingBox(), LibBoard::Polyline::boundingBox(), LibBoard::Text::boundingBox(), center(), LibBoard::Tools::pathBoundingBox(), LibBoard::Board::saveEPS(), LibBoard::Board::saveSVG(), and LibBoard::Board::saveTikZ().
Point LibBoard::Path::center | ( | ) | const |
Center of the bounding box of the path.
References boundingBox(), and LibBoard::Rect::center().
Referenced by LibBoard::Text::center(), LibBoard::hachures(), moveCenter(), moveCenter(), rotate(), rotate(), rotated(), rotated(), rotatedDeg(), rotatedDeg(), rotateDeg(), rotateDeg(), LibBoard::Board::scale(), LibBoard::Group::scale(), scale(), LibBoard::Board::scale(), LibBoard::Group::scale(), and LibBoard::Polyline::scale().
|
inline |
Remove all points of the path.
References _points.
Referenced by main(), LibBoard::Bezier::scale(), LibBoard::Board::setClippingPath(), LibBoard::Group::setClippingPath(), LibBoard::Board::setClippingRectangle(), and LibBoard::Group::setClippingRectangle().
|
inline |
Close the path.
References _openClosed, and Closed.
Referenced by LibBoard::Polyline::flushSVG(), hachures(), hachuresBis(), hachuresTer(), main(), polygons(), LibBoard::Board::setClippingPath(), LibBoard::Group::setClippingPath(), LibBoard::Text::Text(), LibBoard::Text::Text(), LibBoard::Text::Text(), and LibBoard::Text::Text().
|
inline |
Check if the path is empty (i.e. has no points)
References _points.
Referenced by LibBoard::Polyline::flushFIG(), LibBoard::Bezier::flushPostscript(), LibBoard::Polyline::flushPostscript(), LibBoard::Bezier::flushSVG(), LibBoard::Polyline::flushSVG(), and LibBoard::Polyline::flushTikZ().
|
inline |
References _points.
Referenced by flushFIG(), flushPostscript(), flushSVGCommands(), flushSVGPoints(), flushTikZPoints(), isClockwise(), LibBoard::RoughVisitor::map(), LibBoard::mix(), rotate(), rotated(), scaleAll(), translate(), and translated().
std::ostream & LibBoard::Path::flush | ( | std::ostream & | out | ) | const |
References _points.
Referenced by operator<<().
void LibBoard::Path::flushFIG | ( | std::ostream & | stream, |
const TransformFIG & | transform | ||
) | const |
References _points, end(), isClosed(), LibBoard::Transform::mapX(), and LibBoard::TransformFIG::mapY().
Referenced by LibBoard::Polyline::flushFIG().
void LibBoard::Path::flushPostscript | ( | std::ostream & | stream, |
const TransformEPS & | transform | ||
) | const |
void LibBoard::Path::flushSVGCommands | ( | std::ostream & | stream, |
const TransformSVG & | transform | ||
) | const |
References _points, end(), isClosed(), LibBoard::Transform::mapX(), and LibBoard::TransformSVG::mapY().
Referenced by LibBoard::Group::flushSVG(), LibBoard::Polyline::flushSVG(), and LibBoard::Board::saveSVG().
void LibBoard::Path::flushSVGPoints | ( | std::ostream & | stream, |
const TransformSVG & | transform | ||
) | const |
References _points, end(), LibBoard::Transform::mapX(), and LibBoard::TransformSVG::mapY().
Referenced by LibBoard::Polyline::flushSVG().
void LibBoard::Path::flushTikZPoints | ( | std::ostream & | stream, |
const TransformTikZ & | transform | ||
) | const |
References _points, end(), LibBoard::Transform::mapX(), and LibBoard::TransformSVG::mapY().
Referenced by LibBoard::Polyline::flushTikZ(), and LibBoard::Board::saveTikZ().
|
inline |
The first point of the path.
References _points.
Referenced by LibBoard::Bezier::operator+=().
Path LibBoard::Path::getClockwise | ( | ) | const |
Return a clockwise copy of the path.
References setClockwise().
Referenced by LibBoard::Polyline::flushPostscript(), and LibBoard::Polyline::flushSVG().
Path LibBoard::Path::getCounterclockwise | ( | ) | const |
Return a counterclockwise copy of the path.
References setCounterclockwise().
bool LibBoard::Path::isClockwise | ( | ) | const |
Tell if the points of the path are ordered clockwise.
References _points, end(), LibBoard::Point::x, and LibBoard::Point::y.
Referenced by isCounterclockwise(), and setCounterclockwise().
|
inline |
Is the path closed?
References _openClosed, and Closed.
Referenced by divided(), flushFIG(), LibBoard::Polyline::flushFIG(), flushPostscript(), LibBoard::Polyline::flushSVG(), flushSVGCommands(), LibBoard::Polyline::flushTikZ(), LibBoard::RoughVisitor::map(), LibBoard::Tools::pathBoundaryPoints(), LibBoard::Bezier::smoothedPolyline(), and strikeOut().
bool LibBoard::Path::isCounterclockwise | ( | ) | const |
Tell if the points of the path are ordered counterclockwise.
References isClockwise().
Referenced by setClockwise().
|
inline |
Is the path open?
References _openClosed, and Open.
Path & LibBoard::Path::moveCenter | ( | double | x, |
double | y | ||
) |
Translate the center to a given position.
x | |
y |
References center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.
Referenced by LibBoard::Ellipse::sampledPath(), and LibBoard::Polyline::scale().
Translate the center to a given position.
p |
References center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.
|
inline |
|
inline |
The open/closed status of the path.
References _openClosed.
Referenced by LibBoard::mix(), and setOpenClosed().
Add a point at the end of the path.
p | A point. |
References _points.
Add a vector of points at the end of the path.
v | A vector of points. |
References _points.
|
inline |
Get the n-th point of the path.
n | Index of a point in the path. |
References _points.
|
inline |
Get the n-th point of the path (const version).
n | Index of a point in the path. |
References _points.
const std::vector< Point > & LibBoard::Path::points | ( | ) | const |
References _points.
Referenced by LibBoard::bezierControls(), LibBoard::Bezier::boundingBox(), LibBoard::Bezier::discretizedPath(), LibBoard::Bezier::flushPostscript(), LibBoard::Bezier::flushSVG(), main(), LibBoard::RoughVisitor::map(), LibBoard::RoughVisitor::map(), LibBoard::RoughVisitor::map(), mustache(), LibBoard::Bezier::operator+=(), Path(), LibBoard::Tools::pathBoundaryPoints(), LibBoard::Bezier::pathThroughLocalExtremums(), LibBoard::Bezier::scale(), and LibBoard::Bezier::smoothedPolyline().
Path & LibBoard::Path::pop_back | ( | ) |
Remove the last point of the path.
References _points.
Referenced by LibBoard::Ellipse::sampledPath(), LibBoard::Board::setClippingPath(), and LibBoard::Group::setClippingPath().
Add a point to the path.
References _points.
Referenced by LibBoard::mix(), LibBoard::Bezier::operator+=(), LibBoard::Ellipse::sampledPath(), LibBoard::Bezier::smoothedPolyline(), LibBoard::Bezier::smoothedPolyline(), and transformed().
Path & LibBoard::Path::rotate | ( | double | angle | ) |
Rotate the path by a given angle and according to a rotation center.
angle | The rotation angle (in radians). |
center | The rotation center. |
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().
Path LibBoard::Path::rotated | ( | double | angle | ) | const |
Return a rotated copy of the path, thanks to an angle and a rotation center.
angle | The rotation angle (in radians). |
center | The rotation center. |
References _points, center(), and end().
Referenced by LibBoard::hachures(), main(), and rotatedDeg().
Path LibBoard::Path::rotatedDeg | ( | double | angle | ) | const |
Path & LibBoard::Path::rotateDeg | ( | double | angle | ) |
Path & LibBoard::Path::scale | ( | double | s | ) |
Apply a scaling factor to the path.
s | The scaling factor. |
References scale().
Path & LibBoard::Path::scale | ( | double | sx, |
double | sy | ||
) |
Apply a scaling factor to the path along each axis.
sx | The scaling factor along the x axis. |
sy | The scaling factor along the y axis. |
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().
void LibBoard::Path::scaleAll | ( | double | s | ) |
Scale all the points.
s | The scaling factor. |
References _points, and end().
Referenced by LibBoard::Bezier::scaleAll(), LibBoard::Polyline::scaleAll(), LibBoard::GouraudTriangle::scaleAll(), and LibBoard::Text::scaleAll().
Path LibBoard::Path::scaled | ( | double | s | ) | const |
Return a scaled copy of the path.
s | The scaling factor along both axis's. |
References Path().
Path LibBoard::Path::scaled | ( | double | sx, |
double | sy | ||
) | const |
Return a scaled copy of the path.
sx | The scaling factor along the x axis. |
sy | The scaling factor along the y axis. |
References Path().
void LibBoard::Path::setClockwise | ( | ) |
Make the path clockwise.
References _points, and isCounterclockwise().
Referenced by getClockwise().
void LibBoard::Path::setCounterclockwise | ( | ) |
Make the path counterclockwise.
References _points, and isClockwise().
Referenced by LibBoard::Polyline::flushSVG(), and getCounterclockwise().
|
inline |
Set the open/closed flag of the path.
openClosed | The open/closed flag |
References _openClosed, and openClosed().
|
inline |
The number of points in the path.
References _points.
Referenced by LibBoard::Group::boundingBox(), LibBoard::Bezier::eval(), LibBoard::Polyline::flushFIG(), LibBoard::Bezier::flushPostscript(), LibBoard::Group::flushPostscript(), LibBoard::Bezier::flushSVG(), LibBoard::Group::flushSVG(), LibBoard::Polyline::flushSVG(), LibBoard::hachures(), interpolate(), LibBoard::RoughVisitor::map(), LibBoard::RoughVisitor::map(), LibBoard::mix(), LibBoard::Board::saveEPS(), LibBoard::Board::saveSVG(), LibBoard::Board::saveTikZ(), LibBoard::Board::scale(), LibBoard::Board::scale(), LibBoard::Board::setClippingPath(), LibBoard::Group::setClippingPath(), LibBoard::Bezier::smoothedPolyline(), LibBoard::Bezier::smoothedPolyline(), strikeOut(), and LibBoard::Polyline::vertexCount().
Compute the path obtained after a transform.
transform | A transform |
References _openClosed, _points, LibBoard::Transform::map(), and push_back().
Path & LibBoard::Path::translate | ( | double | dx, |
double | dy | ||
) |
Translate the path.
dx | The shift along the x axis. |
dy | The shift along the y axis. |
References _points, and end().
Referenced by moveCenter(), moveCenter(), LibBoard::Board::scale(), LibBoard::Group::scale(), scale(), LibBoard::Board::scale(), LibBoard::Group::scale(), LibBoard::Board::translate(), LibBoard::Bezier::translate(), LibBoard::Group::translate(), LibBoard::Polyline::translate(), and LibBoard::Text::translate().
Path LibBoard::Path::translated | ( | double | dx, |
double | dy | ||
) | const |
|
protected |
Referenced by close(), isClosed(), isOpen(), open(), openClosed(), Path(), setOpenClosed(), and transformed().
|
protected |
Referenced by back(), begin(), boundingBox(), cbegin(), cend(), clear(), empty(), end(), flush(), flushFIG(), flushPostscript(), flushSVGCommands(), flushSVGPoints(), flushTikZPoints(), front(), isClockwise(), operator<<(), operator<<(), operator[](), operator[](), Path(), points(), pop_back(), push_back(), rotate(), rotated(), scale(), scaleAll(), setClockwise(), setCounterclockwise(), size(), transformed(), translate(), and translated().