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;
89 kiids.push_back( item->m_Uuid );
106 if( !selTool || !screen )
111 for(
const KIID& kiid : aKiids )
113 if( item->m_Uuid == kiid )
192 wxLogTrace( wxT(
"KICAD_TABS_DBG" ),
193 wxT(
"activateSymbolTab SelectLibId '%s'" ),
194 m_symbol->GetLibId().Format().wx_str() );
240 const bool isTab = aEvent.GetKeyCode() == WXK_TAB;
241 const bool ctrlOnly = aEvent.ControlDown() && !aEvent.AltDown() && !aEvent.MetaDown();
245 const int keyCode = aEvent.GetKeyCode();
246 const bool isCtrlW = ctrlOnly && !aEvent.ShiftDown()
247 && ( keyCode ==
'W' || keyCode == (
'W' -
'@' ) );
275 for(
unsigned ii = 0; ii < cmd->
GetCount(); ++ii )
284 wxCHECK2_MSG( item != aLiveSymbol,
continue,
285 wxT(
"Live working symbol flagged UR_TRANSIENT in undo/redo list" ) );
311 screen->SetContentModified(
false );
319 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
321 if( ctx->GetLibrary() != aLibrary )
326 else if(
SCH_SCREEN* screen = ctx->GetScreen() )
327 screen->SetContentModified(
false );
339 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
341 if( ctx->GetTabKey() == aKey )
361 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
363 return aOwned.get() == ctx;
373 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
375 if( aIdx < 0 || aIdx >=
static_cast<int>( entries.size() ) )
383 const wxString& aName,
384 int aUnit,
int aBodyStyle,
389 const int unit = aUnit > 0 ? aUnit : 1;
390 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
395 *aWasCreated =
false;
404 m_tabContexts.push_back( std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>( aLib, aName, buffer ) );
420 wxString replacedKey;
424 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
425 const int previewIdx =
m_tabsPanel->Model().PreviewIndex();
427 if( previewIdx >= 0 && previewIdx <
static_cast<int>( entries.size() ) && entries[previewIdx].key != key )
428 replacedKey = entries[previewIdx].key;
433 if( !replacedKey.empty() )
447 const KIID& aSchematicSymbolUUID,
448 const wxString& aReference,
int aUnit,
452 const int unit = aUnit > 0 ? aUnit : 1;
453 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
461 existing->SetUnit( unit );
462 existing->SetBodyStyle( bodyStyle );
465 m_tabsPanel->AddTab( key, existing->GetReference() + wxS(
" " ) +
_(
"[from schematic]" ),
false );
472 m_tabContexts.push_back( std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>( aSymbol, aScreen, aSchematicSymbolUUID,
480 m_tabsPanel->AddTab( key, aReference + wxS(
" " ) +
_(
"[from schematic]" ),
false );
497 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
500 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
501 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
551 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
553 return aOwned.get() == ctx;
562 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
564 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
575 std::vector<SYMBOL_EDITOR_TAB_CONTEXT*> dirty;
577 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
580 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
581 dirty.push_back( ctx.get() );
590 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
591 ctx->GetDisplayName() );
593 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
594 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
598 if( answer == wxID_YES )
610 else if( answer != wxID_NO )
647 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
688 ctx->SetName( newName );
696 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings enter" ) );
703 wxString activeKey =
m_settings->m_ActiveTabKey;
711 wxLogTrace(
"KICAD_TABS",
"Dropping unresolved persisted symbol tab '%s:%s'.",
721 wxLogTrace(
"KICAD_TABS",
"Dropping persisted symbol tab '%s:%s'; buffer unavailable.",
737 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings exit (activeIdx=%d)" ),
750 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
753 if( ctx->IsTransient() )
757 tab.
lib = ctx->GetLibrary();
758 tab.
name = ctx->GetName();
759 tab.
unit = ctx->GetUnit();
764 const int idx =
m_tabsPanel->FindTab( ctx->GetTabKey() );
765 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
767 if( idx >= 0 && idx <
static_cast<int>( entries.size() ) )
768 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 (schematic) tab that is not the active one, since the active tab's...
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
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
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.