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-2022 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 m_resolveNetConflicts( false )
47{
48}
49
50
52 m_resolveNetConflicts( false )
53{
54 m_toolMgr = aTool->GetManager();
57}
58
59
61 m_resolveNetConflicts( false )
62{
63 m_toolMgr = aFrame->GetToolManager();
66}
67
68
70{
71}
72
73
75{
76 return static_cast<BOARD*>( m_toolMgr->GetModel() );
77}
78
79
81{
82 // if aItem belongs a footprint, the full footprint will be saved
83 // because undo/redo does not handle "sub items" modifications
84 if( aItem && aItem->Type() != PCB_FOOTPRINT_T && aChangeType == CHT_MODIFY )
85 {
86 EDA_ITEM* item = aItem->GetParent();
87
88 if( item && item->Type() == PCB_FOOTPRINT_T ) // means aItem belongs a footprint
89 aItem = item;
90 }
91
92 return COMMIT::Stage( aItem, aChangeType );
93}
94
95
96COMMIT& BOARD_COMMIT::Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType )
97{
98 return COMMIT::Stage( container, aChangeType );
99}
100
101
103{
104 return COMMIT::Stage( aItems, aModFlag );
105}
106
107
109{
110 wxCHECK( item, /* void */ );
111
113
114 if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
115 zoneFillerTool->DirtyZone( static_cast<ZONE*>( item ) );
116
117 if( item->Type() == PCB_FOOTPRINT_T )
118 {
119 static_cast<FOOTPRINT*>( item )->RunOnChildren(
120 [&]( BOARD_ITEM* child )
121 {
122 dirtyIntersectingZones( child );
123 } );
124 }
125 else if( item->Type() == PCB_GROUP_T )
126 {
127 static_cast<PCB_GROUP*>( item )->RunOnChildren(
128 [&]( BOARD_ITEM* child )
129 {
130 dirtyIntersectingZones( child );
131 } );
132 }
133 else
134 {
135 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
136 BOX2I bbox = item->GetBoundingBox();
137 LSET layers = item->GetLayerSet();
138
139 if( layers.test( Edge_Cuts ) || layers.test( Margin ) )
140 layers = LSET::PhysicalLayersMask();
141 else
142 layers &= LSET::AllCuMask();
143
144 if( layers.any() )
145 {
146 for( ZONE* zone : board->Zones() )
147 {
148 if( zone->GetIsRuleArea() )
149 continue;
150
151 if( ( zone->GetLayerSet() & layers ).any()
152 && zone->GetBoundingBox().Intersects( bbox ) )
153 {
154 zoneFillerTool->DirtyZone( zone );
155 }
156 }
157 }
158 }
159}
160
161
162void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
163{
164 // Objects potentially interested in changes:
165 PICKED_ITEMS_LIST undoList;
166 KIGFX::VIEW* view = m_toolMgr->GetView();
167 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
168 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
169 std::set<EDA_ITEM*> savedModules;
171 bool itemsDeselected = false;
172 bool solderMaskDirty = false;
173 bool autofillZones = false;
174
175 if( Empty() )
176 return;
177
178 // Note:
179 // frame == nullptr happens in QA tests
180 // in this case m_isBoardEditor and m_isFootprintEditor are set to false
181 // But we also test frame == nullptr mainly to make Coverity happy
182
183 std::vector<BOARD_ITEM*> bulkAddedItems;
184 std::vector<BOARD_ITEM*> bulkRemovedItems;
185 std::vector<BOARD_ITEM*> itemsChanged;
186
188 && !( aCommitFlags & ZONE_FILL_OP )
189 && ( frame && frame->GetPcbNewSettings()->m_AutoRefillZones ) )
190 {
191 autofillZones = true;
192
193 for( ZONE* zone : board->Zones() )
194 zone->CacheBoundingBox();
195 }
196
197 for( COMMIT_LINE& ent : m_changes )
198 {
199 int changeType = ent.m_type & CHT_TYPE;
200 int changeFlags = ent.m_type & CHT_FLAGS;
201 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
202
203 wxASSERT( ent.m_item );
204
205 // Module items need to be saved in the undo buffer before modification
207 {
208 // Be sure that we are storing a footprint
209 if( ent.m_item->Type() != PCB_FOOTPRINT_T )
210 {
211 ent.m_item = ent.m_item->GetParent();
212 wxASSERT( ent.m_item );
213 }
214
215 // We have not saved the footprint yet, so let's create an entry
216 if( savedModules.count( ent.m_item ) == 0 )
217 {
218 if( !ent.m_copy )
219 {
220 wxASSERT( changeType != CHT_MODIFY ); // too late to make a copy..
221 ent.m_copy = ent.m_item->Clone();
222 }
223
224 wxASSERT( ent.m_item->Type() == PCB_FOOTPRINT_T );
225 wxASSERT( ent.m_copy->Type() == PCB_FOOTPRINT_T );
226
227 if( !( aCommitFlags & SKIP_UNDO ) && frame )
228 {
229 ITEM_PICKER itemWrapper( nullptr, ent.m_item, UNDO_REDO::CHANGED );
230 itemWrapper.SetLink( ent.m_copy );
231 undoList.PushItem( itemWrapper );
232 frame->SaveCopyInUndoList( undoList, UNDO_REDO::CHANGED );
233 }
234
235 savedModules.insert( ent.m_item );
236 }
237 }
238
239 if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
240 || boardItem->IsOnLayer( F_Mask ) || boardItem->IsOnLayer( B_Mask ) )
241 {
242 solderMaskDirty = true;
243 }
244
245 switch( changeType )
246 {
247 case CHT_ADD:
248 {
249 if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup() )
250 selTool->GetEnteredGroup()->AddItem( boardItem );
251
253 {
254 // footprints inside footprints are not supported yet
255 wxASSERT( boardItem->Type() != PCB_FOOTPRINT_T );
256
257 boardItem->SetParent( board->Footprints().front() );
258
259 if( !( changeFlags & CHT_DONE ) )
260 board->Footprints().front()->Add( boardItem );
261 }
262 else if( boardItem->Type() == PCB_PAD_T
263 || boardItem->Type() == PCB_FP_TEXT_T
264 || boardItem->Type() == PCB_FP_TEXTBOX_T
265 || boardItem->Type() == PCB_FP_SHAPE_T
266 || boardItem->Type() == PCB_FP_DIM_ALIGNED_T
267 || boardItem->Type() == PCB_FP_DIM_LEADER_T
268 || boardItem->Type() == PCB_FP_DIM_CENTER_T
269 || boardItem->Type() == PCB_FP_DIM_RADIAL_T
270 || boardItem->Type() == PCB_FP_DIM_ORTHOGONAL_T
271 || boardItem->Type() == PCB_FP_ZONE_T )
272 {
273 wxASSERT( boardItem->GetParent() &&
274 boardItem->GetParent()->Type() == PCB_FOOTPRINT_T );
275 }
276 else
277 {
278 if( !( aCommitFlags & SKIP_UNDO ) )
279 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
280
281 if( !( changeFlags & CHT_DONE ) )
282 {
283 board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
284 bulkAddedItems.push_back( boardItem );
285 }
286 }
287
288 if( autofillZones && boardItem->Type() != PCB_MARKER_T )
289 dirtyIntersectingZones( boardItem );
290
291 if( view && boardItem->Type() != PCB_NETINFO_T )
292 view->Add( boardItem );
293
294 break;
295 }
296
297 case CHT_REMOVE:
298 {
299 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
300
301 if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
302 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
303
304 if( boardItem->IsSelected() )
305 {
306 if( selTool )
307 selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
308
309 itemsDeselected = true;
310 }
311
312 if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
313 parentGroup->RemoveItem( boardItem );
314
315 if( autofillZones )
316 dirtyIntersectingZones( boardItem );
317
318 switch( boardItem->Type() )
319 {
320 // Footprint items
321 case PCB_PAD_T:
322 case PCB_FP_SHAPE_T:
323 case PCB_FP_TEXT_T:
324 case PCB_FP_TEXTBOX_T:
330 case PCB_FP_ZONE_T:
331 // This level can only handle footprint children in the footprint editor as
332 // only in that case has the entire footprint (and all its children) already
333 // been saved for undo.
334 wxASSERT( m_isFootprintEditor );
335
336 if( boardItem->Type() == PCB_FP_TEXT_T )
337 {
338 FP_TEXT* text = static_cast<FP_TEXT*>( boardItem );
339
340 // don't allow deletion of Reference or Value
341 if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
342 break;
343 }
344
345 if( view )
346 view->Remove( boardItem );
347
348 if( !( changeFlags & CHT_DONE ) )
349 {
350 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem->GetParent() );
351 wxASSERT( footprint && footprint->Type() == PCB_FOOTPRINT_T );
352 footprint->Delete( boardItem );
353 }
354
355 break;
356
357 // Board items
358 case PCB_SHAPE_T: // a shape (normally not on copper layers)
359 case PCB_BITMAP_T: // a bitmap on a user layer
360 case PCB_TEXT_T: // a text on a layer
361 case PCB_TEXTBOX_T: // a wrapped text on a layer
362 case PCB_TRACE_T: // a track segment (segment on a copper layer)
363 case PCB_ARC_T: // an arced track segment (segment on a copper layer)
364 case PCB_VIA_T: // a via (like track segment on a copper layer)
365 case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
366 case PCB_DIM_CENTER_T:
367 case PCB_DIM_RADIAL_T:
369 case PCB_DIM_LEADER_T: // a leader dimension
370 case PCB_TARGET_T: // a target (graphic item)
371 case PCB_MARKER_T: // a marker used to show something
372 case PCB_ZONE_T:
373 if( view )
374 view->Remove( boardItem );
375
376 if( !( changeFlags & CHT_DONE ) )
377 {
378 board->Remove( boardItem, REMOVE_MODE::BULK );
379 bulkRemovedItems.push_back( boardItem );
380 }
381
382 break;
383
384 case PCB_FOOTPRINT_T:
385 {
386 // No support for nested footprints (yet)
387 wxASSERT( !m_isFootprintEditor );
388
389 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
390
391 if( view )
392 view->Remove( footprint );
393
394 footprint->ClearFlags();
395
396 if( !( changeFlags & CHT_DONE ) )
397 {
398 board->Remove( footprint, REMOVE_MODE::BULK ); // handles connectivity
399 bulkRemovedItems.push_back( footprint );
400 }
401 }
402
403 break;
404
405 case PCB_GROUP_T:
406 if( view )
407 view->Remove( boardItem );
408
409 if( !( changeFlags & CHT_DONE ) )
410 {
412 board->GetFirstFootprint()->Remove( boardItem );
413 else
414 {
415 board->Remove( boardItem, REMOVE_MODE::BULK );
416 bulkRemovedItems.push_back( boardItem );
417 }
418 }
419
420 break;
421
422 // Metadata items
423 case PCB_NETINFO_T:
424 board->Remove( boardItem, REMOVE_MODE::BULK );
425 bulkRemovedItems.push_back( boardItem );
426 break;
427
428 default: // other types do not need to (or should not) be handled
429 wxASSERT( false );
430 break;
431 }
432
433 break;
434 }
435
436 case CHT_MODIFY:
437 {
438 if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
439 {
440 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
441 wxASSERT( ent.m_copy );
442 itemWrapper.SetLink( ent.m_copy );
443 undoList.PushItem( itemWrapper );
444 }
445
446 if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
447 {
448 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
449
450 if( ent.m_copy )
451 connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
452
453 connectivity->Update( boardItem );
454 }
455
456 if( autofillZones )
457 {
458 dirtyIntersectingZones( static_cast<BOARD_ITEM*>( ent.m_copy )); // before
459 dirtyIntersectingZones( boardItem ); // after
460 }
461
462 if( view )
463 {
464 view->Update( boardItem );
465
467 {
468 static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
469 [&]( BOARD_ITEM* aChild )
470 {
471 view->Update( aChild );
472 });
473 }
474 }
475
476 itemsChanged.push_back( boardItem );
477
478 // if no undo entry is needed, the copy would create a memory leak
479 if( aCommitFlags & SKIP_UNDO )
480 delete ent.m_copy;
481
482 break;
483 }
484
485 default:
486 wxASSERT( false );
487 break;
488 }
489 }
490
491 if( bulkAddedItems.size() > 0 )
492 board->FinalizeBulkAdd( bulkAddedItems );
493
494 if( bulkRemovedItems.size() > 0 )
495 board->FinalizeBulkRemove( bulkRemovedItems );
496
497 if( itemsChanged.size() > 0 )
498 board->OnItemsChanged( itemsChanged );
499
500 if( m_isBoardEditor )
501 {
502 size_t num_changes = m_changes.size();
503
504 if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
505 {
506 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
507
509 connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
510
511 connectivity->RecalculateRatsnest( this );
513 connectivity->ClearLocalRatsnest();
514 }
515
516 if( frame )
517 {
518 if( solderMaskDirty )
519 frame->HideSolderMask();
520
521 frame->GetCanvas()->RedrawRatsnest();
522 }
523
524 // Log undo items for any connectivity changes
525 for( size_t i = num_changes; i < m_changes.size(); ++i )
526 {
527 COMMIT_LINE& ent = m_changes[i];
528
529 wxASSERT( ( ent.m_type & CHT_TYPE ) == CHT_MODIFY );
530
531 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
532
533 if( !( aCommitFlags & SKIP_UNDO ) )
534 {
535 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
536 wxASSERT( ent.m_copy );
537 itemWrapper.SetLink( ent.m_copy );
538 undoList.PushItem( itemWrapper );
539 }
540 else
541 {
542 delete ent.m_copy;
543 }
544
545 if( view )
546 view->Update( boardItem );
547 }
548 }
549
550 if( m_isBoardEditor && !( aCommitFlags & SKIP_UNDO ) && frame )
551 {
552 if( aCommitFlags & APPEND_UNDO )
554 else
555 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
556 }
557
559
560 if( itemsDeselected )
562
563 if( autofillZones )
565
566 if( frame )
567 {
568 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
569 frame->OnModify();
570 else
572 }
573
574 clear();
575}
576
577
579{
580 switch( aItem->Type() )
581 {
582 case PCB_PAD_T:
583 case PCB_FP_SHAPE_T:
584 case PCB_FP_TEXT_T:
585 case PCB_FP_TEXTBOX_T:
591 case PCB_FP_ZONE_T:
592 return aItem->GetParent();
593
594 case PCB_ZONE_T:
595 wxASSERT( !dynamic_cast<FOOTPRINT*>( aItem->GetParent() ) );
596 return aItem;
597
598 default:
599 break;
600 }
601
602 return aItem;
603}
604
605
607{
608 PICKED_ITEMS_LIST undoList;
609 KIGFX::VIEW* view = m_toolMgr->GetView();
610 BOARD* board = (BOARD*) m_toolMgr->GetModel();
611 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
612
613 std::vector<BOARD_ITEM*> bulkAddedItems;
614 std::vector<BOARD_ITEM*> bulkRemovedItems;
615 std::vector<BOARD_ITEM*> itemsChanged;
616
617 for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
618 {
619 COMMIT_LINE& ent = *it;
620 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
621 BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
622 int changeType = ent.m_type & CHT_TYPE;
623 int changeFlags = ent.m_type & CHT_FLAGS;
624
625 switch( changeType )
626 {
627 case CHT_ADD:
628 if( !( changeFlags & CHT_DONE ) )
629 break;
630
631 view->Remove( item );
632 connectivity->Remove( item );
633 board->Remove( item, REMOVE_MODE::BULK );
634 bulkRemovedItems.push_back( item );
635 break;
636
637 case CHT_REMOVE:
638 if( !( changeFlags & CHT_DONE ) )
639 break;
640
641 view->Add( item );
642 connectivity->Add( item );
643 board->Add( item, ADD_MODE::INSERT );
644 bulkAddedItems.push_back( item );
645 break;
646
647 case CHT_MODIFY:
648 {
649 view->Remove( item );
650 connectivity->Remove( item );
651
652 item->SwapItemData( copy );
653
654 view->Add( item );
655 connectivity->Add( item );
656 board->OnItemChanged( item );
657 itemsChanged.push_back( item );
658
659 delete copy;
660 break;
661 }
662
663 default:
664 wxASSERT( false );
665 break;
666 }
667 }
668
669 if( bulkAddedItems.size() > 0 )
670 board->FinalizeBulkAdd( bulkAddedItems );
671
672 if( bulkRemovedItems.size() > 0 )
673 board->FinalizeBulkRemove( bulkRemovedItems );
674
675 if( itemsChanged.size() > 0 )
676 board->OnItemsChanged( itemsChanged );
677
678 if ( !m_isFootprintEditor )
679 {
680 connectivity->RecalculateRatsnest();
682 }
683
685 selTool->RebuildSelection();
686
687 clear();
688}
689
#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()
virtual 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:83
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
void dirtyIntersectingZones(BOARD_ITEM *item)
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:81
bool m_isFootprintEditor
Definition: board_commit.h:82
bool m_resolveNetConflicts
Definition: board_commit.h:84
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:58
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:166
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:72
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:245
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
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:1991
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:696
ZONES & Zones()
Definition: board.h:313
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
FOOTPRINTS & Footprints()
Definition: board.h:307
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:799
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:793
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:248
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:805
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:1997
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
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:178
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
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:143
bool IsSelected() const
Definition: eda_item.h:107
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:144
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:619
@ 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:346
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:1574
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
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:336
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
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:52
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:40
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:143
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206
Master controller class:
Definition: tool_manager.h:55
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
@ RESOLVE_CONFLICTS
Clusters with conflicting drivers are not updated (default)
#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...