LibrePCB Developers Documentation
Loading...
Searching...
No Matches
Path Class Referencefinal

The Path class represents a list of vertices connected by straight lines or circular arc segments. More...

#include <path.h>

+ Collaboration diagram for Path:

Public Member Functions

 Path () noexcept
 
 Path (const Path &other) noexcept
 
 Path (const QVector< Vertex > &vertices) noexcept
 
 Path (const SExpression &node)
 
 ~Path () noexcept
 
bool isClosed () const noexcept
 
bool isCurved () const noexcept
 
bool isZeroLength () const noexcept
 
QVector< Vertex > & getVertices () noexcept
 
const QVector< Vertex > & getVertices () const noexcept
 
UnsignedLength getTotalStraightLength () const noexcept
 
qreal calcAreaOfStraightSegments () const noexcept
 
Point calcNearestPointBetweenVertices (const Point &p) const noexcept
 
Path cleaned () const noexcept
 
Path toClosedPath () const noexcept
 
Path toOpenPath () const noexcept
 
QVector< PathtoOutlineStrokes (const PositiveLength &width) const noexcept
 
const QPainterPath & toQPainterPathPx () const noexcept
 
Pathtranslate (const Point &offset) noexcept
 
Path translated (const Point &offset) const noexcept
 
PathmapToGrid (const PositiveLength &gridInterval) noexcept
 
Path mappedToGrid (const PositiveLength &gridInterval) const noexcept
 
Pathrotate (const Angle &angle, const Point &center=Point(0, 0)) noexcept
 
Path rotated (const Angle &angle, const Point &center=Point(0, 0)) const noexcept
 
Pathmirror (Qt::Orientation orientation, const Point &center=Point(0, 0)) noexcept
 
Path mirrored (Qt::Orientation orientation, const Point &center=Point(0, 0)) const noexcept
 
Pathreverse () noexcept
 
Path reversed () const noexcept
 
PathflattenArcs (const PositiveLength &maxTolerance) noexcept
 
Path flattenedArcs (const PositiveLength &maxTolerance) const noexcept
 
void addVertex (const Vertex &vertex) noexcept
 
void addVertex (const Point &pos, const Angle &angle=Angle::deg0()) noexcept
 
void insertVertex (int index, const Vertex &vertex) noexcept
 
void insertVertex (int index, const Point &pos, const Angle &angle=Angle::deg0()) noexcept
 
bool clean () noexcept
 
bool close () noexcept
 
bool open () noexcept
 
void serialize (SExpression &root) const
 Serialize into librepcb::SExpression node.
 
Pathoperator= (const Path &rhs) noexcept
 
bool operator== (const Path &rhs) const noexcept
 
bool operator!= (const Path &rhs) const noexcept
 
bool operator< (const Path &rhs) const noexcept
 The "<" operator to compare two librepcb::Path objects.
 

Static Public Member Functions

static Path line (const Point &p1, const Point &p2, const Angle &angle=Angle::deg0()) noexcept
 
static Path circle (const PositiveLength &diameter) noexcept
 
static Path donut (const PositiveLength &outerDiameter, const PositiveLength &innerDiameter) noexcept
 
static Path obround (const PositiveLength &width, const PositiveLength &height) noexcept
 
static Path obround (const Point &p1, const Point &p2, const PositiveLength &width) noexcept
 
static Path arcObround (const Point &p1, const Point &p2, const Angle &angle, const PositiveLength &width) noexcept
 
static Path rect (const Point &p1, const Point &p2) noexcept
 
static Path centeredRect (const PositiveLength &width, const PositiveLength &height, const UnsignedLength &cornerRadius=UnsignedLength(0)) noexcept
 
static Path chamferedRect (const PositiveLength &width, const PositiveLength &height, const UnsignedLength &chamferSize, bool topLeft, bool topRight, bool bottomLeft, bool bottomRight) noexcept
 
static Path trapezoid (const PositiveLength &width, const PositiveLength &height, const Length &dw, const Length dh) noexcept
 
