KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <macros.h>
21#include <tool/tool_manager.h>
22#include <tools/sch_tool_base.h>
23
24#include <lib_symbol.h>
25
26#include <sch_group.h>
27#include <sch_screen.h>
28#include <schematic.h>
29
30#include <view/view.h>
31#include <sch_commit.h>
32#include <connection_graph.h>
33
34#include <functional>
35#include <wx/log.h>
36
37
39 COMMIT(),
40 m_toolMgr( aToolMgr ),
41 m_isLibEditor( false )
42{
43 SCH_BASE_FRAME* frame = static_cast<SCH_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
44 m_isLibEditor = frame && frame->IsType( FRAME_SCH_SYMBOL_EDITOR );
45}
46
47
53
54
60
61
65
66
68 RECURSE_MODE aRecurse )
69{
70 wxCHECK( aItem, *this );
71
72 if( aRecurse == RECURSE_MODE::RECURSE )
73 {
74 if( SCH_GROUP* group = dynamic_cast<SCH_GROUP*>( aItem ) )
75 {
76 for( EDA_ITEM* member : group->GetItems() )
77 Stage( member, aChangeType, aScreen, aRecurse );
78 }
79 }
80
81 // IS_SELECTED flag should not be set on undo items which were added for a drag operation.
82 if( aItem->IsSelected() && aItem->HasFlag( SELECTED_BY_DRAG ) )
83 {
84 aItem->ClearSelected();
85 COMMIT::Stage( aItem, aChangeType, aScreen );
86 aItem->SetSelected();
87 }
88 else
89 {
90 COMMIT::Stage( aItem, aChangeType, aScreen );
91 }
92
93 return *this;
94}
95
96
97COMMIT& SCH_COMMIT::Stage( std::vector<EDA_ITEM*> &container, CHANGE_TYPE aChangeType,
98 BASE_SCREEN *aScreen )
99{
100 for( EDA_ITEM* item : container )
101 Stage( item, aChangeType, aScreen );
102
103 return *this;
104}
105
106
107void SCH_COMMIT::pushLibEdit( const wxString& aMessage, int aCommitFlags )
108{
109 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
110 LIB_SYMBOL* symbol = dynamic_cast<LIB_SYMBOL*>( m_entries.front().m_item );
111 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_entries.front().m_copy );
112
113 if( symbol )
114 {
115 if( KIGFX::VIEW* view = m_toolMgr->GetView() )
116 {
117 view->Update( symbol );
118
119 symbol->RunOnChildren(
120 [&]( SCH_ITEM* aChild )
121 {
122 view->Update( aChild );
123 },
125 }
126
127 if( SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() ) )
128 {
129 if( !( aCommitFlags & SKIP_UNDO ) )
130 {
131 if( copy )
132 {
133 frame->PushSymbolToUndoList( aMessage, copy );
134 copy = nullptr; // we've transferred ownership to the undo stack
135 }
136 }
137 }
138
139 if( copy )
140 {
141 // if no undo entry was needed, the copy would create a memory leak
142 delete copy;
143 copy = nullptr;
144 }
145 }
146
147 m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } );
149}
150
151
152void SCH_COMMIT::pushSchEdit( const wxString& aMessage, int aCommitFlags )
153{
154 // Objects potentially interested in changes:
155 PICKED_ITEMS_LIST undoList;
156 KIGFX::VIEW* view = m_toolMgr->GetView();
157
158 SCH_EDIT_FRAME* frame = static_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
159 SCH_SCREEN* currentScreen = frame ? frame->GetScreen() : nullptr;
160 SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
161 SCH_GROUP* enteredGroup = selTool ? selTool->GetEnteredGroup() : nullptr;
162 bool itemsDeselected = false;
163 bool selectedModified = false;
164 bool dirtyConnectivity = false;
165 bool refreshHierarchy = false;
166 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
167
168 if( Empty() )
169 return;
170
171 undoList.SetDescription( aMessage );
172
173 SCHEMATIC* schematic = nullptr;
174 std::vector<SCH_ITEM*> bulkAddedItems;
175 std::vector<SCH_ITEM*> bulkRemovedItems;
176 std::vector<SCH_ITEM*> itemsChanged;
177
178 auto updateConnectivityFlag =
179 [&]( SCH_ITEM* schItem )
180 {
181 if( schItem->IsConnectable() || ( schItem->Type() == SCH_RULE_AREA_T ) )
182 {
183 dirtyConnectivity = true;
184
185 // Do a local clean up if there are any connectable objects in the commit.
186 if( connectivityCleanUp == NO_CLEANUP )
187 connectivityCleanUp = LOCAL_CLEANUP;
188
189 // Do a full rebuild of the connectivity if there is a sheet in the commit.
190 if( schItem->Type() == SCH_SHEET_T )
191 connectivityCleanUp = GLOBAL_CLEANUP;
192 }
193 };
194
195 // We don't know that anything will be added to the entered group, but it does no harm to
196 // add it to the commit anyway.
197 if( enteredGroup && frame )
198 Modify( enteredGroup, frame->GetScreen() );
199
200 // Handle wires with Hop Over shapes (view update only; skipped headless):
201 if( frame )
202 {
203 for( COMMIT_LINE& entry : m_entries )
204 {
205 SCH_ITEM* schCopyItem = dynamic_cast<SCH_ITEM*>( entry.m_copy );
206 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( entry.m_item );
207
208 if( schCopyItem && schCopyItem->Type() == SCH_LINE_T )
209 frame->UpdateHopOveredWires( schCopyItem );
210
211 if( schItem && schItem->Type() == SCH_LINE_T )
212 frame->UpdateHopOveredWires( schItem );
213 }
214 }
215
216
217 // Modify() appends to m_entries, so collect first and stage after the loop.
218 std::vector<std::pair<EDA_GROUP*, BASE_SCREEN*>> removedItemGroups;
219
220 for( COMMIT_LINE& entry : m_entries )
221 {
222 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( entry.m_item );
223 int changeType = entry.m_type & CHT_TYPE;
224
225 wxCHECK2( schItem, continue );
226
227 if( changeType == CHT_REMOVE && schItem->GetParentGroup() )
228 removedItemGroups.emplace_back( schItem->GetParentGroup(), entry.m_screen );
229 }
230
231 for( const auto& [group, screen] : removedItemGroups )
232 Modify( group->AsEdaItem(), screen );
233
234 for( COMMIT_LINE& entry : m_entries )
235 {
236 int changeType = entry.m_type & CHT_TYPE;
237 int changeFlags = entry.m_type & CHT_FLAGS;
238 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( entry.m_item );
239 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( entry.m_screen );
240
241 wxCHECK2( schItem, continue );
242 wxCHECK2( screen, continue );
243
244 if( !schematic )
245 schematic = schItem->Schematic();
246
247 if( schItem->IsSelected() )
248 {
249 selectedModified = true;
250 }
251 else
252 {
253 schItem->RunOnChildren(
254 [&selectedModified]( SCH_ITEM* aChild )
255 {
256 if( aChild->IsSelected() )
257 selectedModified = true;
258 },
260 }
261
262 switch( changeType )
263 {
264 case CHT_ADD:
265 {
266 if( enteredGroup && schItem->IsGroupableType() && !schItem->GetParentGroup() )
267 selTool->GetEnteredGroup()->AddItem( schItem );
268
269 updateConnectivityFlag( schItem );
270
271 if( !( aCommitFlags & SKIP_UNDO ) )
272 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::NEWITEM ) );
273
274 if( !( changeFlags & CHT_DONE ) )
275 {
276 if( !screen->CheckIfOnDrawList( schItem ) ) // don't want a loop!
277 screen->Append( schItem );
278
279 if( view && screen == currentScreen )
280 view->Add( schItem );
281 }
282
283 if( frame && screen == currentScreen )
284 frame->UpdateItem( schItem, true, true );
285 else if( screen )
286 screen->Update( schItem );
287
288 bulkAddedItems.push_back( schItem );
289
290 if( schItem->Type() == SCH_SHEET_T )
291 refreshHierarchy = true;
292
293 break;
294 }
295
296 case CHT_REMOVE:
297 {
298 updateConnectivityFlag( schItem );
299
300 if( !( aCommitFlags & SKIP_UNDO ) )
301 {
302 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::DELETED );
303 itemWrapper.SetLink( entry.m_copy );
304 entry.m_copy = nullptr; // We've transferred ownership to the undo list
305 undoList.PushItem( itemWrapper );
306 }
307
308 if( schItem->IsSelected() )
309 {
310 if( selTool )
311 selTool->RemoveItemFromSel( schItem, true /* quiet mode */ );
312
313 itemsDeselected = true;
314 }
315
316 if( schItem->Type() == SCH_FIELD_T )
317 {
318 static_cast<SCH_FIELD*>( schItem )->SetVisible( false );
319 break;
320 }
321
322 if( EDA_GROUP* group = schItem->GetParentGroup() )
323 group->RemoveItem( schItem );
324
325 if( !( changeFlags & CHT_DONE ) )
326 {
327 screen->Remove( schItem );
328
329 if( view && screen == currentScreen )
330 view->Remove( schItem );
331 }
332
333 if( frame && screen == currentScreen )
334 frame->UpdateItem( schItem, true, true );
335 else if( screen )
336 screen->Update( schItem );
337
338 if( schItem->Type() == SCH_SHEET_T )
339 refreshHierarchy = true;
340
341 bulkRemovedItems.push_back( schItem );
342 break;
343 }
344
345 case CHT_MODIFY:
346 {
347 const SCH_ITEM* itemCopy = static_cast<const SCH_ITEM*>( entry.m_copy );
348 SCH_SHEET_PATH currentSheet;
349
350 if( frame )
351 currentSheet = frame->GetCurrentSheet();
352
353 if( itemCopy->HasConnectivityChanges( schItem, &currentSheet )
354 || ( itemCopy->Type() == SCH_RULE_AREA_T ) )
355 {
356 updateConnectivityFlag( schItem );
357 }
358
359 if( schItem->Type() == SCH_SYMBOL_T )
360 {
361 const SCH_SYMBOL* origSymbol = static_cast<const SCH_SYMBOL*>( itemCopy );
362 const SCH_SYMBOL* modSymbol = static_cast<const SCH_SYMBOL*>( schItem );
363
364 if( origSymbol->GetPins().size() != modSymbol->GetPins().size() )
365 connectivityCleanUp = GLOBAL_CLEANUP;
366 }
367
368 if( !( aCommitFlags & SKIP_UNDO ) )
369 {
370#if 0
371 // While this keeps us from marking documents modified when someone OK's a dialog with
372 // no changes, it depends on our various SCH_ITEM::operator=='s being bullet-proof. They
373 // currently aren't.
374 if( *itemCopy == *schItem )
375 {
376 // No actual changes made; short-circuit undo
377 delete entry.m_copy;
378 entry.m_copy = nullptr;
379 break;
380 }
381#endif
382
383 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::CHANGED );
384 itemWrapper.SetLink( entry.m_copy );
385 entry.m_copy = nullptr; // We've transferred ownership to the undo list
386 undoList.PushItem( itemWrapper );
387 }
388
389 if( schItem->Type() == SCH_SHEET_T )
390 {
391 const SCH_SHEET* modifiedSheet = static_cast<const SCH_SHEET*>( schItem );
392 const SCH_SHEET* originalSheet = static_cast<const SCH_SHEET*>( itemCopy );
393 wxCHECK2( modifiedSheet && originalSheet, continue );
394
395 if( originalSheet->HasPageNumberChanges( *modifiedSheet ) )
396 refreshHierarchy = true;
397 }
398
399 if( frame && screen == currentScreen )
400 frame->UpdateItem( schItem, false, true );
401 else if( screen )
402 screen->Update( schItem );
403
404 itemsChanged.push_back( schItem );
405 break;
406 }
407
408 default:
409 wxASSERT( false );
410 break;
411 }
412
413 // Delete any copies we still have ownership of
414 delete entry.m_copy;
415 entry.m_copy = nullptr;
416
417 // Clear all flags but SELECTED and others used to move and rotate commands,
418 // after edition (selected items must keep their selection flag).
419 const int selected_mask = ( SELECTED | STARTPOINT | ENDPOINT );
420 schItem->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
421
422 if( schItem->Type() == SCH_SHEET_T || schItem->Type() == SCH_SYMBOL_T )
423 {
424 schItem->RunOnChildren(
425 [&]( SCH_ITEM* child )
426 {
427 child->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
428 },
430 }
431 }
432
433 if( schematic )
434 {
435 if( bulkAddedItems.size() > 0 )
436 schematic->OnItemsAdded( bulkAddedItems );
437
438 if( bulkRemovedItems.size() > 0 )
439 schematic->OnItemsRemoved( bulkRemovedItems );
440
441 if( itemsChanged.size() > 0 )
442 schematic->OnItemsChanged( itemsChanged );
443
444 if( refreshHierarchy )
445 {
446 schematic->RefreshHierarchy();
447
448 if( frame )
450 }
451 }
452
453 if( !( aCommitFlags & SKIP_UNDO ) && frame && undoList.GetCount() > 0 )
454 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED, false );
455
456 if( dirtyConnectivity )
457 {
458 wxLogTrace( wxS( "CONN_PROFILE" ),
459 wxS( "SCH_COMMIT::pushSchEdit() %s clean up connectivity rebuild." ),
460 connectivityCleanUp == LOCAL_CLEANUP ? wxS( "local" ) : wxS( "global" ) );
461
462 if( frame )
463 frame->RecalculateConnections( this, connectivityCleanUp );
464 else if( schematic )
465 schematic->RecalculateConnections( this, connectivityCleanUp, m_toolMgr );
466 }
467
468 m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } );
469
470 if( itemsDeselected )
472
473 if( selectedModified )
475}
476
477
478void SCH_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
479{
480 if( Empty() )
481 return;
482
483 if( m_isLibEditor )
484 pushLibEdit( aMessage, aCommitFlags );
485 else
486 pushSchEdit( aMessage, aCommitFlags );
487
488 if( SCH_BASE_FRAME* frame = static_cast<SCH_BASE_FRAME*>( m_toolMgr->GetToolHolder() ) )
489 {
490 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
491 frame->OnModify();
492
493 if( frame && frame->GetCanvas() )
494 frame->GetCanvas()->Refresh();
495 }
496
497 clear();
498}
499
500
502{
503 EDA_ITEM* parent = aItem->GetParent();
504
505 if( m_isLibEditor )
506 return static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() )->GetCurSymbol();
507
508 if( parent && parent->IsType( { SCH_SYMBOL_T, SCH_TABLE_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
509 return parent;
510
511 return aItem;
512}
513
514
516{
517 if( m_isLibEditor )
518 {
519 SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
520 LIB_SYMBOL* symbol = frame->GetCurSymbol();
521 std::vector<KIID> selected;
522
523 // Cloning will clear the selected flags, but we want to keep them.
524 for( const SCH_ITEM& item : symbol->GetDrawItems() )
525 {
526 if( item.IsSelected() )
527 selected.push_back( item.m_Uuid );
528 }
529
530 symbol = new LIB_SYMBOL( *symbol );
531
532 // Restore selected flags.
533 for( SCH_ITEM& item : symbol->GetDrawItems() )
534 {
535 if( alg::contains( selected, item.m_Uuid ) )
536 item.SetSelected();
537 }
538
539 return symbol;
540 }
541
542 return aItem->Clone();
543}
544
545
547{
548 if( Empty() )
549 return;
550
551 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
552 SYMBOL_EDIT_FRAME* frame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
553 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_entries.front().m_copy );
554 SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
555
556 if( frame && copy )
557 {
558 frame->SetCurSymbol( copy, false );
559 m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
560 }
561
562 if( selTool )
563 selTool->RebuildSelection();
564
565 clear();
566}
567
568
570{
571 KIGFX::VIEW* view = m_toolMgr->GetView();
572 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
573 SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
574 SCH_SHEET_LIST sheets;
575
576 if( m_entries.empty() )
577 return;
578
579 if( m_isLibEditor )
580 {
582 return;
583 }
584
585 SCHEMATIC* schematic = nullptr;
586 std::vector<SCH_ITEM*> bulkAddedItems;
587 std::vector<SCH_ITEM*> bulkRemovedItems;
588 std::vector<SCH_ITEM*> itemsChanged;
589
590 for( COMMIT_LINE& ent : m_entries )
591 {
592 int changeType = ent.m_type & CHT_TYPE;
593 int changeFlags = ent.m_type & CHT_FLAGS;
594 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ent.m_item );
595 SCH_ITEM* copy = dynamic_cast<SCH_ITEM*>( ent.m_copy );
596 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
597
598 wxCHECK2( item && screen, continue );
599
600 if( !schematic )
601 schematic = item->Schematic();
602
603 switch( changeType )
604 {
605 case CHT_ADD:
606 if( !( changeFlags & CHT_DONE ) )
607 break;
608
609 if( view )
610 view->Remove( item );
611
612 screen->Remove( item );
613 bulkRemovedItems.push_back( item );
614 break;
615
616 case CHT_REMOVE:
617 item->SetConnectivityDirty();
618
619 if( !( changeFlags & CHT_DONE ) )
620 break;
621
622 if( view )
623 view->Add( item );
624
625 screen->Append( item );
626 bulkAddedItems.push_back( item );
627 break;
628
629 case CHT_MODIFY:
630 {
631 wxCHECK2( copy, break );
632
633 if( view )
634 view->Remove( item );
635
636 bool unselect = !item->IsSelected();
637
638 item->SwapItemData( copy );
639
640 if( unselect )
641 {
642 item->ClearSelected();
643 item->RunOnChildren( []( SCH_ITEM* aChild )
644 {
645 aChild->ClearSelected();
646 },
648 }
649
650 // Special cases for items which have instance data
651 if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T && item->Type() == SCH_FIELD_T )
652 {
653 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
654 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
655
656 if( field->GetId() == FIELD_T::REFERENCE )
657 {
658 // Lazy eval of sheet list; this is expensive even when unsorted
659 if( sheets.empty() )
660 sheets = schematic->Hierarchy();
661
662 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
663 symbol->SetRef( &sheet, field->GetText() );
664 }
665 }
666
667 // This must be called before any calls that require stable object pointers.
668 screen->Update( item );
669
670 // This hack is to prevent incorrectly parented symbol pins from breaking the
671 // connectivity algorithm.
672 if( item->Type() == SCH_SYMBOL_T )
673 {
674 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
675 symbol->UpdatePins();
676
677 CONNECTION_GRAPH* graph = schematic->ConnectionGraph();
678
679 SCH_SYMBOL* symbolCopy = static_cast<SCH_SYMBOL*>( copy );
680 graph->RemoveItem( symbolCopy );
681
682 for( SCH_PIN* pin : symbolCopy->GetPins() )
683 graph->RemoveItem( pin );
684 }
685
686 item->SetConnectivityDirty();
687
688 if( view )
689 view->Add( item );
690
691 delete copy;
692 break;
693 }
694
695 default:
696 wxASSERT( false );
697 break;
698 }
699 }
700
701 if( schematic )
702 {
703 if( bulkAddedItems.size() > 0 )
704 schematic->OnItemsAdded( bulkAddedItems );
705
706 if( bulkRemovedItems.size() > 0 )
707 schematic->OnItemsRemoved( bulkRemovedItems );
708
709 if( itemsChanged.size() > 0 )
710 schematic->OnItemsChanged( itemsChanged );
711 }
712
713 if( selTool )
714 selTool->RebuildSelection();
715
716 if( frame )
717 frame->RecalculateConnections( nullptr, NO_CLEANUP );
718
719 clear();
720}
721
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:37
bool Empty() const
Definition commit.h:134
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
std::vector< COMMIT_LINE > m_entries
Definition commit.h:183
void clear()
Should be called in Push() & Revert() methods.
Definition commit.h:154
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
Calculate the connectivity of a schematic and generates netlists.
void RemoveItem(SCH_ITEM *aItem)
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:42
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:58
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:114
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
void ClearSelected()
Definition eda_item.h:147
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:154
bool IsSelected() const
Definition eda_item.h:132
void SetSelected()
Definition eda_item.h:144
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:202
EDA_ITEM * GetParent() 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:143
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition eda_item.h:156
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:348
static const TOOL_EVENT UnselectedEvent
Definition actions.h:342
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:63
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition view.cpp:300
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:404
Define a library symbol object.
Definition lib_symbol.h:80
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:759
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
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)
unsigned GetCount() const
Holds all the data relating to one schematic.
Definition schematic.h:90
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
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.
bool m_isLibEditor
Definition sch_commit.h:69
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
EDA_ITEM * undoLevelItem(EDA_ITEM *aItem) const override
virtual void Revert() override
Revert the commit by restoring the modified items state.
TOOL_MANAGER * m_toolMgr
Definition sch_commit.h:68
SCH_COMMIT(TOOL_MANAGER *aToolMgr)
virtual ~SCH_COMMIT()
void pushLibEdit(const wxString &aMessage, int aCommitFlags)
void revertLibEdit()
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
void pushSchEdit(const wxString &aMessage, int aCommitFlags)
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
SCH_SHEET_PATH & GetCurrentSheet() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr)
Generate the connection data for the entire schematic hierarchy.
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true, bool aClear=false)
Update the hierarchy navigation tree and history.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateHopOveredWires(SCH_ITEM *aItem)
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:128
FIELD_T GetId() const
Definition sch_field.h:132
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:48
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:628
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
void SetConnectivityDirty(bool aDirty=true)
Definition sch_item.h:587
virtual bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const
Check if aItem has connectivity changes against this object.
Definition sch_item.h:604
bool IsGroupableType() const
Definition sch_item.cpp:113
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition sch_item.cpp:632
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
SCH_GROUP * GetEnteredGroup()
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:44
bool HasPageNumberChanges(const SCH_SHEET &aOther) const
Check if the instance data of this sheet has any changes compared to aOther.
Schematic symbol object.
Definition sch_symbol.h:69
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
A foundation class for a tool operating on a schematic or symbol.
bool IsSymbolEditor() const
Returns true if the tool is running in the symbol editor.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
The symbol library editor main window.
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition tool_base.h:142
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
Master controller class:
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:48
@ RECURSE
Definition eda_item.h:49
@ NO_RECURSE
Definition eda_item.h:50
#define SELECTED
Item was manually selected by the user.
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define EDA_ITEM_ALL_FLAGS
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
This file contains miscellaneous commonly used macros and functions.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
#define SKIP_SET_DIRTY
Definition sch_commit.h:38
#define SKIP_UNDO
Definition sch_commit.h:36
Class to handle a set of SCH_ITEMs.
SCH_CLEANUP_FLAGS
Definition schematic.h:76
@ LOCAL_CLEANUP
Definition schematic.h:78
@ NO_CLEANUP
Definition schematic.h:77
@ GLOBAL_CLEANUP
Definition schematic.h:79
@ REFERENCE
Field Reference of part, i.e. "IC21".
KIBIS_PIN * pin
@ 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
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_FIELD_T
Definition typeinfo.h:147
@ SCH_SHEET_T
Definition typeinfo.h:172
@ SCH_RULE_AREA_T
Definition typeinfo.h:167