KiCad PCB EDA Suite
Loading...
Searching...
No Matches
collectors.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef COLLECTORS_H
22#define COLLECTORS_H
23
24/*
25 * This module contains a number of COLLECTOR implementations which are used
26 * to augment the functionality of class PCB_EDIT_FRAME.
27 */
28
29#include <collector.h>
30#include <layer_ids.h> // LAYER_COUNT, layer defs
31#include <lset.h>
32#include <view/view.h>
33#include <board_item.h>
34
37 * should be collected (aside from HitTest()ing and KICAD_T scanTypes, which are provided to the
38 * GENERAL_COLLECTOR through attributes or arguments separately).
39 * <p>
40 * A justification for this class is to keep the structural storage details of the program's
41 * "configuration options" out of GENERAL_COLLECTOR::Inspect(). This class carries all the
42 * necessary details with it into the Inspect() call. The constructors or other functions of this
43 * class's derivatives are then the only place where knowledge of the specific structure of the
44 * global preference storage is needed. Thus, GENERAL_COLLECTOR::Inspect() can be kept as simple
45 * as possible, and insulated from changes in global preference storage.
46 * </p>
47 * This class introduces the notion of layer locking.
48 */
50{
51public:
52 virtual ~COLLECTORS_GUIDE() {}
53
57 virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
58
62 virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
63
65 * @return true if should ignore locked items, else false.
66 */
67 virtual bool IgnoreLockedItems() const = 0;
68
74 virtual bool IncludeSecondary() const = 0;
75
79 virtual bool IgnoreFPTextOnBack() const = 0;
80
84 virtual bool IgnoreFPTextOnFront() const = 0;
85
88
89 virtual bool IgnoreFootprintsOnBack() const = 0;
93
94 virtual bool IgnoreFootprintsOnFront() const = 0;
99 virtual bool IgnorePadsOnBack() const = 0;
100
101
103 */
104 virtual bool IgnorePadsOnFront() const = 0;
105
109 virtual bool IgnoreThroughHolePads() const = 0;
110
114 virtual bool IgnorePads() const
115 {
117 }
118
122 virtual bool IgnoreFPValues() const = 0;
123
125 * @return true if should ignore footprint references.
126 */
127 virtual bool IgnoreFPReferences() const = 0;
128
130
132 virtual bool IgnoreThroughVias() const = 0;
133
137 virtual bool IgnoreBlindBuriedVias() const = 0;
138
139
141 */
142 virtual bool IgnoreMicroVias() const = 0;
143
147 virtual bool IgnoreTracks() const = 0;
148
152 virtual bool IgnoreZoneFills() const = 0;
153
157 virtual bool IgnoreNoNets() const = 0;
158
159 virtual int Accuracy() const = 0;
160
161 virtual double OnePixelInIU() const = 0;
162};
163
164
165
176{
177public:
184 BOARD_ITEM* operator[]( int ndx ) const override
185 {
186 if( (unsigned)ndx < (unsigned)GetCount() )
187 return (BOARD_ITEM*) m_list[ ndx ];
188
189 return nullptr;
190 }
191};
192
193
203{
204protected:
211 std::vector<EDA_ITEM*> m_List2nd;
212
217
218public:
219
223 static const std::vector<KICAD_T> AllBoardItems;
224
228 static const std::vector<KICAD_T> Zones;
229
234 static const std::vector<KICAD_T> BoardLevelItems;
235
239 static const std::vector<KICAD_T> Footprints;
240
244 static const std::vector<KICAD_T> PadsOrTracks;
245
249 static const std::vector<KICAD_T> FootprintItems;
250
254 static const std::vector<KICAD_T> Tracks;
255
259 static const std::vector<KICAD_T> Dimensions;
260
264 static const std::vector<KICAD_T> DraggableItems;
265
267 m_Guide( nullptr )
268 {
270 }
271
272 void Empty2nd()
273 {
274 m_List2nd.clear();
275 }
276
277 void Append2nd( EDA_ITEM* item )
278 {
279 m_List2nd.push_back( item );
280 }
281
287 void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
288
289 const COLLECTORS_GUIDE* GetGuide() const { return m_Guide; }
290
299 INSPECT_RESULT Inspect( EDA_ITEM* aTestItem, void* aTestData ) override;
300
310 void Collect( BOARD_ITEM* aItem, const std::vector<KICAD_T>& aScanList,
311 const VECTOR2I& aRefPos, const COLLECTORS_GUIDE& aGuide );
312};
313
314
320{
321public:
322
331 GENERAL_COLLECTORS_GUIDE( const LSET& aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
332 KIGFX::VIEW* aView )
333 {
334 static const VECTOR2I one( 1, 1 );
335
336 m_preferredLayer = aPreferredLayer;
337 m_visibleLayers = aVisibleLayerMask;
338 m_ignoreLockedItems = false;
339
340#if defined(USE_MATCH_LAYER)
341 m_includeSecondary = false;
342#else
343 m_includeSecondary = true;
344#endif
345
347 m_ignoreFPTextOnFront = false;
348 m_ignoreFootprintsOnBack = true; // !Show_footprints_Cmp;
350
351 m_ignorePadsOnFront = false;
352 m_ignorePadsOnBack = false;
354
355 m_ignoreFPValues = false;
356 m_ignoreFPReferences = false;
357
358 m_ignoreThroughVias = false;
360 m_ignoreMicroVias = false;
361 m_ignoreTracks = false;
362 m_ignoreZoneFills = true;
363 m_ignoreNoNets = false;
364
365 m_onePixelInIU = abs( aView->ToWorld( one, false ).x );
367 }
368
372 bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
373 {
374 return m_visibleLayers[aLayerId];
375 }
376 void SetLayerVisible( PCB_LAYER_ID aLayerId, bool isVisible )
377 {
378 m_visibleLayers.set( aLayerId, isVisible );
379 }
380 void SetLayerVisibleBits( const LSET& aLayerBits ) { m_visibleLayers = aLayerBits; }
381
387
391 bool IgnoreLockedItems() const override { return m_ignoreLockedItems; }
392 void SetIgnoreLockedItems( bool ignore ) { m_ignoreLockedItems = ignore; }
393
399 bool IncludeSecondary() const override { return m_includeSecondary; }
400 void SetIncludeSecondary( bool include ) { m_includeSecondary = include; }
401
405 bool IgnoreFPTextOnBack() const override { return m_ignoreFPTextOnBack; }
406 void SetIgnoreFPTextOnBack( bool ignore ) { m_ignoreFPTextOnBack = ignore; }
407
411 bool IgnoreFPTextOnFront() const override { return m_ignoreFPTextOnFront; }
412 void SetIgnoreFPTextOnFront( bool ignore ) { m_ignoreFPTextOnFront = ignore; }
413
417 bool IgnoreFootprintsOnBack() const override { return m_ignoreFootprintsOnBack; }
418 void SetIgnoreFootprintsOnBack( bool ignore ) { m_ignoreFootprintsOnBack = ignore; }
419
423 bool IgnoreFootprintsOnFront() const override { return m_ignoreFootprintsOnFront; }
425
429 bool IgnorePadsOnBack() const override { return m_ignorePadsOnBack; }
430 void SetIgnorePadsOnBack(bool ignore) { m_ignorePadsOnBack = ignore; }
431
435 bool IgnorePadsOnFront() const override { return m_ignorePadsOnFront; }
436 void SetIgnorePadsOnFront(bool ignore) { m_ignorePadsOnFront = ignore; }
437
441 bool IgnoreThroughHolePads() const override { return m_ignoreThroughHolePads; }
442 void SetIgnoreThroughHolePads(bool ignore) { m_ignoreThroughHolePads = ignore; }
443
447 bool IgnoreFPValues() const override { return m_ignoreFPValues; }
448 void SetIgnoreFPValues( bool ignore) { m_ignoreFPValues = ignore; }
449
453 bool IgnoreFPReferences() const override { return m_ignoreFPReferences; }
454 void SetIgnoreFPReferences( bool ignore) { m_ignoreFPReferences = ignore; }
455
456 bool IgnoreThroughVias() const override { return m_ignoreThroughVias; }
457 void SetIgnoreThroughVias( bool ignore ) { m_ignoreThroughVias = ignore; }
458
459 bool IgnoreBlindBuriedVias() const override { return m_ignoreBlindBuriedVias; }
460 void SetIgnoreBlindBuriedVias( bool ignore ) { m_ignoreBlindBuriedVias = ignore; }
461
462 bool IgnoreMicroVias() const override { return m_ignoreMicroVias; }
463 void SetIgnoreMicroVias( bool ignore ) { m_ignoreMicroVias = ignore; }
464
465 bool IgnoreTracks() const override { return m_ignoreTracks; }
466 void SetIgnoreTracks( bool ignore ) { m_ignoreTracks = ignore; }
467
468 bool IgnoreZoneFills() const override { return m_ignoreZoneFills; }
469 void SetIgnoreZoneFills( bool ignore ) { m_ignoreZoneFills = ignore; }
470
471 bool IgnoreNoNets() const override { return m_ignoreNoNets; }
472 void SetIgnoreNoNets( bool ignore ) { m_ignoreNoNets = ignore; }
473
474 int Accuracy() const override { return m_accuracy; }
475 void SetAccuracy( int aValue ) { m_accuracy = aValue; }
476
477 double OnePixelInIU() const override { return m_onePixelInIU; }
478
479private:
480 // the storage architecture here is not important, since this is only
481 // a carrier object and its functions are what is used, and data only indirectly.
482
484
486
489
505
508};
509
510
517{
518public:
519
527 INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
528
535 void Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes );
536};
537
538
545{
546public:
548 m_layer_id( aLayerId )
549 { }
550
551 void SetLayerId( PCB_LAYER_ID aLayerId ) { m_layer_id = aLayerId; }
552
560 INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
561
568 void Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes );
569
570private:
572};
573
574#endif // COLLECTORS_H
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR telling it what should ...
Definition collectors.h:50
virtual bool IgnoreThroughVias() const =0
virtual bool IgnoreNoNets() const =0
virtual bool IsLayerVisible(PCB_LAYER_ID layer) const =0
virtual bool IgnoreFPTextOnFront() const =0
virtual double OnePixelInIU() const =0
virtual bool IgnoreFPTextOnBack() const =0
virtual bool IgnoreLockedItems() const =0
virtual bool IgnoreZoneFills() const =0
virtual bool IgnoreMicroVias() const =0
virtual bool IgnoreFootprintsOnBack() const =0
virtual bool IgnoreBlindBuriedVias() const =0
virtual int Accuracy() const =0
virtual bool IgnoreThroughHolePads() const =0
virtual bool IgnorePadsOnBack() const =0
virtual bool IgnoreFPReferences() const =0
virtual bool IgnorePadsOnFront() const =0
virtual bool IgnoreFootprintsOnFront() const =0
virtual bool IgnorePads() const
Definition collectors.h:114
virtual bool IgnoreTracks() const =0
virtual bool IncludeSecondary() const =0
Determine if the secondary criteria or 2nd choice items should be included.
virtual bool IgnoreFPValues() const =0
virtual ~COLLECTORS_GUIDE()
Definition collectors.h:52
virtual PCB_LAYER_ID GetPreferredLayer() const =0
int GetCount() const
Return the number of objects in the list.
Definition collector.h:79
void SetScanTypes(const std::vector< KICAD_T > &aTypes)
Record the list of KICAD_T types to consider for collection by the Inspect() function.
Definition collector.h:209
std::vector< EDA_ITEM * > m_list
Definition collector.h:238
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
void SetIgnoreBlindBuriedVias(bool ignore)
Definition collectors.h:460
void SetIgnoreTracks(bool ignore)
Definition collectors.h:466
bool IgnoreFootprintsOnBack() const override
Definition collectors.h:417
GENERAL_COLLECTORS_GUIDE(const LSET &aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer, KIGFX::VIEW *aView)
Grab stuff from global preferences and uses reasonable defaults.
Definition collectors.h:331
void SetIgnoreFootprintsOnFront(bool ignore)
Definition collectors.h:424
bool IgnorePadsOnFront() const override
Definition collectors.h:435
void SetIgnoreFPTextOnFront(bool ignore)
Definition collectors.h:412
bool IgnoreLockedItems() const override
Definition collectors.h:391
void SetIgnoreMicroVias(bool ignore)
Definition collectors.h:463
LSET m_visibleLayers
bit-mapped layer visible bits
Definition collectors.h:485
void SetIgnoreZoneFills(bool ignore)
Definition collectors.h:469
int Accuracy() const override
Definition collectors.h:474
bool IgnoreTracks() const override
Definition collectors.h:465
double OnePixelInIU() const override
Definition collectors.h:477
bool IncludeSecondary() const override
Determine if the secondary criteria, or 2nd choice items should be included.
Definition collectors.h:399
bool IgnoreFPTextOnBack() const override
Definition collectors.h:405
void SetIgnorePadsOnBack(bool ignore)
Definition collectors.h:430
void SetLayerVisible(PCB_LAYER_ID aLayerId, bool isVisible)
Definition collectors.h:376
void SetIgnoreLockedItems(bool ignore)
Definition collectors.h:392
bool IgnoreBlindBuriedVias() const override
Definition collectors.h:459
bool IgnoreNoNets() const override
Definition collectors.h:471
void SetIgnoreFPTextOnBack(bool ignore)
Definition collectors.h:406
bool IgnoreFPValues() const override
Definition collectors.h:447
void SetLayerVisibleBits(const LSET &aLayerBits)
Definition collectors.h:380
bool IgnoreFootprintsOnFront() const override
Definition collectors.h:423
void SetPreferredLayer(PCB_LAYER_ID aLayer)
Definition collectors.h:386
bool IgnoreThroughVias() const override
Definition collectors.h:456
void SetIgnoreThroughVias(bool ignore)
Definition collectors.h:457
void SetIgnoreThroughHolePads(bool ignore)
Definition collectors.h:442
void SetIncludeSecondary(bool include)
Definition collectors.h:400
void SetIgnoreNoNets(bool ignore)
Definition collectors.h:472
bool IsLayerVisible(PCB_LAYER_ID aLayerId) const override
Definition collectors.h:372
void SetIgnoreFPReferences(bool ignore)
Definition collectors.h:454
bool IgnoreThroughHolePads() const override
Definition collectors.h:441
bool IgnoreMicroVias() const override
Definition collectors.h:462
void SetIgnoreFPValues(bool ignore)
Definition collectors.h:448
bool IgnoreZoneFills() const override
Definition collectors.h:468
void SetIgnorePadsOnFront(bool ignore)
Definition collectors.h:436
void SetIgnoreFootprintsOnBack(bool ignore)
Definition collectors.h:418
bool IgnoreFPTextOnFront() const override
Definition collectors.h:411
bool IgnorePadsOnBack() const override
Definition collectors.h:429
void SetAccuracy(int aValue)
Definition collectors.h:475
PCB_LAYER_ID m_preferredLayer
Definition collectors.h:483
PCB_LAYER_ID GetPreferredLayer() const override
Definition collectors.h:385
bool IgnoreFPReferences() const override
Definition collectors.h:453
static const std::vector< KICAD_T > BoardLevelItems
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
Definition collectors.h:65
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition collectors.h:287
static const std::vector< KICAD_T > PadsOrTracks
A scan list for PADs, TRACKs, or VIAs.
Definition collectors.h:95
void Append2nd(EDA_ITEM *item)
Definition collectors.h:277
INSPECT_RESULT Inspect(EDA_ITEM *aTestItem, void *aTestData) override
The examining function within the INSPECTOR which is passed to the Iterate function.
const COLLECTORS_GUIDE * GetGuide() const
Definition collectors.h:289
static const std::vector< KICAD_T > Zones
A scan list for zones outlines only.
Definition collectors.h:228
std::vector< EDA_ITEM * > m_List2nd
A place to hold collected objects which don't match precisely the search criteria,...
Definition collectors.h:211
static const std::vector< KICAD_T > Footprints
A scan list for only FOOTPRINTs.
Definition collectors.h:90
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
Definition collectors.h:37
static const std::vector< KICAD_T > Tracks
A scan list for only TRACKs and ARCs.
Definition collectors.h:125
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.
static const std::vector< KICAD_T > Dimensions
A scan list for dimensions.
Definition collectors.h:132
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
Definition collectors.h:103
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition collectors.h:216
static const std::vector< KICAD_T > DraggableItems
A scan list for items that can be dragged.
Definition collectors.h:141
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition view.cpp:534
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Collect BOARD_ITEM objects.
Definition collectors.h:176
BOARD_ITEM * operator[](int ndx) const override
Overload the COLLECTOR::operator[](int) to return a BOARD_ITEM instead of an EDA_ITEM.
Definition collectors.h:184
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Test a BOARD_ITEM using this class's Inspector method, which does the collection.
INSPECT_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
The examining function within the INSPECTOR which is passed to the iterate function.
PCB_LAYER_COLLECTOR(PCB_LAYER_ID aLayerId=UNDEFINED_LAYER)
Definition collectors.h:547
void SetLayerId(PCB_LAYER_ID aLayerId)
Definition collectors.h:551
PCB_LAYER_ID m_layer_id
Definition collectors.h:571
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
Definition collectors.h:517
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
INSPECT_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
The examining function within the INSPECTOR which is passed to the Iterate function.
INSPECT_RESULT
Definition eda_item.h:42
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683