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

Used when the right click button is pressed, or when the select tool is in effect. More...

#include <collectors.h>

Inheritance diagram for GENERAL_COLLECTOR:
PCB_COLLECTOR COLLECTOR

Public Types

using ITER = std::vector< EDA_ITEM * >::iterator
 
using CITER = std::vector< EDA_ITEM * >::const_iterator
 

Public Member Functions

 GENERAL_COLLECTOR ()
 
void Empty2nd ()
 
void Append2nd (EDA_ITEM *item)
 
void SetGuide (const COLLECTORS_GUIDE *aGuide)
 Record which COLLECTORS_GUIDE to use. More...
 
const COLLECTORS_GUIDEGetGuide () const
 
INSPECT_RESULT Inspect (EDA_ITEM *aTestItem, void *aTestData) override
 The examining function within the INSPECTOR which is passed to the Iterate function. More...
 
void Collect (BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
 Scan a BOARD_ITEM using this class's Inspector method, which does the collection. More...
 
BOARD_ITEMoperator[] (int ndx) const override
 Overload the COLLECTOR::operator[](int) to return a BOARD_ITEM instead of an EDA_ITEM. More...
 
ITER begin ()
 
CITER begin () const
 
ITER end ()
 
CITER end () const
 
int GetCount () const
 Return the number of objects in the list. More...
 
void Empty ()
 Clear the list. More...
 
void Append (EDA_ITEM *item)
 Add an item to the end of the list. More...
 
void Remove (int aIndex)
 Remove the item at aIndex (first position is 0). More...
 
void Remove (const EDA_ITEM *aItem)
 Remove the item aItem (if exists in the collector). More...
 
bool HasAdditionalItems ()
 Test if the collector has heuristic backup items. More...
 
void Combine ()
 Re-combine the backup list into the main list of the collector. More...
 
void Transfer (int aIndex)
 Move the item at aIndex (first position is 0) to the backup list. More...
 
void Transfer (EDA_ITEM *aItem)
 Move aItem (if exists in the collector) to the backup list. More...
 
bool HasItem (const EDA_ITEM *aItem) const
 Tests if aItem has already been collected. More...
 
void SetScanTypes (const std::vector< KICAD_T > &aTypes)
 Record the list of KICAD_T types to consider for collection by the Inspect() function. More...
 
void SetRefPos (const VECTOR2I &aRefPos)
 
int CountType (KICAD_T aType)
 Count the number of items matching aType. More...
 

Public Attributes

int m_Threshold
 
wxString m_MenuTitle
 
bool m_MenuCancelled
 

Static Public Attributes

static const std::vector< KICAD_TAllBoardItems
 A scan list for all editable board items. More...
 
static const std::vector< KICAD_TZones
 A scan list for zones outlines only. More...
 
static const std::vector< KICAD_TBoardLevelItems
 A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT, such as PAD and PCB_TEXT. More...
 
static const std::vector< KICAD_TFootprints
 A scan list for only FOOTPRINTs. More...
 
static const std::vector< KICAD_TPadsOrTracks
 A scan list for PADs, TRACKs, or VIAs. More...
 
static const std::vector< KICAD_TFootprintItems
 A scan list for primary footprint items. More...
 
static const std::vector< KICAD_TTracks
 A scan list for only TRACKs and ARCs. More...
 
static const std::vector< KICAD_TDimensions
 A scan list for dimensions. More...
 
static const std::vector< KICAD_TDraggableItems
 A scan list for items that can be dragged. More...
 

Protected Attributes

std::vector< EDA_ITEM * > m_List2nd
 A place to hold collected objects which don't match precisely the search criteria, but would be acceptable if nothing else is found. More...
 
const COLLECTORS_GUIDEm_Guide
 Determine which items are to be collected by Inspect(). More...
 
std::vector< EDA_ITEM * > m_list
 
std::vector< EDA_ITEM * > m_backupList
 
std::vector< KICAD_Tm_scanTypes
 
INSPECTOR_FUNC m_inspector
 
VECTOR2I m_refPos
 

Detailed Description

Used when the right click button is pressed, or when the select tool is in effect.

This class can be used by window classes such as PCB_EDIT_FRAME.

Philosophy: this class knows nothing of the context in which a BOARD is used and that means it knows nothing about which layers are visible or current, but can handle those concerns by the SetPreferredLayer() function and the SetLayerSet() function.

Definition at line 205 of file collectors.h.

Member Typedef Documentation

◆ CITER

using COLLECTOR::CITER = std::vector<EDA_ITEM*>::const_iterator
inherited

Definition at line 71 of file collector.h.

◆ ITER

using COLLECTOR::ITER = std::vector<EDA_ITEM*>::iterator
inherited

Definition at line 70 of file collector.h.

Constructor & Destructor Documentation

◆ GENERAL_COLLECTOR()

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Definition at line 269 of file collectors.h.

References AllBoardItems, and COLLECTOR::SetScanTypes().

Member Function Documentation

◆ Append()

◆ Append2nd()

void GENERAL_COLLECTOR::Append2nd ( EDA_ITEM item)
inline

Definition at line 280 of file collectors.h.

References m_List2nd.

Referenced by Inspect().

◆ begin() [1/2]

ITER COLLECTOR::begin ( )
inlineinherited

Definition at line 73 of file collector.h.

References COLLECTOR::m_list.

◆ begin() [2/2]

CITER COLLECTOR::begin ( ) const
inlineinherited

Definition at line 75 of file collector.h.

References COLLECTOR::m_list.

◆ Collect()

void GENERAL_COLLECTOR::Collect ( BOARD_ITEM aItem,
const std::vector< KICAD_T > &  aScanList,
const VECTOR2I aRefPos,
const COLLECTORS_GUIDE aGuide 
)

Scan a BOARD_ITEM using this class's Inspector method, which does the collection.

Parameters
aItemA BOARD_ITEM to scan, may be a BOARD or FOOTPRINT, or whatever.
aScanListA list of KICAD_Ts that specs what is to be collected and the priority order of the resultant collection in "m_list".
aRefPosA wxPoint to use in hit-testing.
aGuideThe COLLECTORS_GUIDE to use in collecting items.

Definition at line 474 of file collectors.cpp.

References COLLECTOR::Append(), COLLECTOR::Empty(), Empty2nd(), COLLECTOR::m_inspector, m_List2nd, COLLECTOR::m_scanTypes, SetGuide(), COLLECTOR::SetRefPos(), COLLECTOR::SetScanTypes(), and EDA_ITEM::Visit().

Referenced by PAD_TOOL::EnumeratePads(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_CONTROL::InteractiveDelete(), DRAWING_TOOL::PlaceTuningPattern(), PCB_SELECTION_TOOL::selectAllConnectedShapes(), and PCB_SELECTION_TOOL::selectPoint().

◆ Combine()

void COLLECTOR::Combine ( )
inlineinherited

Re-combine the backup list into the main list of the collector.

Definition at line 140 of file collector.h.

References COLLECTOR::m_backupList, and COLLECTOR::m_list.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ CountType()

int COLLECTOR::CountType ( KICAD_T  aType)
inlineinherited

Count the number of items matching aType.

Parameters
aTypetype we are interested in.
Returns
number of occurrences.

Definition at line 221 of file collector.h.

References COLLECTOR::m_list.

Referenced by ROUTER_TOOL::NeighboringSegmentFilter().

◆ Empty()

◆ Empty2nd()

void GENERAL_COLLECTOR::Empty2nd ( )
inline

Definition at line 275 of file collectors.h.

References m_List2nd.

Referenced by Collect().

◆ end() [1/2]

ITER COLLECTOR::end ( )
inlineinherited

Definition at line 74 of file collector.h.

References COLLECTOR::m_list.

◆ end() [2/2]

CITER COLLECTOR::end ( ) const
inlineinherited

Definition at line 76 of file collector.h.

References COLLECTOR::m_list.

◆ GetCount()

int COLLECTOR::GetCount ( ) const
inlineinherited

Return the number of objects in the list.

Definition at line 81 of file collector.h.

References COLLECTOR::m_list.

Referenced by BOARD_EDITOR_CONTROL::AssignNetclass(), EDIT_TOOL::BooleanPolygons(), BuildBoardPolygonOutlines(), BuildFootprintPolygonOutlines(), EDIT_TOOL::ChangeTrackWidth(), EE_SELECTION_TOOL::CollectHits(), connectedItemFilter(), EDIT_TOOL::copyToClipboard(), FOOTPRINT::CoverageRatio(), CONVERT_TOOL::CreateLines(), BOARD_INSPECTION_TOOL::DiffFootprint(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::Drag(), PAD_TOOL::EnumeratePads(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::FilterCollectedItems(), PCB_SELECTION_TOOL::FilterCollectorForFootprints(), PCB_SELECTION_TOOL::FilterCollectorForFreePads(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), PCB_SELECTION_TOOL::FilterCollectorForMarkers(), EDIT_TOOL::FootprintFilter(), EE_SELECTION_TOOL::GetNode(), PANEL_SETUP_LAYERS::getNonRemovableLayers(), PANEL_SETUP_LAYERS::getRemovedLayersWithItems(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), GENDRILL_WRITER_BASE::getUniqueLayerPairs(), GROUP_TOOL::Group(), PL_SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), EDIT_TOOL::HealShapes(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_EDIT_FRAME::inferLegacyEdgeClearance(), SCH_EDIT_TOOL::InteractiveDelete(), PCB_CONTROL::InteractiveDelete(), EE_COLLECTOR::IsCorner(), EE_SELECTION_TOOL::Main(), DSN::SPECCTRA_DB::makeIMAGE(), EDIT_TOOL::ModifyLines(), EE_SELECTION_TOOL::narrowSelection(), ROUTER_TOOL::NeighboringSegmentFilter(), COLLECTOR::operator[](), EE_COLLECTOR::operator[](), GERBER_COLLECTOR::operator[](), PCB_COLLECTOR::operator[](), EDIT_TOOL::PackAndMoveFootprints(), EDIT_TOOL::PadFilter(), DRAWING_TOOL::PlaceTuningPattern(), PCB_SELECTION_TOOL::pruneObscuredSelectionCandidates(), GENERATOR_TOOL::RegenerateSelected(), CONVERT_TOOL::SegmentToArc(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), SCH_EDITOR_CONTROL::SimProbe(), SCH_EDITOR_CONTROL::SimTune(), EDIT_TOOL::Swap(), TestBoardOutlinesGraphicItems(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ GetGuide()

const COLLECTORS_GUIDE * GENERAL_COLLECTOR::GetGuide ( ) const
inline

◆ HasAdditionalItems()

bool COLLECTOR::HasAdditionalItems ( )
inlineinherited

Test if the collector has heuristic backup items.

Returns
true if Combine() can run to bring secondary items into the list.

Definition at line 132 of file collector.h.

References COLLECTOR::m_backupList.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ HasItem()

bool COLLECTOR::HasItem ( const EDA_ITEM aItem) const
inlineinherited

Tests if aItem has already been collected.

Parameters
aItemThe EDA_ITEM* to be tested.
Returns
True if aItem is already collected.

Definition at line 195 of file collector.h.

References COLLECTOR::m_list.

Referenced by EE_SELECTION_TOOL::CollectHits(), PCB_SELECTION_TOOL::FilterCollectorForFreePads(), and PCB_SELECTION_TOOL::FilterCollectorForHierarchy().

◆ Inspect()

INSPECT_RESULT GENERAL_COLLECTOR::Inspect ( EDA_ITEM aTestItem,
void *  aTestData 
)
overridevirtual

The examining function within the INSPECTOR which is passed to the Iterate function.

Search and collect all the objects which match the test data.

Parameters
testItemAn EDA_ITEM to examine.
aTestDatais not used in this class.
Returns
SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE

Reimplemented from COLLECTOR.

Definition at line 141 of file collectors.cpp.

References COLLECTORS_GUIDE::Accuracy(), COLLECTOR::Append(), Append2nd(), B_Cu, F_Cu, BOARD_ITEM::GetLayer(), ZONE::GetLayerSet(), BOARD_ITEM::GetParentFootprint(), COLLECTORS_GUIDE::GetPreferredLayer(), FOOTPRINT::GetSide(), group, EDA_ITEM::HitTest(), FOOTPRINT::HitTest(), PCB_MARKER::HitTest(), FOOTPRINT::HitTestAccurate(), ZONE::HitTestFilledArea(), ZONE::HitTestForCorner(), ZONE::HitTestForEdge(), COLLECTORS_GUIDE::IgnoreBlindBuriedVias(), COLLECTORS_GUIDE::IgnoreFootprintsOnBack(), COLLECTORS_GUIDE::IgnoreFootprintsOnFront(), COLLECTORS_GUIDE::IgnoreFPReferences(), COLLECTORS_GUIDE::IgnoreFPTextOnBack(), COLLECTORS_GUIDE::IgnoreFPTextOnFront(), COLLECTORS_GUIDE::IgnoreFPValues(), COLLECTORS_GUIDE::IgnoreHiddenFPText(), COLLECTORS_GUIDE::IgnoreLockedItems(), COLLECTORS_GUIDE::IgnoreMicroVias(), COLLECTORS_GUIDE::IgnorePads(), COLLECTORS_GUIDE::IgnorePadsOnBack(), COLLECTORS_GUIDE::IgnorePadsOnFront(), COLLECTORS_GUIDE::IgnoreThroughVias(), COLLECTORS_GUIDE::IgnoreTracks(), COLLECTORS_GUIDE::IgnoreZoneFills(), COLLECTORS_GUIDE::IncludeSecondary(), IsBackLayer(), IsFrontLayer(), COLLECTORS_GUIDE::IsLayerVisible(), BOARD_ITEM::IsLocked(), BOARD_ITEM::IsOnLayer(), PCB_FIELD::IsReference(), PCB_FIELD::IsValue(), KI_FALLTHROUGH, KiROUND(), m_Guide, COLLECTOR::m_refPos, pad, PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FIELD_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, LSET::Seq(), text, EDA_ITEM::Type(), and via.

◆ operator[]()

BOARD_ITEM * PCB_COLLECTOR::operator[] ( int  ndx) const
inlineoverridevirtualinherited

Overload the COLLECTOR::operator[](int) to return a BOARD_ITEM instead of an EDA_ITEM.

Parameters
ndxThe index into the list.
Returns
a board item or NULL.

Reimplemented from COLLECTOR.

Definition at line 187 of file collectors.h.

References COLLECTOR::GetCount(), and COLLECTOR::m_list.

◆ Remove() [1/2]

void COLLECTOR::Remove ( const EDA_ITEM aItem)
inlineinherited

Remove the item aItem (if exists in the collector).

Parameters
aItemthe item to be removed.

Definition at line 119 of file collector.h.

References alg::delete_if(), and COLLECTOR::m_list.

◆ Remove() [2/2]

◆ SetGuide()

void GENERAL_COLLECTOR::SetGuide ( const COLLECTORS_GUIDE aGuide)
inline

Record which COLLECTORS_GUIDE to use.

Parameters
aGuideWhich guide to use in the collection.

Definition at line 290 of file collectors.h.

References m_Guide.

Referenced by Collect(), and PCB_SELECTION_TOOL::RequestSelection().

◆ SetRefPos()

void COLLECTOR::SetRefPos ( const VECTOR2I aRefPos)
inlineinherited

Definition at line 213 of file collector.h.

References COLLECTOR::m_refPos.

Referenced by Collect(), GERBER_COLLECTOR::Collect(), and EE_COLLECTOR::Collect().

◆ SetScanTypes()

void COLLECTOR::SetScanTypes ( const std::vector< KICAD_T > &  aTypes)
inlineinherited

Record the list of KICAD_T types to consider for collection by the Inspect() function.

Parameters
aScanTypesA list of KICAD_Ts.

Definition at line 211 of file collector.h.

References COLLECTOR::m_scanTypes.

Referenced by Collect(), GERBER_COLLECTOR::Collect(), EE_COLLECTOR::Collect(), GENERAL_COLLECTOR(), and GERBER_COLLECTOR::GERBER_COLLECTOR().

◆ Transfer() [1/2]

void COLLECTOR::Transfer ( EDA_ITEM aItem)
inlineinherited

Move aItem (if exists in the collector) to the backup list.

Parameters
aItemthe item to be moved.

Definition at line 162 of file collector.h.

References COLLECTOR::m_backupList, and COLLECTOR::m_list.

◆ Transfer() [2/2]

void COLLECTOR::Transfer ( int  aIndex)
inlineinherited

Move the item at aIndex (first position is 0) to the backup list.

Parameters
aIndexThe index into the list.

Definition at line 151 of file collector.h.

References COLLECTOR::m_backupList, and COLLECTOR::m_list.

Referenced by PL_SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), and PCB_SELECTION_TOOL::GuessSelectionCandidates().

Member Data Documentation

◆ AllBoardItems

const std::vector< KICAD_T > GENERAL_COLLECTOR::AllBoardItems
static
Initial value:
= {
}
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:100
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition: typeinfo.h:91
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:95
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:101
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:105
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:97
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:99
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:96
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:94
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:102

A scan list for all editable board items.

Definition at line 226 of file collectors.h.

Referenced by GENERAL_COLLECTOR(), PCB_EDIT_FRAME::inferLegacyEdgeClearance(), PCB_CONTROL::Paste(), PCB_SELECTION_TOOL::RebuildSelection(), and PCB_SELECTION_TOOL::selectPoint().

◆ BoardLevelItems

◆ Dimensions

const std::vector< KICAD_T > GENERAL_COLLECTOR::Dimensions
static
Initial value:

A scan list for dimensions.

Definition at line 262 of file collectors.h.

◆ DraggableItems

const std::vector< KICAD_T > GENERAL_COLLECTOR::DraggableItems
static
Initial value:

A scan list for items that can be dragged.

Definition at line 267 of file collectors.h.

Referenced by ROUTER_TOOL::CanInlineDrag(), and EDIT_TOOL::Init().

◆ FootprintItems

◆ Footprints

const std::vector< KICAD_T > GENERAL_COLLECTOR::Footprints
static
Initial value:

A scan list for only FOOTPRINTs.

Definition at line 242 of file collectors.h.

◆ m_backupList

std::vector<EDA_ITEM*> COLLECTOR::m_backupList
protectedinherited

◆ m_Guide

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::m_Guide
protected

Determine which items are to be collected by Inspect().

Definition at line 219 of file collectors.h.

Referenced by GetGuide(), Inspect(), and SetGuide().

◆ m_inspector

INSPECTOR_FUNC COLLECTOR::m_inspector
protectedinherited

◆ m_list

◆ m_List2nd

std::vector<EDA_ITEM*> GENERAL_COLLECTOR::m_List2nd
protected

A place to hold collected objects which don't match precisely the search criteria, but would be acceptable if nothing else is found.

"2nd" choice, which will be appended to the end of COLLECTOR's prime "list" at the end of the search.

Definition at line 214 of file collectors.h.

Referenced by Append2nd(), Collect(), and Empty2nd().

◆ m_MenuCancelled

bool COLLECTOR::m_MenuCancelled
inherited

◆ m_MenuTitle

wxString COLLECTOR::m_MenuTitle
inherited

Definition at line 236 of file collector.h.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ m_refPos

VECTOR2I COLLECTOR::m_refPos
protectedinherited

◆ m_scanTypes

std::vector<KICAD_T> COLLECTOR::m_scanTypes
protectedinherited

◆ m_Threshold

◆ PadsOrTracks

const std::vector< KICAD_T > GENERAL_COLLECTOR::PadsOrTracks
static
Initial value:

A scan list for PADs, TRACKs, or VIAs.

Definition at line 247 of file collectors.h.

◆ Tracks

const std::vector< KICAD_T > GENERAL_COLLECTOR::Tracks
static
Initial value:

A scan list for only TRACKs and ARCs.

Definition at line 257 of file collectors.h.

Referenced by BOARD::TracksInNet().

◆ Zones

const std::vector<KICAD_T> GENERAL_COLLECTOR::Zones
static

A scan list for zones outlines only.

Definition at line 231 of file collectors.h.


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