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#include "pns_segment.h"
25
26namespace PNS {
27
29{
30}
31
32
33void ITEM_SET::Add( const LINE& aLine )
34{
35 LINE* copy = aLine.Clone();
36 copy->SetOwner( this );
37 m_items.emplace_back( copy );
38}
39
40
41void ITEM_SET::Prepend( const LINE& aLine )
42{
43 LINE* copy = aLine.Clone();
44 copy->SetOwner( this );
45 m_items.emplace( m_items.begin(), copy );
46}
47
48
49ITEM_SET& ITEM_SET::FilterLayers( int aStart, int aEnd, bool aInvert )
50{
51 std::vector<ITEM*> newItems;
53
54 if( aEnd < 0 )
55 l = PNS_LAYER_RANGE( aStart );
56 else
57 l = PNS_LAYER_RANGE( aStart, aEnd );
58
59 for( ITEM* item : m_items )
60 {
61 if( item->Layers().Overlaps( l ) ^ aInvert )
62 newItems.push_back( item );
63 }
64
65 m_items = std::move( newItems );
66
67 return *this;
68}
69
70
71ITEM_SET& ITEM_SET::FilterKinds( int aKindMask, bool aInvert )
72{
73 std::vector<ITEM*> newItems;
74
75 for( ITEM *item : m_items )
76 {
77 if( item->OfKind( aKindMask ) ^ aInvert )
78 newItems.push_back( item );
79 }
80
81 m_items = std::move( newItems );
82
83 return *this;
84}
85
86
87ITEM_SET& ITEM_SET::FilterMarker( int aMarker, bool aInvert )
88{
89 std::vector<ITEM*> newItems;
90
91 for( ITEM* item : m_items )
92 {
93 if( item->Marker() & aMarker )
94 newItems.push_back( item );
95 }
96
97 m_items = std::move( newItems );
98
99 return *this;
100}
101
102
104{
105 std::vector<ITEM*> newItems;
106
107 for( ITEM *item : m_items )
108 {
109 if( ( item->Net() == aNet ) ^ aInvert )
110 newItems.push_back( item );
111 }
112
113 m_items = std::move( newItems );
114
115 return *this;
116}
117
118
120{
121 std::vector<ITEM*> newItems;
122
123 for( ITEM* item : m_items )
124 {
125 if( item != aItem )
126 newItems.push_back( item );
127 }
128
129 m_items = std::move( newItems );
130
131 return *this;
132}
133
135{
136 for( ITEM* item : m_items )
137 {
138 // fixme: biconnected concept
139 if( auto seg = dyn_cast<SEGMENT*>( item ) )
140 {
141 if( seg->Seg().A == aV || seg->Seg().B == aV )
142 return seg;
143 }
144 }
145
146 return nullptr;
147}
148
149}
ITEM_SET & FilterNet(NET_HANDLE aNet, bool aInvert=false)
std::vector< ITEM * > m_items
Definition: pns_itemset.h:186
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:33
ITEM_SET & ExcludeItem(const ITEM *aItem)
ITEM_SET & FilterMarker(int aMarker, bool aInvert=false)
Definition: pns_itemset.cpp:87
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:71
ITEM_SET & FilterLayers(int aStart, int aEnd=-1, bool aInvert=false)
Definition: pns_itemset.cpp:49
ITEM * FindVertex(const VECTOR2I &aV) const
void Prepend(const LINE &aLine)
Definition: pns_itemset.cpp:41
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:62
virtual LINE * Clone() const override
Return a deep copy of the item.
Definition: pns_line.cpp:115
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition: pns_item.h:54