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

#include <pcb_grid_helper.h>

Inheritance diagram for PCB_GRID_HELPER:
GRID_HELPER

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

 PCB_GRID_HELPER (TOOL_MANAGER *aToolMgr, MAGNETIC_SETTINGS *aMagneticSettings)
 
BOARD_ITEMGetSnapped () const
 Function GetSnapped If the PCB_GRID_HELPER has highlighted a snap point (target shown), this function will return a pointer to the item to which it snapped. More...
 
VECTOR2I AlignToSegment (const VECTOR2I &aPoint, const SEG &aSeg)
 
VECTOR2I BestDragOrigin (const VECTOR2I &aMousePos, std::vector< BOARD_ITEM * > &aItem, const SELECTION_FILTER_OPTIONS *aSelectionFilter=nullptr)
 
VECTOR2I AlignToArc (const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
 
VECTOR2I AlignToNearestPad (const VECTOR2I &aMousePos, PADS &aPads)
 
VECTOR2I BestSnapAnchor (const VECTOR2I &aOrigin, BOARD_ITEM *aReferenceItem)
 Chooses the "best" snap anchor around the given point, optionally taking layers from the reference item. More...
 
VECTOR2I BestSnapAnchor (const VECTOR2I &aOrigin, const LSET &aLayers, const std::vector< BOARD_ITEM * > &aSkip={})
 
VECTOR2I GetGrid () const
 
VECTOR2I GetVisibleGrid () const
 
VECTOR2I GetOrigin () const
 
void SetAuxAxes (bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
 
virtual VECTOR2I Align (const VECTOR2I &aPoint) const
 
VECTOR2I AlignGrid (const VECTOR2I &aPoint) const
 
void SetSkipPoint (const VECTOR2I &aPoint)
 
void ClearSkipPoint ()
 We clear the skip point by setting it to an unreachable position, thereby preventing matching. More...
 
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. More...
 

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
 

Private Member Functions

std::set< BOARD_ITEM * > queryVisible (const BOX2I &aArea, const std::vector< BOARD_ITEM * > &aSkip) const
 
ANCHORnearestAnchor (const VECTOR2I &aPos, int aFlags, LSET aMatchLayers)
 
void computeAnchors (BOARD_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom=false, const SELECTION_FILTER_OPTIONS *aSelectionFilter=nullptr)
 computeAnchors inserts the local anchor points in to the grid helper for the specified board item, given the reference point and the direction of use for the point. More...
 

Private Attributes

MAGNETIC_SETTINGSm_magneticSettings
 

Detailed Description

Definition at line 35 of file pcb_grid_helper.h.

Member Enumeration Documentation

◆ ANCHOR_FLAGS

enum GRID_HELPER::ANCHOR_FLAGS
inherited
Enumerator
CORNER 
OUTLINE 
SNAPPABLE 
ORIGIN 
VERTICAL 
HORIZONTAL 
ALL 

Definition at line 77 of file grid_helper.h.

Constructor & Destructor Documentation

◆ PCB_GRID_HELPER()

Member Function Documentation

◆ addAnchor()

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

◆ Align()

◆ AlignGrid()

◆ AlignToArc()

VECTOR2I PCB_GRID_HELPER::AlignToArc ( const VECTOR2I aPoint,
const SHAPE_ARC aSeg 
)

◆ AlignToNearestPad()

VECTOR2I PCB_GRID_HELPER::AlignToNearestPad ( const VECTOR2I aMousePos,
PADS &  aPads 
)

◆ AlignToSegment()

VECTOR2I PCB_GRID_HELPER::AlignToSegment ( const VECTOR2I aPoint,
const SEG aSeg 
)

◆ BestDragOrigin()

◆ BestSnapAnchor() [1/2]

VECTOR2I PCB_GRID_HELPER::BestSnapAnchor ( const VECTOR2I aOrigin,
BOARD_ITEM aReferenceItem 
)

Chooses the "best" snap anchor around the given point, optionally taking layers from the reference item.

The reference item will not be snapped to (it is being dragged or created) and we choose the layers that can be snapped based on the reference item layer

Parameters
aOriginPoint we want to snap from
aReferenceItemReference item for layer/type special casing
Returns
snapped screen point

Definition at line 259 of file pcb_grid_helper.cpp.

References LSET::AllLayersMask(), BestSnapAnchor(), and BOARD_ITEM::GetLayerSet().

Referenced by BestSnapAnchor().

◆ BestSnapAnchor() [2/2]

◆ canUseGrid()

bool GRID_HELPER::canUseGrid ( ) const
inlineprotectedinherited

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 123 of file grid_helper.h.

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

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

◆ clearAnchors()

void GRID_HELPER::clearAnchors ( )
inlineprotectedinherited

◆ ClearMaskFlag()

void GRID_HELPER::ClearMaskFlag ( int  aFlag)
inlineinherited

Definition at line 75 of file grid_helper.h.

References GRID_HELPER::m_maskTypes.

◆ ClearSkipPoint()

void GRID_HELPER::ClearSkipPoint ( )
inlineinherited

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

Definition at line 60 of file grid_helper.h.

References GRID_HELPER::m_skipPoint.

◆ computeAnchors()

void PCB_GRID_HELPER::computeAnchors ( BOARD_ITEM aItem,
const VECTOR2I aRefPos,
bool  aFrom = false,
const SELECTION_FILTER_OPTIONS aSelectionFilter = nullptr 
)
private

computeAnchors inserts the local anchor points in to the grid helper for the specified board item, given the reference point and the direction of use for the point.

Parameters
aItemThe board item for which to compute the anchors
aRefPosThe point for which to compute the anchors (if used by the component)
aFromIs this for an anchor that is designating a source point (aFrom=true) or not

If we are getting a drag point, we don't want to center the edge of pads

Definition at line 416 of file pcb_grid_helper.cpp.

References SEG::A, GRID_HELPER::addAnchor(), ANGLE_90, SHAPE_LINE_CHAIN::Append(), SEG::B, SEG::Center(), BOX2< Vec >::Centre(), SHAPE_POLY_SET::CIterateWithHoles(), computeAnchors(), GRID_HELPER::CORNER, SELECTION_FILTER_OPTIONS::dimensions, EuclideanNorm(), SELECTION_FILTER_OPTIONS::footprints, FOOTPRINT::GetBoundingBox(), BOARD_ITEM::GetCenter(), PCB_DIM_ALIGNED::GetCrossbarEnd(), PCB_DIM_ALIGNED::GetCrossbarStart(), PCB_DIMENSION_BASE::GetEnd(), PCB_TRACK::GetEnd(), GRID_HELPER::GetGrid(), KIGFX::RENDER_SETTINGS::GetHighContrast(), KIGFX::RENDER_SETTINGS::GetHighContrastLayers(), PCB_DIM_RADIAL::GetKnee(), KIGFX::VIEW::GetPainter(), EDA_ITEM::GetPosition(), FOOTPRINT::GetPosition(), KIGFX::VIEW::GetScale(), SHAPE_LINE_CHAIN::GetSegment(), SHAPE_LINE_CHAIN::GetSegmentCount(), KIGFX::PAINTER::GetSettings(), PCB_DIMENSION_BASE::GetStart(), PCB_TRACK::GetStart(), EDA_TEXT::GetTextPos(), TOOL_MANAGER::GetView(), SELECTION_FILTER_OPTIONS::graphics, MAGNETIC_SETTINGS::graphics, grid, group, KIGFX::VIEW::IsVisible(), KI_FALLTHROUGH, m_magneticSettings, GRID_HELPER::m_toolMgr, SHAPE_LINE_CHAIN::Move(), SHAPE_LINE_CHAIN::NearestPoint(), normal, GRID_HELPER::ORIGIN, GRID_HELPER::OUTLINE, pad, SELECTION_FILTER_OPTIONS::pads, FOOTPRINT::Pads(), MAGNETIC_SETTINGS::pads, PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FOOTPRINT_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, SHAPE_LINE_CHAIN::Rotate(), RotatePoint(), SHAPE_LINE_CHAIN::SetClosed(), GRID_HELPER::SNAPPABLE, SELECTION_FILTER_OPTIONS::text, SELECTION_FILTER_OPTIONS::tracks, MAGNETIC_SETTINGS::tracks, EDA_ITEM::Type(), SELECTION_FILTER_OPTIONS::vias, VECTOR2< T >::x, VECTOR2< T >::y, and SELECTION_FILTER_OPTIONS::zones.

Referenced by AlignToNearestPad(), BestDragOrigin(), BestSnapAnchor(), and computeAnchors().

◆ GetGrid()

◆ GetOrigin()

VECTOR2I GRID_HELPER::GetOrigin ( ) const
inherited

◆ GetSnap()

bool GRID_HELPER::GetSnap ( ) const
inlineinherited

◆ GetSnapped()

BOARD_ITEM * PCB_GRID_HELPER::GetSnapped ( ) const

Function GetSnapped If the PCB_GRID_HELPER has highlighted a snap point (target shown), this function will return a pointer to the item to which it snapped.

Returns
NULL if not snapped. Pointer to snapped item otherwise

Definition at line 367 of file pcb_grid_helper.cpp.

References GRID_HELPER::ANCHOR::item, and GRID_HELPER::m_snapItem.

◆ GetUseGrid()

bool GRID_HELPER::GetUseGrid ( ) const
inlineinherited

Definition at line 69 of file grid_helper.h.

References GRID_HELPER::m_enableGrid.

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

◆ GetVisibleGrid()

VECTOR2I GRID_HELPER::GetVisibleGrid ( ) const
inherited

◆ nearestAnchor()

PCB_GRID_HELPER::ANCHOR * PCB_GRID_HELPER::nearestAnchor ( const VECTOR2I aPos,
int  aFlags,
LSET  aMatchLayers 
)
private

Definition at line 860 of file pcb_grid_helper.cpp.

References BOARD_ITEM::GetLayerSet(), and GRID_HELPER::m_anchors.

Referenced by BestDragOrigin(), and BestSnapAnchor().

◆ queryVisible()

◆ SetAuxAxes()

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

◆ SetMask()

void GRID_HELPER::SetMask ( int  aMask)
inlineinherited

Definition at line 73 of file grid_helper.h.

References GRID_HELPER::m_maskTypes.

◆ SetMaskFlag()

void GRID_HELPER::SetMaskFlag ( int  aFlag)
inlineinherited

Definition at line 74 of file grid_helper.h.

References GRID_HELPER::m_maskTypes.

◆ SetSkipPoint()

void GRID_HELPER::SetSkipPoint ( const VECTOR2I aPoint)
inlineinherited

Definition at line 52 of file grid_helper.h.

References GRID_HELPER::m_skipPoint.

◆ SetSnap()

◆ SetSnapLine()

void GRID_HELPER::SetSnapLine ( bool  aSnap)
inlineinherited

Definition at line 71 of file grid_helper.h.

References GRID_HELPER::m_enableSnapLine.

◆ SetUseGrid()

void GRID_HELPER::SetUseGrid ( bool  aSnapToGrid)
inlineinherited

Member Data Documentation

◆ m_anchors

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

◆ m_auxAxis

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

Definition at line 132 of file grid_helper.h.

Referenced by GRID_HELPER::Align(), and GRID_HELPER::SetAuxAxes().

◆ m_enableGrid

bool GRID_HELPER::m_enableGrid
protectedinherited

◆ m_enableSnap

bool GRID_HELPER::m_enableSnap
protectedinherited

◆ m_enableSnapLine

bool GRID_HELPER::m_enableSnapLine
protectedinherited

◆ m_magneticSettings

MAGNETIC_SETTINGS* PCB_GRID_HELPER::m_magneticSettings
private

Definition at line 89 of file pcb_grid_helper.h.

Referenced by computeAnchors().

◆ m_maskTypes

int GRID_HELPER::m_maskTypes
protectedinherited

◆ m_skipPoint

VECTOR2I GRID_HELPER::m_skipPoint
protectedinherited

◆ m_snapItem

◆ m_toolMgr

◆ m_viewAxis

KIGFX::ORIGIN_VIEWITEM GRID_HELPER::m_viewAxis
protectedinherited

◆ m_viewSnapLine

KIGFX::ORIGIN_VIEWITEM GRID_HELPER::m_viewSnapLine
protectedinherited

◆ m_viewSnapPoint

KIGFX::ORIGIN_VIEWITEM GRID_HELPER::m_viewSnapPoint
protectedinherited

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