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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <macros.h>
23#include <pgm_base.h>
25#include <board.h>
28#include <footprint.h>
29#include <lset.h>
30#include <pad.h>
31#include <pcb_group.h>
32#include <pcb_track.h>
33#include <pcb_shape.h>
34#include <tool/tool_manager.h>
37#include <view/view.h>
38#include <board_commit.h>
39#include <tools/pcb_tool_base.h>
40#include <tools/pcb_actions.h>
43#include <teardrop/teardrop.h>
44#include <pcb_board_outline.h>
45#include <pcb_drill_map.h>
46#include <pcb_base_frame.h>
47
48#include <functional>
49#include <unordered_set>
51using namespace std::placeholders;
52
53
54// A no-geometry board item (net metadata or a geometric constraint) is never pushed into the
55// VIEW or the connectivity graph. VIEW::Add early-returns on an empty layer set but still
56// stamps the item's view private data, which a later VIEW::Remove would mis-index.
57static bool isNoGeometryItem( const BOARD_ITEM* aItem )
58{
59 return aItem->Type() == PCB_NETINFO_T || aItem->Type() == PCB_CONSTRAINT_T
60 || aItem->Type() == PCB_3D_BODY_T;
61}
62
63
65 COMMIT(),
66 m_toolMgr( aTool->GetManager() ),
67 m_isBoardEditor( false ),
68 m_isFootprintEditor( false )
69{
70 if( PCB_TOOL_BASE* pcb_tool = dynamic_cast<PCB_TOOL_BASE*>( aTool ) )
71 {
72 m_isBoardEditor = pcb_tool->IsBoardEditor();
73 m_isFootprintEditor = pcb_tool->IsFootprintEditor();
74 }
75}
76
77
79 COMMIT(),
80 m_toolMgr( aFrame->GetToolManager() ),
81 m_isBoardEditor( aFrame->IsType( FRAME_PCB_EDITOR ) ),
83{
84}
85
86
88 COMMIT(),
89 m_toolMgr( aMgr ),
90 m_isBoardEditor( false ),
91 m_isFootprintEditor( false )
92{
93 EDA_DRAW_FRAME* frame = dynamic_cast<EDA_DRAW_FRAME*>( aMgr->GetToolHolder() );
94
95 if( frame && frame->IsType( FRAME_PCB_EDITOR ) )
96 m_isBoardEditor = true;
97 else if( frame && frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
99}
100
101
102BOARD_COMMIT::BOARD_COMMIT( TOOL_MANAGER* aMgr, bool aIsBoardEditor, bool aIsFootprintEditor ) :
103 COMMIT(),
104 m_toolMgr( aMgr ),
105 m_isBoardEditor( aIsBoardEditor ),
106 m_isFootprintEditor( aIsFootprintEditor )
107{
108}
109
110
112{
113 return static_cast<BOARD*>( m_toolMgr->GetModel() );
114}
115
116
117COMMIT& BOARD_COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCREEN* aScreen, RECURSE_MODE aRecurse )
118{
119 // A modified item is edited in place before the push tells the board, and a save can read it in between
120 if( BOARD* board = GetBoard(); board && ( aChangeType & CHT_TYPE ) == CHT_MODIFY && aItem->IsBOARD_ITEM() )
121 board->bumpDrillModelFor( { static_cast<BOARD_ITEM*>( aItem ) } );
122
123 if( aRecurse == RECURSE_MODE::RECURSE )
124 {
125 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( aItem ) )
126 {
127 for( EDA_ITEM* member : group->GetItems() )
128 Stage( member, aChangeType, aScreen, aRecurse );
129 }
130 }
131
132 if( m_isBoardEditor && ( aChangeType & CHT_TYPE ) == CHT_REMOVE
133 && aItem->IsBOARD_ITEM()
134 && static_cast<BOARD_ITEM*>( aItem )->GetParentFootprint() )
135 {
136 if( m_deletedItems.find( { aItem, aScreen } ) == m_deletedItems.end() )
137 makeEntry( aItem, aChangeType, makeImage( aItem ), aScreen );
138
139 return *this;
140 }
141
142 return COMMIT::Stage( aItem, aChangeType );
143}
144
145
146COMMIT& BOARD_COMMIT::Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType, BASE_SCREEN* aScreen )
147{
148 return COMMIT::Stage( container, aChangeType, aScreen );
149}
150
151
153{
154 return COMMIT::Stage( aItems, aModFlag, aScreen );
155}
156
157
159{
160 COMMIT_LINE* entry = findEntry( aItem );
161
162 // An add already applied to the board has to be undone through it, so only pending adds are freed
163 if( !entry || entry->m_type != CHT_ADD )
164 {
165 Remove( aItem );
166 return false;
167 }
168
169 if( EDA_GROUP* parentGroup = aItem->GetParentGroup() )
170 parentGroup->RemoveItem( aItem );
171
172 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( aItem ) )
173 group->RemoveAll();
174
175 Unstage( aItem, nullptr );
176 return true;
177}
178
179
180void BOARD_COMMIT::propagateDamage( BOARD_ITEM* aChangedItem, std::vector<ZONE*>* aStaleZones,
181 std::vector<BOX2I>& aStaleRuleAreas )
182{
183 wxCHECK( aChangedItem, /* void */ );
184
185 if( aStaleZones && aChangedItem->Type() == PCB_ZONE_T )
186 aStaleZones->push_back( static_cast<ZONE*>( aChangedItem ) );
187
188 aChangedItem->RunOnChildren( std::bind( &BOARD_COMMIT::propagateDamage, this, _1, aStaleZones, aStaleRuleAreas ),
190
191 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
192 BOX2I damageBBox = aChangedItem->GetBoundingBox();
193 LSET damageLayers = aChangedItem->GetLayerSet();
194
195 if( m_isBoardEditor && aChangedItem->Type() == PCB_ZONE_T )
196 {
197 // A named zone can have custom DRC rules targetting it.
198 if( !static_cast<ZONE*>( aChangedItem )->GetZoneName().IsEmpty() )
199 aStaleRuleAreas.push_back( damageBBox );
200 }
201
202 if( aStaleZones )
203 {
204 if( damageLayers.test( Edge_Cuts ) || damageLayers.test( Margin ) )
205 damageLayers = LSET::PhysicalLayersMask();
206 else
207 damageLayers &= LSET::AllCuMask();
208
209 if( damageLayers.any() )
210 {
211 for( ZONE* zone : board->Zones() )
212 {
213 if( zone->GetIsRuleArea() )
214 continue;
215
216 if( ( zone->GetLayerSet() & damageLayers ).any() && zone->GetBoundingBox().Intersects( damageBBox ) )
217 aStaleZones->push_back( zone );
218 }
219 }
220 }
221}
222
223
224void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
225{
226 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( m_toolMgr->GetView() );
227 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
228 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
229 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
230 PCB_GROUP* enteredGroup = selTool && !( aCommitFlags & SKIP_ENTERED_GROUP ) ? selTool->GetEnteredGroup()
231 : nullptr;
232 // Notification info
233 PICKED_ITEMS_LIST undoList;
234 bool itemsDeselected = false;
235 bool selectedModified = false;
236
237 std::unordered_set<EDA_ITEM*> removedItems;
238
239 // Dirty flags and lists
240 bool solderMaskDirty = false;
241 bool autofillZones = false;
242 bool updateBoardBoundingBox = false;
243 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
244 std::set<PCB_TRACK*> staleTeardropTracks;
245 std::vector<BOARD_ITEM*> dirtyCopper;
246 std::set<BOARD_ITEM*> dirtyCopperSeen;
247 std::vector<ZONE*> staleZonesStorage;
248 std::vector<ZONE*>* staleZones = nullptr;
249 std::vector<BOX2I> staleRuleAreas;
250
251 if( Empty() )
252 return;
253
254 bool containsDrillMap = false;
255 bool containsGeneratedTable = false;
256
257 for( const COMMIT_LINE& entry : m_entries )
258 {
259 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
260 continue;
261
262 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( entry.m_item );
263
264 containsDrillMap |= item->Type() == PCB_DRILL_MAP_T;
265 containsGeneratedTable |= IsGeneratedTableType( item->Type() );
266 }
267
268 undoList.SetDescription( aMessage );
269
270 // Copies handed in through Modified() were not made by makeImage(), but the undo stack owns them all
271 for( const COMMIT_LINE& entry : m_entries )
272 {
273 if( entry.m_copy )
274 entry.m_copy->SetFlags( UR_TRANSIENT );
275 }
276
277 TEARDROP_MANAGER teardropMgr( board, m_toolMgr );
278 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
279
280 // Note: frame == nullptr happens in QA tests
281
282 if( !frame )
283 aCommitFlags |= SKIP_UNDO;
284
285 std::vector<BOARD_ITEM*> bulkAddedItems;
286 std::vector<BOARD_ITEM*> bulkRemovedItems;
287 std::vector<BOARD_ITEM*> itemsChanged;
288
289 if( m_isBoardEditor && !( aCommitFlags & ZONE_FILL_OP )
290 && ( frame && frame->GetPcbNewSettings()->m_AutoRefillZones ) )
291 {
292 autofillZones = true;
293 staleZones = &staleZonesStorage;
294
295 for( ZONE* zone : board->Zones() )
296 zone->CacheBoundingBox();
297 }
298
299 for( COMMIT_LINE& entry : m_entries )
300 {
301 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
302 continue;
303
304 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( entry.m_item );
305
306 if( m_isBoardEditor )
307 {
308 BOARD_ITEM* preEditItem = nullptr;
309
310 if( entry.m_copy && entry.m_copy->IsBOARD_ITEM() )
311 preEditItem = static_cast<BOARD_ITEM*>( entry.m_copy );
312
313 if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
314 || boardItem->IsOnLayer( F_Mask )
315 || boardItem->IsOnLayer( B_Mask )
316 || ( preEditItem && preEditItem->IsOnLayer( F_Mask ) )
317 || ( preEditItem && preEditItem->IsOnLayer( B_Mask ) ) )
318 {
319 solderMaskDirty = true;
320 }
321
322 if( boardItem->IsOnLayer( Edge_Cuts )
323 || ( preEditItem && preEditItem->IsOnLayer( Edge_Cuts ) ) )
324 {
325 updateBoardBoundingBox = true;
326 }
327
328 if( !( aCommitFlags & SKIP_TEARDROPS ) )
329 {
330 // Teardrops are fitted to the copper around them, so any changed copper item
331 // can invalidate one, not only what a teardrop connects to.
332 auto collectCopper =
333 [&]( BOARD_ITEM* aItem )
334 {
335 // Pours are the filler's business. Containers have no copper of
336 // their own and their boxes sweep far more than they occupy.
337 if( aItem->Type() == PCB_ZONE_T
338 || aItem->Type() == PCB_FOOTPRINT_T
339 || aItem->Type() == PCB_GROUP_T
340 || aItem->Type() == PCB_GENERATOR_T )
341 {
342 return;
343 }
344
345 // A group and its members can both be in the commit.
346 if( ( aItem->GetLayerSet() & LSET::AllCuMask() ).any()
347 && dirtyCopperSeen.insert( aItem ).second )
348 {
349 dirtyCopper.push_back( aItem );
350 }
351 };
352
353 collectCopper( boardItem );
354 boardItem->RunOnChildren( collectCopper, RECURSE_MODE::RECURSE );
355
356 // boardItem already carries the edit, so it cannot show where the item was.
357 // The pre-edit clone is still ours here and answers a bounding box.
358 if( entry.m_copy && entry.m_copy->IsBOARD_ITEM() )
359 {
360 BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( entry.m_copy );
361
362 collectCopper( copy );
363 copy->RunOnChildren( collectCopper, RECURSE_MODE::RECURSE );
364 }
365
366 if( boardItem->Type() == PCB_FOOTPRINT_T )
367 {
368 for( PAD* pad : static_cast<FOOTPRINT*>( boardItem )->Pads() )
369 staleTeardropPadsAndVias.push_back( pad );
370 }
371 else if( boardItem->Type() == PCB_PAD_T || boardItem->Type() == PCB_VIA_T )
372 {
373 staleTeardropPadsAndVias.push_back( boardItem );
374 }
375 else if( boardItem->Type() == PCB_TRACE_T || boardItem->Type() == PCB_ARC_T )
376 {
377 PCB_TRACK* track = static_cast<PCB_TRACK*>( boardItem );
378
379 staleTeardropTracks.insert( track );
380
381 std::vector<PAD*> connectedPads;
382 std::vector<PCB_VIA*> connectedVias;
383
384 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
385
386 for( PAD* pad : connectedPads )
387 staleTeardropPadsAndVias.push_back( pad );
388
389 for( PCB_VIA* via : connectedVias )
390 staleTeardropPadsAndVias.push_back( via );
391 }
392 }
393 }
394
395 if( boardItem->IsSelected() || ( m_isFootprintEditor && boardItem == board->GetFirstFootprint() ) )
396 selectedModified = true;
397 }
398
399 // Old teardrops must be removed before connectivity is rebuilt
400 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() || !dirtyCopper.empty() )
401 teardropMgr.RemoveTeardrops( *this, &staleTeardropPadsAndVias, &staleTeardropTracks, &dirtyCopper );
402
403 auto updateComponentClasses =
404 [this]( BOARD_ITEM* boardItem )
405 {
406 if( boardItem->Type() != PCB_FOOTPRINT_T )
407 return;
408
409 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
411 };
412
413 // We don't know that anything will be added to the entered group, but it does no harm to
414 // add it to the commit anyway (well, as long as we're not trying to remove it).
415 if( enteredGroup && GetStatus( enteredGroup ) == 0 )
416 Modify( enteredGroup );
417
418 for( COMMIT_LINE& entry : m_entries )
419 {
420 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
421 continue;
422
423 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( entry.m_item );
424 int changeType = entry.m_type & CHT_TYPE;
425 int changeFlags = entry.m_type & CHT_FLAGS;
426
427 switch( changeType )
428 {
429 case CHT_ADD:
430 if( enteredGroup && boardItem->IsGroupableType() && !boardItem->GetParentGroup() )
431 enteredGroup->AddItem( boardItem );
432
433 if( !( aCommitFlags & SKIP_UNDO ) )
434 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
435
436 if( !( changeFlags & CHT_DONE ) )
437 {
438 // Markers are always stored at the board level, even in the footprint editor
439 if( m_isFootprintEditor && boardItem->Type() != PCB_MARKER_T )
440 {
441 if( FOOTPRINT* parentFP = board->GetFirstFootprint() )
442 parentFP->Add( boardItem );
443 }
444 else
445 {
446 board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
447 bulkAddedItems.push_back( boardItem );
448 }
449 }
450
451 if( boardItem->Type() != PCB_MARKER_T )
452 propagateDamage( boardItem, staleZones, staleRuleAreas );
453
454 if( view && !isNoGeometryItem( boardItem ) )
455 view->Add( boardItem );
456
457 updateComponentClasses( boardItem );
458
459 break;
460
461 case CHT_REMOVE:
462 {
463 EDA_GROUP* parentGroup = boardItem->GetParentGroup();
464
465 if( !( aCommitFlags & SKIP_UNDO ) )
466 {
468 ITEM_PICKER itemWrapper( nullptr, boardItem, status );
469 itemWrapper.SetLink( entry.m_copy );
470 entry.m_copy = nullptr; // We've transferred ownership to the undo list
471 undoList.PushItem( itemWrapper );
472 }
473
474 if( boardItem->IsSelected() )
475 {
476 if( selTool )
477 selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
478
479 // In an undo we're going to re-create from the item, not the image. That seems wrong, but
480 // it would be a big risky change to make it use the image, so let's just reset the selection
481 // flag for now (so that on undo it comes back selected).
482 boardItem->SetFlags( SELECTED );
483
484 itemsDeselected = true;
485 }
486
487 removedItems.insert( boardItem );
488
489 if( parentGroup && !( parentGroup->AsEdaItem()->GetFlags() & STRUCT_DELETED ) )
490 parentGroup->RemoveItem( boardItem );
491
492 if( boardItem->Type() != PCB_MARKER_T )
493 propagateDamage( boardItem, staleZones, staleRuleAreas );
494
495 switch( boardItem->Type() )
496 {
497 case PCB_FIELD_T:
498 static_cast<PCB_FIELD*>( boardItem )->SetVisible( false );
499
500 if( view )
501 view->Update( boardItem );
502
503 break;
504
505 case PCB_TEXT_T:
506 case PCB_PAD_T:
507 case PCB_SHAPE_T:
509 case PCB_GENERATOR_T:
510 case PCB_TEXTBOX_T:
511 case PCB_BARCODE_T:
512 case PCB_TABLE_T:
514 case PCB_DRILL_MAP_T:
516 case PCB_TRACE_T:
517 case PCB_ARC_T:
518 case PCB_VIA_T:
520 case PCB_DIM_CENTER_T:
521 case PCB_DIM_RADIAL_T:
523 case PCB_DIM_LEADER_T:
524 case PCB_TARGET_T:
525 case PCB_POINT_T:
526 case PCB_ZONE_T:
527 case PCB_GRID_ITEM_T:
528 case PCB_FOOTPRINT_T:
529 case PCB_GROUP_T:
530 if( view )
531 view->Remove( boardItem );
532
533 if( !( changeFlags & CHT_DONE ) )
534 {
535 if( m_isFootprintEditor && boardItem->Type() != PCB_MARKER_T )
536 {
537 if( FOOTPRINT* parentFP = board->GetFirstFootprint() )
538 {
539 parentFP->Remove( boardItem );
540 connectivity->Remove( boardItem );
541 itemsChanged.push_back( parentFP );
542 }
543 }
544 else if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
545 {
546 parentFP->Remove( boardItem );
547 connectivity->Remove( boardItem );
548 itemsChanged.push_back( parentFP );
549 }
550 else
551 {
552 board->Remove( boardItem, REMOVE_MODE::BULK );
553 bulkRemovedItems.push_back( boardItem );
554 }
555 }
556
557 break;
558
559 case PCB_MARKER_T:
560 if( view )
561 view->Remove( boardItem );
562
563 if( !( changeFlags & CHT_DONE ) )
564 {
565 // Markers are always stored at the board level, even in the footprint editor
566 board->Remove( boardItem, REMOVE_MODE::BULK );
567 bulkRemovedItems.push_back( boardItem );
568 }
569
570 break;
571
572 // No-geometry items: never in the view, so skip view->Remove.
573 case PCB_CONSTRAINT_T:
574 case PCB_3D_BODY_T:
575 if( !( changeFlags & CHT_DONE ) )
576 {
578 {
579 if( FOOTPRINT* parentFP = board->GetFirstFootprint() )
580 {
581 parentFP->Remove( boardItem );
582 itemsChanged.push_back( parentFP );
583 }
584 }
585 else if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
586 {
587 parentFP->Remove( boardItem );
588 itemsChanged.push_back( parentFP );
589 }
590 else
591 {
592 board->Remove( boardItem, REMOVE_MODE::BULK );
593 bulkRemovedItems.push_back( boardItem );
594 }
595 }
596
597 break;
598
599 // Metadata items
600 case PCB_NETINFO_T:
601 board->Remove( boardItem, REMOVE_MODE::BULK );
602 bulkRemovedItems.push_back( boardItem );
603 break;
604
605 default: // other types do not need to (or should not) be handled
606 wxASSERT( false );
607 break;
608 }
609
610 // Removed items are owned by undo/redo, but a hidden field still belongs to its footprint
611 if( boardItem->Type() != PCB_FIELD_T )
612 boardItem->SetFlags( UR_TRANSIENT );
613
614 break;
615 }
616
617 case CHT_MODIFY:
618 {
619 BOARD_ITEM* boardItemCopy = static_cast<BOARD_ITEM*>( entry.m_copy );
620
621 if( !( aCommitFlags & SKIP_UNDO ) )
622 {
623 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
624 itemWrapper.SetLink( entry.m_copy );
625 entry.m_copy = nullptr; // We've transferred ownership to the undo list
626 undoList.PushItem( itemWrapper );
627 }
628
629 if( !( aCommitFlags & SKIP_CONNECTIVITY ) && !isNoGeometryItem( boardItem ) )
630 {
631 connectivity->MarkItemNetAsDirty( boardItemCopy );
632 connectivity->Update( boardItem );
633 }
634
635 if( boardItem->Type() != PCB_MARKER_T )
636 {
637 propagateDamage( boardItemCopy, staleZones, staleRuleAreas ); // before
638 propagateDamage( boardItem, staleZones, staleRuleAreas ); // after
639 }
640
641 updateComponentClasses( boardItem );
642
643 if( view && !isNoGeometryItem( boardItem ) )
644 view->Update( boardItem );
645
646 itemsChanged.push_back( boardItem );
647 break;
648 }
649
650 default:
651 UNIMPLEMENTED_FOR( boardItem->GetClass() );
652 break;
653 }
654
655 // Delete any copies we still have ownership of
656 delete entry.m_copy;
657 entry.m_copy = nullptr;
658
659 boardItem->ClearEditFlags();
660 boardItem->RunOnChildren(
661 [&]( BOARD_ITEM* item )
662 {
663 item->ClearEditFlags();
664 },
666 } // ... and regenerate them.
667
668 // Deselection above keys off the SELECTED flag on the removed item itself, but the selection
669 // may separately hold an owned descendant such as a pad, field or table cell. Descendants
670 // are freed along with the removed parent, so prune them here or the selection keeps a
671 // dangling pointer that the next repaint dereferences.
672 if( selTool && !removedItems.empty() )
673 {
674 for( EDA_ITEM* selectedItem : selTool->GetSelection().GetItems() )
675 {
676 for( EDA_ITEM* ancestor = selectedItem; ancestor; ancestor = ancestor->GetParent() )
677 {
678 if( removedItems.count( ancestor ) )
679 {
680 selTool->RemoveItemFromSel( selectedItem, true /* quiet mode */ );
681 itemsDeselected = true;
682 break;
683 }
684 }
685 }
686 }
687
688 // Invalidate component classes
690
691 if( m_isBoardEditor )
692 {
693 size_t originalCount = m_entries.size();
694
695 if( aCommitFlags & SKIP_CONNECTIVITY )
696 {
697 connectivity->ClearRatsnest();
698 connectivity->ClearLocalRatsnest();
699 }
700 else
701 {
702 connectivity->RecalculateRatsnest( this );
704 connectivity->ClearLocalRatsnest();
705
706 if( frame )
707 frame->GetCanvas()->RedrawRatsnest();
708
709 board->OnRatsnestChanged();
710 }
711
712 if( solderMaskDirty )
713 {
714 if( frame )
715 frame->HideSolderMask();
716 }
717
718 if( updateBoardBoundingBox )
719 {
720 if( PCB_BOARD_OUTLINE* outline = board->BoardOutline() )
721 {
722 board->UpdateBoardOutline();
723
724 if( view )
725 {
726 if( view->HasItem( outline ) )
727 view->Update( outline );
728 else
729 view->Add( outline );
730 }
731 }
732
733 RefreshDrillMapOutlines( *board, view );
734 }
735
736 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
737 {
738 if( !staleRuleAreas.empty() && ( cfg->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
739 || cfg->m_Display.m_PadClearance ) )
740 {
741 if( view )
742 view->UpdateCollidingItems( staleRuleAreas, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T } );
743 }
744 }
745
746 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
747 {
748 teardropMgr.UpdateTeardrops( *this, &staleTeardropPadsAndVias, &staleTeardropTracks );
749
750 // UpdateTeardrops() can modify the ratsnest data. So rebuild this ratsnest data
751 connectivity->RecalculateRatsnest( this );
752 }
753
754 // Log undo items for any connectivity or teardrop changes
755 for( size_t i = originalCount; i < m_entries.size(); ++i )
756 {
757 COMMIT_LINE& entry = m_entries[i];
758 BOARD_ITEM* boardItem = nullptr;
759 BOARD_ITEM* boardItemCopy = nullptr;
760
761 if( entry.m_item && entry.m_item->IsBOARD_ITEM() )
762 boardItem = static_cast<BOARD_ITEM*>( entry.m_item );
763
764 if( entry.m_copy && entry.m_copy->IsBOARD_ITEM() )
765 boardItemCopy = static_cast<BOARD_ITEM*>( entry.m_copy );
766
767 wxCHECK2( boardItem, continue );
768
769 if( !( aCommitFlags & SKIP_UNDO ) )
770 {
771 ITEM_PICKER itemWrapper( nullptr, boardItem, convert( entry.m_type & CHT_TYPE ) );
772 itemWrapper.SetLink( boardItemCopy );
773 undoList.PushItem( itemWrapper );
774 }
775 else
776 {
777 delete entry.m_copy;
778 }
779
780 if( view && !isNoGeometryItem( boardItem ) )
781 {
782 if( ( entry.m_type & CHT_TYPE ) == CHT_ADD )
783 view->Add( boardItem );
784 else if( ( entry.m_type & CHT_TYPE ) == CHT_REMOVE )
785 view->Remove( boardItem );
786 else
787 view->Update( boardItem );
788 }
789 }
790 }
791
792 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
793 board->OnItemsCompositeUpdate( bulkAddedItems, bulkRemovedItems, itemsChanged );
794
795 // A shrinking table deletes the cells past its new end and the selection holds those
796 // cells directly, so it has to be resolved again from what is still on the board
797 if( containsGeneratedTable && selTool )
798 selTool->RebuildSelection();
799
800 if( frame )
801 {
802 if( !( aCommitFlags & SKIP_UNDO ) )
803 {
804 if( aCommitFlags & APPEND_UNDO )
806 else
807 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
808 }
809 }
810
811 m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } );
812
813 if( itemsDeselected )
815
816 if( autofillZones )
817 {
818 ZONE_FILLER_TOOL* zoneFillerTool = m_toolMgr->GetTool<ZONE_FILLER_TOOL>();
819
820 for( ZONE* zone : *staleZones )
821 zoneFillerTool->DirtyZone( zone );
822
824 }
825
826 // Rehatching only refreshes cached view geometry (consumers regenerate it lazily), and
827 // dispatching it headlessly makes the tool manager query the platform cursor position
828 if( view )
830
831 if( selectedModified )
833
834 if( frame )
835 {
836 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
837 frame->OnModify();
838 else
840
841 // Ensure the message panel is updated after committing changes.
842 // By default (i.e. if no event posted), display the updated board info
843 if( !itemsDeselected && !autofillZones && !selectedModified )
844 {
845 std::vector<MSG_PANEL_ITEM> msg_list;
846 board->GetMsgPanelInfo( frame, msg_list );
847 frame->SetMsgPanel( msg_list );
848 }
849 }
850
851 if( containsDrillMap && frame )
853
854 clear();
855}
856
857
859{
860 // Easiest way to disallow both a parent and one of its children appearing in the list
861 // is to only ever add the parent when either can be legal (ie: in the board editor).
862 if( m_isBoardEditor && aItem->IsBOARD_ITEM() )
863 {
864 if( FOOTPRINT* footprint = static_cast<BOARD_ITEM*>( aItem )->GetParentFootprint() )
865 return footprint;
866 }
867
868 EDA_ITEM* parent = aItem->GetParent();
869
870 if( parent && BaseType( parent->Type() ) == PCB_TABLE_T )
871 return parent;
872
873 return aItem;
874}
875
876
878{
879 return MakeImage( aItem );
880}
881
882
884{
885 EDA_ITEM* clone = aItem->Clone();
886 clone->SetFlags( UR_TRANSIENT );
887
888 return clone;
889}
890
891
893{
895
896 // A save during the commit may have rebuilt tables from the edits just discarded
898}
899
900
901void BOARD_COMMIT::RevertToCheckpoint( int aCheckpoint )
902{
903 PICKED_ITEMS_LIST undoList;
904 KIGFX::VIEW* view = m_toolMgr->GetView(); // null in headless sessions
905 BOARD* board = (BOARD*) m_toolMgr->GetModel();
906 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
907
908 board->IncrementTimeStamp(); // clear caches
909
910 auto updateComponentClasses =
911 [this]( BOARD_ITEM* boardItem )
912 {
913 if( boardItem->Type() != PCB_FOOTPRINT_T )
914 return;
915
916 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
918 };
919
920 std::vector<BOARD_ITEM*> bulkAddedItems;
921 std::vector<BOARD_ITEM*> bulkRemovedItems;
922 std::vector<BOARD_ITEM*> itemsChanged;
923 std::vector<BOARD_ITEM*> itemsToDelete;
924 bool containsDrillMap = false;
925
926 for( int ii = aCheckpoint; ii < (int) m_entries.size(); ++ii )
927 {
928 COMMIT_LINE& entry = m_entries[ii];
929
930 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
931 continue;
932
933 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( entry.m_item );
934 int changeType = entry.m_type & CHT_TYPE;
935 int changeFlags = entry.m_type & CHT_FLAGS;
936
937 if( boardItem->Type() == PCB_DRILL_CHART_T || boardItem->Type() == PCB_DRILL_MAP_T )
938 {
939 containsDrillMap |= boardItem->Type() == PCB_DRILL_MAP_T;
940 }
941
942 switch( changeType )
943 {
944 case CHT_ADD:
945 if( changeFlags & CHT_DONE )
946 {
947 if( view && !isNoGeometryItem( boardItem ) )
948 view->Remove( boardItem );
949
950 connectivity->Remove( boardItem );
951
953 {
954 if( FOOTPRINT* parentFP = board->GetFirstFootprint() )
955 {
956 parentFP->Remove( boardItem );
957 itemsChanged.push_back( parentFP );
958 }
959 }
960 else if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
961 {
962 parentFP->Remove( boardItem );
963 itemsChanged.push_back( parentFP );
964 }
965 else
966 {
967 board->Remove( boardItem, REMOVE_MODE::BULK );
968 bulkRemovedItems.push_back( boardItem );
969 }
970 }
971
972 if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( boardItem ) )
973 group->RemoveAll();
974
975 // Defer deletion until after OnItemsCompositeUpdate so that
976 // board listeners do not receive dangling pointers.
977 itemsToDelete.push_back( boardItem );
978 entry.m_item = nullptr;
979 continue;
980
981 case CHT_REMOVE:
982 {
983 if( !( changeFlags & CHT_DONE ) )
984 break;
985
986 if( view && !isNoGeometryItem( boardItem ) )
987 view->Add( boardItem );
988
990 {
991 if( FOOTPRINT* parentFP = board->GetFirstFootprint() )
992 {
993 parentFP->Add( boardItem, ADD_MODE::INSERT );
994 connectivity->Add( boardItem );
995 itemsChanged.push_back( parentFP );
996 }
997 }
998 else if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() )
999 {
1000 parentFP->Add( boardItem, ADD_MODE::INSERT );
1001 connectivity->Add( boardItem );
1002 itemsChanged.push_back( parentFP );
1003 }
1004 else
1005 {
1006 board->Add( boardItem, ADD_MODE::INSERT );
1007 bulkAddedItems.push_back( boardItem );
1008 }
1009
1010 updateComponentClasses( boardItem );
1011 break;
1012 }
1013
1014 case CHT_MODIFY:
1015 {
1016 if( view && !isNoGeometryItem( boardItem ) )
1017 view->Remove( boardItem );
1018
1019 connectivity->Remove( boardItem );
1020
1021 wxASSERT( entry.m_copy && entry.m_copy->IsBOARD_ITEM() );
1022 BOARD_ITEM* boardItemCopy = static_cast<BOARD_ITEM*>( entry.m_copy );
1023 boardItem->SwapItemData( boardItemCopy );
1024
1025 if( view && !isNoGeometryItem( boardItem ) )
1026 view->Add( boardItem );
1027
1028 connectivity->Add( boardItem );
1029 itemsChanged.push_back( boardItem );
1030
1031 updateComponentClasses( boardItem );
1032 break;
1033 }
1034
1035 default:
1036 UNIMPLEMENTED_FOR( boardItem->GetClass() );
1037 break;
1038 }
1039
1040 // Delete any copies we still have ownership of
1041 delete entry.m_copy;
1042 entry.m_copy = nullptr;
1043
1044 boardItem->ClearEditFlags();
1045 }
1046
1047 // Invalidate component classes
1049
1050 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
1051 board->OnItemsCompositeUpdate( bulkAddedItems, bulkRemovedItems, itemsChanged );
1052
1053 if( m_isBoardEditor )
1054 {
1055 for( BOARD_ITEM* item : itemsToDelete )
1056 connectivity->Remove( item );
1057 }
1058
1059 for( BOARD_ITEM* item : itemsToDelete )
1060 delete item;
1061
1062 if( m_isBoardEditor )
1063 {
1064 connectivity->RecalculateRatsnest();
1065 board->UpdateRatsnestExclusions();
1066 board->OnRatsnestChanged();
1067 }
1068
1069 if( PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>() )
1070 selTool->RebuildSelection();
1071
1072 // Property panel needs to know about the reselect
1074
1075 if( containsDrillMap )
1076 {
1077 if( PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() ) )
1078 {
1079 frame->RefreshDrillSymbols( KIGFX::LAYERS | KIGFX::GEOMETRY | KIGFX::REPAINT );
1080 }
1081 }
1082
1083 dropEntriesAfter( aCheckpoint );
1084}
1085
1086
1088{
1089 if( aID == niluuid )
1090 return nullptr;
1091
1092 for( COMMIT_LINE& entry : m_entries )
1093 {
1094 if( entry.m_item && entry.m_item->IsBOARD_ITEM() && entry.m_item->m_Uuid == aID )
1095 return entry.m_item;
1096 }
1097
1098 return nullptr;
1099}
static bool isNoGeometryItem(const BOARD_ITEM *aItem)
#define SKIP_CONNECTIVITY
#define SKIP_SET_DIRTY
#define APPEND_UNDO
#define SKIP_UNDO
#define ZONE_FILL_OP
#define SKIP_ENTERED_GROUP
#define SKIP_TEARDROPS
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:37
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
bool RemoveOrDiscard(BOARD_ITEM *aItem)
Remove aItem, or free it if it was added earlier in this commit and never reached the board.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
virtual EDA_ITEM * ResolveItem(KIID &aID) override
Search for an item in this commit that matches the provided KIID.
BOARD * GetBoard() const
void Revert() override
Revert the commit by restoring the modified items state.
static EDA_ITEM * MakeImage(EDA_ITEM *aItem)
EDA_ITEM * undoLevelItem(EDA_ITEM *aItem) const override
bool m_isBoardEditor
void RevertToCheckpoint(int aCheckpoint) override
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
void propagateDamage(BOARD_ITEM *aItem, std::vector< ZONE * > *aStaleZones, std::vector< BOX2I > &aStaleRuleAreas)
TOOL_MANAGER * m_toolMgr
bool m_isFootprintEditor
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:99
bool IsGroupableType() const
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:432
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition board_item.h:369
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
Definition board_item.h:279
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1548
PCB_BOARD_OUTLINE * BoardOutline()
Definition board.h:487
void UpdateBoardOutline()
Definition board.cpp:4347
const ZONES & Zones() const
Definition board.h:469
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:3906
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition board.h:713
void IncrementTimeStamp()
Definition board.cpp:448
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
Definition board.cpp:3917
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition board.cpp:2642
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition board.cpp:538
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
Definition board.h:1708
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition board.cpp:1723
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:758
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:86
std::set< std::pair< EDA_ITEM *, BASE_SCREEN * > > m_deletedItems
Definition commit.h:224
void Unstage(EDA_ITEM *aItem, BASE_SCREEN *aScreen)
Definition commit.cpp:177
bool Empty() const
Definition commit.h:145
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
COMMIT()
Definition commit.cpp:30
COMMIT_LINE * findEntry(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Search for an entry describing change for a particular item.
Definition commit.cpp:267
virtual void makeEntry(EDA_ITEM *aItem, CHANGE_TYPE aType, EDA_ITEM *aCopy=nullptr, BASE_SCREEN *aScreen=nullptr)
Definition commit.cpp:243
std::vector< COMMIT_LINE > m_entries
Definition commit.h:225
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition commit.cpp:235
void dropEntriesAfter(int aCheckpoint)
Definition commit.h:184
void clear()
Should be called in Push() & Revert() methods.
Definition commit.h:176
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Add a change of the item aItem of type aChangeType to the change list.
Definition commit.cpp:42
void InvalidateComponentClasses()
Invalidates any caches component classes and recomputes caches if required.
void RebuildRequiredCaches(FOOTPRINT *aFootprint=nullptr) const
Rebuilds any caches that may be required by custom assignment rules.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
void RemoveItem(EDA_ITEM *aItem)
Remove item from group.
Definition eda_group.cpp:77
virtual EDA_ITEM * AsEdaItem()=0
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual void ClearEditFlags()
Definition eda_item.h:178
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:280
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:158
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
bool IsSelected() const
Definition eda_item.h:134
EDA_ITEM * GetParent() const
Definition eda_item.h:112
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition eda_item.cpp:288
EDA_ITEM_FLAGS GetFlags() const
Definition eda_item.h:167
static const TOOL_EVENT SelectedItemsModified
Selected item had a property changed (except movement)
Definition actions.h:354
static const TOOL_EVENT UnselectedEvent
Definition actions.h:348
void SetLink(EDA_ITEM *aItem)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition pcb_view.cpp:87
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition pcb_view.cpp:53
void UpdateCollidingItems(const std::vector< BOX2I > &aStaleAreas, std::initializer_list< KICAD_T > aTypes)
Sets the KIGFX::REPAINT on all items matching aTypes which intersect aStaleAreas.
Definition pcb_view.cpp:118
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition pcb_view.cpp:70
bool IsBOARD_ITEM() const
Definition view_item.h:98
virtual wxString GetClass() const =0
Return the class name.
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:365
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:488
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
Definition view.cpp:2616
Definition kiid.h:46
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition lset.cpp:693
Definition pad.h:61
DISPLAY_OPTIONS m_Display
static TOOL_ACTION rehatchShapes
static TOOL_ACTION zoneFillDirty
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 RefreshDrillSymbols(int aUpdateFlags)
Refresh cached drill symbols in frames that render drill maps.
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()
Force refresh of the ratsnest visual representation.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
The selection tool: currently supports:
PCB_GROUP * GetEnteredGroup()
PCB_SELECTION & GetSelection()
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void SetDescription(const wxString &aDescription)
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
const std::deque< EDA_ITEM * > GetItems() const
Definition selection.h:125
TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) ...
Definition teardrop.h:87
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:437
void RemoveTeardrops(BOARD_COMMIT &aCommit, std::vector< BOARD_ITEM * > *dirtyPadsAndVias, std::set< PCB_TRACK * > *dirtyTracks, const std::vector< BOARD_ITEM * > *dirtyCopper=nullptr)
Remove teardrops on dirty pads, vias or tracks, and any whose neighbouring copper moved,...
Definition teardrop.cpp:243
Base abstract interface for all kinds of tools.
Definition tool_base.h:62
Master controller class:
TOOLS_HOLDER * GetToolHolder() const
Handle actions specific to filling copper zones.
void DirtyZone(ZONE *aZone)
Handle a list of polygons defining a copper zone.
Definition zone.h:70
CHANGE_TYPE
Types of changes.
Definition commit.h:37
@ CHT_MODIFY
Definition commit.h:40
@ CHT_REMOVE
Definition commit.h:39
@ CHT_DONE
Flag to indicate the change is already applied.
Definition commit.h:43
@ CHT_TYPE
Definition commit.h:41
@ CHT_ADD
Definition commit.h:38
@ CHT_FLAGS
Definition commit.h:44
RECURSE_MODE
Definition eda_item.h:50
@ RECURSE
Definition eda_item.h:51
@ NO_RECURSE
Definition eda_item.h:52
#define SELECTED
Item was manually selected by the user.
#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:38
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:39
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
KIID niluuid(0)
@ Edge_Cuts
Definition layer_ids.h:108
@ B_Mask
Definition layer_ids.h:94
@ F_Mask
Definition layer_ids.h:93
@ Margin
Definition layer_ids.h:109
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition macros.h:92
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:51
@ LAYERS
Layers have changed.
Definition view_item.h:52
void RefreshDrillMapOutlines(const BOARD &aBoard, KIGFX::VIEW *aView)
Repaint every drill map after an Edge.Cuts edit.
Class to handle a set of BOARD_ITEMs.
@ SHOW_WITH_VIA_ALWAYS
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
EDA_ITEM * m_copy
Optional copy of the item.
Definition commit.h:170
CHANGE_TYPE m_type
Modification type.
Definition commit.h:171
EDA_ITEM * m_item
Main item that is added/deleted/modified.
Definition commit.h:169
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition tool_action.h:45
@ TA_MODEL_CHANGE
Model has changed (partial update).
Definition tool_event.h:117
@ TC_MESSAGE
Definition tool_event.h:54
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition typeinfo.h:261
@ PCB_CONSTRAINT_T
a geometric constraint between board items
Definition typeinfo.h:237
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:98
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:95
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
Definition typeinfo.h:240
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:96
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:103
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_3D_BODY_T
class PCB_3D_BODY, a 3D body (extruded or model) on a footprint
Definition typeinfo.h:241
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:91
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:93
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:99
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_GRID_ITEM_T
a subgrid placed on a board
Definition typeinfo.h:238
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:94
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition typeinfo.h:102
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:97
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239
constexpr bool IsGeneratedTableType(const KICAD_T aType)
A PCB_TABLE subclass whose cells are generated from the board rather than typed by the user.
Definition typeinfo.h:328
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...