KiCad PCB EDA Suite
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 <board.h>
27#include <footprint.h>
28#include <pcb_group.h>
29#include <tool/tool_manager.h>
32#include <view/view.h>
33#include <board_commit.h>
34#include <tools/pcb_tool_base.h>
35#include <tools/pcb_actions.h>
37
38#include <functional>
39using namespace std::placeholders;
40
41
43 m_toolMgr( aToolMgr ),
44 m_isFootprintEditor( false ),
45 m_isBoardEditor( false )
46{
47}
48
49
51{
52 m_toolMgr = aTool->GetManager();
55}
56
57
59{
60 m_toolMgr = aFrame->GetToolManager();
63}
64
65
67{
68}
69
70
72{
73 return static_cast<BOARD*>( m_toolMgr->GetModel() );
74}
75
76
78{
79 wxCHECK( aItem, *this );
80
82
83 // If aItem belongs a footprint, the full footprint will be saved because undo/redo does
84 // not handle "sub items" modifications. This has implications for auto-zone-refill, so
85 // we need to store a bit more information.
86 if( aChangeType == CHT_MODIFY )
87 {
88 if( aItem->Type() == PCB_FOOTPRINT_T )
89 {
90 static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
91 [&]( BOARD_ITEM* child )
92 {
94 } );
95 }
96 else if( aItem->GetParent() && aItem->GetParent()->Type() == PCB_FOOTPRINT_T )
97 {
98 if( aItem->Type() == PCB_GROUP_T )
99 {
100 static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
101 [&]( BOARD_ITEM* child )
102 {
103 child->SetFlags( IS_MODIFIED_CHILD );
104 } );
105 }
106 else
107 {
108 aItem->SetFlags( IS_MODIFIED_CHILD );
109 }
110
111 aItem = aItem->GetParent();
112 }
113 else if( aItem->Type() == PCB_GROUP_T )
114 {
115 // Many operations on group (move, rotate, etc.) are applied directly to their
116 // children, so it's the children that must be staged.
117 static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
118 [&]( BOARD_ITEM* child )
119 {
120 COMMIT::Stage( child, aChangeType );
121 } );
122 }
123 }
124
125 return COMMIT::Stage( aItem, aChangeType );
126}
127
128
129COMMIT& BOARD_COMMIT::Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType )
130{
131 return COMMIT::Stage( container, aChangeType );
132}
133
134
136{
137 return COMMIT::Stage( aItems, aModFlag );
138}
139
140
142{
143 wxCHECK( item, /* void */ );
144
146
147 if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
148 zoneFillerTool->DirtyZone( static_cast<ZONE*>( item ) );
149
150 if( item->Type() == PCB_FOOTPRINT_T )
151 {
152 static_cast<FOOTPRINT*>( item )->RunOnChildren(
153 [&]( BOARD_ITEM* child )
154 {
155 if( aChangeType != CHT_MODIFY || ( child->GetFlags() & IS_MODIFIED_CHILD ) )
156 dirtyIntersectingZones( child, aChangeType );
157
159 } );
160 }
161 else if( item->Type() == PCB_GROUP_T )
162 {
163 static_cast<PCB_GROUP*>( item )->RunOnChildren(
164 [&]( BOARD_ITEM* child )
165 {
166 dirtyIntersectingZones( child, aChangeType );
168 } );
169 }
170 else
171 {
172 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
173 BOX2I bbox = item->GetBoundingBox();
174 LSET layers = item->GetLayerSet();
175
176 if( layers.test( Edge_Cuts ) || layers.test( Margin ) )
177 layers = LSET::PhysicalLayersMask();
178 else
179 layers &= LSET::AllCuMask();
180
181 if( layers.any() )
182 {
183 for( ZONE* zone : board->Zones() )
184 {
185 if( zone->GetIsRuleArea() )
186 continue;
187
188 if( ( zone->GetLayerSet() & layers ).any()
189 && zone->GetBoundingBox().Intersects( bbox ) )
190 {
191 zoneFillerTool->DirtyZone( zone );
192 }
193 }
194 }
195
197 }
198}
199
200
201void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
202{
203 // Objects potentially interested in changes:
204 PICKED_ITEMS_LIST undoList;
205 KIGFX::VIEW* view = m_toolMgr->GetView();
206 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
207 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
208 std::set<EDA_ITEM*> savedModules;
210 bool itemsDeselected = false;
211 bool solderMaskDirty = false;
212 bool autofillZones = false;
213 bool selectedModified = false;
214
215 if( Empty() )
216 return;
217
218 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
219
220 // Note:
221 // frame == nullptr happens in QA tests
222 // in this case m_isBoardEditor and m_isFootprintEditor are set to false
223 // But we also test frame == nullptr mainly to make Coverity happy
224
225 std::vector<BOARD_ITEM*> bulkAddedItems;
226 std::vector<BOARD_ITEM*> bulkRemovedItems;
227 std::vector<BOARD_ITEM*> itemsChanged;
228
230 && !( aCommitFlags & ZONE_FILL_OP )
231 && ( frame && frame->GetPcbNewSettings()->m_AutoRefillZones ) )
232 {
233 autofillZones = true;
234
235 for( ZONE* zone : board->Zones() )
236 zone->CacheBoundingBox();
237 }
238
239 for( COMMIT_LINE& ent : m_changes )
240 {
241 int changeType = ent.m_type & CHT_TYPE;
242 int changeFlags = ent.m_type & CHT_FLAGS;
243 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
244
245 wxASSERT( ent.m_item );
246
247 // Module items need to be saved in the undo buffer before modification
249 {
250 // Be sure that we are storing a footprint
251 if( ent.m_item->Type() != PCB_FOOTPRINT_T )
252 {
253 ent.m_item = ent.m_item->GetParent();
254 wxASSERT( ent.m_item );
255 }
256
257 // We have not saved the footprint yet, so let's create an entry
258 if( savedModules.count( ent.m_item ) == 0 )
259 {
260 if( !ent.m_copy )
261 {
262 wxASSERT( changeType != CHT_MODIFY ); // too late to make a copy..
263 ent.m_copy = makeImage( ent.m_item );
264 }
265
266 wxASSERT( ent.m_item->Type() == PCB_FOOTPRINT_T );
267 wxASSERT( ent.m_copy->Type() == PCB_FOOTPRINT_T );
268
269 if( !( aCommitFlags & SKIP_UNDO ) && frame )
270 {
271 ITEM_PICKER itemWrapper( nullptr, ent.m_item, UNDO_REDO::CHANGED );
272 itemWrapper.SetLink( ent.m_copy );
273 undoList.PushItem( itemWrapper );
274 frame->SaveCopyInUndoList( undoList, UNDO_REDO::CHANGED );
275 }
276
277 savedModules.insert( ent.m_item );
278 }
279 }
280
281 if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
282 || boardItem->IsOnLayer( F_Mask ) || boardItem->IsOnLayer( B_Mask ) )
283 {
284 solderMaskDirty = true;
285 }
286
287 if( boardItem->IsSelected() )
288 selectedModified = true;
289
290 // If we're the footprint editor, the boardItem will always be the containing footprint
291 if( m_isFootprintEditor && boardItem->Type() == PCB_FOOTPRINT_T )
292 {
293 static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
294 [&selectedModified]( BOARD_ITEM* aItem )
295 {
296 if( aItem->HasFlag( IS_MODIFIED_CHILD ) )
297 selectedModified = true;
298 } );
299 }
300
301 switch( changeType )
302 {
303 case CHT_ADD:
304 {
305 if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup()
306 && PCB_GROUP::IsGroupableType( boardItem->Type() ) )
307 {
308 selTool->GetEnteredGroup()->AddItem( boardItem );
309 }
310
312 {
313 // footprints inside footprints are not supported yet
314 wxASSERT( boardItem->Type() != PCB_FOOTPRINT_T );
315
316 boardItem->SetParent( board->Footprints().front() );
317
318 if( !( changeFlags & CHT_DONE ) )
319 board->Footprints().front()->Add( boardItem );
320 }
321 else if( boardItem->Type() == PCB_PAD_T
322 || boardItem->Type() == PCB_FP_TEXT_T
323 || boardItem->Type() == PCB_FP_TEXTBOX_T
324 || boardItem->Type() == PCB_FP_SHAPE_T
325 || boardItem->Type() == PCB_FP_DIM_ALIGNED_T
326 || boardItem->Type() == PCB_FP_DIM_LEADER_T
327 || boardItem->Type() == PCB_FP_DIM_CENTER_T
328 || boardItem->Type() == PCB_FP_DIM_RADIAL_T
329 || boardItem->Type() == PCB_FP_DIM_ORTHOGONAL_T
330 || boardItem->Type() == PCB_FP_ZONE_T )
331 {
332 wxASSERT( boardItem->GetParent() &&
333 boardItem->GetParent()->Type() == PCB_FOOTPRINT_T );
334 }
335 else
336 {
337 if( !( aCommitFlags & SKIP_UNDO ) )
338 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
339
340 if( !( changeFlags & CHT_DONE ) )
341 {
342 board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
343 bulkAddedItems.push_back( boardItem );
344 }
345 }
346
347 if( autofillZones && boardItem->Type() != PCB_MARKER_T )
348 dirtyIntersectingZones( boardItem, changeType );
349
350 if( view && boardItem->Type() != PCB_NETINFO_T )
351 view->Add( boardItem );
352
353 break;
354 }
355
356 case CHT_REMOVE:
357 {
358 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
359
360 if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
361 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
362
363 if( boardItem->IsSelected() )
364 {
365 if( selTool )
366 selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
367
368 itemsDeselected = true;
369 }
370
371 if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
372 parentGroup->RemoveItem( boardItem );
373
374 if( autofillZones )
375 dirtyIntersectingZones( boardItem, changeType );
376
377 switch( boardItem->Type() )
378 {
379 // Footprint items
380 case PCB_PAD_T:
381 case PCB_FP_SHAPE_T:
382 case PCB_FP_TEXT_T:
383 case PCB_FP_TEXTBOX_T:
389 case PCB_FP_ZONE_T:
390 // This level can only handle footprint children in the footprint editor as
391 // only in that case has the entire footprint (and all its children) already
392 // been saved for undo.
393 wxASSERT( m_isFootprintEditor );
394
395 if( boardItem->Type() == PCB_FP_TEXT_T )
396 {
397 FP_TEXT* text = static_cast<FP_TEXT*>( boardItem );
398
399 // don't allow deletion of Reference or Value
400 if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
401 break;
402 }
403
404 if( view )
405 view->Remove( boardItem );
406
407 if( !( changeFlags & CHT_DONE ) )
408 {
409 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem->GetParent() );
410 wxASSERT( footprint && footprint->Type() == PCB_FOOTPRINT_T );
411 footprint->Delete( boardItem );
412 }
413
414 break;
415
416 // Board items
417 case PCB_SHAPE_T: // a shape (normally not on copper layers)
418 case PCB_BITMAP_T: // a bitmap on a user layer
419 case PCB_TEXT_T: // a text on a layer
420 case PCB_TEXTBOX_T: // a wrapped text on a layer
421 case PCB_TRACE_T: // a track segment (segment on a copper layer)
422 case PCB_ARC_T: // an arced track segment (segment on a copper layer)
423 case PCB_VIA_T: // a via (like track segment on a copper layer)
424 case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
425 case PCB_DIM_CENTER_T:
426 case PCB_DIM_RADIAL_T:
428 case PCB_DIM_LEADER_T: // a leader dimension
429 case PCB_TARGET_T: // a target (graphic item)
430 case PCB_MARKER_T: // a marker used to show something
431 case PCB_ZONE_T:
432 if( view )
433 view->Remove( boardItem );
434
435 if( !( changeFlags & CHT_DONE ) )
436 {
437 board->Remove( boardItem, REMOVE_MODE::BULK );
438 bulkRemovedItems.push_back( boardItem );
439 }
440
441 break;
442
443 case PCB_FOOTPRINT_T:
444 {
445 // No support for nested footprints (yet)
446 wxASSERT( !m_isFootprintEditor );
447
448 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
449
450 if( view )
451 view->Remove( footprint );
452
453 footprint->ClearFlags();
454
455 if( !( changeFlags & CHT_DONE ) )
456 {
457 board->Remove( footprint, REMOVE_MODE::BULK ); // handles connectivity
458 bulkRemovedItems.push_back( footprint );
459 }
460 }
461
462 break;
463
464 case PCB_GROUP_T:
465 if( view )
466 view->Remove( boardItem );
467
468 if( !( changeFlags & CHT_DONE ) )
469 {
471 board->GetFirstFootprint()->Remove( boardItem );
472 else
473 {
474 board->Remove( boardItem, REMOVE_MODE::BULK );
475 bulkRemovedItems.push_back( boardItem );
476 }
477 }
478
479 break;
480
481 // Metadata items
482 case PCB_NETINFO_T:
483 board->Remove( boardItem, REMOVE_MODE::BULK );
484 bulkRemovedItems.push_back( boardItem );
485 break;
486
487 default: // other types do not need to (or should not) be handled
488 wxASSERT( false );
489 break;
490 }
491
492 break;
493 }
494
495 case CHT_MODIFY:
496 {
497 if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
498 {
499 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
500 wxASSERT( ent.m_copy );
501 itemWrapper.SetLink( ent.m_copy );
502 undoList.PushItem( itemWrapper );
503 }
504
505 if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
506 {
507 if( ent.m_copy )
508 connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
509
510 connectivity->Update( boardItem );
511 }
512
513 if( autofillZones )
514 {
515 dirtyIntersectingZones( static_cast<BOARD_ITEM*>( ent.m_copy ), changeType ); // before
516 dirtyIntersectingZones( boardItem, changeType ); // after
517 }
518
519 if( view )
520 {
521 view->Update( boardItem );
522
524 {
525 static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
526 [&]( BOARD_ITEM* aChild )
527 {
528 view->Update( aChild );
529 });
530 }
531 }
532
533 itemsChanged.push_back( boardItem );
534
535 // if no undo entry is needed, the copy would create a memory leak
536 if( aCommitFlags & SKIP_UNDO )
537 delete ent.m_copy;
538
539 break;
540 }
541
542 default:
543 wxASSERT( false );
544 break;
545 }
546 }
547
548 if( bulkAddedItems.size() > 0 )
549 board->FinalizeBulkAdd( bulkAddedItems );
550
551 if( bulkRemovedItems.size() > 0 )
552 board->FinalizeBulkRemove( bulkRemovedItems );
553
554 if( itemsChanged.size() > 0 )
555 board->OnItemsChanged( itemsChanged );
556
557 if( m_isBoardEditor )
558 {
559 size_t num_changes = m_changes.size();
560
561 if( aCommitFlags & SKIP_CONNECTIVITY )
562 {
563 connectivity->ClearRatsnest();
564 connectivity->ClearLocalRatsnest();
565 }
566 else
567 {
568 connectivity->RecalculateRatsnest( this );
570 connectivity->ClearLocalRatsnest();
571
572 if( frame )
573 frame->GetCanvas()->RedrawRatsnest();
574 }
575
576 if( solderMaskDirty )
577 {
578 if( frame )
579 frame->HideSolderMask();
580 }
581
582 // Log undo items for any connectivity changes
583 for( size_t i = num_changes; i < m_changes.size(); ++i )
584 {
585 COMMIT_LINE& ent = m_changes[i];
586
587 wxASSERT( ( ent.m_type & CHT_TYPE ) == CHT_MODIFY );
588
589 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
590
591 if( !( aCommitFlags & SKIP_UNDO ) )
592 {
593 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
594 wxASSERT( ent.m_copy );
595 itemWrapper.SetLink( ent.m_copy );
596 undoList.PushItem( itemWrapper );
597 }
598 else
599 {
600 delete ent.m_copy;
601 }
602
603 if( view )
604 view->Update( boardItem );
605 }
606 }
607
608 if( m_isBoardEditor && !( aCommitFlags & SKIP_UNDO ) && frame )
609 {
610 if( aCommitFlags & APPEND_UNDO )
612 else
613 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
614 }
615
617
618 if( itemsDeselected )
620
621 if( autofillZones )
623
624 if( selectedModified )
626
627 if( frame )
628 {
629 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
630 frame->OnModify();
631 else
633 }
634
635 clear();
636}
637
638
640{
641 switch( aItem->Type() )
642 {
643 case PCB_PAD_T:
644 case PCB_FP_SHAPE_T:
645 case PCB_FP_TEXT_T:
646 case PCB_FP_TEXTBOX_T:
652 case PCB_FP_ZONE_T:
653 return aItem->GetParent();
654
655 case PCB_ZONE_T:
656 wxASSERT( !dynamic_cast<FOOTPRINT*>( aItem->GetParent() ) );
657 return aItem;
658
659 default:
660 break;
661 }
662
663 return aItem;
664}
665
666
668{
669 BOARD_ITEM* clone = static_cast<BOARD_ITEM*>( aItem->Clone() );
670
671 clone->SetParentGroup( nullptr );
672 return clone;
673}
674
675
677{
678 PICKED_ITEMS_LIST undoList;
679 KIGFX::VIEW* view = m_toolMgr->GetView();
680 BOARD* board = (BOARD*) m_toolMgr->GetModel();
681 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
682
683 board->IncrementTimeStamp(); // clear caches
684
685 std::vector<BOARD_ITEM*> bulkAddedItems;
686 std::vector<BOARD_ITEM*> bulkRemovedItems;
687 std::vector<BOARD_ITEM*> itemsChanged;
688
689 for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
690 {
691 COMMIT_LINE& ent = *it;
692 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
693 BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
694 int changeType = ent.m_type & CHT_TYPE;
695 int changeFlags = ent.m_type & CHT_FLAGS;
696
697 switch( changeType )
698 {
699 case CHT_ADD:
700 if( !( changeFlags & CHT_DONE ) )
701 break;
702
703 view->Remove( item );
704 connectivity->Remove( item );
705 board->Remove( item, REMOVE_MODE::BULK );
706 bulkRemovedItems.push_back( item );
707 break;
708
709 case CHT_REMOVE:
710 if( !( changeFlags & CHT_DONE ) )
711 break;
712
713 view->Add( item );
714 connectivity->Add( item );
715 board->Add( item, ADD_MODE::INSERT );
716 bulkAddedItems.push_back( item );
717 break;
718
719 case CHT_MODIFY:
720 {
721 view->Remove( item );
722 connectivity->Remove( item );
723
724 item->SwapItemData( copy );
725
726 if( item->Type() == PCB_GROUP_T )
727 {
728 PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
729
730 group->RunOnChildren( [&]( BOARD_ITEM* child )
731 {
732 child->SetParentGroup( group );
733 } );
734 }
735
736 view->Add( item );
737 connectivity->Add( item );
738 board->OnItemChanged( item );
739 itemsChanged.push_back( item );
740
741 delete copy;
742 break;
743 }
744
745 default:
746 wxASSERT( false );
747 break;
748 }
749 }
750
751 if( bulkAddedItems.size() > 0 )
752 board->FinalizeBulkAdd( bulkAddedItems );
753
754 if( bulkRemovedItems.size() > 0 )
755 board->FinalizeBulkRemove( bulkRemovedItems );
756
757 if( itemsChanged.size() > 0 )
758 board->OnItemsChanged( itemsChanged );
759
760 if ( !m_isFootprintEditor )
761 {
762 connectivity->RecalculateRatsnest();
764 }
765
767 selTool->RebuildSelection();
768
769 clear();
770}
771
#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
virtual ~BOARD_COMMIT()
void dirtyIntersectingZones(BOARD_ITEM *item, int aChangeType)
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
BOARD * GetBoard() const
BOARD_COMMIT(TOOL_MANAGER *aToolMgr)
virtual void Revert() override
bool m_isBoardEditor
Definition: board_commit.h:75
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:73
bool m_isFootprintEditor
Definition: board_commit.h:74
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the container and deletes it.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:83
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:166
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:84
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:197
virtual bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const
Test to see if this object is on the given layer.
Definition: board_item.h:257
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:175
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:2071
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:772
ZONES & Zones()
Definition: board.h:317
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:403
FOOTPRINTS & Footprints()
Definition: board.h:311
void IncrementTimeStamp()
Definition: board.cpp:234
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:875
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:869
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:274
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:881
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:2077
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:430
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:72
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType)
Definition: commit.cpp:48
bool Empty() const
Returns status of an item.
Definition: commit.h:139
void clear()
Definition: commit.h:156
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:180
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:139
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
bool IsSelected() const
Definition: eda_item.h:106
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:208
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:628
@ TEXT_is_DIVERS
Definition: fp_text.h:51
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:69
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349
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:1591
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:870
DISPLAY_OPTIONS m_Display
static TOOL_ACTION zoneFillDirty
Definition: pcb_actions.h:345
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 ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)=0
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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:43
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:95
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.
bool IsFootprintEditor() const
bool IsBoardEditor() const
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:144
Master controller class:
Definition: tool_manager.h:55
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.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:285
Handle actions specific to filling copper zones.
void DirtyZone(ZONE *aZone)
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
CHANGE_TYPE
Types of changes.
Definition: commit.h:39
@ CHT_MODIFY
Definition: commit.h:42
@ CHT_REMOVE
Definition: commit.h:41
@ CHT_DONE
Definition: commit.h:47
@ CHT_TYPE
Flag to indicate the change is already applied, just notify observers (not compatible with CHT_MODIFY...
Definition: commit.h:43
@ CHT_ADD
Definition: commit.h:40
@ CHT_FLAGS
Definition: commit.h:48
#define IS_MODIFIED_CHILD
when a child is promoted to its parent for a COMMIT, this flag indicates the modified child
#define STRUCT_DELETED
flag indication structures to be erased
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ 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
EDA_ITEM * m_copy
Optional copy of the item.
Definition: commit.h:151
CHANGE_TYPE m_type
Modification type.
Definition: commit.h:152
EDA_ITEM * m_item
Main item that is added/deleted/modified.
Definition: commit.h:150
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:45
@ TA_MODEL_CHANGE
Definition: tool_event.h:116
@ TC_MESSAGE
Definition: tool_event.h:53
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ 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:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ 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:106
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:114
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...