Helpers Class
Helper functions for building graphs. More...
| Header: | #include <QuickGraphLib> |
| Inherits: | QObject |
Static Public Members
| QRectF | boundingRect(QVariant points) |
| QRectF | clampedResizeRect(QPointF position, QPointF anchor, qreal minimumWidth, qreal minimumHeight, int xSign, int ySign) |
| int | displayDecimalPoints(qreal axisRange, QList<qreal> ticks) |
| qreal | distanceToSegment(QPointF point, QPointF segmentStart, QPointF segmentEnd) |
| QPicture | exportToPicture(QQuickItem *item) |
| bool | exportToPng(QQuickItem *item, QUrl path, int dpi = 96 * 2) |
| bool | exportToSvg(QQuickItem *item, QUrl path) |
| bool | isInsideEllipse(QPointF point, QPointF center, qreal radiusX, qreal radiusY) |
| bool | isInsidePolygon(QPointF point, QVariant points) |
| bool | isNearPolyline(QPointF point, QVariant points, qreal hitWidth, bool closed) |
| bool | isNearSegment(QPointF point, QPointF segmentStart, QPointF segmentEnd, qreal hitWidth) |
| QList<qreal> | linspace(qreal min, qreal max, int num) |
| QList<qreal> | logspace(qreal logmin, qreal logmax, int num, qreal base = 10) |
| QPolygonF | mapPoints(QVariant points, QMatrix4x4 dataTransform) |
| QRectF | normalizedRect(QRectF rect) |
| QList<int> | range(int min, int max, int step = 1) |
| QList<qreal> | tickLocator(qreal min, qreal max, int maxNum) |
Detailed Description
See also QuickGraphLib::Helpers.
Member Function Documentation
[static invokable] QRectF Helpers::boundingRect(QVariant points)
Returns the bounding rectangle of points.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QRectF Helpers::clampedResizeRect(QPointF position, QPointF anchor, qreal minimumWidth, qreal minimumHeight, int xSign, int ySign)
Returns a normalized rectangle between anchor and position. The position is clamped to preserve the non-negative minimumWidth and minimumHeight in the directions indicated by xSign and ySign.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] int Helpers::displayDecimalPoints(qreal axisRange, QList<qreal> ticks)
Return the best number of decimal points for displaying ticks on an axis. This function considers the axisRange, as well as the range and spacing of the ticks. The returned number of decimal places does not guarantee that the tick value displayed is not rounded.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] qreal Helpers::distanceToSegment(QPointF point, QPointF segmentStart, QPointF segmentEnd)
Returns the shortest distance from point to the line segment from segmentStart to segmentEnd.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QPicture Helpers::exportToPicture(QQuickItem *item)
Exports the graph in item to a QPicture.
Note: Only some QML elements are supported by this export method (e.g. Rectangle, PathPolyline). Other elements will be rendered incorrectly or not at all. See QPainter-based export for more information.
Note: Using this method, followed by saving to an image should give the same result as the other functions (ignoring some differences in the output that result in equivalent display). One exception is that exporting an ImageView as SVG will result in images rendering using the "optimiseSpeed" setting when they are not smooth. For reliable rendering across multiple programs, it is better to replace this with "pixelated". Helpers::exportToSvg does this correction automatically.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also Helpers::exportToPng, Helpers::exportToSvg, and Exporting graphs.
[static invokable] bool Helpers::exportToPng(QQuickItem *item, QUrl path, int dpi = 96 * 2)
Exports the graph in item to an PNG file at path with the resolution dpi. Returns a boolean indicating success.
Note: Only some QML elements are supported by this export method (e.g. Rectangle, PathPolyline). Other elements will be rendered incorrectly or not at all. See QPainter-based export for more information.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also Helpers::exportToSvg, Helpers::exportToPicture, and Exporting graphs.
[static invokable] bool Helpers::exportToSvg(QQuickItem *item, QUrl path)
Exports the graph in item to an SVG file at path. Returns a boolean indicating success.
Note: Only some QML elements are supported by this export method (e.g. Rectangle, PathPolyline). Other elements will be rendered incorrectly or not at all. See QPainter-based export for more information.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also Helpers::exportToPng, Helpers::exportToPicture, and Exporting graphs.
[static invokable] bool Helpers::isInsideEllipse(QPointF point, QPointF center, qreal radiusX, qreal radiusY)
Returns whether point is inside the ellipse centered on center with radii radiusX and radiusY.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] bool Helpers::isInsidePolygon(QPointF point, QVariant points)
Returns whether point is inside the polygon defined by points.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] bool Helpers::isNearPolyline(QPointF point, QVariant points, qreal hitWidth, bool closed)
Returns whether point is within half hitWidth of any segment in points. If closed is true, the final point is connected back to the first point.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] bool Helpers::isNearSegment(QPointF point, QPointF segmentStart, QPointF segmentEnd, qreal hitWidth)
Returns whether point is within half hitWidth of the segment from segmentStart to segmentEnd.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QList<qreal> Helpers::linspace(qreal min, qreal max, int num)
Returns a list of num values equally spaced from min and max (inclusive).
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QList<qreal> Helpers::logspace(qreal logmin, qreal logmax, int num, qreal base = 10)
Returns a list of num values equally spaced from base to the power of logmin and base to the power of logmax (inclusive).
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QPolygonF Helpers::mapPoints(QVariant points, QMatrix4x4 dataTransform)
Maps each point in points though the transform defined by dataTransform.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QRectF Helpers::normalizedRect(QRectF rect)
Returns rect with non-negative width and height.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QList<int> Helpers::range(int min, int max, int step = 1)
Returns a list of values from min to max (exclusive) with a gap of step between each one.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static invokable] QList<qreal> Helpers::tickLocator(qreal min, qreal max, int maxNum)
Returns a list of at most maxNum nice tick locations values equally spaced between min and max.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.