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

#include <grid_helper.h>

Inheritance diagram for GRID_HELPER:
EE_GRID_HELPER PCB_GRID_HELPER

Classes

struct  ANCHOR
 

Public Types

enum  ANCHOR_FLAGS {
  CORNER = 1 , OUTLINE = 2 , SNAPPABLE = 4 , ORIGIN = 8 ,
  VERTICAL = 16 , HORIZONTAL = 32 , ALL = CORNER | OUTLINE | SNAPPABLE | ORIGIN | VERTICAL | HORIZONTAL
}
 

Public Member Functions

 GRID_HELPER (TOOL_MANAGER *aToolMgr)
 
virtual ~GRID_HELPER ()
 
VECTOR2I GetGrid () const
 
VECTOR2D GetVisibleGrid () const
 
VECTOR2I GetOrigin () const
 
void SetAuxAxes (bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
 
virtual VECTOR2I Align (const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
 
virtual VECTOR2I AlignGrid (const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
 
virtual VECTOR2I Align (const VECTOR2I &aPoint) const
 
virtual VECTOR2I Align (const VECTOR2I &aPoint, const VECTOR2D &aGrid, const VECTOR2D &aOffset) const
 
VECTOR2I AlignGrid (const VECTOR2I &aPoint) const
 
VECTOR2I AlignGrid (const VECTOR2I &aPoint, const VECTOR2D &aGrid, const VECTOR2D &aOffset) const
 
virtual GRID_HELPER_GRIDS GetSelectionGrid (const SELECTION &aSelection) const
 Gets the coarsest grid that applies to a selecion of items.
 
virtual GRID_HELPER_GRIDS GetItemGrid (const EDA_ITEM *aItem) const
 Gets the coarsest grid that applies to an item.
 
virtual VECTOR2D GetGridSize (GRID_HELPER_GRIDS aGrid) const
 Return the size of the specified grid.
 
void SetSkipPoint (const VECTOR2I &aPoint)
 
void ClearSkipPoint ()
 We clear the skip point by setting it to an unreachable position, thereby preventing matching.
 
void SetSnap (bool aSnap)
 
bool GetSnap () const
 
void SetUseGrid (bool aSnapToGrid)
 
bool GetUseGrid () const
 
void SetSnapLine (bool aSnap)
 
void SetMask (int aMask)
 
void SetMaskFlag (int aFlag)
 
void ClearMaskFlag (int aFlag)
 

Protected Member Functions

void addAnchor (const VECTOR2I &aPos, int aFlags, EDA_ITEM *aItem)
 
void clearAnchors ()
 
bool canUseGrid () const
 Check whether it is possible to use the grid – this depends both on local grid helper settings and global (tool manager) KiCad settings.
 
VECTOR2I computeNearest (const VECTOR2I &aPoint, const VECTOR2I &aGrid, const VECTOR2I &aOffset) const
 

Protected Attributes

std::vector< ANCHORm_anchors
 
TOOL_MANAGERm_toolMgr
 
std::optional< VECTOR2Im_auxAxis
 
int m_maskTypes
 
bool m_enableSnap
 
bool m_enableGrid
 
bool m_enableSnapLine
 
ANCHORm_snapItem
 
VECTOR2I m_skipPoint
 
KIGFX::ORIGIN_VIEWITEM m_viewSnapPoint
 
KIGFX::ORIGIN_VIEWITEM m_viewSnapLine
 
KIGFX::ORIGIN_VIEWITEM m_viewAxis
 

Detailed Description

Definition at line 48 of file grid_helper.h.

Member Enumeration Documentation

◆ ANCHOR_FLAGS

Enumerator
CORNER 
OUTLINE 
SNAPPABLE 
ORIGIN 
VERTICAL 
HORIZONTAL 
ALL 

Definition at line 118 of file grid_helper.h.

Constructor & Destructor Documentation

◆ GRID_HELPER()

GRID_HELPER::GRID_HELPER ( TOOL_MANAGER aToolMgr)

Definition at line 37 of file grid_helper.cpp.

References ALL, m_enableGrid, m_enableSnap, m_enableSnapLine, m_maskTypes, and m_snapItem.

◆ ~GRID_HELPER()

GRID_HELPER::~GRID_HELPER ( )
virtual

Definition at line 48 of file grid_helper.cpp.

Member Function Documentation

◆ addAnchor()

void GRID_HELPER::addAnchor ( const VECTOR2I aPos,
int  aFlags,
EDA_ITEM aItem 
)
inlineprotected

Definition at line 148 of file grid_helper.h.

References m_anchors, and m_maskTypes.

Referenced by PCB_GRID_HELPER::computeAnchors(), and EE_GRID_HELPER::computeAnchors().

◆ Align() [1/3]

VECTOR2I GRID_HELPER::Align ( const VECTOR2I aPoint) const
virtual

Reimplemented in PCB_GRID_HELPER.

Definition at line 135 of file grid_helper.cpp.

References Align(), GetGrid(), and GetOrigin().

◆ Align() [2/3]

VECTOR2I GRID_HELPER::Align ( const VECTOR2I aPoint,
const VECTOR2D aGrid,
const VECTOR2D aOffset 
) const
virtual

Reimplemented in PCB_GRID_HELPER.

Definition at line 141 of file grid_helper.cpp.

References std::abs(), AlignGrid(), canUseGrid(), m_auxAxis, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Align() [3/3]

virtual VECTOR2I GRID_HELPER::Align ( const VECTOR2I aPoint,
GRID_HELPER_GRIDS  aGrid 
) const
inlinevirtual

Reimplemented in PCB_GRID_HELPER.

Definition at line 60 of file grid_helper.h.

References Align(), GetGridSize(), and GetOrigin().

Referenced by Align(), EE_GRID_HELPER::BestSnapAnchor(), and EE_GRID_HELPER::computeAnchors().

◆ AlignGrid() [1/3]

VECTOR2I GRID_HELPER::AlignGrid ( const VECTOR2I aPoint) const

Definition at line 114 of file grid_helper.cpp.

References computeNearest(), GetGrid(), and GetOrigin().

◆ AlignGrid() [2/3]

VECTOR2I GRID_HELPER::AlignGrid ( const VECTOR2I aPoint,
const VECTOR2D aGrid,
const VECTOR2D aOffset 
) const

Definition at line 120 of file grid_helper.cpp.

References computeNearest().

◆ AlignGrid() [3/3]

virtual VECTOR2I GRID_HELPER::AlignGrid ( const VECTOR2I aPoint,
GRID_HELPER_GRIDS  aGrid 
) const
inlinevirtual

◆ canUseGrid()

bool GRID_HELPER::canUseGrid ( ) const
protected

Check whether it is possible to use the grid – this depends both on local grid helper settings and global (tool manager) KiCad settings.

Definition at line 162 of file grid_helper.cpp.

References KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOL_MANAGER::GetView(), m_enableGrid, and m_toolMgr.

Referenced by Align(), and EE_GRID_HELPER::BestSnapAnchor().

◆ clearAnchors()

◆ ClearMaskFlag()

void GRID_HELPER::ClearMaskFlag ( int  aFlag)
inline

Definition at line 116 of file grid_helper.h.

References m_maskTypes.

◆ ClearSkipPoint()

void GRID_HELPER::ClearSkipPoint ( )
inline

We clear the skip point by setting it to an unreachable position, thereby preventing matching.

Definition at line 101 of file grid_helper.h.

References m_skipPoint.

◆ computeNearest()

VECTOR2I GRID_HELPER::computeNearest ( const VECTOR2I aPoint,
const VECTOR2I aGrid,
const VECTOR2I aOffset 
) const
protected

Definition at line 127 of file grid_helper.cpp.

References KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by AlignGrid().

◆ GetGrid()

VECTOR2I GRID_HELPER::GetGrid ( ) const

◆ GetGridSize()

VECTOR2D GRID_HELPER::GetGridSize ( GRID_HELPER_GRIDS  aGrid) const
virtual

Return the size of the specified grid.

Reimplemented in EE_GRID_HELPER, and PCB_GRID_HELPER.

Definition at line 92 of file grid_helper.cpp.

References KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSize(), TOOL_MANAGER::GetView(), and m_toolMgr.

Referenced by Align(), PCB_GRID_HELPER::AlignGrid(), and AlignGrid().

◆ GetItemGrid()

virtual GRID_HELPER_GRIDS GRID_HELPER::GetItemGrid ( const EDA_ITEM aItem) const
inlinevirtual

Gets the coarsest grid that applies to an item.

Reimplemented in EE_GRID_HELPER, and PCB_GRID_HELPER.

Definition at line 86 of file grid_helper.h.

References GRID_CURRENT.

Referenced by PCB_GRID_HELPER::AlignGrid().

◆ GetOrigin()

VECTOR2I GRID_HELPER::GetOrigin ( ) const

◆ GetSelectionGrid()

GRID_HELPER_GRIDS GRID_HELPER::GetSelectionGrid ( const SELECTION aSelection) const
virtual

Gets the coarsest grid that applies to a selecion of items.

Reimplemented in EE_GRID_HELPER.

Definition at line 75 of file grid_helper.cpp.

◆ GetSnap()

bool GRID_HELPER::GetSnap ( ) const
inline

◆ GetUseGrid()

bool GRID_HELPER::GetUseGrid ( ) const
inline

Definition at line 110 of file grid_helper.h.

References m_enableGrid.

Referenced by PNS::TOOL_BASE::updateStartItem().

◆ GetVisibleGrid()

VECTOR2D GRID_HELPER::GetVisibleGrid ( ) const

◆ SetAuxAxes()

void GRID_HELPER::SetAuxAxes ( bool  aEnable,
const VECTOR2I aOrigin = VECTOR2I( 0, 0 ) 
)

◆ SetMask()

void GRID_HELPER::SetMask ( int  aMask)
inline

Definition at line 114 of file grid_helper.h.

References m_maskTypes.

◆ SetMaskFlag()

void GRID_HELPER::SetMaskFlag ( int  aFlag)
inline

Definition at line 115 of file grid_helper.h.

References m_maskTypes.

◆ SetSkipPoint()

void GRID_HELPER::SetSkipPoint ( const VECTOR2I aPoint)
inline

Definition at line 93 of file grid_helper.h.

References m_skipPoint.

◆ SetSnap()

◆ SetSnapLine()

void GRID_HELPER::SetSnapLine ( bool  aSnap)
inline

Definition at line 112 of file grid_helper.h.

References m_enableSnapLine.

◆ SetUseGrid()

void GRID_HELPER::SetUseGrid ( bool  aSnapToGrid)
inline

Member Data Documentation

◆ m_anchors

std::vector<ANCHOR> GRID_HELPER::m_anchors
protected

◆ m_auxAxis

std::optional<VECTOR2I> GRID_HELPER::m_auxAxis
protected

Definition at line 173 of file grid_helper.h.

Referenced by Align(), and SetAuxAxes().

◆ m_enableGrid

bool GRID_HELPER::m_enableGrid
protected

◆ m_enableSnap

◆ m_enableSnapLine

bool GRID_HELPER::m_enableSnapLine
protected

◆ m_maskTypes

int GRID_HELPER::m_maskTypes
protected

Definition at line 175 of file grid_helper.h.

Referenced by addAnchor(), ClearMaskFlag(), GRID_HELPER(), SetMask(), and SetMaskFlag().

◆ m_skipPoint

VECTOR2I GRID_HELPER::m_skipPoint
protected

◆ m_snapItem

◆ m_toolMgr

◆ m_viewAxis

◆ m_viewSnapLine

◆ m_viewSnapPoint


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