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_item.h>
29#include <lib_symbol.h>
30
31#include <sch_screen.h>
32#include <schematic.h>
33
34#include <view/view.h>
35#include <sch_commit.h>
36#include <connection_graph.h>
37
38#include <functional>
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 [&]( LIB_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 selectedModified = true;
213
214 if( !( aCommitFlags & SKIP_CONNECTIVITY ) && schItem->IsConnectable() )
215 {
216 dirtyConnectivity = true;
217
218 // Do a local clean up if there are any connectable objects in the commit.
219 if( connectivityCleanUp == NO_CLEANUP )
220 connectivityCleanUp = LOCAL_CLEANUP;
221
222 // Do a full rebauild of the connectivity if there is a sheet in the commit.
223 if( schItem->Type() == SCH_SHEET_T )
224 connectivityCleanUp = GLOBAL_CLEANUP;
225 }
226
227 switch( changeType )
228 {
229 case CHT_ADD:
230 {
231 if( !( aCommitFlags & SKIP_UNDO ) )
232 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::NEWITEM ) );
233
234 if( !( changeFlags & CHT_DONE ) )
235 {
236 if( !screen->CheckIfOnDrawList( schItem ) ) // don't want a loop!
237 screen->Append( schItem );
238
239 if( view )
240 view->Add( schItem );
241 }
242
243 if( frame )
244 frame->UpdateItem( schItem, true, true );
245
246 bulkAddedItems.push_back( schItem );
247
248 break;
249 }
250
251 case CHT_REMOVE:
252 {
253 if( !( aCommitFlags & SKIP_UNDO ) )
254 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::DELETED ) );
255
256 if( schItem->IsSelected() )
257 {
258 if( selTool )
259 selTool->RemoveItemFromSel( schItem, true /* quiet mode */ );
260
261 itemsDeselected = true;
262 }
263
264 if( schItem->Type() == SCH_FIELD_T )
265 {
266 static_cast<SCH_FIELD*>( schItem )->SetVisible( false );
267 break;
268 }
269
270 if( !( changeFlags & CHT_DONE ) )
271 {
272 screen->Remove( schItem );
273
274 if( view )
275 view->Remove( schItem );
276 }
277
278 if( frame )
279 frame->UpdateItem( schItem, true, true );
280
281 bulkRemovedItems.push_back( schItem );
282
283 break;
284 }
285
286 case CHT_MODIFY:
287 {
288 if( !( aCommitFlags & SKIP_UNDO ) )
289 {
290 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::CHANGED );
291 wxASSERT( ent.m_copy );
292 itemWrapper.SetLink( ent.m_copy );
293 undoList.PushItem( itemWrapper );
294 ent.m_copy = nullptr; // We've transferred ownership to the undo list
295 }
296
297 if( frame )
298 frame->UpdateItem( schItem, false, true );
299
300 itemsChanged.push_back( schItem );
301
302 if( ent.m_copy )
303 {
304 // if no undo entry is needed, the copy would create a memory leak
305 delete ent.m_copy;
306 ent.m_copy = nullptr;
307 }
308
309 break;
310 }
311
312 default:
313 wxASSERT( false );
314 break;
315 }
316
317 // Clear all flags but SELECTED and others used to move and rotate commands,
318 // after edition (selected items must keep their selection flag).
319 const int selected_mask = ( SELECTED | STARTPOINT | ENDPOINT );
320 schItem->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
321 }
322
323 if( schematic )
324 {
325 if( bulkAddedItems.size() > 0 )
326 schematic->OnItemsAdded( bulkAddedItems );
327
328 if( bulkRemovedItems.size() > 0 )
329 schematic->OnItemsRemoved( bulkRemovedItems );
330
331 if( itemsChanged.size() > 0 )
332 schematic->OnItemsChanged( itemsChanged );
333 }
334
335 if( !( aCommitFlags & SKIP_UNDO ) )
336 {
337 if( frame )
338 {
339 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED, false, dirtyConnectivity );
340
341 if( dirtyConnectivity )
342 frame->RecalculateConnections( this, connectivityCleanUp );
343 }
344 }
345
347
348 if( itemsDeselected )
350
351 if( selectedModified )
353
354 if( frame && frame->GetCanvas() )
355 frame->GetCanvas()->Refresh();
356
357 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
358 {
359 if( frame )
360 frame->OnModify();
361 }
362
363 clear();
364}
365
366
367void SCH_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
368{
369 if( m_isLibEditor )
370 pushLibEdit( aMessage, aCommitFlags );
371 else
372 pushSchEdit( aMessage, aCommitFlags );
373}
374
375
377{
378 EDA_ITEM* parent = aItem->GetParent();
379
380 if( parent && parent->Type() == SCH_SYMBOL_T )
381 return parent;
382
383 if( parent && parent->Type() == LIB_SYMBOL_T )
384 return parent;
385
386 if( m_isLibEditor )
387 return static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() )->GetCurSymbol();
388
389 return aItem;
390}
391
392
394{
395 if( m_isLibEditor )
396 {
397 SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
398 LIB_SYMBOL* symbol = frame->GetCurSymbol();
399 std::vector<KIID> selected;
400
401 for( const LIB_ITEM& item : symbol->GetDrawItems() )
402 {
403 if( item.IsSelected() )
404 selected.push_back( item.m_Uuid );
405 }
406
407 symbol = new LIB_SYMBOL( *symbol );
408
409 for( LIB_ITEM& item : symbol->GetDrawItems() )
410 {
411 if( alg::contains( selected, item.m_Uuid ) )
412 item.SetSelected();
413 }
414
415 return symbol;
416 }
417
418 return aItem->Clone();
419}
420
421
423{
424 if( Empty() )
425 return;
426
427 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
428 SYMBOL_EDIT_FRAME* frame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
429 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_changes.front().m_copy );
431
432 if( frame && copy )
433 {
434 frame->SetCurSymbol( copy, false );
436 }
437
438 for( size_t ii = 1; ii < m_changes.size(); ++ii )
439 delete m_changes[ii].m_copy;
440
441 if( selTool )
442 selTool->RebuildSelection();
443
444 clear();
445}
446
447
449{
450 KIGFX::VIEW* view = m_toolMgr->GetView();
451 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
453
454 if( m_changes.empty() )
455 return;
456
457 if( m_isLibEditor )
458 {
460 return;
461 }
462
463 SCHEMATIC* schematic = nullptr;
464 std::vector<SCH_ITEM*> bulkAddedItems;
465 std::vector<SCH_ITEM*> bulkRemovedItems;
466 std::vector<SCH_ITEM*> itemsChanged;
467
468 for( COMMIT_LINE& ent : m_changes )
469 {
470 int changeType = ent.m_type & CHT_TYPE;
471 int changeFlags = ent.m_type & CHT_FLAGS;
472 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ent.m_item );
473 SCH_ITEM* copy = dynamic_cast<SCH_ITEM*>( ent.m_copy );
474 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
475
476 wxCHECK2( item && screen, continue );
477
478 if( !schematic )
479 schematic = item->Schematic();
480
481 switch( changeType )
482 {
483 case CHT_ADD:
484 if( !( changeFlags & CHT_DONE ) )
485 break;
486
487 if( view )
488 view->Remove( item );
489
490 screen->Remove( item );
491 bulkRemovedItems.push_back( item );
492 break;
493
494 case CHT_REMOVE:
495 item->SetConnectivityDirty();
496
497 if( !( changeFlags & CHT_DONE ) )
498 break;
499
500 if( view )
501 view->Add( item );
502
503 screen->Append( item );
504 bulkAddedItems.push_back( item );
505 break;
506
507 case CHT_MODIFY:
508 {
509 if( view )
510 view->Remove( item );
511
512 bool unselect = !item->IsSelected();
513
514 item->SwapData( copy );
515
516 if( unselect )
517 {
518 item->ClearSelected();
519 item->RunOnChildren( []( SCH_ITEM* aChild ) { aChild->ClearSelected(); } );
520 }
521
522 // Special cases for items which have instance data
523 if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T
524 && item->Type() == SCH_FIELD_T )
525 {
526 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
527 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
528
529 if( field->GetId() == REFERENCE_FIELD )
530 {
531 SCH_SHEET_PATH sheet = schematic->GetSheets().FindSheetForScreen( screen );
532 symbol->SetRef( &sheet, field->GetText() );
533 }
534 }
535
536 // This must be called before any calls that require stable object pointers.
537 screen->Update( item );
538
539 // This hack is to prevent incorrectly parented symbol pins from breaking the
540 // connectivity algorithm.
541 if( item->Type() == SCH_SYMBOL_T )
542 {
543 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
544 symbol->UpdatePins();
545
546 CONNECTION_GRAPH* graph = schematic->ConnectionGraph();
547
548 SCH_SYMBOL* symbolCopy = static_cast<SCH_SYMBOL*>( copy );
549 graph->RemoveItem( symbolCopy );
550
551 for( SCH_PIN* pin : symbolCopy->GetPins() )
552 graph->RemoveItem( pin );
553 }
554
555 item->SetConnectivityDirty();
556
557 if( view )
558 view->Add( item );
559
560 delete copy;
561 break;
562 }
563
564 default:
565 wxASSERT( false );
566 break;
567 }
568 }
569
570 if( schematic )
571 {
572 if( bulkAddedItems.size() > 0 )
573 schematic->OnItemsAdded( bulkAddedItems );
574
575 if( bulkRemovedItems.size() > 0 )
576 schematic->OnItemsRemoved( bulkRemovedItems );
577
578 if( itemsChanged.size() > 0 )
579 schematic->OnItemsChanged( itemsChanged );
580 }
581
582 if( selTool )
583 selTool->RebuildSelection();
584
585 if( frame )
586 {
587 frame->RecalculateConnections( nullptr, NO_CLEANUP );
588 }
589
590 clear();
591}
592
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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearSelected()
Definition: eda_item.h:118
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
bool IsSelected() const
Definition: eda_item.h:106
void SetSelected()
Definition: eda_item.h:115
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:172
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
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:127
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
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:260
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:254
void SetLink(EDA_ITEM *aItem)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:313
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1619
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
Define a library symbol object.
Definition: lib_symbol.h:99
void RunOnChildren(const std::function< void(LIB_ITEM *)> &aFunction)
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:545
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: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: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: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:367
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:448
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:422
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
Definition: sch_commit.cpp:393
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
Definition: sch_commit.cpp:376
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.
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:52
int GetId() const
Definition: sch_field.h:128
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
virtual bool IsConnectable() const
Definition: sch_item.h:389
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:490
virtual void SwapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition: sch_item.cpp:261
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:455
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:150
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:320
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:313
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:383
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:109
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:338
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:790
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:57
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:389
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:378
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_CONNECTIVITY
Definition: sch_commit.h:43
#define SKIP_SET_DIRTY
Definition: sch_commit.h:42
#define SKIP_UNDO
Definition: sch_commit.h:40
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:202
@ SCH_SYMBOL_T
Definition: typeinfo.h:160
@ SCH_FIELD_T
Definition: typeinfo.h:159
@ SCH_SHEET_T
Definition: typeinfo.h:162
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...