KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
PathRouter Class Reference

Orthogonal path-routing algorithm that navigates around rectangular obstacles. More...

#include <pathrouter.h>

Public Member Functions

 PathRouter ()
 Default constructor — creates an unconfigured router with default margin settings.
 
 PathRouter (const Point &origin, const Point &destination, const QRectF &canvas, const QList< Rectangle > &obstacles=QList< Rectangle >())
 Construct a PathRouter with full configuration.
 
Line::List calcluatePath ()
 Compute the routed path from origin to destination avoiding all obstacles.
 
void appendObstacle (const Rectangle &value)
 Append a single obstacle rectangle to the routing obstacle set.
 
void setObstacles (const QList< Rectangle > &value)
 Replace the entire obstacle set.
 
Point originPoint () const
 Return the origin point.
 
void setOriginPoint (const Point &value)
 Set the origin point.
 
Point destinationPoint () const
 Return the destination point.
 
void setDestinationPoint (const Point &value)
 Set the destination point.
 
int routingMargin () const
 Return the routing margin applied around each obstacle.
 
void setRoutingMargin (int value)
 Set the routing margin applied around each obstacle.
 
bool consolidateEmptyRectangles () const
 Return whether empty (non-obstacle) rectangles are consolidated before routing.
 
void setConsolidateEmptyRectangles (bool value)
 Enable or disable consolidation of empty rectangles before routing.
 
bool routeAroundMargins () const
 Return whether the router routes around obstacle margins.
 
void setRouteAroundMargins (bool value)
 Enable or disable routing around obstacle margins.
 
void setInitialDirection (Geo::Direction direction)
 Force the direction of the first routed segment.
 
void setFirstSegmentLength (double value)
 Set the length of the first segment before obstacle avoidance begins.
 
int verticalConstraint () const
 Return the vertical constraint (maximum Y coordinate the path may reach).
 
void setVerticalConstraint (int value)
 Set the vertical constraint (maximum Y the path may reach).
 
int debugLevel () const
 Return the debug verbosity level.
 
void setDebugLevel (int value)
 Set the debug verbosity level.
 

Static Public Member Functions

static void mergeAdjacentLines (Line::List &lines)
 Merge adjacent collinear line segments in-place.
 

Detailed Description

Orthogonal path-routing algorithm that navigates around rectangular obstacles.

PathRouter computes a list of horizontal/vertical line segments connecting an origin point to a destination point while avoiding a set of rectangular obstacles on a canvas. Call calcluatePath() after configuration to obtain the routed Line::List.

Definition at line 21 of file pathrouter.h.

Constructor & Destructor Documentation

◆ PathRouter() [1/2]

PathRouter::PathRouter ( )
inline

Default constructor — creates an unconfigured router with default margin settings.

Definition at line 25 of file pathrouter.h.

◆ PathRouter() [2/2]

PathRouter::PathRouter ( const Point origin,
const Point destination,
const QRectF &  canvas,
const QList< Rectangle > &  obstacles = QList< Rectangle >() 
)

Construct a PathRouter with full configuration.

Parameters
originStarting point for the path
destinationEnding point for the path
canvasBounding rectangle for the entire routing area
obstaclesList of rectangular obstacles to route around (default empty)

Member Function Documentation

◆ appendObstacle()

void PathRouter::appendObstacle ( const Rectangle value)
inline

Append a single obstacle rectangle to the routing obstacle set.

Parameters
valueObstacle rectangle to add

Definition at line 56 of file pathrouter.h.

◆ calcluatePath()

Line::List PathRouter::calcluatePath ( )

Compute the routed path from origin to destination avoiding all obstacles.

Returns
Ordered list of line segments forming the routed path

◆ consolidateEmptyRectangles()

bool PathRouter::consolidateEmptyRectangles ( ) const
inline

Return whether empty (non-obstacle) rectangles are consolidated before routing.

