53 snapshot.
scale = view->GetScale();
54 snapshot.
center = view->GetCenter();
55 snapshot.
valid =
true;
64 if( !aSnapshot.
valid )
69 view->SetScale( aSnapshot.
scale );
70 view->SetCenter( aSnapshot.
center );
77 std::vector<KIID> kiids;
88 kiids.push_back( item->m_Uuid );
104 if( !selTool || !screen )
109 for(
const KIID& kiid : aKiids )
111 if( item->m_Uuid == kiid )
190 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"activateSymbolTab SelectLibId '%s'" ),
191 m_symbol->GetLibId().Format().wx_str() );
236 const bool isTab = aEvent.GetKeyCode() == WXK_TAB;
237 const bool ctrlOnly = aEvent.ControlDown() && !aEvent.AltDown() && !aEvent.MetaDown();
241 const int keyCode = aEvent.GetKeyCode();
242 const bool isCtrlW = ctrlOnly && !aEvent.ShiftDown()
243 && ( keyCode ==
'W' || keyCode == (
'W' -
'@' ) );
271 for(
unsigned ii = 0; ii < cmd->
GetCount(); ++ii )
280 wxCHECK2_MSG( item != aLiveSymbol,
continue,
281 wxT(
"Live working symbol flagged UR_TRANSIENT in undo/redo list" ) );
307 screen->SetContentModified(
false );
315 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
317 if( ctx->GetLibrary() != aLibrary )
322 else if(
SCH_SCREEN* screen = ctx->GetScreen() )
323 screen->SetContentModified(
false );
335 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
337 if( ctx->GetTabKey() == aKey )
357 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
359 return aOwned.get() == ctx;
369 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
371 if( aIdx < 0 || aIdx >=
static_cast<int>( entries.size() ) )
379 int aUnit,
int aBodyStyle,
bool aAsPreview,
383 const int unit = aUnit > 0 ? aUnit : 1;
384 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
389 *aWasCreated =
false;
398 m_tabContexts.push_back( std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>( aLib, aName, buffer ) );
414 wxString replacedKey;
418 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
419 const int previewIdx =
m_tabsPanel->Model().PreviewIndex();
421 if( previewIdx >= 0 && previewIdx <
static_cast<int>( entries.size() ) && entries[previewIdx].key != key )
422 replacedKey = entries[previewIdx].key;
427 if( !replacedKey.empty() )
441 const KIID& aSchematicSymbolUUID,
const wxString& aReference,
442 int aUnit,
int aBodyStyle )
445 const int unit = aUnit > 0 ? aUnit : 1;
446 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
454 existing->SetUnit( unit );
455 existing->SetBodyStyle( bodyStyle );
458 m_tabsPanel->AddTab( key, existing->GetReference() + wxS(
" " ) +
_(
"[from schematic]" ),
false );
465 m_tabContexts.push_back( std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>( aSymbol, aScreen, aSchematicSymbolUUID,
473 m_tabsPanel->AddTab( key, aReference + wxS(
" " ) +
_(
"[from schematic]" ),
false );
490 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
493 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
494 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
544 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
546 return aOwned.get() == ctx;
555 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
557 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
568 std::vector<SYMBOL_EDITOR_TAB_CONTEXT*> dirty;
570 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
573 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
574 dirty.push_back( ctx.get() );
583 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ), ctx->GetDisplayName() );
585 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
586 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
590 if( answer == wxID_YES )
602 else if( answer != wxID_NO )
639 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
680 ctx->SetName( newName );
688 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings enter" ) );
695 wxString activeKey =
m_settings->m_ActiveTabKey;
702 wxLogTrace(
"KICAD_TABS",
"Dropping unresolved persisted symbol tab '%s:%s'.", tab.
lib, tab.
name );
711 wxLogTrace(
"KICAD_TABS",
"Dropping persisted symbol tab '%s:%s'; buffer unavailable.", tab.
lib, tab.
name );
726 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings exit (activeIdx=%d)" ), activeIdx );
738 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
741 if( ctx->IsTransient() )
745 tab.
lib = ctx->GetLibrary();
746 tab.
name = ctx->GetName();
747 tab.
unit = ctx->GetUnit();
752 const int idx =
m_tabsPanel->FindTab( ctx->GetTabKey() );
753 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
755 if( idx >= 0 && idx <
static_cast<int>( entries.size() ) )
756 tab.
preview = entries[idx].preview;
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION selectionClear
Clear the current selection.
UNDO_REDO_CONTAINER m_undoList
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
UNDO_REDO_CONTAINER m_redoList
PROPERTIES_PANEL * m_propertiesPanel
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.
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
GUI-free preview/dirty/close state machine.
void MarkModified(const wxString &aKey, bool aModified)
Update the modified flag.
VIEW_SNAPSHOT & ViewSnapshot()
std::vector< KIID > & SavedSelection()
Selection saved as resolved KIIDs, restored after the view is rebuilt.
UNDO_REDO_CONTAINER & RedoList()
UNDO_REDO_CONTAINER & UndoList()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
A holder to handle information on schematic or board items.
unsigned GetCount() const
void ClearItemsList()
Delete only the list of pickers NOT the picked data itself.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySymbol(LIB_SYMBOL *aSymbol)
Base class for any item which can be embedded within the SCHEMATIC container class,...
bool m_ShowGraphicsDisabled
EE_RTREE & Items()
Get the full RTree, usually for iterating.
One open symbol tab owning a working LIB_SYMBOL and screen lent to the frame while active.
void ReleaseToFrame()
Hand the working symbol/screen to the frame as the tab becomes active.
wxString GetDisplayName() const override
Short label shown on the tab.
LIB_SYMBOL * GetSymbol() const
Observe the working symbol/screen.
const wxString & GetReference() const
static wxString MakeTabKey(const wxString &aLib, const wxString &aName)
De-duplication key for a library:symbol pair.
static wxString MakeInstanceTabKey(const KIID &aSchematicSymbolUUID)
De-duplication key for a placed schematic instance, in a namespace disjoint from library keys.
SCH_SCREEN * GetScreen() const
wxString GetTabKey() const override
Stable identity for persistence and de-duplication.
const KIID & GetSchematicSymbolUUID() const
void SetBodyStyle(int aBodyStyle)
bool IsModified() const override
True when the working screen carries unsaved edits.
void AdoptWorkingObjects(LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
Take ownership back on detach, capturing whatever the frame's symbol now points at.
bool IsFromSchematic() const
std::vector< std::unique_ptr< SYMBOL_EDITOR_TAB_CONTEXT > > m_tabContexts
bool m_isSymbolFromSchematic
True while a schematic-edit auto-hide of the library tree still needs restoring on save.
void restoreSymbolTabsFromSettings()
Recreate tabs from the persisted open-tab list once the libraries have loaded.
bool promptToSaveInactiveInstanceTabs()
Prompt to save each dirty instance (symbol from schematic) tab that is not the active one,...
bool hasDirtyInactiveInstanceTabs() const
True if any non-active instance (schematic) tab has unsaved edits.
bool IsLibraryTreeShown() const override
void RenameSymbolTab(const LIB_ID &aOldId, const LIB_ID &aNewId)
Update the open tab for aOldId, if any, to the renamed symbol aNewId so its label and key track the r...
static void freeTransientUndoCommands(UNDO_REDO_CONTAINER &aList, const LIB_SYMBOL *aLiveSymbol)
Free every command in the list and the UR_TRANSIENT-flagged copies it owns, which the shared deleters...
EDITOR_TABS_PANEL * m_tabsPanel
SYMBOL_EDITOR_TAB_CONTEXT * findOrCreateSymbolInstanceTab(LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen, const KIID &aSchematicSymbolUUID, const wxString &aReference, int aUnit, int aBodyStyle)
Find or create the instance tab for a placed schematic symbol and make it active.
void restoreSymbolSelectionKiids(const std::vector< KIID > &aKiids)
Reselect the items named by aKiids after a reload rebuilt the view.
static void clearTabModifiedState(SYMBOL_EDITOR_TAB_CONTEXT &aContext, EDITOR_TABS_MODEL &aModel)
Clear a tab's dirty state on both the context (read on repaint) and the strip model (read on close),...
void RebuildSymbolUnitAndBodyStyleLists()
void OnTabCharHook(wxKeyEvent &aEvent)
Cycle symbol tabs from the char hook, since GTK cannot register WXK_TAB as an accelerator.
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
SYMBOL_EDITOR_SETTINGS * m_settings
void dropSymbolTabContext(const wxString &aKey)
Drop the inactive context for aKey from m_tabContexts, freeing its undo/redo.
bool IsSymbolFromLegacyLibrary() const
bool IsSymbolFromSchematic() const
void SetScreen(BASE_SCREEN *aScreen) override
SYMBOL_EDITOR_TAB_CONTEXT * m_activeTab
SYMBOL_EDITOR_SETTINGS * GetSettings() const
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
KIID m_schematicSymbolUUID
RefDes of the symbol (only valid if symbol was loaded from schematic)
EDITOR_TAB_CONTEXT::VIEW_SNAPSHOT captureSymbolViewSnapshot() const
Capture the current view zoom/center for the active tab's snapshot.
void restoreSymbolViewSnapshot(const EDITOR_TAB_CONTEXT::VIEW_SNAPSHOT &aSnapshot)
Restore a previously captured view zoom/center.
bool m_silentSymbolTabClose
SYMBOL_EDITOR_TAB_CONTEXT * findOrCreateSymbolTab(const wxString &aLib, const wxString &aName, int aUnit, int aBodyStyle, bool aAsPreview, bool *aWasCreated=nullptr)
Open aName from aLib in a tab, creating it when absent, and return the activated context.
SYMBOL_EDITOR_TAB_CONTEXT * symbolTabContextForKey(const wxString &aKey) const
Resolve the tab context for a tab key, or nullptr.
void storeSymbolTabsToSettings()
Write the current tab set into the editor settings for the next session.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
LIB_TREE * GetLibTree() const override
bool promptAndCloseSymbolTab(int aIdx)
Prompt for unsaved changes on the tab and drop its context.
SYMBOL_TREE_PANE * m_treePane
std::vector< KIID > captureSymbolSelectionKiids() const
Capture the KIIDs of the current selection for the active tab's snapshot.
void closeSymbolTab(const LIB_ID &aLibId)
Close the open tab for aLibId, if any, without prompting and leaving the other tabs open.
bool saveCurrentSymbol()
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
void clearSymbolTabsModifiedForLibrary(const wxString &aLibrary)
Clear the unsaved-edits flag on every tab in a saved library so its dirty indicator clears.
SYMBOL_EDITOR_TAB_CONTEXT * symbolTabContextForIndex(int aIdx) const
Resolve the tab context for a panel tab index, or nullptr.
static void clearSymbolTabUndoRedo(SYMBOL_EDITOR_TAB_CONTEXT &aContext)
Free a detached context's undo/redo, which the frame's own teardown path never reaches.
void detachActiveSymbolTab()
Snapshot the active tab's view and selection into its context without deleting the document.
void activateSymbolTab(SYMBOL_EDITOR_TAB_CONTEXT *aContext)
Make aContext the active tab, borrowing its working symbol, undo/redo, view and selection,...
void closeAllSymbolTabsSilently()
Close every tab without prompting and return the frame to the empty state.
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
View snapshot captured on detach, restored on activate.
One persisted open editor tab, restored on the next session.