KiCad PCB EDA Suite
pns_itemset.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "pns_itemset.h"
23#include "pns_line.h"
24
25namespace PNS {
26
28{
29}
30
31
32void ITEM_SET::Add( const LINE& aLine )
33{
34 LINE* copy = aLine.Clone();
35 m_items.emplace_back( ENTRY( copy, true ) );
36}
37
38
39void ITEM_SET::Prepend( const LINE& aLine )
40{
41 LINE* copy = aLine.Clone();
42 m_items.emplace( m_items.begin(), ENTRY( copy, true ) );
43}
44
45
46ITEM_SET& ITEM_SET::FilterLayers( int aStart, int aEnd, bool aInvert )
47{
48 ENTRIES newItems;
50
51 if( aEnd < 0 )
52 l = LAYER_RANGE( aStart );
53 else
54 l = LAYER_RANGE( aStart, aEnd );
55
56 for( const ENTRY& ent : m_items )
57 {
58 if( ent.item->Layers().Overlaps( l ) ^ aInvert )
59 newItems.push_back( ent );
60 }
61
62 m_items = newItems;
63
64 return *this;
65}
66
67
68ITEM_SET& ITEM_SET::FilterKinds( int aKindMask, bool aInvert )
69{
70 ENTRIES newItems;
71
72 for( const ENTRY& ent : m_items )
73 {
74 if( ent.item->OfKind( aKindMask ) ^ aInvert )
75 newItems.push_back( ent );
76 }
77
78 m_items = newItems;
79
80 return *this;
81}
82
83
84ITEM_SET& ITEM_SET::FilterMarker( int aMarker, bool aInvert )
85{
86 ENTRIES newItems;
87
88 for( const ENTRY& ent : m_items )
89 {
90 if( ent.item->Marker() & aMarker )
91 newItems.push_back( ent );
92 }
93
94 m_items = newItems;
95
96 return *this;
97}
98
99
100ITEM_SET& ITEM_SET::FilterNet( int aNet, bool aInvert )
101{
102 ENTRIES newItems;
103
104 for( const ENTRY& ent : m_items )
105 {
106 if( ( ent.item->Net() == aNet ) ^ aInvert )
107 newItems.push_back( ent );
108 }
109
110 m_items = newItems;
111
112 return *this;
113}
114
115
117{
118 ENTRIES newItems;
119
120 for( const ENTRY& ent : m_items )
121 {
122 if( ent.item != aItem )
123 newItems.push_back( ent );
124 }
125
126 m_items = newItems;
127
128 return *this;
129}
130
131}
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
ITEM_SET & FilterNet(int aNet, bool aInvert=false)
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
ITEM_SET & ExcludeItem(const ITEM *aItem)
ITEM_SET & FilterMarker(int aMarker, bool aInvert=false)
Definition: pns_itemset.cpp:84
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:68
ITEM_SET & FilterLayers(int aStart, int aEnd=-1, bool aInvert=false)
Definition: pns_itemset.cpp:46
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:93
void Prepend(const LINE &aLine)
Definition: pns_itemset.cpp:39
ENTRIES m_items
Definition: pns_itemset.h:228
Base class for PNS router board items.
Definition: pns_item.h:56
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:61
virtual LINE * Clone() const override
Return a deep copy of the item.
Definition: pns_line.cpp:81
Push and Shove diff pair dimensions (gap) settings dialog.