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 )
194 wxLogTrace( wxT(
"KICAD_TABS_DBG" ),
195 wxT(
"activateSymbolTab SelectLibId '%s'" ),
196 m_symbol->GetLibId().Format().wx_str() );
244 const bool isTab = aEvent.GetKeyCode() == WXK_TAB;
245 const bool ctrlOnly = aEvent.ControlDown() && !aEvent.AltDown() && !aEvent.MetaDown();
249 const int keyCode = aEvent.GetKeyCode();
250 const bool isCtrlW = ctrlOnly && !aEvent.ShiftDown()
251 && ( keyCode ==
'W' || keyCode == (
'W' -
'@' ) );
279 for(
unsigned ii = 0; ii < cmd->
GetCount(); ++ii )
288 wxCHECK2_MSG( item != aLiveSymbol,
continue,
289 wxT(
"Live working symbol flagged UR_TRANSIENT in undo/redo list" ) );
315 screen->SetContentModified(
false );
323 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
325 if( ctx->GetLibrary() != aLibrary )
330 else if(
SCH_SCREEN* screen = ctx->GetScreen() )
331 screen->SetContentModified(
false );
343 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
345 if( ctx->GetTabKey() == aKey )
365 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
367 return aOwned.get() == ctx;
377 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
379 if( aIdx < 0 || aIdx >=
static_cast<int>( entries.size() ) )
387 const wxString& aName,
388 int aUnit,
int aBodyStyle,
393 const int unit = aUnit > 0 ? aUnit : 1;
394 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
399 *aWasCreated =
false;
409 std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>( aLib, aName, buffer ) );
425 wxString replacedKey;
429 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
430 const int previewIdx =
m_tabsPanel->Model().PreviewIndex();
432 if( previewIdx >= 0 && previewIdx <
static_cast<int>( entries.size() )
433 && entries[previewIdx].key != key )
435 replacedKey = entries[previewIdx].key;
441 if( !replacedKey.empty() )
455 const KIID& aSchematicSymbolUUID,
456 const wxString& aReference,
int aUnit,
460 const int unit = aUnit > 0 ? aUnit : 1;
461 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
469 existing->SetUnit( unit );
470 existing->SetBodyStyle( bodyStyle );
473 m_tabsPanel->AddTab( key, existing->GetReference(),
false );
480 m_tabContexts.push_back( std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>(
481 aSymbol, aScreen, aSchematicSymbolUUID, aReference ) );
505 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
508 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
509 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
560 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
562 return aOwned.get() == ctx;
571 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
573 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
584 std::vector<SYMBOL_EDITOR_TAB_CONTEXT*> dirty;
586 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
589 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
590 dirty.push_back( ctx.get() );
599 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
600 ctx->GetDisplayName() );
602 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
603 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
607 if( answer == wxID_YES )
619 else if( answer != wxID_NO )
656 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
697 ctx->SetName( newName );
706 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings enter" ) );
713 wxString activeKey =
m_settings->m_ActiveTabKey;
721 wxLogTrace(
"KICAD_TABS",
"Dropping unresolved persisted symbol tab '%s:%s'.",
731 wxLogTrace(
"KICAD_TABS",
"Dropping persisted symbol tab '%s:%s'; buffer unavailable.",
747 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings exit (activeIdx=%d)" ),
760 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
763 if( ctx->IsTransient() )
767 tab.
lib = ctx->GetLibrary();
768 tab.
name = ctx->GetName();
769 tab.
unit = ctx->GetUnit();
774 const int idx =
m_tabsPanel->FindTab( ctx->GetTabKey() );
775 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
777 if( idx >= 0 && idx <
static_cast<int>( entries.size() ) )
778 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
const wxString & GetLibrary() 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.
int m_bodyStyle
Flag if the symbol being edited was loaded directly from a schematic.
LIB_TREE * GetLibTree() const override
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
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()
Store the currently modified symbol in the library manager buffer.
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.