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
87bool PCB_GROUP::DeserializeGroup( const google::protobuf::Any& aContainer, COMMIT* aCommit )
88{
89 kiapi::board::types::Group group;
90
91 if( !aContainer.UnpackTo( &group ) )
92 return false;
93
94 SetUuidDirect( KIID( group.id().value() ) );
95 SetName( wxString( group.name().c_str(), wxConvUTF8 ) );
96 SetLocked( group.locked() == kiapi::common::types::LockedState::LS_LOCKED );
97
98 BOARD* board = GetBoard();
99
100 if( !board )
101 return false;
102
103 for( const kiapi::common::types::KIID& itemId : group.items() )
104 {
105 KIID id( itemId.value() );
106 EDA_ITEM* item = board->ResolveItem( id, true );
107
108 if( !item && aCommit )
109 item = aCommit->ResolveItem( id );
110
111 if( item )
112 AddItem( item );
113 }
114
115 if( group.has_lib_id() )
117
118 kiapi::common::UnpackCustomProperties( group.custom_properties(), *this );
119
120 return true;
121}
122
123std::unordered_set<BOARD_ITEM*> PCB_GROUP::GetBoardItems() const
124{
125 std::unordered_set<BOARD_ITEM*> items;
126
127 for( EDA_ITEM* item : m_items )
128 {
129 if( item->IsBOARD_ITEM() )
130 items.insert( static_cast<BOARD_ITEM*>( item ) );
131 }
132
133 return items;
134}
135
136
137/*
138 * @return if not in the footprint editor and aItem is in a footprint, returns the
139 * footprint's parent group. Otherwise, returns the aItem's parent group.
140 */
141EDA_GROUP* getClosestGroup( BOARD_ITEM* aItem, bool isFootprintEditor )
142{
143 if( !isFootprintEditor && aItem->GetParent() && aItem->GetParent()->Type() == PCB_FOOTPRINT_T )
144 return aItem->GetParent()->GetParentGroup();
145 else
146 return aItem->GetParentGroup();
147}
148
149
151EDA_GROUP* getNestedGroup( BOARD_ITEM* aItem, EDA_GROUP* aScope, bool isFootprintEditor )
152{
153 EDA_GROUP* group = getClosestGroup( aItem, isFootprintEditor );
154
155 if( group == aScope )
156 return nullptr;
157
158 while( group && group->AsEdaItem()->GetParentGroup() && group->AsEdaItem()->GetParentGroup() != aScope )
159 group = group->AsEdaItem()->GetParentGroup();
160
161 return group;
162}
163
164
165EDA_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* aItem, EDA_GROUP* aScope, bool isFootprintEditor )
166{
167 return getNestedGroup( aItem, aScope, isFootprintEditor );
168}
169
170
171bool PCB_GROUP::WithinScope( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
172{
173 EDA_GROUP* group = getClosestGroup( aItem, isFootprintEditor );
174
175 if( group && group == aScope )
176 return true;
177
178 EDA_GROUP* nested = getNestedGroup( aItem, aScope, isFootprintEditor );
179
180 return nested && nested->AsEdaItem()->GetParentGroup() && ( nested->AsEdaItem()->GetParentGroup() == aScope );
181}
182
183
185{
186 return GetBoundingBox().Centre();
187}
188
189
190void PCB_GROUP::SetPosition( const VECTOR2I& aNewpos )
191{
192 VECTOR2I delta = aNewpos - GetPosition();
193
194 Move( delta );
195}
196
197
198void PCB_GROUP::SetLocked( bool aLockState )
199{
200 BOARD_ITEM::SetLocked( aLockState );
201
203 [&]( BOARD_ITEM* child )
204 {
205 child->SetLocked( aLockState );
206 },
208}
209
210
212{
213 // Use copy constructor to get the same uuid and other fields
214 PCB_GROUP* newGroup = new PCB_GROUP( *this );
215 return newGroup;
216}
217
218
220{
221 // Use copy constructor to get the same uuid and other fields
222 PCB_GROUP* newGroup = new PCB_GROUP( *this );
223 newGroup->m_items.clear();
224
225 for( EDA_ITEM* member : m_items )
226 {
227 if( member->Type() == PCB_GROUP_T )
228 newGroup->AddItem( static_cast<PCB_GROUP*>( member )->DeepClone() );
229 else if( member->Type() == PCB_GENERATOR_T )
230 newGroup->AddItem( static_cast<PCB_GENERATOR*>( member )->DeepClone() );
231 else
232 newGroup->AddItem( static_cast<BOARD_ITEM*>( member->Clone() ) );
233 }
234
235 return newGroup;
236}
237
238
239PCB_GROUP* PCB_GROUP::DeepDuplicate( bool addToParentGroup, BOARD_COMMIT* aCommit,
240 std::map<KIID, KIID>* aKIIDMap ) const
241{
242 PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( Duplicate( addToParentGroup, aCommit ) );
243 newGroup->m_items.clear();
244
245 if( aKIIDMap )
246 ( *aKIIDMap )[m_Uuid] = newGroup->m_Uuid;
247
248 for( EDA_ITEM* member : m_items )
249 {
250 // A PCB_GENERATOR owns member items that are not in this group's m_items, so a shallow
251 // copy would leave the duplicate referencing the original's members.
252 if( member->Type() == PCB_GROUP_T || member->Type() == PCB_GENERATOR_T )
253 {
254 newGroup->AddItem( static_cast<PCB_GROUP*>( member )->DeepDuplicate( IGNORE_PARENT_GROUP,
255 nullptr, aKIIDMap ) );
256 }
257 else
258 {
259 BOARD_ITEM* orig = static_cast<BOARD_ITEM*>( member );
260 BOARD_ITEM* memberDupe = orig->Duplicate( IGNORE_PARENT_GROUP );
261
262 if( aKIIDMap )
263 {
264 ( *aKIIDMap )[orig->m_Uuid] = memberDupe->m_Uuid;
265
266 // Children from ordered vectors so lockstep walk pairs reliably
267 // only unordered group membership above needs clone-time capture
268 std::vector<BOARD_ITEM*> dupeChildren;
269 memberDupe->RunOnChildren( [&]( BOARD_ITEM* aChild ) { dupeChildren.push_back( aChild ); },
271
272 std::size_t index = 0;
273 orig->RunOnChildren(
274 [&]( BOARD_ITEM* aChild )
275 {
276 if( index < dupeChildren.size() )
277 ( *aKIIDMap )[aChild->m_Uuid] = dupeChildren[index]->m_Uuid;
278
279 index++;
280 },
282 }
283
284 newGroup->AddItem( memberDupe );
285 }
286 }
287
288 return newGroup;
289}
290
291
293{
294 assert( aImage->Type() == PCB_GROUP_T );
295 PCB_GROUP* image = static_cast<PCB_GROUP*>( aImage );
296
297 std::swap( *this, *image );
298
300}
301
302
304{
305 // A group doesn't own its children (they're owned by the board), so undo doesn't do a
306 // deep clone when making an image. However, it's still safest to update the parentGroup
307 // pointers of the group's children. We must do it in the right order in case any of the
308 // children are shared (ie: image first, "this" second so that any shared children end up
309 // with "this").
310 aImage->RunOnChildren(
311 [&]( BOARD_ITEM* child )
312 {
313 child->SetParentGroup( aImage );
314 },
316
318 [&]( BOARD_ITEM* child )
319 {
320 child->SetParentGroup( this );
321 },
323}
324
325
326bool PCB_GROUP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
327{
328 // Groups are selected by promoting a selection of one of their children
329 return false;
330}
331
332
333bool PCB_GROUP::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
334{
335 // Groups are selected by promoting a selection of one of their children
336 return false;
337}
338
339
340bool PCB_GROUP::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
341{
342 // Groups are selected by promoting a selection of one of their children
343 return false;
344}
345
346
348{
349 BOX2I bbox;
350
351 for( EDA_ITEM* item : m_items )
352 {
353 if( item->Type() == PCB_FOOTPRINT_T )
354 bbox.Merge( static_cast<FOOTPRINT*>( item )->GetBoundingBox( true ) );
355 else
356 bbox.Merge( item->GetBoundingBox() );
357 }
358
359 bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
360
361 return bbox;
362}
363
364
365std::shared_ptr<SHAPE> PCB_GROUP::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash,
366 DRC_CONSTRAINT_T aUsage ) const
367{
368 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
369
370 for( BOARD_ITEM* item : GetBoardItems() )
371 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash, aUsage )->Clone() );
372
373 return shape;
374}
375
376
377INSPECT_RESULT PCB_GROUP::Visit( INSPECTOR aInspector, void* aTestData,
378 const std::vector<KICAD_T>& aScanTypes )
379{
380 for( KICAD_T scanType : aScanTypes )
381 {
382 if( scanType == Type() )
383 {
384 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
386 }
387 }
388
390}
391
392
394{
395 LSET aSet;
396
397 for( EDA_ITEM* item : m_items )
398 aSet |= static_cast<BOARD_ITEM*>( item )->GetLayerSet();
399
400 return aSet;
401}
402
403
405{
406 // A group is on a layer if any item is on the layer
407 for( EDA_ITEM* item : m_items )
408 {
409 if( static_cast<BOARD_ITEM*>( item )->IsOnLayer( aLayer ) )
410 return true;
411 }
412
413 return false;
414}
415
416
417std::vector<int> PCB_GROUP::ViewGetLayers() const
418{
419 return { LAYER_ANCHOR };
420}
421
422
423double PCB_GROUP::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
424{
425 if( aView->IsLayerVisibleCached( LAYER_ANCHOR ) )
426 return LOD_SHOW;
427
428 return LOD_HIDE;
429}
430
431
432void PCB_GROUP::Move( const VECTOR2I& aMoveVector )
433{
434 for( EDA_ITEM* member : m_items )
435 static_cast<BOARD_ITEM*>( member )->Move( aMoveVector );
436}
437
438
439void PCB_GROUP::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
440{
441 for( EDA_ITEM* item : m_items )
442 static_cast<BOARD_ITEM*>( item )->Rotate( aRotCentre, aAngle );
443}
444
445
446void PCB_GROUP::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
447{
448 for( EDA_ITEM* item : m_items )
449 static_cast<BOARD_ITEM*>( item )->Flip( aCentre, aFlipDirection );
450}
451
452
453void PCB_GROUP::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
454{
455 // Footprints have no mirror, only flip. If the group holds one, leave the whole group alone
456 // rather than mirror the rest and tear it apart.
457 bool hasFootprint = false;
458
460 [&]( BOARD_ITEM* aChild )
461 {
462 if( aChild->Type() == PCB_FOOTPRINT_T )
463 hasFootprint = true;
464 },
466
467 if( hasFootprint )
468 return;
469
470 for( EDA_ITEM* item : m_items )
471 static_cast<BOARD_ITEM*>( item )->Mirror( aCentre, aFlipDirection );
472}
473
474
475wxString PCB_GROUP::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
476{
477 if( m_name.empty() )
478 return wxString::Format( _( "Unnamed Group, %zu members" ), m_items.size() );
479 else
480 return wxString::Format( _( "Group '%s', %zu members" ), m_name, m_items.size() );
481}
482
483
485{
486 return BITMAPS::module;
487}
488
489
490void PCB_GROUP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
491{
492 aList.emplace_back( _( "Group" ), m_name.empty() ? _( "<unnamed>" ) : m_name );
493 aList.emplace_back( _( "Members" ), wxString::Format( wxT( "%zu" ), m_items.size() ) );
494
495 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
496 aList.emplace_back( _( "Status" ), _( "Locked" ) );
497}
498
499
500bool PCB_GROUP::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
501{
502 return EDA_ITEM::Matches( UnescapeString( GetName() ), aSearchData );
503}
504
505
506void PCB_GROUP::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
507{
508 try
509 {
510 for( BOARD_ITEM* item : GetBoardItems() )
511 {
512 aFunction( item );
513
514 if( aMode == RECURSE_MODE::RECURSE && ( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T ) )
515 {
516 item->RunOnChildren( aFunction, RECURSE_MODE::RECURSE );
517 }
518 }
519 }
520 catch( std::bad_function_call& )
521 {
522 wxFAIL_MSG( wxT( "Error calling function in PCB_GROUP::RunOnChildren" ) );
523 }
524}
525
526
527bool PCB_GROUP::operator==( const BOARD_ITEM& aBoardItem ) const
528{
529 if( aBoardItem.Type() != Type() )
530 return false;
531
532 const PCB_GROUP& other = static_cast<const PCB_GROUP&>( aBoardItem );
533
534 return *this == other;
535}
536
537
538bool PCB_GROUP::operator==( const PCB_GROUP& aOther ) const
539{
540 if( m_items.size() != aOther.m_items.size() )
541 return false;
542
543 // The items in groups are in unordered sets hashed by the pointer value, so we need to
544 // order them by UUID (EDA_ITEM_SET) to compare
545 EDA_ITEM_SET itemSet( m_items.begin(), m_items.end() );
546 EDA_ITEM_SET otherItemSet( aOther.m_items.begin(), aOther.m_items.end() );
547
548 for( auto it1 = itemSet.begin(), it2 = otherItemSet.begin(); it1 != itemSet.end(); ++it1, ++it2 )
549 {
550 // Compare UUID instead of the items themselves because we only care if the contents
551 // of the group has changed, not which elements in the group have changed
552 if( ( *it1 )->m_Uuid != ( *it2 )->m_Uuid )
553 return false;
554 }
555
556 return true;
557}
558
559
560double PCB_GROUP::Similarity( const BOARD_ITEM& aOther ) const
561{
562 if( aOther.Type() != Type() )
563 return 0.0;
564
565 const PCB_GROUP& other = static_cast<const PCB_GROUP&>( aOther );
566
567 double similarity = 0.0;
568
569 for( EDA_ITEM* item : m_items )
570 {
571 for( EDA_ITEM* otherItem : other.m_items )
572 {
573 similarity += static_cast<BOARD_ITEM*>( item )->Similarity( *static_cast<BOARD_ITEM*>( otherItem ) );
574 }
575 }
576
577 return similarity / m_items.size();
578}
579
580
581static struct PCB_GROUP_DESC
582{
584 {
591
592 propMgr.Mask( TYPE_HASH( PCB_GROUP ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ) );
593 propMgr.Mask( TYPE_HASH( PCB_GROUP ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ) );
594 propMgr.Mask( TYPE_HASH( PCB_GROUP ), TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ) );
595
596 const wxString groupTab = _HKI( "Group Properties" );
597
598 propMgr.AddProperty( new PROPERTY<EDA_GROUP, wxString>( _HKI( "Name" ),
600 groupTab );
601 }
int index
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
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:578
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:417
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:653
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:88
wxString m_name
Definition eda_group.h:92
std::unordered_set< EDA_ITEM * > m_items
Definition eda_group.h:91
std::unordered_set< EDA_ITEM * > & GetItems()
Definition eda_group.h:64
wxString GetName() const
Definition eda_group.h:61
bool HasDesignBlockLink() const
Definition eda_group.h:85
void SetDesignBlockLibId(const LIB_ID &aLibId)
Definition eda_group.h:87
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:58
virtual EDA_ITEM * AsEdaItem()=0
void SetName(const wxString &aName)
Definition eda_group.h:62
const KIID m_Uuid
Definition eda_item.h:597
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:482
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:439
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.
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:87
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
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
Provide class metadata.Helper macro to map type hashes to names.
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:658
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)
Definition property.h:74
#define REGISTER_TYPE(x)
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:683