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