KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
Line::List Class Reference

A list of Line objects with spatial query helpers. More...

#include <line.h>

+ Inheritance diagram for Line::List:
+ Collaboration diagram for Line::List:

Public Member Functions

 List ()
 Default constructor.
 
 List (const QList< Line > &other)
 Construct from a QList<Line>.
 
Line longestHorizontalLine ()
 Return the longest horizontal line in the list.
 
Line longestVerticalLine ()
 Return the longest vertical line in the list.
 
bool containsLineWithSameEndpoints (const Line &line) const
 Test whether the list contains a line with the same two endpoints.
 
Line highest () const
 Return the line with the smallest Y start or end coordinate.
 
Line lowest () const
 Return the line with the largest Y start or end coordinate.
 
Line shortest () const
 Return the shortest line in the list.
 
Line longest () const
 Return the longest line in the list.
 
QPointF closestPointTo (const QPointF &other)
 Return the point on any line closest to the given point.
 
QPointF closestPointTo (const QPointF &other, Line &closestLine, double &closestDistance)
 Return the closest point, and output which line and distance produced it.
 
double minX () const
 Return the minimum X coordinate across all line endpoints.
 
double maxX () const
 Return the maximum X coordinate across all line endpoints.
 
double minY () const
 Return the minimum Y coordinate across all line endpoints.
 
double maxY () const
 Return the maximum Y coordinate across all line endpoints.
 
Rectangle boundingRectangle () const
 Return the bounding rectangle of all lines in the list.
 
Line lineContainingPoint (const Point &point) const
 Return the first line that contains the given point.
 
Line lineNearPoint (const Point &point, int margin) const
 Return the first line near the given point within a margin.
 
double totalLength () const
 Return the total combined length of all lines.
 
ListmoveDelta (double dx, double dy)
 Move all lines by the given delta.
 
QList< QLineF > toQLineFList () const
 Convert all lines to a list of QLineF objects.
 
QList< QLine > toQLineList () const
 Convert all lines to a list of QLine objects.
 
QString toString () const
 Format the list as a human-readable string.
 

Static Public Member Functions

static List fromPoints (const QList< QPoint > &points)
 Build a list of lines connecting adjacent points in a QList<QPoint>.
 
static List fromPoints (const QList< QPointF > &points)
 Build a list of lines connecting adjacent points in a QList<QPointF>.
 
static List fromString (const QString &value)
 Parse a List from a string produced by toString().
 

Detailed Description

A list of Line objects with spatial query helpers.

Definition at line 126 of file line.h.

Constructor & Destructor Documentation

◆ List() [1/2]

Line::List::List ( )
inline

Default constructor.

Definition at line 130 of file line.h.

◆ List() [2/2]

Line::List::List ( const QList< Line > &  other)
inline

Construct from a QList<Line>.

Parameters
otherSource list to copy lines from

Definition at line 136 of file line.h.

Member Function Documentation

◆ boundingRectangle()

Rectangle Line::List::boundingRectangle ( ) const

Return the bounding rectangle of all lines in the list.

Returns
Bounding Rectangle

◆ closestPointTo() [1/2]

QPointF Line::List::closestPointTo ( const QPointF &  other)

Return the point on any line closest to the given point.

Parameters
otherReference point
Returns
Closest point on any line

◆ closestPointTo() [2/2]

QPointF Line::List::closestPointTo ( const QPointF &  other,
Line closestLine,
double &  closestDistance 
)

Return the closest point, and output which line and distance produced it.

Parameters
otherReference point
closestLineOutput set to the line containing the closest point
closestDistanceOutput set to the distance to the closest point
Returns
Closest point on any line

◆ containsLineWithSameEndpoints()

bool Line::List::containsLineWithSameEndpoints ( const Line line) const

Test whether the list contains a line with the same two endpoints.

Parameters
lineLine to search for
Returns
true if a matching line is found

◆ fromPoints() [1/2]

static List Line::List::fromPoints ( const QList< QPoint > &  points)
static

Build a list of lines connecting adjacent points in a QList<QPoint>.

Parameters
pointsList of integer points
Returns
List of lines connecting consecutive points

◆ fromPoints() [2/2]

static List Line::List::fromPoints ( const QList< QPointF > &  points)
static

Build a list of lines connecting adjacent points in a QList<QPointF>.

Parameters
pointsList of floating-point points
Returns
List of lines connecting consecutive points

◆ fromString()

static List Line::List::fromString ( const QString &  value)
static

Parse a List from a string produced by toString().

Parameters
valueString representation
Returns
Parsed List

◆ highest()

Line Line::List::highest ( ) const

Return the line with the smallest Y start or end coordinate.

Returns
Highest Line

◆ lineContainingPoint()

Line Line::List::lineContainingPoint ( const Point point) const

Return the first line that contains the given point.

Parameters
pointPoint to search for
Returns
Matching line, or an invalid line if not found

◆ lineNearPoint()

Line Line::List::lineNearPoint ( const Point point,
int  margin 
) const

Return the first line near the given point within a margin.

Parameters
pointReference point
marginMaximum allowed distance
Returns
Nearby line, or an invalid line if not found

◆ longest()

Line Line::List::longest ( ) const

Return the longest line in the list.

Returns
Longest Line

◆ longestHorizontalLine()

Line Line::List::longestHorizontalLine ( )

Return the longest horizontal line in the list.

Returns
Longest horizontal Line

◆ longestVerticalLine()

Line Line::List::longestVerticalLine ( )

Return the longest vertical line in the list.

Returns
Longest vertical Line

◆ lowest()

Line Line::List::lowest ( ) const

Return the line with the largest Y start or end coordinate.

Returns
Lowest Line

◆ maxX()

double Line::List::maxX ( ) const

Return the maximum X coordinate across all line endpoints.

Returns
Maximum X value

◆ maxY()

double Line::List::maxY ( ) const

Return the maximum Y coordinate across all line endpoints.

Returns
Maximum Y value

◆ minX()

double Line::List::minX ( ) const

Return the minimum X coordinate across all line endpoints.

Returns
Minimum X value

◆ minY()

double Line::List::minY ( ) const

Return the minimum Y coordinate across all line endpoints.

Returns
Minimum Y value

◆ moveDelta()

List & Line::List::moveDelta ( double  dx,
double  dy 
)

Move all lines by the given delta.

Parameters
dxHorizontal displacement
dyVertical displacement
Returns
Reference to this list

◆ shortest()

Line Line::List::shortest ( ) const

Return the shortest line in the list.

Returns
Shortest Line

◆ toQLineFList()

QList< QLineF > Line::List::toQLineFList ( ) const

Convert all lines to a list of QLineF objects.

Returns
QList of QLineF

◆ toQLineList()

QList< QLine > Line::List::toQLineList ( ) const

Convert all lines to a list of QLine objects.

Returns
QList of QLine

◆ toString()

QString Line::List::toString ( ) const

Format the list as a human-readable string.

Returns
String representation

◆ totalLength()

double Line::List::totalLength ( ) const

Return the total combined length of all lines.

Returns
Sum of all line lengths

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