KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_group.cpp
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) 2020 Joshua Redstone redstone at gmail.com
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, see <https://www.gnu.org/licenses/>.
19 */
20#include "pcb_group.h"
21
22#include <bitmaps.h>
23#include <eda_draw_frame.h>
25#include <board.h>
26#include <board_item.h>
27#include <confirm.h>
28#include <footprint.h>
29#include <pcb_generator.h>
30#include <string_utils.h>
31#include <widgets/msgpanel.h>
32#include <view/view.h>
33#include <api/api_enums.h>
34#include <api/api_utils.h>
35#include <api/api_pcb_utils.h>
36#include <api/board/board_types.pb.h>
37#include <google/protobuf/any.pb.h>
38
39#include <wx/debug.h>
40#include <properties/property.h>
42
44 BOARD_ITEM( aParent, PCB_GROUP_T )
45{
46}
47
48
50 BOARD_ITEM( aParent, idtype, aLayer )
51{
52}
53
54void PCB_GROUP::Serialize( google::protobuf::Any &aContainer ) const
55{
56 using namespace kiapi::common::types;
57 kiapi::board::types::Group group;
58
59 group.mutable_id()->set_value( m_Uuid.AsStdString() );
60 group.set_name( GetName().ToUTF8() );
61 group.set_locked( IsLocked() ? LockedState::LS_LOCKED : LockedState::LS_UNLOCKED );
62
63 for( EDA_ITEM* item : GetItems() )
64 {
65 kiapi::common::types::KIID* itemId = group.add_items();
66 itemId->set_value( item->m_Uuid.AsStdString() );
67 }
68
69 if( FOOTPRINT* parent = GetParentFootprint() )
70 group.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
71 else if( const BOARD* board = GetBoard() )
72 group.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
73
74 if( HasDesignBlockLink() )
76
77 kiapi::common::PackCustomProperties( group.mutable_custom_properties(), *this );
78 aContainer.PackFrom( group );
79}
80
81
82bool PCB_GROUP::Deserialize( const google::protobuf::Any& aContainer )
83{
84 return DeserializeGroup( aContainer, nullptr );
85}
86
87
88// Note: this only records the group members in m_deserializedItems. A proper AddItem() must
89// be done in a second pass (FinalizeGroupDeserialization()).
90bool PCB_GROUP::DeserializeGroup( const google::protobuf::Any& aContainer, COMMIT* aCommit )
91{
92 kiapi::board::types::Group group;
93
94 if( !aContainer.UnpackTo( &group ) )
95 return false;
96
97 SetUuidDirect( KIID( group.id().value() ) );
98 SetName( wxString( group.name().c_str(), wxConvUTF8 ) );
99 SetLocked( group.locked() == kiapi::common::types::LockedState::LS_LOCKED );
100
101 m_items.clear();
102 m_deserializedItems.clear();
103
104 BOARD* board = GetBoard();
105
106 if( !board )
107 return false;
108
109 for( const kiapi::common::types::KIID& itemId : group.items() )
110 {
111 KIID id( itemId.value() );
112 EDA_ITEM* item = board->ResolveItem( id, true );
113
114 if( !item && aCommit )
115 item = aCommit->ResolveItem( id );
116
117 if( item )
118 m_deserializedItems.insert( item );
119 }
120
121 if( group.has_lib_id() )
123
124 kiapi::common::UnpackCustomProperties( group.custom_properties(), *this );
125
126 return true;
127}
128
129
130std::unordered_set<BOARD_ITEM*> PCB_GROUP::GetBoardItems() const
131{
132 std::unordered_set<BOARD_ITEM*> items;
133
134 for( EDA_ITEM* item : m_items )
135 {
136 if( item->IsBOARD_ITEM() )
137 items.insert( static_cast<BOARD_ITEM*>( item ) );
138 }
139
140 return items;
141}
142
143
144/*
145 * @return if not in the footprint editor and aItem is in a footprint, returns the
146 * footprint's parent group. Otherwise, returns the aItem's parent group.
147 */
148EDA_GROUP* getClosestGroup( BOARD_ITEM* aItem, bool isFootprintEditor )
149{
150 if( !isFootprintEditor && aItem->GetParent() && aItem->GetParent()->Type() == PCB_FOOTPRINT_T )
151 return aItem->GetParent()->GetParentGroup();
152 else
153 return aItem->GetParentGroup();
154}
155
156
158EDA_GROUP* getNestedGroup( BOARD_ITEM* aItem, EDA_GROUP* aScope, bool isFootprintEditor )
159{
160 EDA_GROUP* group = getClosestGroup( aItem, isFootprintEditor );
161
162 if( group == aScope )
163 return nullptr;
164
165 while( group && group->AsEdaItem()->GetParentGroup() && group->AsEdaItem()->GetParentGroup() != aScope )
166 group = group->AsEdaItem()->GetParentGroup();
167
168 return group;
169}
170
171
172EDA_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* aItem, EDA_GROUP* aScope, bool isFootprintEditor )
173{
174 return getNestedGroup( aItem, aScope, isFootprintEditor );
175}
176
177
178bool PCB_GROUP::WithinScope( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
179{
180 EDA_GROUP* group = getClosestGroup( aItem, isFootprintEditor );
181
182 if( group && group == aScope )
183 return true;
184
185 EDA_GROUP* nested = getNestedGroup( aItem, aScope, isFootprintEditor );
186
187 return nested && nested->AsEdaItem()->GetParentGroup() && ( nested->AsEdaItem()->GetParentGroup() == aScope );
188}
189
190
192{
193 return GetBoundingBox().Centre();
194}
195
196
197void PCB_GROUP::SetPosition( const VECTOR2I& aNewpos )
198{
199 VECTOR2I delta = aNewpos - GetPosition();
200
201 Move( delta );
202}
203
204
205void PCB_GROUP::SetLocked( bool aLockState )
206{
207 BOARD_ITEM::SetLocked( aLockState );
208
209 // Don't set locked flag on children. BOARD_ITEM::IsLocked() checks the parent group for current
210 // lock status before exmaining its own flag.
211 //
212 // Setting the child flag just leands to endless problems when members get added-to/removed-from
213 // locked groups.
214}
215
216
218{
219 // Use copy constructor to get the same uuid and other fields
220 PCB_GROUP* newGroup = new PCB_GROUP( *this );
221 return newGroup;
222}
223
224
226{
227 // Use copy constructor to get the same uuid and other fields
228 PCB_GROUP* newGroup = new PCB_GROUP( *this );
229 newGroup->m_items.clear();
230
231 for( EDA_ITEM* member : m_items )
232 {
233 if( member->Type() == PCB_GROUP_T )
234 newGroup->AddItem( static_cast<PCB_GROUP*>( member )->DeepClone() );
235 else if( member->Type() == PCB_GENERATOR_T )
236 newGroup->AddItem( static_cast<PCB_GENERATOR*>( member )->DeepClone() );
237 else
238 newGroup->AddItem( static_cast<BOARD_ITEM*>( member->Clone() ) );
239 }
240
241 return newGroup;
242}
243
244
245PCB_GROUP* PCB_GROUP::DeepDuplicate( bool addToParentGroup, BOARD_COMMIT* aCommit,
246 std::map<KIID, KIID>* aKIIDMap ) const
247{
248 PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( Duplicate( addToParentGroup, aCommit ) );
249 newGroup->m_items.clear();
250
251 if( aKIIDMap )
252 ( *aKIIDMap )[m_Uuid] = newGroup->m_Uuid;
253
254 for( EDA_ITEM* member : m_items )
255 {
256 // A PCB_GENERATOR owns member items that are not in this group's m_items, so a shallow
257 // copy would leave the duplicate referencing the original's members.
258 if( member->Type() == PCB_GROUP_T || member->Type() == PCB_GENERATOR_T )
259 {
260 newGroup->AddItem( static_cast<PCB_GROUP*>( member )->DeepDuplicate( IGNORE_PARENT_GROUP,
261 nullptr, aKIIDMap ) );
262 }
263 else
264 {
265 BOARD_ITEM* orig = static_cast<BOARD_ITEM*>( member );
266 BOARD_ITEM* memberDupe = orig->Duplicate( IGNORE_PARENT_GROUP );
267
268 if( aKIIDMap )
269 {
270 ( *aKIIDMap )[orig->m_Uuid] = memberDupe->m_Uuid;
271
272 // Children from ordered vectors so lockstep walk pairs reliably
273 // only unordered group membership above needs clone-time capture
274 std::vector<BOARD_ITEM*> dupeChildren;
275 memberDupe->RunOnChildren( [&]( BOARD_ITEM* aChild ) { dupeChildren.push_back( aChild ); },
277
278 std::size_t index = 0;
279 orig->RunOnChildren(
280 [&]( BOARD_ITEM* aChild )
281 {
282 if( index < dupeChildren.size() )
283 ( *aKIIDMap )[aChild->m_Uuid] = dupeChildren[index]->m_Uuid;
284
285 index++;
286 },
288 }
289
290 newGroup->AddItem( memberDupe );
291 }
292 }
293
294 return newGroup;
295}
296
297
299{
300 assert( aImage->Type() == PCB_GROUP_T );
301 PCB_GROUP* image = static_cast<PCB_GROUP*>( aImage );
302
303 std::swap( *this, *image );
304
306}
307
308
310{
311 // A group doesn't own its children (they're owned by the board), so undo doesn't do a
312 // deep clone when making an image. However, it's still safest to update the parentGroup
313 // pointers of the group's children. We must do it in the right order in case any of the
314 // children are shared (ie: image first, "this" second so that any shared children end up
315 // with "this").
316 aImage->RunOnChildren(
317 [&]( BOARD_ITEM* child )
318 {
319 child->SetParentGroup( aImage );
320 },
322
324 [&]( BOARD_ITEM* child )
325 {
326 child->SetParentGroup( this );
327 },
329}
330
331
332double PCB_GROUP::GetCoverageArea( int aTextMargin ) const
333{
334 double area = 0.0;
335
336 for( BOARD_ITEM* member : GetBoardItems() )
337 area += member->GetCoverageArea( aTextMargin );
338
339 return area;
340}
341
342
343bool PCB_GROUP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
344{
345 // Groups are selected by promoting a selection of one of their children
346 return false;
347}
348
349
350bool PCB_GROUP::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
351{
352 // Groups are selected by promoting a selection of one of their children
353 return false;
354}
355
356
357bool PCB_GROUP::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
358{
359 // Groups are selected by promoting a selection of one of their children
360 return false;
361}
362
363
365{
366 BOX2I bbox;
367
368 for( EDA_ITEM* item : m_items )
369 {
370 if( item->Type() == PCB_FOOTPRINT_T )
371 bbox.Merge( static_cast<FOOTPRINT*>( item )->GetBoundingBox( true ) );
372 else
373 bbox.Merge( item->GetBoundingBox() );
374 }
375
376 bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
377
378 return bbox;
379}
380
381
382std::shared_ptr<SHAPE> PCB_GROUP::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash,
383 DRC_CONSTRAINT_T aUsage ) const
384{
385 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
386
387 for( BOARD_ITEM* item : GetBoardItems() )
388 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash, aUsage )->Clone() );
389
390 return shape;
391}
392
393
394INSPECT_RESULT PCB_GROUP::Visit( INSPECTOR aInspector, void* aTestData,
395 const std::vector<KICAD_T>& aScanTypes )
396{
397 for( KICAD_T scanType : aScanTypes )
398 {
399 if( scanType == Type() )
400 {
401 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
403 }
404 }
405
407}
408
409
411{
412 LSET aSet;
413
414 for( EDA_ITEM* item : m_items )
415 aSet |= static_cast<BOARD_ITEM*>( item )->GetLayerSet();
416
417 return aSet;
418}
419
420
422{
423 // A group is on a layer if any item is on the layer
424 for( EDA_ITEM* item : m_items )
425 {
426 if( static_cast<BOARD_ITEM*>( item )->IsOnLayer( aLayer ) )
427 return true;
428 }
429
430 return false;
431}
432
433
434std::vector<int> PCB_GROUP::ViewGetLayers() const
435{
436 return { LAYER_ANCHOR };
437}
438
439
440double PCB_GROUP::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
441{
442 if( aView->IsLayerVisibleCached( LAYER_ANCHOR ) )
443 return LOD_SHOW;
444
445 return LOD_HIDE;
446}
447
448
449void PCB_GROUP::Move( const VECTOR2I& aMoveVector )
450{
451 for( EDA_ITEM* member : m_items )
452 static_cast<BOARD_ITEM*>( member )->Move( aMoveVector );
453}
454
455
456void PCB_GROUP::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
457{
458 for( EDA_ITEM* item : m_items )
459 static_cast<BOARD_ITEM*>( item )->Rotate( aRotCentre, aAngle );
460}
461
462
463void PCB_GROUP::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
464{
465 for( EDA_ITEM* item : m_items )
466 static_cast<BOARD_ITEM*>( item )->Flip( aCentre, aFlipDirection );
467}
468
469
470void PCB_GROUP::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
471{
472 // Footprints have no mirror, only flip. If the group holds one, leave the whole group alone
473 // rather than mirror the rest and tear it apart.
474 bool hasFootprint = false;
475
477 [&]( BOARD_ITEM* aChild )
478 {
479 if( aChild->Type() == PCB_FOOTPRINT_T )
480 hasFootprint = true;
481 },
483
484 if( hasFootprint )
485 return;
486
487 for( EDA_ITEM* item : m_items )
488 static_cast<BOARD_ITEM*>( item )->Mirror( aCentre, aFlipDirection );
489}
490
491
492wxString PCB_GROUP::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
493{
494 if( m_name.empty() )
495 return wxString::Format( _( "Unnamed Group, %zu members" ), m_items.size() );
496 else
497 return wxString::Format( _( "Group '%s', %zu members" ), m_name, m_items.size() );
498}
499
500
502{
503 return BITMAPS::module;
504}
505
506
507void PCB_GROUP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
508{
509 aList.emplace_back( _( "Group" ), m_name.empty() ? _( "<unnamed>" ) : m_name );
510 aList.emplace_back( _( "Members" ), wxString::Format( wxT( "%zu" ), m_items.size() ) );
511
512 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
513 aList.emplace_back( _( "Status" ), _( "Locked" ) );
514}
515
516
517bool PCB_GROUP::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
518{
519 return EDA_ITEM::Matches( UnescapeString( GetName() ), aSearchData );
520}
521
522
523void PCB_GROUP::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
524{
525 try
526 {
527 for( BOARD_ITEM* item : GetBoardItems() )
528 {
529 aFunction( item );
530
531 if( aMode == RECURSE_MODE::RECURSE && ( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T ) )
532 {
533 item->RunOnChildren( aFunction, RECURSE_MODE::RECURSE );
534 }
535 }
536 }
537 catch( std::bad_function_call& )
538 {
539 wxFAIL_MSG( wxT( "Error calling function in PCB_GROUP::RunOnChildren" ) );
540 }
541}
542
543
544bool PCB_GROUP::operator==( const BOARD_ITEM& aBoardItem ) const
545{
546 if( aBoardItem.Type() != Type() )
547 return false;
548
549 const PCB_GROUP& other = static_cast<const PCB_GROUP&>( aBoardItem );
550
551 return *this == other;
552}
553
554
555bool PCB_GROUP::operator==( const PCB_GROUP& aOther ) const
556{
557 if( m_items.size() != aOther.m_items.size() )
558 return false;
559
560 // The items in groups are in unordered sets hashed by the pointer value, so we need to
561 // order them by UUID (EDA_ITEM_SET) to compare
562 EDA_ITEM_SET itemSet( m_items.begin(), m_items.end() );
563 EDA_ITEM_SET otherItemSet( aOther.m_items.begin(), aOther.m_items.end() );
564
565 for( auto it1 = itemSet.begin(), it2 = otherItemSet.begin(); it1 != itemSet.end(); ++it1, ++it2 )
566 {
567 // Compare UUID instead of the items themselves because we only care if the contents
568 // of the group has changed, not which elements in the group have changed
569 if( ( *it1 )->m_Uuid != ( *it2 )->m_Uuid )
570 return false;
571 }
572
573 return true;
574}
575
576
577double PCB_GROUP::Similarity( const BOARD_ITEM& aOther ) const
578{
579 if( aOther.Type() != Type() )
580 return 0.0;
581
582 const PCB_GROUP& other = static_cast<const PCB_GROUP&>( aOther );
583
584 double similarity = 0.0;
585
586 for( EDA_ITEM* item : m_items )
587 {
588 for( EDA_ITEM* otherItem : other.m_items )
589 {
590 similarity += static_cast<BOARD_ITEM*>( item )->Similarity( *static_cast<BOARD_ITEM*>( otherItem ) );
591 }
592 }
593
594 return similarity / m_items.size();
595}
596
597
598static struct PCB_GROUP_DESC
599{
601 {
608
609 propMgr.Mask( TYPE_HASH( PCB_GROUP ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ) );
610 propMgr.Mask( TYPE_HASH( PCB_GROUP ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ) );
611 propMgr.Mask( TYPE_HASH( PCB_GROUP ), TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ) );
612
613 const wxString groupTab = _HKI( "Group Properties" );
614
615 propMgr.AddProperty( new PROPERTY<EDA_GROUP, wxString>( _HKI( "Name" ),
617 groupTab );
618 }
int index
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
friend class BOARD
Definition board_item.h:593
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
virtual BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const
Create a copy of this BOARD_ITEM.
void SetLocked(bool aLocked) override
Definition board_item.h:418
bool IsLocked() const override
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
Definition board_item.h:264
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:266
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:553
constexpr Vec Centre() const
Definition box2.h:94
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:594
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
virtual EDA_ITEM * ResolveItem(KIID &aID)=0
Search for an item in this commit that matches the provided KIID.
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
const LIB_ID & GetDesignBlockLibId() const
Definition eda_group.h:102
wxString m_name
Definition eda_group.h:106
std::unordered_set< EDA_ITEM * > m_items
Definition eda_group.h:105
std::unordered_set< EDA_ITEM * > & GetItems()
Definition eda_group.h:78
wxString GetName() const
Definition eda_group.h:75
bool HasDesignBlockLink() const
Definition eda_group.h:99
void SetDesignBlockLibId(const LIB_ID &aLibId)
Definition eda_group.h:101
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:58
virtual EDA_ITEM * AsEdaItem()=0
std::unordered_set< EDA_ITEM * > m_deserializedItems
Definition eda_group.h:109
void SetName(const wxString &aName)
Definition eda_group.h:76
const KIID m_Uuid
Definition eda_item.h:599
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:484
virtual void SetParentGroup(EDA_GROUP *aGroup)
Definition eda_item.h:115
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition view_item.h:176
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition view_item.h:181
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:441
Definition kiid.h:46
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
static bool WithinScope(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
PCB_GROUP * DeepClone() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pcb_group.cpp:82
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
static EDA_GROUP * TopLevelGroup(BOARD_ITEM *aItem, EDA_GROUP *aScope, bool isFootprintEditor)
bool operator==(const PCB_GROUP &aOther) const
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pcb_group.cpp:54
void SetPosition(const VECTOR2I &aNewpos) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
bool DeserializeGroup(const google::protobuf::Any &aContainer, COMMIT *aCommit) override
Deserializes the given protobuf message into this group.
Definition pcb_group.cpp:90
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
INSPECT_RESULT Visit(INSPECTOR aInspector, void *aTestData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
std::unordered_set< BOARD_ITEM * > GetBoardItems() const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
VECTOR2I GetPosition() const override
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
PCB_GROUP * DeepDuplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr, std::map< KIID, KIID > *aKIIDMap=nullptr) const
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void swapChildOwnership(PCB_GROUP *aImage)
Re-point the children of this group and aImage at whichever group now holds them.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
PCB_GROUP(BOARD_ITEM *aParent)
Definition pcb_group.cpp:43
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void swapData(BOARD_ITEM *aImage) override
void SetLocked(bool aLocked) override
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
This file is part of the common library.
DRC_CONSTRAINT_T
Definition drc_rule.h:49
#define _(s)
#define PCB_EDIT_FRAME_NAME
RECURSE_MODE
Definition eda_item.h:50
@ RECURSE
Definition eda_item.h:51
@ NO_RECURSE
Definition eda_item.h:52
INSPECT_RESULT
Definition eda_item.h:44
std::set< EDA_ITEM *, CompareByUuid > EDA_ITEM_SET
Definition eda_item.h:660
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:244
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
FLIP_DIRECTION
Definition mirror.h:23
Message panel definition file.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void PackLibId(types::LibraryIdentifier *aOutput, const LIB_ID &aId)
KICOMMON_API LIB_ID UnpackLibId(const types::LibraryIdentifier &aId)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
#define _HKI(x)
Definition page_info.cpp:40
EDA_GROUP * getClosestGroup(BOARD_ITEM *aItem, bool isFootprintEditor)
static struct PCB_GROUP_DESC _PCB_GROUP_DESC
EDA_GROUP * getNestedGroup(BOARD_ITEM *aItem, EDA_GROUP *aScope, bool isFootprintEditor)
Returns the top level group inside the aScope group, or nullptr.
Class to handle a set of BOARD_ITEMs.
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
EDA_GROUP * getNestedGroup(SCH_ITEM *aItem, EDA_GROUP *aScope, bool isSymbolEditor)
Returns the top level group inside the aScope group, or nullptr.
EDA_GROUP * getClosestGroup(SCH_ITEM *aItem, bool isSymbolEditor)
wxString UnescapeString(const wxString &aSource)
int delta
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:103
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708