static Path octagon (const PositiveLength &width, const PositiveLength &height, const UnsignedLength &cornerRadius=UnsignedLength(0)) noexcept
 
static Path flatArc (const Point &p1, const Point &p2, const Angle &angle, const PositiveLength &maxTolerance) noexcept
 
static QPainterPath toQPainterPathPx (const QVector< Path > &paths, bool area) noexcept
 Convert multiple librepcb::Path objects to a QPainterPath.
 

Private Member Functions

void invalidatePainterPath () const noexcept
 

Private Attributes

QVector< VertexmVertices
 
QPainterPath mPainterPathPx
 

Detailed Description

The Path class represents a list of vertices connected by straight lines or circular arc segments.

This class is similar to a polygon or polyline, but it doesn't have properties like width or layer. It's only a list of coordinates which are connected together by straight lines or circular arc segments.

A path may be closed (first point == last point) or open (first point != last point).

For a valid path, minimum two vertices are required. Paths with less than two vertices are useless and thus considered as invalid.

Constructor & Destructor Documentation

◆ Path() [1/4]

Path ( )
inlinenoexcept
+ Here is the caller graph for this function:

◆ Path() [2/4]

Path ( const Path other)
noexcept

◆ Path() [3/4]

Path ( const QVector< Vertex > &  vertices)
inlineexplicitnoexcept

◆ Path() [4/4]

Path ( const SExpression node)
explicit
+ Here is the call graph for this function:

◆ ~Path()

~Path ( )
inlinenoexcept

Member Function Documentation

◆ isClosed()

bool isClosed ( ) const
noexcept
+ Here is the caller graph for this function:

◆ isCurved()

bool isCurved ( ) const
noexcept
+ Here is the call graph for this function:

◆ isZeroLength()

bool isZeroLength ( ) const
noexcept

◆ getVertices() [1/2]

QVector< Vertex > & getVertices ( )
inlinenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVertices() [2/2]

const QVector< Vertex > & getVertices ( ) const
inlinenoexcept

◆ getTotalStraightLength()

UnsignedLength getTotalStraightLength ( ) const
noexcept
+ Here is the caller graph for this function:

◆ calcAreaOfStraightSegments()

qreal calcAreaOfStraightSegments ( ) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calcNearestPointBetweenVertices()

Point calcNearestPointBetweenVertices ( const Point p) const
noexcept
+ Here is the call graph for this function:

◆ cleaned()

Path cleaned ( ) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toClosedPath()

Path toClosedPath ( ) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toOpenPath()

Path toOpenPath ( ) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toOutlineStrokes()

QVector< Path > toOutlineStrokes ( const PositiveLength width) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toQPainterPathPx() [1/2]

const QPainterPath & toQPainterPathPx ( ) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translate()

Path & translate ( const Point offset)
noexcept
+ Here is the caller graph for this function:

◆ translated()

Path translated ( const Point offset) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapToGrid()

Path & mapToGrid ( const PositiveLength gridInterval)
noexcept
+ Here is the caller graph for this function:

◆ mappedToGrid()

Path mappedToGrid ( const PositiveLength gridInterval) const
noexcept
+ Here is the call graph for this function:

◆ rotate()

Path & rotate ( const Angle angle,
const Point center = Point(0, 0) 
)
noexcept
+ Here is the caller graph for this function:

◆ rotated()

Path rotated ( const Angle angle,
const Point center = Point(0, 0) 
) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mirror()

Path & mirror ( Qt::Orientation  orientation,
const Point center = Point(0, 0) 
)
noexcept
+ Here is the caller graph for this function:

◆ mirrored()

Path mirrored ( Qt::Orientation  orientation,
const Point center = Point(0, 0) 
) const
noexcept
+ Here is the call graph for this function:

◆ reverse()

Path & reverse ( )
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reversed()

Path reversed ( ) const
noexcept
+ Here is the call graph for this function:

