85 wxCHECK( aItem, *
this );
104 Stage( member, aChangeType, aScreen, aRecurse );
127 Stage( item, aChangeType, aScreen );
159 view->Update( symbol );
164 view->Update( aChild );
175 frame->PushSymbolToUndoList( aMessage,
copy );
204 bool itemsDeselected =
false;
205 bool selectedModified =
false;
206 bool dirtyConnectivity =
false;
207 bool refreshConnectivity =
false;
208 bool refreshHierarchy =
false;
222 std::vector<SCH_ITEM*> bulkAddedItems;
223 std::vector<SCH_ITEM*> bulkRemovedItems;
224 std::vector<SCH_ITEM*> itemsChanged;
225 std::vector<std::unique_ptr<SCH_ITEM>> cleanupRemovedItems;
226 std::set<SCH_SCREEN*> connectivityScreens;
234 if( !bulkAddedItems.empty() )
237 if( !bulkRemovedItems.empty() )
240 if( !itemsChanged.empty() )
243 if( refreshHierarchy )
246 bulkAddedItems.clear();
247 bulkRemovedItems.clear();
248 itemsChanged.clear();
251 auto updateConnectivityFlag =
256 dirtyConnectivity =
true;
257 connectivityScreens.insert( screen );
270 if( enteredGroup && frame )
290 auto stageRemovedGroups =
294 std::vector<std::pair<EDA_GROUP*, BASE_SCREEN*>> removedItemGroups;
299 int changeType = entry.m_type &
CHT_TYPE;
301 wxCHECK2( schItem,
continue );
304 removedItemGroups.emplace_back( schItem->
GetParentGroup(), entry.m_screen );
307 for(
const auto& [
group, screen] : removedItemGroups )
311 stageRemovedGroups();
312 bool cleanupPending =
true;
313 std::set<SCH_SCREEN*> touchedScreens;
315 for(
size_t index = 0; ; )
319 if( !cleanupPending || !dirtyConnectivity || ( aCommitFlags &
SKIP_CONNECTIVITY ) || !schematic )
322 cleanupPending =
false;
331 : std::set<SCH_SCREEN*>() );
333 stageRemovedGroups();
344 wxCHECK2( schItem,
continue );
345 wxCHECK2( screen,
continue );
347 touchedScreens.insert( screen );
354 refreshConnectivity =
true;
358 selectedModified =
true;
363 [&selectedModified](
SCH_ITEM* aChild )
366 selectedModified =
true;
378 updateConnectivityFlag( schItem, screen );
386 screen->
Append( schItem );
388 if( view && screen == currentScreen )
389 view->
Add( schItem );
392 if( frame && screen == currentScreen )
395 screen->
Update( schItem );
397 bulkAddedItems.push_back( schItem );
400 refreshHierarchy =
true;
407 updateConnectivityFlag( schItem, screen );
422 itemsDeselected =
true;
427 static_cast<SCH_FIELD*
>( schItem )->SetVisible(
false );
432 cleanupRemovedItems.emplace_back( schItem );
435 group->RemoveItem( schItem );
439 screen->
Remove( schItem );
441 if( view && screen == currentScreen )
445 if( frame && screen == currentScreen )
448 screen->
Update( schItem );
451 refreshHierarchy =
true;
453 bulkRemovedItems.push_back( schItem );
461 bool fullSheetUpdate =
true;
472 refreshHierarchy |= hierarchyChanged;
483 updateConnectivityFlag( schItem, screen, fullSheetUpdate );
488 refreshConnectivity =
true;
496 if( origSymbol->
GetPins( ¤tSheet ).size() != modSymbol->
GetPins( ¤tSheet ).size() )
509 if( *itemCopy == *schItem )
524 if( frame && screen == currentScreen )
527 screen->
Update( schItem );
529 itemsChanged.push_back( schItem );
564 screen->SetContentModified();
570 cleanupRemovedItems.clear();
572 if( ( dirtyConnectivity || refreshConnectivity ) && !( aCommitFlags &
SKIP_CONNECTIVITY ) )
574 wxLogTrace( wxS(
"CONN_PROFILE" ), wxS(
"SCH_COMMIT::pushSchEdit() connectivity refresh, cleanup=%d." ),
575 static_cast<int>( connectivityCleanUp ) );
588 if( refreshHierarchy && frame )
593 if( itemsDeselected )
596 if( selectedModified )
616 if( frame && frame->GetCanvas() )
617 frame->GetCanvas()->Refresh();
632 return frame->GetCurSymbol();
637 if( parent && parent->
IsType( { SCH_SYMBOL_T, SCH_TABLE_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
653 std::vector<KIID> selected;
658 if( item.IsSelected() )
659 selected.push_back( item.m_Uuid );
675 return aItem->
Clone();
725 std::vector<SCH_ITEM*> bulkAddedItems;
726 std::vector<SCH_ITEM*> bulkRemovedItems;
727 std::vector<SCH_ITEM*> itemsChanged;
729 for(
int ii = aCheckpoint; ii < (int)
m_entries.size(); ++ii )
738 wxCHECK2( item && screen,
continue );
753 bulkRemovedItems.push_back( item );
768 bulkAddedItems.push_back( item );
773 wxCHECK2(
copy,
break );
843 itemsChanged.push_back( item );
858 if( bulkAddedItems.size() > 0 )
861 if( bulkRemovedItems.size() > 0 )
864 if( itemsChanged.size() > 0 )
885 if( entry.m_item && entry.m_item->IsSCH_ITEM() && entry.m_item->m_Uuid == aID )
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Handles how to draw a screen (a board, a schematic ...)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT_LINE * findEntry(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Search for an entry describing change for a particular item.
std::vector< COMMIT_LINE > m_entries
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been removed.
void clear()
Should be called in Push() & Revert() methods.
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.
Calculate the connectivity of a schematic and generate 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).
void AddItem(EDA_ITEM *aItem)
Add item to group.
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
static const TOOL_EVENT SelectedItemsModified
Selected item had a property changed (except movement)
static const TOOL_EVENT UnselectedEvent
void SetLink(EDA_ITEM *aItem)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Define a library symbol object.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
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.
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.
void CleanUpConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, const std::set< SCH_SCREEN * > &aLocalScreens={})
CONNECTION_GRAPH * ConnectionGraph() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER *aToolManager, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PICKED_ITEMS_LIST *aLastChangeList=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
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.
EDA_ITEM * undoLevelItem(EDA_ITEM *aItem) const override
void Revert() override
Revert the commit by restoring the modified items state.
EDA_ITEM * ResolveItem(KIID &aID) override
Search for an item in this commit that matches the provided KIID.
void RemovedForCleanup(SCH_ITEM *aItem, SCH_SCREEN *aScreen)
Retain the pre-edit state of an item already removed from its screen by cleanup.
SCH_COMMIT(TOOL_MANAGER *aToolMgr)
void pushLibEdit(const wxString &aMessage, int aCommitFlags)
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
void pushSchEdit(const wxString &aMessage, int aCommitFlags)
void RevertToCheckpoint(int aCheckpoint) override
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
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.
bool RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
SCH_SHEET_PATH & GetCurrentSheet() const
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.
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
SCH_SCREEN * GetParentScreen() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
bool IsConnectivityDirty() const
virtual bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const
Check if aItem has connectivity changes against this object.
bool IsGroupableType() const
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
static bool IsConnectivitySource(const SCH_ITEM *aItem)
Markers, bitmaps, plain shapes, graphic lines and groups carry nothing captured by connectivity.
void BumpConnectivityRevision(KICAD_T aChangedType=TYPE_NOT_INIT)
Increment the connectivity revisions of this screen.
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)
Refresh a changed item in the tree and invalidate connectivity.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
bool PruneUnusedLibSymbol(const wxString &aName)
Remove the library symbol cached under aName if no symbol on this screen still references that name.
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.
bool HasPinIdentityChanges(const SCH_SHEET &aOther) const
bool HasHierarchyChanges(const SCH_SHEET &aOther) const
wxString GetSchSymbolLibraryName() const
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.
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.
CHANGE_TYPE
Types of changes.
@ CHT_DONE
Flag to indicate the change is already applied.
#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 STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
@ FRAME_SCH_SYMBOL_EDITOR
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
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.
#define SKIP_CONNECTIVITY
#define DELETE_REMOVED_ITEMS
Class to handle a set of SCH_ITEMs.
EDA_ITEM * m_copy
Optional copy of the item.
CHANGE_TYPE m_type
Modification type.
EDA_ITEM * m_item
Main item that is added/deleted/modified.
@ REFERENCE
Field Reference of part, i.e. "IC21".