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 <tomasz.wlostowski@cern.ch>
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 
25 namespace PNS {
26 
28 {
29 }
30 
31 
32 void ITEM_SET::Add( const LINE& aLine )
33 {
34  LINE* copy = aLine.Clone();
35  m_items.push_back( ENTRY( copy, true ) );
36 }
37 
38 
39 void ITEM_SET::Prepend( const LINE& aLine )
40 {
41  LINE* copy = aLine.Clone();
42  m_items.insert( m_items.begin(), ENTRY( copy, true ) );
43 }
44 
45 
46 ITEM_SET& ITEM_SET::FilterLayers( int aStart, int aEnd, bool aInvert )
47 {
48  ENTRIES newItems;
49  LAYER_RANGE l;
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  {
60  newItems.push_back( ent );
61  }
62  }
63 
64  m_items = newItems;
65 
66  return *this;
67 }
68 
69 
70 ITEM_SET& ITEM_SET::FilterKinds( int aKindMask, bool aInvert )
71 {
72  ENTRIES newItems;
73 
74  for( const ENTRY& ent : m_items )
75  {
76  if( ent.item->OfKind( aKindMask ) ^ aInvert )
77  {
78  newItems.push_back( ent );
79  }
80  }
81 
82  m_items = newItems;
83 
84  return *this;
85 }
86 
87 
88 ITEM_SET& ITEM_SET::FilterMarker( int aMarker, bool aInvert )
89 {
90  ENTRIES newItems;
91 
92  for( const ENTRY& ent : m_items )
93  {
94  if( ent.item->Marker() & aMarker )
95  {
96  newItems.push_back( ent );
97  }
98  }
99 
100  m_items = newItems;
101 
102  return *this;
103 }
104 
105 
106 ITEM_SET& ITEM_SET::FilterNet( int aNet, bool aInvert )
107 {
108  ENTRIES newItems;
109 
110  for( const ENTRY& ent : m_items )
111  {
112  if( ( ent.item->Net() == aNet ) ^ aInvert )
113  {
114  newItems.push_back( ent );
115  }
116  }
117 
118  m_items = newItems;
119 
120  return *this;
121 }
122 
123 
125 {
126  ENTRIES newItems;
127 
128  for( const ENTRY& ent : m_items )
129  {
130  if( ent.item != aItem )
131 
132  newItems.push_back( ent );
133  }
134 
135  m_items = newItems;
136 
137  return *this;
138 }
139 
140 }
Class ITEM.
Definition: pns_item.h:53
void Prepend(const LINE &aLine)
Definition: pns_itemset.cpp:39
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:70
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ITEM_SET & ExcludeItem(const ITEM *aItem)
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
ITEM_SET & FilterMarker(int aMarker, bool aInvert=false)
Definition: pns_itemset.cpp:88
ENTRIES m_items
Definition: pns_itemset.h:226
ITEM_SET & FilterNet(int aNet, bool aInvert=false)
ITEM_SET & FilterLayers(int aStart, int aEnd=-1, bool aInvert=false)
Definition: pns_itemset.cpp:46
Push and Shove diff pair dimensions (gap) settings dialog.
virtual LINE * Clone() const override
Function Clone()
Definition: pns_line.cpp:78
Class LAYER_RANGE.
Definition: pns_layerset.h:32