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

#include <ee_grid_helper.h>

Inheritance diagram for EE_GRID_HELPER:
GRID_HELPER

Public Types

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

Public Member Functions

 EE_GRID_HELPER ()
 
 EE_GRID_HELPER (TOOL_MANAGER *aToolMgr)
 
 ~EE_GRID_HELPER () override
 
SCH_ITEMGetSnapped () const
 Function GetSnapped If the EE_GRID_HELPER has highlighted a snap point (target shown), this function will return a pointer to the item to which it snapped.
 
VECTOR2D GetGridSize (GRID_HELPER_GRIDS aGrid) const override
 Return the size of the specified grid.
 
GRID_HELPER_GRIDS GetSelectionGrid (const SELECTION &aItem) const override
 Gets the coarsest grid that applies to a selecion of items.
 
GRID_HELPER_GRIDS GetItemGrid (const EDA_ITEM *aItem) const override
 Get the coarsest grid that applies to an item.
 
VECTOR2I BestDragOrigin (const VECTOR2I &aMousePos, GRID_HELPER_GRIDS aGrid, const SCH_SELECTION &aItems)
 
VECTOR2I BestSnapAnchor (const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM *aSkip)
 
VECTOR2I BestSnapAnchor (const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, const SCH_SELECTION &aSkip={})
 
VECTOR2I GetGrid () const
 
VECTOR2D GetVisibleGrid () const
 
VECTOR2I GetOrigin () const
 
void SetGridSize (const VECTOR2D &aGrid)
 
void SetVisibleGridSize (const VECTOR2D &aGrid)
 
void SetOrigin (const VECTOR2I &aOrigin)
 
void SetGridSnapping (bool aEnable)
 
