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 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
188
189 if( Empty() )
190 return;
191
192 undoList.SetDescription( aMessage );
193
194 SCHEMATIC* schematic = nullptr;
195 std::vector<SCH_ITEM*> bulkAddedItems;
196 std::vector<SCH_ITEM*> bulkRemovedItems;
197 std::vector<SCH_ITEM*> itemsChanged;
198
199 for( COMMIT_LINE& ent : m_changes )
200 {
201 int changeType = ent.m_type & CHT_TYPE;
202 int changeFlags = ent.m_type & CHT_FLAGS;
203 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( ent.m_item );
204 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
205
206 wxCHECK2( schItem && screen, continue );
207
208 if( !schematic )
209 schematic = schItem->Schematic();
210
211 if( schItem->IsSelected() )
212 {
213 selectedModified = true;
214 }
215 else
216 {
217 schItem->RunOnChildren(
218 [&selectedModified]( SCH_ITEM* aChild )
219 {
220 if( aChild->IsSelected() )
221 selectedModified = true;
222 } );
223 }
224
225 auto updateConnectivityFlag = [&]()
226 {
227 if( schItem->IsConnectable() || ( schItem->Type() == SCH_RULE_AREA_T ) )
228 {
229 dirtyConnectivity = true;
230
231 // Do a local clean up if there are any connectable objects in the commit.
232 if( connectivityCleanUp == NO_CLEANUP )
233 connectivityCleanUp = LOCAL_CLEANUP;
234
235 // Do a full rebauild of the connectivity if there is a sheet in the commit.
236 if( schItem->Type() == SCH_SHEET_T )
237 connectivityCleanUp = GLOBAL_CLEANUP;
238 }
239 };
240
241 switch( changeType )
242 {
243 case CHT_ADD:
244 {
245 updateConnectivityFlag();
246
247 if( !( aCommitFlags & SKIP_UNDO ) )
248 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::NEWITEM ) );
249
250 if( !( changeFlags & CHT_DONE ) )
251 {
252 if( !screen->CheckIfOnDrawList( schItem ) ) // don't want a loop!
253 screen->Append( schItem );
254
255 if( view )
256 view->Add( schItem );
257 }
258
259 if( frame )
260 frame->UpdateItem( schItem, true, true );
261
262 bulkAddedItems.push_back( schItem );
263
264 break;
265 }
266
267 case CHT_REMOVE:
268 {
269 updateConnectivityFlag();
270
271 if( !( aCommitFlags & SKIP_UNDO ) )
272 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::DELETED ) );
273
274 if( schItem->IsSelected() )
275 {
276 if( selTool )
277 selTool->RemoveItemFromSel( schItem, true /* quiet mode */ );
278
279 itemsDeselected = true;
280 }
281
282 if( schItem->Type() == SCH_FIELD_T )
283 {
284 static_cast<SCH_FIELD*>( schItem )->SetVisible( false );
285 break;
286 }
287
288 if( !( changeFlags & CHT_DONE ) )
289 {
290 screen->Remove( schItem );
291
292 if( view )
293 view->Remove( schItem );
294 }
295
296 if( frame )
297 frame->UpdateItem( schItem, true, true );
298
299 bulkRemovedItems.push_back( schItem );
300
301 break;
302 }
303
304 case CHT_MODIFY:
305 {
306 if( !( aCommitFlags & SKIP_UNDO ) )
307 {
308 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::CHANGED );
309 wxASSERT( ent.m_copy );
310 itemWrapper.SetLink( ent.m_copy );
311
312 const SCH_ITEM* itemCopy = static_cast<const SCH_ITEM*>( ent.m_copy );
313
314 wxCHECK2( itemCopy, continue );
315
316 SCH_SHEET_PATH currentSheet;
317
318 if( frame )
319 currentSheet = frame->GetCurrentSheet();
320
321 if( itemCopy->HasConnectivityChanges( schItem, &currentSheet )
322 || ( itemCopy->Type() == SCH_RULE_AREA_T ) )
323 {
324 updateConnectivityFlag();
325 }
326
327 undoList.PushItem( itemWrapper );
328 ent.m_copy = nullptr; // We've transferred ownership to the undo list
329 }
330
331 if( frame )
332 frame->UpdateItem( schItem, false, true );
333
334 itemsChanged.push_back( schItem );
335
336 if( ent.m_copy )
337 {
338 // if no undo entry is needed, the copy would create a memory leak
339 delete ent.m_copy;
340 ent.m_copy = nullptr;
341 }
342
343 break;
344 }
345
346 default:
347 wxASSERT( false );
348 break;
349 }
350
351 // Clear all flags but SELECTED and others used to move and rotate commands,
352 // after edition (selected items must keep their selection flag).
353 const int selected_mask = ( SELECTED | STARTPOINT | ENDPOINT );
354 schItem->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
355 }
356
357 if( schematic )
358 {
359 if( bulkAddedItems.size() > 0 )
360 schematic->OnItemsAdded( bulkAddedItems );
361
362 if( bulkRemovedItems.size() > 0 )
363 schematic->OnItemsRemoved( bulkRemovedItems );
364
365 if( itemsChanged.size() > 0 )
366 schematic->OnItemsChanged( itemsChanged );
367 }
368
369 if( !( aCommitFlags & SKIP_UNDO ) )
370 {
371 if( frame )
372 {
373 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED, false, dirtyConnectivity );
374
375 if( dirtyConnectivity )
376 {
377 wxLogTrace( wxS( "CONN_PROFILE" ),
378 wxS( "SCH_COMMIT::pushSchEdit() %s clean up connectivity rebuild." ),
379 ( connectivityCleanUp == LOCAL_CLEANUP ) ? wxS( "local" ) : wxS( "global" ) );
380 frame->RecalculateConnections( this, connectivityCleanUp );
381 }
382 }
383 }
384
386
387 if( itemsDeselected )
389
390 if( selectedModified )
392
393 if( frame && frame->GetCanvas() )
394 frame->GetCanvas()->Refresh();
395
396 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
397 {
398 if( frame )
399 frame->OnModify();
400 }
401
402 clear();
403}
404
405
406void SCH_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
407{
408 if( m_isLibEditor )
409 pushLibEdit( aMessage, aCommitFlags );
410 else
411 pushSchEdit( aMessage, aCommitFlags );
412}
413
414
416{
417 EDA_ITEM* parent = aItem->GetParent();
418
419 if( parent && ( parent->Type() == SCH_SYMBOL_T || parent->Type() == LIB_SYMBOL_T ) )
420 return parent;
421
422 if( m_isLibEditor )
423 return static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() )->GetCurSymbol();
424
425 return aItem;
426}
427
428
430{
431 if( m_isLibEditor )
432 {
433 SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
434 LIB_SYMBOL* symbol = frame->GetCurSymbol();
435 std::vector<KIID> selected;
436
437 for( const SCH_ITEM& item : symbol->GetDrawItems() )
438 {
439 if( item.IsSelected() )
440 selected.push_back( item.m_Uuid );
441 }
442
443 symbol = new LIB_SYMBOL( *symbol );
444
445 for( SCH_ITEM& item : symbol->GetDrawItems() )
446 {
447 if( alg::contains( selected, item.m_Uuid ) )
448 item.SetSelected();
449 }
450
451 return symbol;
452 }
453
454 return aItem->Clone();
455}
456
457
459{
460 if( Empty() )
461 return;
462
463 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
464 SYMBOL_EDIT_FRAME* frame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
465 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_changes.front().m_copy );
467
468 if( frame && copy )
469 {
470 frame->SetCurSymbol( copy, false );
472 }
473
474 for( size_t ii = 1; ii < m_changes.size(); ++ii )
475 delete m_changes[ii].m_copy;
476
477 if( selTool )
478 selTool->RebuildSelection();
479
480 clear();
481}
482
483
485{
486 KIGFX::VIEW* view = m_toolMgr->GetView();
487 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
489 SCH_SHEET_LIST sheets;
490
491 if( m_changes.empty() )
492 return;
493
494 if( m_isLibEditor )
495 {
497 return;
498 }
499
500 SCHEMATIC* schematic = nullptr;
501 std::vector<SCH_ITEM*> bulkAddedItems;
502 std::vector<SCH_ITEM*> bulkRemovedItems;
503 std::vector<SCH_ITEM*> itemsChanged;
504
505 for( COMMIT_LINE& ent : m_changes )
506 {
507 int changeType = ent.m_type & CHT_TYPE;
508 int changeFlags = ent.m_type & CHT_FLAGS;
509 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ent.m_item );
510 SCH_ITEM* copy = dynamic_cast<SCH_ITEM*>( ent.m_copy );
511 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
512
513 wxCHECK2( item && screen, continue );
514
515 if( !schematic )
516 schematic = item->Schematic();
517
518 switch( changeType )
519 {
520 case CHT_ADD:
521 if( !( changeFlags & CHT_DONE ) )
522 break;
523
524 if( view )
525 view->Remove( item );
526
527 screen->Remove( item );
528 bulkRemovedItems.push_back( item );
529 break;
530
531 case CHT_REMOVE:
532 item->SetConnectivityDirty();
533
534 if( !( changeFlags & CHT_DONE ) )
535 break;
536
537 if( view )
538 view->Add( item );
539
540 screen->Append( item );
541 bulkAddedItems.push_back( item );
542 break;
543
544 case CHT_MODIFY:
545 {
546 if( view )
547 view->Remove( item );
548
549 bool unselect = !item->IsSelected();
550
551 item->SwapData( copy );
552
553 if( unselect )
554 {
555 item->ClearSelected();
556 item->RunOnChildren( []( SCH_ITEM* aChild ) { aChild->ClearSelected(); } );
557 }
558
559 // Special cases for items which have instance data
560 if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T
561 && item->Type() == SCH_FIELD_T )
562 {
563 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
564 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
565
566 if( field->GetId() == REFERENCE_FIELD )
567 {
568 // Lazy eval of sheet list; this is expensive even when unsorted
569 if( sheets.empty() )
570 sheets = schematic->BuildUnorderedSheetList();
571
572 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
573 symbol->SetRef( &sheet, field->GetText() );
574 }
575 }
576
577 // This must be called before any calls that require stable object pointers.
578 screen->Update( item );
579
580 // This hack is to prevent incorrectly parented symbol pins from breaking the
581 // connectivity algorithm.
582 if( item->Type() == SCH_SYMBOL_T )
583 {
584 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
585 symbol->UpdatePins();
586
587 CONNECTION_GRAPH* graph = schematic->ConnectionGraph();
588
589 SCH_SYMBOL* symbolCopy = static_cast<SCH_SYMBOL*>( copy );
590 graph->RemoveItem( symbolCopy );
591
592 for( SCH_PIN* pin : symbolCopy->GetPins() )
593 graph->RemoveItem( pin );
594 }
595
596 item->SetConnectivityDirty();
597
598 if( view )
599 view->Add( item );
600
601 delete copy;
602 break;
603 }
604
605 default:
606 wxASSERT( false );
607 break;
608 }
609 }
610
611 if( schematic )
612 {
613 if( bulkAddedItems.size() > 0 )
614 schematic->OnItemsAdded( bulkAddedItems );
615
616 if( bulkRemovedItems.size() > 0 )
617 schematic->OnItemsRemoved( bulkRemovedItems );
618
619 if( itemsChanged.size() > 0 )
620 schematic->OnItemsChanged( itemsChanged );
621 }
622
623 if( selTool )
624 selTool->RebuildSelection();
625
626 if( frame )
627 {
628 frame->RecalculateConnections( nullptr, NO_CLEANUP );
629 }
630
631 clear();
632}
633
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:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
void ClearSelected()
Definition: eda_item.h:121
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:128
bool IsSelected() const
Definition: eda_item.h:109
void SetSelected()
Definition: eda_item.h:118
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:175
EDA_ITEM * GetParent() const
Definition: eda_item.h:102
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:130
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:271
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:265
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:315
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:354
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:1631
Define a library symbol object.
Definition: lib_symbol.h:77
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:497
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:75
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:754
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:760
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:153
SCH_SHEET_LIST BuildUnorderedSheetList() const
Definition: schematic.h:100
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:766
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:406
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:484
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:458
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
Definition: sch_commit.cpp:429
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
Definition: sch_commit.cpp:415
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 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:145
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:343
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:152
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:322
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:315
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:385
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...
Schematic symbol object.
Definition: sch_symbol.h:105
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:264
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:690
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:145
@ 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...