KiCad PCB EDA Suite
SYMBOL_EDIT_FRAME Class Reference

The symbol library editor main window. More...

#include <symbol_edit_frame.h>

Inheritance diagram for SYMBOL_EDIT_FRAME:
SCH_BASE_FRAME EDA_DRAW_FRAME KIWAY_PLAYER EDA_BASE_FRAME TOOLS_HOLDER KIWAY_HOLDER

Public Types

enum  UNDO_REDO_LIST { UNDO_LIST, REDO_LIST }
 Specifies whether we are interacting with the undo or redo stacks. More...
 
enum  HOLDER_TYPE { DIALOG, FRAME, PANEL }
 

Public Member Functions

 SYMBOL_EDIT_FRAME (KIWAY *aKiway, wxWindow *aParent)
 
 ~SYMBOL_EDIT_FRAME () override
 
void SwitchCanvas (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
 Switch currently used canvas ( Cairo / OpenGL). More...
 
bool IsContentModified () const override
 Get if any symbols or libraries have been modified but not saved. More...
 
bool HasLibModifications () const
 Check if any pending libraries have been modified. More...
 
wxString GetCurLib () const
 The nickname of the current library being edited and empty string if none. More...
 
wxString SetCurLib (const wxString &aLibNickname)
 Set the current library nickname and returns the old library nickname. More...
 
LIB_TREE_NODEGetCurrentTreeNode () const
 
LIB_ID GetTreeLIBID (int *aUnit=nullptr) const
 Return the LIB_ID of the library or symbol selected in the symbol tree. More...
 
LIB_SYMBOLGetCurSymbol () const
 Return the current symbol being edited or NULL if none selected. More...
 
void SetCurSymbol (LIB_SYMBOL *aSymbol, bool aUpdateZoom)
 Take ownership of aSymbol and notes that it is the one currently being edited. More...
 
SYMBOL_LIBRARY_MANAGERGetLibManager ()
 
SELECTIONGetCurrentSelection () override
 Get the current selection from the canvas area. More...
 
void ReCreateMenuBar () override
 Recreates the menu bar. More...
 
bool SynchronizePins ()
 
bool AddLibraryFile (bool aCreateNew)
 Create or add an existing library to the symbol library table. More...
 
void CreateNewSymbol ()
 Create a new symbol in the selected library. More...
 
void ImportSymbol ()
 
void ExportSymbol ()
 
void Save ()
 Save the selected symbol or library. More...
 
void SaveSymbolAs ()
 Save the currently selected symbol to a new name and/or location. More...
 
void SaveLibraryAs ()
 Save the currently selected library to a new file. More...
 
void SaveAll ()
 Save all modified symbols and libraries. More...
 
void Revert (bool aConfirm=true)
 Revert unsaved changes in a symbol, restoring to the last saved state. More...
 
void RevertAll ()
 
void DeleteSymbolFromLibrary ()
 
void CopySymbolToClipboard ()
 
void LoadSymbol (const wxString &aLibrary, const wxString &aSymbol, int Unit)
 
void DuplicateSymbol (bool aFromClipboard)
 Insert a duplicate symbol. More...
 
void OnSelectUnit (wxCommandEvent &event)
 
void OnToggleSymbolTree (wxCommandEvent &event)
 
bool IsSymbolTreeShown ()
 
void FreezeLibraryTree ()
 
void ThawLibraryTree ()
 
void OnUpdateUnitNumber (wxUpdateUIEvent &event)
 
void UpdateAfterSymbolProperties (wxString *aOldName=nullptr)
 
void RebuildSymbolUnitsList ()
 
bool canCloseWindow (wxCloseEvent &aCloseEvent) override
 
void doCloseWindow () override
 
void OnExitKiCad (wxCommandEvent &event)
 
void ReCreateHToolbar () override
 
void ReCreateVToolbar () override
 
void ReCreateOptToolbar () override
 
void LoadSettings (APP_SETTINGS_BASE *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (APP_SETTINGS_BASE *aCfg) override
 Save common frame parameters to a configuration data file. More...
 
SYMBOL_EDITOR_SETTINGSGetSettings () const
 
APP_SETTINGS_BASEconfig () const override
 Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
COLOR_SETTINGSGetColorSettings () const override
 Returns a pointer to the active color theme settings. More...
 
void CloseWindow (wxCommandEvent &event)
 Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro: More...
 
void OnModify () override
 Must be called after a schematic change in order to set the "modify" flag of the current symbol. More...
 
int GetUnit () const
 
void SetUnit (int aUnit)
 
int GetConvert () const
 
void SetConvert (int aConvert)
 
bool GetShowDeMorgan () const
 
void SetShowDeMorgan (bool show)
 
void ClearMsgPanel () override
 Clear all messages from the message panel. More...
 
bool IsSymbolFromSchematic () const
 
bool IsSymbolFromLegacyLibrary () const
 
void UpdateSymbolMsgPanelInfo ()
 Display the documentation of the selected symbol. More...
 
void SaveCopyInUndoList (EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
 Create a copy of the current symbol, and save it in the undo list. More...
 
void GetSymbolFromUndoList ()
 
void GetSymbolFromRedoList ()
 
void RollbackSymbolFromUndo ()
 
void ClearUndoORRedoList (UNDO_REDO_LIST whichList, int aItemCount=-1) override
 Free the undo or redo list from aList element. More...
 
bool LoadSymbol (const LIB_ID &aLibId, int aUnit, int aConvert)
 Select the currently active library and loads the symbol from aLibId. More...
 
void PrintPage (const RENDER_SETTINGS *aSettings) override
 Print a page. More...
 
void SVGPlotSymbol (const wxString &aFullFileName)
 Create the SVG print file for the current edited symbol. More...
 
void SyncLibraries (bool aShowProgress, const wxString &aForceRefresh=wxEmptyString)
 Synchronize the library manager to the symbol library table, and then the symbol tree to the library manager. More...
 
void RegenerateLibraryTree ()
 Filter, sort, and redisplay the library tree. More...
 
void RefreshLibraryTree ()
 Redisplay the library tree. More...
 
void InstallPreferences (PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
 Allow the symbol editor to install its preferences panel into the preferences dialog. More...
 
void CommonSettingsChanged (bool aEnvVarsChanged, bool aTextVarsChanged) override
 Called after the preferences dialog is run. More...
 
void ShowChangedLanguage () override
 
void SetScreen (BASE_SCREEN *aScreen) override
 
const BOX2I GetDocumentExtents (bool aIncludeAllVisible=true) const override
 Returns bbox of document with option to not include some items. More...
 
void RebuildView ()
 
void HardRedraw () override
 Rebuild the GAL and redraw the screen. More...
 
void KiwayMailIn (KIWAY_EXPRESS &mail) override
 Receive KIWAY_EXPRESS messages from other players. More...
 
void LoadSymbolFromSchematic (SCH_SYMBOL *aSymbol)
 Load a symbol from the schematic to edit in place. More...
 
bool IsSymbolEditable () const
 Test if a symbol is loaded and can be edited. More...
 
bool IsSymbolAlias () const
 Restore the empty editor screen, without any symbol or library selected. More...
 
void emptyScreen ()
 Return either the symbol selected in the symbol tree, if context menu is active or the currently modified symbol. More...
 
LIB_ID GetTargetLibId () const
 
void createCanvas ()
 
SCH_DRAW_PANELGetCanvas () const override
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
SCH_SCREENGetScreen () const override
 Return a pointer to a BASE_SCREEN or one of its derivatives. More...
 
EESCHEMA_SETTINGSeeconfig () const
 
SYMBOL_EDITOR_SETTINGSlibeditconfig () const
 
KIGFX::SCH_RENDER_SETTINGSGetRenderSettings ()
 
COLOR4D GetDrawBgColor () const override
 
virtual bool GetShowAllPins () const
 Allow some frames to show/hide hidden pins. More...
 
void SetPageSettings (const PAGE_INFO &aPageSettings) override
 
const PAGE_INFOGetPageSettings () const override
 
const wxSize GetPageSizeIU () const override
 Works off of GetPageSettings() to return the size of the paper page in the internal units of this particular view. More...
 
const wxPoint & GetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const wxPoint &aPoint) override
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
void UpdateStatusBar () override
 Update the status bar information. More...
 
PICKED_SYMBOL PickSymbolFromLibTree (const SCHLIB_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
 Call the library viewer to select symbol to import into schematic. More...
 
LIB_SYMBOLGetLibSymbol (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
 Load symbol from symbol library table. More...
 
PICKED_SYMBOL PickSymbolFromLibBrowser (wxTopLevelWindow *aParent, const SCHLIB_FILTER *aFilter, const LIB_ID &aPreselectedLibId, int aUnit, int aConvert)
 Call the library viewer to select symbol to import into schematic. More...
 
virtual void RedrawScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
virtual void CenterScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
void AddToScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen)
 Add an item to the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void RemoveFromScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen)
 Remove an item from the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void UpdateItem (EDA_ITEM *aItem, bool isAddOrDelete=false)
 Mark an item for refresh. More...
 
void RefreshSelection ()
 Mark selected items for refresh. More...
 
void SyncView ()
 Mark all items for refresh. More...
 
COLOR4D GetLayerColor (SCH_LAYER_ID aLayer)
 Helper to retrieve a layer color from the global color settings. More...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
void ScriptingConsoleEnableDisable ()
 Toggles the scripting console visibility. More...
 
bool IsScriptingConsoleVisible ()
 Gets the current visibility of the scripting console window. More...
 
wxFindReplaceData & GetFindReplaceData ()
 
wxArrayString & GetFindHistoryList ()
 
bool GetShowPolarCoords () const
 For those frames that support polar coordinates. More...
 
void SetShowPolarCoords (bool aShow)
 
void ToggleUserUnits () override
 
void GetUnitPair (EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
 Get the pair or units in current use. More...
 
wxPoint GetNearestGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
wxPoint GetNearestHalfGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize / 2 location to aPosition. More...
 
virtual ORIGIN_TRANSFORMSGetOriginTransforms ()
 Return a reference to the default ORIGIN_TRANSFORMS object. More...
 
virtual void SetDrawBgColor (const COLOR4D &aColor)
 
bool ShowPageLimits () const
 
void SetShowPageLimits (bool aShow)
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
 
virtual wxString GetScreenDesc () const
 
void EraseMsgBox ()
 
virtual void ReCreateAuxiliaryToolbar ()
 
virtual void UpdateToolbarControlSizes ()
 Update the sizes of any controls in the toolbars of the frame. More...
 
bool IsGridVisible () const
 
virtual void SetGridVisibility (bool aVisible)
 
virtual COLOR4D GetGridColor ()
 
virtual void SetGridColor (const COLOR4D &aColor)
 
void OnSelectGrid (wxCommandEvent &event)
 Command event handler for selecting grid sizes. More...
 
void OnGridSettings (wxCommandEvent &event)
 
void UpdateGridSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.). More...
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 Update the checked item in the grid combobox. More...
 
void UpdateZoomSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.) More...
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 Update the checked item in the zoom combobox. More...
 
const wxString GetZoomLevelIndicator () const
 Return a human readable value for display in dialogs. More...
 
virtual void OnSelectZoom (wxCommandEvent &event)
 Set the zoom factor when selected by the zoom list box in the main tool bar. More...
 
virtual void OnSize (wxSizeEvent &event) override
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
virtual void Zoom_Automatique (bool aWarpPointer)
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void FocusOnLocation (const wxPoint &aPos)
 Useful to focus on a particular location, in find functions. More...
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Construct a "basic" menu for a tool, containing only items that apply to all tools (e.g. More...
 
void PrintDrawingSheet (const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Prints the drawing-sheet (frame and title block). More...
 
void DisplayToolMsg (const wxString &msg) override
 
virtual void OnPageSettingsChange ()
 Called when modifying the page settings. More...
 
void DisplayUnitsMsg ()
 Display current unit pane in the status bar. More...
 
virtual void DisplayGridMsg ()
 Display current grid size in the status bar. More...
 
void AppendMsgPanel (const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
 Append a message to the message panel. More...
 
void SetMsgPanel (const std::vector< MSG_PANEL_ITEM > &aList)
 Clear the message panel and populates it with the contents of aList. More...
 
void SetMsgPanel (EDA_ITEM *aItem)
 
void SetMsgPanel (const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
 Helper function that erases the msg panel and then appends a single message. More...
 
virtual void UpdateMsgPanel ()
 Redraw the message panel. More...
 
virtual EDA_ITEMGetItem (const KIID &aId) const
 Fetch an item by KIID. More...
 
virtual void ActivateGalCanvas ()
 Use to start up the GAL drawing canvas. More...
 
void SetCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
wxWindow * GetToolCanvas () const override
 Canvas access. More...
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Return a reference to the gal rendering options used by GAL for rendering. More...
 
void RefreshCanvas () override
 
void RecreateToolbars ()
 Rebuild all toolbars, and update the checked state of check tools. More...
 
virtual bool OpenProjectFiles (const std::vector< wxString > &aFileList, int aCtl=0)
 Open a project or set of files given by aFileList. More...
 
virtual void ParseArgs (wxCmdLineParser &aParser)
 Handle command-line arguments in a frame-specific way. More...
 
virtual bool ShowModal (wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
 Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until this KIWAY_PLAYER derivative calls DismissModal(). More...
 
bool Destroy () override
 Our version of Destroy() which is virtual from wxWidgets. More...
 
bool IsModal () const override
 Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame. More...
 
void SetModal (bool aIsModal)
 
bool IsDismissed ()
 
void DismissModal (bool aRetVal, const wxString &aResult=wxEmptyString)
 
void CreateServer (int service, bool local=true)
 
void OnSockRequest (wxSocketEvent &evt)
 
void OnSockRequestServer (wxSocketEvent &evt)
 
virtual void ExecuteRemoteCommand (const char *cmdline)
 Execute a remote command sent via socket (to port KICAD_PCB_PORT_SERVICE_NUMBER, currently 4242). More...
 
EDA_UNITS GetUserUnits () const
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS aUnits)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
SETTINGS_MANAGERGetSettingsManager () const
 
virtual SEVERITY GetSeverity (int aErrorCode) const
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &aKeyEvent)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuEvent (wxMenuEvent &event)
 The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
virtual void RegisterUIUpdateHandler (int aID, const ACTION_CONDITIONS &aConditions) override
 Register a UI update handler for the control with ID aID. More...
 
virtual void RegisterUIUpdateHandler (const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
 Register an action's update conditions with the UI layer to allow the UI to appropriately display the state of its controls. More...
 
virtual void UnregisterUIUpdateHandler (int aID) override
 Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler. More...
 
virtual void UnregisterUIUpdateHandler (const TOOL_ACTION &aAction)
 Unregister a UI handler for an action that was registered using RegisterUIUpdateHandler. More...
 
void OnMaximize (wxMaximizeEvent &aEvent)
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
FRAME_T GetFrameType () const
 
virtual const SEARCH_STACKsys_search ()
 Return a SEARCH_STACK pertaining to entire program. More...
 
virtual wxString help_name ()
 
void OnKicadAbout (wxCommandEvent &event)
 
void OnPreferences (wxCommandEvent &event)
 Displays the preferences and settings of all opened editors paged dialog. More...
 
void PrintMsg (const wxString &text)
 
void CreateInfoBar ()
 
void FinishAUIInitialization ()
 
WX_INFOBARGetInfoBar ()
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left of the infobar, and an optional closebox to the right. More...
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton, std::function< void(void)> aCallback)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left of the infobar, and an optional closebox to the right. More...
 
void ShowInfoBarWarning (const wxString &aWarningMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left of the infobar. More...
 
void ShowInfoBarMsg (const wxString &aMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of the infobar. More...
 
void LoadWindowState (const wxString &aFileName)
 
virtual void LoadWindowState (const WINDOW_STATE &aState)
 Load frame state info from a configuration file. More...
 
void LoadWindowSettings (const WINDOW_SETTINGS *aCfg)
 Load window settings from the given settings object. More...
 
void SaveWindowSettings (WINDOW_SETTINGS *aCfg)
 Save window settings to the given settings object. More...
 
virtual WINDOW_SETTINGSGetWindowSettings (APP_SETTINGS_BASE *aCfg)
 Return a pointer to the window settings for this frame. More...
 
wxString ConfigBaseName () override
 Get the configuration base name. More...
 
virtual void SaveProjectSettings ()
 Save changes to the project settings to the project (.pro) file. More...
 
void ImportHotkeyConfigFromFile (std::map< std::string, TOOL_ACTION * > aActionMap, const wxString &aDefaultShortname)
 Prompt the user for a hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
 Fetches the file name from the file history list. More...
 
void ClearFileHistory (FILE_HISTORY *aFileHistory=nullptr)
 Removes all files from the file history. More...
 
void UpdateFileHistory (const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
 Update the list of recently opened files. More...
 
FILE_HISTORYGetFileHistory ()
 Get the frame's main file history. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
virtual wxString GetCurrentFileName () const
 Get the full filename + path of the currently opened file in the frame. More...
 
void AddStandardHelpMenu (wxMenuBar *aMenuBar)
 Adds the standard KiCad help menu to the menubar. More...
 
bool IsWritable (const wxFileName &aFileName)
 Checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName)
 Check if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
virtual void ThemeChanged ()
 Process light/dark theme change. More...
 
virtual void ProjectChanged ()
 Notification event that the project has changed. More...
 
const wxString & GetAboutTitle () const
 
wxSize GetWindowSize ()
 Get the undecorated window size that can be used for restoring the window size. More...
 
virtual void ClearUndoRedoList ()
 Clear the undo and redo list using ClearUndoORRedoList() More...
 
virtual void PushCommandToUndoList (PICKED_ITEMS_LIST *aItem)
 Add a command to undo in the undo list. More...
 
virtual void PushCommandToRedoList (PICKED_ITEMS_LIST *aItem)
 Add a command to redo in the redo list. More...
 
virtual PICKED_ITEMS_LISTPopCommandFromUndoList ()
 Return the last command to undo and remove it from list, nothing is deleted. More...
 
virtual PICKED_ITEMS_LISTPopCommandFromRedoList ()
 Return the last command to undo and remove it from list, nothing is deleted. More...
 
virtual int GetUndoCommandCount () const
 
virtual int GetRedoCommandCount () const
 
int GetMaxUndoItems () const
 
bool NonUserClose (bool aForce)
 
virtual void HandleSystemColorChange ()
 Update the UI in response to a change in the system colors. More...
 
TOOL_MANAGERGetToolManager () const
 Return the MVC controller. More...
 
virtual void PushTool (const std::string &actionName)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const std::string &actionName)
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
bool GetDoImmediateActions () const
 Indicate that hotkeys should perform an immediate action even if another tool is currently active. More...
 
MOUSE_DRAG_ACTION GetDragAction () const
 Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects. More...
 
bool GetMoveWarpsCursor () const
 Indicate that a move operation should warp the mouse pointer to the origin of the move object. More...
 
HOLDER_TYPE GetType () const
 
KIWAYKiway () const
 Return a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Return a reference to the PROJECT associated with this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 It is only used for debugging, since "this" is not a wxWindow*. More...
 

Static Public Member Functions

static void HandleUpdateUIEvent (wxUpdateUIEvent &aEvent, EDA_BASE_FRAME *aFrame, ACTION_CONDITIONS aCond)
 Handle events generated when the UI is trying to figure out the current state of the UI controls related to TOOL_ACTIONS (e.g. More...
 

Public Attributes

bool m_SyncPinEdit
 Set to true to synchronize pins at the same position when editing symbols with multiple units or multiple body styles. More...
 

Protected Member Functions

void setupUIConditions () override
 Setup the UI conditions for the various actions and their controls in this frame. More...
 
bool saveSymbolLibTables (bool aGlobal, bool aProject)
 Save Symbol Library Tables to disk. More...
 
void unitsChangeRefresh () override
 Called when when the units setting has changed to allow for any derived classes to handle refreshing and controls that have units based measurements in them. More...
 
void setupUnits (APP_SETTINGS_BASE *aCfg)
 
void resolveCanvasType ()
 Determines the Canvas type to load (with prompt if required) and initializes m_canvasType. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting ()
 Returns the canvas type stored in the application settings. More...
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
virtual void handleActivateEvent (wxActivateEvent &aEvent)
 Handle a window activation event. More...
 
void onActivate (wxActivateEvent &aEvent)
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 An event handler called on a language menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 
virtual bool isAutoSaveRequired () const
 Return the auto save status of the application. More...
 
virtual bool doAutoSave ()
 This should be overridden by the derived class to handle the auto save feature. More...
 
void onSystemColorChange (wxSysColourChangedEvent &aEvent)
 
void initExitKey ()
 Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id. More...
 
void ensureWindowIsOnScreen ()
 

Static Protected Member Functions

static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

SCHEMATIC_SETTINGS m_base_frame_defaults
 These are only used by symbol_editor. More...
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 
bool m_showPageLimits
 
COLOR4D m_gridColor
 
COLOR4D m_drawBgColor
 
int m_undoRedoCountMax
 
bool m_polarCoords
 
bool m_showBorderAndTitleBlock
 
long m_firstRunDialogSetting
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
ACTION_TOOLBARm_mainToolBar
 
ACTION_TOOLBARm_auxiliaryToolBar
 
ACTION_TOOLBARm_drawToolBar
 
ACTION_TOOLBARm_optionsToolBar
 
wxFindReplaceData * m_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_msgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 The current canvas type. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 < Points to nested event_loop. NULL means not modal and dismissed. More...
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
FRAME_T m_ident
 
wxPoint m_framePos
 
wxSize m_frameSize
 
bool m_maximizeByDefault
 
int m_displayIndex
 
wxPoint m_normalFramePos
 
wxSize m_normalFrameSize
 
wxString m_aboutTitle
 
wxAuiManager m_auimgr
 
wxString m_perspective
 
WX_INFOBARm_infoBar
 
wxString m_configName
 
SETTINGS_MANAGERm_settingsManager
 
FILE_HISTORYm_fileHistory
 
bool m_hasAutoSave
 
bool m_autoSaveState
 
int m_autoSaveInterval
 
wxTimer * m_autoSaveTimer
 
UNDO_REDO_CONTAINER m_undoList
 
UNDO_REDO_CONTAINER m_redoList
 
wxString m_mruPath
 
EDA_UNITS m_userUnits
 Map containing the UI update handlers registered with wx for each action. More...
 
std::map< int, UIUpdateHandlerm_uiUpdateMap
 Set by the close window event handler after frames are asked if they can close. More...
 
bool m_isClosing
 Set by NonUserClose() to indicate that the user did not request the current close. More...
 
bool m_isNonUserClose
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
TOOL_DISPATCHERm_toolDispatcher
 
SELECTION m_dummySelection
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
MOUSE_DRAG_ACTION m_dragAction
 
bool m_moveWarpsCursor
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 < Default style flags used for wxAUI toolbars. More...
 

Private Types

enum  TABLE_SCOPE { GLOBAL_LIB_TABLE, PROJECT_LIB_TABLE }
 

Private Member Functions

void setupTools ()
 
void saveSymbolAs ()
 
bool saveLibrary (const wxString &aLibrary, bool aNewFile)
 Save the changes to the current library. More...
 
void updateTitle ()
 Update the main window title bar with the current library name and read only status of the library. More...
 
void SelectActiveLibrary (const wxString &aLibrary=wxEmptyString)
 Set the current active library to aLibrary. More...
 
wxString SelectLibraryFromList ()
 Display a list of loaded libraries in the symbol library and allows the user to select a library. More...
 
bool LoadSymbolFromCurrentLib (const wxString &aAliasName, int aUnit=0, int aConvert=0)
 Load a symbol from the current active library, optionally setting the selected unit and convert. More...
 
bool LoadOneLibrarySymbolAux (LIB_SYMBOL *aLibEntry, const wxString &aLibrary, int aUnit, int aConvert)
 Create a copy of aLibEntry into memory. More...
 
SYMBOL_LIB_TABLEselectSymLibTable (bool aOptional=false)
 Display a dialog asking the user to select a symbol library table. More...
 
bool backupFile (const wxFileName &aOriginalFile, const wxString &aBackupExt)
 Return currently edited symbol. More...
 
LIB_SYMBOLgetTargetSymbol () const
 Return either the library selected in the symbol tree, if context menu is active or the library that is currently modified. More...
 
wxString getTargetLib () const
 
bool saveAllLibraries (bool aRequireConfirmation)
 Save the current symbol. More...
 
bool saveCurrentSymbol ()
 Store the currently modified symbol in the library manager buffer. More...
 
void storeCurrentSymbol ()
 Return true if aLibId is an alias for the editor screen symbol. More...
 
bool isCurrentSymbol (const LIB_ID &aLibId) const
 Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library. More...
 
void ensureUniqueName (LIB_SYMBOL *aSymbol, const wxString &aLibrary)
 
bool addLibTableEntry (const wxString &aLibFile, TABLE_SCOPE aScope=GLOBAL_LIB_TABLE)
 Add aLibFile to the symbol library table defined by aScope. More...
 
bool replaceLibTableEntry (const wxString &aLibNickname, const wxString &aLibFile)
 Replace the file path of the symbol library table entry aLibNickname with aLibFile. More...
 

Private Attributes

SCH_SCREENm_dummyScreen
 < Helper screen used when no symbol is loaded More...
 
LIB_SYMBOLm_symbol
 
wxComboBox * m_unitSelectBox
 
SYMBOL_TREE_PANEm_treePane
 
SYMBOL_LIBRARY_MANAGERm_libMgr
 
SYMBOL_EDITOR_SETTINGSm_settings
 
int m_unit
 
int m_convert
 Flag if the symbol being edited was loaded directly from a schematic. More...
 
bool m_isSymbolFromSchematic
 
wxString m_reference
 The reference of the symbol. More...
 

Static Private Attributes

static bool m_showDeMorgan = false
 

Detailed Description

The symbol library editor main window.

Definition at line 52 of file symbol_edit_frame.h.

Member Enumeration Documentation

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 

Definition at line 39 of file kiway_holder.h.

◆ TABLE_SCOPE

Enumerator
GLOBAL_LIB_TABLE 
PROJECT_LIB_TABLE 

Definition at line 471 of file symbol_edit_frame.h.

◆ UNDO_REDO_LIST

Specifies whether we are interacting with the undo or redo stacks.

Enumerator
UNDO_LIST 
REDO_LIST 

Definition at line 109 of file eda_base_frame.h.

Constructor & Destructor Documentation

◆ SYMBOL_EDIT_FRAME()

SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME ( KIWAY aKiway,
wxWindow *  aParent 
)

Definition at line 97 of file symbol_edit_frame.cpp.

97  :
98  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_SYMBOL_EDITOR, _( "Library Editor" ),
99  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
101  m_unitSelectBox( nullptr ),
102  m_isSymbolFromSchematic( false )
103 {
104  SetShowDeMorgan( false );
105  m_SyncPinEdit = false;
106 
107  m_symbol = nullptr;
108  m_treePane = nullptr;
109  m_libMgr = nullptr;
110  m_unit = 1;
111  m_convert = 1;
112  m_aboutTitle = _( "KiCad Symbol Editor" );
113 
114  wxIcon icon;
115  wxIconBundle icon_bundle;
116 
117  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit ) );
118  icon_bundle.AddIcon( icon );
119  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_32 ) );
120  icon_bundle.AddIcon( icon );
121  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_16 ) );
122  icon_bundle.AddIcon( icon );
123 
124  SetIcons( icon_bundle );
125 
126  m_settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
128 
129  // Ensure axis are always drawn
131  gal_opts.m_axesEnabled = true;
132 
133  m_dummyScreen = new SCH_SCREEN();
135  GetScreen()->m_Center = true;
136 
138 
141 
142  setupTools();
144 
145  m_libMgr = new SYMBOL_LIBRARY_MANAGER( *this );
146 
147  // Preload libraries before using SyncLibraries the first time, as the preload is threaded
148  WX_PROGRESS_REPORTER reporter( this, _( "Loading Symbol Libraries" ),
149  m_libMgr->GetLibraryCount(), true );
150  m_libMgr->Preload( reporter );
151 
152  SyncLibraries( false );
153  m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
154 
155  ReCreateMenuBar();
159 
160  updateTitle();
163 
164  m_auimgr.SetManagedWindow( this );
165 
166  CreateInfoBar();
167  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
168  .Top().Layer( 6 ) );
169  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
170  .Bottom().Layer( 6 ) );
171 
172  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
173  .Left().Layer( 3 ) );
174  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "SymbolTree" )
175  .Left().Layer( 2 )
176  .Caption( _( "Libraries" ) )
177  .MinSize( 250, -1 ).BestSize( 250, -1 ) );
178  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
179  .Right().Layer( 2 ) );
180 
181  m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" )
182  .CentrePane() );
183 
185 
186  if( m_settings->m_LibWidth > 0 )
187  {
188  wxAuiPaneInfo& treePane = m_auimgr.GetPane( "SymbolTree" );
189 
190  // wxAUI hack: force width by setting MinSize() and then Fixed()
191  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
192  treePane.MinSize( m_settings->m_LibWidth, -1 );
193  treePane.Fixed();
194  m_auimgr.Update();
195 
196  // now make it resizable again
197  treePane.Resizable();
198  m_auimgr.Update();
199 
200  // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
201  // back to minimum.
202  treePane.MinSize( 250, -1 );
203  }
204 
205  Raise();
206  Show( true );
207 
208  SyncView();
209  GetCanvas()->GetView()->UseDrawPriority( true );
210  GetCanvas()->GetGAL()->SetAxesEnabled( true );
211 
213 
214  // Set the working/draw area size to display a symbol to a reasonable value:
215  // A 600mm x 600mm with a origin at the area center looks like a large working area
216  double max_size_x = Millimeter2iu( 600 );
217  double max_size_y = Millimeter2iu( 600 );
218  BOX2D bbox;
219  bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
220  bbox.SetSize( max_size_x, max_size_y );
221  GetCanvas()->GetView()->SetBoundary( bbox );
222 
224 
225  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
226 
227  // Catch unhandled accelerator command characters that were no handled by the library tree
228  // panel.
230  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
231 
232  // Ensure the window is on top
233  Raise();
234 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
int m_convert
Flag if the symbol being edited was loaded directly from a schematic.
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
ACTION_TOOLBAR * m_optionsToolBar
void SetScreen(BASE_SCREEN *aScreen) override
void SetShowDeMorgan(bool show)
void UseDrawPriority(bool aFlag)
Definition: view.h:687
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
SYMBOL_TREE_PANE * m_treePane
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void SetSize(const Vec &size)
Definition: box2.h:195
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
bool m_axesEnabled
Fullscreen crosshair or small cross.
Library Editor pane with symbol tree and symbol library table selector.
#define LIB_EDIT_FRAME_NAME
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
void updateTitle()
Update the main window title bar with the current library name and read only status of the library.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
void FinishAUIInitialization()
bool m_Center
Center on screen.
Definition: base_screen.h:96
void SyncView()
Mark all items for refresh.
EDA_MSG_PANEL * m_messagePanel
Class to handle modifications to the symbol libraries.
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
void ReCreateHToolbar() override
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
void Preload(PROGRESS_REPORTER &aReporter)
Preloads all symbol libraries in the symbol library table using SYMBOL_ASYNC_LOADER.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void ReCreateMenuBar() override
Recreates the menu bar.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
COLOR_SETTINGS * m_colorSettings
The current canvas type.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: sch_painter.cpp:95
COLOR4D GetColor(int aLayer) const
void ReCreateOptToolbar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SYMBOL_EDITOR_SETTINGS * m_settings
void setupUnits(APP_SETTINGS_BASE *aCfg)
void SetOrigin(const Vec &pos)
Definition: box2.h:193
void ReCreateVToolbar() override
SYMBOL_LIBRARY_MANAGER * m_libMgr
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
Definition: view.h:274
void SyncLibraries(bool aShowProgress, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
static constexpr int Millimeter2iu(double mm)
wxString m_aboutTitle
wxComboBox * m_unitSelectBox
ACTION_TOOLBAR * m_drawToolBar

References _, TOOL_DISPATCHER::DispatchWxEvent(), icon_libedit, icon_libedit_16, icon_libedit_32, KiBitmap(), LAYER_SCHEMATIC_GRID_AXES, PCAD2KICAD::Left, KIGFX::GAL_DISPLAY_OPTIONS::m_axesEnabled, Millimeter2iu(), Pgm(), PCAD2KICAD::Right, BOX2< Vec >::SetOrigin(), KIPLATFORM::APP::SetShutdownBlockReason(), BOX2< Vec >::SetSize(), and ACTIONS::zoomFitScreen.

◆ ~SYMBOL_EDIT_FRAME()

SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME ( )
override

Definition at line 237 of file symbol_edit_frame.cpp.

238 {
239  // Shutdown all running tools
240  if( m_toolManager )
242 
243  if( IsSymbolFromSchematic() )
244  {
245  delete m_symbol;
246  m_symbol = nullptr;
247 
248  SCH_SCREEN* screen = GetScreen();
249  delete screen;
250  m_isSymbolFromSchematic = false;
251  }
252  // current screen is destroyed in EDA_DRAW_FRAME
254 
255  auto libedit = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
256  Pgm().GetSettingsManager().Save( libedit );
257 
258  delete m_libMgr;
259 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
void SetScreen(BASE_SCREEN *aScreen) override
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
bool IsSymbolFromSchematic() const
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SYMBOL_LIBRARY_MANAGER * m_libMgr

References SCH_BASE_FRAME::GetScreen(), IsSymbolFromSchematic(), libedit, m_dummyScreen, m_isSymbolFromSchematic, m_libMgr, m_symbol, TOOLS_HOLDER::m_toolManager, Pgm(), SetScreen(), and TOOL_MANAGER::ShutdownAllTools().

Member Function Documentation

◆ ActivateGalCanvas()

void EDA_DRAW_FRAME::ActivateGalCanvas ( )
virtualinherited

Use to start up the GAL drawing canvas.

Reimplemented in GERBVIEW_FRAME, PCB_BASE_FRAME, PCB_EDIT_FRAME, FOOTPRINT_EDIT_FRAME, and PCB_BASE_EDIT_FRAME.

Definition at line 703 of file eda_draw_frame.cpp.

704 {
705  GetCanvas()->SetEvtHandlerEnabled( true );
706  GetCanvas()->StartDrawing();
707 }
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void StartDrawing()
Begin drawing if it was stopped previously.

References EDA_DRAW_FRAME::GetCanvas(), and EDA_DRAW_PANEL_GAL::StartDrawing().

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::ActivateGalCanvas(), SCH_BASE_FRAME::createCanvas(), SCH_DRAW_PANEL::OnShow(), and EDA_DRAW_FRAME::SwitchCanvas().

◆ AddLibraryFile()

bool SYMBOL_EDIT_FRAME::AddLibraryFile ( bool  aCreateNew)

Create or add an existing library to the symbol library table.

Definition at line 802 of file symbol_edit_frame.cpp.

803 {
804  // Select the target library table (global/project)
805  SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
806 
807  if( !libTable )
808  return false;
809 
810  wxFileName fn = m_libMgr->GetUniqueLibraryName();
811 
812  if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
814  ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
816  {
817  return false;
818  }
819 
820  wxString libName = fn.GetName();
821 
822  if( libName.IsEmpty() )
823  return false;
824 
825  if( m_libMgr->LibraryExists( libName ) )
826  {
827  DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
828  return false;
829  }
830 
831  if( aCreateNew )
832  {
833  if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
834  {
835  DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
836  "Make sure you have write permissions and try again." ),
837  fn.GetFullPath() ) );
838  return false;
839  }
840  }
841  else
842  {
843  if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
844  {
845  DisplayError( this, _( "Could not open the library file." ) );
846  return false;
847  }
848  }
849 
850  bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
851  saveSymbolLibTables( globalTable, !globalTable );
852 
853  std::string packet = fn.GetFullPath().ToStdString();
855 
856  return true;
857 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:271
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:476
SYMBOL_LIB_TABLE * selectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
wxString GetUniqueLibraryName() const
Return a library name that is not currently in use.
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
#define _(s)
wxString KiCadSymbolLibFileWildcard()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:97
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
SYMBOL_LIBRARY_MANAGER * m_libMgr
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Create an empty library and adds it to the library table.
const std::string KiCadSymbolLibFileExtension

