KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 copy->SetOwner( this );
36 m_items.emplace_back( copy );
37}
38
39
40void ITEM_SET::Prepend( const LINE& aLine )
41{
42 LINE* copy = aLine.Clone();
43 copy->SetOwner( this );
44 m_items.emplace( m_items.begin(), copy );
45}
46
47
48ITEM_SET& ITEM_SET::FilterLayers( int aStart, int aEnd, bool aInvert )
49{
50 std::vector<ITEM*> newItems;
52
53 if( aEnd < 0 )
54 l = LAYER_RANGE( aStart );
55 else
56 l = LAYER_RANGE( aStart, aEnd );
57
58 for( ITEM* item : m_items )
59 {
60 if( item->Layers().Overlaps( l ) ^ aInvert )
61 newItems.push_back( item );
62 }
63
64 m_items = std::move( newItems );
65
66 return *this;
67}
68
69
70ITEM_SET& ITEM_SET::FilterKinds( int aKindMask, bool aInvert )
71{
72 std::vector<ITEM*> newItems;
73
74 for( ITEM *item : m_items )
75 {
76 if( item->OfKind( aKindMask ) ^ aInvert )
77 newItems.push_back( item );
78 }
79
80 m_items = std::move( newItems );
81
82 return *this;
83}
84
85
86ITEM_SET& ITEM_SET::FilterMarker( int aMarker, bool aInvert )
87{
88 std::vector<ITEM*> newItems;
89
90 for( ITEM* item : m_items )
91 {
92 if( item->Marker() & aMarker )
93 newItems.push_back( item );
94 }
95
96 m_items = std::move( newItems );
97
98 return *this;
99}
100
101
103{
104 std::vector<ITEM*> newItems;
105
106 for( ITEM *item : m_items )
107 {
108 if( ( item->Net() == aNet ) ^ aInvert )
109 newItems.push_back( item );
110 }
111
112 m_items = std::move( newItems );
113
114 return *this;
115}
116
117
119{
120 std::vector<ITEM*> newItems;
121
122 for( ITEM* item : m_items )
123 {
124 if( item != aItem )
125 newItems.push_back( item );
126 }
127
128 m_items = std::move( newItems );
129
130 return *this;
131}
132
133}
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
ITEM_SET & FilterNet(NET_HANDLE aNet, bool aInvert=false)
std::vector< ITEM * > m_items
Definition: pns_itemset.h:184
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:86
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:70
ITEM_SET & FilterLayers(int aStart, int aEnd=-1, bool aInvert=false)
Definition: pns_itemset.cpp:48
void Prepend(const LINE &aLine)
Definition: pns_itemset.cpp:40
Base class for PNS router board items.
Definition: pns_item.h:97
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:101
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition: pns_item.h:54