LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Toolbox Class Referencefinal

The Toolbox class provides some useful general purpose methods. More...

#include <toolbox.h>

+ Collaboration diagram for Toolbox:

Public Member Functions

 Toolbox ()=delete
 
 Toolbox (const Toolbox &other)=delete
 
 ~Toolbox ()=delete
 
Toolboxoperator= (const Toolbox &rhs)=delete
 

Static Public Member Functions

template<typename T >
static QList< T > sortedQSet (const QSet< T > &set) noexcept
 
static QRectF boundingRectFromRadius (qreal radius) noexcept
 
static QRectF boundingRectFromRadius (qreal rx, qreal ry) noexcept
 
static QRectF adjustedBoundingRect (const QRectF &rect, qreal offset) noexcept
 
static QPainterPath shapeFromPath (const QPainterPath &path, const QPen &pen, const QBrush &brush, const UnsignedLength &minWidth=UnsignedLength(0)) noexcept
 
static Length arcRadius (const Point &p1, const Point &p2, const Angle &a) noexcept
 
static Point arcCenter (const Point &p1, const Point &p2, const Angle &a) noexcept
 
static Point nearestPointOnLine (const Point &p, const Point &l1, const Point &l2) noexcept
 Calculate the point on a given line which is nearest to a given point. More...
 
static Length shortestDistanceBetweenPointAndLine (const Point &p, const Point &l1, const Point &l2, Point *nearest=nullptr) noexcept
 Calculate the shortest distance between a given point and a given line. More...
 
static QVariant stringOrNumberToQVariant (const QString &string) noexcept
 Convert a numeric or non-numeric string to the corresponding QVariant. More...
 
static QString cleanUserInputString (const QString &input, const QRegularExpression &removeRegex, bool trim=true, bool toLower=false, bool toUpper=false, const QString &spaceReplacement=" ", int maxLength=-1) noexcept
 Clean a user input string. More...
 
template<typename T >
static QString decimalFixedPointToString (T value, qint32 pointPos) noexcept
 Convert a fixed point decimal number from an integer to a QString. More...
 
template<typename T >
static T decimalFixedPointFromString (const QString &str, qint32 pointPos)
 Convert a fixed point decimal number from a QString to an integer. More...
 

Detailed Description

The Toolbox class provides some useful general purpose methods.

Author
ubruhin
Date
2016-10-30

Constructor & Destructor Documentation

Toolbox ( )
delete
Toolbox ( const Toolbox other)
delete
~Toolbox ( )
delete

Member Function Documentation

Toolbox& operator= ( const Toolbox rhs)
delete
static QList<T> sortedQSet ( const QSet< T > &  set)
inlinestaticnoexcept

+ Here is the caller graph for this function:

static QRectF boundingRectFromRadius ( qreal  radius)
inlinestaticnoexcept

+ Here is the caller graph for this function:

static QRectF boundingRectFromRadius ( qreal  rx,
qreal  ry 
)
inlinestaticnoexcept
static QRectF adjustedBoundingRect ( const QRectF &  rect,
qreal  offset 
)
inlinestaticnoexcept

+ Here is the caller graph for this function:

QPainterPath shapeFromPath ( const QPainterPath &  path,
const QPen &  pen,
const QBrush &  brush,
const UnsignedLength minWidth = UnsignedLength(0) 
)
staticnoexcept

+ Here is the caller graph for this function:

Length arcRadius ( const Point p1,
const Point p2,
const Angle a 
)
staticnoexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Point arcCenter ( const Point p1,
const Point p2,
const Angle a 
)
staticnoexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Point nearestPointOnLine ( const Point p,
const Point l1,
const Point l2 
)
staticnoexcept

Calculate the point on a given line which is nearest to a given point.

Parameters
pAn arbitrary point
l1Start point of the line
l2End point of the line
Returns
Nearest point on the given line (either l1, l2, or a point between them)
Warning
This method works with floating point numbers and thus the result may not be perfectly precise.

+ Here is the call graph for this function:

Length shortestDistanceBetweenPointAndLine ( const Point p,
const Point l1,
const Point l2,
Point nearest = nullptr 
)
staticnoexcept

Calculate the shortest distance between a given point and a given line.

Parameters
pAn arbitrary point
l1Start point of the line
l2End point of the line
nearestIf not nullptr, the nearest point is returned here
Returns
Shortest distance between the given point and the given line (>=0)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QVariant stringOrNumberToQVariant ( const QString &  string)
staticnoexcept

Convert a numeric or non-numeric string to the corresponding QVariant.

Parameters
stringThe string to be converted
Returns
A QVariant with either a QVariant::Int or a QVariant::String

+ Here is the caller graph for this function:

QString cleanUserInputString ( const QString &  input,
const QRegularExpression &  removeRegex,
bool  trim = true,
bool  toLower = false,
bool  toUpper = false,
const QString &  spaceReplacement = " ",
int  maxLength = -1 
)
staticnoexcept

Clean a user input string.

Parameters
inputThe string typed by the user
removeRegexRegex for all patterns to remove from the string
trimIf true, leading and trailing spaces are removed
toLowerIf true, all characters are converted to lowercase
toUpperIf true, all characters are converted to uppercase
spaceReplacementAll spaces are replaced by this string
maxLengthIf >= 0, the string is truncated to this length
Returns
The cleaned string (may be empty)

+ Here is the caller graph for this function:

static QString decimalFixedPointToString ( value,
qint32  pointPos 
)
inlinestaticnoexcept

Convert a fixed point decimal number from an integer to a QString.

Parameters
valueValue to convert
pointPosNumber of fixed point decimal positions
static T decimalFixedPointFromString ( const QString &  str,
qint32  pointPos 
)
inlinestatic

Convert a fixed point decimal number from a QString to an integer.

Parameters
strA QString that represents the number
pointPosNumber of decimal positions. If the number has more decimal digits, this function will throw

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