References _, SYMBOL_LIBRARY_MANAGER::AddLibrary(), SYMBOL_LIBRARY_MANAGER::CreateLibrary(), DisplayError(), KIWAY::ExpressMail(), Format(), FRAME_SCH_SYMBOL_EDITOR, PATHS::GetDefaultUserSymbolsPath(), SYMBOL_LIB_TABLE::GetGlobalLibTable(), SYMBOL_LIBRARY_MANAGER::GetUniqueLibraryName(), KiCadSymbolLibFileExtension, KiCadSymbolLibFileWildcard(), KIWAY_HOLDER::Kiway(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), EDA_DRAW_FRAME::LibraryFileBrowser(), m_libMgr, MAIL_LIB_EDIT, SCH_BASE_FRAME::saveSymbolLibTables(), and selectSymLibTable().

◆ addLibTableEntry()

bool SYMBOL_EDIT_FRAME::addLibTableEntry ( const wxString &  aLibFile,
TABLE_SCOPE  aScope = GLOBAL_LIB_TABLE 
)
private

Add aLibFile to the symbol library table defined by aScope.

Note
The library defined by aLibFile must be a KiCad (s-expression) library.
Parameters
aLibFileis the full path and file name of the symbol library to add to the table.
aScopedefines if aLibFile is added to the global or project library table.
Returns
true if successful or false if a failure occurs.

Definition at line 1339 of file symbol_edit_frame.cpp.

