Helpers QML Type

Helper functions for building graphs. More...

Import Statement: import QuickGraphLib

Methods

Detailed Description

Method Documentation

rect boundingRect(var points)

Returns the bounding rectangle of points.


rect clampedResizeRect(point position, point anchor, real minimumWidth, real 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.


real distanceToSegment(point point, point segmentStart, point segmentEnd)

Returns the shortest distance from point to the line segment from segmentStart to segmentEnd.


QPicture exportToPicture(Item obj)

Exports the graph in obj 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.

See also Helpers::exportToPng, Helpers::exportToSvg, and Exporting graphs.


bool exportToPng(Item obj, url path, int dpi = 96 * 2)

Exports the graph in obj 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.

See also Helpers::exportToSvg, Helpers::exportToPicture, and Exporting graphs.


bool exportToSvg(Item obj, url path)

Exports the graph in obj 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.

See also Helpers::exportToPng, Helpers::exportToPicture, and Exporting graphs.


bool isInsideEllipse(point point, point center, real radiusX, real radiusY)

Returns whether point is inside the ellipse centered on center with radii radiusX and radiusY.


bool isInsidePolygon(point point, var points)

Returns whether point is inside the polygon defined by points.


bool isNearPolyline(point point, var points, real 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.


bool isNearSegment(point point, point segmentStart, point segmentEnd, real hitWidth)

Returns whether point is within half hitWidth of the segment from segmentStart to segmentEnd.


list<real> linspace(real min, real max, int num)

Returns a list of num values equally spaced from min and max (inclusive).


list<real> logspace(real logmin, real logmax, int num, real 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).


QPolygonF mapPoints(var points, matrix4x4 dataTransform)

Maps each point in points though the transform defined by dataTransform. Essentially the same as points.map(p => dataTransform.map(p)), but more efficient.


rect normalizedRect(rect rect)

Returns rect with non-negative width and height.


list<int> 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.


list<real> tickLocator(real min, real max, int maxNum)

Returns a list of at most maxNum nice tick locations values equally spaced between min and max.