Returns
true if consolidation is enabled

Definition at line 104 of file pathrouter.h.

◆ debugLevel()

int PathRouter::debugLevel ( ) const
inline

Return the debug verbosity level.

Returns
Debug level (0 = silent)

Definition at line 152 of file pathrouter.h.

◆ destinationPoint()

Point PathRouter::destinationPoint ( ) const
inline

Return the destination point.

Returns
Current destination Point

Definition at line 80 of file pathrouter.h.

◆ mergeAdjacentLines()

static void PathRouter::mergeAdjacentLines ( Line::List lines)
static

Merge adjacent collinear line segments in-place.

Parameters
linesLine list to process; merged in place

◆ originPoint()

Point PathRouter::originPoint ( ) const
inline

Return the origin point.

Returns
Current origin Point

Definition at line 68 of file pathrouter.h.

◆ routeAroundMargins()

bool PathRouter::routeAroundMargins ( ) const
inline

Return whether the router routes around obstacle margins.

Returns
true if margin-based routing is enabled

Definition at line 116 of file pathrouter.h.

◆ routingMargin()

int PathRouter::routingMargin ( ) const
inline

Return the routing margin applied around each obstacle.

Returns
Margin in pixels/units

Definition at line 92 of file pathrouter.h.

◆ setConsolidateEmptyRectangles()

void PathRouter::setConsolidateEmptyRectangles ( bool  value)
inline

Enable or disable consolidation of empty rectangles before routing.

Parameters
valuetrue to enable consolidation

Definition at line 110 of file pathrouter.h.

◆ setDebugLevel()

void PathRouter::setDebugLevel ( int  value)
inline

Set the debug verbosity level.

Parameters
valueDebug level (0 = silent, higher = more verbose)

Definition at line 158 of file pathrouter.h.

◆ setDestinationPoint()

void PathRouter::setDestinationPoint ( const Point value)
inline

Set the destination point.

Parameters
valueNew destination Point

Definition at line 86 of file pathrouter.h.

◆ setFirstSegmentLength()

void PathRouter::setFirstSegmentLength ( double  value)
inline

Set the length of the first segment before obstacle avoidance begins.

Parameters
valueLength in pixels/units

Definition at line 134 of file pathrouter.h.

◆ setInitialDirection()

void PathRouter::setInitialDirection ( Geo::Direction  direction)
inline

Force the direction of the first routed segment.

Parameters
directionPreferred initial travel direction

Definition at line 128 of file pathrouter.h.

◆ setObstacles()

void PathRouter::setObstacles ( const QList< Rectangle > &  value)
inline

Replace the entire obstacle set.

Parameters
valueNew list of obstacle rectangles

Definition at line 62 of file pathrouter.h.

◆ setOriginPoint()

void PathRouter::setOriginPoint ( const Point value)
inline

Set the origin point.

Parameters
valueNew origin Point

Definition at line 74 of file pathrouter.h.

◆ setRouteAroundMargins()

void PathRouter::setRouteAroundMargins ( bool  value)
inline

Enable or disable routing around obstacle margins.

Parameters
valuetrue to route around margins

Definition at line 122 of file pathrouter.h.

◆ setRoutingMargin()

void PathRouter::setRoutingMargin ( int  value)
inline

Set the routing margin applied around each obstacle.

Parameters
valueMargin in pixels/units

Definition at line 98 of file pathrouter.h.

◆ setVerticalConstraint()

void PathRouter::setVerticalConstraint ( int  value)
inline

Set the vertical constraint (maximum Y the path may reach).

Parameters
valueY constraint value, or -1 to disable

Definition at line 146 of file pathrouter.h.

◆ verticalConstraint()

int PathRouter::verticalConstraint ( ) const
inline

Return the vertical constraint (maximum Y coordinate the path may reach).

Returns
Constraint Y value, or -1 if unconstrained

Definition at line 140 of file pathrouter.h.


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