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_SCREEN* currentScreen = frame ? frame->GetScreen() : nullptr;
164 SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
165 SCH_GROUP* enteredGroup = selTool ? selTool->GetEnteredGroup() : nullptr;
166 bool itemsDeselected = false;
167 bool selectedModified = false;
168 bool dirtyConnectivity = false;
169 bool refreshHierarchy = false;
170 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
171
172 if( Empty() )
173 return;
174
175 undoList.SetDescription( aMessage );
176
177 SCHEMATIC* schematic = nullptr;
178 std::vector<SCH_ITEM*> bulkAddedItems;
179 std::vector<SCH_ITEM*> bulkRemovedItems;
180 std::vector<SCH_ITEM*> itemsChanged;
181
182 auto updateConnectivityFlag =
183 [&]( SCH_ITEM* schItem )
184 {
185 if( schItem->IsConnectable() || ( schItem->Type() == SCH_RULE_AREA_T ) )
186 {
187 dirtyConnectivity = true;
188
189 // Do a local clean up if there are any connectable objects in the commit.
190 if( connectivityCleanUp == NO_CLEANUP )
191 connectivityCleanUp = LOCAL_CLEANUP;
192
193 // Do a full rebuild of the connectivity if there is a sheet in the commit.
194 if( schItem->Type() == SCH_SHEET_T )
195 connectivityCleanUp = GLOBAL_CLEANUP;
196 }
197 };
198
199 // We don't know that anything will be added to the entered group, but it does no harm to
200 // add it to the commit anyway.
201 if( enteredGroup )
202 Modify( enteredGroup, frame->GetScreen() );
203
204 // Handle wires with Hop Over shapes:
205 for( COMMIT_LINE& entry : m_entries )
206 {
207 SCH_ITEM* schCopyItem = dynamic_cast<SCH_ITEM*>( entry.m_copy );
208 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( entry.m_item );
209
210 if( schCopyItem && schCopyItem->Type() == SCH_LINE_T )
211 frame->UpdateHopOveredWires( schCopyItem );
212
213 if( schItem && schItem->Type() == SCH_LINE_T )
214 frame->UpdateHopOveredWires( schItem );
215 }
216
217
218 for( COMMIT_LINE& entry : m_entries )
219 {
220 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( entry.m_item );
221 int changeType = entry.m_type & CHT_TYPE;
222
223 wxCHECK2( schItem, continue );
224
225 if( changeType == CHT_REMOVE && schItem->GetParentGroup() )
226 Modify( schItem->GetParentGroup()->AsEdaItem(), entry.m_screen );
227 }
228
229 for( COMMIT_LINE& entry : m_entries )
230 {
231 int changeType = entry.m_type & CHT_TYPE;
232 int changeFlags = entry.m_type & CHT_FLAGS;
233 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( entry.m_item );
234 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( entry.m_screen );
235
236 wxCHECK2( schItem, continue );
237 wxCHECK2( screen, continue );
238
239 if( !schematic )
240 schematic = schItem->Schematic();
241
242 if( schItem->IsSelected() )
243 {
244 selectedModified = true;
245 }
246 else
247 {
248 schItem->RunOnChildren(
249 [&selectedModified]( SCH_ITEM* aChild )
250 {
251 if( aChild->IsSelected() )
252 selectedModified = true;
253 },
255 }
256
257 switch( changeType )
258 {
259 case CHT_ADD:
260 {
261 if( enteredGroup && schItem->IsGroupableType() && !schItem->GetParentGroup() )
262 selTool->GetEnteredGroup()->AddItem( schItem );
263
264 updateConnectivityFlag( schItem );
265
266 if( !( aCommitFlags & SKIP_UNDO ) )
267 undoList.PushItem( ITEM_PICKER( screen, schItem, UNDO_REDO::NEWITEM ) );
268
269 if( !( changeFlags & CHT_DONE ) )
270 {
271 if( !screen->CheckIfOnDrawList( schItem ) ) // don't want a loop!
272 screen->Append( schItem );
273
274 if( view && screen == currentScreen )
275 view->Add( schItem );
276 }
277
278 if( frame && screen == currentScreen )
279 frame->UpdateItem( schItem, true, true );
280 else if( screen )
281 screen->Update( schItem );
282
283 bulkAddedItems.push_back( schItem );
284
285 if( schItem->Type() == SCH_SHEET_T )
286 refreshHierarchy = true;
287
288 break;
289 }
290
291 case CHT_REMOVE:
292 {
293 updateConnectivityFlag( schItem );
294
295 if( !( aCommitFlags & SKIP_UNDO ) )
296 {
297 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::DELETED );
298 itemWrapper.SetLink( entry.m_copy );
299 entry.m_copy = nullptr; // We've transferred ownership to the undo list
300 undoList.PushItem( itemWrapper );
301 }
302
303 if( schItem->IsSelected() )
304 {
305 if( selTool )
306 selTool->RemoveItemFromSel( schItem, true /* quiet mode */ );
307
308 itemsDeselected = true;
309 }
310
311 if( schItem->Type() == SCH_FIELD_T )
312 {
313 static_cast<SCH_FIELD*>( schItem )->SetVisible( false );
314 break;
315 }
316
317 if( EDA_GROUP* group = schItem->GetParentGroup() )
318 group->RemoveItem( schItem );
319
320 if( !( changeFlags & CHT_DONE ) )
321 {
322 screen->Remove( schItem );
323
324 if( view && screen == currentScreen )
325 view->Remove( schItem );
326 }
327
328 if( frame && screen == currentScreen )
329 frame->UpdateItem( schItem, true, true );
330 else if( screen )
331 screen->Update( schItem );
332
333 if( schItem->Type() == SCH_SHEET_T )
334 refreshHierarchy = true;
335
336 bulkRemovedItems.push_back( schItem );
337 break;
338 }
339
340 case CHT_MODIFY:
341 {
342 const SCH_ITEM* itemCopy = static_cast<const SCH_ITEM*>( entry.m_copy );
343 SCH_SHEET_PATH currentSheet;
344
345 if( frame )
346 currentSheet = frame->GetCurrentSheet();
347
348 if( itemCopy->HasConnectivityChanges( schItem, &currentSheet )
349 || ( itemCopy->Type() == SCH_RULE_AREA_T ) )
350 {
351 updateConnectivityFlag( schItem );
352 }
353
354 if( !( aCommitFlags & SKIP_UNDO ) )
355 {
356#if 0
357 // While this keeps us from marking documents modified when someone OK's a dialog with
358 // no changes, it depends on our various SCH_ITEM::operator=='s being bullet-proof. They
359 // currently aren't.
360 if( *itemCopy == *schItem )
361 {
362 // No actual changes made; short-circuit undo
363 delete entry.m_copy;
364 entry.m_copy = nullptr;
365 break;
366 }
367#endif
368
369 ITEM_PICKER itemWrapper( screen, schItem, UNDO_REDO::CHANGED );
370 itemWrapper.SetLink( entry.m_copy );
371 entry.m_copy = nullptr; // We've transferred ownership to the undo list
372 undoList.PushItem( itemWrapper );
373 }
374
375 if( schItem->Type() == SCH_SHEET_T )
376 {
377 const SCH_SHEET* modifiedSheet = static_cast<const SCH_SHEET*>( schItem );
378 const SCH_SHEET* originalSheet = static_cast<const SCH_SHEET*>( itemCopy );
379 wxCHECK2( modifiedSheet && originalSheet, continue );
380
381 if( originalSheet->HasPageNumberChanges( *modifiedSheet ) )
382 refreshHierarchy = true;
383 }
384
385 if( frame && screen == currentScreen )
386 frame->UpdateItem( schItem, false, true );
387 else if( screen )
388 screen->Update( schItem );
389
390 itemsChanged.push_back( schItem );
391 break;
392 }
393
394 default:
395 wxASSERT( false );
396 break;
397 }
398
399 // Delete any copies we still have ownership of
400 delete entry.m_copy;
401 entry.m_copy = nullptr;
402
403 // Clear all flags but SELECTED and others used to move and rotate commands,
404 // after edition (selected items must keep their selection flag).
405 const int selected_mask = ( SELECTED | STARTPOINT | ENDPOINT );
406 schItem->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
407
408 if( schItem->Type() == SCH_SHEET_T || schItem->Type() == SCH_SYMBOL_T )
409 {
410 schItem->RunOnChildren(
411 [&]( SCH_ITEM* child )
412 {
413 child->ClearFlags( EDA_ITEM_ALL_FLAGS - selected_mask );
414 },
416 }
417 }
418
419 if( schematic )
420 {
421 if( bulkAddedItems.size() > 0 )
422 schematic->OnItemsAdded( bulkAddedItems );
423
424 if( bulkRemovedItems.size() > 0 )
425 schematic->OnItemsRemoved( bulkRemovedItems );
426
427 if( itemsChanged.size() > 0 )
428 schematic->OnItemsChanged( itemsChanged );
429
430 if( refreshHierarchy )
431 {
432 schematic->RefreshHierarchy();
433
434 if( frame )
436 }
437 }
438
439 if( !( aCommitFlags & SKIP_UNDO ) )
440 {
441 if( frame )
442 {
443 if( undoList.GetCount() > 0 )
444 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED, false );
445
446 if( dirtyConnectivity )
447 {
448 wxLogTrace( wxS( "CONN_PROFILE" ),
449 wxS( "SCH_COMMIT::pushSchEdit() %s clean up connectivity rebuild." ),
450 connectivityCleanUp == LOCAL_CLEANUP ? wxS( "local" ) : wxS( "global" ) );
451 frame->RecalculateConnections( this, connectivityCleanUp );
452 }
453 }
454 }
455
456 m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } );
457
458 if( itemsDeselected )
460
461 if( selectedModified )
463}
464
465
466void SCH_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
467{
468 if( Empty() )
469 return;
470
471 if( m_isLibEditor )
472 pushLibEdit( aMessage, aCommitFlags );
473 else
474 pushSchEdit( aMessage, aCommitFlags );
475
476 if( SCH_BASE_FRAME* frame = static_cast<SCH_BASE_FRAME*>( m_toolMgr->GetToolHolder() ) )
477 {
478 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
479 frame->OnModify();
480
481 if( frame && frame->GetCanvas() )
482 frame->GetCanvas()->Refresh();
483 }
484
485 clear();
486}
487
488
490{
491 EDA_ITEM* parent = aItem->GetParent();
492
493 if( m_isLibEditor )
494 return static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() )->GetCurSymbol();
495
496 if( parent && parent->IsType( { SCH_SYMBOL_T, SCH_TABLE_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
497 return parent;
498
499 return aItem;
500}
501
502
504{
505 if( m_isLibEditor )
506 {
507 SYMBOL_EDIT_FRAME* frame = static_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
508 LIB_SYMBOL* symbol = frame->GetCurSymbol();
509 std::vector<KIID> selected;
510
511 // Cloning will clear the selected flags, but we want to keep them.
512 for( const SCH_ITEM& item : symbol->GetDrawItems() )
513 {
514 if( item.IsSelected() )
515 selected.push_back( item.m_Uuid );
516 }
517
518 symbol = new LIB_SYMBOL( *symbol );
519
520 // Restore selected flags.
521 for( SCH_ITEM& item : symbol->GetDrawItems() )
522 {
523 if( alg::contains( selected, item.m_Uuid ) )
524 item.SetSelected();
525 }
526
527 return symbol;
528 }
529
530 return aItem->Clone();
531}
532
533
535{
536 if( Empty() )
537 return;
538
539 // Symbol editor just saves copies of the whole symbol, so grab the first and discard the rest
540 SYMBOL_EDIT_FRAME* frame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
541 LIB_SYMBOL* copy = dynamic_cast<LIB_SYMBOL*>( m_entries.front().m_copy );
542 SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
543
544 if( frame && copy )
545 {
546 frame->SetCurSymbol( copy, false );
547 m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
548 }
549
550 if( selTool )
551 selTool->RebuildSelection();
552
553 clear();
554}
555
556
558{
559 KIGFX::VIEW* view = m_toolMgr->GetView();
560 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() );
561 SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
562 SCH_SHEET_LIST sheets;
563
564 if( m_entries.empty() )
565 return;
566
567 if( m_isLibEditor )
568 {
570 return;
571 }
572
573 SCHEMATIC* schematic = nullptr;
574 std::vector<SCH_ITEM*> bulkAddedItems;
575 std::vector<SCH_ITEM*> bulkRemovedItems;
576 std::vector<SCH_ITEM*> itemsChanged;
577
578 for( COMMIT_LINE& ent : m_entries )
579 {
580 int changeType = ent.m_type & CHT_TYPE;
581 int changeFlags = ent.m_type & CHT_FLAGS;
582 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ent.m_item );
583 SCH_ITEM* copy = dynamic_cast<SCH_ITEM*>( ent.m_copy );
584 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( ent.m_screen );
585
586 wxCHECK2( item && screen, continue );
587
588 if( !schematic )
589 schematic = item->Schematic();
590
591 switch( changeType )
592 {
593 case CHT_ADD:
594 if( !( changeFlags & CHT_DONE ) )
595 break;
596
597 if( view )
598 view->Remove( item );
599
600 screen->Remove( item );
601 bulkRemovedItems.push_back( item );
602 break;
603
604 case CHT_REMOVE:
605 item->SetConnectivityDirty();
606
607 if( !( changeFlags & CHT_DONE ) )
608 break;
609
610 if( view )
611 view->Add( item );
612
613 screen->Append( item );
614 bulkAddedItems.push_back( item );
615 break;
616
617 case CHT_MODIFY:
618 {
619 wxCHECK2( copy, break );
620
621 if( view )
622 view->Remove( item );
623
624 bool unselect = !item->IsSelected();
625
626 item->SwapItemData( copy );
627
628 if( unselect )
629 {
630 item->ClearSelected();
631 item->RunOnChildren( []( SCH_ITEM* aChild )
632 {
633 aChild->ClearSelected();
634 },
636 }
637
638 // Special cases for items which have instance data
639 if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T && item->Type() == SCH_FIELD_T )
640 {
641 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
642 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
643
644 if( field->GetId() == FIELD_T::REFERENCE )
645 {
646 // Lazy eval of sheet list; this is expensive even when unsorted
647 if( sheets.empty() )
648 sheets = schematic->Hierarchy();
649
650 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
651 symbol->SetRef( &sheet, field->GetText() );
652 }
653 }
654
655 // This must be called before any calls that require stable object pointers.
656 screen->Update( item );
657
658 // This hack is to prevent incorrectly parented symbol pins from breaking the
659 // connectivity algorithm.
660 if( item->Type() == SCH_SYMBOL_T )
661 {
662 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
663 symbol->UpdatePins();
664
665 CONNECTION_GRAPH* graph = schematic->ConnectionGraph();
666
667 SCH_SYMBOL* symbolCopy = static_cast<SCH_SYMBOL*>( copy );
668 graph->RemoveItem( symbolCopy );
669
670 for( SCH_PIN* pin : symbolCopy->GetPins() )
671 graph->RemoveItem( pin );
672 }
673
674 item->SetConnectivityDirty();
675
676 if( view )
677 view->Add( item );
678
679 delete copy;
680 break;
681 }
682
683 default:
684 wxASSERT( false );
685 break;
686 }
687 }
688
689 if( schematic )
690 {
691 if( bulkAddedItems.size() > 0 )
692 schematic->OnItemsAdded( bulkAddedItems );
693
694 if( bulkRemovedItems.size() > 0 )
695 schematic->OnItemsRemoved( bulkRemovedItems );
696
697 if( itemsChanged.size() > 0 )
698 schematic->OnItemsChanged( itemsChanged );
699 }
700
701 if( selTool )
702 selTool->RebuildSelection();
703
704 if( frame )
705 frame->RecalculateConnections( nullptr, NO_CLEANUP );
706
707 clear();
708}
709
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:100
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:118
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
void ClearSelected()
Definition eda_item.h:144
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:151
bool IsSelected() const
Definition eda_item.h:129
void SetSelected()
Definition eda_item.h:141
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:199
EDA_ITEM * GetParent() const
Definition eda_item.h:114
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition eda_item.cpp:128
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition eda_item.h:153
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:352
static const TOOL_EVENT UnselectedEvent
Definition actions.h:346
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:67
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition view.cpp:301
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:405
Define a library symbol object.
Definition lib_symbol.h:83
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:712
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)
unsigned GetCount() const
Holds all the data relating to one schematic.
Definition schematic.h:89
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:200
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)
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:123
FIELD_T GetId() const
Definition sch_field.h:127
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:168
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:634
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:269
void SetConnectivityDirty(bool aDirty=true)
Definition sch_item.h:593
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:610
bool IsGroupableType() const
Definition sch_item.cpp:117
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition sch_item.cpp:633
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:48
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:76
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
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.
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:52
@ RECURSE
Definition eda_item.h:53
@ NO_RECURSE
Definition eda_item.h:54
#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:75
@ LOCAL_CLEANUP
Definition schematic.h:77
@ NO_CLEANUP
Definition schematic.h:76
@ GLOBAL_CLEANUP
Definition schematic.h:78
@ REFERENCE
Field Reference of part, i.e. "IC21".
KIBIS_PIN * pin
@ 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:164
@ SCH_SYMBOL_T
Definition typeinfo.h:173
@ SCH_FIELD_T
Definition typeinfo.h:151
@ SCH_SHEET_T
Definition typeinfo.h:176
@ SCH_RULE_AREA_T
Definition typeinfo.h:171