KiCad PCB EDA Suite
|
Class that handles the drawing of a polygon, including management of last corner deletion and drawing of leader lines with various constraints (eg 45 deg only). More...
#include <polygon_geom_manager.h>
Classes | |
class | CLIENT |
"Listener" interface for a class that wants to be updated about polygon geometry changes More... | |
Public Member Functions | |
POLYGON_GEOM_MANAGER (CLIENT &aClient) | |
bool | AddPoint (const VECTOR2I &aPt) |
Lock in a polygon point. | |
void | SetFinished () |
Mark the polygon finished and update the client. | |
void | Reset () |
Clear the manager state and start again. | |
void | SetLeaderMode (LEADER_MODE aMode) |
Set the leader mode to use when calculating the leader/returner lines. | |
LEADER_MODE | GetLeaderMode () const |
void | AllowIntersections (bool aEnabled) |
Enables/disables self-intersecting polygons. | |
bool | IntersectionsAllowed () const |
Check whether self-intersecting polygons are enabled. | |
bool | IsSelfIntersecting (bool aIncludeLeaderPts) const |
Check whether the locked points constitute a self-intersecting outline. | |
void | SetCursorPosition (const VECTOR2I &aPos) |
Set the current cursor position. | |
bool | IsPolygonInProgress () const |
int | PolygonPointCount () const |
bool | NewPointClosesOutline (const VECTOR2I &aPt) const |
std::optional< VECTOR2I > | DeleteLastCorner () |
Remove the last-added point from the polygon. | |
const SHAPE_LINE_CHAIN & | GetLockedInPoints () const |
Get the "locked-in" points that describe the polygon itself. | |
const SHAPE_LINE_CHAIN & | GetLeaderLinePoints () const |
Get the points comprising the leader line (the line from the last locked-in point to the current cursor position. | |
const SHAPE_LINE_CHAIN & | GetLoopLinePoints () const |
Get the points from the current cursor position to the polygon start point. | |
Private Member Functions | |
void | updateTemporaryLines (const VECTOR2I &aEndPoint, LEADER_MODE aModifier=LEADER_MODE::DIRECT) |
Update the leader and loop lines points based on a new endpoint (probably a cursor position) | |
Private Attributes | |
CLIENT & | m_client |
The current mode of the leader line. | |
LEADER_MODE | m_leaderMode |
Flag enabling self-intersecting polygons. | |
bool | m_intersectionsAllowed |
Point that have been "locked in". | |
SHAPE_LINE_CHAIN | m_lockedPoints |
Points in the temporary "leader" line(s) | |
SHAPE_LINE_CHAIN | m_leaderPts |
Points between the cursor and start point. | |
SHAPE_LINE_CHAIN | m_loopPts |
Class that handles the drawing of a polygon, including management of last corner deletion and drawing of leader lines with various constraints (eg 45 deg only).
This class handles only the geometry of the process.
Definition at line 36 of file polygon_geom_manager.h.
POLYGON_GEOM_MANAGER::POLYGON_GEOM_MANAGER | ( | CLIENT & | aClient | ) |
aClient | is the client to pass the results onto |
Definition at line 32 of file polygon_geom_manager.cpp.
References DIRECT, m_client, m_intersectionsAllowed, and m_leaderMode.
Referenced by POLYGON_GEOM_MANAGER::CLIENT::OnComplete(), POLYGON_GEOM_MANAGER::CLIENT::OnFirstPoint(), and POLYGON_GEOM_MANAGER::CLIENT::OnGeometryChange().
bool POLYGON_GEOM_MANAGER::AddPoint | ( | const VECTOR2I & | aPt | ) |
Lock in a polygon point.
Definition at line 39 of file polygon_geom_manager.cpp.
References IsPolygonInProgress(), IsSelfIntersecting(), m_client, m_intersectionsAllowed, m_leaderPts, m_lockedPoints, and updateTemporaryLines().
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), and DRAWING_TOOL::DrawZone().
|
inline |
Enables/disables self-intersecting polygons.
aEnabled | true if self-intersecting polygons are enabled. |
Definition at line 102 of file polygon_geom_manager.h.
References m_intersectionsAllowed.
std::optional< VECTOR2I > POLYGON_GEOM_MANAGER::DeleteLastCorner | ( | ) |
Remove the last-added point from the polygon.
Definition at line 133 of file polygon_geom_manager.cpp.
References m_client, m_leaderPts, m_lockedPoints, and updateTemporaryLines().
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), and DRAWING_TOOL::DrawZone().
|
inline |
Get the points comprising the leader line (the line from the last locked-in point to the current cursor position.
How this is drawn will depend on the LEADER_MODE
Definition at line 166 of file polygon_geom_manager.h.
References m_leaderPts.
Referenced by RULE_AREA_CREATE_HELPER::OnComplete(), ZONE_CREATE_HELPER::OnComplete(), RULE_AREA_CREATE_HELPER::OnGeometryChange(), and ZONE_CREATE_HELPER::OnGeometryChange().
|
inline |
Definition at line 92 of file polygon_geom_manager.h.
References m_leaderMode.
Referenced by RULE_AREA_CREATE_HELPER::OnComplete(), and ZONE_CREATE_HELPER::OnComplete().
|
inline |
Get the "locked-in" points that describe the polygon itself.
Definition at line 155 of file polygon_geom_manager.h.
References m_lockedPoints.
Referenced by RULE_AREA_CREATE_HELPER::OnComplete(), ZONE_CREATE_HELPER::OnComplete(), RULE_AREA_CREATE_HELPER::OnGeometryChange(), and ZONE_CREATE_HELPER::OnGeometryChange().
|
inline |
Get the points from the current cursor position to the polygon start point.
Definition at line 175 of file polygon_geom_manager.h.
References m_loopPts.
Referenced by RULE_AREA_CREATE_HELPER::OnComplete(), ZONE_CREATE_HELPER::OnComplete(), RULE_AREA_CREATE_HELPER::OnGeometryChange(), and ZONE_CREATE_HELPER::OnGeometryChange().
|
inline |
Check whether self-intersecting polygons are enabled.
Definition at line 112 of file polygon_geom_manager.h.
References m_intersectionsAllowed.
bool POLYGON_GEOM_MANAGER::IsPolygonInProgress | ( | ) | const |
Definition at line 115 of file polygon_geom_manager.cpp.
References m_lockedPoints.
Referenced by AddPoint(), RULE_AREA_CREATE_HELPER::OnGeometryChange(), and ZONE_CREATE_HELPER::OnGeometryChange().
bool POLYGON_GEOM_MANAGER::IsSelfIntersecting | ( | bool | aIncludeLeaderPts | ) | const |
Check whether the locked points constitute a self-intersecting outline.
aIncludeLeaderPts | when true, also the leading points (not placed ones) will be tested. |
Definition at line 88 of file polygon_geom_manager.cpp.
References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::CPoint(), m_leaderPts, m_lockedPoints, SHAPE_LINE_CHAIN::SelfIntersecting(), and SHAPE_LINE_CHAIN::SetClosed().
Referenced by AddPoint().
bool POLYGON_GEOM_MANAGER::NewPointClosesOutline | ( | const VECTOR2I & | aPt | ) | const |
Definition at line 127 of file polygon_geom_manager.cpp.
References m_lockedPoints.
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), and DRAWING_TOOL::DrawZone().
int POLYGON_GEOM_MANAGER::PolygonPointCount | ( | ) | const |
Definition at line 121 of file polygon_geom_manager.cpp.
References m_lockedPoints.
void POLYGON_GEOM_MANAGER::Reset | ( | ) |
Clear the manager state and start again.
Definition at line 153 of file polygon_geom_manager.cpp.
References m_client, m_leaderPts, m_lockedPoints, and m_loopPts.
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), and DRAWING_TOOL::DrawZone().
void POLYGON_GEOM_MANAGER::SetCursorPosition | ( | const VECTOR2I & | aPos | ) |
Set the current cursor position.
Definition at line 108 of file polygon_geom_manager.cpp.
References m_lockedPoints, and updateTemporaryLines().
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), and DRAWING_TOOL::DrawZone().
void POLYGON_GEOM_MANAGER::SetFinished | ( | ) |
Mark the polygon finished and update the client.
Definition at line 75 of file polygon_geom_manager.cpp.
References m_client.
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), and DRAWING_TOOL::DrawZone().
void POLYGON_GEOM_MANAGER::SetLeaderMode | ( | LEADER_MODE | aMode | ) |
Set the leader mode to use when calculating the leader/returner lines.
Definition at line 82 of file polygon_geom_manager.cpp.
References m_leaderMode.
Referenced by SCH_DRAWING_TOOLS::DrawRuleArea(), DRAWING_TOOL::DrawZone(), RULE_AREA_CREATE_HELPER::OnFirstPoint(), and ZONE_CREATE_HELPER::OnFirstPoint().
|
private |
Update the leader and loop lines points based on a new endpoint (probably a cursor position)
The "user" of the polygon data that is informed when the geometry changes
Definition at line 246 of file polygon_geom_manager.cpp.
References build45DegLeader(), build90DegLeader(), DEG45, DEG90, m_client, m_leaderMode, m_leaderPts, m_lockedPoints, m_loopPts, and SHAPE_LINE_CHAIN::Reverse().
Referenced by AddPoint(), DeleteLastCorner(), and SetCursorPosition().
|
private |
The current mode of the leader line.
Definition at line 190 of file polygon_geom_manager.h.
Referenced by AddPoint(), DeleteLastCorner(), POLYGON_GEOM_MANAGER(), Reset(), SetFinished(), and updateTemporaryLines().
|
private |
Point that have been "locked in".
Definition at line 196 of file polygon_geom_manager.h.
Referenced by AddPoint(), AllowIntersections(), IntersectionsAllowed(), and POLYGON_GEOM_MANAGER().
|
private |
Flag enabling self-intersecting polygons.
Definition at line 193 of file polygon_geom_manager.h.
Referenced by GetLeaderMode(), POLYGON_GEOM_MANAGER(), SetLeaderMode(), and updateTemporaryLines().
|
private |
Points between the cursor and start point.
Definition at line 202 of file polygon_geom_manager.h.
Referenced by AddPoint(), DeleteLastCorner(), GetLeaderLinePoints(), IsSelfIntersecting(), Reset(), and updateTemporaryLines().
|
private |
Points in the temporary "leader" line(s)
Definition at line 199 of file polygon_geom_manager.h.
Referenced by AddPoint(), DeleteLastCorner(), GetLockedInPoints(), IsPolygonInProgress(), IsSelfIntersecting(), NewPointClosesOutline(), PolygonPointCount(), Reset(), SetCursorPosition(), and updateTemporaryLines().
|
private |
Definition at line 205 of file polygon_geom_manager.h.
Referenced by GetLoopLinePoints(), Reset(), and updateTemporaryLines().