1340 {
1341  wxFileName fn = aLibFile;
1342  wxFileName libTableFileName( Prj().GetProjectPath(),
1344  wxString libNickname = fn.GetName();
1345  SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1346  const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
1347 
1348  if( libTable->HasLibrary( libNickname ) )
1349  {
1350  wxString tmp;
1351  int suffix = 1;
1352 
1353  while( libTable->HasLibrary( libNickname ) )
1354  {
1355  tmp.Printf( "%s%d", fn.GetName(), suffix );
1356  libNickname = tmp;
1357  suffix += 1;
1358  }
1359  }
1360 
1362  row->SetNickName( libNickname );
1363 
1364  wxString normalizedPath = NormalizePath( aLibFile, &envVars, Prj().GetProjectPath() );
1365 
1366  if( aScope == GLOBAL_LIB_TABLE )
1367  {
1369  libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
1370 
1371  // We cannot normalize against the current project path when saving to global table.
1372  normalizedPath = NormalizePath( aLibFile, &envVars, wxEmptyString );
1373  }
1374 
1375  if( normalizedPath.IsEmpty() )
1376  normalizedPath = aLibFile;
1377 
1378  row->SetFullURI( normalizedPath );
1379 
1380  wxCHECK( libTable->InsertRow( row ), false );
1381 
1382  try
1383  {
1384  libTable->Save( libTableFileName.GetFullPath() );
1385  }
1386  catch( const IO_ERROR& ioe )
1387  {
1388  wxString msg = aScope == GLOBAL_LIB_TABLE ? _( "Error saving global library table." )
1389  : _( "Error saving project library table." );
1390 
1391  wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1392  dlg.SetExtendedMessage( ioe.What() );
1393  dlg.ShowModal();
1394 
1395  return false;
1396  }
1397 
1398  return true;
1399 }
static const wxString & GetSymbolLibTableFileName()
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
#define _(s)
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:69

References _, SYMBOL_LIB_TABLE::GetGlobalLibTable(), SYMBOL_LIB_TABLE::GetGlobalTableFileName(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName(), GLOBAL_LIB_TABLE, LIB_TABLE::HasLibrary(), LIB_TABLE::InsertRow(), NormalizePath(), Pgm(), KIWAY_HOLDER::Prj(), LIB_TABLE::Save(), LIB_TABLE_ROW::SetFullURI(), LIB_TABLE_ROW::SetNickName(), and IO_ERROR::What().

Referenced by saveLibrary().

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 440 of file eda_base_frame.cpp.

441 {
442  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
443  ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
444 
445  helpMenu->Add( ACTIONS::help );
446  helpMenu->Add( ACTIONS::gettingStarted );
447  helpMenu->Add( ACTIONS::listHotKeys );
448  helpMenu->Add( ACTIONS::getInvolved );
449  helpMenu->Add( ACTIONS::donate );
450  helpMenu->Add( ACTIONS::reportBug );
451 
452  helpMenu->AppendSeparator();
453  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
454 
455  // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
456  aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
457 }
static TOOL_ACTION listHotKeys
Definition: actions.h:178
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
static TOOL_ACTION reportBug
Cursor control event types.
Definition: actions.h:181
static TOOL_ACTION donate
Definition: actions.h:179
#define _(s)
Handle actions that are shared between different applications.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION help
Definition: actions.h:177
static TOOL_ACTION getInvolved
Definition: actions.h:180
static TOOL_ACTION gettingStarted
Definition: actions.h:176

References _, about, ACTIONS::donate, ACTIONS::getInvolved, ACTIONS::gettingStarted, TOOL_MANAGER::GetTool(), ACTIONS::help, ACTIONS::listHotKeys, TOOLS_HOLDER::m_toolManager, and ACTIONS::reportBug.

Referenced by EDA_3D_VIEWER_FRAME::CreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), and PCB_EDIT_FRAME::ReCreateMenuBar().

◆ AddStandardSubMenus()

void EDA_DRAW_FRAME::AddStandardSubMenus ( TOOL_MENU aMenu)
inherited

Construct a "basic" menu for a tool, containing only items that apply to all tools (e.g.

zoom and grid).

Definition at line 494 of file eda_draw_frame.cpp.

495 {
496  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
497  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
498 
499  aMenu.AddSeparator( 1000 );
500 
501  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
502  zoomMenu->SetTool( commonTools );
503  aToolMenu.AddSubMenu( zoomMenu );
504 
505  auto gridMenu = std::make_shared<GRID_MENU>( this );
506  gridMenu->SetTool( commonTools );
507  aToolMenu.AddSubMenu( gridMenu );
508 
509  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
510  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
511 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
Handles action that are shared between different applications.
Definition: common_tools.h:37
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158

References CONDITIONAL_MENU::AddSeparator(), TOOL_MENU::AddSubMenu(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::m_toolManager, and SELECTION_CONDITIONS::ShowAlways().

Referenced by ROUTER_TOOL::Init(), PL_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), PCB_SELECTION_TOOL::Init(), and PICKER_TOOL::Init().

◆ AddToScreen()

void SCH_BASE_FRAME::AddToScreen ( EDA_ITEM aItem,
SCH_SCREEN aScreen 
)
inherited

Add an item to the screen (and view) aScreen is the screen the item is located on, if not the current screen.

Definition at line 363 of file sch_base_frame.cpp.

364 {
365  auto screen = aScreen;
366 
367  if( aScreen == nullptr )
368  screen = GetScreen();
369 
370  screen->Append( (SCH_ITEM*) aItem );
371 
372  if( screen == GetScreen() )
373  {
374  GetCanvas()->GetView()->Add( aItem );
375  UpdateItem( aItem, true ); // handle any additional parent semantics
376  }
377 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:323
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193

References KIGFX::VIEW::Add(), SCH_BASE_FRAME::GetCanvas(), SCH_BASE_FRAME::GetScreen(), SCH_DRAW_PANEL::GetView(), and SCH_BASE_FRAME::UpdateItem().

Referenced by SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_EDIT_FRAME::AddJunction(), SCH_EDIT_FRAME::BreakSegment(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_FRAME::DeleteJunction(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), and SCH_EDIT_FRAME::SchematicCleanUp().

◆ AppendMsgPanel()

void EDA_DRAW_FRAME::AppendMsgPanel ( const wxString &  aTextUpper,
const wxString &  aTextLower,
int  aPadding = 6 
)
inherited

Append a message to the message panel.

This helper method checks to make sure the message panel exists in the frame and appends a message to it using the message panel AppendMessage() method.

Parameters
aTextUpperThe message upper text.
aTextLowerThe message lower text.
aPaddingNumber of spaces to pad between messages.

Definition at line 648 of file eda_draw_frame.cpp.

650 {
651  if( m_messagePanel )
652  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
653 }
EDA_MSG_PANEL * m_messagePanel
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:94

References EDA_MSG_PANEL::AppendMessage(), and EDA_DRAW_FRAME::m_messagePanel.

Referenced by GERBER_FILE_IMAGE::DisplayImageInfo(), SYMBOL_VIEWER_FRAME::updatePreviewSymbol(), and UpdateSymbolMsgPanelInfo().

◆ backupFile()

bool SYMBOL_EDIT_FRAME::backupFile ( const wxFileName &  aOriginalFile,
const wxString &  aBackupExt 
)
private

Return currently edited symbol.

Definition at line 1027 of file symbol_edit_frame.cpp.

1028 {
1029  if( aOriginalFile.FileExists() )
1030  {
1031  wxFileName backupFileName( aOriginalFile );
1032  backupFileName.SetExt( aBackupExt );
1033 
1034  if( backupFileName.FileExists() )
1035  wxRemoveFile( backupFileName.GetFullPath() );
1036 
1037  if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
1038  {
1039  DisplayError( this, wxString::Format( _( "Failed to save backup to '%s'." ),
1040  backupFileName.GetFullPath() ) );
1041  return false;
1042  }
1043  }
1044 
1045  return true;
1046 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:271
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References _, DisplayError(), and Format().

Referenced by saveLibrary().

◆ canCloseWindow()

bool SYMBOL_EDIT_FRAME::canCloseWindow ( wxCloseEvent &  aCloseEvent)
overridevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 502 of file symbol_edit_frame.cpp.

503 {
504  // Shutdown blocks must be determined and vetoed as early as possible
505  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
506  && IsContentModified() )
507  {
508  return false;
509  }
510 
512  {
513  SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
514 
515  switch( UnsavedChangesDialog( this,
516  _( "Save changes to schematic before closing?" ),
517  nullptr ) )
518  {
519  case wxID_YES:
520  if( schframe && GetCurSymbol() ) // Should be always the case
521  schframe->SaveSymbolToSchematic( *GetCurSymbol());
522 
523  return true;
524 
525  case wxID_NO: return true;
526 
527  default:
528  case wxID_CANCEL: return false;
529  }
530  }
531 
532  if( !saveAllLibraries( true ) )
533  {
534  return false;
535  }
536 
537  return true;
538 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
Schematic editor (Eeschema) main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:176
#define _(s)
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
bool saveAllLibraries(bool aRequireConfirmation)
Save the current symbol.
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol)
Update the LIB_SYMBOL of the currently selected symbol.

References _, FRAME_SCH, GetCurSymbol(), IsContentModified(), KIWAY_HOLDER::Kiway(), m_isSymbolFromSchematic, KIWAY::Player(), saveAllLibraries(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), KIPLATFORM::APP::SupportsShutdownBlockReason(), and UnsavedChangesDialog().

◆ CenterScreen()

void SCH_BASE_FRAME::CenterScreen ( const wxPoint &  aCenterPoint,
bool  aWarpPointer 
)
virtualinherited

Definition at line 254 of file sch_base_frame.cpp.

255 {
256  GetCanvas()->GetView()->SetCenter( aCenterPoint );
257 
258  if( aWarpPointer )
259  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
260 
261  GetCanvas()->Refresh();
262 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:581
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...

References SCH_BASE_FRAME::GetCanvas(), SCH_DRAW_PANEL::GetView(), EDA_DRAW_PANEL_GAL::GetViewControls(), EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by SCH_EDITOR_CONTROL::FindSymbolAndItem().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1181 of file eda_base_frame.cpp.

1182 {
1183  SetUserUnits( aUnits );
1185 
1186  wxCommandEvent e( UNITS_CHANGED );
1187  ProcessEventLocally( e );
1188 }
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void SetUserUnits(EDA_UNITS aUnits)

References EDA_BASE_FRAME::SetUserUnits(), and EDA_BASE_FRAME::unitsChangeRefresh().

Referenced by COMMON_TOOLS::SwitchUnits(), and COMMON_TOOLS::ToggleUnits().

◆ CheckForAutoSaveFile()

void EDA_BASE_FRAME::CheckForAutoSaveFile ( const wxFileName &  aFileName)
inherited

Check if an auto save file exists for aFileName and takes the appropriate action depending on the user input.

If an auto save file exists for aFileName, the user is prompted if they wish to replace file aFileName with the auto saved file. If the user chooses to replace the file, the backup file of aFileName is removed, aFileName is renamed to the backup file name, and the auto save file is renamed to aFileName. If user chooses to keep the existing version of aFileName, the auto save file is removed.

Parameters
aFileNameA wxFileName object containing the file name to check.

Definition at line 1069 of file eda_base_frame.cpp.

1070 {
1071  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1072 
1073  wxFileName autoSaveFileName = aFileName;
1074 
1075  // Check for auto save file.
1076  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
1077 
1078  wxLogTrace( traceAutoSave,
1079  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
1080 
1081  if( !autoSaveFileName.FileExists() )
1082  return;
1083 
1084  wxString msg = wxString::Format( _(
1085  "Well this is potentially embarrassing!\n"
1086  "It appears that the last time you were editing the file\n"
1087  "\"%s\"\n"
1088  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
1089  aFileName.GetFullName()
1090  );
1091 
1092  int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1093  this );
1094 
1095  // Make a backup of the current file, delete the file, and rename the auto save file to
1096  // the file name.
1097  if( response == wxYES )
1098  {
1099  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
1100  {
1101  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
1102  Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1103  }
1104  }
1105  else
1106  {
1107  wxLogTrace( traceAutoSave,
1108  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
1109 
1110  // Remove the auto save file when using the previous file as is.
1111  wxRemoveFile( autoSaveFileName.GetFullPath() );
1112  }
1113 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static wxString GetAutoSaveFilePrefix()

References _, Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), Pgm(), and traceAutoSave.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ ClearFileHistory()

void EDA_BASE_FRAME::ClearFileHistory ( FILE_HISTORY aFileHistory = nullptr)
inherited

Removes all files from the file history.

Parameters
aFileHistoryThe FILE_HISTORY in use. If null, the main application file history is used

Definition at line 956 of file eda_base_frame.cpp.

957 {
958  if( !aFileHistory )
959  aFileHistory = m_fileHistory;
960 
961  wxASSERT( aFileHistory );
962 
963  aFileHistory->ClearFileHistory();
964 
965  // Update the menubar to update the file history menu
966  if( GetMenuBar() )
967  {
968  ReCreateMenuBar();
969  GetMenuBar()->Refresh();
970  }
971 }
void ClearFileHistory()
Clear all entries from the file history.
FILE_HISTORY * m_fileHistory
virtual void ReCreateMenuBar()
Recreates the menu bar.

References FILE_HISTORY::ClearFileHistory(), EDA_BASE_FRAME::m_fileHistory, and EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by GERBVIEW_FRAME::OnClearDrlFileHistory(), KICAD_MANAGER_FRAME::OnClearFileHistory(), PL_EDITOR_FRAME::OnClearFileHistory(), PCB_EDIT_FRAME::OnClearFileHistory(), SCH_EDIT_FRAME::OnClearFileHistory(), GERBVIEW_FRAME::OnClearGbrFileHistory(), GERBVIEW_FRAME::OnClearJobFileHistory(), and GERBVIEW_FRAME::OnClearZipFileHistory().

◆ ClearMsgPanel()

void SYMBOL_EDIT_FRAME::ClearMsgPanel ( )
inlineoverridevirtual

Clear all messages from the message panel.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 230 of file symbol_edit_frame.h.

231  {
233  }
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.

References UpdateSymbolMsgPanelInfo().

Referenced by saveLibrary().

◆ ClearUndoORRedoList()

void SYMBOL_EDIT_FRAME::ClearUndoORRedoList ( UNDO_REDO_LIST  whichList,
int  aItemCount = -1 
)
overridevirtual

Free the undo or redo list from aList element.

  • Wrappers are deleted.
  • data pointed by wrappers are deleted if not in use in schematic i.e. when they are copy of a schematic item or they are no more in use (DELETED)
Parameters
whichList= the UNDO_REDO_CONTAINER to clear
aItemCount= the count of items to remove. < 0 for all items items are removed from the beginning of the list. So this function can be called to remove old commands

Reimplemented from EDA_BASE_FRAME.

Definition at line 1260 of file symbol_edit_frame.cpp.

1261 {
1262  if( aItemCount == 0 )
1263  return;
1264 
1265  UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
1266 
1267  for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
1268  {
1269  command->ClearListAndDeleteItems();
1270  delete command;
1271  }
1272 
1273  list.m_CommandsList.clear();
1274 }
UNDO_REDO_CONTAINER m_undoList
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
A holder to handle information on schematic or board items.
UNDO_REDO_CONTAINER m_redoList
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...

References PICKED_ITEMS_LIST::ClearListAndDeleteItems(), UNDO_REDO_CONTAINER::m_CommandsList, EDA_BASE_FRAME::m_redoList, EDA_BASE_FRAME::m_undoList, and EDA_BASE_FRAME::UNDO_LIST.

Referenced by SaveCopyInUndoList().

◆ ClearUndoRedoList()

void EDA_BASE_FRAME::ClearUndoRedoList ( )
virtualinherited

◆ CloseWindow()

void SYMBOL_EDIT_FRAME::CloseWindow ( wxCommandEvent &  event)
inline

Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:

EVT_CLOSE( SYMBOL_EDIT_FRAME::OnCloseWindow )

Definition at line 209 of file symbol_edit_frame.h.

210  {
211  // Generate a wxCloseEvent
212  Close( false );
213  }

◆ CommonSettingsChanged()

void SYMBOL_EDIT_FRAME::CommonSettingsChanged ( bool  aEnvVarsChanged,
bool  aTextVarsChanged 
)
overridevirtual

Called after the preferences dialog is run.

Reimplemented from SCH_BASE_FRAME.

Definition at line 1079 of file symbol_edit_frame.cpp.

1080 {
1081  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1082 
1084  GetCanvas()->GetGAL()->DrawGrid();
1085 
1086  RecreateToolbars();
1087 
1088  if( aEnvVarsChanged )
1089  SyncLibraries( true );
1090 
1091  Layout();
1092  SendSizeEvent();
1093 }
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void DrawGrid()
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
COLOR_SETTINGS * m_colorSettings
The current canvas type.
COLOR4D GetColor(int aLayer) const
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void SyncLibraries(bool aShowProgress, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...

References SCH_BASE_FRAME::CommonSettingsChanged(), KIGFX::GAL::DrawGrid(), SCH_BASE_FRAME::GetCanvas(), COLOR_SETTINGS::GetColor(), EDA_DRAW_PANEL_GAL::GetGAL(), LAYER_SCHEMATIC_GRID_AXES, EDA_DRAW_FRAME::m_colorSettings, EDA_DRAW_FRAME::RecreateToolbars(), KIGFX::GAL::SetAxesColor(), and SyncLibraries().

◆ config()

APP_SETTINGS_BASE * SYMBOL_EDIT_FRAME::config ( ) const
overridevirtual

Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented from EDA_BASE_FRAME.

Definition at line 290 of file symbol_edit_frame.cpp.

291 {
292  return static_cast<APP_SETTINGS_BASE*>( GetSettings() );
293 }
SYMBOL_EDITOR_SETTINGS * GetSettings() const

References GetSettings().

◆ ConfigBaseName()

wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineoverridevirtualinherited

Get the configuration base name.

This is usually the name of the frame set by CTOR, except for frames shown in multiple modes in which case the m_configName must be set to the base name so that a single configuration can be used.

Returns
a base name prefix used in Load/Save settings to build the full name of keys used in configuration.

Reimplemented from TOOLS_HOLDER.

Definition at line 358 of file eda_base_frame.h.

359  {
360  wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
361  return baseCfgName;
362  }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

Referenced by EDA_BASE_FRAME::SaveWindowSettings().

◆ CopySymbolToClipboard()

void SYMBOL_EDIT_FRAME::CopySymbolToClipboard ( )

Definition at line 778 of file symbol_editor.cpp.

779 {
780  int dummyUnit;
781  LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
783  libId.GetLibNickname() );
784 
785  if( !symbol )
786  return;
787 
788  std::unique_ptr< LIB_SYMBOL> tmp = symbol->Flatten();
789  STRING_FORMATTER formatter;
790  SCH_SEXPR_PLUGIN::FormatLibSymbol( tmp.get(), formatter );
791 
792  wxLogNull doNotLog; // disable logging of failed clipboard actions
793 
794  auto clipboard = wxTheClipboard;
795  wxClipboardLocker clipboardLock( clipboard );
796 
797  if( !clipboardLock || !clipboard->IsOpened() )
798  return;
799 
800  auto data = new wxTextDataObject( wxString( formatter.GetString().c_str(), wxConvUTF8 ) );
801  clipboard->SetData( data );
802 
803  clipboard->Flush();
804 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
SYMBOL_TREE_PANE * m_treePane
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
Definition: lib_symbol.h:96
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:332
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:168
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
const std::string & GetString()
Definition: richio.h:438
SYMBOL_LIBRARY_MANAGER * m_libMgr
LIB_TREE * GetLibTree() const
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:414

References LIB_SYMBOL::Flatten(), SCH_SEXPR_PLUGIN::FormatLibSymbol(), SYMBOL_LIBRARY_MANAGER::GetBufferedSymbol(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), SYMBOL_TREE_PANE::GetLibTree(), LIB_TREE::GetSelectedLibId(), STRING_FORMATTER::GetString(), m_libMgr, and m_treePane.

Referenced by SYMBOL_EDITOR_CONTROL::CutCopyDelete().

◆ createCanvas()

void SCH_BASE_FRAME::createCanvas ( )
inherited

Definition at line 285 of file sch_base_frame.cpp.

286 {
288 
289  // Allows only a CAIRO or OPENGL canvas:
292  {
294  }
295 
296  SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_frameSize,
299 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
static constexpr GAL_TYPE GAL_FALLBACK
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.

References EDA_DRAW_FRAME::ActivateGalCanvas(), EDA_DRAW_PANEL_GAL::GAL_FALLBACK, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, EDA_DRAW_FRAME::GetGalDisplayOptions(), EDA_DRAW_FRAME::loadCanvasTypeSetting(), EDA_DRAW_FRAME::m_canvasType, EDA_BASE_FRAME::m_frameSize, and EDA_DRAW_FRAME::SetCanvas().

Referenced by SCH_BASE_FRAME::SCH_BASE_FRAME().

◆ CreateInfoBar()

void EDA_BASE_FRAME::CreateInfoBar ( )
inherited

Definition at line 821 of file eda_base_frame.cpp.

822 {
823 #if defined( __WXOSX_MAC__ )
825 #else
826  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
827 
828  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
829 #endif
830 }
wxAuiManager m_auimgr
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
Specialization of the wxAuiPaneInfo class for KiCad panels.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
WX_INFOBAR * m_infoBar

References TOOLS_HOLDER::GetToolCanvas(), EDA_BASE_FRAME::m_auimgr, and EDA_BASE_FRAME::m_infoBar.

◆ CreateNewSymbol()

void SYMBOL_EDIT_FRAME::CreateNewSymbol ( )

Create a new symbol in the selected library.

Definition at line 382 of file symbol_editor.cpp.

383 {
385 
386  wxArrayString rootSymbols;
387  wxString lib = getTargetLib();
388 
389  if( !m_libMgr->LibraryExists( lib ) )
390  {
391  lib = SelectLibraryFromList();
392 
393  if( !m_libMgr->LibraryExists( lib ) )
394  return;
395  }
396 
397  m_libMgr->GetRootSymbolNames( lib, rootSymbols );
398 
399  rootSymbols.Sort();
400 
401  DIALOG_LIB_NEW_SYMBOL dlg( this, &rootSymbols );
402  dlg.SetMinSize( dlg.GetSize() );
403 
404  if( dlg.ShowModal() == wxID_CANCEL )
405  return;
406 
407  if( dlg.GetName().IsEmpty() )
408  {
409  wxMessageBox( _( "This new symbol has no name and cannot be created." ) );
410  return;
411  }
412 
413  wxString name = dlg.GetName();
414 
415  // Currently, symbol names cannot include a space, that breaks libraries:
416  name.Replace( " ", "_" );
417 
418  // Test if there is a symbol with this name already.
419  if( !lib.empty() && m_libMgr->SymbolExists( name, lib ) )
420  {
421  wxString msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'." ),
422  name,
423  lib );
424 
425  KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
426  errorDlg.SetOKLabel( _( "Overwrite" ) );
427  errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
428 
429  if( errorDlg.ShowModal() == wxID_CANCEL )
430  return;
431  }
432 
433  LIB_SYMBOL new_symbol( name ); // do not create symbol on the heap, it will be buffered soon
434 
435  wxString parentSymbolName = dlg.GetParentSymbolName();
436 
437  if( parentSymbolName.IsEmpty() )
438  {
439  new_symbol.GetReferenceField().SetText( dlg.GetReference() );
440  new_symbol.SetUnitCount( dlg.GetUnitCount() );
441 
442  // Initialize new_symbol.m_TextInside member:
443  // if 0, pin text is outside the body (on the pin)
444  // if > 0, pin text is inside the body
445  if( dlg.GetPinNameInside() )
446  {
447  new_symbol.SetPinNameOffset( dlg.GetPinTextPosition() );
448 
449  if( new_symbol.GetPinNameOffset() == 0 )
450  new_symbol.SetPinNameOffset( 1 );
451  }
452  else
453  {
454  new_symbol.SetPinNameOffset( 0 );
455  }
456 
457  ( dlg.GetPowerSymbol() ) ? new_symbol.SetPower() : new_symbol.SetNormal();
458  new_symbol.SetShowPinNumbers( dlg.GetShowPinNumber() );
459  new_symbol.SetShowPinNames( dlg.GetShowPinName() );
460  new_symbol.LockUnits( dlg.GetLockItems() );
461  new_symbol.SetIncludeInBom( dlg.GetIncludeInBom() );
462  new_symbol.SetIncludeOnBoard( dlg.GetIncludeOnBoard() );
463 
464  if( dlg.GetUnitCount() < 2 )
465  new_symbol.LockUnits( false );
466 
467  new_symbol.SetConversion( dlg.GetAlternateBodyStyle() );
468 
469  // must be called after loadSymbol, that calls SetShowDeMorgan, but
470  // because the symbol is empty,it looks like it has no alternate body
471  SetShowDeMorgan( dlg.GetAlternateBodyStyle() );
472  }
473  else
474  {
475  LIB_SYMBOL* parent = m_libMgr->GetAlias( parentSymbolName, lib );
476  wxCHECK( parent, /* void */ );
477  new_symbol.SetParent( parent );
478 
479  // Inherit the parent mandatory field attributes.
480  for( int id = 0; id < MANDATORY_FIELDS; ++id )
481  {
482  LIB_FIELD* field = new_symbol.GetFieldById( id );
483 
484  // the MANDATORY_FIELDS are exactly that in RAM.
485  wxCHECK( field, /* void */ );
486 
487  LIB_FIELD* parentField = parent->GetFieldById( id );
488 
489  wxCHECK( parentField, /* void */ );
490 
491  *field = *parentField;
492 
493  switch( id )
494  {
495  case REFERENCE_FIELD:
496  // parent's reference already copied
497  break;
498 
499  case VALUE_FIELD:
500  field->SetText( name );
501  break;
502 
503  case FOOTPRINT_FIELD:
504  case DATASHEET_FIELD:
505  // - footprint might be the same as parent, but might not
506  // - datasheet is most likely different
507  // - probably best to play it safe and copy neither
508  field->SetText( wxEmptyString );
509  break;
510  }
511 
512  field->SetParent( &new_symbol );
513  }
514  }
515 
516  m_libMgr->UpdateSymbol( &new_symbol, lib );
517  SyncLibraries( false );
518  LoadSymbol( name, lib, 1 );
519 }
Field Reference of part, i.e. "IC21".
void GetRootSymbolNames(const wxString &aLibName, wxArrayString &aRootSymbolNames)
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
void SetShowDeMorgan(bool show)
Field object used in symbol libraries.
Definition: lib_field.h:59
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
Define a library symbol object.
Definition: lib_symbol.h:96
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
name of datasheet
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:114
wxString getTargetLib() const
#define _(s)
wxString SelectLibraryFromList()
Display a list of loaded libraries in the symbol library and allows the user to select a library.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
Definition: lib_symbol.cpp:939
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
const char * name
Definition: DXF_plotter.cpp:56
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
SYMBOL_LIBRARY_MANAGER * m_libMgr
void SyncLibraries(bool aShowProgress, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
Field Name Module PCB, i.e. "16DIP300".

References _, ACTIONS::cancelInteractive, DATASHEET_FIELD, KIDIALOG::DoNotShowCheckbox(), FOOTPRINT_FIELD, Format(), SYMBOL_LIBRARY_MANAGER::GetAlias(), DIALOG_LIB_NEW_SYMBOL::GetAlternateBodyStyle(), LIB_SYMBOL::GetFieldById(), DIALOG_LIB_NEW_SYMBOL::GetIncludeInBom(), DIALOG_LIB_NEW_SYMBOL::GetIncludeOnBoard(), DIALOG_LIB_NEW_SYMBOL::GetLockItems(), DIALOG_LIB_NEW_SYMBOL::GetName(), DIALOG_LIB_NEW_SYMBOL::GetParentSymbolName(), DIALOG_LIB_NEW_SYMBOL::GetPinNameInside(), LIB_SYMBOL::GetPinNameOffset(), DIALOG_LIB_NEW_SYMBOL::GetPinTextPosition(), DIALOG_LIB_NEW_SYMBOL::GetPowerSymbol(), DIALOG_LIB_NEW_SYMBOL::GetReference(), LIB_SYMBOL::GetReferenceField(), SYMBOL_LIBRARY_MANAGER::GetRootSymbolNames(), DIALOG_LIB_NEW_SYMBOL::GetShowPinName(), DIALOG_LIB_NEW_SYMBOL::GetShowPinNumber(), getTargetLib(), DIALOG_LIB_NEW_SYMBOL::GetUnitCount(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), LoadSymbol(), LIB_SYMBOL::LockUnits(), m_libMgr, TOOLS_HOLDER::m_toolManager, MANDATORY_FIELDS, name, REFERENCE_FIELD, TOOL_MANAGER::RunAction(), SelectLibraryFromList(), LIB_SYMBOL::SetConversion(), LIB_SYMBOL::SetIncludeInBom(), LIB_SYMBOL::SetIncludeOnBoard(), LIB_SYMBOL::SetNormal(), EDA_ITEM::SetParent(), LIB_SYMBOL::SetParent(), LIB_SYMBOL::SetPinNameOffset(), LIB_SYMBOL::SetPower(), SetShowDeMorgan(), LIB_SYMBOL::SetShowPinNames(), LIB_SYMBOL::SetShowPinNumbers(), EDA_TEXT::SetText(), LIB_SYMBOL::SetUnitCount(), KIDIALOG::ShowModal(), SYMBOL_LIBRARY_MANAGER::SymbolExists(), SyncLibraries(), SYMBOL_LIBRARY_MANAGER::UpdateSymbol(), and VALUE_FIELD.

Referenced by SYMBOL_EDITOR_CONTROL::AddSymbol().

◆ CreateServer()

void KIWAY_PLAYER::CreateServer ( int  service,
bool  local = true 
)
inherited

Definition at line 43 of file eda_dde.cpp.

44 {
45  wxIPV4address addr;
46 
47  // Set the port number
48  addr.Service( service );
49 
50  // Listen on localhost only if requested
51  if( local )
52  addr.Hostname( HOSTNAME );
53 
54  delete m_socketServer;
55  m_socketServer = new wxSocketServer( addr );
56 
57  m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
58  m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
59  m_socketServer->Notify( true );
60 }
static const wxString HOSTNAME(wxT("localhost"))
wxSocketServer * m_socketServer
Definition: kiway_player.h:218

References HOSTNAME(), ID_EDA_SOCKET_EVENT_SERV, and KIWAY_PLAYER::m_socketServer.

Referenced by SCH::IFACE::CreateWindow().

◆ CurrentToolName()

std::string TOOLS_HOLDER::CurrentToolName ( ) const
inherited

Definition at line 100 of file tools_holder.cpp.

101 {
102  if( m_toolStack.empty() )
103  return ACTIONS::selectionTool.GetName();
104  else
105  return m_toolStack.back();
106 }
std::vector< std::string > m_toolStack
Definition: tools_holder.h:164
static TOOL_ACTION selectionTool
Definition: actions.h:153

References TOOLS_HOLDER::m_toolStack, and ACTIONS::selectionTool.

Referenced by TOOL_MANAGER::processEvent(), and TOOLS_HOLDER::ShowChangedLanguage().

◆ DeleteSymbolFromLibrary()

void SYMBOL_EDIT_FRAME::DeleteSymbolFromLibrary ( )

Definition at line 737 of file symbol_editor.cpp.

738 {
739  LIB_ID libId = GetTargetLibId();
740 
741  if( m_libMgr->IsSymbolModified( libId.GetLibItemName(), libId.GetLibNickname() )
742  && !IsOK( this, wxString::Format( _( "The symbol '%s' has been modified.\n"
743  "Do you want to remove it from the library?" ),
744  libId.GetUniStringLibItemName() ) ) )
745  {
746  return;
747  }
748 
749  if( m_libMgr->HasDerivedSymbols( libId.GetLibItemName(), libId.GetLibNickname() ) )
750  {
751  wxString msg;
752 
753  msg.Printf( _( "The symbol %s is used to derive other symbols.\n"
754  "Deleting this symbol will delete all of the symbols derived from it.\n\n"
755  "Do you wish to delete this symbol and all of its derivatives?" ),
756  libId.GetLibItemName().wx_str() );
757 
758  wxMessageDialog::ButtonLabel yesButtonLabel( _( "Delete Symbol" ) );
759  wxMessageDialog::ButtonLabel noButtonLabel( _( "Keep Symbol" ) );
760 
761  wxMessageDialog dlg( this, msg, _( "Warning" ),
762  wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTER );
763  dlg.SetYesNoLabels( yesButtonLabel, noButtonLabel );
764 
765  if( dlg.ShowModal() == wxID_NO )
766  return;
767  }
768 
769  if( isCurrentSymbol( libId ) )
770  emptyScreen();
771 
772  m_libMgr->RemoveSymbol( libId.GetLibItemName(), libId.GetLibNickname() );
773 
775 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
SYMBOL_TREE_PANE * m_treePane
bool RemoveSymbol(const wxString &aName, const wxString &aLibrary)
Remove the symbol from the symbol buffer.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
bool IsSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
bool HasDerivedSymbols(const wxString &aSymbolName, const wxString &aLibraryName)
Check if symbol aSymbolName in library aLibraryName is a root symbol that has derived symbols.
bool isCurrentSymbol(const LIB_ID &aLibId) const
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:234
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
LIB_ID GetTargetLibId() const
wxString wx_str() const
Definition: utf8.cpp:46
SYMBOL_LIBRARY_MANAGER * m_libMgr
void emptyScreen()
Return either the symbol selected in the symbol tree, if context menu is active or the currently modi...
LIB_TREE * GetLibTree() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:315
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition: lib_id.h:114

References _, emptyScreen(), Format(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), SYMBOL_TREE_PANE::GetLibTree(), GetTargetLibId(), LIB_ID::GetUniStringLibItemName(), SYMBOL_LIBRARY_MANAGER::HasDerivedSymbols(), isCurrentSymbol(), IsOK(), SYMBOL_LIBRARY_MANAGER::IsSymbolModified(), m_libMgr, m_treePane, LIB_TREE::RefreshLibTree(), SYMBOL_LIBRARY_MANAGER::RemoveSymbol(), and UTF8::wx_str().

Referenced by SYMBOL_EDITOR_CONTROL::CutCopyDelete().

◆ Destroy()

◆ DismissModal()

void KIWAY_PLAYER::DismissModal ( bool  aRetVal,
const wxString &  aResult = wxEmptyString 
)
inherited

Definition at line 166 of file kiway_player.cpp.

167 {
168  m_modal_ret_val = aRetVal;
169  m_modal_string = aResult;
170 
171  if( m_modal_loop )
172  {
173  m_modal_loop->Exit();
174  m_modal_loop = nullptr; // this marks it as dismissed.
175  }
176 
177  Show( false );
178 }
bool m_modal_ret_val
Definition: kiway_player.h:216
wxString m_modal_string
Definition: kiway_player.h:215
WX_EVENT_LOOP * m_modal_loop
< Points to nested event_loop. NULL means not modal and dismissed.
Definition: kiway_player.h:213

References KIWAY_PLAYER::m_modal_loop, KIWAY_PLAYER::m_modal_ret_val, and KIWAY_PLAYER::m_modal_string.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SYMBOL_VIEWER_FRAME::doCloseWindow(), FOOTPRINT_VIEWER_FRAME::doCloseWindow(), FOOTPRINT_WIZARD_FRAME::doCloseWindow(), FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint(), and SYMBOL_VIEWER_FRAME::FinishModal().

◆ DisplayGridMsg()

void EDA_DRAW_FRAME::DisplayGridMsg ( )
virtualinherited

Display current grid size in the status bar.

Reimplemented in PCB_BASE_FRAME, GERBVIEW_FRAME, and PL_EDITOR_FRAME.

Definition at line 520 of file eda_draw_frame.cpp.

521 {
522  wxString line;
523 
524  line.Printf( "grid %s",
525  MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x,
526  false ) );
527 
528  SetStatusText( line, 4 );
529 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References EDA_DRAW_FRAME::GetCanvas(), EDA_BASE_FRAME::GetUserUnits(), and MessageTextFromValue().

Referenced by SCH_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

void EDA_DRAW_FRAME::DisplayToolMsg ( const wxString &  msg)
overridevirtualinherited

Reimplemented from TOOLS_HOLDER.

Definition at line 514 of file eda_draw_frame.cpp.

515 {
516  SetStatusText( msg, 6 );
517 }

Referenced by EDIT_TOOL::Duplicate(), and PCB_CONTROL::Paste().

◆ DisplayUnitsMsg()

void EDA_DRAW_FRAME::DisplayUnitsMsg ( )
inherited

Display current unit pane in the status bar.

Definition at line 532 of file eda_draw_frame.cpp.

533 {
534  wxString msg;
535 
536  switch( m_userUnits )
537  {
538  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
539  case EDA_UNITS::MILS: msg = _( "mils" ); break;
540  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
541  default: msg = _( "Units" ); break;
542  }
543 
544  SetStatusText( msg, 5 );
545 }
#define _(s)
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.

References _, INCHES, EDA_BASE_FRAME::m_userUnits, MILLIMETRES, and MILS.

Referenced by EDA_DRAW_FRAME::UpdateGridSelectBox(), SCH_BASE_FRAME::UpdateStatusBar(), and EDA_DRAW_FRAME::UpdateStatusBar().

◆ doAutoSave()

bool EDA_BASE_FRAME::doAutoSave ( )
protectedvirtualinherited

This should be overridden by the derived class to handle the auto save feature.

Returns
true if the auto save was successful otherwise false.

Reimplemented in SCH_EDIT_FRAME, and PCB_EDIT_FRAME.

Definition at line 323 of file eda_base_frame.cpp.

324 {
325  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
326 }

Referenced by EDA_BASE_FRAME::onAutoSaveTimer().

◆ doCloseWindow()

void SYMBOL_EDIT_FRAME::doCloseWindow ( )
overridevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 541 of file symbol_edit_frame.cpp.

542 {
543  Destroy();
544 }
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.

References KIWAY_PLAYER::Destroy().

◆ DuplicateSymbol()

void SYMBOL_EDIT_FRAME::DuplicateSymbol ( bool  aFromClipboard)

Insert a duplicate symbol.

If aFromClipboard is true then action is a paste.

Definition at line 807 of file symbol_editor.cpp.

808 {
809  int dummyUnit;
810  LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
811  wxString lib = libId.GetLibNickname();
812 
813  if( !m_libMgr->LibraryExists( lib ) )
814  return;
815 
816  LIB_SYMBOL* srcSymbol = nullptr;
817  LIB_SYMBOL* newSymbol = nullptr;
818 
819  if( aFromClipboard )
820  {
821  wxLogNull doNotLog; // disable logging of failed clipboard actions
822 
823  auto clipboard = wxTheClipboard;
824  wxClipboardLocker clipboardLock( clipboard );
825 
826  if( !clipboardLock || ! clipboard->IsSupported( wxDF_TEXT ) )
827  return;
828 
829  wxTextDataObject data;
830  clipboard->GetData( data );
831  wxString symbolSource = data.GetText();
832 
833  STRING_LINE_READER reader( TO_UTF8( symbolSource ), "Clipboard" );
834 
835  try
836  {
837  newSymbol = SCH_SEXPR_PLUGIN::ParseLibSymbol( reader );
838  }
839  catch( IO_ERROR& e )
840  {
841  wxLogMessage( "Can not paste: %s", e.Problem() );
842  return;
843  }
844  }
845  else
846  {
847  srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib );
848 
849  wxCHECK( srcSymbol, /* void */ );
850 
851  newSymbol = new LIB_SYMBOL( *srcSymbol );
852 
853  // Derive from same parent.
854  if( srcSymbol->IsAlias() )
855  {
856  std::shared_ptr< LIB_SYMBOL > srcParent = srcSymbol->GetParent().lock();
857 
858  wxCHECK( srcParent, /* void */ );
859 
860  newSymbol->SetParent( srcParent.get() );
861  }
862  }
863 
864  if( !newSymbol )
865  return;
866 
867  ensureUniqueName( newSymbol, lib );
868  m_libMgr->UpdateSymbol( newSymbol, lib );
869 
870  LoadOneLibrarySymbolAux( newSymbol, lib, GetUnit(), GetConvert() );
871 
872  SyncLibraries( false );
873  m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, newSymbol->GetName() ) );
874 
875  delete newSymbol;
876 }
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:124
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
wxString GetName() const override
Definition: lib_symbol.h:133
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool IsAlias() const
Definition: lib_symbol.h:172
void ensureUniqueName(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
SYMBOL_TREE_PANE * m_treePane
bool LoadOneLibrarySymbolAux(LIB_SYMBOL *aLibEntry, const wxString &aLibrary, int aUnit, int aConvert)
Create a copy of aLibEntry into memory.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
Definition: lib_symbol.h:96
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static LIB_SYMBOL * ParseLibSymbol(LINE_READER &aReader, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:168
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
void SetParent(LIB_SYMBOL *aParent=nullptr)
Definition: lib_symbol.cpp:323
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
SYMBOL_LIBRARY_MANAGER * m_libMgr
LIB_TREE * GetLibTree() const
void SyncLibraries(bool aShowProgress, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:193

References ensureUniqueName(), SYMBOL_LIBRARY_MANAGER::GetBufferedSymbol(), GetConvert(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), SYMBOL_TREE_PANE::GetLibTree(), LIB_SYMBOL::GetName(), LIB_SYMBOL::GetParent(), LIB_TREE::GetSelectedLibId(), GetUnit(), LIB_SYMBOL::IsAlias(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), LoadOneLibrarySymbolAux(), m_libMgr, m_treePane, SCH_SEXPR_PLUGIN::ParseLibSymbol(), IO_ERROR::Problem(), LIB_TREE::SelectLibId(), LIB_SYMBOL::SetParent(), SyncLibraries(), TO_UTF8, and SYMBOL_LIBRARY_MANAGER::UpdateSymbol().

Referenced by SYMBOL_EDITOR_CONTROL::DuplicateSymbol().

◆ eeconfig()

EESCHEMA_SETTINGS * SCH_BASE_FRAME::eeconfig ( ) const
inherited

Definition at line 116 of file sch_base_frame.cpp.

117 {
118  return dynamic_cast<EESCHEMA_SETTINGS*>( config() );
119 }
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.

References EDA_BASE_FRAME::config().

Referenced by SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes(), DIALOG_BOM::DIALOG_BOM(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::editFieldText(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_EDIT_FRAME::GetSchematicJunctionSize(), SCH_EDIT_FRAME::GetShowAllPins(), DIALOG_BOM::installGeneratorsList(), SCH_EDIT_FRAME::LoadSettings(), EE_SELECTION_TOOL::Main(), SCH_EDIT_TOOL::Mirror(), DIALOG_PRINT_USING_PRINTER::OnMonochromeChecked(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_PRINTOUT::PrintPage(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Rotate(), DIALOG_PRINT_USING_PRINTER::SavePrintOptions(), SCH_EDIT_FRAME::SaveSettings(), EE_SELECTION_TOOL::Selectable(), SCH_EDIT_FRAME::SelectUnit(), SCH_EDIT_FRAME::setupUIConditions(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_EDITOR_CONTROL::ToggleForceHV(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow(), DIALOG_PRINT_USING_PRINTER::TransferDataToWindow(), and DIALOG_BOM::~DIALOG_BOM().

◆ emptyScreen()

void SYMBOL_EDIT_FRAME::emptyScreen ( )

Return either the symbol selected in the symbol tree, if context menu is active or the currently modified symbol.

Definition at line 1067 of file symbol_edit_frame.cpp.

1068 {
1070  SetCurLib( wxEmptyString );
1071  SetCurSymbol( nullptr, false );
1075  Refresh();
1076 }
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
void SetScreen(BASE_SCREEN *aScreen) override
SYMBOL_TREE_PANE * m_treePane
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:205
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
LIB_TREE * GetLibTree() const
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()

References EDA_BASE_FRAME::ClearUndoRedoList(), SYMBOL_TREE_PANE::GetLibTree(), m_dummyScreen, TOOLS_HOLDER::m_toolManager, m_treePane, Refresh(), TOOL_MANAGER::RunAction(), SetCurLib(), SetCurSymbol(), SetScreen(), LIB_TREE::Unselect(), and ACTIONS::zoomFitScreen.

Referenced by DeleteSymbolFromLibrary(), and Revert().

◆ ensureUniqueName()

void SYMBOL_EDIT_FRAME::ensureUniqueName ( LIB_SYMBOL aSymbol,
const wxString &  aLibrary 
)
private

Definition at line 879 of file symbol_editor.cpp.

880 {
881  wxCHECK( aSymbol, /* void */ );
882 
883  int i = 1;
884  wxString newName = aSymbol->GetName();
885 
886  // Append a number to the name until the name is unique in the library.
887  while( m_libMgr->SymbolExists( newName, aLibrary ) )
888  newName.Printf( "%s_%d", aSymbol->GetName(), i++ );
889 
890  aSymbol->SetName( newName );
891 }
wxString GetName() const override
Definition: lib_symbol.h:133
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:314
SYMBOL_LIBRARY_MANAGER * m_libMgr

References LIB_SYMBOL::GetName(), m_libMgr, LIB_SYMBOL::SetName(), and SYMBOL_LIBRARY_MANAGER::SymbolExists().

Referenced by DuplicateSymbol().

◆ ensureWindowIsOnScreen()

void EDA_BASE_FRAME::ensureWindowIsOnScreen ( )
protectedinherited

Definition at line 637 of file eda_base_frame.cpp.

638 {
639  wxDisplay display( wxDisplay::GetFromWindow( this ) );
640  wxRect clientSize = display.GetClientArea();
641  wxPoint pos = GetPosition();
642  wxSize size = GetWindowSize();
643 
644  wxLogTrace( traceDisplayLocation,
645  "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d", clientSize.x, clientSize.y,
646  clientSize.width, clientSize.height );
647 
648  if( pos.y < clientSize.y )
649  {
650  wxLogTrace( traceDisplayLocation,
651  "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d", pos.y,
652  clientSize.y );
653  pos.y = clientSize.y;
654  }
655 
656  if( pos.x < clientSize.x )
657  {
658  wxLogTrace( traceDisplayLocation,
659  "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d", pos.x,
660  clientSize.x );
661  pos.x = clientSize.x;
662  }
663 
664  if( pos.x + size.x - clientSize.x > clientSize.width )
665  {
666  int newWidth = clientSize.width - ( pos.x - clientSize.x );
667  wxLogTrace( traceDisplayLocation,
668  "ensureWindowIsOnScreen: effective width %d above available %d, setting to %d",
669  pos.x + size.x, clientSize.width, newWidth );
670  size.x = newWidth;
671  }
672 
673  if( pos.y + size.y - clientSize.y > clientSize.height )
674  {
675  int newHeight = clientSize.height - ( pos.y - clientSize.y );
676  wxLogTrace( traceDisplayLocation,
677  "ensureWindowIsOnScreen: effective height %d above available %d, setting to %d",
678  pos.y + size.y, clientSize.height, newHeight );
679  size.y = newHeight;
680  }
681 
682  wxLogTrace( traceDisplayLocation, "Updating window position (%d, %d) with size (%d, %d)",
683  pos.x, pos.y, size.x, size.y );
684 
685  SetSize( pos.x, pos.y, size.x, size.y );
686 }
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.

References EDA_BASE_FRAME::GetWindowSize(), and traceDisplayLocation.

Referenced by EDA_BASE_FRAME::OnSize().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

Definition at line 289 of file eda_draw_frame.cpp.

290 {
291  if( m_messagePanel )
293 }
EDA_MSG_PANEL * m_messagePanel
void EraseMsgBox()
Definition: msgpanel.cpp:198

References EDA_MSG_PANEL::EraseMsgBox(), and EDA_DRAW_FRAME::m_messagePanel.

Referenced by GERBVIEW_CONTROL::UpdateMessagePanel().

◆ ExecuteRemoteCommand()

virtual void KIWAY_PLAYER::ExecuteRemoteCommand ( const char *  cmdline)
inlinevirtualinherited

Execute a remote command sent via socket (to port KICAD_PCB_PORT_SERVICE_NUMBER, currently 4242).

Subclasses should override to implement actual command handlers.

Reimplemented in SCH_EDIT_FRAME, and PCB_EDIT_FRAME.

Definition at line 196 of file kiway_player.h.

196 {}

Referenced by KIWAY_PLAYER::OnSockRequest().

◆ ExportSymbol()

void SYMBOL_EDIT_FRAME::ExportSymbol ( )

Definition at line 112 of file symbol_editor_import_export.cpp.

113 {
114  wxString msg, title;
115  LIB_SYMBOL* symbol = getTargetSymbol();
116 
117  if( !symbol )
118  {
119  ShowInfoBarError( _( "There is no symbol selected to save." ) );
120  return;
121  }
122 
123  wxFileName fn;
124 
125  fn.SetName( symbol->GetName().Lower() );
126  fn.SetExt( KiCadSymbolLibFileExtension );
127 
128  wxFileDialog dlg( this, _( "Export Symbol" ), m_mruPath, fn.GetFullName(),
129  KiCadSymbolLibFileWildcard(), wxFD_SAVE );
130 
131  if( dlg.ShowModal() == wxID_CANCEL )
132  return;
133 
134  fn = dlg.GetPath();
135  fn.MakeAbsolute();
136 
137  LIB_SYMBOL* old_symbol = nullptr;
138  SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
139  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( pluginType ) );
140 
141  if( fn.FileExists() )
142  {
143  try
144  {
145  old_symbol = pi->LoadSymbol( fn.GetFullPath(), symbol->GetName() );
146  }
147  catch( const IO_ERROR& ioe )
148  {
149  msg.Printf( _( "Error occurred attempting to load symbol library file '%s'." ),
150  fn.GetFullPath() );
151  DisplayErrorMessage( this, msg, ioe.What() );
152  return;
153  }
154 
155  if( old_symbol )
156  {
157  msg.Printf( _( "Symbol %s already exists in library '%s'." ),
158  UnescapeString( symbol->GetName() ),
159  fn.GetFullName() );
160 
161  KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
162  errorDlg.SetOKLabel( _( "Overwrite" ) );
163  errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
164 
165  if( errorDlg.ShowModal() == wxID_CANCEL )
166  return;
167  }
168  }
169 
170  if( fn.Exists() && !fn.IsDirWritable() )
171  {
172  msg.Printf( _( "Insufficient permissions to save library '%s'." ),
173  fn.GetFullPath() );
174  DisplayError( this, msg );
175  return;
176  }
177 
178  try
179  {
180  if( !fn.FileExists() )
181  pi->CreateSymbolLib( fn.GetFullPath() );
182 
183  // The flattened symbol is most likely what the user would want. As some point in
184  // the future as more of the symbol library inheritance is implemented, this may have
185  // to be changes to save symbols of inherited symbols.
186  pi->SaveSymbol( fn.GetFullPath(), symbol->Flatten().release() );
187  }
188  catch( const IO_ERROR& ioe )
189  {
190  msg.Printf( _( "Failed to create symbol library file '%s'." ), fn.GetFullPath() );
191  DisplayErrorMessage( this, msg, ioe.What() );
192  msg.Printf( _( "Error creating symbol library '%s'." ), fn.GetFullName() );
193  SetStatusText( msg );
194  return;
195  }
196 
197  m_mruPath = fn.GetPath();
198 
199  msg.Printf( _( "Symbol %s saved to library '%s'." ),
200  UnescapeString( symbol->GetName() ),
201  fn.GetFullPath() );
202  SetStatusText( msg );
203 
204  // See if the user wants it added to a library table (global or project)
205  SYMBOL_LIB_TABLE* libTable = selectSymLibTable( true );
206 
207  if( libTable )
208  {
209  if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
210  {
211  DisplayError( this, _( "Could not open the library file." ) );
212  return;
213  }
214 
215  bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
216  saveSymbolLibTables( globalTable, !globalTable );
217  }
218 }
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath)
Return a plugin type given a symbol library using the file extension of aLibPath.
Definition: sch_io_mgr.cpp:151
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:271
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
wxString m_mruPath
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:284
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
wxString GetName() const override
Definition: lib_symbol.h:133
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
Define a library symbol object.
Definition: lib_symbol.h:96
SYMBOL_LIB_TABLE * selectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:332
LIB_SYMBOL * getTargetSymbol() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
#define _(s)
wxString KiCadSymbolLibFileWildcard()
wxString UnescapeString(const wxString &aSource)
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:479
SYMBOL_LIBRARY_MANAGER * m_libMgr
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
const std::string KiCadSymbolLibFileExtension

References _, SYMBOL_LIBRARY_MANAGER::AddLibrary(), DisplayError(), DisplayErrorMessage(), KIDIALOG::DoNotShowCheckbox(), LIB_SYMBOL::Flatten(), SYMBOL_LIB_TABLE::GetGlobalLibTable(), LIB_SYMBOL::GetName(), getTargetSymbol(), SCH_IO_MGR::GuessPluginTypeFromLibPath(), KiCadSymbolLibFileExtension, KiCadSymbolLibFileWildcard(), m_libMgr, EDA_BASE_FRAME::m_mruPath, SCH_BASE_FRAME::saveSymbolLibTables(), selectSymLibTable(), EDA_BASE_FRAME::ShowInfoBarError(), KIDIALOG::ShowModal(), UnescapeString(), and IO_ERROR::What().

◆ FinishAUIInitialization()

void EDA_BASE_FRAME::FinishAUIInitialization ( )
inherited

Definition at line 833 of file eda_base_frame.cpp.

834 {
835 #if defined( __WXOSX_MAC__ )
836  m_auimgr.Update();
837 #else
838  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
839  // hiding it.
840  m_auimgr.Update();
841 
842  // We don't want the infobar displayed right away
843  m_auimgr.GetPane( "InfoBar" ).Hide();
844  m_auimgr.Update();
845 #endif
846 }
wxAuiManager m_auimgr

References EDA_BASE_FRAME::m_auimgr.

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const wxPoint &  aPos)
inherited

Useful to focus on a particular location, in find functions.

Move the graphic cursor (crosshair cursor) at a given coordinate and reframes the drawing if the requested point is out of view or if center on location is requested.

Parameters
aPosis the point to go to.

Definition at line 851 of file eda_draw_frame.cpp.

852 {
853  bool centerView = false;
854  BOX2D r = GetCanvas()->GetView()->GetViewport();
855 
856  // Center if we're off the current view, or within 10% of its edge
857  r.Inflate( - (int) r.GetWidth() / 10 );
858 
859  if( !r.Contains( aPos ) )
860  centerView = true;
861 
862  // Center if we're behind an obscuring dialog, or within 10% of its edge
863  wxWindow* dialog = findDialog( GetChildren() );
864 
865  if( dialog )
866  {
867  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
868  dialog->GetSize() );
869  dialogRect.Inflate( dialogRect.GetWidth() / 10 );
870 
871  if( dialogRect.Contains( (wxPoint) GetCanvas()->GetView()->ToScreen( aPos ) ) )
872  centerView = true;
873  }
874 
875  if( centerView )
876  {
877  // If a dialog partly obscures the window, then center on the uncovered area.
878  if( dialog )
879  {
880  BOX2D dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
881  dialog->GetSize() );
882  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
883  }
884  else
885  GetCanvas()->GetView()->SetCenter( aPos );
886  }
887 
889 }
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:515
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:581
coord_type GetWidth() const
Definition: box2.h:180
bool Contains(const Vec &aPoint) const
Definition: box2.h:134
wxWindow * findDialog(wxWindowList &aList)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:281

References BOX2< Vec >::Contains(), findDialog(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetView(), EDA_DRAW_PANEL_GAL::GetViewControls(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW_CONTROLS::SetCrossHairCursorPosition().

Referenced by PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindNext(), PCB_BASE_FRAME::FocusOnItem(), SCH_EDIT_FRAME::FocusOnItem(), and DIALOG_FIND::search().

◆ FreezeLibraryTree()

void SYMBOL_EDIT_FRAME::FreezeLibraryTree ( )

Definition at line 592 of file symbol_edit_frame.cpp.

593 {
594  m_treePane->Freeze();
595  m_libMgr->GetAdapter()->Freeze();
596 }
SYMBOL_TREE_PANE * m_treePane
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
SYMBOL_LIBRARY_MANAGER * m_libMgr

References SYMBOL_LIBRARY_MANAGER::GetAdapter(), m_libMgr, and m_treePane.

Referenced by saveLibrary().

◆ GetAboutTitle()

const wxString& EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

◆ GetAutoSaveFilePrefix()

static wxString EDA_BASE_FRAME::GetAutoSaveFilePrefix ( )
inlinestaticprotectedinherited

◆ GetAutoSaveInterval()

int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 204 of file eda_base_frame.h.

204 { return m_autoSaveInterval; }

References EDA_BASE_FRAME::m_autoSaveInterval.

◆ GetCanvas()

SCH_DRAW_PANEL * SCH_BASE_FRAME::GetCanvas ( ) const
overridevirtualinherited

Return a pointer to GAL-based canvas of given EDA draw frame.

Returns
Pointer to GAL-based canvas.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 272 of file sch_base_frame.cpp.

273 {
274  return static_cast<SCH_DRAW_PANEL*>( EDA_DRAW_FRAME::GetCanvas() );
275 }
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.

References EDA_DRAW_FRAME::GetCanvas().

Referenced by SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_EDIT_FRAME::AddJunction(), SCH_BASE_FRAME::AddToScreen(), SCH_EDIT_FRAME::AnnotateSymbols(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_EDIT_TOOL::BreakWire(), SCH_BASE_FRAME::CenterScreen(), SYMBOL_VIEWER_FRAME::ClickOnCmpList(), SYMBOL_VIEWER_FRAME::CommonSettingsChanged(), SCH_BASE_FRAME::CommonSettingsChanged(), CommonSettingsChanged(), DIALOG_CHOOSE_SYMBOL::ConstructRightPanel(), SCH_EDIT_FRAME::DeleteAnnotation(), SCH_EDIT_FRAME::DisplayCurrentSheet(), SYMBOL_VIEWER_FRAME::doCloseWindow(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EE_SELECTION_TOOL::doSelectionMenu(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), SYMBOL_EDITOR_EDIT_TOOL::editGraphicProperties(), SYMBOL_EDITOR_EDIT_TOOL::editTextProperties(), SCH_EDITOR_CONTROL::EnterSheet(), DIALOG_ERC::ExcludeMarker(), EE_INSPECTION_TOOL::ExcludeMarker(), SCH_EDITOR_CONTROL::FindNext(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), SCH_EDIT_FRAME::GetDocumentExtents(), SCH_BASE_FRAME::GetRenderSettings(), SCH_BASE_FRAME::HardRedraw(), SCH_EDIT_FRAME::HardRedraw(), SCH_EDITOR_CONTROL::ImportFPAssignments(), SCH_EDIT_TOOL::Init(), SCH_EDIT_FRAME::KiwayMailIn(), SCH_EDITOR_CONTROL::LeaveSheet(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), DIALOG_MIGRATE_BUSES::onAcceptClicked(), DIALOG_ANNOTATE::OnApplyClick(), DIALOG_ERC::OnEraseDrcMarkersClick(), DIALOG_ERC::OnERCItemRClick(), EE_SELECTION_TOOL::OnIdle(), DIALOG_MIGRATE_BUSES::onItemSelected(), SCH_EDIT_FRAME::OnModify(), SCH_EDIT_FRAME::OnPageSettingsChange(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), HIERARCHY_NAVIG_DLG::onSelectSheetPath(), DIALOG_UPDATE_FROM_PCB::OnUpdateClick(), SYMBOL_TREE_PANE::onUpdateUI(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_FRAME::PutDataInPreviousState(), RebuildView(), SCH_EDIT_FRAME::RecalculateConnections(), SCH_EDIT_FRAME::RecomputeIntersheetRefs(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), SCH_EDITOR_CONTROL::Redo(), DIALOG_ERC::redrawDrawPanel(), SCH_BASE_FRAME::RedrawScreen(), SCH_BASE_FRAME::RefreshSelection(), SCH_EDITOR_CONTROL::RemapSymbols(), SCH_BASE_FRAME::RemoveFromScreen(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDITOR_CONTROL::RescueLegacyProject(), SCH_EDITOR_CONTROL::rescueProject(), SCH_EDITOR_CONTROL::RescueSymbolLibTableProject(), SCH_EDIT_FRAME::RollbackSchematicFromUndo(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SetCurrentSheet(), SetCurSymbol(), EE_POINT_EDITOR::setEditedPoint(), SCH_EDIT_FRAME::SetScreen(), SYMBOL_VIEWER_FRAME::SetSelectedLibrary(), SYMBOL_VIEWER_FRAME::setupTools(), setupTools(), SCH_EDIT_FRAME::setupTools(), SYMBOL_EDITOR_CONTROL::ShowElectricalTypes(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SwitchCanvas(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), SCH_BASE_FRAME::SyncView(), SCH_EDIT_FRAME::TestDanglingEnds(), DIALOG_ERC::testErc(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_SETUP_FORMATTING::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataFromWindow(), PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow(), DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SCH_EDITOR_CONTROL::Undo(), SCH_EDITOR_CONTROL::UpdateFind(), SCH_BASE_FRAME::UpdateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), SYMBOL_VIEWER_FRAME::updatePreviewSymbol(), SCH_BASE_FRAME::UpdateStatusBar(), SCH_EDIT_FRAME::~SCH_EDIT_FRAME(), and SYMBOL_VIEWER_FRAME::~SYMBOL_VIEWER_FRAME().

◆ GetColorSettings()

COLOR_SETTINGS * SYMBOL_EDIT_FRAME::GetColorSettings ( ) const
overridevirtual

Returns a pointer to the active color theme settings.

Reimplemented from SCH_BASE_FRAME.

Definition at line 296 of file symbol_edit_frame.cpp.

297 {
298  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
299 
300  if( GetSettings()->m_UseEeschemaColorSettings )
302  else
303  return mgr.GetColorSettings( GetSettings()->m_ColorTheme );
304 }
SYMBOL_EDITOR_SETTINGS * GetSettings() const
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184

References SETTINGS_MANAGER::GetAppSettings(), SETTINGS_MANAGER::GetColorSettings(), GetSettings(), APP_SETTINGS_BASE::m_ColorTheme, and Pgm().

Referenced by SVGPlotSymbol().

◆ GetConvert()

◆ GetCurLib()

wxString SYMBOL_EDIT_FRAME::GetCurLib ( ) const

The nickname of the current library being edited and empty string if none.

Definition at line 650 of file symbol_edit_frame.cpp.

651 {
652  wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
653 
654  if( !libNickname.empty() )
655  {
656  if( !Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
657  {
658  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
659  libNickname = wxEmptyString;
660  }
661  }
662 
663  return libNickname;
664 }
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:212
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:227

References PROJECT::GetRString(), KIWAY_HOLDER::Prj(), PROJECT::SCH_LIBEDIT_CUR_LIB, and PROJECT::SetRString().

Referenced by GetSymbolFromRedoList(), GetSymbolFromUndoList(), LoadSymbolFromCurrentLib(), SetCurLib(), storeCurrentSymbol(), SyncLibraries(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow(), UpdateAfterSymbolProperties(), and updateTitle().

◆ GetCurrentFileName()

virtual wxString EDA_BASE_FRAME::GetCurrentFileName ( ) const
inlinevirtualinherited

Get the full filename + path of the currently opened file in the frame.

If no file is open, an empty string is returned.

Returns
the filename and full path to the open file

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, PL_EDITOR_FRAME, and KICAD_MANAGER_FRAME.

Definition at line 439 of file eda_base_frame.h.

439 { return wxEmptyString; }

Referenced by EDA_BASE_FRAME::SaveSettings().

◆ GetCurrentSelection()

SELECTION & SYMBOL_EDIT_FRAME::GetCurrentSelection ( )
overridevirtual

Get the current selection from the canvas area.

Returns
the current selection.

Reimplemented from TOOLS_HOLDER.

Definition at line 1277 of file symbol_edit_frame.cpp.

1278 {
1279  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1280 }
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158

References TOOL_MANAGER::GetTool(), and TOOLS_HOLDER::m_toolManager.

◆ GetCurrentTreeNode()

LIB_TREE_NODE * SYMBOL_EDIT_FRAME::GetCurrentTreeNode ( ) const

◆ GetCurSymbol()

LIB_SYMBOL* SYMBOL_EDIT_FRAME::GetCurSymbol ( ) const
inline

◆ GetDocumentExtents()

const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents ( bool  aIncludeAllVisible = true) const
overridevirtual

Returns bbox of document with option to not include some items.

Used most commonly by "Zoom to Fit" and "Zoom to Objects". In Eeschema for "Zoom to Fit" it's passed "true" to include drawing sheet border, and "false" by "Zoom To Objects" to ignore drawing sheet border. In Pcbnew, false makes it ignore any items outside the PCB edge such as fabrication notes.

Parameters
aIncludeAllVisibleTrue to include everything visible in bbox calculations, false to ignore some visible items (program dependent).
Returns
Bounding box of the document (ignoring some items as requested).

Reimplemented from EDA_DRAW_FRAME.

Definition at line 1151 of file symbol_edit_frame.cpp.

1152 {
1153  if( !m_symbol )
1154  {
1155  return BOX2I( VECTOR2I( Mils2iu( -100 ), Mils2iu( -100 ) ),
1156  VECTOR2I( Mils2iu( 200 ), Mils2iu( 200 ) ) );
1157  }
1158  else
1159  {
1160  EDA_RECT boundingBox = m_symbol->Flatten()->GetUnitBoundingBox( m_unit, m_convert );
1162  boundingBox.GetHeight() ) );
1163  }
1164 }
int m_convert
Flag if the symbol being edited was loaded directly from a schematic.
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:332
BOX2I boundingBox(T aObject)
Used by SHAPE_INDEX to get the bounding box of a generic T object.
Definition: shape_index.h:62
coord_type GetWidth() const
Definition: box2.h:180
Handle the component boundary box.
Definition: eda_rect.h:42
coord_type GetHeight() const
Definition: box2.h:181
const Vec & GetOrigin() const
Definition: box2.h:176

References boundingBox(), LIB_SYMBOL::Flatten(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), m_convert, m_symbol, and m_unit.

◆ GetDoImmediateActions()

bool TOOLS_HOLDER::GetDoImmediateActions ( ) const
inlineinherited

Indicate that hotkeys should perform an immediate action even if another tool is currently active.

If false, the first hotkey should select the relevant tool.

Definition at line 129 of file tools_holder.h.

129 { return m_immediateActions; }
bool m_immediateActions
Definition: tools_holder.h:171

References TOOLS_HOLDER::m_immediateActions.

◆ GetDragAction()

MOUSE_DRAG_ACTION TOOLS_HOLDER::GetDragAction ( ) const
inlineinherited

Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.

Definition at line 135 of file tools_holder.h.

135 { return m_dragAction; }
MOUSE_DRAG_ACTION m_dragAction
Definition: tools_holder.h:175

References TOOLS_HOLDER::m_dragAction.

Referenced by PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), and PCB_SELECTION_TOOL::Main().

◆ GetDrawBgColor()

COLOR4D SCH_BASE_FRAME::GetDrawBgColor ( ) const
overridevirtualinherited

Reimplemented from EDA_DRAW_FRAME.

Definition at line 436 of file sch_base_frame.cpp.

437 {
439 }
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
COLOR4D GetColor(int aLayer) const

References COLOR_SETTINGS::GetColor(), SCH_BASE_FRAME::GetColorSettings(), and LAYER_SCHEMATIC_BACKGROUND.

Referenced by SCH_PRINTOUT::PrintPage().

◆ GetFileFromHistory()

wxString EDA_BASE_FRAME::GetFileFromHistory ( int  cmdId,
const wxString &  type,
FILE_HISTORY aFileHistory = nullptr 
)
inherited

Fetches the file name from the file history list.

This removes the selected file, if this file does not exist. The menu is also updated, if #FILE_HISTORY::UseMenu was called at initialization time.

Parameters
cmdIdThe command ID associated with the aFileHistory object.
typePlease document me!
aFileHistoryThe FILE_HISTORY in use. If null, the main application file history is used
Returns
a wxString containing the selected filename

Definition at line 916 of file eda_base_frame.cpp.

918 {
919  if( !aFileHistory )
920  aFileHistory = m_fileHistory;
921 
922  wxASSERT( aFileHistory );
923 
924  int baseId = aFileHistory->GetBaseId();
925 
926  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
927 
928  unsigned i = cmdId - baseId;
929 
930  if( i < aFileHistory->GetCount() )
931  {
932  wxString fn = aFileHistory->GetHistoryFile( i );
933 
934  if( wxFileName::FileExists( fn ) )
935  {
936  return fn;
937  }
938  else
939  {
940  DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
941  aFileHistory->RemoveFileFromHistory( i );
942  }
943  }
944 
945  // Update the menubar to update the file history menu
946  if( GetMenuBar() )
947  {
948  ReCreateMenuBar();
949  GetMenuBar()->Refresh();
950  }
951 
952  return wxEmptyString;
953 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:284
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
FILE_HISTORY * m_fileHistory
virtual void ReCreateMenuBar()
Recreates the menu bar.

References _, DisplayErrorMessage(), Format(), EDA_BASE_FRAME::m_fileHistory, and EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by GERBVIEW_FRAME::OnDrlFileHistory(), KICAD_MANAGER_FRAME::OnFileHistory(), PL_EDITOR_FRAME::OnFileHistory(), PCB_EDIT_FRAME::OnFileHistory(), GERBVIEW_FRAME::OnGbrFileHistory(), GERBVIEW_FRAME::OnJobFileHistory(), SCH_EDIT_FRAME::OnLoadFile(), and GERBVIEW_FRAME::OnZipFileHistory().

◆ GetFileHistory()

FILE_HISTORY& EDA_BASE_FRAME::GetFileHistory ( )
inlineinherited

Get the frame's main file history.

Returns
the main file history

Definition at line 423 of file eda_base_frame.h.

424  {
425  return *m_fileHistory;
426  }
FILE_HISTORY * m_fileHistory

References EDA_BASE_FRAME::m_fileHistory.

Referenced by KICAD_MANAGER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), and PCB_EDIT_FRAME::ReCreateMenuBar().

◆ GetFindHistoryList()

wxArrayString& EDA_DRAW_FRAME::GetFindHistoryList ( )
inlineinherited

◆ GetFindReplaceData()

wxFindReplaceData& EDA_DRAW_FRAME::GetFindReplaceData ( )
inlineinherited

◆ GetFrameType()

FRAME_T EDA_BASE_FRAME::GetFrameType ( ) const
inlineinherited

Definition at line 207 of file eda_base_frame.h.

207 { return m_ident; }

References EDA_BASE_FRAME::m_ident.

◆ GetGalDisplayOptions()

◆ GetGridColor()

virtual COLOR4D EDA_DRAW_FRAME::GetGridColor ( )
inlinevirtualinherited

◆ GetGridOrigin()

const wxPoint& SCH_BASE_FRAME::GetGridOrigin ( ) const
inlineoverridevirtualinherited

Return the absolute coordinates of the origin of the snap grid.

This is treated as a relative offset and snapping will occur at multiples of the grid size relative to this point.

Implements EDA_DRAW_FRAME.

Definition at line 124 of file sch_base_frame.h.

125  {
126  static wxPoint zero;
127  return zero;
128  }

◆ GetInfoBar()

◆ GetItem()

virtual EDA_ITEM* EDA_DRAW_FRAME::GetItem ( const KIID aId) const
inlinevirtualinherited

Fetch an item by KIID.

Frame-type-specific implementation.

Reimplemented in SCH_EDIT_FRAME, and PCB_BASE_FRAME.

Definition at line 398 of file eda_draw_frame.h.

398 { return nullptr; }

Referenced by PCB_MARKER::GetMsgPanelInfo(), RC_TREE_MODEL::GetValue(), and EE_SELECTION_TOOL::Main().

◆ GetLayerColor()

COLOR4D SCH_BASE_FRAME::GetLayerColor ( SCH_LAYER_ID  aLayer)
inherited

Helper to retrieve a layer color from the global color settings.

Definition at line 403 of file sch_base_frame.cpp.

404 {
405  return GetColorSettings()->GetColor( aLayer );
406 }
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
COLOR4D GetColor(int aLayer) const

References COLOR_SETTINGS::GetColor(), and SCH_BASE_FRAME::GetColorSettings().

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard().

◆ GetLibManager()

◆ GetLibSymbol()

LIB_SYMBOL * SCH_BASE_FRAME::GetLibSymbol ( const LIB_ID aLibId,
bool  aUseCacheLib = false,
bool  aShowErrorMsg = false 
)
inherited

Load symbol from symbol library table.

Parameters
aLibIdis the symbol library identifier to load.
aUseCacheLibset to true to fall back to cache library if symbol is not found in symbol library table.
aShowErrorMessageset to true to show any error messages.
Returns
The symbol found in the library or NULL if the symbol was not found.

Definition at line 194 of file sch_base_frame.cpp.

196 {
197  SYMBOL_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : nullptr;
198 
199  return SchGetLibSymbol( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowErrorMsg );
200 }
Object used to load, save, search, and otherwise manipulate symbol library files.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.

References KIWAY_HOLDER::Prj(), and SchGetLibSymbol().

Referenced by SCH_EDIT_FRAME::CreateArchiveLibrary(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_BASE_FRAME::PickSymbolFromLibTree(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and DIALOG_CHANGE_SYMBOLS::updateFieldsList().

◆ GetMaxUndoItems()

int EDA_BASE_FRAME::GetMaxUndoItems ( ) const
inlineinherited

Definition at line 581 of file eda_base_frame.h.

581 { return m_undoRedoCountMax; }

References EDA_BASE_FRAME::m_undoRedoCountMax.

Referenced by EDA_DRAW_FRAME::SaveSettings().

◆ GetMoveWarpsCursor()

bool TOOLS_HOLDER::GetMoveWarpsCursor ( ) const
inlineinherited

Indicate that a move operation should warp the mouse pointer to the origin of the move object.

This improves snapping, but some users are allergic to mouse warping.

Definition at line 141 of file tools_holder.h.

141 { return m_moveWarpsCursor; }
bool m_moveWarpsCursor
Definition: tools_holder.h:177

References TOOLS_HOLDER::m_moveWarpsCursor.

Referenced by EDIT_TOOL::doMoveSelection(), ROUTER_TOOL::InlineDrag(), SYMBOL_EDITOR_MOVE_TOOL::Main(), and SCH_MOVE_TOOL::Main().

◆ GetMruPath()

◆ GetNearestGridPosition()

wxPoint EDA_DRAW_FRAME::GetNearestGridPosition ( const wxPoint &  aPosition) const
inherited

Return the nearest aGridSize location to aPosition.

Parameters
aPositionThe position to check.
Returns
The nearest grid position.

Definition at line 792 of file eda_draw_frame.cpp.

793 {
794  const wxPoint& gridOrigin = GetGridOrigin();
795  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
796 
797  double xOffset = fmod( gridOrigin.x, gridSize.x );
798  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
799  double yOffset = fmod( gridOrigin.y, gridSize.y );
800  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
801 
802  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
803 }
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
virtual const wxPoint & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
const VECTOR2D & GetGridSize() const
Return the grid size.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetGAL(), EDA_DRAW_FRAME::GetGridOrigin(), KIGFX::GAL::GetGridSize(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), and SCH_DRAWING_TOOLS::sizeSheet().

◆ GetNearestHalfGridPosition()

wxPoint EDA_DRAW_FRAME::GetNearestHalfGridPosition ( const wxPoint &  aPosition) const
inherited

Return the nearest aGridSize / 2 location to aPosition.

This is useful when attempting for keep outer points on grid but not the middle point.

Parameters
aPositionThe position to check.
Returns
The nearest half-grid position.

Definition at line 806 of file eda_draw_frame.cpp.

807 {
808  const wxPoint& gridOrigin = GetGridOrigin();
809  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
810 
811  double xOffset = fmod( gridOrigin.x, gridSize.x );
812  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
813  double yOffset = fmod( gridOrigin.y, gridSize.y );
814  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
815 
816  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
817 }
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
virtual const wxPoint & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
const VECTOR2D & GetGridSize() const
Return the grid size.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetGAL(), EDA_DRAW_FRAME::GetGridOrigin(), KIGFX::GAL::GetGridSize(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Mirror(), and SCH_EDIT_TOOL::Mirror().

◆ GetOriginTransforms()

virtual ORIGIN_TRANSFORMS& EDA_DRAW_FRAME::GetOriginTransforms ( )
inlinevirtualinherited

Return a reference to the default ORIGIN_TRANSFORMS object.

Reimplemented in PCB_BASE_FRAME.

Definition at line 164 of file eda_draw_frame.h.

165  { return m_originTransforms; }
ORIGIN_TRANSFORMS m_originTransforms

References EDA_DRAW_FRAME::m_originTransforms.

Referenced by PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_SHAPE::GetMsgPanelInfo(), and PCB_DIM_LEADER::GetMsgPanelInfo().

◆ GetPageSettings()

const PAGE_INFO & SCH_BASE_FRAME::GetPageSettings ( ) const
overridevirtualinherited

Implements EDA_DRAW_FRAME.

Definition at line 134 of file sch_base_frame.cpp.

135 {
136  return GetScreen()->GetPageSettings();
137 }
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:132

References SCH_SCREEN::GetPageSettings(), and SCH_BASE_FRAME::GetScreen().

Referenced by DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF().

◆ GetPageSizeIU()

const wxSize SCH_BASE_FRAME::GetPageSizeIU ( ) const
overridevirtualinherited

Works off of GetPageSettings() to return the size of the paper page in the internal units of this particular view.

Implements EDA_DRAW_FRAME.

Definition at line 140 of file sch_base_frame.cpp.

141 {
142  // GetSizeIU is compile time dependent:
143  return GetScreen()->GetPageSettings().GetSizeIU();
144 }
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:132

References SCH_SCREEN::GetPageSettings(), and SCH_BASE_FRAME::GetScreen().

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard().

◆ GetRedoCommandCount()

virtual int EDA_BASE_FRAME::GetRedoCommandCount ( ) const
inlinevirtualinherited

◆ GetRenderSettings()

KIGFX::SCH_RENDER_SETTINGS * SCH_BASE_FRAME::GetRenderSettings ( )
inherited

Definition at line 278 of file sch_base_frame.cpp.

279 {
280  KIGFX::PAINTER* painter = GetCanvas()->GetView()->GetPainter();
281  return static_cast<KIGFX::SCH_RENDER_SETTINGS*>( painter->GetSettings() );
282 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:57
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.

References SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), and SCH_DRAW_PANEL::GetView().

Referenced by DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), SCH_EDIT_FRAME::LoadProjectSettings(), SYMBOL_VIEWER_FRAME::LoadSettings(), SCH_EDIT_FRAME::LoadSettings(), LoadSettings(), DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), DIALOG_PLOT_SCHEMATIC::plotSchematic(), SCH_PRINTOUT::PrintPage(), RebuildView(), SYMBOL_VIEWER_FRAME::SaveSettings(), SaveSettings(), SetCurSymbol(), SYMBOL_VIEWER_FRAME::setupUIConditions(), setupUIConditions(), SYMBOL_EDITOR_CONTROL::ShowElectricalTypes(), SVGPlotSymbol(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_SETUP_FORMATTING::TransferDataFromWindow(), PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow(), and SYMBOL_VIEWER_FRAME::updatePreviewSymbol().

◆ GetScreen()

◆ GetScreenDesc()

wxString EDA_DRAW_FRAME::GetScreenDesc ( ) const
virtualinherited

Reimplemented in SCH_EDIT_FRAME.

Definition at line 948 of file eda_draw_frame.cpp.

949 {
950  // Virtual function. Base class implementation returns an empty string.
951  return wxEmptyString;
952 }

Referenced by KIGFX::SCH_VIEW::DisplaySheet(), and EDA_DRAW_FRAME::PrintDrawingSheet().

◆ GetSettings()

◆ GetSettingsManager()

SETTINGS_MANAGER* EDA_BASE_FRAME::GetSettingsManager ( ) const
inlineinherited

Definition at line 140 of file eda_base_frame.h.

140 { return m_settingsManager; }
SETTINGS_MANAGER * m_settingsManager

References EDA_BASE_FRAME::m_settingsManager.

Referenced by GERBVIEW_FRAME::applyDisplaySettingsToGAL(), KICAD_MANAGER_FRAME::canCloseWindow(), KICAD_MANAGER_FRAME::CreateNewProject(), PCB_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::doAutoSave(), PCB_BASE_EDIT_FRAME::doCloseWindow(), FOOTPRINT_EDIT_FRAME::doCloseWindow(), PCB_EDIT_FRAME::Files_io_from_id(), DIALOG_PLOT_SCHEMATIC::getColorSettings(), GetSettingsManager(), DIALOG_PLOT_SCHEMATIC::initDlg(), DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction(), DIALOG_BOARD_SETUP::OnAuxiliaryAction(), SCH_EDIT_FRAME::OnImportProject(), GERBER_LAYER_WIDGET::OnLayerColorChange(), GERBER_LAYER_WIDGET::OnRenderColorChange(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SCH_EDIT_FRAME::SaveProject(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_EDIT_FRAME::SaveSettings(), PANEL_FP_EDITOR_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow(), DIALOG_PRINT_PCBNEW::TransferDataToWindow(), and SCH_EDIT_FRAME::~SCH_EDIT_FRAME().

◆ GetSeverity()

virtual SEVERITY EDA_BASE_FRAME::GetSeverity ( int  aErrorCode) const
inlinevirtualinherited

Reimplemented in PCB_BASE_FRAME.

Definition at line 142 of file eda_base_frame.h.

References RPT_SEVERITY_UNDEFINED.

Referenced by RC_TREE_MODEL::GetValue().

◆ GetShowAllPins()

virtual bool SCH_BASE_FRAME::GetShowAllPins ( ) const
inlinevirtualinherited

Allow some frames to show/hide hidden pins.

The default impl shows all pins.

Reimplemented in SCH_EDIT_FRAME.

Definition at line 118 of file sch_base_frame.h.

118 { return true; }

Referenced by EE_SELECTION_TOOL::Selectable().

◆ GetShowDeMorgan()

bool SYMBOL_EDIT_FRAME::GetShowDeMorgan ( ) const
inline

Definition at line 227 of file symbol_edit_frame.h.

227 { return m_showDeMorgan; }
static bool m_showDeMorgan

References m_showDeMorgan.

Referenced by setupUIConditions(), and DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow().

◆ GetShowPolarCoords()

bool EDA_DRAW_FRAME::GetShowPolarCoords ( ) const
inlineinherited

For those frames that support polar coordinates.

Definition at line 120 of file eda_draw_frame.h.

120 { return m_polarCoords; }

References EDA_DRAW_FRAME::m_polarCoords.

Referenced by EDITOR_CONDITIONS::polarCoordFunc(), COMMON_TOOLS::TogglePolarCoords(), GERBVIEW_FRAME::UpdateStatusBar(), and PCB_BASE_FRAME::UpdateStatusBar().

◆ GetSymbolFromRedoList()

void SYMBOL_EDIT_FRAME::GetSymbolFromRedoList ( )

Definition at line 59 of file symbol_editor_undo_redo.cpp.

60 {
61  if( GetRedoCommandCount() <= 0 )
62  return;
63 
65 
66  // Load the last redo entry
68  ITEM_PICKER redoWrapper = redoCommand->PopItem();
69  delete redoCommand;
70  LIB_SYMBOL* symbol = (LIB_SYMBOL*) redoWrapper.GetItem();
71  wxCHECK( symbol, /* void */ );
72  symbol->ClearFlags( UR_TRANSIENT );
73  UNDO_REDO undoRedoType = redoWrapper.GetStatus();
74 
75  // Store the current symbol in the undo buffer
76  PICKED_ITEMS_LIST* undoCommand = new PICKED_ITEMS_LIST();
77  LIB_SYMBOL* oldSymbol = m_symbol;
78  oldSymbol->SetFlags( UR_TRANSIENT );
79  ITEM_PICKER undoWrapper( GetScreen(), oldSymbol, undoRedoType );
80  undoCommand->PushItem( undoWrapper );
81  PushCommandToUndoList( undoCommand );
82 
83  // Do not delete the previous symbol by calling SetCurSymbol( symbol )
84  // which calls delete <previous symbol>.
85  // <previous symbol> is now put in undo list and is owned by this list
86  // Just set the current symbol to the symbol which come from the redo list
87  m_symbol = symbol;
88 
89  if( undoRedoType == UNDO_REDO::LIB_RENAME )
90  {
91  wxString lib = GetCurLib();
92  m_libMgr->UpdateSymbolAfterRename( symbol, oldSymbol->GetName(), lib );
93 
94  // Reselect the renamed symbol
95  m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, symbol->GetName() ) );
96  }
97 
99  SetShowDeMorgan( symbol->HasConversion() );
100  updateTitle();
101 
102  RebuildView();
103  OnModify();
104 }
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
wxString GetName() const override
Definition: lib_symbol.h:133
void SetShowDeMorgan(bool show)
EDA_ITEM * GetItem() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SYMBOL_TREE_PANE * m_treePane
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
virtual int GetRedoCommandCount() const
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
Definition: lib_symbol.h:96
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
void updateTitle()
Update the main window title bar with the current library name and read only status of the library.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
A holder to handle information on schematic or board items.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SYMBOL_LIBRARY_MANAGER * m_libMgr
LIB_TREE * GetLibTree() const
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &oldAlias, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
UNDO_REDO GetStatus() const
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:193

References EDA_ITEM::ClearFlags(), EE_ACTIONS::clearSelection, GetCurLib(), ITEM_PICKER::GetItem(), SYMBOL_TREE_PANE::GetLibTree(), LIB_SYMBOL::GetName(), EDA_BASE_FRAME::GetRedoCommandCount(), SCH_BASE_FRAME::GetScreen(), ITEM_PICKER::GetStatus(), LIB_SYMBOL::HasConversion(), LIB_RENAME, m_libMgr, m_symbol, TOOLS_HOLDER::m_toolManager, m_treePane, OnModify(), EDA_BASE_FRAME::PopCommandFromRedoList(), PICKED_ITEMS_LIST::PopItem(), EDA_BASE_FRAME::PushCommandToUndoList(), PICKED_ITEMS_LIST::PushItem(), RebuildSymbolUnitsList(), RebuildView(), TOOL_MANAGER::RunAction(), LIB_TREE::SelectLibId(), EDA_ITEM::SetFlags(), SetShowDeMorgan(), SYMBOL_LIBRARY_MANAGER::UpdateSymbolAfterRename(), updateTitle(), and UR_TRANSIENT.

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Redo().

◆ GetSymbolFromUndoList()

void SYMBOL_EDIT_FRAME::GetSymbolFromUndoList ( )

Definition at line 107 of file symbol_editor_undo_redo.cpp.

108 {
109  if( GetUndoCommandCount() <= 0 )
110  return;
111 
113 
114  // Load the last undo entry
115  PICKED_ITEMS_LIST* undoCommand = PopCommandFromUndoList();
116  ITEM_PICKER undoWrapper = undoCommand->PopItem();
117  delete undoCommand;
118  LIB_SYMBOL* symbol = (LIB_SYMBOL*) undoWrapper.GetItem();
119  wxCHECK( symbol, /* void */ );
120  symbol->ClearFlags( UR_TRANSIENT );
121  UNDO_REDO undoRedoType = undoWrapper.GetStatus();
122 
123  // Store the current symbol in the redo buffer
124  PICKED_ITEMS_LIST* redoCommand = new PICKED_ITEMS_LIST();
125  LIB_SYMBOL* oldSymbol = m_symbol;
126  oldSymbol->SetFlags( UR_TRANSIENT );
127  ITEM_PICKER redoWrapper( GetScreen(), oldSymbol, undoRedoType );
128  redoCommand->PushItem( redoWrapper );
129  PushCommandToRedoList( redoCommand );
130 
131  // Do not delete the previous symbol by calling SetCurSymbol( symbol ),
132  // which calls delete <previous symbol>.
133  // <previous symbol> is now put in redo list and is owned by this list.
134  // Just set the current symbol to the symbol which come from the undo list
135  m_symbol = symbol;
136 
137  if( undoRedoType == UNDO_REDO::LIB_RENAME )
138  {
139  wxString lib = GetCurLib();
140  m_libMgr->UpdateSymbolAfterRename( symbol, oldSymbol->GetName(), lib );
141 
142  // Reselect the renamed symbol
143  m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, symbol->GetName() ) );
144  }
145 
147  SetShowDeMorgan( symbol->HasConversion() );
148  updateTitle();
149 
150  RebuildView();
151  OnModify();
152 }
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
wxString GetName() const override
Definition: lib_symbol.h:133
void SetShowDeMorgan(bool show)
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
EDA_ITEM * GetItem() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SYMBOL_TREE_PANE * m_treePane
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
Definition: lib_symbol.h:96
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
void updateTitle()
Update the main window title bar with the current library name and read only status of the library.
virtual int GetUndoCommandCount() const
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
A holder to handle information on schematic or board items.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SYMBOL_LIBRARY_MANAGER * m_libMgr
LIB_TREE * GetLibTree() const
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &oldAlias, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
UNDO_REDO GetStatus() const
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:193

References EDA_ITEM::ClearFlags(), EE_ACTIONS::clearSelection, GetCurLib(), ITEM_PICKER::GetItem(), SYMBOL_TREE_PANE::GetLibTree(), LIB_SYMBOL::GetName(), SCH_BASE_FRAME::GetScreen(), ITEM_PICKER::GetStatus(), EDA_BASE_FRAME::GetUndoCommandCount(), LIB_SYMBOL::HasConversion(), LIB_RENAME, m_libMgr, m_symbol, TOOLS_HOLDER::m_toolManager, m_treePane, OnModify(), EDA_BASE_FRAME::PopCommandFromUndoList(), PICKED_ITEMS_LIST::PopItem(), EDA_BASE_FRAME::PushCommandToRedoList(), PICKED_ITEMS_LIST::PushItem(), RebuildSymbolUnitsList(), RebuildView(), TOOL_MANAGER::RunAction(), LIB_TREE::SelectLibId(), EDA_ITEM::SetFlags(), SetShowDeMorgan(), SYMBOL_LIBRARY_MANAGER::UpdateSymbolAfterRename(), updateTitle(), and UR_TRANSIENT.

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Undo().

◆ getTargetLib()

wxString SYMBOL_EDIT_FRAME::getTargetLib ( ) const
private

Definition at line 897 of file symbol_edit_frame.cpp.

898 {
899  return GetTargetLibId().GetLibNickname();
900 }
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
LIB_ID GetTargetLibId() const

References LIB_ID::GetLibNickname(), and GetTargetLibId().

Referenced by CreateNewSymbol(), ImportSymbol(), and saveLibrary().

◆ GetTargetLibId()

LIB_ID SYMBOL_EDIT_FRAME::GetTargetLibId ( ) const

Definition at line 880 of file symbol_edit_frame.cpp.

881 {
882  LIB_ID id = GetTreeLIBID();
883 
884  if( id.GetLibNickname().empty() && m_symbol )
885  id = m_symbol->GetLibId();
886 
887  return id;
888 }
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_ID GetLibId() const override
Definition: lib_symbol.h:135
static bool empty(const wxTextEntryBase *aCtrl)

References empty(), LIB_SYMBOL::GetLibId(), GetTreeLIBID(), and m_symbol.

Referenced by DeleteSymbolFromLibrary(), getTargetLib(), SYMBOL_EDITOR_CONTROL::Init(), RegenerateLibraryTree(), Revert(), Save(), SaveLibraryAs(), SaveSymbolAs(), and setupUIConditions().

◆ getTargetSymbol()

LIB_SYMBOL * SYMBOL_EDIT_FRAME::getTargetSymbol ( ) const
private

Return either the library selected in the symbol tree, if context menu is active or the library that is currently modified.

Definition at line 866 of file symbol_edit_frame.cpp.

867 {
868  LIB_ID libId = GetTreeLIBID();
869 
870  if( libId.IsValid() )
871  {
872  LIB_SYMBOL* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
873  return alias;
874  }
875 
876  return m_symbol;
877 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
Define a library symbol object.
Definition: lib_symbol.h:96
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
SYMBOL_LIBRARY_MANAGER * m_libMgr

References SYMBOL_LIBRARY_MANAGER::GetAlias(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), GetTreeLIBID(), LIB_ID::IsValid(), m_libMgr, and m_symbol.

Referenced by ExportSymbol(), Save(), and saveSymbolAs().

◆ GetTitleBlock()

const TITLE_BLOCK & SCH_BASE_FRAME::GetTitleBlock ( ) const
overridevirtualinherited

Implements EDA_DRAW_FRAME.

Definition at line 147 of file sch_base_frame.cpp.

148 {
149  wxASSERT( GetScreen() );
150  return GetScreen()->GetTitleBlock();
151 }
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:150

References SCH_BASE_FRAME::GetScreen(), and SCH_SCREEN::GetTitleBlock().

Referenced by DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), and DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG().

◆ GetToolCanvas()

wxWindow* EDA_DRAW_FRAME::GetToolCanvas ( ) const
inlineoverridevirtualinherited

Canvas access.

Implements TOOLS_HOLDER.

Definition at line 425 of file eda_draw_frame.h.

425 { return GetCanvas(); }
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.

References EDA_DRAW_FRAME::GetCanvas().

◆ GetToolManager()

TOOL_MANAGER* TOOLS_HOLDER::GetToolManager ( ) const
inlineinherited

Return the MVC controller.

Definition at line 54 of file tools_holder.h.

54 { return m_toolManager; }
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158

References TOOLS_HOLDER::m_toolManager.

Referenced by PROJECT_TREE_ITEM::Activate(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), BOARD_COMMIT::BOARD_COMMIT(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), TOOLS_HOLDER::CommonSettingsChanged(), DIALOG_FOOTPRINT_CHECKER::deleteAllMarkers(), DIALOG_ERC::deleteAllMarkers(), DIALOG_DRC::deleteAllMarkers(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), SIM_PLOT_FRAME::doCloseWindow(), DIALOG_GLOBAL_DELETION::DoGlobalDeletions(), SCH_FIELD::DoHypertextMenu(), DRAWING_TOOL::DrawVia(), TRACK_WIDTH_MENU::eventHandler(), DIFF_PAIR_MENU::eventHandler(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), GERBVIEW_FRAME::GERBVIEW_FRAME(), FP_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), SCH_NAVIGATE_TOOL::HypertextCommand(), ROUTER_TOOL::InlineBreakTrack(), EDA_3D_VIEWER_FRAME::InstallPreferences(), KICAD_MANAGER_FRAME::InstallPreferences(), PL_EDITOR_FRAME::InstallPreferences(), FOOTPRINT_EDIT_FRAME::InstallPreferences(), InstallPreferences(), GERBVIEW_FRAME::InstallPreferences(), PCB_EDIT_FRAME::InstallPreferences(), SCH_EDIT_FRAME::InstallPreferences(), PCB_EDIT_FRAME::LoadProjectSettings(), FOOTPRINT_EDIT_FRAME::LoadSettings(), LoadSymbol(), PROPERTIES_FRAME::OnAcceptPrms(), DIALOG_DRC::OnActivateDlg(), DIALOG_FOOTPRINT_CHECKER::OnCancelClick(), DIALOG_DRC::OnCancelClick(), DIALOG_INSPECTOR::onCellClicked(), DIALOG_ERC::OnCloseErcDialog(), DIALOG_FOOTPRINT_CHECKER::OnDeleteOneClick(), DIALOG_DRC::OnDeleteOneClick(), DIALOG_DRC::OnDRCItemRClick(), DIALOG_ERC::OnERCItemSelected(), DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked(), KICAD_MANAGER_FRAME::OnIdle(), FOOTPRINTS_LISTBOX::OnLeftDClick(), APPEARANCE_CONTROLS::onNetclassContextMenu(), APPEARANCE_CONTROLS::onNetContextMenu(), PANEL_PCBNEW_ACTION_PLUGINS::OnOpenDirectoryButtonClick(), SIM_PLOT_FRAME::onProbe(), PANEL_PCBNEW_ACTION_PLUGINS::OnReloadButtonClick(), DIALOG_ABOUT::onReportBug(), DIALOG_PLOT::onRunDRC(), DIALOG_DRC::OnRunDRCClick(), HIERARCHY_NAVIG_DLG::onSelectSheetPath(), SCH_EDIT_FRAME::onSize(), SYMBOL_TREE_PANE::onSymbolSelected(), DIALOG_SYMBOL_FIELDS_TABLE::OnTableCellClick(), SIM_PLOT_FRAME::onTune(), PANEL_SELECTION_FILTER::PANEL_SELECTION_FILTER(), DIALOG_UPDATE_PCB::PerformUpdate(), DIALOG_PLOT::Plot(), TOOLS_HOLDER::PopTool(), FOOTPRINT_WIZARD_FRAME::PythonPluginsReload(), PL_EDITOR_FRAME::RollbackFromUndo(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_EDIT_FRAME::SaveSettings(), EDA_3D_VIEWER_FRAME::SaveSettings(), DIALOG_FIND::search(), CVPCB_MAINFRAME::setupEventHandlers(), APPEARANCE_CONTROLS::showNetclass(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_SYMBOL_FIELDS_TABLE::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow(), EDA_DRAW_FRAME::UpdateMsgPanel(), NET_GRID_TABLE::updateNetVisibility(), DIALOG_NETLIST::~DIALOG_NETLIST(), and DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB().

◆ GetTreeLIBID()

LIB_ID SYMBOL_EDIT_FRAME::GetTreeLIBID ( int *  aUnit = nullptr) const

Return the LIB_ID of the library or symbol selected in the symbol tree.

Definition at line 860 of file symbol_edit_frame.cpp.

861 {
862  return m_treePane->GetLibTree()->GetSelectedLibId( aUnit );
863 }
SYMBOL_TREE_PANE * m_treePane
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:168
LIB_TREE * GetLibTree() const

References SYMBOL_TREE_PANE::GetLibTree(), LIB_TREE::GetSelectedLibId(), and m_treePane.

Referenced by SYMBOL_EDITOR_CONTROL::AddSymbol(), SYMBOL_EDITOR_CONTROL::CutCopyDelete(), SYMBOL_EDITOR_CONTROL::DuplicateSymbol(), SYMBOL_EDITOR_CONTROL::EditSymbol(), GetTargetLibId(), getTargetSymbol(), and SYMBOL_EDITOR_CONTROL::Init().

◆ GetType()

HOLDER_TYPE KIWAY_HOLDER::GetType ( ) const
inlineinherited

Definition at line 46 of file kiway_holder.h.

46 { return m_type; }
HOLDER_TYPE m_type
Definition: kiway_holder.h:76

References KIWAY_HOLDER::m_type.

Referenced by DIALOG_SHIM::DIALOG_SHIM().

◆ GetUndoCommandCount()

virtual int EDA_BASE_FRAME::GetUndoCommandCount ( ) const
inlinevirtualinherited

◆ GetUnit()

◆ GetUnitPair()

void EDA_DRAW_FRAME::GetUnitPair ( EDA_UNITS aPrimaryUnit,
EDA_UNITS aSecondaryUnits 
)
inherited

Get the pair or units in current use.

The primary unit is the main unit of the frame, and the secondary unit is the unit of the other system that was used most recently.

Definition at line 1060 of file eda_draw_frame.cpp.

1061 {
1063 
1064  aPrimaryUnit = GetUserUnits();
1065  aSecondaryUnits = EDA_UNITS::MILS;
1066 
1067  if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1068  {
1069  if( cmnTool )
1070  aSecondaryUnits = cmnTool->GetLastMetricUnits();
1071  else
1072  aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1073  }
1074  else
1075  {
1076  if( cmnTool )
1077  aSecondaryUnits = cmnTool->GetLastImperialUnits();
1078  else
1079  aSecondaryUnits = EDA_UNITS::MILS;
1080  }
1081 }
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:74
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:26
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:75
Handles action that are shared between different applications.
Definition: common_tools.h:37
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References COMMON_TOOLS::GetLastImperialUnits(), COMMON_TOOLS::GetLastMetricUnits(), TOOL_MANAGER::GetTool(), EDA_BASE_FRAME::GetUserUnits(), EDA_UNIT_UTILS::IsImperialUnit(), TOOLS_HOLDER::m_toolManager, MILLIMETRES, and MILS.

Referenced by GRID_MENU::BuildChoiceList(), and PCB_EDIT_FRAME::UpdateTrackWidthSelectBox().

◆ GetUserUnits()

EDA_UNITS EDA_BASE_FRAME::GetUserUnits ( ) const
inlineinherited

Return the user units currently in use.

Definition at line 126 of file eda_base_frame.h.

127  {
128  return m_userUnits;
129  }
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.

References EDA_BASE_FRAME::m_userUnits.

Referenced by DIALOG_CONSTRAINTS_REPORTER::AddPage(), PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs(), PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth(), PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize(), EE_INSPECTION_TOOL::CheckSymbol(), PANEL_SETUP_BOARD_STACKUP::computeBoardThickness(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EDA_DRAW_FRAME::DisplayGridMsg(), GERBER_FILE_IMAGE::DisplayImageInfo(), DIALOG_GROUP_PROPERTIES::DoAddMember(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawBoardCharacteristics(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawSpecificationStackup(), EVT_GRID_CMD_CELL_CHANGED(), PCB_EDIT_FRAME::GenFootprintsReport(), PANEL_FP_EDITOR_DEFAULTS::getGridValue(), PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue(), BOARD_INSPECTION_TOOL::getItemDescription(), LIB_CIRCLE::GetMsgPanelInfo(), LIB_ARC::GetMsgPanelInfo(), LIB_RECTANGLE::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), LIB_POLYLINE::GetMsgPanelInfo(), PL_EDITOR_LAYOUT::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), PCB_MARKER::GetMsgPanelInfo(), LIB_BEZIER::GetMsgPanelInfo(), PCB_TARGET::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), LIB_FIELD::GetMsgPanelInfo(), SCH_BITMAP::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), LIB_PIN::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), PCB_SHAPE::GetMsgPanelInfo(), PCB_VIA::GetMsgPanelInfo(), PCB_DIM_ALIGNED::GetMsgPanelInfo(), PCB_DIM_LEADER::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), EDA_DRAW_FRAME::GetUnitPair(), GetUserUnits(), RC_TREE_MODEL::GetValue(), BOARD_INSPECTION_TOOL::InspectClearance(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), PANEL_SETUP_BOARD_STACKUP::onThicknessChange(), DIALOG_NET_INSPECTOR::onUnitsChanged(), UNIT_BINDER::onUnitsChanged(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP(), POSITION_RELATIVE_TOOL::PositionRelative(), DRC_TOOL::RunTests(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), COMMON_TOOLS::ToggleUnits(), PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup(), PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataToWindow(), UNIT_BINDER::UNIT_BINDER(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), EDITOR_CONDITIONS::unitsFunc(), VIA_SIZE_MENU::update(), TRACK_WIDTH_MENU::update(), DIFF_PAIR_MENU::update(), BOARD_NETLIST_UPDATER::updateCopperZoneNets(), GERBVIEW_FRAME::updateDCodeSelectBox(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), ROUTER_TOOL::updateMessagePanel(), PNS_TUNE_STATUS_POPUP::UpdateStatus(), GERBVIEW_FRAME::UpdateStatusBar(), PL_EDITOR_FRAME::UpdateStatusBar(), SCH_BASE_FRAME::UpdateStatusBar(), PCB_BASE_FRAME::UpdateStatusBar(), PCB_EDIT_FRAME::UpdateViaSizeSelectBox(), and DRC_TOOL::userUnits().

◆ GetWindowSettings()

WINDOW_SETTINGS * EDA_BASE_FRAME::GetWindowSettings ( APP_SETTINGS_BASE aCfg)
virtualinherited

Return a pointer to the window settings for this frame.

By default, points to aCfg->m_Window for top-level frames.

Parameters
aCfgis this frame's config object

Reimplemented in FOOTPRINT_WIZARD_FRAME, SIM_PLOT_FRAME, FOOTPRINT_VIEWER_FRAME, SYMBOL_VIEWER_FRAME, and DISPLAY_FOOTPRINTS_FRAME.

Definition at line 790 of file eda_base_frame.cpp.

791 {
792  return &aCfg->m_Window;
793 }
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181

References APP_SETTINGS_BASE::m_Window.

Referenced by EDA_BASE_FRAME::LoadSettings(), EDA_DRAW_FRAME::LoadSettings(), EDA_BASE_FRAME::SaveSettings(), and EDA_DRAW_FRAME::SaveSettings().

◆ GetWindowSize()

wxSize EDA_BASE_FRAME::GetWindowSize ( )
inherited

Get the undecorated window size that can be used for restoring the window size.

This is needed for GTK, since the normal wxWidgets GetSize() call will return a window size that includes the window decorations added by the window manager.

Returns
the undecorated window size

Definition at line 1215 of file eda_base_frame.cpp.

1216 {
1217 #ifdef __WXGTK__
1218  // GTK includes the window decorations in the normal GetSize call,
1219  // so we have to use a GTK-specific sizing call that returns the
1220  // non-decorated window size.
1221  int width = 0;
1222  int height = 0;
1223  GTKDoGetSize( &width, &height );
1224 
1225  wxSize winSize( width, height );
1226 #else
1227  wxSize winSize = GetSize();
1228 #endif
1229 
1230  return winSize;
1231 }

Referenced by EDA_BASE_FRAME::ensureWindowIsOnScreen(), EDA_BASE_FRAME::OnMaximize(), and EDA_BASE_FRAME::SaveWindowSettings().

◆ GetZoomLevelIndicator()

const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator ( ) const
inherited

Return a human readable value for display in dialogs.

Definition at line 570 of file eda_draw_frame.cpp.

571 {
572  // returns a human readable value which can be displayed as zoom
573  // level indicator in dialogs.
574  double zoom = m_canvas->GetGAL()->GetZoomFactor();
575  return wxString::Format( wxT( "Z %.2f" ), zoom );
576 }
EDA_DRAW_PANEL_GAL * m_canvas
This the frame's interface to setting GAL display options.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
double GetZoomFactor() const
Get the zoom factor.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format(), EDA_DRAW_PANEL_GAL::GetGAL(), KIGFX::GAL::GetZoomFactor(), EDA_DRAW_FRAME::m_canvas, and zoom.

Referenced by PL_EDITOR_FRAME::UpdateStatusBar(), and EDA_DRAW_FRAME::UpdateStatusBar().

◆ handleActivateEvent()

void EDA_DRAW_FRAME::handleActivateEvent ( wxActivateEvent &  aEvent)
protectedvirtualinherited

Handle a window activation event.

Reimplemented in PCB_BASE_EDIT_FRAME.

Definition at line 1133 of file eda_draw_frame.cpp.

1134 {
1135  // Force a refresh of the message panel to ensure that the text is the right color
1136  // when the window activates
1137  if( !IsIconized() )
1138  m_messagePanel->Refresh();
1139 }
EDA_MSG_PANEL * m_messagePanel

References EDA_DRAW_FRAME::m_messagePanel.

Referenced by PCB_BASE_EDIT_FRAME::handleActivateEvent(), and EDA_DRAW_FRAME::onActivate().

◆ HandleSystemColorChange()

void EDA_BASE_FRAME::HandleSystemColorChange ( )
virtualinherited

Update the UI in response to a change in the system colors.

Definition at line 1234 of file eda_base_frame.cpp.

1235 {
1236  // Update the icon theme when the system theme changes and update the toolbars
1238  ThemeChanged();
1239 
1240  // This isn't handled by ThemeChanged()
1241  if( GetMenuBar() )
1242  {
1243  // For icons in menus, icon scaling & hotkeys
1244  ReCreateMenuBar();
1245  GetMenuBar()->Refresh();
1246  }
1247 }
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
virtual void ThemeChanged()
Process light/dark theme change.
virtual void ReCreateMenuBar()
Recreates the menu bar.
BITMAP_STORE * GetBitmapStore()
Definition: bitmap.cpp:93

References GetBitmapStore(), EDA_BASE_FRAME::ReCreateMenuBar(), BITMAP_STORE::ThemeChanged(), and EDA_BASE_FRAME::ThemeChanged().

Referenced by EDA_BASE_FRAME::onSystemColorChange().

◆ HandleUpdateUIEvent()

void EDA_BASE_FRAME::HandleUpdateUIEvent ( wxUpdateUIEvent &  aEvent,
EDA_BASE_FRAME aFrame,
ACTION_CONDITIONS  aCond 
)
staticinherited

Handle events generated when the UI is trying to figure out the current state of the UI controls related to TOOL_ACTIONS (e.g.

enabled, checked, etc.).

Parameters
aEventis the wxUpdateUIEvent to be processed.
aFrameis the frame to get the selection from
aCondare the #UI SELECTION_CONDITIONS used

Definition at line 372 of file eda_base_frame.cpp.

374 {
375  bool checkRes = false;
376  bool enableRes = true;
377  bool showRes = true;
378  SELECTION& selection = aFrame->GetCurrentSelection();
379 
380  try
381  {
382  checkRes = aCond.checkCondition( selection );
383  enableRes = aCond.enableCondition( selection );
384  showRes = aCond.showCondition( selection );
385  }
386  catch( std::exception& )
387  {
388  // Something broke with the conditions, just skip the event.
389  aEvent.Skip();
390  return;
391  }
392 
393  aEvent.Enable( enableRes );
394  aEvent.Show( showRes );
395 
396  // wxWidgets 3.1.5+ includes a field in the event that says if the event supports being
397  // checked, since wxMenuItems don't want to be checked unless they actually are checkable
398 #if wxCHECK_VERSION( 3, 1, 5 )
399  if( aEvent.IsCheckable() )
400  aEvent.Check( checkRes );
401 #else
402  bool canCheck = true;
403 
404  // wxMenuItems don't want to be checked unless they actually are checkable, so we have to
405  // check to see if they can be and can't just universally apply a check in this event.
406  if( auto menu = dynamic_cast<wxMenu*>( aEvent.GetEventObject() ) )
407  canCheck = menu->FindItem( aEvent.GetId() )->IsCheckable();
408 
409  if( canCheck )
410  aEvent.Check( checkRes );
411 #endif
412 }
SELECTION_CONDITION showCondition
Returns true if the UI control should be shown.
SELECTION_CONDITION enableCondition
Returns true if the UI control should be enabled.
SELECTION_CONDITION checkCondition
Returns true if the UI control should be checked.
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Definition: tools_holder.h:101

References ACTION_CONDITIONS::checkCondition, ACTION_CONDITIONS::enableCondition, TOOLS_HOLDER::GetCurrentSelection(), and ACTION_CONDITIONS::showCondition.

Referenced by EDA_BASE_FRAME::RegisterUIUpdateHandler().

◆ HardRedraw()

void SYMBOL_EDIT_FRAME::HardRedraw ( )
overridevirtual

Rebuild the GAL and redraw the screen.

Call when something went wrong.

Reimplemented from SCH_BASE_FRAME.

Definition at line 1129 of file symbol_edit_frame.cpp.

1130 {
1131  SyncLibraries( true );
1132 
1133  if( m_symbol )
1134  {
1136  EE_SELECTION& selection = selectionTool->GetSelection();
1137 
1138  for( LIB_ITEM& item : m_symbol->GetDrawItems() )
1139  {
1140  if( !alg::contains( selection, &item ) )
1141  item.ClearSelected();
1142  else
1143  item.SetSelected();
1144  }
1145  }
1146 
1147  RebuildView();
1148 }
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
EE_SELECTION & GetSelection()
Return the set of currently selected items.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:473
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
void SyncLibraries(bool aShowProgress, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...

References alg::contains(), LIB_SYMBOL::GetDrawItems(), EE_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), m_symbol, TOOLS_HOLDER::m_toolManager, RebuildView(), and SyncLibraries().

◆ HasLibModifications()

bool SYMBOL_EDIT_FRAME::HasLibModifications ( ) const

Check if any pending libraries have been modified.

This only checks for modified libraries. If a new symbol was created and modified and no libraries have been modified, the return value will be false.

Returns
True if there are any pending library modifications.

Definition at line 1233 of file symbol_edit_frame.cpp.

1234 {
1235  wxCHECK( m_libMgr, false );
1236 
1237  return m_libMgr->HasModifications();
1238 }
SYMBOL_LIBRARY_MANAGER * m_libMgr

References SYMBOL_LIBRARY_MANAGER::HasModifications(), and m_libMgr.

◆ help_name()

wxString EDA_BASE_FRAME::help_name ( )
virtualinherited

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 809 of file eda_base_frame.cpp.

810 {
811  return Kiface().GetHelpFileName();
812 }
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
Definition: kiface_base.h:109

References KIFACE_BASE::GetHelpFileName(), and Kiface().

Referenced by COMMON_CONTROL::ShowHelp().

◆ ImportHotkeyConfigFromFile()

void EDA_BASE_FRAME::ImportHotkeyConfigFromFile ( std::map< std::string, TOOL_ACTION * >  aActionMap,
const wxString &  aDefaultShortname 
)
inherited

Prompt the user for a hotkey file to read, and read it.

Parameters
aActionMapcurrent hotkey map (over which the imported hotkeys will be applied).
aDefaultShortnamea default short name (extension not needed) like Eeschema, KiCad...

◆ ImportSymbol()

void SYMBOL_EDIT_FRAME::ImportSymbol ( )

Definition at line 37 of file symbol_editor_import_export.cpp.

38 {
39  wxString msg;
40  wxString libName = getTargetLib();
41 
42  if( !m_libMgr->LibraryExists( libName ) )
43  {
44  libName = SelectLibraryFromList();
45 
46  if( !m_libMgr->LibraryExists( libName ) )
47  return;
48  }
49 
50  wxString wildcards = KiCadSymbolLibFileWildcard();
51 
52  wildcards += "|" + LegacySymbolLibFileWildcard();
53 
54  wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath, wxEmptyString,
55  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
56 
57  if( dlg.ShowModal() == wxID_CANCEL )
58  return;
59 
60  wxFileName fn = dlg.GetPath();
61 
62  if( fn.GetExt().IsEmpty() )
63  fn.SetExt( (dlg.GetFilterIndex() == 0) ?
65 
66  m_mruPath = fn.GetPath();
67 
68  wxArrayString symbols;
69  SCH_IO_MGR::SCH_FILE_T piType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
70  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( piType ) );
71