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