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
490 if( m_changes.empty() )
491 return;
492
493 if( m_isLibEditor )
494 {
496 return;
497 }
498
499 SCHEMATIC* schematic = nullptr;
500 std::vector<SCH_ITEM*> bulkAddedItems;
501 std::vector<SCH_ITEM*> bulkRemovedItems;
502 std::vector<SCH_ITEM*> itemsChanged;
503
504 for( COMMIT_LINE& ent : m_changes )
505 {
506 int changeType = ent.m_type & CHT_TYPE;
507 int changeFlags = ent.m_type & CHT_FLAGS;
508 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ent.m_item );
509 SCH_ITEM* copy = dynamic_cast<SCH_ITEM*>( ent.m_copy );
510 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
511
512 wxCHECK2( item && screen, continue );
513
514 if( !schematic )
515 schematic = item->Schematic();
516
517 switch( changeType )
518 {
519 case CHT_ADD:
520 if( !( changeFlags & CHT_DONE ) )
521 break;
522
523 if( view )
524 view->Remove( item );
525
526 screen->Remove( item );
527 bulkRemovedItems.push_back( item );
528 break;
529
530 case CHT_REMOVE:
531 item->SetConnectivityDirty();
532
533 if( !( changeFlags & CHT_DONE ) )
534 break;
535
536 if( view )
537 view->Add( item );
538
539 screen->Append( item );
540 bulkAddedItems.push_back( item );
541 break;
542
543 case CHT_MODIFY:
544 {
545 if( view )
546 view->Remove( item );
547
548 bool unselect = !item->IsSelected();
549
550 item->SwapData( copy );
551
552 if( unselect )
553 {
554 item->ClearSelected();
555 item->RunOnChildren( []( SCH_ITEM* aChild ) { aChild->ClearSelected(); } );
556 }
557
558 // Special cases for items which have instance data
559 if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T
560 && item->Type() == SCH_FIELD_T )
561 {
562 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
563 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
564
565 if( field->GetId() == REFERENCE_FIELD )
566 {
567 SCH_SHEET_PATH sheet = schematic->GetSheets().FindSheetForScreen( screen );
568 symbol->SetRef( &sheet, field->GetText() );
569 }
570 }
571
572 // This must be called before any calls that require stable object pointers.
573 screen->Update( item );
574
575 // This hack is to prevent incorrectly parented symbol pins from breaking the
576 // connectivity algorithm.
577 if( item->Type() == SCH_SYMBOL_T )
578 {
579 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
580 symbol->UpdatePins();
581
582 CONNECTION_GRAPH* graph = schematic->ConnectionGraph();
583
584 SCH_SYMBOL* symbolCopy = static_cast<SCH_SYMBOL*>( copy );
585 graph->RemoveItem( symbolCopy );
586
587 for( SCH_PIN* pin : symbolCopy->GetPins() )
588 graph->RemoveItem( pin );
589 }
590
591 item->SetConnectivityDirty();
592
593 if( view )
594 view->Add( item );
595
596 delete copy;
597 break;
598 }
599
600 default:
601 wxASSERT( false );
602 break;
603 }
604 }
605
606 if( schematic )
607 {
608 if( bulkAddedItems.size() > 0 )
609 schematic->OnItemsAdded( bulkAddedItems );
610
611 if( bulkRemovedItems.size() > 0 )
612 schematic->OnItemsRemoved( bulkRemovedItems );
613
614 if( itemsChanged.size() > 0 )
615 schematic->OnItemsChanged( itemsChanged );
616 }
617
618 if( selTool )
619 selTool->RebuildSelection();
620
621 if( frame )
622 {
623 frame->RecalculateConnections( nullptr, NO_CLEANUP );
624 }
625
626 clear();
627}
628
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:267
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:261
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:486
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:751
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:757
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:146
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
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:763
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:174
virtual bool IsConnectable() const
Definition: sch_item.h:457
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:576
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:520
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:537
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:151
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:321
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:314
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:384
SCH_SHEET_PATH FindSheetForScreen(const SCH_SCREEN *aScreen)
Return the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen.
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:311
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:751
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...