KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SNAP_LINE_MANAGER Class Reference

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_VECTOR2IGetSnapLineOrigin () 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_HANDLERm_viewHandler
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SNAP_LINE_MANAGER()

SNAP_LINE_MANAGER::SNAP_LINE_MANAGER ( CONSTRUCTION_VIEW_HANDLER aViewHandler)

Definition at line 367 of file construction_manager.cpp.

Member Function Documentation

◆ ClearSnapLine()

◆ GetNearestSnapLinePoint()

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

Parameters
aCursorThe cursor position
aNearestGridThe nearest grid point to the cursor
aDistToNearestThe distance to the nearest non-grid snap point, if any
snapRangeThe 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().

◆ GetSnapLineOrigin()

const OPT_VECTOR2I & SNAP_LINE_MANAGER::GetSnapLineOrigin ( ) const
inline

◆ HasCompleteSnapLine()

bool SNAP_LINE_MANAGER::HasCompleteSnapLine ( ) const
inline

Definition at line 94 of file construction_manager.h.

References m_snapLineEnd, and m_snapLineOrigin.

Referenced by SNAP_MANAGER::updateView().

◆ SetSnapLineEnd()

void SNAP_LINE_MANAGER::SetSnapLineEnd ( const OPT_VECTOR2I aSnapPoint)

◆ SetSnapLineOrigin()

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().

◆ 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().

Member Data Documentation

◆ m_snapLineEnd

OPT_VECTOR2I SNAP_LINE_MANAGER::m_snapLineEnd
private

Definition at line 125 of file construction_manager.h.

Referenced by ClearSnapLine(), HasCompleteSnapLine(), and SetSnapLineEnd().

◆ m_snapLineOrigin

◆ m_viewHandler

CONSTRUCTION_VIEW_HANDLER& SNAP_LINE_MANAGER::m_viewHandler
private

Definition at line 128 of file construction_manager.h.

Referenced by ClearSnapLine(), and SetSnapLineEnd().


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