void SetAuxAxes (bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
 
virtual VECTOR2I Align (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
 
virtual VECTOR2I AlignGrid (const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
 
VECTOR2I AlignGrid (const VECTOR2I &aPoint) const
 
VECTOR2I AlignGrid (const VECTOR2I &aPoint, const VECTOR2D &aGrid) const
 
void SetSkipPoint (const VECTOR2I &aPoint)
 
void ClearSkipPoint ()
 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)
 
std::optional< VECTOR2IGetSnappedPoint () const
 

Protected Member Functions

void addAnchor (const VECTOR2I &aPos, int aFlags, EDA_ITEM *aItem, int aPointTypes=POINT_TYPE::PT_NONE)
 
void addAnchor (const VECTOR2I &aPos, int aFlags, std::vector< EDA_ITEM * > aItems, int aPointTypes)
 
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
 
void showConstructionGeometry (bool aShow)
 
SNAP_MANAGERgetSnapManager ()
 
void updateSnapPoint (const TYPED_POINT2I &aPoint)
 
KIGFX::ANCHOR_DEBUGenableAndGetAnchorDebug ()
 Enable the anchor debug if permitted and return it.
 

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
 
std::optional< ANCHORm_snapItem
 
VECTOR2I m_skipPoint
 
KIGFX::SNAP_INDICATOR m_viewSnapPoint
 
KIGFX::ORIGIN_VIEWITEM m_viewAxis
 
VECTOR2D m_manualGrid
 
VECTOR2D m_manualVisibleGrid
 
VECTOR2I m_manualOrigin
 
bool m_manualGridSnapping
 

Private Member Functions

std::set< SCH_ITEM * > queryVisible (const BOX2I &aArea, const SCH_SELECTION &aSkipList) const
 
ANCHORnearestAnchor (const VECTOR2I &aPos, int aFlags, GRID_HELPER_GRIDS aGrid)
 
void computeAnchors (SCH_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom=false, bool aIncludeText=false)
 Insert the local anchor points in to the grid helper for the specified schematic item, given the reference point and the direction of use for the point.
 

Private Attributes

KIGFX::CONSTRUCTION_GEOM m_constructionGeomPreview
 Show construction geometry (if any) on the canvas.
 
SNAP_MANAGER m_snapManager
 Manage the construction geometry, snap lines, reference points, etc.
 
std::unique_ptr< KIGFX::ANCHOR_DEBUGm_anchorDebug
 #VIEW_ITEM for visualising anchor points, if enabled.
 

Detailed Description

Definition at line 37 of file ee_grid_helper.h.

Member Enumeration Documentation

◆ ANCHOR_FLAGS

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

Definition at line 132 of file grid_helper.h.

Constructor & Destructor Documentation

◆ EE_GRID_HELPER() [1/2]

EE_GRID_HELPER::EE_GRID_HELPER ( )

Definition at line 42 of file ee_grid_helper.cpp.

◆ EE_GRID_HELPER() [2/2]

◆ ~EE_GRID_HELPER()

EE_GRID_HELPER::~EE_GRID_HELPER ( )
override

Member Function Documentation

◆ addAnchor() [1/2]

void GRID_HELPER::addAnchor ( const VECTOR2I aPos,
int  aFlags,
EDA_ITEM aItem,
int  aPointTypes = POINT_TYPE::PT_NONE 
)
inlineprotectedinherited

◆ addAnchor() [2/2]

void GRID_HELPER::addAnchor ( const VECTOR2I aPos,
int  aFlags,
std::vector< EDA_ITEM * >  aItems,
int  aPointTypes 
)
inlineprotectedinherited

Definition at line 191 of file grid_helper.h.

References GRID_HELPER::m_anchors, and GRID_HELPER::m_maskTypes.

◆ Align() [1/3]

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

Reimplemented in PCB_GRID_HELPER.

Definition at line 238 of file grid_helper.cpp.

References GRID_HELPER::Align(), and GRID_HELPER::GetGrid().

◆ Align() [2/3]

VECTOR2I GRID_HELPER::Align ( const VECTOR2I aPoint,
const VECTOR2D aGrid 
) const
virtualinherited

◆ Align() [3/3]

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

◆ AlignGrid() [1/3]

VECTOR2I GRID_HELPER::AlignGrid ( const VECTOR2I aPoint) const
inherited

Definition at line 219 of file grid_helper.cpp.

References GRID_HELPER::computeNearest(), and GRID_HELPER::GetGrid().

◆ AlignGrid() [2/3]

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

Definition at line 225 of file grid_helper.cpp.

References GRID_HELPER::computeNearest().

◆ AlignGrid() [3/3]

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

◆ BestDragOrigin()

◆ BestSnapAnchor() [1/2]

◆ BestSnapAnchor() [2/2]

VECTOR2I EE_GRID_HELPER::BestSnapAnchor ( const VECTOR2I aOrigin,
GRID_HELPER_GRIDS  aGrid,
SCH_ITEM aSkip 
)

Definition at line 143 of file ee_grid_helper.cpp.

References SELECTION::Add(), and BestSnapAnchor().

Referenced by SCH_SELECTION_TOOL::autostartEvent(), and BestSnapAnchor().

◆ canUseGrid()

bool GRID_HELPER::canUseGrid ( ) const
protectedinherited

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 264 of file grid_helper.cpp.

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

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

◆ clearAnchors()

void GRID_HELPER::clearAnchors ( )
inlineprotectedinherited

◆ ClearMaskFlag()

void GRID_HELPER::ClearMaskFlag ( int  aFlag)
inlineinherited

Definition at line 128 of file grid_helper.h.

References GRID_HELPER::m_maskTypes.

Referenced by BOOST_AUTO_TEST_CASE().

◆ ClearSkipPoint()

void GRID_HELPER::ClearSkipPoint ( )
inlineinherited

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

Definition at line 113 of file grid_helper.h.

References GRID_HELPER::m_skipPoint.

Referenced by BOOST_AUTO_TEST_CASE().

◆ computeAnchors()

void EE_GRID_HELPER::computeAnchors ( SCH_ITEM aItem,
const VECTOR2I aRefPos,
bool  aFrom = false,
bool  aIncludeText = false 
)
private

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

Parameters
aItemThe schematic item for which to compute the anchors
aRefPosThe point for which to compute the anchors (if used by the symbol)
aFromIs this for an anchor that is designating a source point (aFrom=true) or not
aIncludeTextif true will compute anchors for text items

Definition at line 468 of file ee_grid_helper.cpp.

References GRID_HELPER::addAnchor(), GRID_HELPER::Align(), computeAnchors(), GRID_HELPER::CORNER, SCH_ITEM::GetConnectionPoints(), SCH_LINE::GetEndPoint(), EDA_ITEM::GetPosition(), SCH_LINE::GetStartPoint(), GRID_HELPER::HORIZONTAL, KI_FALLTHROUGH, GRID_HELPER::ORIGIN, pin, SCH_BUS_WIRE_ENTRY_T, SCH_DIRECTIVE_LABEL_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_GROUP_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_PIN_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TABLE_T, SCH_TABLECELL_T, SCH_TEXT_T, SCH_TEXTBOX_T, GRID_HELPER::SNAPPABLE, TestSegmentHit(), EDA_ITEM::Type(), GRID_HELPER::VERTICAL, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ computeNearest()

VECTOR2I GRID_HELPER::computeNearest ( const VECTOR2I aPoint,
const VECTOR2I aGrid 
) const
protectedinherited

Definition at line 231 of file grid_helper.cpp.

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

Referenced by GRID_HELPER::AlignGrid().

◆ enableAndGetAnchorDebug()

KIGFX::ANCHOR_DEBUG * GRID_HELPER::enableAndGetAnchorDebug ( )
protectedinherited

Enable the anchor debug if permitted and return it.

Returns nullptr if not permitted by the advancd config

Definition at line 112 of file grid_helper.cpp.

References KIGFX::VIEW::Add(), ADVANCED_CFG::GetCfg(), TOOL_MANAGER::GetView(), GRID_HELPER::m_anchorDebug, ADVANCED_CFG::m_EnableSnapAnchorsDebug, GRID_HELPER::m_toolMgr, and KIGFX::VIEW::SetVisible().

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

◆ GetGrid()

VECTOR2I GRID_HELPER::GetGrid ( ) const

◆ GetGridSize()

VECTOR2D EE_GRID_HELPER::GetGridSize ( GRID_HELPER_GRIDS  aGrid) const
overridevirtual

◆ GetItemGrid()

◆ GetOrigin()

VECTOR2I GRID_HELPER::GetOrigin ( ) const
inherited

◆ GetSelectionGrid()

GRID_HELPER_GRIDS EE_GRID_HELPER::GetSelectionGrid ( const SELECTION aSelection) const
overridevirtual

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

Reimplemented from GRID_HELPER.

Definition at line 380 of file ee_grid_helper.cpp.

References SELECTION::Front(), GetGridSize(), GetItemGrid(), and grid.

◆ GetSnap()

bool GRID_HELPER::GetSnap ( ) const
inlineinherited

◆ getSnapManager()

◆ GetSnapped()

SCH_ITEM * EE_GRID_HELPER::GetSnapped ( ) const

Function GetSnapped If the EE_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 325 of file ee_grid_helper.cpp.

References GRID_HELPER::m_snapItem.

◆ GetSnappedPoint()

std::optional< VECTOR2I > GRID_HELPER::GetSnappedPoint ( ) const
inherited

◆ GetUseGrid()

bool GRID_HELPER::GetUseGrid ( ) const
inlineinherited

Definition at line 122 of file grid_helper.h.

References GRID_HELPER::m_enableGrid.

Referenced by BOOST_AUTO_TEST_CASE(), and PNS::TOOL_BASE::updateStartItem().

◆ GetVisibleGrid()

◆ nearestAnchor()

EE_GRID_HELPER::ANCHOR * EE_GRID_HELPER::nearestAnchor ( const VECTOR2I aPos,
int  aFlags,
GRID_HELPER_GRIDS  aGrid 
)
private

◆ queryVisible()

◆ SetAuxAxes()

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

◆ SetGridSize()

void GRID_HELPER::SetGridSize ( const VECTOR2D aGrid)
inlineinherited

◆ SetGridSnapping()

void GRID_HELPER::SetGridSnapping ( bool  aEnable)
inlineinherited

◆ SetMask()

void GRID_HELPER::SetMask ( int  aMask)
inlineinherited

Definition at line 126 of file grid_helper.h.

References GRID_HELPER::m_maskTypes.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SetMaskFlag()

void GRID_HELPER::SetMaskFlag ( int  aFlag)
inlineinherited

Definition at line 127 of file grid_helper.h.

References GRID_HELPER::m_maskTypes.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SetOrigin()

void GRID_HELPER::SetOrigin ( const VECTOR2I aOrigin)
inlineinherited

◆ SetSkipPoint()

void GRID_HELPER::SetSkipPoint ( const VECTOR2I aPoint)
inlineinherited

Definition at line 105 of file grid_helper.h.

References GRID_HELPER::m_skipPoint.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SetSnap()

◆ SetSnapLine()

void GRID_HELPER::SetSnapLine ( bool  aSnap)
inlineinherited

Definition at line 124 of file grid_helper.h.

References GRID_HELPER::m_enableSnapLine.

◆ SetUseGrid()

void GRID_HELPER::SetUseGrid ( bool  aSnapToGrid)
inlineinherited

◆ SetVisibleGridSize()

void GRID_HELPER::SetVisibleGridSize ( const VECTOR2D aGrid)
inlineinherited

Definition at line 68 of file grid_helper.h.

References GRID_HELPER::m_manualVisibleGrid.

Referenced by BOOST_AUTO_TEST_CASE().

◆ showConstructionGeometry()

void GRID_HELPER::showConstructionGeometry ( bool  aShow)
protectedinherited

◆ updateSnapPoint()

Member Data Documentation

◆ m_anchorDebug

std::unique_ptr<KIGFX::ANCHOR_DEBUG> GRID_HELPER::m_anchorDebug
privateinherited

#VIEW_ITEM for visualising anchor points, if enabled.

Definition at line 256 of file grid_helper.h.

Referenced by GRID_HELPER::enableAndGetAnchorDebug(), and GRID_HELPER::~GRID_HELPER().

◆ m_anchors

◆ m_auxAxis

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

Definition at line 228 of file grid_helper.h.

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

◆ m_constructionGeomPreview

KIGFX::CONSTRUCTION_GEOM GRID_HELPER::m_constructionGeomPreview
privateinherited

Show construction geometry (if any) on the canvas.

Definition at line 250 of file grid_helper.h.

Referenced by GetGrid(), GRID_HELPER::showConstructionGeometry(), and GRID_HELPER::~GRID_HELPER().

◆ m_enableGrid

bool GRID_HELPER::m_enableGrid
protectedinherited

◆ m_enableSnap

◆ m_enableSnapLine

bool GRID_HELPER::m_enableSnapLine
protectedinherited

◆ m_manualGrid

VECTOR2D GRID_HELPER::m_manualGrid
protectedinherited

◆ m_manualGridSnapping

bool GRID_HELPER::m_manualGridSnapping
protectedinherited

◆ m_manualOrigin

VECTOR2I GRID_HELPER::m_manualOrigin
protectedinherited

◆ m_manualVisibleGrid

VECTOR2D GRID_HELPER::m_manualVisibleGrid
protectedinherited

◆ m_maskTypes

int GRID_HELPER::m_maskTypes
protectedinherited

◆ m_skipPoint

VECTOR2I GRID_HELPER::m_skipPoint
protectedinherited

◆ m_snapItem

◆ m_snapManager

SNAP_MANAGER GRID_HELPER::m_snapManager
privateinherited

Manage the construction geometry, snap lines, reference points, etc.

Definition at line 253 of file grid_helper.h.

Referenced by GRID_HELPER::getSnapManager().

◆ m_toolMgr

◆ m_viewAxis

◆ m_viewSnapPoint


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