KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_commit.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) 2016 CERN
5 * Copyright (C) 2020-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
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <macros.h>
27#include <board.h>
28#include <footprint.h>
29#include <lset.h>
30#include <pcb_group.h>
31#include <pcb_track.h>
32#include <tool/tool_manager.h>
35#include <view/view.h>
36#include <board_commit.h>
37#include <tools/pcb_tool_base.h>
38#include <tools/pcb_actions.h>
40#include <teardrop/teardrop.h>
41
42#include <functional>
43using namespace std::placeholders;
44
45
47 m_toolMgr( aTool->GetManager() ),
48 m_isBoardEditor( false ),
49 m_isFootprintEditor( false )
50{
51 if( PCB_TOOL_BASE* pcb_tool = dynamic_cast<PCB_TOOL_BASE*>( aTool ) )
52 {
53 m_isBoardEditor = pcb_tool->IsBoardEditor();
54 m_isFootprintEditor = pcb_tool->IsFootprintEditor();
55 }
56}
57
58
60 m_toolMgr( aFrame->GetToolManager() ),
61 m_isBoardEditor( aFrame->IsType( FRAME_PCB_EDITOR ) ),
62 m_isFootprintEditor( aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
63{
64}
65
66
68 m_toolMgr( aMgr ),
69 m_isBoardEditor( false ),
70 m_isFootprintEditor( false )
71{
72 EDA_DRAW_FRAME* frame = dynamic_cast<EDA_DRAW_FRAME*>( aMgr->GetToolHolder() );
73
74 if( frame && frame->IsType( FRAME_PCB_EDITOR ) )
75 m_isBoardEditor = true;
76 else if( frame && frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
78}
79
80
82{
83 return static_cast<BOARD*>( m_toolMgr->GetModel() );
84}
85
86
88{
89 // Many operations (move, rotate, etc.) are applied directly to a group's children, so they
90 // must be staged as well.
91 if( aChangeType == CHT_MODIFY )
92 {
93 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( aItem ) )
94 {
95 group->RunOnChildren(
96 [&]( BOARD_ITEM* child )
97 {
98 Stage( child, aChangeType );
99 } );
100 }
101 }
102
103 return COMMIT::Stage( aItem, aChangeType );
104}
105
106
107COMMIT& BOARD_COMMIT::Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType,
108 BASE_SCREEN* aScreen )
109{
110 return COMMIT::Stage( container, aChangeType, aScreen );
111}
112
113
115 BASE_SCREEN* aScreen )
116{
117 return COMMIT::Stage( aItems, aModFlag, aScreen );
118}
119
120
122{
123 wxCHECK( item, /* void */ );
124
126
127 if( item->Type() == PCB_ZONE_T )
128 zoneFillerTool->DirtyZone( static_cast<ZONE*>( item ) );
129
130 item->RunOnChildren( std::bind( &BOARD_COMMIT::dirtyIntersectingZones, this, _1, aChangeType ) );
131
132 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
133 BOX2I bbox = item->GetBoundingBox();
134 LSET layers = item->GetLayerSet();
135
136 if( layers.test( Edge_Cuts ) || layers.test( Margin ) )
137 layers = LSET::PhysicalLayersMask();
138 else
139 layers &= LSET::AllCuMask();
140
141 if( layers.any() )
142 {
143 for( ZONE* zone : board->Zones() )
144 {
145 if( zone->GetIsRuleArea() )
146 continue;
147
148 if( ( zone->GetLayerSet() & layers ).any()
149 && zone->GetBoundingBox().Intersects( bbox ) )
150 {
151 zoneFillerTool->DirtyZone( zone );
152 }
153 }
154 }
155}
156
157
158void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
159{
160 KIGFX::VIEW* view = m_toolMgr->GetView();
161 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
162 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
164
165 // Notification info
166 PICKED_ITEMS_LIST undoList;
167 bool itemsDeselected = false;
168 bool selectedModified = false;
169
170 // Dirty flags and lists
171 bool solderMaskDirty = false;
172 bool autofillZones = false;
173 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
174 std::set<PCB_TRACK*> staleTeardropTracks;
175 PCB_GROUP* addedGroup = nullptr;
176
177 if( Empty() )
178 return;
179
180 undoList.SetDescription( aMessage );
181
182 TEARDROP_MANAGER teardropMgr( board, m_toolMgr );
183 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
184
185 // Note: frame == nullptr happens in QA tests
186
187 std::vector<BOARD_ITEM*> bulkAddedItems;
188 std::vector<BOARD_ITEM*> bulkRemovedItems;
189 std::vector<BOARD_ITEM*> itemsChanged;
190
192 && !( aCommitFlags & ZONE_FILL_OP )
193 && ( frame && frame->GetPcbNewSettings()->m_AutoRefillZones ) )
194 {
195 autofillZones = true;
196
197 for( ZONE* zone : board->Zones() )
198 zone->CacheBoundingBox();
199 }
200
201 for( COMMIT_LINE& ent : m_changes )
202 {
203 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
204
205 if( m_isBoardEditor && boardItem )
206 {
207 if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
208 || boardItem->IsOnLayer( F_Mask ) || boardItem->IsOnLayer( B_Mask ) )
209 {
210 solderMaskDirty = true;
211 }
212
213 if( !( aCommitFlags & SKIP_TEARDROPS ) )
214 {
215 if( boardItem->Type() == PCB_FOOTPRINT_T )
216 {
217 for( PAD* pad : static_cast<FOOTPRINT*>( boardItem )->Pads() )
218 staleTeardropPadsAndVias.push_back( pad );
219 }
220 else if( boardItem->Type() == PCB_PAD_T || boardItem->Type() == PCB_VIA_T )
221 {
222 staleTeardropPadsAndVias.push_back( boardItem );
223 }
224 else if( boardItem->Type() == PCB_TRACE_T || boardItem->Type() == PCB_ARC_T )
225 {
226 PCB_TRACK* track = static_cast<PCB_TRACK*>( boardItem );
227
228 staleTeardropTracks.insert( track );
229
230 std::vector<PAD*> connectedPads;
231 std::vector<PCB_VIA*> connectedVias;
232
233 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
234
235 for( PAD* pad : connectedPads )
236 staleTeardropPadsAndVias.push_back( pad );
237
238 for( PCB_VIA* via : connectedVias )
239 staleTeardropPadsAndVias.push_back( via );
240 }
241 }
242 }
243
244 if( boardItem && boardItem->IsSelected() )
245 selectedModified = true;
246 }
247
248 // Old teardrops must be removed before connectivity is rebuilt
249 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
250 teardropMgr.RemoveTeardrops( *this, &staleTeardropPadsAndVias, &staleTeardropTracks );
251
252 for( COMMIT_LINE& ent : m_changes )
253 {
254 int changeType = ent.m_type & CHT_TYPE;
255 int changeFlags = ent.m_type & CHT_FLAGS;
256 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
257
258 wxASSERT( ent.m_item );
259 wxCHECK2( boardItem, continue );
260
261 switch( changeType )
262 {
263 case CHT_ADD:
264 if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup()
265 && PCB_GROUP::IsGroupableType( boardItem->Type() ) )
266 {
267 selTool->GetEnteredGroup()->AddItem( boardItem );
268 }
269
270 if( !( aCommitFlags & SKIP_UNDO ) )
271 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
272
273 if( !( changeFlags & CHT_DONE ) )
274 {
276 {
277 FOOTPRINT* parentFP = board->GetFirstFootprint();
278 wxCHECK2_MSG( parentFP, continue, "Commit thinks this is footprint editor, but "
279 "there is no first footprint!" );
280 parentFP->Add( boardItem );
281 }
282 else if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
283 {
284 parentFP->Add( boardItem );
285 }
286 else
287 {
288 board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
289 bulkAddedItems.push_back( boardItem );
290 }
291 }
292
293 if( boardItem->Type() == PCB_GROUP_T || boardItem->Type() == PCB_GENERATOR_T )
294 addedGroup = static_cast<PCB_GROUP*>( boardItem );
295
296 if( m_isBoardEditor && autofillZones && boardItem->Type() != PCB_MARKER_T )
297 dirtyIntersectingZones( boardItem, changeType );
298
299 if( view && boardItem->Type() != PCB_NETINFO_T )
300 view->Add( boardItem );
301
302 break;
303
304 case CHT_REMOVE:
305 {
306 FOOTPRINT* parentFP = boardItem->GetParentFootprint();
307 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
308
309 if( !( aCommitFlags & SKIP_UNDO ) )
310 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
311
312 if( boardItem->IsSelected() )
313 {
314 if( selTool )
315 selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
316
317 itemsDeselected = true;
318 }
319
320 if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
321 parentGroup->RemoveItem( boardItem );
322
323 if( parentFP && !( parentFP->GetFlags() & STRUCT_DELETED ) )
324 ent.m_parent = parentFP->m_Uuid;
325
326 if( m_isBoardEditor && autofillZones && boardItem->Type() != PCB_MARKER_T )
327 dirtyIntersectingZones( boardItem, changeType );
328
329 switch( boardItem->Type() )
330 {
331 case PCB_FIELD_T:
332 static_cast<PCB_FIELD*>( boardItem )->SetVisible( false );
333 break;
334
335 case PCB_TEXT_T:
336 case PCB_PAD_T:
337 case PCB_SHAPE_T: // a shape (normally not on copper layers)
338 case PCB_REFERENCE_IMAGE_T: // a bitmap on an associated layer
339 case PCB_GENERATOR_T: // a generator on a layer
340 case PCB_TEXTBOX_T: // a line-wrapped (and optionally bordered) text item
341 case PCB_TABLE_T: // rows and columns of tablecells
342 case PCB_TRACE_T: // a track segment (segment on a copper layer)
343 case PCB_ARC_T: // an arced track segment (segment on a copper layer)
344 case PCB_VIA_T: // a via (like track segment on a copper layer)
345 case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
346 case PCB_DIM_CENTER_T:
347 case PCB_DIM_RADIAL_T:
349 case PCB_DIM_LEADER_T: // a leader dimension
350 case PCB_TARGET_T: // a target (graphic item)
351 case PCB_MARKER_T: // a marker used to show something
352 case PCB_ZONE_T:
353 case PCB_FOOTPRINT_T:
354 case PCB_GROUP_T:
355 if( view )
356 view->Remove( boardItem );
357
358 if( !( changeFlags & CHT_DONE ) )
359 {
360 if( parentFP )
361 {
362 parentFP->Remove( boardItem );
363 }
364 else
365 {
366 board->Remove( boardItem, REMOVE_MODE::BULK );
367 bulkRemovedItems.push_back( boardItem );
368 }
369 }
370
371 break;
372
373 // Metadata items
374 case PCB_NETINFO_T:
375 board->Remove( boardItem, REMOVE_MODE::BULK );
376 bulkRemovedItems.push_back( boardItem );
377 break;
378
379 default: // other types do not need to (or should not) be handled
380 wxASSERT( false );
381 break;
382 }
383
384 // The item has been removed from the board; it is now owned by undo/redo.
385 boardItem->SetFlags( UR_TRANSIENT );
386
387 break;
388 }
389
390 case CHT_UNGROUP:
391 if( PCB_GROUP* group = boardItem->GetParentGroup() )
392 {
393 if( !( aCommitFlags & SKIP_UNDO ) )
394 {
395 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::UNGROUP );
396 itemWrapper.SetGroupId( group->m_Uuid );
397 undoList.PushItem( itemWrapper );
398 }
399
400 group->RemoveItem( boardItem );
401 }
402
403 break;
404
405 case CHT_GROUP:
406 if( addedGroup )
407 {
408 addedGroup->AddItem( boardItem );
409
410 if( !( aCommitFlags & SKIP_UNDO ) )
411 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::REGROUP ) );
412 }
413
414 break;
415
416 case CHT_MODIFY:
417 {
418 BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
419
420 if( !( aCommitFlags & SKIP_UNDO ) )
421 {
422 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
423 wxASSERT( boardItemCopy );
424 itemWrapper.SetLink( boardItemCopy );
425 undoList.PushItem( itemWrapper );
426 }
427
428 if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
429 {
430 if( boardItemCopy )
431 connectivity->MarkItemNetAsDirty( boardItemCopy );
432
433 connectivity->Update( boardItem );
434 }
435
436 if( m_isBoardEditor && autofillZones && boardItem->Type() != PCB_MARKER_T )
437 {
438 dirtyIntersectingZones( boardItemCopy, changeType ); // before
439 dirtyIntersectingZones( boardItem, changeType ); // after
440 }
441
442 if( view )
443 view->Update( boardItem );
444
445 itemsChanged.push_back( boardItem );
446
447 // if no undo entry is needed, the copy would create a memory leak
448 if( aCommitFlags & SKIP_UNDO )
449 delete ent.m_copy;
450
451 break;
452 }
453
454 default:
455 UNIMPLEMENTED_FOR( boardItem->GetClass() );
456 break;
457 }
458
459 boardItem->ClearEditFlags();
460 boardItem->RunOnDescendants(
461 [&]( BOARD_ITEM* item )
462 {
463 item->ClearEditFlags();
464 } );
465 }
466
467 if( m_isBoardEditor )
468 {
469 size_t num_changes = m_changes.size();
470
471 if( aCommitFlags & SKIP_CONNECTIVITY )
472 {
473 connectivity->ClearRatsnest();
474 connectivity->ClearLocalRatsnest();
475 }
476 else
477 {
478 connectivity->RecalculateRatsnest( this );
480 connectivity->ClearLocalRatsnest();
481
482 if( frame )
483 frame->GetCanvas()->RedrawRatsnest();
484
485 board->OnRatsnestChanged();
486 }
487
488 if( solderMaskDirty )
489 {
490 if( frame )
491 frame->HideSolderMask();
492 }
493
494 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
495 teardropMgr.UpdateTeardrops( *this, &staleTeardropPadsAndVias, &staleTeardropTracks );
496
497 // Log undo items for any connectivity or teardrop changes
498 for( size_t i = num_changes; i < m_changes.size(); ++i )
499 {
500 COMMIT_LINE& ent = m_changes[i];
501 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
502 BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
503
504 wxCHECK2( boardItem, continue );
505
506 if( !( aCommitFlags & SKIP_UNDO ) )
507 {
508 ITEM_PICKER itemWrapper( nullptr, boardItem, convert( ent.m_type & CHT_TYPE ) );
509 itemWrapper.SetLink( boardItemCopy );
510 undoList.PushItem( itemWrapper );
511 }
512 else
513 {
514 delete ent.m_copy;
515 }
516
517 if( view )
518 {
519 if( ( ent.m_type & CHT_TYPE ) == CHT_ADD )
520 view->Add( boardItem );
521 else if( ( ent.m_type & CHT_TYPE ) == CHT_REMOVE )
522 view->Remove( boardItem );
523 else
524 view->Update( boardItem );
525 }
526 }
527 }
528
529 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
530 board->OnItemsCompositeUpdate( bulkAddedItems, bulkRemovedItems, itemsChanged );
531
532 if( frame )
533 {
534 if( !( aCommitFlags & SKIP_UNDO ) )
535 {
536 if( aCommitFlags & APPEND_UNDO )
537 frame->AppendCopyToUndoList( undoList, UNDO_REDO::UNSPECIFIED );
538 else
539 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
540 }
541 }
542
544
545 if( itemsDeselected )
547
548 if( autofillZones )
550
551 if( selectedModified )
553
554 if( frame )
555 {
556 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
557 frame->OnModify();
558 else
560 }
561
562 clear();
563}
564
565
567{
568 return aItem;
569}
570
571
573{
574 return MakeImage( aItem );
575}
576
577
579{
580 EDA_ITEM* clone = aItem->Clone();
581
582 if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( clone ) )
583 board_item->SetParentGroup( nullptr );
584
585 clone->SetFlags( UR_TRANSIENT );
586
587 return clone;
588}
589
590
592{
593 PICKED_ITEMS_LIST undoList;
594 KIGFX::VIEW* view = m_toolMgr->GetView();
595 BOARD* board = (BOARD*) m_toolMgr->GetModel();
596 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
597
598 board->IncrementTimeStamp(); // clear caches
599
600 std::vector<BOARD_ITEM*> bulkAddedItems;
601 std::vector<BOARD_ITEM*> bulkRemovedItems;
602 std::vector<BOARD_ITEM*> itemsChanged;
603
604 for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
605 {
606 COMMIT_LINE& ent = *it;
607 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
608 int changeType = ent.m_type & CHT_TYPE;
609 int changeFlags = ent.m_type & CHT_FLAGS;
610
611 wxCHECK2( boardItem, continue );
612
613 switch( changeType )
614 {
615 case CHT_ADD:
616 // Items are auto-added to the parent group by BOARD_ITEM::Duplicate(), not when
617 // the commit is pushed.
618 if( PCB_GROUP* parentGroup = boardItem->GetParentGroup() )
619 {
620 if( GetStatus( parentGroup ) == 0 )
621 parentGroup->RemoveItem( boardItem );
622 }
623
624 if( !( changeFlags & CHT_DONE ) )
625 break;
626
627 view->Remove( boardItem );
628 connectivity->Remove( boardItem );
629
630 if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
631 {
632 parentFP->Remove( boardItem );
633 }
634 else
635 {
636 board->Remove( boardItem, REMOVE_MODE::BULK );
637 bulkRemovedItems.push_back( boardItem );
638 }
639
640 break;
641
642 case CHT_REMOVE:
643 if( !( changeFlags & CHT_DONE ) )
644 break;
645
646 view->Add( boardItem );
647 connectivity->Add( boardItem );
648
649 if( FOOTPRINT* parentFP = dynamic_cast<FOOTPRINT*>( board->GetItem( ent.m_parent ) ) )
650 {
651 parentFP->Add( boardItem, ADD_MODE::INSERT );
652 }
653 else
654 {
655 board->Add( boardItem, ADD_MODE::INSERT );
656 bulkAddedItems.push_back( boardItem );
657 }
658
659 break;
660
661 case CHT_MODIFY:
662 {
663 view->Remove( boardItem );
664 connectivity->Remove( boardItem );
665
666 BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
667 wxASSERT( boardItemCopy );
668 boardItem->SwapItemData( boardItemCopy );
669
670 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( boardItem ) )
671 {
672 group->RunOnChildren(
673 [&]( BOARD_ITEM* child )
674 {
675 child->SetParentGroup( group );
676 } );
677 }
678
679 view->Add( boardItem );
680 connectivity->Add( boardItem );
681 itemsChanged.push_back( boardItem );
682
683 delete ent.m_copy;
684 break;
685 }
686
687 default:
688 UNIMPLEMENTED_FOR( boardItem->GetClass() );
689 break;
690 }
691
692 boardItem->ClearEditFlags();
693 }
694
695 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
696 board->OnItemsCompositeUpdate( bulkAddedItems, bulkRemovedItems, itemsChanged );
697
698 if( m_isBoardEditor )
699 {
700 connectivity->RecalculateRatsnest();
702 board->OnRatsnestChanged();
703 }
704
706 selTool->RebuildSelection();
707
708 // Property panel needs to know about the reselect
710
711 clear();
712}
713
#define SKIP_CONNECTIVITY
Definition: board_commit.h:42
#define SKIP_SET_DIRTY
Definition: board_commit.h:41
#define APPEND_UNDO
Definition: board_commit.h:40
#define SKIP_UNDO
Definition: board_commit.h:39
#define ZONE_FILL_OP
Definition: board_commit.h:43
#define SKIP_TEARDROPS
Definition: board_commit.h:44
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
bool test(size_t pos) const
Definition: base_set.h:48
bool any() const
Definition: base_set.h:56
void dirtyIntersectingZones(BOARD_ITEM *item, int aChangeType)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
BOARD * GetBoard() const
virtual void Revert() override
static EDA_ITEM * MakeImage(EDA_ITEM *aItem)
bool m_isBoardEditor
Definition: board_commit.h:79
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:78
bool m_isFootprintEditor
Definition: board_commit.h:80
BOARD_COMMIT(EDA_DRAW_FRAME *aFrame)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:92
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:193
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:93
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:307
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:266
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:245
virtual void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction, int aDepth=0) const
Invoke a function on all descendants.
Definition: board_item.h:215
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all children.
Definition: board_item.h:209
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:289
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:983
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:1391
const ZONES & Zones() const
Definition: board.h:334
void OnItemsCompositeUpdate(std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
Notify the board and its listeners that items on the board have been modified in a composite operatio...
Definition: board.cpp:2680
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:447
void IncrementTimeStamp()
Definition: board.cpp:255
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
Definition: board.cpp:2689
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:296
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:1121
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:474
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:74
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr)
Definition: commit.cpp:48
bool Empty() const
Returns status of an item.
Definition: commit.h:144
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Definition: commit.cpp:129
void clear()
Definition: commit.h:165
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:195
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual void ClearEditFlags()
Definition: eda_item.h:141
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
bool IsSelected() const
Definition: eda_item.h:110
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
virtual wxString GetClass() const =0
Return the class name.
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:130
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:277
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:271
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:1046
std::deque< PAD * > & Pads()
Definition: footprint.h:205
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:983
void SetGroupId(KIID aId)
void SetLink(EDA_ITEM *aItem)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:317
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:357
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1687
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:732
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:822
Definition: pad.h:54
DISPLAY_OPTIONS m_Display
static TOOL_ACTION zoneFillDirty
Definition: pcb_actions.h:398
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)
Create a new entry in undo list of commands.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
virtual void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
static bool IsGroupableType(KICAD_T aType)
Check if the proposed type can be added to a group.
Definition: pcb_group.cpp:49
virtual bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:95
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80
The selection tool: currently supports:
PCB_GROUP * GetEnteredGroup()
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
A holder to handle information on schematic or board items.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) ...
Definition: teardrop.h:97
void UpdateTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks, bool aForceFullUpdate=false)
Update teardrops on a list of items.
Definition: teardrop.cpp:151
void RemoveTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks)
Remove teardrops connected to any dirty pads, vias or tracks.
Definition: teardrop.cpp:99
Base abstract interface for all kinds of tools.
Definition: tool_base.h:66
Master controller class:
Definition: tool_manager.h:62
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:402
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
EDA_ITEM * GetModel() const
Definition: tool_manager.h:398
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:391
Handle actions specific to filling copper zones.
void DirtyZone(ZONE *aZone)
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
CHANGE_TYPE
Types of changes.
Definition: commit.h:41
@ CHT_MODIFY
Definition: commit.h:44
@ CHT_GROUP
Definition: commit.h:45
@ CHT_REMOVE
Definition: commit.h:43
@ CHT_DONE
Flag to indicate the change is already applied.
Definition: commit.h:49
@ CHT_TYPE
Definition: commit.h:47
@ CHT_ADD
Definition: commit.h:42
@ CHT_UNGROUP
Definition: commit.h:46
@ CHT_FLAGS
Definition: commit.h:50
#define STRUCT_DELETED
flag indication structures to be erased
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_Mask
Definition: layer_ids.h:106
@ F_Mask
Definition: layer_ids.h:107
@ Margin
Definition: layer_ids.h:114
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
Class to handle a set of BOARD_ITEMs.
EDA_ITEM * m_copy
Optional copy of the item.
Definition: commit.h:158
CHANGE_TYPE m_type
Modification type.
Definition: commit.h:159
KIID m_parent
Parent item (primarily for undo of deleted items)
Definition: commit.h:160
EDA_ITEM * m_item
Main item that is added/deleted/modified.
Definition: commit.h:157
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:48
@ TA_MODEL_CHANGE
Definition: tool_event.h:120
@ TC_MESSAGE
Definition: tool_event.h:57
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:105
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition: typeinfo.h:91
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:103
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:110
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:99
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:106
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:101
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition: typeinfo.h:94
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:109
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:104
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...