LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 
const QPainterPath & toQPainterPathPx (bool close=false) 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 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) noexcept
 
- 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 ( )
inlinenoexcept
Path ( const Path other)
noexcept
Path ( const QVector< Vertex > &  vertices)
inlineexplicitnoexcept
Path ( const SExpression node)
explicit

+ Here is the call graph for this function:

~Path ( )
inlinenoexcept

Member Function Documentation

bool isClosed ( ) const
noexcept

+ Here is the caller graph for this function:

QVector<Vertex>& getVertices ( )
inlinenoexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const QVector<Vertex>& getVertices ( ) const
inlinenoexcept
const QPainterPath & toQPainterPathPx ( bool  close = false) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Path & translate ( const Point offset)
noexcept

+ Here is the caller graph for this function:

Path translated ( const Point offset) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Path & rotate ( const Angle angle,
const Point center = Point(0, 0) 
)
noexcept

+ Here is the caller graph for this function:

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:

Path & mirror ( Qt::Orientation  orientation,
const Point center = Point(0, 0) 
)
noexcept

+ Here is the caller graph for this function:

Path mirrored ( Qt::Orientation  orientation,
const Point center = Point(0, 0) 
) const
noexcept

+ Here is the call graph for this function:

void addVertex ( const Vertex vertex)
noexcept

+ Here is the caller graph for this function:

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:

bool operator== ( const Path rhs) const
inlinenoexcept
bool operator!= ( const Path rhs) const
inlinenoexcept
Path & operator= ( const Path rhs)
noexcept
Path line ( const Point p1,
const Point p2,
const Angle angle = Angle::deg0() 
)
staticnoexcept

+ Here is the caller graph for this function:

Path circle ( const PositiveLength diameter)
staticnoexcept

+ Here is the caller graph for this function:

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:

Path obround ( const Point p1,
const Point p2,
const PositiveLength width 
)
staticnoexcept

+ Here is the call graph for this function:

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:

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:

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:

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:

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

+ Here is the call graph for this function:

void invalidatePainterPath ( ) const
inlineprivatenoexcept

+ Here is the caller graph for this function:

Member Data Documentation

QVector<Vertex> mVertices
private
QPainterPath mPainterPathPx
mutableprivate

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