24#ifndef SYMBOL_EDIT_FRAME_H
25#define SYMBOL_EDIT_FRAME_H
51#define UNITS_ALL _HKI( "ALL" )
52#define DEMORGAN_ALL _HKI( "ALL" )
53#define DEMORGAN_STD _HKI( "Standard" )
54#define DEMORGAN_ALT _HKI( "Alternate" )
148 bool aTreeShownNow );
242 void LoadSymbol(
const wxString& aLibrary,
const wxString& aSymbol,
int Unit );
401 void SyncLibraries(
bool aShowProgress,
bool aPreloadCancelled =
false,
402 const wxString& aForceRefresh = wxEmptyString );
441 bool aUpdateRtree =
false )
override;
540 bool LoadSymbolFromLib(
const wxString& aLibName,
const wxString& aSymbolName,
int aUnit = 0,
int aBodyStyle = 0 );
566 bool backupLibrary(
const wxFileName& aOriginalFile, wxString& aErrorMsg );
630 int aUnit,
int aBodyStyle,
bool aAsPreview,
631 bool* aWasCreated =
nullptr );
642 const KIID& aSchematicSymbolUUID,
643 const wxString& aReference,
int aUnit,
732 DECLARE_EVENT_TABLE()
Base class for API handlers related to library management.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Handles how to draw a screen (a board, a schematic ...)
Color settings are a bit different than most of the settings objects in that there can be more than o...
UNDO_REDO_LIST
Specify whether we are interacting with the undo or redo stacks.
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
A base class for most all the KiCad significant classes used in schematics and boards.
GUI-free preview/dirty/close state machine.
The tab strip plus the single shared GAL canvas.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
A logical library item identifier and consists of various portions much like a URI.
Symbol library management helper that is specific to the symbol library editor frame.
Define a library symbol object.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
Widget displaying a tree of symbols with optional search text control and description panel.
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
Schematic editor (Eeschema) main window.
One open symbol tab owning a working LIB_SYMBOL and screen lent to the frame while active.
std::vector< std::unique_ptr< SYMBOL_EDITOR_TAB_CONTEXT > > m_tabContexts
bool m_isSymbolFromSchematic
Flag if the symbol being edited was loaded directly from a schematic.
void restoreSymbolTabsFromSettings()
Recreate tabs from the persisted open-tab list once the libraries have loaded.
bool SaveLibraryHeadless(const wxString &aLibrary)
Save the given library (including buffered changes) without user interaction.
void ClearMsgPanel() override
Clear all messages from the message panel.
void OnExitKiCad(wxCommandEvent &event)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
bool promptToSaveInactiveInstanceTabs()
Prompt to save each dirty instance (symbol from schematic) tab that is not the active one,...
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
void SaveAll()
Save all modified symbols and libraries.
bool m_syncLibrariesInProgress
bool GetDrawSpecificUnit() const
void DeleteSymbolFromLibrary()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
APP_SETTINGS_BASE * config() const override
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
std::unique_ptr< API_HANDLER_COMMON > m_apiHandlerCommon
void SetDrawSpecificBodyStyle(bool aSpecific)
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...
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
wxString getTargetLib() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
bool LoadSymbolFromLib(const wxString &aLibName, const wxString &aSymbolName, int aUnit=0, int aBodyStyle=0)
Load a symbol from a library, optionally setting the selected unit and body style.
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Return true if aLibId is an alias for the editor screen symbol.
bool backupLibrary(const wxFileName &aOriginalFile, wxString &aErrorMsg)
Create a backup copy of a symbol library.
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...
void OnSelectBodyStyle(wxCommandEvent &event)
wxString m_reference
RefDes of the symbol (only valid if symbol was loaded from schematic)
bool GetShowInvisibleFields()
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 SVGPlotSymbol(const wxString &aFullFileName)
Create the SVG print file for the current edited symbol.
void RefreshLibraryTree()
Redisplay the library tree.
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
bool saveLibrary(const wxString &aLibrary, SAVE_LIBRARY_AS aSaveType=SAVE_LIBRARY_AS::ORIGINAL)
Save the changes to the current library.
void restoreSymbolSelectionKiids(const std::vector< KIID > &aKiids)
Reselect the items named by aKiids after a reload rebuilt the view.
void FocusLibraryTreeInput() override
wxComboBox * m_unitSelectBox
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),...
bool m_drawSpecificBodyStyle
When editing a symbol: only apply new graphic items to the current body style.
EDITOR_TABS_PANEL * GetTabsPanel() const
The tab strip fronting the shared canvas, or nullptr before it is mounted.
friend struct SYMBOL_EDITOR_TABS_TEST_FIXTURE
void RebuildSymbolUnitAndBodyStyleLists()
int GetTreeLIBIDs(std::vector< LIB_ID > &aSelection) const
void OnTabCharHook(wxKeyEvent &aEvent)
Cycle symbol tabs from the char hook, since GTK cannot register WXK_TAB as an accelerator.
bool GetDrawSpecificBodyStyle() const
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
void ClearToolbarControl(int aId) override
void FocusOnLibId(const LIB_ID &aLibID)
bool IsSymbolAlias() const
void SaveLibraryAs(SAVE_LIBRARY_AS aSaveType=SAVE_LIBRARY_AS::NEW)
Save the currently selected library to a new file.
void ToggleProperties() override
void Save()
Save the selected symbol or library.
SYMBOL_EDITOR_SETTINGS * m_settings
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
void onPluginAvailabilityChanged(wxCommandEvent &aEvt)
void HardRedraw() override
Rebuild the GAL and redraw the screen.
int GetTreeSelectionCount() const
void dropSymbolTabContext(const wxString &aKey)
Drop the inactive context for aKey from m_tabContexts, freeing its undo/redo.
bool addLibTableEntry(const wxString &aLibFile, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::GLOBAL)
Add aLibFile to the symbol library table defined by aScope.
void PushSymbolToUndoList(const wxString &aDescription, LIB_SYMBOL *aSymbolCopy, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
int m_unit
The unit number to edit and show.
bool LoadOneLibrarySymbol(LIB_SYMBOL *aLibEntry, const wxString &aLibrary, int aUnit, int aBodyStyle)
Create a copy of aLibEntry into memory.
bool CanCloseSymbolFromSchematic(bool doClose)
void GetSymbolFromRedoList()
bool IsSymbolFromLegacyLibrary() const
void centerItemIdleHandler(wxIdleEvent &aEvent)
bool replaceLibTableEntry(const wxString &aLibNickname, const wxString &aLibFile)
Replace the file path of the symbol library table entry aLibNickname with aLibFile.
bool IsSyncLibrariesInProgress() const
bool IsSymbolFromSchematic() const
static bool m_showDeMorgan
void SetScreen(BASE_SCREEN *aScreen) override
void KiwayMailIn(KIWAY_MAIL_EVENT &mail) override
Receive KIWAY_MAIL_EVENT messages from other players.
void emptyScreen()
Restore the empty editor screen, without any symbol or library selected.
SYMBOL_EDITOR_TAB_CONTEXT * m_activeTab
void SaveCopyInUndoList(const wxString &aDescription, LIB_SYMBOL *aSymbol, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT)
Create a copy of the current symbol, and save it in the undo list.
SYMBOL_EDITOR_SETTINGS * GetSettings() const
void DuplicateSymbol(bool aFromClipboard)
Insert a duplicate symbol.
SCH_SCREEN * m_dummyScreen
Helper screen used when no symbol is loaded.
LIB_ID m_centerItemOnIdle
void saveSymbolCopyAs(bool aOpenCopy)
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
KIID m_schematicSymbolUUID
SYMBOL_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent)
EDITOR_TAB_CONTEXT::VIEW_SNAPSHOT captureSymbolViewSnapshot() const
Capture the current view zoom/center for the active tab's snapshot.
static bool libTreeAutoHiddenForSchematicEdit(bool aWasFromSchematic, bool aRestorePending, bool aTreeShownNow)
Resolve whether the library tree's auto-hide for a schematic edit still needs restoring on save.
void restoreSymbolViewSnapshot(const EDITOR_TAB_CONTEXT::VIEW_SNAPSHOT &aSnapshot)
Restore a previously captured view zoom/center.
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
std::unique_ptr< API_HANDLER_SYMBOL > m_apiHandler
std::vector< LIB_ID > GetSelectedLibIds() const
void SyncLibraries(bool aShowProgress, bool aPreloadCancelled=false, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
bool m_silentSymbolTabClose
While true, promptAndCloseSymbolTab() skips the unsaved-changes dialog.
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.
void OnSelectUnit(wxCommandEvent &event)
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.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
LIB_ID GetTargetLibId() const override
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
bool m_libTreeAutoHiddenForSchematicEdit
True while a schematic-edit auto-hide of the library tree still needs restoring on save.
void SetBodyStyle(int aBodyStyle)
PLUGIN_ACTION_SCOPE PluginActionScope() const override
int m_bodyStyle
Show the normal shape (m_bodyStyle <= 1) or the DeMorgan converted shape (m_bodyStyle > 1)
bool saveAllLibraries(bool aRequireConfirmation)
Return true when the operation has succeeded (all requested libraries have been saved or none was sel...
bool GetShowInvisiblePins()
void UpdateMsgPanel() override
Redraw the message panel.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
void CreateNewSymbol(const wxString &newName=wxEmptyString)
Create a new symbol in the selected library.
LIB_TREE * GetLibTree() const override
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
SYMBOL_EDITOR_TAB_CONTEXT * CreateUnsavedSymbolTab(LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
Open a new tab over a transient working symbol and screen and make it active.
bool HasLibModifications() const
Check if any pending libraries have been modified.
std::unique_ptr< API_HANDLER_LIBRARIES > m_apiLibrariesHandler
bool promptAndCloseSymbolTab(int aIdx)
Prompt for unsaved changes on the tab and drop its context.
SYMBOL_TREE_PANE * m_treePane
void SetDrawSpecificUnit(bool aSpecific)
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
std::vector< KIID > captureSymbolSelectionKiids() const
Capture the KIIDs of the current selection for the active tab's snapshot.
bool m_drawSpecificUnit
When editing a symbol: only apply new graphic items to the current unit.
void closeSymbolTab(const LIB_ID &aLibId)
Close the open tab for aLibId, if any, without prompting and leaving the other tabs open.
bool saveCurrentSymbol()
Save the current symbol.
bool IsSymbolGraphicallyEditable() const
Test if a symbol is loaded and can be edited graphically.
void GetSymbolFromUndoList()
void CopySymbolToClipboard()
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void OnUpdateBodyStyle(wxUpdateUIEvent &event)
void SaveSymbolCopyAs(bool aOpenCopy)
Save the currently selected symbol to a new name and/or location.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas ( Cairo / OpenGL).
void clearSymbolTabsModifiedForLibrary(const wxString &aLibrary)
Clear the unsaved-edits flag on every tab in a saved library so its dirty indicator clears.
void doCloseWindow() override
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 DdAddLibrary(wxString aLibFile)
Add a library dropped file to the symbol library table.
wxString AddLibraryFile(bool aCreateNew)
Create or add an existing library to the symbol library table.
~SYMBOL_EDIT_FRAME() override
void FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
void configureToolbars() override
void Revert(LIB_ID &aTarget, bool aConfirm=true)
Revert unsaved changes in a symbol, restoring to the last saved state.
void ensureUniqueName(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
wxComboBox * m_bodyStyleSelectBox
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 UpdateLibraryTree(const wxDataViewItem &aTreeItem, LIB_SYMBOL *aSymbol)
Update a symbol node in the library tree.
void closeAllSymbolTabsSilently()
Close every tab without prompting and return the frame to the empty state.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
void ToggleLibraryTree() override
void doReCreateMenuBar() override
LIB_SYMBOL * getTargetSymbol() const
Return currently edited symbol.
void OnUpdateUnitNumber(wxUpdateUIEvent &event)
Library Editor pane with symbol tree and symbol library table selector.
A holder to handle a list of undo (or redo) commands.
View snapshot captured on detach, restored on activate.
SAVE_LIBRARY_AS
Types of KiCad symbol library save actions.
@ NEW
Save to a new library in the original symbol library format.
@ UNPACKED
Save a packed symbol library to the unpacked format.
@ PACKED
Save an unpacked symbol library to the packed format.
@ ORIGINAL
Save to the original symbol library format.
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...