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

#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.
 
void SetDirections (const std::vector< VECTOR2I > &aDirections)
 
const std::vector< VECTOR2I > & GetDirections () const
 
std::optional< int > GetActiveDirection () const
 

Private Member Functions

void notifyGuideChange ()
 

Private Attributes

OPT_VECTOR2I m_snapLineOrigin
 
OPT_VECTOR2I m_snapLineEnd
 
std::vector< VECTOR2Im_directions
 
std::optional< int > m_activeDirection
 
CONSTRUCTION_VIEW_HANDLERm_viewHandler
 
SNAP_MANAGERm_snapManager
 

Detailed Description

Definition at line 71 of file construction_manager.h.

Constructor & Destructor Documentation

◆ SNAP_LINE_MANAGER()

SNAP_LINE_MANAGER::SNAP_LINE_MANAGER ( CONSTRUCTION_VIEW_HANDLER & aViewHandler)

Definition at line 396 of file construction_manager.cpp.

References m_snapManager, m_viewHandler, and SetDirections().

Member Function Documentation

◆ ClearSnapLine()

void SNAP_LINE_MANAGER::ClearSnapLine ( )

Clear the snap line origin and end points.

Definition at line 526 of file construction_manager.cpp.

References m_activeDirection, m_snapLineEnd, m_snapLineOrigin, m_viewHandler, and notifyGuideChange().

Referenced by SetDirections().

◆ GetActiveDirection()

std::optional< int > SNAP_LINE_MANAGER::GetActiveDirection ( ) const
inline

Definition at line 130 of file construction_manager.h.

References m_activeDirection.

Referenced by GRID_HELPER::SnapToConstructionLines().

◆ GetDirections()

const std::vector< VECTOR2I > & SNAP_LINE_MANAGER::GetDirections ( ) const
inline

Definition at line 128 of file construction_manager.h.

References m_directions.

Referenced by GRID_HELPER::SnapToConstructionLines().

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

Definition at line 559 of file construction_manager.cpp.

References std::abs(), EDA_ANGLE::AsDegrees(), cursor, DEGREES_T, delta, VECTOR2< T >::EuclideanNorm(), KiROUND(), m_directions, m_snapLineOrigin, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_GRID_HELPER::BestSnapAnchor().

◆ GetSnapLineOrigin()

const OPT_VECTOR2I & SNAP_LINE_MANAGER::GetSnapLineOrigin ( ) const
inline

Definition at line 97 of file construction_manager.h.

References m_snapLineOrigin.

Referenced by GRID_HELPER::SnapToConstructionLines().

◆ HasCompleteSnapLine()

bool SNAP_LINE_MANAGER::HasCompleteSnapLine ( ) const
inline

Definition at line 99 of file construction_manager.h.

References m_snapLineEnd, and m_snapLineOrigin.

◆ notifyGuideChange()

void SNAP_LINE_MANAGER::notifyGuideChange ( )
private

Definition at line 702 of file construction_manager.cpp.

References m_snapManager.

Referenced by ClearSnapLine(), SetDirections(), SetSnapLineEnd(), and SetSnapLineOrigin().

◆ SetDirections()

void SNAP_LINE_MANAGER::SetDirections ( const std::vector< VECTOR2I > & aDirections)

◆ SetSnapLineEnd()

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 505 of file construction_manager.cpp.

References findDirectionIndex(), m_activeDirection, m_directions, m_snapLineEnd, m_snapLineOrigin, m_viewHandler, and notifyGuideChange().

Referenced by EE_GRID_HELPER::BestSnapAnchor(), PCB_GRID_HELPER::BestSnapAnchor(), and SetSnappedAnchor().

◆ 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 489 of file construction_manager.cpp.

References m_activeDirection, m_snapLineEnd, m_snapLineOrigin, m_viewHandler, and notifyGuideChange().

Referenced by EE_GRID_HELPER::BestSnapAnchor(), PCB_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 536 of file construction_manager.cpp.

References findDirectionIndex(), m_directions, m_snapLineOrigin, SetSnapLineEnd(), and SetSnapLineOrigin().

Referenced by PCB_GRID_HELPER::BestSnapAnchor().

Member Data Documentation

◆ m_activeDirection

std::optional<int> SNAP_LINE_MANAGER::m_activeDirection
private

◆ m_directions

std::vector<VECTOR2I> SNAP_LINE_MANAGER::m_directions
private

◆ m_snapLineEnd

OPT_VECTOR2I SNAP_LINE_MANAGER::m_snapLineEnd
private

◆ m_snapLineOrigin

◆ m_snapManager

SNAP_MANAGER* SNAP_LINE_MANAGER::m_snapManager
private

Definition at line 143 of file construction_manager.h.

Referenced by notifyGuideChange(), and SNAP_LINE_MANAGER().

◆ m_viewHandler

CONSTRUCTION_VIEW_HANDLER& SNAP_LINE_MANAGER::m_viewHandler
private

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