◆ flattenArcs()

Path & flattenArcs ( const PositiveLength maxTolerance)
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flattenedArcs()

Path flattenedArcs ( const PositiveLength maxTolerance) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addVertex() [1/2]

void addVertex ( const Vertex vertex)
noexcept
+ Here is the caller graph for this function:

◆ addVertex() [2/2]

void addVertex ( const Point pos,
const Angle angle = Angle::deg0() 
)
noexcept

◆ insertVertex() [1/2]

void insertVertex ( int  index,
const Vertex vertex 
)
noexcept

◆ insertVertex() [2/2]

void insertVertex ( int  index,
const Point pos,
const Angle angle = Angle::deg0() 
)
noexcept

◆ clean()

bool clean ( )
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ close()

bool close ( )
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ open()

bool open ( )
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void serialize ( SExpression root) const

Serialize into librepcb::SExpression node.

Parameters
rootRoot node to serialize into.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

Path & operator= ( const Path rhs)
noexcept

◆ operator==()

bool operator== ( const Path rhs) const
inlinenoexcept

◆ operator!=()

bool operator!= ( const Path rhs) const
inlinenoexcept

◆ operator<()

bool operator< ( const Path rhs) const
noexcept

The "<" operator to compare two librepcb::Path objects.

Useful for sorting path lists/sets (e.g. to for canonical order in files), or to store them in a QMap.

Parameters
rhsThe right hand side object.
Returns
true if this path is smaller, else false

◆ line()

Path line ( const Point p1,
const Point p2,
const Angle angle = Angle::deg0() 
)
staticnoexcept
+ Here is the caller graph for this function:

◆ circle()

Path circle ( const PositiveLength diameter)
staticnoexcept
+ Here is the caller graph for this function:

◆ donut()

Path donut ( const PositiveLength outerDiameter,
const PositiveLength innerDiameter 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ obround() [1/2]

Path obround ( const PositiveLength width,
const PositiveLength height 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ obround() [2/2]

Path obround ( const Point p1,
const Point p2,
const PositiveLength width 
)
staticnoexcept
+ Here is the call graph for this function:

◆ arcObround()

Path arcObround ( const Point p1,
const Point p2,
const Angle angle,
const PositiveLength width 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rect()

Path rect ( const Point p1,
const Point p2 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ centeredRect()

Path centeredRect ( const PositiveLength width,
const PositiveLength height,
const UnsignedLength cornerRadius = UnsignedLength(0) 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ chamferedRect()

Path chamferedRect ( const PositiveLength width,
const PositiveLength height,
const UnsignedLength chamferSize,
bool  topLeft,
bool  topRight,
bool  bottomLeft,
bool  bottomRight 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trapezoid()

Path trapezoid ( const PositiveLength width,
const PositiveLength height,
const Length dw,
const Length  dh 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ octagon()

Path octagon ( const PositiveLength width,
const PositiveLength height,
const UnsignedLength cornerRadius = UnsignedLength(0) 
)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flatArc()

Path flatArc ( const Point p1,
const Point p2,
const Angle angle,
const PositiveLength maxTolerance 
)
staticnoexcept
+ Here is the call graph for this function:

◆ toQPainterPathPx() [2/2]

QPainterPath toQPainterPathPx ( const QVector< Path > &  paths,
bool  area 
)
staticnoexcept

Convert multiple librepcb::Path objects to a QPainterPath.

The paths are united, so you get the union of all the passed paths.

Parameters
pathsThe paths to convert.
areaWhether the passed paths should be interpreted as areas (true) or strokes (false).
Returns
The QPainterPath with the united paths.
+ Here is the call graph for this function:

◆ invalidatePainterPath()

void invalidatePainterPath ( ) const
inlineprivatenoexcept
+ Here is the caller graph for this function:

Member Data Documentation

◆ mVertices

QVector<Vertex> mVertices
private

◆ mPainterPathPx

QPainterPath mPainterPathPx
mutableprivate

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