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 (C) 2023-2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <macros.h>
25#include <tool/tool_manager.h>
26#include <tools/ee_tool_base.h>
27
28#include <lib_symbol.h>
29
30#include <sch_screen.h>
31#include <schematic.h>
32
33#include <view/view.h>
34#include <sch_commit.h>
35#include <connection_graph.h>
36
37#include <functional>
38#include <wx/log.h>
39
40
42 m_toolMgr( aToolMgr ),
43 m_isLibEditor( false )
44{
45 SCH_BASE_FRAME* frame = static_cast<SCH_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
46 m_isLibEditor = frame && frame->IsType( FRAME_SCH_SYMBOL_EDITOR );
47}
48
49
51{
52 m_toolMgr = aTool->GetManager();
54}
55
56
58{
59 m_toolMgr = aFrame->GetToolManager();
61}
62
63
65{
66}
67
68
69COMMIT& SCH_COMMIT::Stage( EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen )
70{
71 wxCHECK( aItem, *this );
72
73 // If aItem belongs a symbol, sheet or label, the full parent will be saved because undo/redo
74 // does not handle "sub items" modifications.
75 if( aItem->Type() != SCH_SHEET_T
76 && aItem->GetParent() && aItem->GetParent()->IsType( { SCH_SYMBOL_T, LIB_SYMBOL_T,
77 SCH_SHEET_T,
78 SCH_LABEL_LOCATE_ANY_T } ) )
79 {
80 aItem = aItem->GetParent();
81 aChangeType = CHT_MODIFY;
82 }
83
84 // IS_SELECTED flag should not be set on undo items which were added for
85 // a drag operation.
86 if( aItem->IsSelected() && aItem->HasFlag( SELECTED_BY_DRAG ) )
87 {
88 aItem->ClearSelected();
89 COMMIT::Stage( aItem, aChangeType, aScreen );
90 aItem->SetSelected();
91 }
92 else
93 {
94 COMMIT::Stage( aItem, aChangeType, aScreen );
95 }
96
97 return *this;
98}
99
100
101COMMIT& SCH_COMMIT::Stage( std::vector<EDA_ITEM*> &container, CHANGE_TYPE aChangeType,
102 BASE_SCREEN *aScreen )
103{
104 for( EDA_ITEM* item : container )
105 Stage( item, aChangeType, aScreen );
106
107 return *this;
108}
109
110
112 BASE_SCREEN *aScreen )
113{
114 return COMMIT::Stage( aItems, aModFlag, aScreen );
115}
116
117
118void SCH_COMMIT::pushLibEdit( const wxString& aMessage, int aCommitFlags )
119{
120 KIGFX::VIEW* view = m_toolMgr->GetView();
121 SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
122
123 if( Empty() )
124 return;
125
126 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
127 LIB_SYMBOL* symbol = dynamic_cast<LIB_SYMBOL*>( m_changes.front().m_item );
128 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_changes.front().m_copy );
129
130 if( symbol )
131 {
132 if( view )
133 {
134 view->Update( symbol );
135
136 symbol->RunOnChildren(
137 [&]( SCH_ITEM* aChild )
138 {
139 view->Update( aChild );
140 } );
141 }
142
143 if( !( aCommitFlags & SKIP_UNDO ) )
144 {
145 if( frame && copy )
146 {
147 frame->PushSymbolToUndoList( aMessage, copy );
148 copy = nullptr; // we've transferred ownership to the undo stack
149 }
150 }
151
152 if( copy )
153 {
154 // if no undo entry was needed, the copy would create a memory leak
155 delete copy;
156 copy = nullptr;
157 }
158 }
159
162
163 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
164 {
165 if( frame )
166 frame->OnModify();
167 }
168
169 for( size_t ii = 1; ii < m_changes.size(); ++ii )
170 delete m_changes[ii].m_copy;
171
172 clear();
173}
174
175
176void SCH_COMMIT::pushSchEdit( const wxString& aMessage, int aCommitFlags )
177{
178 // Objects potentially interested in changes:
179 PICKED_ITEMS_LIST undoList;
180 KIGFX::VIEW* view = m_toolMgr->GetView();
181
182 SCH_EDIT_FRAME* frame = static_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
184 bool itemsDeselected = false;
185 bool selectedModified = false;
186 bool dirtyConnectivity = false;
187 bool refreshHierarchy = false;
188 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
189
190 if( Empty() )
191 return;
192
193 undoList.SetDescription( aMessage );
194
195 SCHEMATIC* schematic = nullptr;
196 std::vector<SCH_ITEM*> bulkAddedItems;
197 std::vector<SCH_ITEM*> bulkRemovedItems;
198 std::vector<SCH_ITEM*> itemsChanged;
199
200 for( COMMIT_LINE& ent : m_changes )
201 {
202 int changeType = ent.m_type & CHT_TYPE;
203 int changeFlags = ent.m_type & CHT_FLAGS;
204 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( ent.m_item );
205 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
206
207 wxCHECK2( schItem && screen, continue );
208
209 if( !schematic )
210 schematic = schItem->Schematic();
211
212 if( schItem->IsSelected() )
213 {
214 selectedModified = true;
215 }
216 else
217 {
218 schItem->RunOnChildren(
219 [&selectedModified]( SCH_ITEM* aChild )
220 {
221 if( aChild->IsSelected() )
222 selectedModified = true;
223 } );
224 }
225
226 auto updateConnectivityFlag = [&]()
227 {
228 if( schItem->IsConnectable() || ( schItem->Type() == SCH_RULE_AREA_T ) )
229 {
230 dirtyConnectivity = true;
231
232 // Do a local clean up if there are any connectable objects in the commit.
233 if( connectivityCleanUp == NO_CLEANUP )
234 connectivityCleanUp = LOCAL_CLEANUP;
235
236 // Do a full rebauild of the connectivity if there is a sheet in the commit.
237 if( schItem->Type() == SCH_SHEET_T )
238 connectivityCleanUp = GLOBAL_CLEANUP;
239 }
240 };
241
242 switch( changeType )
243 {
244 case CHT_ADD:
245 {
246 updateConnectivityFlag();
247
248 if( !( aCommitFlags & SKIP_UNDO ) )
249 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::NEWITEM ) );
250
251 if( !( changeFlags & CHT_DONE ) )
252 {
253 if( !screen->CheckIfOnDrawList( schItem ) ) // don't want a loop!
254 screen->Append( schItem );
255
256 if( view )
257 view->Add( schItem );
258 }
259
260 if( frame )
261 frame->UpdateItem( schItem, true, true );
262
263 bulkAddedItems.push_back( schItem );
264
265 if( schItem->Type() == SCH_SHEET_T )
266 refreshHierarchy = true;
267
268 break;
269 }
270
271 case CHT_REMOVE:
272 {
273 updateConnectivityFlag();
274
275 if( !( aCommitFlags & SKIP_UNDO ) )
276 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::DELETED ) );
277
278 if( schItem->IsSelected() )
279 {
280 if( selTool )
281 selTool->RemoveItemFromSel( schItem, true /* quiet mode */ );
282
283 itemsDeselected = true;
284 }
285
286 if( schItem->Type() == SCH_FIELD_T )
287 {
288 static_cast<SCH_FIELD*>( schItem )->SetVisible( false );
289 break;
290 }
291
292 if( !( changeFlags & CHT_DONE ) )
293 {
294 screen->Remove( schItem );
295
296 if( view )
297 view->Remove( schItem );
298 }
299
300 if( frame )
301 frame->UpdateItem( schItem, true, true );
302
303 bulkRemovedItems.push_back( schItem );
304
305 if( schItem->Type() == SCH_SHEET_T )
306 refreshHierarchy = true;
307
308 break;
309 }
310
311 case CHT_MODIFY:
312 {
313 if( !( aCommitFlags & SKIP_UNDO ) )
314 {
315 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::CHANGED );
316 wxASSERT( ent.m_copy );
317 itemWrapper.SetLink( ent.m_copy );
318
319 const SCH_ITEM* itemCopy = static_cast<const SCH_ITEM*>( ent.m_copy );
320
321 wxCHECK2( itemCopy, continue );
322
323 SCH_SHEET_PATH currentSheet;
324
325 if( frame )
326 currentSheet = frame->GetCurrentSheet();
327
328 if( itemCopy->HasConnectivityChanges( schItem, &currentSheet )
329 || ( itemCopy->Type() == SCH_RULE_AREA_T ) )
330 {
331 updateConnectivityFlag();
332 }
333
334
335 if( schItem->Type() == SCH_SHEET_T )
336 {
337 const SCH_SHEET* modifiedSheet = static_cast<const SCH_SHEET*>( schItem );
338 const SCH_SHEET* originalSheet = static_cast<const SCH_SHEET*>( itemCopy );
339 wxCHECK2( modifiedSheet && originalSheet, continue );
340
341 if( originalSheet->HasPageNumberChanges( *modifiedSheet ) )
342 refreshHierarchy = true;
343 }
344
345 undoList.PushItem( itemWrapper );
346 ent.m_copy = nullptr; // We've transferred ownership to the undo list
347 }
348
349 if( frame )
350 frame->UpdateItem( schItem, false, true );
351
352 itemsChanged.push_back( schItem );
353
354 if( ent.m_copy )
355 {
356 // if no undo entry is needed, the copy would create a memory leak
357 delete ent.m_copy;
358 ent.m_copy = nullptr;
359 }
360
361 break;
362 }
363
364 default:
365 wxASSERT( false );
366 break;
367 }
368
369 // Clear all flags but SELECTED and others used to move and rotate commands,
370 // after edition (selected items must keep their selection flag).
371 const int selected_mask = ( SELECTED | STARTPOINT | ENDPOINT );
372 schItem->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
373 }
374
375 if( schematic )
376 {
377 if( bulkAddedItems.size() > 0 )
378 schematic->OnItemsAdded( bulkAddedItems );
379
380 if( bulkRemovedItems.size() > 0 )
381 schematic->OnItemsRemoved( bulkRemovedItems );
382
383 if( itemsChanged.size() > 0 )
384 schematic->OnItemsChanged( itemsChanged );
385
386 if( refreshHierarchy )
387 {
388 schematic->RefreshHierarchy();
389
390 if( frame )
392 }
393 }
394
395 if( !( aCommitFlags & SKIP_UNDO ) )
396 {
397 if( frame )
398 {
399 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED, false, dirtyConnectivity );
400
401 if( dirtyConnectivity )
402 {
403 wxLogTrace( wxS( "CONN_PROFILE" ),
404 wxS( "SCH_COMMIT::pushSchEdit() %s clean up connectivity rebuild." ),
405 ( connectivityCleanUp == LOCAL_CLEANUP ) ? wxS( "local" ) : wxS( "global" ) );
406 frame->RecalculateConnections( this, connectivityCleanUp );
407 }
408 }
409 }
410
412
413 if( itemsDeselected )
415
416 if( selectedModified )
418
419 if( frame && frame->GetCanvas() )
420 frame->GetCanvas()->Refresh();
421
422 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
423 {
424 if( frame )
425 frame->OnModify();
426 }
427
428 clear();
429}
430
431
432void SCH_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
433{
434 if( m_isLibEditor )
435 pushLibEdit( aMessage, aCommitFlags );
436 else
437 pushSchEdit( aMessage, aCommitFlags );
438}
439
440
442{
443 EDA_ITEM* parent = aItem->GetParent();
444
445 if( parent && ( parent->Type() == SCH_SYMBOL_T || parent->Type() == LIB_SYMBOL_T ) )
446 return parent;
447
448 if( m_isLibEditor )
449 return static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() )->GetCurSymbol();
450
451 return aItem;
452}
453
454
456{
457 if( m_isLibEditor )
458 {
459 SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
460 LIB_SYMBOL* symbol = frame->GetCurSymbol();
461 std::vector<KIID> selected;
462
463 for( const SCH_ITEM& item : symbol->GetDrawItems() )
464 {
465 if( item.IsSelected() )
466 selected.push_back( item.m_Uuid );
467 }
468
469 symbol = new LIB_SYMBOL( *symbol );
470
471 for( SCH_ITEM& item : symbol->GetDrawItems() )
472 {
473 if( alg::contains( selected, item.m_Uuid ) )
474 item.SetSelected();
475 }
476
477 return symbol;
478 }
479
480 return aItem->Clone();
481}
482
483
485{
486 if( Empty() )
487 return;
488
489 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
490 SYMBOL_EDIT_FRAME* frame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
491 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_changes.front().m_copy );
493
494 if( frame && copy )
495 {
496 frame->SetCurSymbol( copy, false );
498 }
499
500 for( size_t ii = 1; ii < m_changes.size(); ++ii )
501 delete m_changes[ii].m_copy;
502
503 if( selTool )
504 selTool->RebuildSelection();
505
506 clear();
507}
508
509
511{
512 KIGFX::VIEW* view = m_toolMgr->GetView();
513 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
515 SCH_SHEET_LIST sheets;
516
517 if( m_changes.empty() )
518 return;
519
520 if( m_isLibEditor )
521 {
523 return;
524 }
525
526 SCHEMATIC* schematic = nullptr;
527 std::vector<SCH_ITEM*> bulkAddedItems;
528 std::vector<SCH_ITEM*> bulkRemovedItems;
529 std::vector<SCH_ITEM*> itemsChanged;
530
531 for( COMMIT_LINE& ent : m_changes )
532 {
533 int changeType = ent.m_type & CHT_TYPE;
534 int changeFlags = ent.m_type & CHT_FLAGS;
535 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ent.m_item );
536 SCH_ITEM* copy = dynamic_cast<SCH_ITEM*>( ent.m_copy );
537 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
538
539 wxCHECK2( item && screen, continue );
540
541 if( !schematic )
542 schematic = item->Schematic();
543
544 switch( changeType )
545 {
546 case CHT_ADD:
547 if( !( changeFlags & CHT_DONE ) )
548 break;
549
550 if( view )
551 view->Remove( item );
552
553 screen->Remove( item );
554 bulkRemovedItems.push_back( item );
555 break;
556
557 case CHT_REMOVE:
558 item->SetConnectivityDirty();
559
560 if( !( changeFlags & CHT_DONE ) )
561 break;
562
563 if( view )
564 view->Add( item );
565
566 screen->Append( item );
567 bulkAddedItems.push_back( item );
568 break;
569
570 case CHT_MODIFY:
571 {
572 if( view )
573 view->Remove( item );
574
575 bool unselect = !item->IsSelected();
576
577 item->SwapData( copy );
578
579 if( unselect )
580 {
581 item->ClearSelected();
582 item->RunOnChildren( []( SCH_ITEM* aChild ) { aChild->ClearSelected(); } );
583 }
584
585 // Special cases for items which have instance data
586 if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T
587 && item->Type() == SCH_FIELD_T )
588 {
589 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
590 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
591
592 if( field->GetId() == REFERENCE_FIELD )
593 {
594 // Lazy eval of sheet list; this is expensive even when unsorted
595 if( sheets.empty() )
596 sheets = schematic->Hierarchy();
597
598 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
599 symbol->SetRef( &sheet, field->GetText() );
600 }
601 }
602
603 // This must be called before any calls that require stable object pointers.
604 screen->Update( item );
605
606 // This hack is to prevent incorrectly parented symbol pins from breaking the
607 // connectivity algorithm.
608 if( item->Type() == SCH_SYMBOL_T )
609 {
610 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
611 symbol->UpdatePins();
612
613 CONNECTION_GRAPH* graph = schematic->ConnectionGraph();
614
615 SCH_SYMBOL* symbolCopy = static_cast<SCH_SYMBOL*>( copy );
616 graph->RemoveItem( symbolCopy );
617
618 for( SCH_PIN* pin : symbolCopy->GetPins() )
619 graph->RemoveItem( pin );
620 }
621
622 item->SetConnectivityDirty();
623
624 if( view )
625 view->Add( item );
626
627 delete copy;
628 break;
629 }
630
631 default:
632 wxASSERT( false );
633 break;
634 }
635 }
636
637 if( schematic )
638 {
639 if( bulkAddedItems.size() > 0 )
640 schematic->OnItemsAdded( bulkAddedItems );
641
642 if( bulkRemovedItems.size() > 0 )
643 schematic->OnItemsRemoved( bulkRemovedItems );
644
645 if( itemsChanged.size() > 0 )
646 schematic->OnItemsChanged( itemsChanged );
647 }
648
649 if( selTool )
650 selTool->RebuildSelection();
651
652 if( frame )
653 {
654 frame->RecalculateConnections( nullptr, NO_CLEANUP );
655 }
656
657 clear();
658}
659
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
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
void clear()
Definition: commit.h:165
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:195
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearSelected()
Definition: eda_item.h:122
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:129
bool IsSelected() const
Definition: eda_item.h:110
void SetSelected()
Definition: eda_item.h:119
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:176
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:85
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:131
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
bool IsSymbolEditor() const
Returns true if the tool is running in the symbol editor.
Definition: ee_tool_base.h:99
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:299
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:293
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:299
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:334
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:1669
Define a library symbol object.
Definition: lib_symbol.h:78
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:499
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)
Holds all the data relating to one schematic.
Definition: schematic.h:77
void OnItemsAdded(std::vector< SCH_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
Definition: schematic.cpp:766
void OnItemsRemoved(std::vector< SCH_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
Definition: schematic.cpp:772
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:166
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
void RefreshHierarchy()
Definition: schematic.cpp:222
void OnItemsChanged(std::vector< SCH_ITEM * > &aItems)
Notify the schematic and its listeners that an item on the schematic has been modified in some way.
Definition: schematic.cpp:778
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool m_isLibEditor
Definition: sch_commit.h:77
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:432
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
Definition: sch_commit.cpp:69
virtual void Revert() override
Definition: sch_commit.cpp:510
TOOL_MANAGER * m_toolMgr
Definition: sch_commit.h:76
SCH_COMMIT(TOOL_MANAGER *aToolMgr)
Definition: sch_commit.cpp:41
virtual ~SCH_COMMIT()
Definition: sch_commit.cpp:64
void pushLibEdit(const wxString &aMessage, int aCommitFlags)
Definition: sch_commit.cpp:118
void revertLibEdit()
Definition: sch_commit.cpp:484
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
Definition: sch_commit.cpp:455
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
Definition: sch_commit.cpp:441
void pushSchEdit(const wxString &aMessage, int aCommitFlags)
Definition: sch_commit.cpp:176
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true)
Update the hierarchy navigation tree and history.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
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)
Generate the connection data for the entire schematic hierarchy.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
int GetId() const
Definition: sch_field.h:133
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual bool IsConnectable() const
Definition: sch_item.h:449
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:568
virtual void SwapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition: sch_item.cpp:345
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:512
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:529
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:153
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:323
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:316
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:386
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:57
bool HasPageNumberChanges(const SCH_SHEET &aOther) const
Check if the instance data of this sheet has any changes compared to aOther.
Definition: sch_sheet.cpp:1538
Schematic symbol object.
Definition: sch_symbol.h:104
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:315
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:779
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
The symbol library editor main window.
void PushSymbolToUndoList(const wxString &aDescription, LIB_SYMBOL *aSymbolCopy, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT)
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.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:146
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
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
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:391
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:49
@ CHT_TYPE
Definition: commit.h:47
@ CHT_ADD
Definition: commit.h:42
@ CHT_FLAGS
Definition: commit.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:35
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:100
#define SKIP_SET_DIRTY
Definition: sch_commit.h:43
#define SKIP_UNDO
Definition: sch_commit.h:41
SCH_CLEANUP_FLAGS
@ LOCAL_CLEANUP
@ NO_CLEANUP
@ GLOBAL_CLEANUP
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ 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
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...