KiCad PCB EDA Suite
|
A class that manages the geometry of a "snap line". More...
#include <construction_manager.h>
Public Member Functions | |
SNAP_LINE_MANAGER (CONSTRUCTION_VIEW_HANDLER &aViewHandler) | |
void | SetSnapLineOrigin (const VECTOR2I &aOrigin) |
The snap point is a special point that is located at the last point the cursor snapped to. | |
void | SetSnapLineEnd (const OPT_VECTOR2I &aSnapPoint) |
Set the end point of the snap line. | |
void | ClearSnapLine () |
Clear the snap line origin and end points. | |
const OPT_VECTOR2I & | GetSnapLineOrigin () const |
bool | HasCompleteSnapLine () const |
void | SetSnappedAnchor (const VECTOR2I &aAnchorPos) |
Inform this manager that an anchor snap has been made. | |
OPT_VECTOR2I | GetNearestSnapLinePoint (const VECTOR2I &aCursor, const VECTOR2I &aNearestGrid, std::optional< int > aDistToNearest, int snapRange) const |
If the snap line is active, return the best snap point that is closest to the cursor. | |
Private Attributes | |
OPT_VECTOR2I | m_snapLineOrigin |
OPT_VECTOR2I | m_snapLineEnd |
CONSTRUCTION_VIEW_HANDLER & | m_viewHandler |
A class that manages the geometry of a "snap line".
This is a line that has a start point (the "snap origin") and an end point (the "snap end"). The end can only be set if the origin is set. If the origin is set, the end will be unset.
Definition at line 68 of file construction_manager.h.
SNAP_LINE_MANAGER::SNAP_LINE_MANAGER | ( | CONSTRUCTION_VIEW_HANDLER & | aViewHandler | ) |
Definition at line 367 of file construction_manager.cpp.
void SNAP_LINE_MANAGER::ClearSnapLine | ( | ) |
Clear the snap line origin and end points.
Definition at line 394 of file construction_manager.cpp.
References KIGFX::CONSTRUCTION_GEOM::ClearSnapLine(), CONSTRUCTION_VIEW_HANDLER::GetViewItem(), m_snapLineEnd, m_snapLineOrigin, m_viewHandler, and CONSTRUCTION_VIEW_HANDLER::updateView().
Referenced by PCB_GRID_HELPER::BestSnapAnchor(), EE_GRID_HELPER::BestSnapAnchor(), and SetSnapLineOrigin().
OPT_VECTOR2I SNAP_LINE_MANAGER::GetNearestSnapLinePoint | ( | const VECTOR2I & | aCursor, |
const VECTOR2I & | aNearestGrid, | ||
std::optional< int > | aDistToNearest, | ||
int | snapRange | ||
) | const |
If the snap line is active, return the best snap point that is closest to the cursor.
If there's no active snap line, return std::nullopt.
If there's a snap very near, use that otherwise, use the grid point. With this point, snap to it on an H/V axis.
Then, if there's a grid point near, snap to it on an H/V axis
aCursor | The cursor position |
aNearestGrid | The nearest grid point to the cursor |
aDistToNearest | The distance to the nearest non-grid snap point, if any |
snapRange | The snap range |
Allows de-snapping from the line if you are closer to another snap point Or if you have moved far enough away from the line
Definition at line 458 of file construction_manager.cpp.
References DEGREES_T, m_snapLineOrigin, pointHasEscapedSnapLineX(), pointHasEscapedSnapLineY(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by PCB_GRID_HELPER::BestSnapAnchor().
|
inline |
Definition at line 92 of file construction_manager.h.
References m_snapLineOrigin.
Referenced by EE_GRID_HELPER::BestSnapAnchor(), and SNAP_MANAGER::GetConstructionItems().
|
inline |
Definition at line 94 of file construction_manager.h.
References m_snapLineEnd, and m_snapLineOrigin.
Referenced by SNAP_MANAGER::updateView().
void SNAP_LINE_MANAGER::SetSnapLineEnd | ( | const OPT_VECTOR2I & | aSnapPoint | ) |
Set the end point of the snap line.
Passing std::nullopt will unset the end point, but keep the origin.
Definition at line 379 of file construction_manager.cpp.
References KIGFX::CONSTRUCTION_GEOM::ClearSnapLine(), CONSTRUCTION_VIEW_HANDLER::GetViewItem(), m_snapLineEnd, m_snapLineOrigin, m_viewHandler, KIGFX::CONSTRUCTION_GEOM::SetSnapLine(), and CONSTRUCTION_VIEW_HANDLER::updateView().
Referenced by PCB_GRID_HELPER::BestSnapAnchor(), EE_GRID_HELPER::BestSnapAnchor(), and SetSnappedAnchor().
void SNAP_LINE_MANAGER::SetSnapLineOrigin | ( | const VECTOR2I & | aOrigin | ) |
The snap point is a special point that is located at the last point the cursor snapped to.
If it is set, the construction manager may add extra construction geometry to the helper extending from the snap point origin to the cursor, which is the 'snap line'.
Definition at line 372 of file construction_manager.cpp.
References ClearSnapLine(), and m_snapLineOrigin.
Referenced by PCB_GRID_HELPER::BestSnapAnchor(), EE_GRID_HELPER::BestSnapAnchor(), and SetSnappedAnchor().
void SNAP_LINE_MANAGER::SetSnappedAnchor | ( | const VECTOR2I & | aAnchorPos | ) |
Inform this manager that an anchor snap has been made.
This will also update the start or end of the snap line as appropriate.
Definition at line 402 of file construction_manager.cpp.
References m_snapLineOrigin, SetSnapLineEnd(), SetSnapLineOrigin(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by PCB_GRID_HELPER::BestSnapAnchor().
|
private |
Definition at line 125 of file construction_manager.h.
Referenced by ClearSnapLine(), HasCompleteSnapLine(), and SetSnapLineEnd().
|
private |
Definition at line 124 of file construction_manager.h.
Referenced by ClearSnapLine(), GetNearestSnapLinePoint(), GetSnapLineOrigin(), HasCompleteSnapLine(), SetSnapLineEnd(), SetSnapLineOrigin(), and SetSnappedAnchor().
|
private |
Definition at line 128 of file construction_manager.h.
Referenced by ClearSnapLine(), and SetSnapLineEnd().