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 <pcb_group.h>
30#include <pcb_track.h>
31#include <tool/tool_manager.h>
34#include <view/view.h>
35#include <board_commit.h>
36#include <tools/pcb_tool_base.h>
37#include <tools/pcb_actions.h>
39#include <teardrop/teardrop.h>
40
41#include <functional>
42using namespace std::placeholders;
43
44
46 m_toolMgr( aTool->GetManager() ),
47 m_isBoardEditor( false ),
48 m_isFootprintEditor( false )
49{
50 if( PCB_TOOL_BASE* pcb_tool = dynamic_cast<PCB_TOOL_BASE*>( aTool ) )
51 {
52 m_isBoardEditor = pcb_tool->IsBoardEditor();
53 m_isFootprintEditor = pcb_tool->IsFootprintEditor();
54 }
55}
56
57
59 m_toolMgr( aFrame->GetToolManager() ),
60 m_isBoardEditor( aFrame->IsType( FRAME_PCB_EDITOR ) ),
61 m_isFootprintEditor( aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
62{
63}
64
65
67 m_toolMgr( aMgr ),
68 m_isBoardEditor( false ),
69 m_isFootprintEditor( false )
70{
71 EDA_DRAW_FRAME* frame = dynamic_cast<EDA_DRAW_FRAME*>( aMgr->GetToolHolder() );
72
73 if( frame && frame->IsType( FRAME_PCB_EDITOR ) )
74 m_isBoardEditor = true;
75 else if( frame && frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
77}
78
79
81{
82 return static_cast<BOARD*>( m_toolMgr->GetModel() );
83}
84
85
87{
88 wxCHECK( aItem, *this );
89
90 // Many operations (move, rotate, etc.) are applied directly to a group's children, so they
91 // must be staged as well.
92 if( aChangeType == CHT_MODIFY )
93 {
94 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( aItem ) )
95 {
96 group->RunOnChildren(
97 [&]( BOARD_ITEM* child )
98 {
99 Stage( child, aChangeType );
100 } );
101 }
102 }
103
104 return COMMIT::Stage( aItem, aChangeType );
105}
106
107
108COMMIT& BOARD_COMMIT::Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType,
109 BASE_SCREEN* aScreen )
110{
111 return COMMIT::Stage( container, aChangeType, aScreen );
112}
113
114
116 BASE_SCREEN* aScreen )
117{
118 return COMMIT::Stage( aItems, aModFlag, aScreen );
119}
120
121
123{
124 wxCHECK( item, /* void */ );
125
127
128 if( item->Type() == PCB_ZONE_T )
129 zoneFillerTool->DirtyZone( static_cast<ZONE*>( item ) );
130
131 item->RunOnChildren( std::bind( &BOARD_COMMIT::dirtyIntersectingZones, this, _1, aChangeType ) );
132
133 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
134 BOX2I bbox = item->GetBoundingBox();
135 LSET layers = item->GetLayerSet();
136
137 if( layers.test( Edge_Cuts ) || layers.test( Margin ) )
138 layers = LSET::PhysicalLayersMask();
139 else
140 layers &= LSET::AllCuMask();
141
142 if( layers.any() )
143 {
144 for( ZONE* zone : board->Zones() )
145 {
146 if( zone->GetIsRuleArea() )
147 continue;
148
149 if( ( zone->GetLayerSet() & layers ).any()
150 && zone->GetBoundingBox().Intersects( bbox ) )
151 {
152 zoneFillerTool->DirtyZone( zone );
153 }
154 }
155 }
156}
157
158
159void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
160{
161 KIGFX::VIEW* view = m_toolMgr->GetView();
162 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
163 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
165
166 // Notification info
167 PICKED_ITEMS_LIST undoList;
168 bool itemsDeselected = false;
169 bool selectedModified = false;
170
171 // Dirty flags and lists
172 bool solderMaskDirty = false;
173 bool autofillZones = false;
174 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
175 std::set<PCB_TRACK*> staleTeardropTracks;
176 PCB_GROUP* addedGroup = nullptr;
177
178 if( Empty() )
179 return;
180
181 undoList.SetDescription( aMessage );
182
183 TEARDROP_MANAGER teardropMgr( board, m_toolMgr );
184 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
185
186 // Note: frame == nullptr happens in QA tests
187
188 std::vector<BOARD_ITEM*> bulkAddedItems;
189 std::vector<BOARD_ITEM*> bulkRemovedItems;
190 std::vector<BOARD_ITEM*> itemsChanged;
191
193 && !( aCommitFlags & ZONE_FILL_OP )
194 && ( frame && frame->GetPcbNewSettings()->m_AutoRefillZones ) )
195 {
196 autofillZones = true;
197
198 for( ZONE* zone : board->Zones() )
199 zone->CacheBoundingBox();
200 }
201
202 for( COMMIT_LINE& ent : m_changes )
203 {
204 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
205
206 if( m_isBoardEditor && boardItem )
207 {
208 if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
209 || boardItem->IsOnLayer( F_Mask ) || boardItem->IsOnLayer( B_Mask ) )
210 {
211 solderMaskDirty = true;
212 }
213
214 if( !( aCommitFlags & SKIP_TEARDROPS ) )
215 {
216 if( boardItem->Type() == PCB_FOOTPRINT_T )
217 {
218 for( PAD* pad : static_cast<FOOTPRINT*>( boardItem )->Pads() )
219 staleTeardropPadsAndVias.push_back( pad );
220 }
221 else if( boardItem->Type() == PCB_PAD_T || boardItem->Type() == PCB_VIA_T )
222 {
223 staleTeardropPadsAndVias.push_back( boardItem );
224 }
225 else if( boardItem->Type() == PCB_TRACE_T || boardItem->Type() == PCB_ARC_T )
226 {
227 PCB_TRACK* track = static_cast<PCB_TRACK*>( boardItem );
228
229 staleTeardropTracks.insert( track );
230
231 std::vector<PAD*> connectedPads;
232 std::vector<PCB_VIA*> connectedVias;
233
234 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
235
236 for( PAD* pad : connectedPads )
237 staleTeardropPadsAndVias.push_back( pad );
238
239 for( PCB_VIA* via : connectedVias )
240 staleTeardropPadsAndVias.push_back( via );
241 }
242 }
243 }
244
245 if( boardItem && boardItem->IsSelected() )
246 selectedModified = true;
247 }
248
249 // Old teardrops must be removed before connectivity is rebuilt
250 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
251 teardropMgr.RemoveTeardrops( *this, &staleTeardropPadsAndVias, &staleTeardropTracks );
252
253 for( COMMIT_LINE& ent : m_changes )
254 {
255 int changeType = ent.m_type & CHT_TYPE;
256 int changeFlags = ent.m_type & CHT_FLAGS;
257 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
258
259 wxASSERT( ent.m_item );
260 wxCHECK2( boardItem, continue );
261
262 switch( changeType )
263 {
264 case CHT_ADD:
265 if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup()
266 && PCB_GROUP::IsGroupableType( boardItem->Type() ) )
267 {
268 selTool->GetEnteredGroup()->AddItem( boardItem );
269 }
270
271 if( !( aCommitFlags & SKIP_UNDO ) )
272 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
273
274 if( !( changeFlags & CHT_DONE ) )
275 {
277 {
278 FOOTPRINT* parentFP = board->GetFirstFootprint();
279 wxCHECK2_MSG( parentFP, continue, "Commit thinks this is footprint editor, but "
280 "there is no first footprint!" );
281 parentFP->Add( boardItem );
282 }
283 else if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
284 {
285 parentFP->Add( boardItem );
286 }
287 else
288 {
289 board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
290 bulkAddedItems.push_back( boardItem );
291 }
292 }
293
294 if( boardItem->Type() == PCB_GROUP_T )
295 addedGroup = static_cast<PCB_GROUP*>( boardItem );
296
297 if( autofillZones && boardItem->Type() != PCB_MARKER_T )
298 dirtyIntersectingZones( boardItem, changeType );
299
300 if( view && boardItem->Type() != PCB_NETINFO_T )
301 view->Add( boardItem );
302
303 break;
304
305 case CHT_REMOVE:
306 {
307 FOOTPRINT* parentFP = boardItem->GetParentFootprint();
308 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
309
310 if( !( aCommitFlags & SKIP_UNDO ) )
311 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
312
313 if( boardItem->IsSelected() )
314 {
315 if( selTool )
316 selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
317
318 itemsDeselected = true;
319 }
320
321 if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
322 parentGroup->RemoveItem( boardItem );
323
324 if( parentFP && !( parentFP->GetFlags() & STRUCT_DELETED ) )
325 ent.m_parent = parentFP->m_Uuid;
326
327 if( autofillZones )
328 dirtyIntersectingZones( boardItem, changeType );
329
330 switch( boardItem->Type() )
331 {
332 case PCB_FIELD_T:
333 static_cast<PCB_FIELD*>( boardItem )->SetVisible( false );
334 break;
335
336 case PCB_TEXT_T:
337 case PCB_PAD_T:
338 case PCB_SHAPE_T: // a shape (normally not on copper layers)
339 case PCB_REFERENCE_IMAGE_T: // a bitmap on an associated layer
340 case PCB_GENERATOR_T: // a generator on a layer
341 case PCB_TEXTBOX_T: // a line-wrapped (and optionally bordered) text item
342 case PCB_TABLE_T: // rows and columns of tablecells
343 case PCB_TRACE_T: // a track segment (segment on a copper layer)
344 case PCB_ARC_T: // an arced track segment (segment on a copper layer)
345 case PCB_VIA_T: // a via (like track segment on a copper layer)
346 case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
347 case PCB_DIM_CENTER_T:
348 case PCB_DIM_RADIAL_T:
350 case PCB_DIM_LEADER_T: // a leader dimension
351 case PCB_TARGET_T: // a target (graphic item)
352 case PCB_MARKER_T: // a marker used to show something
353 case PCB_ZONE_T:
354 case PCB_FOOTPRINT_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 case PCB_GROUP_T:
374 if( view )
375 view->Remove( boardItem );
376
377 if( !( changeFlags & CHT_DONE ) )
378 {
379 if( parentFP )
380 {
381 parentFP->Remove( boardItem );
382 }
383 else
384 {
385 board->Remove( boardItem, REMOVE_MODE::BULK );
386 bulkRemovedItems.push_back( boardItem );
387 }
388 }
389
390 break;
391
392 // Metadata items
393 case PCB_NETINFO_T:
394 board->Remove( boardItem, REMOVE_MODE::BULK );
395 bulkRemovedItems.push_back( boardItem );
396 break;
397
398 default: // other types do not need to (or should not) be handled
399 wxASSERT( false );
400 break;
401 }
402
403 // The item has been removed from the board; it is now owned by undo/redo.
404 boardItem->SetFlags( UR_TRANSIENT );
405
406 break;
407 }
408
409 case CHT_UNGROUP:
410 if( PCB_GROUP* group = boardItem->GetParentGroup() )
411 {
412 if( !( aCommitFlags & SKIP_UNDO ) )
413 {
414 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::UNGROUP );
415 itemWrapper.SetGroupId( group->m_Uuid );
416 undoList.PushItem( itemWrapper );
417 }
418
419 group->RemoveItem( boardItem );
420 }
421
422 break;
423
424 case CHT_GROUP:
425 if( addedGroup )
426 {
427 addedGroup->AddItem( boardItem );
428
429 if( !( aCommitFlags & SKIP_UNDO ) )
430 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::REGROUP ) );
431 }
432
433 break;
434
435 case CHT_MODIFY:
436 {
437 BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
438
439 if( !( aCommitFlags & SKIP_UNDO ) )
440 {
441 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
442 wxASSERT( boardItemCopy );
443 itemWrapper.SetLink( boardItemCopy );
444 undoList.PushItem( itemWrapper );
445 }
446
447 if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
448 {
449 if( boardItemCopy )
450 connectivity->MarkItemNetAsDirty( boardItemCopy );
451
452 connectivity->Update( boardItem );
453 }
454
455 if( m_isBoardEditor && autofillZones )
456 {
457 dirtyIntersectingZones( boardItemCopy, changeType ); // before
458 dirtyIntersectingZones( boardItem, changeType ); // after
459 }
460
461 if( view )
462 view->Update( boardItem );
463
464 itemsChanged.push_back( boardItem );
465
466 // if no undo entry is needed, the copy would create a memory leak
467 if( aCommitFlags & SKIP_UNDO )
468 delete ent.m_copy;
469
470 break;
471 }
472
473 default:
474 UNIMPLEMENTED_FOR( boardItem->GetClass() );
475 break;
476 }
477
478 boardItem->ClearEditFlags();
479 boardItem->RunOnDescendants(
480 [&]( BOARD_ITEM* item )
481 {
482 item->ClearEditFlags();
483 } );
484 }
485
486 if( bulkAddedItems.size() > 0 )
487 board->FinalizeBulkAdd( bulkAddedItems );
488
489 if( bulkRemovedItems.size() > 0 )
490 board->FinalizeBulkRemove( bulkRemovedItems );
491
492 if( itemsChanged.size() > 0 )
493 board->OnItemsChanged( itemsChanged );
494
495 if( m_isBoardEditor )
496 {
497 size_t num_changes = m_changes.size();
498
499 if( aCommitFlags & SKIP_CONNECTIVITY )
500 {
501 connectivity->ClearRatsnest();
502 connectivity->ClearLocalRatsnest();
503 }
504 else
505 {
506 connectivity->RecalculateRatsnest( this );
508 connectivity->ClearLocalRatsnest();
509
510 if( frame )
511 frame->GetCanvas()->RedrawRatsnest();
512
513 board->OnRatsnestChanged();
514 }
515
516 if( solderMaskDirty )
517 {
518 if( frame )
519 frame->HideSolderMask();
520 }
521
522 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
523 teardropMgr.UpdateTeardrops( *this, &staleTeardropPadsAndVias, &staleTeardropTracks );
524
525 // Log undo items for any connectivity or teardrop changes
526 for( size_t i = num_changes; i < m_changes.size(); ++i )
527 {
528 COMMIT_LINE& ent = m_changes[i];
529 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
530 BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
531
532 wxCHECK2( boardItem, continue );
533
534 if( !( aCommitFlags & SKIP_UNDO ) )
535 {
536 ITEM_PICKER itemWrapper( nullptr, boardItem, convert( ent.m_type & CHT_TYPE ) );
537 itemWrapper.SetLink( boardItemCopy );
538 undoList.PushItem( itemWrapper );
539 }
540 else
541 {
542 delete ent.m_copy;
543 }
544
545 if( view )
546 {
547 if( ( ent.m_type & CHT_TYPE ) == CHT_ADD )
548 view->Add( boardItem );
549 else if( ( ent.m_type & CHT_TYPE ) == CHT_REMOVE )
550 view->Remove( boardItem );
551 else
552 view->Update( boardItem );
553 }
554 }
555 }
556
557 if( frame )
558 {
559 if( !( aCommitFlags & SKIP_UNDO ) )
560 {
561 if( aCommitFlags & APPEND_UNDO )
562 frame->AppendCopyToUndoList( undoList, UNDO_REDO::UNSPECIFIED );
563 else
564 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
565 }
566 }
567
569
570 if( itemsDeselected )
572
573 if( autofillZones )
575
576 if( selectedModified )
578
579 if( frame )
580 {
581 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
582 frame->OnModify();
583 else
585 }
586
587 clear();
588}
589
590
592{
593 return aItem;
594}
595
596
598{
599 return MakeImage( aItem );
600}
601
602
604{
605 EDA_ITEM* clone = aItem->Clone();
606
607 if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( clone ) )
608 board_item->SetParentGroup( nullptr );
609
610 clone->SetFlags( UR_TRANSIENT );
611
612 return clone;
613}
614
615
617{
618 PICKED_ITEMS_LIST undoList;
619 KIGFX::VIEW* view = m_toolMgr->GetView();
620 BOARD* board = (BOARD*) m_toolMgr->GetModel();
621 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
622
623 board->IncrementTimeStamp(); // clear caches
624
625 std::vector<BOARD_ITEM*> bulkAddedItems;
626 std::vector<BOARD_ITEM*> bulkRemovedItems;
627 std::vector<BOARD_ITEM*> itemsChanged;
628
629 for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
630 {
631 COMMIT_LINE& ent = *it;
632 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
633 int changeType = ent.m_type & CHT_TYPE;
634 int changeFlags = ent.m_type & CHT_FLAGS;
635
636 wxCHECK2( boardItem, continue );
637
638 switch( changeType )
639 {
640 case CHT_ADD:
641 // Items are auto-added to the parent group by BOARD_ITEM::Duplicate(), not when
642 // the commit is pushed.
643 if( PCB_GROUP* parentGroup = boardItem->GetParentGroup() )
644 {
645 if( GetStatus( parentGroup ) == 0 )
646 parentGroup->RemoveItem( boardItem );
647 }
648
649 if( !( changeFlags & CHT_DONE ) )
650 break;
651
652 view->Remove( boardItem );
653 connectivity->Remove( boardItem );
654
655 if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
656 {
657 parentFP->Remove( boardItem );
658 }
659 else
660 {
661 board->Remove( boardItem, REMOVE_MODE::BULK );
662 bulkRemovedItems.push_back( boardItem );
663 }
664
665 break;
666
667 case CHT_REMOVE:
668 if( !( changeFlags & CHT_DONE ) )
669 break;
670
671 view->Add( boardItem );
672 connectivity->Add( boardItem );
673
674 if( FOOTPRINT* parentFP = dynamic_cast<FOOTPRINT*>( board->GetItem( ent.m_parent ) ) )
675 {
676 parentFP->Add( boardItem, ADD_MODE::INSERT );
677 }
678 else
679 {
680 board->Add( boardItem, ADD_MODE::INSERT );
681 bulkAddedItems.push_back( boardItem );
682 }
683
684 break;
685
686 case CHT_MODIFY:
687 {
688 view->Remove( boardItem );
689 connectivity->Remove( boardItem );
690
691 BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
692 wxASSERT( boardItemCopy );
693 boardItem->SwapItemData( boardItemCopy );
694
695 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( boardItem ) )
696 {
697 group->RunOnChildren(
698 [&]( BOARD_ITEM* child )
699 {
700 child->SetParentGroup( group );
701 } );
702 }
703
704 view->Add( boardItem );
705 connectivity->Add( boardItem );
706 itemsChanged.push_back( boardItem );
707
708 delete ent.m_copy;
709 break;
710 }
711
712 default:
713 UNIMPLEMENTED_FOR( boardItem->GetClass() );
714 break;
715 }
716
717 boardItem->ClearEditFlags();
718 }
719
720 if( bulkAddedItems.size() > 0 )
721 board->FinalizeBulkAdd( bulkAddedItems );
722
723 if( bulkRemovedItems.size() > 0 )
724 board->FinalizeBulkRemove( bulkRemovedItems );
725
726 if( itemsChanged.size() > 0 )
727 board->OnItemsChanged( itemsChanged );
728
729 if( m_isBoardEditor )
730 {
731 connectivity->RecalculateRatsnest();
733 board->OnRatsnestChanged();
734 }
735
737 selTool->RebuildSelection();
738
739 // Property panel needs to know about the reselect
741
742 clear();
743}
744
#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
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:77
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:90
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:175
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:291
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:231
virtual void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction, int aDepth=0) const
Invoke a function on all descendants.
Definition: board_item.h:201
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all children.
Definition: board_item.h:195
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:891
ZONES & Zones()
Definition: board.h:324
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:1166
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:414
void IncrementTimeStamp()
Definition: board.cpp:258
void FinalizeBulkRemove(std::vector< BOARD_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
Definition: board.cpp:1001
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
Definition: board.cpp:2390
void FinalizeBulkAdd(std::vector< BOARD_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
Definition: board.cpp:995
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:298
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:1007
void OnItemsChanged(std::vector< BOARD_ITEM * > &aItems)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:2384
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:441
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:85
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:123
const KIID m_Uuid
Definition: eda_item.h:482
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsSelected() const
Definition: eda_item.h:106
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.
void ClearEditFlags()
Definition: eda_item.h:137
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:126
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:264
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:258
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:783
PADS & Pads()
Definition: footprint.h:188
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:720
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:315
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:354
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:1636
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:573
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:960
Definition: pad.h:59
DISPLAY_OPTIONS m_Display
static TOOL_ACTION zoneFillDirty
Definition: pcb_actions.h:393
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:51
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:57
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:389
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
EDA_ITEM * GetModel() const
Definition: tool_manager.h:385
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:378
Handle actions specific to filling copper zones.
void DirtyZone(ZONE *aZone)
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
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:114
@ B_Mask
Definition: layer_ids.h:107
@ F_Mask
Definition: layer_ids.h:108
@ Margin
Definition: layer_ids.h:115
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...