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