LibrePCB Developers Documentation
Path Class Referencefinal

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

#include <path.h>

+ Inheritance diagram for Path:
+ 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
 
QVector< Vertex > & getVertices () noexcept
 
const QVector< Vertex > & getVertices () const noexcept
 
Path toClosedPath () 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
 
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
 
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 close () noexcept
 
void serialize (SExpression &root) const override
 Serialize the object into an existing S-Expression node. More...
 
bool operator== (const Path &rhs) const noexcept
 
bool operator!= (const Path &rhs) const noexcept
 
Pathoperator= (const Path &rhs) noexcept
 
- Public Member Functions inherited from SerializableObject
 SerializableObject () noexcept
 
virtual ~SerializableObject () noexcept
 
SExpression serializeToDomElement (const QString &name) const
 Serialize the object to a new S-Expression node. More...
 

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 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) noexcept
 
static Path octagon (const PositiveLength &width, const PositiveLength &height) 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. More...
 
- Static Public Member Functions inherited from SerializableObject
template<typename T >
static void serializeObjectContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainerUuidSorted (SExpression &root, const T &container, const QString &itemName)
 

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
+ Here is the call graph for this function:

◆ Path() [4/4]

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

◆ ~Path()

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

Member Function Documentation

◆ isClosed()

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

◆ 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
+ Here is the call 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:

◆ 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 call graph for this function:
+ 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:

◆ rotate()

Path & rotate ( const Angle angle,
const Point center = Point(0, 0) 
)
noexcept
+ Here is the call graph for this function:
+ 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 call graph for this function:
+ 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:
+ Here is the caller graph for this function:

◆ addVertex() [1/2]

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

◆ addVertex() [2/2]

void addVertex ( const Point pos,
const Angle angle = Angle::deg0() 
)
noexcept
+ Here is the call graph for this function:

◆ insertVertex() [1/2]

void insertVertex ( int  index,
const Vertex vertex 
)
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertVertex() [2/2]

void insertVertex ( int  index,
const Point pos,
const Angle angle = Angle::deg0() 
)
noexcept
+ Here is the call graph for this function:

◆ close()

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

◆ serialize()

void serialize ( SExpression root) const
overridevirtual

Serialize the object into an existing S-Expression node.

This method inserts/appends all attributes and childs of the object to an existing S-Expression node. The content which already exists in the given S-Expression node will not be removed.

Note
The generated S-Expression node has always the format of the application's major version (it's not possible to generate DOMs of older versions).
Parameters
rootThe target DOM root node
Exceptions
ExceptionThis method throws an exception if an error occurs.

Implements SerializableObject.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==()

bool operator== ( const Path rhs) const
inlinenoexcept

◆ operator!=()

bool operator!= ( const Path rhs) const
inlinenoexcept
+ Here is the call graph for this function:

◆ operator=()

Path & operator= ( const Path rhs)
noexcept
+ Here is the caller graph for this function:

◆ line()

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

◆ circle()

Path circle ( const PositiveLength diameter)
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 
)
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 
)
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:
+ Here is the caller 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: