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" ) );
312 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
314 if( ctx->GetLibrary() != aLibrary )
319 screen->SetContentModified(
false );
326 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
328 if( ctx->GetTabKey() == aKey )
348 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
350 return aOwned.get() == ctx;
360 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
362 if( aIdx < 0 || aIdx >=
static_cast<int>( entries.size() ) )
370 const wxString& aName,
371 int aUnit,
int aBodyStyle,
376 const int unit = aUnit > 0 ? aUnit : 1;
377 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
382 *aWasCreated =
false;
392 std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>( aLib, aName, buffer ) );
408 wxString replacedKey;
412 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
413 const int previewIdx =
m_tabsPanel->Model().PreviewIndex();
415 if( previewIdx >= 0 && previewIdx <
static_cast<int>( entries.size() )
416 && entries[previewIdx].key != key )
418 replacedKey = entries[previewIdx].key;
424 if( !replacedKey.empty() )
438 const KIID& aSchematicSymbolUUID,
439 const wxString& aReference,
int aUnit,
443 const int unit = aUnit > 0 ? aUnit : 1;
444 const int bodyStyle = aBodyStyle > 0 ? aBodyStyle : 1;
452 existing->SetUnit( unit );
453 existing->SetBodyStyle( bodyStyle );
456 m_tabsPanel->AddTab( key, existing->GetReference(),
false );
463 m_tabContexts.push_back( std::make_unique<SYMBOL_EDITOR_TAB_CONTEXT>(
464 aSymbol, aScreen, aSchematicSymbolUUID, aReference ) );
488 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
491 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
492 dlg.SetYesNoCancelLabels(
_(
"Save" ),
_(
"Discard Changes" ),
_(
"Cancel" ) );
543 [ctx](
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& aOwned )
545 return aOwned.get() == ctx;
554 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
556 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
567 std::vector<SYMBOL_EDITOR_TAB_CONTEXT*> dirty;
569 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
572 if( ctx.get() !=
m_activeTab && ctx->IsTransient() && ctx->IsModified() )
573 dirty.push_back( ctx.get() );
582 wxString msg = wxString::Format(
_(
"Save changes to '%s' before closing?" ),
583 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 )
650 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings enter" ) );
657 wxString activeKey =
m_settings->m_ActiveTabKey;
665 wxLogTrace(
"KICAD_TABS",
"Dropping unresolved persisted symbol tab '%s:%s'.",
675 wxLogTrace(
"KICAD_TABS",
"Dropping persisted symbol tab '%s:%s'; buffer unavailable.",
691 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"restoreSymbolTabsFromSettings exit (activeIdx=%d)" ),
704 for(
const std::unique_ptr<SYMBOL_EDITOR_TAB_CONTEXT>& ctx :
m_tabContexts )
707 if( ctx->IsTransient() )
711 tab.
lib = ctx->GetLibrary();
712 tab.
name = ctx->GetName();
713 tab.
unit = ctx->GetUnit();
718 const int idx =
m_tabsPanel->FindTab( ctx->GetTabKey() );
719 const std::vector<EDITOR_TABS_MODEL::ENTRY>& entries =
m_tabsPanel->Model().Entries();
721 if( idx >= 0 && idx <
static_cast<int>( entries.size() ) )
722 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
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...
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
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
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.
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.
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.