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