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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef COLLECTORS_H
26#define COLLECTORS_H
27
28/*
29 * This module contains a number of COLLECTOR implementations which are used
30 * to augment the functionality of class PCB_EDIT_FRAME.
31 */
32
33#include <collector.h>
34#include <layer_ids.h> // LAYER_COUNT, layer defs
35#include <lset.h>
36#include <view/view.h>
37#include <board_item.h>
38
54{
55public:
56 virtual ~COLLECTORS_GUIDE() {}
57
61 virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
62
66 virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
67
71 virtual bool IgnoreLockedItems() const = 0;
72
78 virtual bool IncludeSecondary() const = 0;
79
83 virtual bool IgnoreFPTextOnBack() const = 0;
84
88 virtual bool IgnoreFPTextOnFront() const = 0;
89
93 virtual bool IgnoreFootprintsOnBack() const = 0;
94
98 virtual bool IgnoreFootprintsOnFront() const = 0;
99
103 virtual bool IgnorePadsOnBack() const = 0;
104
108 virtual bool IgnorePadsOnFront() const = 0;
109
113 virtual bool IgnoreThroughHolePads() const = 0;
114
118 virtual bool IgnorePads() const
119 {
121 }
122
126 virtual bool IgnoreFPValues() const = 0;
127
131 virtual bool IgnoreFPReferences() const = 0;
132
136 virtual bool IgnoreThroughVias() const = 0;
137
141 virtual bool IgnoreBlindBuriedVias() const = 0;
142
146 virtual bool IgnoreMicroVias() const = 0;
147
151 virtual bool IgnoreTracks() const = 0;
152
156 virtual bool IgnoreZoneFills() const = 0;
157
161 virtual bool IgnoreNoNets() const = 0;
162
163 virtual int Accuracy() const = 0;
164
165 virtual double OnePixelInIU() const = 0;
166};
167
168
169
180{
181public:
188 BOARD_ITEM* operator[]( int ndx ) const override
189 {
190 if( (unsigned)ndx < (unsigned)GetCount() )
191 return (BOARD_ITEM*) m_list[ ndx ];
192
193 return nullptr;
194 }
195};
196
197
207{
208protected:
215 std::vector<EDA_ITEM*> m_List2nd;
216
221
222public:
223
227 static const std::vector<KICAD_T> AllBoardItems;
228
232 static const std::vector<KICAD_T> Zones;
233
238 static const std::vector<KICAD_T> BoardLevelItems;
239
243 static const std::vector<KICAD_T> Footprints;
244
248 static const std::vector<KICAD_T> PadsOrTracks;
249
253 static const std::vector<KICAD_T> FootprintItems;
254
258 static const std::vector<KICAD_T> Tracks;
259
263 static const std::vector<KICAD_T> Dimensions;
264
268 static const std::vector<KICAD_T> DraggableItems;
269
271 m_Guide( nullptr )
272 {
274 }
275
276 void Empty2nd()
277 {
278 m_List2nd.clear();
279 }
280
281 void Append2nd( EDA_ITEM* item )
282 {
283 m_List2nd.push_back( item );
284 }
285
291 void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
292
293 const COLLECTORS_GUIDE* GetGuide() const { return m_Guide; }
294
303 INSPECT_RESULT Inspect( EDA_ITEM* aTestItem, void* aTestData ) override;
304
314 void Collect( BOARD_ITEM* aItem, const std::vector<KICAD_T>& aScanList,
315 const VECTOR2I& aRefPos, const COLLECTORS_GUIDE& aGuide );
316};
317
318
324{
325public:
326
335 GENERAL_COLLECTORS_GUIDE( const LSET& aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
336 KIGFX::VIEW* aView )
337 {
338 static const VECTOR2I one( 1, 1 );
339
340 m_preferredLayer = aPreferredLayer;
341 m_visibleLayers = aVisibleLayerMask;
342 m_ignoreLockedItems = false;
343
344#if defined(USE_MATCH_LAYER)
345 m_includeSecondary = false;
346#else
347 m_includeSecondary = true;
348#endif
349
351 m_ignoreFPTextOnFront = false;
352 m_ignoreFootprintsOnBack = true; // !Show_footprints_Cmp;
354
355 m_ignorePadsOnFront = false;
356 m_ignorePadsOnBack = false;
358
359 m_ignoreFPValues = false;
360 m_ignoreFPReferences = false;
361
362 m_ignoreThroughVias = false;
364 m_ignoreMicroVias = false;
365 m_ignoreTracks = false;
366 m_ignoreZoneFills = true;
367 m_ignoreNoNets = false;
368
369 m_onePixelInIU = abs( aView->ToWorld( one, false ).x );
371 }
372
376 bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
377 {
378 return m_visibleLayers[aLayerId];
379 }
380 void SetLayerVisible( PCB_LAYER_ID aLayerId, bool isVisible )
381 {
382 m_visibleLayers.set( aLayerId, isVisible );
383 }
384 void SetLayerVisibleBits( const LSET& aLayerBits ) { m_visibleLayers = aLayerBits; }
385
391
395 bool IgnoreLockedItems() const override { return m_ignoreLockedItems; }
396 void SetIgnoreLockedItems( bool ignore ) { m_ignoreLockedItems = ignore; }
397
403 bool IncludeSecondary() const override { return m_includeSecondary; }
404 void SetIncludeSecondary( bool include ) { m_includeSecondary = include; }
405
409 bool IgnoreFPTextOnBack() const override { return m_ignoreFPTextOnBack; }
410 void SetIgnoreFPTextOnBack( bool ignore ) { m_ignoreFPTextOnBack = ignore; }
411
415 bool IgnoreFPTextOnFront() const override { return m_ignoreFPTextOnFront; }
416 void SetIgnoreFPTextOnFront( bool ignore ) { m_ignoreFPTextOnFront = ignore; }
417
421 bool IgnoreFootprintsOnBack() const override { return m_ignoreFootprintsOnBack; }
422 void SetIgnoreFootprintsOnBack( bool ignore ) { m_ignoreFootprintsOnBack = ignore; }
423
427 bool IgnoreFootprintsOnFront() const override { return m_ignoreFootprintsOnFront; }
429
433 bool IgnorePadsOnBack() const override { return m_ignorePadsOnBack; }
434 void SetIgnorePadsOnBack(bool ignore) { m_ignorePadsOnBack = ignore; }
435
439 bool IgnorePadsOnFront() const override { return m_ignorePadsOnFront; }
440 void SetIgnorePadsOnFront(bool ignore) { m_ignorePadsOnFront = ignore; }
441
445 bool IgnoreThroughHolePads() const override { return m_ignoreThroughHolePads; }
446 void SetIgnoreThroughHolePads(bool ignore) { m_ignoreThroughHolePads = ignore; }
447
451 bool IgnoreFPValues() const override { return m_ignoreFPValues; }
452 void SetIgnoreFPValues( bool ignore) { m_ignoreFPValues = ignore; }
453
457 bool IgnoreFPReferences() const override { return m_ignoreFPReferences; }
458 void SetIgnoreFPReferences( bool ignore) { m_ignoreFPReferences = ignore; }
459
460 bool IgnoreThroughVias() const override { return m_ignoreThroughVias; }
461 void SetIgnoreThroughVias( bool ignore ) { m_ignoreThroughVias = ignore; }
462
463 bool IgnoreBlindBuriedVias() const override { return m_ignoreBlindBuriedVias; }
464 void SetIgnoreBlindBuriedVias( bool ignore ) { m_ignoreBlindBuriedVias = ignore; }
465
466 bool IgnoreMicroVias() const override { return m_ignoreMicroVias; }
467 void SetIgnoreMicroVias( bool ignore ) { m_ignoreMicroVias = ignore; }
468
469 bool IgnoreTracks() const override { return m_ignoreTracks; }
470 void SetIgnoreTracks( bool ignore ) { m_ignoreTracks = ignore; }
471
472 bool IgnoreZoneFills() const override { return m_ignoreZoneFills; }
473 void SetIgnoreZoneFills( bool ignore ) { m_ignoreZoneFills = ignore; }
474
475 bool IgnoreNoNets() const override { return m_ignoreNoNets; }
476 void SetIgnoreNoNets( bool ignore ) { m_ignoreNoNets = ignore; }
477
478 int Accuracy() const override { return m_accuracy; }
479 void SetAccuracy( int aValue ) { m_accuracy = aValue; }
480
481 double OnePixelInIU() const override { return m_onePixelInIU; }
482
483private:
484 // the storage architecture here is not important, since this is only
485 // a carrier object and its functions are what is used, and data only indirectly.
486
488
490
493
509
512};
513
514
521{
522public:
523
531 INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
532
539 void Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes );
540};
541
542
549{
550public:
552 m_layer_id( aLayerId )
553 { }
554
555 void SetLayerId( PCB_LAYER_ID aLayerId ) { m_layer_id = aLayerId; }
556
564 INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
565
572 void Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes );
573
574private:
576};
577
578#endif // COLLECTORS_H
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
BASE_SET & set(size_t pos)
Definition: base_set.h:116
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR telling it what should ...
Definition: collectors.h:54
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:118
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:56
virtual PCB_LAYER_ID GetPreferredLayer() const =0
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
Definition: collector.h:49
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:83
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:213
std::vector< EDA_ITEM * > m_list
Definition: collector.h:242
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:324
void SetIgnoreBlindBuriedVias(bool ignore)
Definition: collectors.h:464
void SetIgnoreTracks(bool ignore)
Definition: collectors.h:470
bool IgnoreFootprintsOnBack() const override
Definition: collectors.h:421
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:335
void SetIgnoreFootprintsOnFront(bool ignore)
Definition: collectors.h:428
bool IgnorePadsOnFront() const override
Definition: collectors.h:439
void SetIgnoreFPTextOnFront(bool ignore)
Definition: collectors.h:416
bool IgnoreLockedItems() const override
Definition: collectors.h:395
void SetIgnoreMicroVias(bool ignore)
Definition: collectors.h:467
LSET m_visibleLayers
bit-mapped layer visible bits
Definition: collectors.h:489
void SetIgnoreZoneFills(bool ignore)
Definition: collectors.h:473
int Accuracy() const override
Definition: collectors.h:478
bool IgnoreTracks() const override
Definition: collectors.h:469
double OnePixelInIU() const override
Definition: collectors.h:481
bool IncludeSecondary() const override
Determine if the secondary criteria, or 2nd choice items should be included.
Definition: collectors.h:403
bool IgnoreFPTextOnBack() const override
Definition: collectors.h:409
void SetIgnorePadsOnBack(bool ignore)
Definition: collectors.h:434
void SetLayerVisible(PCB_LAYER_ID aLayerId, bool isVisible)
Definition: collectors.h:380
void SetIgnoreLockedItems(bool ignore)
Definition: collectors.h:396
bool IgnoreBlindBuriedVias() const override
Definition: collectors.h:463
bool IgnoreNoNets() const override
Definition: collectors.h:475
void SetIgnoreFPTextOnBack(bool ignore)
Definition: collectors.h:410
bool IgnoreFPValues() const override
Definition: collectors.h:451
void SetLayerVisibleBits(const LSET &aLayerBits)
Definition: collectors.h:384
bool IgnoreFootprintsOnFront() const override
Definition: collectors.h:427
void SetPreferredLayer(PCB_LAYER_ID aLayer)
Definition: collectors.h:390
bool IgnoreThroughVias() const override
Definition: collectors.h:460
void SetIgnoreThroughVias(bool ignore)
Definition: collectors.h:461
void SetIgnoreThroughHolePads(bool ignore)
Definition: collectors.h:446
void SetIncludeSecondary(bool include)
Definition: collectors.h:404
void SetIgnoreNoNets(bool ignore)
Definition: collectors.h:476
bool IsLayerVisible(PCB_LAYER_ID aLayerId) const override
Definition: collectors.h:376
void SetIgnoreFPReferences(bool ignore)
Definition: collectors.h:458
bool IgnoreThroughHolePads() const override
Definition: collectors.h:445
bool IgnoreMicroVias() const override
Definition: collectors.h:466
void SetIgnoreFPValues(bool ignore)
Definition: collectors.h:452
bool IgnoreZoneFills() const override
Definition: collectors.h:472
void SetIgnorePadsOnFront(bool ignore)
Definition: collectors.h:440
void SetIgnoreFootprintsOnBack(bool ignore)
Definition: collectors.h:422
bool IgnoreFPTextOnFront() const override
Definition: collectors.h:415
bool IgnorePadsOnBack() const override
Definition: collectors.h:433
void SetAccuracy(int aValue)
Definition: collectors.h:479
PCB_LAYER_ID m_preferredLayer
Definition: collectors.h:487
PCB_LAYER_ID GetPreferredLayer() const override
Definition: collectors.h:389
bool IgnoreFPReferences() const override
Definition: collectors.h:457
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:207
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:238
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:291
static const std::vector< KICAD_T > PadsOrTracks
A scan list for PADs, TRACKs, or VIAs.
Definition: collectors.h:248
void Append2nd(EDA_ITEM *item)
Definition: collectors.h:281
INSPECT_RESULT Inspect(EDA_ITEM *aTestItem, void *aTestData) override
The examining function within the INSPECTOR which is passed to the Iterate function.
Definition: collectors.cpp:147
const COLLECTORS_GUIDE * GetGuide() const
Definition: collectors.h:293
static const std::vector< KICAD_T > Zones
A scan list for zones outlines only.
Definition: collectors.h:232
std::vector< EDA_ITEM * > m_List2nd
A place to hold collected objects which don't match precisely the search criteria,...
Definition: collectors.h:215
static const std::vector< KICAD_T > Footprints
A scan list for only FOOTPRINTs.
Definition: collectors.h:243
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
Definition: collectors.h:227
static const std::vector< KICAD_T > Tracks
A scan list for only TRACKs and ARCs.
Definition: collectors.h:258
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.
Definition: collectors.cpp:505
static const std::vector< KICAD_T > Dimensions
A scan list for dimensions.
Definition: collectors.h:263
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
Definition: collectors.h:253
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition: collectors.h:220
static const std::vector< KICAD_T > DraggableItems
A scan list for items that can be dragged.
Definition: collectors.h:268
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:66
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:467
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
Collect BOARD_ITEM objects.
Definition: collectors.h:180
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:188
Collect all BOARD_ITEM objects on a given layer.
Definition: collectors.h:549
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.
Definition: collectors.cpp:559
INSPECT_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
The examining function within the INSPECTOR which is passed to the iterate function.
Definition: collectors.cpp:548
PCB_LAYER_COLLECTOR(PCB_LAYER_ID aLayerId=UNDEFINED_LAYER)
Definition: collectors.h:551
void SetLayerId(PCB_LAYER_ID aLayerId)
Definition: collectors.h:555
PCB_LAYER_ID m_layer_id
Definition: collectors.h:575
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
Definition: collectors.h:521
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.
Definition: collectors.cpp:541
INSPECT_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
The examining function within the INSPECTOR which is passed to the Iterate function.
Definition: collectors.cpp:531
INSPECT_RESULT
Definition: eda_item.h:44
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61