KiCad PCB EDA Suite
SCH_EDIT_FRAME Class Reference

Schematic editor (Eeschema) main window. More...

#include <sch_edit_frame.h>

Inheritance diagram for SCH_EDIT_FRAME:
SCH_BASE_FRAME EDA_DRAW_FRAME KIWAY_PLAYER EDA_BASE_FRAME TOOLS_HOLDER KIWAY_HOLDER UNITS_PROVIDER

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

 SCH_EDIT_FRAME (KIWAY *aKiway, wxWindow *aParent)
 
 ~SCH_EDIT_FRAME () override
 
SCH_SCREENGetScreen () const override
 Return a pointer to a BASE_SCREEN or one of its derivatives. More...
 
SELECTIONGetCurrentSelection () override
 Get the current selection from the canvas area. More...
 
SCHEMATICSchematic () const
 
bool GetShowAllPins () const override
 Allow edit frame to show/hide hidden pins. More...
 
void SaveProjectSettings () override
 Save changes to the project settings to the project (.pro) file. More...
 
bool LoadProjectSettings ()
 Load the KiCad project file (*.pro) settings specific to Eeschema. More...
 
void ShowSchematicSetupDialog (const wxString &aInitialPage=wxEmptyString)
 
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...
 
void CreateScreens ()
 
void ReCreateHToolbar () override
 
void ReCreateVToolbar () override
 
void ReCreateOptToolbar () override
 
void ReCreateMenuBar () override
 Recreates the menu bar. More...
 
void setupUIConditions () override
 Setup the UI conditions for the various actions and their controls in this frame. More...
 
bool IsContentModified () const override
 Get if the current schematic has been modified but not saved. More...
 
void OnModify () override
 Must be called after a schematic change in order to set the "modify" flag of the current screen and update the date in frame reference. More...
 
void RecordERCExclusions ()
 Scan existing markers and record data from any that are Excluded. More...
 
void ResolveERCExclusions ()
 Update markers to match recorded exclusions. More...
 
SEVERITY GetSeverity (int aErrorCode) const override
 
wxString GetScreenDesc () const override
 Return a human-readable description of the current screen. More...
 
void ExecuteRemoteCommand (const char *cmdline) override
 Execute a remote command sent by Pcbnew via a socket connection. More...
 
void KiwayMailIn (KIWAY_EXPRESS &aEvent) override
 Receive KIWAY_EXPRESS messages from other players. More...
 
void AutoRotateItem (SCH_SCREEN *aScreen, SCH_ITEM *aItem)
 Automatically set the rotation of an item (if the item supports it) More...
 
void AddItemToScreenAndUndoList (SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
 Add an item to the schematic and adds the changes to the undo/redo container. More...
 
void ShowFindReplaceDialog (bool aReplace)
 Run the Find or Find & Replace dialog. More...
 
void UpdateHierarchyNavigator ()
 Update the hierarchy navigation tree and history. More...
 
void ShowFindReplaceStatus (const wxString &aMsg, int aStatusTime)
 
void ClearFindReplaceStatus ()
 
void OnFindDialogClose ()
 Notification that the Find dialog has closed. More...
 
bool BreakSegment (SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
 Break a single segment into two at the specified point. More...
 
bool BreakSegments (const VECTOR2I &aPoint, SCH_SCREEN *aScreen=nullptr)
 Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an intersection is found. More...
 
bool BreakSegmentsOnJunctions (SCH_SCREEN *aScreen=nullptr)
 Test all junctions and bus entries in the schematic for intersections with wires and buses and breaks any intersections into multiple segments. More...
 
void TestDanglingEnds ()
 Test all of the connectable objects in the schematic for unused connection points. More...
 
void SendSelectItemsToPcb (const std::vector< EDA_ITEM * > &aItems, bool aForce)
 Sends items to Pcbnew for selection. More...
 
void SendCrossProbeNetName (const wxString &aNetName)
 Sends a net name to Pcbnew for highlighting. More...
 
void SetCrossProbeConnection (const SCH_CONNECTION *aConnection)
 Send a connection (net or bus) to Pcbnew for highlighting. More...
 
void SendCrossProbeClearHighlight ()
 Tell Pcbnew to clear the existing highlighted net, if one exists. More...
 
const SCH_CONNECTIONGetHighlightedConnection () const
 
void SetHighlightedConnection (const SCH_CONNECTION *aConnection)
 
bool ReadyToNetlist (const wxString &aAnnotateMessage)
 Check if we are ready to write a netlist file for the current schematic. More...
 
bool WriteNetListFile (int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=nullptr)
 Create a netlist file. More...
 
void DeleteAnnotation (ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive, bool *appendUndo)
 Clear the current symbol annotation. More...
 
void AnnotateSymbols (ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, REPORTER &aReporter, bool appendUndo=false)
 Annotate the symbols in the schematic that are not currently annotated. More...
 
int CheckAnnotate (ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL, bool aRecursive=true)
 Check for annotation errors. More...
 
int ModalAnnotate (const wxString &aMessage)
 Run a modal version of the annotate dialog for a specific purpose. More...
 
SCH_SHEET_PATHGetCurrentSheet () const
 
void SetCurrentSheet (const SCH_SHEET_PATH &aSheet)
 
void UpdateItem (EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
 Mark an item for refresh. More...
 
void HardRedraw () override
 Rebuild the GAL and redraw the screen. More...
 
void DisplayCurrentSheet ()
 Draw the current sheet on the display. More...
 
void DrawCurrentSheetToClipboard ()
 Use the wxWidgets print code to draw an image of the current sheet onto the clipboard. More...
 
void OnPageSettingsChange () override
 Called when modifying the page settings. More...
 
wxString GetUniqueFilenameForCurrentSheet ()
 
void SetSheetNumberAndCount ()
 Set the m_ScreenNumber and m_NumberOfScreens members for screens. More...
 
wxPageSetupDialogData & GetPageSetupData ()
 
void NewProject ()
 
void LoadProject ()
 
bool SaveProject (bool aSaveAs=false)
 Save the currently-open schematic (including its hierarchy) and associated project. More...
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 Open a project or set of files given by aFileList. More...
 
wxString GetCurrentFileName () const override
 Get the full filename + path of the currently opened file in the frame. More...
 
bool AppendSchematic ()
 Import a KiCad schematic into the current sheet. More...
 
bool AddSheetAndUpdateDisplay (const wxString aFullFileName)
 Add a sheet file into the current sheet and updates display. More...
 
bool AskToSaveChanges ()
 Check if any of the screens has unsaved changes and asks the user whether to save or drop them. More...
 
SCH_JUNCTIONAddJunction (SCH_SCREEN *aScreen, const VECTOR2I &aPos, bool aAppendToUndo, bool aFinal=true)
 
bool SchematicCleanUp (SCH_SCREEN *aScreen=nullptr)
 Perform routine schematic cleaning including breaking wire and buses and deleting identical objects superimposed on top of each other. More...
 
bool TrimWire (const VECTOR2I &aStart, const VECTOR2I &aEnd)
 If any single wire passes through both points, remove the portion between the two points, potentially splitting the wire into two. More...
 
std::vector< VECTOR2IGetSchematicConnections ()
 Collect a unique list of all possible connection points in the schematic. More...
 
void OnOpenPcbnew (wxCommandEvent &event)
 
void OnOpenCvpcb (wxCommandEvent &event)
 
void OnUpdatePCB (wxCommandEvent &event)
 
void OnAnnotate (wxCommandEvent &event)
 
bool CheckSheetForRecursion (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
 Verify that aSheet will not cause a recursion error in aHierarchy. More...
 
bool AllowCaseSensitiveFileNameClashes (const wxString &aSchematicFileName)
 Check aSchematicFileName for a potential file name case sensitivity clashes. More...
 
bool EditSheetProperties (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
 Edit an existing sheet or add a new sheet to the schematic. More...
 
void InitSheet (SCH_SHEET *aSheet, const wxString &aNewFilename)
 
bool LoadSheetFromFile (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
 Load a the KiCad schematic file aFileName into the sheet aSheet. More...
 
void DeleteJunction (SCH_ITEM *aItem, bool aAppend=false)
 Removes a given junction and heals any wire segments under the junction. More...
 
void ConvertPart (SCH_SYMBOL *aSymbol)
 
void SelectUnit (SCH_SYMBOL *aSymbol, int aUnit)
 
void StartNewUndo ()
 Create a new, blank stack for future Undo commands to be pushed to. More...
 
void SaveCopyInUndoList (SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
 Create a copy of the current schematic item, and put it in the undo list. More...
 
void SaveCopyInUndoList (const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
 Create a new entry in undo list of commands. More...
 
void PutDataInPreviousState (PICKED_ITEMS_LIST *aList)
 Restore an undo or redo command to put data pointed by aList in the previous state. More...
 
void ClearUndoORRedoList (UNDO_REDO_LIST whichList, int aItemCount=-1) override
 Free the undo or redo list from aList element. More...
 
void SaveCopyForRepeatItem (const SCH_ITEM *aItem)
 Clone aItem and owns that clone in this container. More...
 
void AddCopyForRepeatItem (const SCH_ITEM *aItem)
 
const std::vector< std::unique_ptr< SCH_ITEM > > & GetRepeatItems () const
 Return the items which are to be repeated with the insert key. More...
 
EDA_ITEMGetItem (const KIID &aId) const override
 Fetch an item by KIID. More...
 
void RollbackSchematicFromUndo ()
 Perform an undo of the last edit WITHOUT logging a corresponding redo. More...
 
bool CreateArchiveLibraryCacheFile (bool aUseCurrentSheetFilename=false)
 Create a symbol library file with the name of the root document plus the '-cache' suffix,. More...
 
bool CreateArchiveLibrary (const wxString &aFileName)
 Create a library aFileName that contains all symbols used in the current schematic. More...
 
virtual void PrintPage (const RENDER_SETTINGS *aSettings) override
 Plot or print the current sheet to the clipboard. More...
 
void SetNetListerCommand (const wxString &aCommand)
 
void DefaultExecFlags ()
 Reset the execution flags to defaults for external netlist and bom generators. More...
 
void SetExecFlags (const int aFlags)
 Set (adds) specified flags for next execution of external generator of the netlist or bom. More...
 
void ClearExecFlags (const int aFlags)
 Clear (removes) specified flags that not needed for next execution of external generator of the netlist or bom. More...
 
wxString GetNetListerCommand () const
 
void RecalculateConnections (SCH_CLEANUP_FLAGS aCleanupFlags)
 Generate the connection data for the entire schematic hierarchy. More...
 
void CommonSettingsChanged (bool aEnvVarsChanged, bool aTextVarsChanged) override
 Called after the preferences dialog is run. More...
 
void UpdateNetHighlightStatus ()
 
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 FixupJunctions ()
 
int GetSchematicJunctionSize ()
 
void FocusOnItem (SCH_ITEM *aItem)
 
bool IsSyncingSelection ()
 
void SaveSymbolToSchematic (const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
 Update a schematic symbol from a LIB_SYMBOL. More...
 
void RecomputeIntersheetRefs (bool autoplaceUninitialized=false)
 Update the schematic's page reference map for all global labels, and refresh the labels so that they are redrawn with up-to-date references. More...
 
void ShowAllIntersheetRefs (bool aShow)
 
virtual void CheckForAutoSaveFile (const wxFileName &aFileName) override
 This overloaded version checks if the auto save master file "#auto_saved_files#" exists and recovers all of the schematic files listed in it. More...
 
void ToggleSchematicHierarchy ()
 Toggle the show/hide state of the left side schematic navigation panel. More...
 
void createCanvas ()
 
SCH_DRAW_PANELGetCanvas () const override
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
EESCHEMA_SETTINGSeeconfig () const
 
SYMBOL_EDITOR_SETTINGSlibeditconfig () const
 
KIGFX::SCH_RENDER_SETTINGSGetRenderSettings ()
 
COLOR4D GetDrawBgColor () const override
 
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 VECTOR2IGetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const VECTOR2I &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 SYMBOL_LIBRARY_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 SYMBOL_LIBRARY_FILTER *aFilter, const LIB_ID &aPreselectedLibId, int aUnit, int aConvert)
 Call the library viewer to select symbol to import into schematic. More...
 
wxString SelectLibraryFromList ()
 Display a list of loaded libraries and allows the user to select a library. More...
 
SYMBOL_LIB_TABLESelectSymLibTable (bool aOptional=false)
 Display a dialog asking the user to select a symbol library table. More...
 
virtual void RedrawScreen (const VECTOR2I &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 RefreshZoomDependentItems ()
 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...
 
COLOR_SETTINGSGetColorSettings (bool aForceRefresh=false) const override
 Returns a pointer to the active color theme settings. More...
 
void ActivateGalCanvas () override
 Use to start up the GAL drawing canvas. 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...
 
EDA_SEARCH_DATAGetFindReplaceData ()
 
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...
 
VECTOR2I GetNearestGridPosition (const VECTOR2I &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
VECTOR2I GetNearestHalfGridPosition (const VECTOR2I &aPosition) const
 Return the nearest aGridSize / 2 location to aPosition. More...
 
virtual void SetDrawBgColor (const COLOR4D &aColor)
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
 
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 wxchoice. More...
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 Update the checked item in the zoom wxchoice. More...
 
void UpdateZoomSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.) 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 VECTOR2I &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, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Prints the drawing-sheet (frame and title block). More...
 
void DisplayToolMsg (const wxString &msg) override
 
void DisplayConstraintsMsg (const wxString &msg)
 
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...
 
virtual void ClearMsgPanel ()
 Clear all messages from 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 void SwitchCanvas (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Changes the current rendering backend. 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 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)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
virtual ORIGIN_TRANSFORMSGetOriginTransforms ()
 Return a reference to the default ORIGIN_TRANSFORMS object. More...
 
SETTINGS_MANAGERGetSettingsManager () 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)
 
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...
 
virtual APP_SETTINGS_BASEconfig () const
 Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. 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...
 
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
 
void AddStandardHelpMenu (wxMenuBar *aMenuBar)
 Adds the standard KiCad help menu to the menubar. More...
 
bool IsWritable (const wxFileName &aFileName, bool aVerbose=true)
 Checks if aFileName can be written. 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 TOOL_EVENT &aEvent)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const TOOL_EVENT &aEvent)
 Pops a tool from the stack. More...
 
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...
 
bool HasKiway () const
 Safety check before asking for the Kiway reference. 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...
 
EDA_UNITS GetUserUnits () const
 
void SetUserUnits (EDA_UNITS aUnits)
 
const EDA_IU_SCALEGetIuScale () const
 
wxString StringFromValue (double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aValue in internal units into a united string. More...
 
wxString StringFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=false)
 
wxString MessageTextFromValue (double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 A lower-precision version of StringFromValue(). More...
 
wxString MessageTextFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=true)
 
long long int ValueFromString (const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aTextValue in aUnits to internal units used by the frame. More...
 

Static Public Member Functions

static const wxString SchematicHierarchyPaneName ()
 
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...
 

Protected Member Functions

bool doAutoSave () override
 Save the schematic files that have been modified and not yet saved. More...
 
bool isAutoSaveRequired () const override
 Return true if the schematic has been modified. More...
 
void sendNetlistToCvpcb ()
 Send the KiCad netlist over to CVPCB. More...
 
void onSize (wxSizeEvent &aEvent)
 
void handleActivateEvent (wxActivateEvent &aEvent) override
 Handle a window activation event. More...
 
void handleIconizeEvent (wxIconizeEvent &aEvent) override
 Handle a window iconize event. 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)
 
std::vector< wxWindow * > findDialogs ()
 
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...
 
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...
 
void onIconize (wxIconizeEvent &aEvent)
 
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 ()
 
virtual void OnDropFiles (wxDropFilesEvent &aEvent)
 Handles event fired when a file is dropped to the window. More...
 
virtual void DoWithAcceptedFiles ()
 Execute action on accepted dropped file. More...
 

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
 
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
 
std::unique_ptr< EDA_SEARCH_DATAm_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_msgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 
SEARCH_PANEm_searchPane
 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
 
std::vector< wxFileName > m_AcceptedFiles
 
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_supportsAutoSave
 
bool m_autoSaveState
 
wxTimer * m_autoSaveTimer
 
UNDO_REDO_CONTAINER m_undoList
 
UNDO_REDO_CONTAINER m_redoList
 
wxString m_mruPath
 
ORIGIN_TRANSFORMS m_originTransforms
 
std::map< int, UIUpdateHandlerm_uiUpdateMap
 < Map containing the UI update handlers registered with wx for each action. More...
 
bool m_isClosing
 Set by NonUserClose() to indicate that the user did not request the current close. More...
 
bool m_isNonUserClose
 
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
 Associates files extensions with action to execute. More...
 
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 Member Functions

void OnResizeHierarchyNavigator (wxSizeEvent &aEvent)
 
void setupTools ()
 
void OnExit (wxCommandEvent &event)
 
void OnLoadFile (wxCommandEvent &event)
 
void OnAppendProject (wxCommandEvent &event)
 
void OnImportProject (wxCommandEvent &event)
 
void OnClearFileHistory (wxCommandEvent &aEvent)
 
bool canCloseWindow (wxCloseEvent &aCloseEvent) override
 
void doCloseWindow () override
 
void UpdateTitle ()
 Set the main window title bar text. More...
 
void initScreenZoom ()
 Initialize the zoom value of the current screen and mark the screen as zoom-initialized. More...
 
bool checkForNoFullyDefinedLibIds (SCH_SHEET *aSheet)
 Verify that the symbol library links aSheet and all of its child sheets have been remapped to the symbol library table. More...
 
bool importFile (const wxString &aFileName, int aFileType)
 Load the given filename but sets the path to the current project path. More...
 
bool saveSchematicFile (SCH_SHEET *aSheet, const wxString &aSavePath)
 Save aSheet to a schematic file. More...
 
void mapExistingAnnotation (std::map< wxString, wxString > &aMap)
 Fill a map of uuid -> reference from the currently loaded schematic. More...
 
bool updateAutoSaveFile ()
 
const wxString & getAutoSaveFileName () const
 
void windowClosing (wxCloseEvent &event)
 (with its unexpected name so it does not collide with the real OnWindowClose() function provided in derived classes) is called just before a window closing, and is used to call a derivation specific SaveSettings(). More...
 
void commonInit (FRAME_T aFrameType)
 Collect common initialization functions used in all CTORs. More...
 
wxWindow * findQuasiModalDialog ()
 

Private Attributes

SCHEMATICm_schematic
 The currently loaded schematic. More...
 
const SCH_CONNECTIONm_highlightedConn
 The highlighted net or bus, or nullptr. More...
 
wxPageSetupDialogData m_pageSetupData
 
std::vector< std::unique_ptr< SCH_ITEM > > m_items_to_repeat
 For the repeat-last-item cmd. More...
 
wxString m_netListerCommand
 Command line to call a custom net list generator. More...
 
int m_exec_flags
 Flags of the wxExecute() function to call a custom net list generator. More...
 
DIALOG_SCH_FINDm_findReplaceDialog
 
HIERARCHY_NAVIG_PANELm_hierarchy
 
bool m_syncingPcbToSchSelection
 
BASE_SCREENm_currentScreen
 current used SCREEN More...
 
EDA_DRAW_PANEL_GALm_canvas
 This the frame's interface to setting GAL display options. More...
 
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
 
KIWAYm_kiway
 
HOLDER_TYPE m_type
 
const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_userUnits
 

Friends

class SCH_EDITOR_CONTROL
 

Detailed Description

Schematic editor (Eeschema) main window.

Definition at line 97 of file sch_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.

◆ UNDO_REDO_LIST

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

Enumerator
UNDO_LIST 
REDO_LIST 

Definition at line 111 of file eda_base_frame.h.

112 {
113 UNDO_LIST,
115 };

Constructor & Destructor Documentation

◆ SCH_EDIT_FRAME()

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

Definition at line 115 of file sch_edit_frame.cpp.

115 :
116 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
118 m_highlightedConn( nullptr )
119{
120 m_maximizeByDefault = true;
121 m_schematic = new SCHEMATIC( nullptr );
122
123 m_showBorderAndTitleBlock = true; // true to show sheet references
124 m_supportsAutoSave = true;
126 m_aboutTitle = _( "KiCad Schematic Editor" );
127
128 m_findReplaceDialog = nullptr;
129
130 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
131
132 // Give an icon
133 wxIcon icon;
134 wxIconBundle icon_bundle;
135
136 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema ) );
137 icon_bundle.AddIcon( icon );
138 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
139 icon_bundle.AddIcon( icon );
140 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
141 icon_bundle.AddIcon( icon );
142
143 SetIcons( icon_bundle );
144
146
147 // NB: also links the schematic to the loaded project
149
150 setupTools();
156
158
159 // Initialize common print setup dialog settings.
160 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
161 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
162 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
163 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
164
165 m_auimgr.SetManagedWindow( this );
166
168
169 // Rows; layers 4 - 6
170 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
171 .Top().Layer( 6 ) );
172
173 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
174 .Bottom().Layer( 6 ) );
175
176 // Columns; layers 1 - 3
177 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
178 .Caption( _( "Schematic Hierarchy" ) )
179 .Left().Layer( 3 )
180 .TopDockable( false )
181 .BottomDockable( false )
182 .CloseButton( true )
183 .MinSize( 120, 60 )
184 .BestSize( 200, 200 )
185 .FloatingSize( 200, 200 )
186 .Show( false ) );
187 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
188 .Left().Layer( 2 ) );
189
190 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
191 .Right().Layer( 2 ) );
192
193 // Center
194 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
195 .Center() );
196
198
201
202 GetCanvas()->GetGAL()->SetAxesEnabled( false );
203
204 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
205 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
206
207 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
209
210 hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
211
214 {
215 // Show at end, after positioning
216 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
218 }
219
221 hierarchy_pane.Float();
222
224 {
225 SetAuiPaneSize( m_auimgr, hierarchy_pane,
227
228 // wxAUI hack: force width by setting MinSize() and then Fixed()
229 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
230 hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 );
231 hierarchy_pane.Fixed();
232 m_auimgr.Update();
233
234 // now make it resizable again
235 hierarchy_pane.Resizable();
236 m_auimgr.Update();
237
238 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
239 // back to minimum.
240 hierarchy_pane.MinSize( 120, 60 );
241 }
242 else
243 {
244 m_auimgr.Update();
245 }
246
248
250
251 m_hierarchy->Connect( wxEVT_SIZE,
252 wxSizeEventHandler( SCH_EDIT_FRAME::OnResizeHierarchyNavigator ),
253 NULL, this );
254
255
256 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
257 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
258 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
259
260 setupUnits( eeconfig() );
261
262 // Net list generator
264
265 UpdateTitle();
266 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
267
268 // Default shutdown reason until a file is loaded
269 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
270
271 // Init for dropping files
273 DragAcceptFiles( true );
274
275 // Ensure the window is on top
276 Raise();
277
278 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
279 // top-left corner of the canvas
280 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
281 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
282}
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
@ icon_eeschema
@ icon_eeschema_16
@ icon_eeschema_32
void FinishAUIInitialization()
wxAuiManager m_auimgr
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associates files extensions with action to execute.
wxString m_aboutTitle
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void setupUnits(APP_SETTINGS_BASE *aCfg)
ACTION_TOOLBAR * m_optionsToolBar
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
EDA_MSG_PANEL * m_messagePanel
ACTION_TOOLBAR * m_mainToolBar
ACTION_TOOLBAR * m_drawToolBar
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
bool m_showBorderAndTitleBlock
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:258
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:134
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
Holds all the data relating to one schematic.
Definition: schematic.h:60
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DefaultExecFlags()
Reset the execution flags to defaults for external netlist and bom generators.
HIERARCHY_NAVIG_PANEL * m_hierarchy
wxPageSetupDialogData m_pageSetupData
void UpdateTitle()
Set the main window title bar text.
bool m_syncingPcbToSchSelection
void onSize(wxSizeEvent &aEvent)
SCHEMATIC * m_schematic
The currently loaded schematic.
void ReCreateVToolbar() override
bool LoadProjectSettings()
Load the KiCad project file (*.pro) settings specific to Eeschema.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
static const wxString SchematicHierarchyPaneName()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void ReCreateMenuBar() override
Recreates the menu bar.
void ReCreateOptToolbar() override
DIALOG_SCH_FIND * m_findReplaceDialog
const SCH_CONNECTION * m_highlightedConn
The highlighted net or bus, or nullptr.
void OnResizeHierarchyNavigator(wxSizeEvent &aEvent)
void ReCreateHToolbar() override
Handle actions specific to the schematic editor.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ FRAME_SCH
Definition: frame_type.h:34
const std::string KiCadSchematicFileExtension
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.

References _, PCAD2KICAD::Center, EE_ACTIONS::ddAppendFile, KIGFX::eeconfig(), KIGFX::VIEW::GetPainter(), EESCHEMA_SETTINGS::AUI_PANELS::hierarchy_panel_docked_width, EESCHEMA_SETTINGS::AUI_PANELS::hierarchy_panel_float_height, EESCHEMA_SETTINGS::AUI_PANELS::hierarchy_panel_float_width, icon_eeschema, icon_eeschema_16, icon_eeschema_32, KiBitmap(), KiCadSchematicFileExtension, PCAD2KICAD::Left, EESCHEMA_SETTINGS::m_AuiPanels, OnResizeHierarchyNavigator(), onSize(), PCAD2KICAD::Right, EESCHEMA_SETTINGS::AUI_PANELS::schematic_hierarchy_float, SetAuiPaneSize(), KIPLATFORM::APP::SetShutdownBlockReason(), and EESCHEMA_SETTINGS::AUI_PANELS::show_schematic_hierarchy.

◆ ~SCH_EDIT_FRAME()

SCH_EDIT_FRAME::~SCH_EDIT_FRAME ( )
override

Definition at line 285 of file sch_edit_frame.cpp.

286{
287 m_hierarchy->Disconnect( wxEVT_SIZE,
288 wxSizeEventHandler( SCH_EDIT_FRAME::OnResizeHierarchyNavigator ),
289 NULL, this );
290 // Ensure m_canvasType is up to date, to save it in config
292
293 // Close modeless dialogs
294 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
295
296 if( open_dlg )
297 open_dlg->Close( true );
298
299 // Shutdown all running tools
300 if( m_toolManager )
301 {
303 delete m_toolManager;
304 m_toolManager = nullptr;
305 }
306
307 SetScreen( nullptr );
308
309 delete m_schematic;
310 m_schematic = nullptr;
311
312 // Close the project if we are standalone, so it gets cleaned up properly
313 if( Kiface().IsSingle() )
314 {
315 try
316 {
317 GetSettingsManager()->UnloadProject( &Prj(), false );
318 }
319 catch( const nlohmann::detail::type_error& exc )
320 {
321 // This may be overkill and could be an assertion but we are more likely to
322 // find any settings manager errors this way.
323 wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
324 }
325 }
326
327 delete m_hierarchy;
328}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
SETTINGS_MANAGER * GetSettingsManager() const
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void SetScreen(BASE_SCREEN *aScreen) override
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
#define DIALOG_ERC_WINDOW_NAME
Definition: dialog_erc.h:37

References DIALOG_ERC_WINDOW_NAME, EDA_DRAW_PANEL_GAL::GetBackend(), SCH_BASE_FRAME::GetCanvas(), EDA_BASE_FRAME::GetSettingsManager(), Kiface(), EDA_DRAW_FRAME::m_canvasType, m_hierarchy, m_schematic, TOOLS_HOLDER::m_toolManager, OnResizeHierarchyNavigator(), KIWAY_HOLDER::Prj(), SetScreen(), TOOL_MANAGER::ShutdownAllTools(), and SETTINGS_MANAGER::UnloadProject().

Member Function Documentation

◆ ActivateGalCanvas()

void SCH_BASE_FRAME::ActivateGalCanvas ( )
overridevirtualinherited

Use to start up the GAL drawing canvas.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 348 of file sch_base_frame.cpp.

349{
351
352#if defined( KICAD_USE_3DCONNEXION )
353 try
354 {
355 if( !m_spaceMouse )
356 {
357 m_spaceMouse = new NL_SCHEMATIC_PLUGIN();
358 }
359
360 m_spaceMouse->SetCanvas( GetCanvas() );
361 }
362 catch( const std::system_error& e )
363 {
364 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
365 }
366#endif
367}
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
The class that implements the public interface to the SpaceMouse plug-in.

References EDA_DRAW_FRAME::ActivateGalCanvas(), and SCH_BASE_FRAME::GetCanvas().

Referenced by SCH_BASE_FRAME::createCanvas(), and SCH_DRAW_PANEL::OnShow().

◆ AddCopyForRepeatItem()

void SCH_EDIT_FRAME::AddCopyForRepeatItem ( const SCH_ITEM aItem)

Definition at line 604 of file sch_edit_frame.cpp.

605{
606 // we cannot store a pointer to an item in the display list here since
607 // that item may be deleted, such as part of a line concatenation or other.
608 // So simply always keep a copy of the object which is to be repeated.
609
610 if( aItem )
611 {
612 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Clone() ) );
613
614 // Clone() preserves the flags, we want 'em cleared.
615 repeatItem->ClearFlags();
616
617 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
618 }
619}
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
std::vector< std::unique_ptr< SCH_ITEM > > m_items_to_repeat
For the repeat-last-item cmd.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147

References EDA_ITEM::Clone(), and m_items_to_repeat.

Referenced by SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_EDIT_TOOL::RepeatDrawItem(), and SaveCopyForRepeatItem().

◆ AddItemToScreenAndUndoList()

void SCH_EDIT_FRAME::AddItemToScreenAndUndoList ( SCH_SCREEN aScreen,
SCH_ITEM aItem,
bool  aUndoAppend 
)

Add an item to the schematic and adds the changes to the undo/redo container.

Parameters
aUndoAppendTrue if the action should be appended to the current undo record.

Definition at line 1324 of file sch_edit_frame.cpp.

1326{
1327 wxCHECK_RET( aItem != nullptr, wxT( "Cannot add null item to list." ) );
1328
1329 SCH_SHEET* parentSheet = nullptr;
1330 SCH_SYMBOL* parentSymbol = nullptr;
1331 SCH_ITEM* undoItem = aItem;
1332
1333 if( aItem->Type() == SCH_SHEET_PIN_T )
1334 {
1335 parentSheet = (SCH_SHEET*) aItem->GetParent();
1336
1337 wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1338 wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1339
1340 undoItem = parentSheet;
1341 }
1342
1343 else if( aItem->Type() == SCH_FIELD_T )
1344 {
1345 parentSymbol = (SCH_SYMBOL*) aItem->GetParent();
1346
1347 wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_SYMBOL_T,
1348 wxT( "Cannot place field in invalid schematic symbol." ) );
1349
1350 undoItem = parentSymbol;
1351 }
1352
1353 if( aItem->IsNew() )
1354 {
1355 if( aItem->Type() == SCH_SHEET_PIN_T )
1356 {
1357 // Sheet pins are owned by their parent sheet.
1358 SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1359
1360 parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1361 }
1362 else if( aItem->Type() == SCH_FIELD_T )
1363 {
1364 // Symbol fields are also owned by their parent, but new symbol fields are
1365 // handled elsewhere.
1366 wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1367 }
1368 else
1369 {
1370 if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1371 AddToScreen( aItem, aScreen );
1372
1373 SaveCopyForRepeatItem( aItem );
1374 SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1375 }
1376
1377 // Update connectivity info for new item
1378 if( !aItem->IsMoving() )
1380 }
1381
1382 aItem->ClearFlags( IS_NEW );
1383
1384 aScreen->SetContentModified();
1385 UpdateItem( aItem );
1386
1387 if( !aItem->IsMoving() && aItem->IsConnectable() )
1388 {
1389 std::vector<VECTOR2I> pts = aItem->GetConnectionPoints();
1390
1391 bool connected = true;
1392 for( auto i = pts.begin(); i != pts.end(); i++ )
1393 {
1394 for( auto j = i + 1; j != pts.end(); j++ )
1395 TrimWire( *i, *j );
1396
1397 if( aScreen->IsExplicitJunctionNeeded( *i ) )
1398 {
1399 AddJunction( aScreen, *i, true, false );
1400 connected = true;
1401 }
1402 }
1403
1404 if( connected )
1405 {
1406 AutoRotateItem( aScreen, aItem );
1407 }
1408
1410
1411 for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1412 UpdateItem( item );
1413 }
1414
1415 aItem->ClearEditFlags();
1416 GetCanvas()->Refresh();
1417}
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
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...
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
void ClearEditFlags()
Definition: eda_item.h:160
bool IsMoving() const
Definition: eda_item.h:104
bool IsNew() const
Definition: eda_item.h:103
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,...
bool TrimWire(const VECTOR2I &aStart, const VECTOR2I &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCH_SHEET_PATH & GetCurrentSheet() const
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const VECTOR2I &aPos, bool aAppendToUndo, bool aFinal=true)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
virtual bool IsConnectable() const
Definition: sch_item.h:340
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:187
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:355
bool IsExplicitJunctionNeeded(const VECTOR2I &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
Definition: sch_screen.cpp:437
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:329
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:352
Schematic symbol object.
Definition: sch_symbol.h:79
#define IS_NEW
New item, just created.
@ LOCAL_CLEANUP
@ SCH_SYMBOL_T
Definition: typeinfo.h:155
@ SCH_FIELD_T
Definition: typeinfo.h:154
@ SCH_SHEET_T
Definition: typeinfo.h:157
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:156

References AddJunction(), SCH_SHEET::AddPin(), SCH_BASE_FRAME::AddToScreen(), AutoRotateItem(), CHANGED, SCH_SCREEN::CheckIfOnDrawList(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearFlags(), SCH_ITEM::ConnectedItems(), SCH_BASE_FRAME::GetCanvas(), SCH_ITEM::GetConnectionPoints(), GetCurrentSheet(), EDA_ITEM::GetParent(), IS_NEW, SCH_ITEM::IsConnectable(), SCH_SCREEN::IsExplicitJunctionNeeded(), EDA_ITEM::IsMoving(), EDA_ITEM::IsNew(), LOCAL_CLEANUP, NEWITEM, RecalculateConnections(), EDA_DRAW_PANEL_GAL::Refresh(), SaveCopyForRepeatItem(), SaveCopyInUndoList(), SCH_FIELD_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, BASE_SCREEN::SetContentModified(), TestDanglingEnds(), TrimWire(), EDA_ITEM::Type(), and UpdateItem().

Referenced by SCH_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceImage(), SCH_DRAWING_TOOLS::PlaceSymbol(), BACK_ANNOTATE::processNetNameChange(), SCH_DRAWING_TOOLS::SingleClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ AddJunction()

SCH_JUNCTION * SCH_EDIT_FRAME::AddJunction ( SCH_SCREEN aScreen,
const VECTOR2I aPos,
bool  aAppendToUndo,
bool  aFinal = true 
)

Definition at line 454 of file bus-wire-junction.cpp.

456{
457 SCH_JUNCTION* junction = new SCH_JUNCTION( aPos );
458
459 AddToScreen( junction, aScreen );
460 SaveCopyInUndoList( aScreen, junction, UNDO_REDO::NEWITEM, aUndoAppend );
461 BreakSegments( aPos );
462
463 if( aFinal )
464 {
466
468 OnModify();
469
470 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
471 view->ClearPreview();
472 view->ShowPreview( false );
473 view->ClearHiddenFlags();
474 }
475
476 return junction;
477}
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:210
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:181
void ShowPreview(bool aShow=true)
Definition: view.cpp:1632
void ClearPreview()
Definition: view.cpp:1596
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
bool BreakSegments(const VECTOR2I &aPoint, SCH_SCREEN *aScreen=nullptr)
Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an int...
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.

References SCH_BASE_FRAME::AddToScreen(), BreakSegments(), KIGFX::SCH_VIEW::ClearHiddenFlags(), KIGFX::VIEW::ClearPreview(), SCH_BASE_FRAME::GetCanvas(), SCH_DRAW_PANEL::GetView(), TOOLS_HOLDER::m_toolManager, NEWITEM, OnModify(), TOOL_MANAGER::PostEvent(), SaveCopyInUndoList(), EVENTS::SelectedItemsModified, KIGFX::VIEW::ShowPreview(), and TestDanglingEnds().

Referenced by AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), and SCH_MOVE_TOOL::Main().

◆ AddSheetAndUpdateDisplay()

bool SCH_EDIT_FRAME::AddSheetAndUpdateDisplay ( const wxString  aFullFileName)

Add a sheet file into the current sheet and updates display.

Note
Used in AppendSchematic() and SCH_EDIT_TOOL::ddAppendFile() (so it is public)
Parameters
aFullFileNamePath and name of sheet
Returns
True if the sheet was properly added

Definition at line 548 of file eeschema/files-io.cpp.

549{
550 if( !LoadSheetFromFile( GetCurrentSheet().Last(), &GetCurrentSheet(), aFullFileName ) )
551 return false;
552
555
556 SyncView();
557 OnModify();
558 HardRedraw(); // Full reinit of the current screen and the display.
559
561
562 return true;
563}
void SyncView()
Mark all items for refresh.
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:105
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.

References GetCurrentSheet(), HardRedraw(), initScreenZoom(), LoadSheetFromFile(), OnModify(), SetSheetNumberAndCount(), SCH_BASE_FRAME::SyncView(), and UpdateHierarchyNavigator().

Referenced by AppendSchematic(), and SCH_EDIT_TOOL::DdAppendFile().

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 443 of file eda_base_frame.cpp.

444{
446 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
447
448 helpMenu->Add( ACTIONS::help );
449 helpMenu->Add( ACTIONS::gettingStarted );
450 helpMenu->Add( ACTIONS::listHotKeys );
451 helpMenu->Add( ACTIONS::getInvolved );
452 helpMenu->Add( ACTIONS::donate );
453 helpMenu->Add( ACTIONS::reportBug );
454
455 helpMenu->AppendSeparator();
456 helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
457
458 // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
459 aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
460}
static TOOL_ACTION reportBug
Cursor control event types.
Definition: actions.h:186
static TOOL_ACTION donate
Definition: actions.h:184
static TOOL_ACTION listHotKeys
Definition: actions.h:183
static TOOL_ACTION getInvolved
Definition: actions.h:185
static TOOL_ACTION gettingStarted
Definition: actions.h:181
static TOOL_ACTION help
Definition: actions.h:182
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
Handle actions that are shared between different applications.

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(), CVPCB_MAINFRAME::ReCreateMenuBar(), ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_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 546 of file eda_draw_frame.cpp.

547{
549 CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
550
551 aMenu.AddSeparator( 1000 );
552
553 std::shared_ptr<ZOOM_MENU> zoomMenu = std::make_shared<ZOOM_MENU>( this );
554 zoomMenu->SetTool( commonTools );
555 aToolMenu.RegisterSubMenu( zoomMenu );
556
557 std::shared_ptr<GRID_MENU> gridMenu = std::make_shared<GRID_MENU>( this );
558 gridMenu->SetTool( commonTools );
559 aToolMenu.RegisterSubMenu( gridMenu );
560
561 aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
562 aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
563}
Handles action that are shared between different applications.
Definition: common_tools.h:38
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44

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

Referenced by EE_SELECTION_TOOL::Init(), PICKER_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_SELECTION_TOOL::Init(), ROUTER_TOOL::Init(), PCB_SELECTION_TOOL::Init(), and PCB_VIEWER_TOOLS::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 440 of file sch_base_frame.cpp.

441{
442 // Null pointers will cause boost::ptr_vector to raise a boost::bad_pointer exception which
443 // will be unhandled. There is no valid reason to pass an invalid EDA_ITEM pointer to the
444 // screen append function.
445 wxCHECK( aItem != nullptr, /* voide */ );
446
447 auto screen = aScreen;
448
449 if( aScreen == nullptr )
450 screen = GetScreen();
451
452 screen->Append( (SCH_ITEM*) aItem );
453
454 if( screen == GetScreen() )
455 {
456 GetCanvas()->GetView()->Add( aItem );
457 UpdateItem( aItem, true ); // handle any additional parent semantics
458 }
459}
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.

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

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

◆ AllowCaseSensitiveFileNameClashes()

bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes ( const wxString &  aSchematicFileName)

Check aSchematicFileName for a potential file name case sensitivity clashes.

On platforms where file names are case sensitive, it is possible to schematic sheet file names that would cause issues on platforms where file name are case insensitive. File names foo.sch and Foo.sch are unique files on Linux and MacOS but on Windows this would result in a broken schematic.

Parameters
aSchematicFileNameis the absolute path and file name of the file to test.
Returns
true if the user accepts the potential file name clash risk.

Definition at line 553 of file sheet.cpp.

554{
555 wxString msg;
556 SCH_SCREENS screens( Schematic().Root() );
557 wxFileName fn = aSchematicFileName;
558
559 wxCHECK( fn.IsAbsolute(), false );
560
561 if( eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog
562 && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
563 {
564 msg.Printf( _( "The file name '%s' can cause issues with an existing file name\n"
565 "already defined in the schematic on systems that support case\n"
566 "insensitive file names. This will cause issues if you copy this\n"
567 "project to an operating system that supports case insensitive file\n"
568 "names.\n\nDo you wish to continue?" ),
569 fn.GetName() );
570
571 wxRichMessageDialog dlg( this, msg, _( "Warning" ),
572 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
573 dlg.ShowCheckBox( _( "Do not show this message again." ) );
574 dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
575 wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
576
577 if( dlg.ShowModal() == wxID_NO )
578 return false;
579
581 !dlg.IsCheckBoxChecked();
582 }
583
584 return true;
585}
SCHEMATIC & Schematic() const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:613

References _, SCH_SCREENS::CanCauseCaseSensitivityIssue(), SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::m_Appearance, Schematic(), and EESCHEMA_SETTINGS::APPEARANCE::show_sheet_filename_case_sensitivity_dialog.

Referenced by DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged().

◆ AnnotateSymbols()

void SCH_EDIT_FRAME::AnnotateSymbols ( ANNOTATE_SCOPE_T  aAnnotateScope,
ANNOTATE_ORDER_T  aSortOption,
ANNOTATE_ALGO_T  aAlgoOption,
bool  aRecursive,
int  aStartNumber,
bool  aResetAnnotation,
bool  aRepairTimestamps,
REPORTER aReporter,
bool  appendUndo = false 
)

Annotate the symbols in the schematic that are not currently annotated.

Multi-unit symbols are annotated together. E.g. if two symbols were R8A and R8B, they may become R3A and R3B, but not R3A and R3C or R3C and R4D.

Parameters
aAnnotateScopeSee ANNOTATE_SCOPE_T
aSortOptionDefine the annotation order. See ANNOTATE_ORDER_T.
aAlgoOptionDefine the annotation style. See ANNOTATE_ALGO_T.
aRecursiveAnnotation should descend into and annotate subsheets
aStartNumberThe start number for non-sheet-based annotation styles.
aResetAnnotationClear any previous annotation if true. Otherwise, keep the existing symbol annotation.
aRepairTimestampsTest for and repair any duplicate time stamps if true. Otherwise, keep the existing time stamps. This option could change previous annotation because time stamps are used to handle annotation in complex hierarchies.
aReporterA sink for error messages. Use NULL_REPORTER if you don't need errors.
appendUndoTrue if the annotation operation should be added to an existing undo, false if it should be separately undo-able.

When the sheet number is used in annotation, each sheet annotation starts from sheet number * 100. In other words the first sheet uses 100 to 199, the second sheet uses 200 to 299, and so on.

Definition at line 194 of file annotate.cpp.

203{
205 EE_SELECTION& selection = selTool->RequestSelection();
206
207 SCH_REFERENCE_LIST references;
208 SCH_SCREENS screens( Schematic().Root() );
210 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
211
212
213 // Store the selected sheets relative to the full hierarchy so we get the correct sheet numbers
214 SCH_SHEET_LIST selectedSheets;
215
216 for( EDA_ITEM* item : selection )
217 {
218 if( item->Type() == SCH_SHEET_T )
219 {
220 SCH_SHEET_PATH subSheetPath = currentSheet;
221 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
222
223 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
224 }
225 }
226
227
228 // Like above, store subsheets relative to full hierarchy for recursive annotation from current
229 // sheet
230 SCH_SHEET_LIST subSheets;
231
232 std::vector<SCH_ITEM*> tempSubSheets;
233 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
234
235 for( SCH_ITEM* item : tempSubSheets )
236 {
237 SCH_SHEET_PATH subSheetPath = currentSheet;
238 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
239
240 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
241 }
242
243
244 std::unordered_set<SCH_SYMBOL*> selectedSymbols;
245
246 if( aAnnotateScope == ANNOTATE_SELECTION )
247 selectedSymbols = getInferredSymbols( selection );
248
249
250 // Map of locked symbols
251 SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
252
253 // Map of previous annotation for building info messages
254 std::map<wxString, wxString> previousAnnotation;
255
256 // Test for and replace duplicate time stamps in symbols and sheets. Duplicate time stamps
257 // can happen with old schematics, schematic conversions, or manual editing of files.
258 if( aRepairTimestamps )
259 {
260 int count = screens.ReplaceDuplicateTimeStamps();
261
262 if( count )
263 {
264 wxString msg;
265 msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
266 aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
267 }
268 }
269
270 // Collect all the sets that must be annotated together.
271 switch( aAnnotateScope )
272 {
273 case ANNOTATE_ALL:
274 sheets.GetMultiUnitSymbols( lockedSymbols );
275 break;
276
278 currentSheet.GetMultiUnitSymbols( lockedSymbols );
279 break;
280
282 for( SCH_SYMBOL* symbol : selectedSymbols )
283 currentSheet.AppendMultiUnitSymbol( lockedSymbols, symbol );
284
285 break;
286 }
287
288 // Store previous annotations for building info messages
289 mapExistingAnnotation( previousAnnotation );
290
291 // Set sheet number and number of sheets.
293
294 // Build symbol list
295 switch( aAnnotateScope )
296 {
297 case ANNOTATE_ALL:
298 sheets.GetSymbols( references );
299 break;
300
302 currentSheet.GetSymbols( references );
303
304 if( aRecursive )
305 subSheets.GetSymbolsWithinPath( references, currentSheet, false, true );
306
307 break;
308
310 for( SCH_SYMBOL* symbol : selectedSymbols )
311 currentSheet.AppendSymbol( references, symbol, false, true );
312
313 if( aRecursive )
314 selectedSheets.GetSymbolsWithinPath( references, currentSheet, false, true );
315
316 break;
317 }
318
319 // Remove annotation only updates the "new" flag to indicate to the algorithm
320 // that these references must be reannotated, but keeps the original reference
321 // so that we can reannotate multi-unit symbols together.
322 if( aResetAnnotation )
323 references.RemoveAnnotation( false );
324
325 // Build additional list of references to be used during reannotation
326 // to avoid duplicate designators (no additional references when annotating
327 // the full schematic)
328 SCH_REFERENCE_LIST additionalRefs;
329
330 if( aAnnotateScope != ANNOTATE_ALL )
331 {
332 SCH_REFERENCE_LIST allRefs;
333 sheets.GetSymbols( allRefs );
334
335 for( size_t i = 0; i < allRefs.GetCount(); i++ )
336 {
337 if( !references.Contains( allRefs[i] ) )
338 additionalRefs.AddItem( allRefs[i] );
339 }
340 }
341
342 // Break full symbol reference into name (prefix) and number:
343 // example: IC1 become IC, and 1
344 references.SplitReferences();
345
346 // Annotate all of the references we've collected by our options
347 references.AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols,
348 additionalRefs, false );
349
350 for( size_t i = 0; i < references.GetCount(); i++ )
351 {
352 SCH_REFERENCE& ref = references[i];
353 SCH_SYMBOL* symbol = ref.GetSymbol();
354 SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
355
356 SaveCopyInUndoList( sheet->LastScreen(), symbol, UNDO_REDO::CHANGED, appendUndo );
357 appendUndo = true;
358 ref.Annotate();
359
360 KIID_PATH full_uuid = sheet->Path();
361 full_uuid.push_back( symbol->m_Uuid );
362
363 wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
364 wxString newRef = symbol->GetRef( sheet );
365
366 if( symbol->GetUnitCount() > 1 )
367 newRef << LIB_SYMBOL::SubReference( symbol->GetUnitSelection( sheet ) );
368
369 wxString msg;
370
371 if( prevRef.Length() )
372 {
373 if( newRef == prevRef )
374 continue;
375
376 if( symbol->GetUnitCount() > 1 )
377 {
378 msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
379 symbol->GetValue( sheet, true ),
380 LIB_SYMBOL::SubReference( symbol->GetUnit(), false ),
381 prevRef,
382 newRef );
383 }
384 else
385 {
386 msg.Printf( _( "Updated %s from %s to %s." ),
387 symbol->GetValue( sheet, true ),
388 prevRef,
389 newRef );
390 }
391 }
392 else
393 {
394 if( symbol->GetUnitCount() > 1 )
395 {
396 msg.Printf( _( "Annotated %s (unit %s) as %s." ),
397 symbol->GetValue( sheet, true ),
398 LIB_SYMBOL::SubReference( symbol->GetUnit(), false ),
399 newRef );
400 }
401 else
402 {
403 msg.Printf( _( "Annotated %s as %s." ),
404 symbol->GetValue( sheet, true ),
405 newRef );
406 }
407 }
408
409 aReporter.Report( msg, RPT_SEVERITY_ACTION );
410 }
411
412 // Final control (just in case ... ).
413 if( !CheckAnnotate(
414 [ &aReporter ]( ERCE_T , const wxString& aMsg, SCH_REFERENCE* , SCH_REFERENCE* )
415 {
416 aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
417 },
418 aAnnotateScope, aRecursive ) )
419 {
420 aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
421 }
422
423 // Update on screen references, that can be modified by previous calculations:
426
427 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
428
429 if( erc_dlg )
430 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
431
432 SyncView();
433 GetCanvas()->Refresh();
434 OnModify();
435
436 // Must go after OnModify() so the connectivity graph has been updated
438}
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const EE_SELECTION &aSelection)
Definition: annotate.cpp:163
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const KIID m_Uuid
Definition: eda_item.h:492
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
Return either an existing selection (filtered), or the selection at the current cursor position if th...
wxString AsString() const
Definition: kiid.cpp:330
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:588
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.h:99
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:85
void mapExistingAnnotation(std::map< wxString, wxString > &aMap)
Fill a map of uuid -> reference from the currently loaded schematic.
Definition: annotate.cpp:38
int CheckAnnotate(ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL, bool aRecursive=true)
Check for annotation errors.
Definition: annotate.cpp:441
void UpdateNetHighlightStatus()
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
bool Contains(const SCH_REFERENCE &aItem) const
Return true if aItem exists in this list.
void AnnotateByOptions(enum ANNOTATE_ORDER_T aSortOption, enum ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent)
Annotate the references by the provided options.
size_t GetCount() const
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void AddItem(const SCH_REFERENCE &aItem)
void RemoveAnnotation(bool aIncludePowerSymbols)
Treat all symbols in this list as non-annotated.
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
SCH_SYMBOL * GetSymbol() const
void Annotate()
Update the annotation of the symbol according the current object state.
void GetSheets(std::vector< SCH_ITEM * > *aItems) const
Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
void GetSheetsWithinPath(SCH_SHEET_PATHS &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sh...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:429
int GetUnit() const
Definition: sch_symbol.h:225
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:516
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific value for the given sheet path.
Definition: sch_symbol.cpp:651
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:609
ERCE_T
ERC error codes.
Definition: erc_settings.h:37
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION
@ ANNOTATE_SELECTION
Annotate the selection.
@ ANNOTATE_CURRENT_SHEET
Annotate the current sheet.
@ ANNOTATE_ALL
Annotate the full schematic.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.

References _, SCH_REFERENCE_LIST::AddItem(), SCH_REFERENCE::Annotate(), ANNOTATE_ALL, ANNOTATE_CURRENT_SHEET, ANNOTATE_SELECTION, SCH_REFERENCE_LIST::AnnotateByOptions(), SCH_SHEET_PATH::AppendMultiUnitSymbol(), SCH_SHEET_PATH::AppendSymbol(), KIID_PATH::AsString(), CHANGED, CheckAnnotate(), SCH_REFERENCE_LIST::Contains(), DIALOG_ERC_WINDOW_NAME, SCH_BASE_FRAME::GetCanvas(), SCH_REFERENCE_LIST::GetCount(), GetCurrentSheet(), getInferredSymbols(), SCH_SHEET_PATH::GetMultiUnitSymbols(), SCH_SHEET_LIST::GetMultiUnitSymbols(), SCH_SYMBOL::GetRef(), SCH_REFERENCE::GetSheetPath(), SCHEMATIC::GetSheets(), SCH_SCREEN::GetSheets(), SCH_SHEET_LIST::GetSheetsWithinPath(), SCH_REFERENCE::GetSymbol(), SCH_SHEET_PATH::GetSymbols(), SCH_SHEET_LIST::GetSymbols(), SCH_SHEET_LIST::GetSymbolsWithinPath(), TOOL_MANAGER::GetTool(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), SCH_SYMBOL::GetUnitSelection(), SCH_SYMBOL::GetValue(), SCH_SHEET_PATH::LastScreen(), TOOLS_HOLDER::m_toolManager, EDA_ITEM::m_Uuid, mapExistingAnnotation(), OnModify(), SCH_SHEET_PATH::Path(), SCH_SHEET_PATH::push_back(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_REFERENCE_LIST::RemoveAnnotation(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), REPORTER::Report(), REPORTER::ReportTail(), EE_SELECTION_TOOL::RequestSelection(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, SaveCopyInUndoList(), SCH_SHEET_T, Schematic(), SetSheetNumberAndCount(), SCH_REFERENCE_LIST::SplitReferences(), LIB_SYMBOL::SubReference(), SCH_BASE_FRAME::SyncView(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and UpdateNetHighlightStatus().

Referenced by DIALOG_ANNOTATE::OnApplyClick(), and SCH_EDIT_TOOL::RepeatDrawItem().

◆ 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 708 of file eda_draw_frame.cpp.

710{
711 if( m_messagePanel )
712 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
713}
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:93

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

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

◆ AppendSchematic()

bool SCH_EDIT_FRAME::AppendSchematic ( )

Import a KiCad schematic into the current sheet.

Returns
True if the schematic was imported properly.

Definition at line 525 of file eeschema/files-io.cpp.

526{
527 SCH_SCREEN* screen = GetScreen();
528
529 if( !screen )
530 {
531 wxLogError( wxT( "Document not ready, cannot import" ) );
532 return false;
533 }
534
535 // open file chooser dialog
536 wxString path = wxPathOnly( Prj().GetProjectFullName() );
537
538 wxFileDialog dlg( this, _( "Insert Schematic" ), path, wxEmptyString,
539 KiCadSchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
540
541 if( dlg.ShowModal() == wxID_CANCEL )
542 return false;
543
544 return AddSheetAndUpdateDisplay( dlg.GetPath() );
545}
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool AddSheetAndUpdateDisplay(const wxString aFullFileName)
Add a sheet file into the current sheet and updates display.
wxString KiCadSchematicFileWildcard()

References _, AddSheetAndUpdateDisplay(), GetScreen(), KiCadSchematicFileWildcard(), path, and KIWAY_HOLDER::Prj().

Referenced by OnAppendProject().

◆ AskToSaveChanges()

bool SCH_EDIT_FRAME::AskToSaveChanges ( )

Check if any of the screens has unsaved changes and asks the user whether to save or drop them.

Returns
True if user decided to save or drop changes, false if the operation should be canceled.

Definition at line 1284 of file eeschema/files-io.cpp.

1285{
1286 SCH_SCREENS screenList( Schematic().Root() );
1287
1288 // Save any currently open and modified project files.
1289 for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1290 {
1291 SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
1292
1293 // Simulator must be closed before loading another schematic, otherwise it may crash.
1294 // If there are any changes in the simulator the user will be prompted to save them.
1295 if( simFrame && !simFrame->Close() )
1296 return false;
1297
1298 if( screen->IsContentModified() )
1299 {
1300 if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
1301 "Save changes?" ),
1302 [&]() -> bool
1303 {
1304 return SaveProject();
1305 } ) )
1306 {
1307 return false;
1308 }
1309 }
1310 }
1311
1312 return true;
1313}
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:394
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
Implementing SIM_PLOT_FRAME_BASE.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:240
@ FRAME_SIMULATOR
Definition: frame_type.h:38

References _, FRAME_SIMULATOR, SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), HandleUnsavedChanges(), KIWAY_HOLDER::Kiway(), KIWAY::Player(), SaveProject(), and Schematic().

Referenced by OnImportProject(), and OpenProjectFiles().

◆ AutoRotateItem()

void SCH_EDIT_FRAME::AutoRotateItem ( SCH_SCREEN aScreen,
SCH_ITEM aItem 
)

Automatically set the rotation of an item (if the item supports it)

Definition at line 1298 of file sch_edit_frame.cpp.

1299{
1300 if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
1301 {
1302 auto label = static_cast<SCH_LABEL_BASE*>( aItem );
1303 if( label->AutoRotateOnPlacement() )
1304 {
1305 auto textSpin = aScreen->GetLabelOrientationForPoint(
1306 label->GetPosition(), label->GetTextSpinStyle(), &GetCurrentSheet() );
1307 if( textSpin != label->GetTextSpinStyle() )
1308 {
1309 label->SetTextSpinStyle( textSpin );
1310 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1311 {
1312 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1313 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1314 {
1315 otherLabel->AutoplaceFields( aScreen, false );
1316 }
1317 }
1318 }
1319 }
1320 }
1321}
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:162
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:376
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
TEXT_SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, TEXT_SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:446
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151

References SCH_LABEL_BASE::AutoplaceFields(), GetCurrentSheet(), SCH_SCREEN::GetLabelOrientationForPoint(), EDA_TEXT::GetText(), SCH_ITEM::IsType(), SCH_SCREEN::Items(), EE_RTREE::OfType(), and SCH_GLOBAL_LABEL_T.

Referenced by AddItemToScreenAndUndoList(), and SCH_EDIT_TOOL::Swap().

◆ BreakSegment()

bool SCH_EDIT_FRAME::BreakSegment ( SCH_LINE aSegment,
const VECTOR2I aPoint,
SCH_LINE **  aNewSegment = nullptr,
SCH_SCREEN aScreen = nullptr 
)

Break a single segment into two at the specified point.

Note
This always appends to the existing undo state.
Parameters
aSegmentLine segment to break
aPointPoint at which to break the segment
aNewSegmentPointer to the newly created segment (if given and created)
aScreenis the screen to examine, or nullptr to examine the current screen.
Returns
True if any wires or buses were broken.

Definition at line 293 of file bus-wire-junction.cpp.

295{
296 if( aScreen == nullptr )
297 aScreen = GetScreen();
298
299 SCH_LINE* newSegment = static_cast<SCH_LINE*>( aSegment->Duplicate() );
300
301 newSegment->SetStartPoint( aPoint );
302 newSegment->SetConnectivityDirty( true );
303 AddToScreen( newSegment, aScreen );
304
305 SaveCopyInUndoList( aScreen, newSegment, UNDO_REDO::NEWITEM, true );
306 SaveCopyInUndoList( aScreen, aSegment, UNDO_REDO::CHANGED, true );
307
308 UpdateItem( aSegment, false, true );
309 aSegment->SetEndPoint( aPoint );
310
311 if( aNewSegment )
312 *aNewSegment = newSegment;
313
314 return true;
315}
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:406
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:93
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
void SetStartPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:133
void SetEndPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:138

References SCH_BASE_FRAME::AddToScreen(), CHANGED, SCH_ITEM::Duplicate(), GetScreen(), NEWITEM, SaveCopyInUndoList(), SCH_ITEM::SetConnectivityDirty(), SCH_LINE::SetEndPoint(), SCH_LINE::SetStartPoint(), and UpdateItem().

Referenced by BreakSegments(), SCH_EDIT_TOOL::BreakWire(), and TrimWire().

◆ BreakSegments()

bool SCH_EDIT_FRAME::BreakSegments ( const VECTOR2I aPoint,
SCH_SCREEN aScreen = nullptr 
)

Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an intersection is found.

Note
This always appends to the existing undo state.
Parameters
aPointTest this point for an intersection.
aScreenis the screen to examine, or nullptr to examine the current screen.
Returns
True if any wires or buses were broken.

Definition at line 318 of file bus-wire-junction.cpp.

319{
320 if( aScreen == nullptr )
321 aScreen = GetScreen();
322
323 bool brokenSegments = false;
324 std::vector<SCH_LINE*> wires;
325
326 for( SCH_ITEM* item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
327 {
328 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
329 {
330 SCH_LINE* wire = static_cast<SCH_LINE*>( item );
331
332 if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), aPoint )
333 && !wire->IsEndPoint( aPoint ) )
334 {
335 wires.push_back( wire );
336 }
337 }
338 }
339
340 for( SCH_LINE* wire : wires )
341 brokenSegments |= BreakSegment( wire, aPoint, nullptr, aScreen );
342
343 return brokenSegments;
344}
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
bool BreakSegment(SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
Break a single segment into two at the specified point.
VECTOR2I GetEndPoint() const
Definition: sch_line.h:137
VECTOR2I GetStartPoint() const
Definition: sch_line.h:132
bool IsEndPoint(const VECTOR2I &aPoint) const
Definition: sch_line.h:92
bool IsPointOnSegment(const VECTOR2I &aSegStart, const VECTOR2I &aSegEnd, const VECTOR2I &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
@ SCH_LINE_T
Definition: typeinfo.h:145

References BreakSegment(), SCH_LINE::GetEndPoint(), GetScreen(), SCH_LINE::GetStartPoint(), SCH_LINE::IsEndPoint(), IsPointOnSegment(), SCH_SCREEN::Items(), EE_RTREE::Overlapping(), and SCH_LINE_T.

Referenced by AddJunction(), and BreakSegmentsOnJunctions().

◆ BreakSegmentsOnJunctions()

bool SCH_EDIT_FRAME::BreakSegmentsOnJunctions ( SCH_SCREEN aScreen = nullptr)

Test all junctions and bus entries in the schematic for intersections with wires and buses and breaks any intersections into multiple segments.

Note
This always appends to the existing undo state.
Parameters
aScreenis the screen to examine, or nullptr to examine the current screen
Returns
True if any wires or buses were broken.

Definition at line 347 of file bus-wire-junction.cpp.

348{
349 if( aScreen == nullptr )
350 aScreen = GetScreen();
351
352 bool brokenSegments = false;
353
354 std::set<VECTOR2I> point_set;
355
356 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_JUNCTION_T ) )
357 point_set.insert( item->GetPosition() );
358
359 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_BUS_WIRE_ENTRY_T ) )
360 {
361 SCH_BUS_WIRE_ENTRY* entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
362 point_set.insert( entry->GetPosition() );
363 point_set.insert( entry->GetEnd() );
364 }
365
366
367 for( const VECTOR2I& pt : point_set )
368 brokenSegments |= BreakSegments( pt, aScreen );
369
370 return brokenSegments;
371}
VECTOR2I GetPosition() const override
VECTOR2I GetEnd() const
Class for a wire to bus entry.
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:143
@ SCH_JUNCTION_T
Definition: typeinfo.h:141

References BreakSegments(), SCH_BUS_ENTRY_BASE::GetEnd(), SCH_BUS_ENTRY_BASE::GetPosition(), GetScreen(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SCH_BUS_WIRE_ENTRY_T, and SCH_JUNCTION_T.

Referenced by SchematicCleanUp().

◆ canCloseWindow()

bool SCH_EDIT_FRAME::canCloseWindow ( wxCloseEvent &  aCloseEvent)
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 742 of file sch_edit_frame.cpp.

743{
744 // Exit interactive editing
745 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
746 // will cancel any drag currently in progress, but commit all changes from previous drags.
747 if( m_toolManager )
749
750 // Shutdown blocks must be determined and vetoed as early as possible
751 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
752 && Schematic().GetSheets().IsModified() )
753 {
754 return false;
755 }
756
757 if( Kiface().IsSingle() )
758 {
759 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
760
761 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
762 return false;
763
764 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
765
766 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
767 return false;
768
769 symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
770
771 if( symbolViewer && !symbolViewer->Close() ) // Can close modal symbol viewer?
772 return false;
773 }
774 else
775 {
776 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
777
778 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
779 {
780 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
781 return false;
782 }
783 }
784
785 SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
786
787 if( simFrame && !simFrame->Close() ) // Can close the simulator?
788 return false;
789
790 // We may have gotten multiple events; don't clean up twice
791 if( !Schematic().IsValid() )
792 return false;
793
794 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
795
796 if( sheetlist.IsModified() )
797 {
798 wxFileName fileName = Schematic().RootScreen()->GetFileName();
799 wxString msg = _( "Save changes to '%s' before closing?" );
800
801 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
802 [&]() -> bool
803 {
804 return SaveProject();
805 } ) )
806 {
807 return false;
808 }
809 }
810
811 // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
812 // board.
813 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
814
815 if( open_dlg )
816 open_dlg->Close( true );
817
818 return true;
819}
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:106
const wxString & GetFileName() const
Definition: sch_screen.h:143
bool IsModified() const
Check the entire hierarchy for any modifications.
The symbol library editor main window.
Symbol library viewer main window.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH_VIEWER_MODAL
Definition: frame_type.h:37
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
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 _, ACTIONS::cancelInteractive, DIALOG_ERC_WINDOW_NAME, Format(), FRAME_SCH_SYMBOL_EDITOR, FRAME_SCH_VIEWER, FRAME_SCH_VIEWER_MODAL, FRAME_SIMULATOR, SCH_SCREEN::GetFileName(), SCHEMATIC::GetSheets(), HandleUnsavedChanges(), SCH_SHEET_LIST::IsModified(), SCHEMATIC::IsValid(), Kiface(), KIWAY_HOLDER::Kiway(), TOOLS_HOLDER::m_toolManager, KIWAY::Player(), SCHEMATIC::RootScreen(), TOOL_MANAGER::RunAction(), Schematic(), and KIPLATFORM::APP::SupportsShutdownBlockReason().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1303 of file eda_base_frame.cpp.

1304{
1305 SetUserUnits( aUnits );
1307
1308 wxCommandEvent e( UNITS_CHANGED );
1309 ProcessEventLocally( e );
1310}
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 UNITS_PROVIDER::SetUserUnits(), and EDA_BASE_FRAME::unitsChangeRefresh().

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

◆ CheckAnnotate()

int SCH_EDIT_FRAME::CheckAnnotate ( ANNOTATION_ERROR_HANDLER  aErrorHandler,
ANNOTATE_SCOPE_T  aAnnotateScope = ANNOTATE_ALL,
bool  aRecursive = true 
)

Check for annotation errors.

The following list of items are checked:

  • Symbols that are not annotated.
  • Duplicate symbol references.
  • Multiple part per package symbols where the part number is greater number of parts in the package.
  • Multiple part per package symbols where the reference designator is different between parts.
Returns
Number of annotation errors found.
Parameters
aReporterA handler for error reporting.
aAnnotateScopeSee ANNOTATE_SCOPE_T Check the current sheet only if true. Otherwise check the entire schematic.

Definition at line 441 of file annotate.cpp.

444{
445 SCH_REFERENCE_LIST referenceList;
446 constexpr bool includePowerSymbols = false;
448 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
449
450 // Build the list of symbols
451 switch( aAnnotateScope )
452 {
453 case ANNOTATE_ALL:
454 Schematic().GetSheets().GetSymbols( referenceList );
455 break;
456
458 GetCurrentSheet().GetSymbols( referenceList, includePowerSymbols );
459
460 if( aRecursive )
461 {
462 SCH_SHEET_LIST subSheets;
463
464 std::vector<SCH_ITEM*> tempSubSheets;
465 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
466
467 for( SCH_ITEM* item : tempSubSheets )
468 {
469 SCH_SHEET_PATH subSheetPath = currentSheet;
470 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
471
472 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
473 }
474
475 for( SCH_SHEET_PATH sheet : subSheets )
476 sheet.GetSymbols( referenceList, includePowerSymbols );
477 }
478
479 break;
480
483 EE_SELECTION& selection = selTool->RequestSelection();
484
485 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
486 GetCurrentSheet().AppendSymbol( referenceList, symbol, false, true );
487
488 if( aRecursive )
489 {
490 SCH_SHEET_LIST selectedSheets;
491
492 for( EDA_ITEM* item : selection.Items() )
493 {
494 if( item->Type() == SCH_SHEET_T )
495 {
496 SCH_SHEET_PATH subSheetPath = currentSheet;
497 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
498
499 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
500 }
501 }
502
503 for( SCH_SHEET_PATH sheet : selectedSheets )
504 sheet.GetSymbols( referenceList, includePowerSymbols );
505 }
506
507 break;
508 }
509
510 // Empty schematic does not need annotation
511 if( referenceList.GetCount() == 0 )
512 return 0;
513
514 return referenceList.CheckAnnotation( aErrorHandler );
515}
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.

References ANNOTATE_ALL, ANNOTATE_CURRENT_SHEET, ANNOTATE_SELECTION, SCH_SHEET_PATH::AppendSymbol(), SCH_REFERENCE_LIST::CheckAnnotation(), SCH_REFERENCE_LIST::GetCount(), GetCurrentSheet(), getInferredSymbols(), SCHEMATIC::GetSheets(), SCH_SCREEN::GetSheets(), SCH_SHEET_LIST::GetSheetsWithinPath(), SCH_SHEET_PATH::GetSymbols(), SCH_SHEET_LIST::GetSymbols(), TOOL_MANAGER::GetTool(), SCH_SHEET_PATH::LastScreen(), TOOLS_HOLDER::m_toolManager, SCH_SHEET_PATH::push_back(), EE_SELECTION_TOOL::RequestSelection(), SCH_SHEET_T, and Schematic().

Referenced by AnnotateSymbols(), DIALOG_ERC::OnRunERCClick(), ReadyToNetlist(), and DIALOG_ERC::UpdateAnnotationWarning().

◆ CheckForAutoSaveFile()

void SCH_EDIT_FRAME::CheckForAutoSaveFile ( const wxFileName &  aFileName)
overridevirtual

This overloaded version checks if the auto save master file "#auto_saved_files#" exists and recovers all of the schematic files listed in it.

Parameters
aFileNameis the project auto save master file name.

Reimplemented from EDA_BASE_FRAME.

Definition at line 1375 of file eeschema/files-io.cpp.

1376{
1377 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1378
1379 wxLogTrace( traceAutoSave,
1380 wxT( "Checking for auto save file " ) + aFileName.GetFullPath() );
1381
1382 if( !aFileName.FileExists() )
1383 return;
1384
1385 wxString msg = _(
1386 "Well this is potentially embarrassing!\n"
1387 "It appears that the last time you were editing one or more of the schematic files\n"
1388 "were not saved properly. Do you wish to restore the last saved edits you made?" );
1389
1390 int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1391 this );
1392
1393 wxTextFile autoSaveFile( aFileName.GetFullPath() );
1394
1395 if( !autoSaveFile.Open() )
1396 {
1397 msg.Printf( _( "The file '%s` could not be opened.\n"
1398 "Manual recovery of automatically saved files is required." ),
1399 aFileName.GetFullPath() );
1400
1401 wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1402 return;
1403 }
1404
1405 if( response == wxYES )
1406 {
1407 wxArrayString unrecoveredFiles;
1408
1409 for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
1410 fn = autoSaveFile.GetNextLine() )
1411 {
1412 wxFileName recoveredFn = fn;
1413 wxString tmp = recoveredFn.GetName();
1414
1415 // Strip "_autosave-" prefix from the auto save file name.
1416 tmp.Replace( GetAutoSaveFilePrefix(), wxT( "" ), false );
1417 recoveredFn.SetName( tmp );
1418
1419 wxFileName backupFn = recoveredFn;
1420
1421 backupFn.SetExt( backupFn.GetExt() + BackupFileSuffix );
1422
1423 wxLogTrace( traceAutoSave, wxT( "Recovering auto save file:\n"
1424 " Original file: '%s'\n"
1425 " Backup file: '%s'\n"
1426 " Auto save file: '%s'" ),
1427 recoveredFn.GetFullPath(), backupFn.GetFullPath(), fn );
1428
1429 // Attempt to back up the last schematic file before overwriting it with the auto
1430 // save file.
1431 if( !wxCopyFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) )
1432 {
1433 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1434 }
1435 else if( !wxRenameFile( fn, recoveredFn.GetFullPath() ) )
1436 {
1437 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1438 }
1439 }
1440
1441 if( !unrecoveredFiles.IsEmpty() )
1442 {
1443 msg = _( "The following automatically saved file(s) could not be restored\n" );
1444
1445 for( size_t i = 0; i < unrecoveredFiles.GetCount(); i++ )
1446 msg += unrecoveredFiles[i] + wxT( "\n" );
1447
1448 msg += _( "Manual recovery will be required to restore the file(s) above." );
1449 wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
1450 this );
1451 }
1452 }
1453 else
1454 {
1455 wxArrayString unremovedFiles;
1456
1457 for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
1458 fn = autoSaveFile.GetNextLine() )
1459 {
1460 wxLogTrace( traceAutoSave, wxT( "Removing auto save file " ) + fn );
1461
1462 if( !wxRemoveFile( fn ) )
1463 {
1464 unremovedFiles.Add( fn );
1465 }
1466 }
1467
1468 if( !unremovedFiles.IsEmpty() )
1469 {
1470 msg = _( "The following automatically saved file(s) could not be removed\n" );
1471
1472 for( size_t i = 0; i < unremovedFiles.GetCount(); i++ )
1473 msg += unremovedFiles[i] + wxT( "\n" );
1474
1475 msg += _( "Manual removal will be required for the file(s) above." );
1476 wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
1477 this );
1478 }
1479 }
1480
1481 // Remove the auto save master file.
1482 wxLogTrace( traceAutoSave, wxT( "Removing auto save file '%s'" ), aFileName.GetFullPath() );
1483
1484 if( !wxRemoveFile( aFileName.GetFullPath() ) )
1485 {
1486 msg.Printf( _( "The automatic save master file\n"
1487 "'%s'\n"
1488 "could not be deleted." ), aFileName.GetFullPath() );
1489
1490 wxMessageDialog dlg( this, msg, Pgm().App().GetAppDisplayName(),
1491 wxOK | wxICON_EXCLAMATION | wxCENTER );
1492
1493 dlg.SetExtendedMessage(
1494 _( "This file must be manually removed or the auto save feature will be\n"
1495 "shown every time the schematic editor is launched." ) );
1496
1497 dlg.ShowModal();
1498 }
1499}
static wxString GetAutoSaveFilePrefix()
const std::string BackupFileSuffix
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:111

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

Referenced by OpenProjectFiles().

◆ checkForNoFullyDefinedLibIds()

bool SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds ( SCH_SHEET aSheet)
private

Verify that the symbol library links aSheet and all of its child sheets have been remapped to the symbol library table.

Parameters
aSheetis the SCH_SHEET object to test.
Returns
true if aSheet and its child sheets have not been remapped.

Definition at line 75 of file sheet.cpp.

76{
77 wxASSERT( aSheet && aSheet->GetScreen() );
78
79 wxString msg;
80 SCH_SCREENS newScreens( aSheet );
81
82 if( newScreens.HasNoFullyDefinedLibIds() )
83 {
84 msg.Printf( _( "The schematic '%s' has not had its symbol library links remapped "
85 "to the symbol library table. The project this schematic belongs to "
86 "must first be remapped before it can be imported into the current "
87 "project." ),
88 aSheet->GetScreen()->GetFileName() );
89 DisplayInfoMessage( this, msg );
90 return true;
91 }
92
93 return false;
94}
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:320

References _, DisplayInfoMessage(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetScreen(), and SCH_SCREENS::HasNoFullyDefinedLibIds().

Referenced by LoadSheetFromFile().

◆ CheckSheetForRecursion()

bool SCH_EDIT_FRAME::CheckSheetForRecursion ( SCH_SHEET aSheet,
SCH_SHEET_PATH aHierarchy 
)

Verify that aSheet will not cause a recursion error in aHierarchy.

Parameters
aSheetis the SCH_SHEET object to test.
aHierarchyis the SCH_SHEET_PATH where aSheet is going to reside.
Returns
true if aSheet will cause a recursion error in aHierarchy.

Definition at line 47 of file sheet.cpp.

48{
49 wxASSERT( aSheet && aHierarchy );
50
51 wxString msg;
52 SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // The full schematic sheet hierarchy.
53 SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
54
55 wxFileName destFile = aHierarchy->LastScreen()->GetFileName();
56
57 // SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
58 // something is seriously broken.
59 wxASSERT( destFile.IsAbsolute() );
60
61 if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
62 {
63 msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
64 "has the sheet '%s' or one of its subsheets as a parent somewhere in the "
65 "schematic hierarchy." ),
66 destFile.GetFullPath() );
67 DisplayError( this, msg );
68 return true;
69 }
70
71 return false;
72}
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280

References _, DisplayError(), SCH_SCREEN::GetFileName(), SCHEMATIC::GetSheets(), SCH_SHEET_PATH::LastScreen(), Schematic(), and SCH_SHEET_LIST::TestForRecursion().

Referenced by LoadSheetFromFile(), and DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged().

◆ ClearExecFlags()

void SCH_EDIT_FRAME::ClearExecFlags ( const int  aFlags)
inline

Clear (removes) specified flags that not needed for next execution of external generator of the netlist or bom.

Parameters
aFlagsis the wxEXEC_* flags, see wxExecute documentation.

Definition at line 763 of file sch_edit_frame.h.

763{ m_exec_flags &= ~( aFlags ); }
int m_exec_flags
Flags of the wxExecute() function to call a custom net list generator.

References m_exec_flags.

◆ 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 948 of file eda_base_frame.cpp.

949{
950 if( !aFileHistory )
951 aFileHistory = m_fileHistory;
952
953 wxASSERT( aFileHistory );
954
955 aFileHistory->ClearFileHistory();
956
957 // Update the menubar to update the file history menu
958 if( GetMenuBar() )
959 {
961 GetMenuBar()->Refresh();
962 }
963}
FILE_HISTORY * m_fileHistory
virtual void ReCreateMenuBar()
Recreates the menu bar.
void ClearFileHistory()
Clear all entries from the file history.

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

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

◆ ClearFindReplaceStatus()

void SCH_EDIT_FRAME::ClearFindReplaceStatus ( )

Definition at line 1089 of file sch_edit_frame.cpp.

1090{
1091 m_infoBar->Dismiss();
1092}
WX_INFOBAR * m_infoBar
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175

References WX_INFOBAR::Dismiss(), and EDA_BASE_FRAME::m_infoBar.

Referenced by SCH_EDITOR_CONTROL::FindNext().

◆ ClearMsgPanel()

◆ ClearUndoORRedoList()

void SCH_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
whichListis the UNDO_REDO_CONTAINER to clear
aItemCountis the count of items to remove. Use < 0 to remove all items from the beginning of the list.

Reimplemented from EDA_BASE_FRAME.

Definition at line 411 of file schematic_undo_redo.cpp.

412{
413 if( aItemCount == 0 )
414 return;
415
416 UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
417
418 for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
419 {
420 command->ClearListAndDeleteItems();
421 delete command;
422 }
423
424 list.m_CommandsList.clear();
425}
UNDO_REDO_CONTAINER m_undoList
UNDO_REDO_CONTAINER m_redoList
A holder to handle information on schematic or board items.
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList

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 DIALOG_SYMBOL_REMAP::OnRemapSymbols(), and SaveCopyInUndoList().

◆ ClearUndoRedoList()

◆ commonInit()

void EDA_BASE_FRAME::commonInit ( FRAME_T  aFrameType)
privateinherited

Collect common initialization functions used in all CTORs.

Definition at line 117 of file eda_base_frame.cpp.

118{
119 m_ident = aFrameType;
120 m_maximizeByDefault = false;
121 m_infoBar = nullptr;
122 m_settingsManager = nullptr;
123 m_fileHistory = nullptr;
124 m_supportsAutoSave = false;
125 m_autoSaveState = false;
127 m_isClosing = false;
128 m_isNonUserClose = false;
129 m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
131 m_frameSize = defaultSize( aFrameType );
132 m_displayIndex = -1;
133
134 m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
135
136 m_settingsManager = &Pgm().GetSettingsManager();
137
138 // Set a reasonable minimal size for the frame
139 SetSizeHints( minSize( aFrameType ).x, minSize( aFrameType ).y, -1, -1, -1, -1 );
140
141 // Store dimensions of the user area of the main window.
142 GetClientSize( &m_frameSize.x, &m_frameSize.y );
143
144 Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
145 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
146
147 // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
148 // to be called before any other hook for wxCloseEvent, which is necessary.
149 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
150
151 initExitKey();
152}
void windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
void initExitKey()
Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
void onAutoSaveTimer(wxTimerEvent &aEvent)
Handle the auto save timer event.
wxTimer * m_autoSaveTimer
SETTINGS_MANAGER * m_settingsManager
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
wxString m_mruPath
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:139
static const wxSize minSize(FRAME_T aFrameType)
static const wxSize defaultSize(FRAME_T aFrameType)
#define DEFAULT_MAX_UNDO_ITEMS
@ ID_AUTO_SAVE_TIMER
Definition: id.h:79

References DEFAULT_MAX_UNDO_ITEMS, defaultSize(), PATHS::GetDefaultUserProjectsPath(), ID_AUTO_SAVE_TIMER, minSize(), EDA_BASE_FRAME::onAutoSaveTimer(), Pgm(), and EDA_BASE_FRAME::windowClosing().

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

◆ CommonSettingsChanged()

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

Called after the preferences dialog is run.

Reimplemented from SCH_BASE_FRAME.

Definition at line 1607 of file sch_edit_frame.cpp.

1608{
1609 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1610
1611 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1613
1615
1616 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1618
1619 KIGFX::VIEW* view = GetCanvas()->GetView();
1623
1625
1626 for( SCH_ITEM* item : screen->Items() )
1627 item->ClearCaches();
1628
1629 for( std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
1630 libSymbol.second->ClearCaches();
1631
1633
1635 Layout();
1636 SendSizeEvent();
1637}
WINDOW_SETTINGS m_Window
Definition: app_settings.h:184
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void ForceRefresh()
Force a redraw.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:393
These settings were stored in SCH_BASE_FRAME previously.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowAllIntersheetRefs(bool aShow)
int GetSchematicJunctionSize()
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:453
@ LAYER_ERC_WARN
Definition: layer_ids.h:369
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:371
@ LAYER_ERC_ERR
Definition: layer_ids.h:370

References SCH_BASE_FRAME::CommonSettingsChanged(), EDA_DRAW_PANEL_GAL::ForceRefresh(), SCH_BASE_FRAME::GetCanvas(), GetCurrentSheet(), EDA_DRAW_FRAME::GetGalDisplayOptions(), SCH_SCREEN::GetLibSymbols(), GetSchematicJunctionSize(), SCH_DRAW_PANEL::GetView(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), LAYER_ERC_ERR, LAYER_ERC_EXCLUSION, LAYER_ERC_WARN, EESCHEMA_SETTINGS::m_Appearance, SCHEMATIC_SETTINGS::m_IntersheetRefsShow, SCHEMATIC_SETTINGS::m_JunctionSize, APP_SETTINGS_BASE::m_Window, Pgm(), KIGFX::GAL_DISPLAY_OPTIONS::ReadWindowSettings(), EDA_DRAW_FRAME::RecreateToolbars(), Schematic(), KIGFX::VIEW::SetLayerVisible(), SCHEMATIC::Settings(), EESCHEMA_SETTINGS::APPEARANCE::show_erc_errors, EESCHEMA_SETTINGS::APPEARANCE::show_erc_exclusions, EESCHEMA_SETTINGS::APPEARANCE::show_erc_warnings, and ShowAllIntersheetRefs().

◆ config()

APP_SETTINGS_BASE * EDA_BASE_FRAME::config ( ) const
virtualinherited

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

Reimplemented in SYMBOL_EDIT_FRAME, KICAD_MANAGER_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 788 of file eda_base_frame.cpp.

789{
790 // KICAD_MANAGER_FRAME overrides this
791 return Kiface().KifaceSettings();
792}
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93

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

Referenced by GERBVIEW_FRAME::ActivateGalCanvas(), PCB_BASE_FRAME::ActivateGalCanvas(), BM2CMP_FRAME::BM2CMP_FRAME(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS(), SIM_PLOT_FRAME::doCloseWindow(), FOOTPRINT_WIZARD_FRAME::doCloseWindow(), SCH_BASE_FRAME::eeconfig(), GERBVIEW_FRAME::GERBVIEW_FRAME(), PCB_EDIT_FRAME::GetRotationAngle(), GRID_MENU::GRID_MENU(), COMMON_TOOLS::GridFast1(), COMMON_TOOLS::GridFast2(), GERBVIEW_FRAME::gvconfig(), EDA_DRAW_FRAME::IsGridVisible(), SCH_BASE_FRAME::libeditconfig(), EDA_DRAW_FRAME::OnUpdateSelectGrid(), EDA_DRAW_FRAME::OnUpdateSelectZoom(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), GERBVIEW_FRAME::Read_EXCELLON_File(), DIALOG_GRID_SETTINGS::RebuildGridSizes(), EDA_DRAW_FRAME::resolveCanvasType(), PCB_BASE_EDIT_FRAME::SetBoard(), EDA_DRAW_FRAME::SetGridVisibility(), CVPCB_MAINFRAME::setupTools(), setupTools(), SYMBOL_VIEWER_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), PL_EDITOR_FRAME::setupTools(), PCB_EDIT_FRAME::setupTools(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), GRID_MENU::update(), ZOOM_MENU::update(), EDA_DRAW_FRAME::UpdateGridSelectBox(), EDA_DRAW_FRAME::UpdateZoomSelectBox(), EDA_BASE_FRAME::windowClosing(), and BM2CMP_FRAME::~BM2CMP_FRAME().

◆ 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 341 of file eda_base_frame.h.

342 {
343 wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
344 return baseCfgName;
345 }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

◆ ConvertPart()

void SCH_EDIT_FRAME::ConvertPart ( SCH_SYMBOL aSymbol)

Definition at line 275 of file picksymbol.cpp.

276{
277 if( !aSymbol || !aSymbol->GetLibSymbolRef() )
278 return;
279
280 wxString msg;
281
282 if( !aSymbol->GetLibSymbolRef()->HasConversion() )
283 {
284 LIB_ID id = aSymbol->GetLibSymbolRef()->GetLibId();
285
286 msg.Printf( _( "No alternate body style found for symbol '%s' in library '%s'." ),
287 id.GetLibItemName().wx_str(),
288 id.GetLibNickname().wx_str() );
289 DisplayError( this, msg );
290 return;
291 }
292
293 EDA_ITEM_FLAGS savedFlags = aSymbol->GetFlags();
294
295 aSymbol->SetConvert( aSymbol->GetConvert() + 1 );
296
297 // ensure m_convert = 1 or 2
298 // 1 = shape 1 = not converted
299 // 2 = shape 2 = first converted shape
300 // > 2 is not currently supported
301 // When m_convert = val max, return to the first shape
302 if( aSymbol->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN )
303 aSymbol->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
304
306 aSymbol->ClearFlags();
307 aSymbol->SetFlags( savedFlags ); // Restore m_flags (modified by SetConvert())
308
309 // If selected make sure all the now-included pins are selected
310 if( aSymbol->IsSelected() )
312
313 UpdateItem( aSymbol, false, true );
314 OnModify();
315}
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
bool IsSelected() const
Definition: eda_item.h:107
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:144
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
void SetConvert(int aConvert)
Definition: sch_symbol.cpp:406
int GetConvert() const
Definition: sch_symbol.h:267
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:189
std::uint32_t EDA_ITEM_FLAGS

References _, EE_ACTIONS::addItemToSel, EDA_ITEM::ClearFlags(), DisplayError(), SCH_SYMBOL::GetConvert(), EDA_ITEM::GetFlags(), SCH_SYMBOL::GetLibSymbolRef(), EDA_ITEM::IsSelected(), TOOLS_HOLDER::m_toolManager, OnModify(), TOOL_MANAGER::RunAction(), SCH_SYMBOL::SetConvert(), EDA_ITEM::SetFlags(), TestDanglingEnds(), and UpdateItem().

Referenced by SCH_EDIT_TOOL::ConvertDeMorgan().

◆ CreateArchiveLibrary()

bool SCH_EDIT_FRAME::CreateArchiveLibrary ( const wxString &  aFileName)

Create a library aFileName that contains all symbols used in the current schematic.

Parameters
aFileNameThe full path and file name of the archive library.
Returns
True if aFileName was written successfully.

Definition at line 65 of file libarch.cpp.

66{
67 wxString tmp;
68 wxString errorMsg;
69 SCH_SCREENS screens( Schematic().Root() );
70
71 // Create a new empty library to archive symbols:
72 std::unique_ptr<SYMBOL_LIB> archLib = std::make_unique<SYMBOL_LIB>( SCH_LIB_TYPE::LT_EESCHEMA,
73 aFileName );
74
75 // Save symbols to file only when the library will be fully filled
76 archLib->EnableBuffering();
77
78 /* Examine all screens (not hierarchical sheets) used in the schematic and build a
79 * library of unique symbols found in all screens. Complex hierarchies are not a
80 * problem because we just want to know the library symbols used in the schematic
81 * not their reference.
82 */
83 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
84 {
85
86 for( SCH_ITEM* aItem : screen->Items().OfType( SCH_SYMBOL_T ) )
87 {
88 LIB_SYMBOL* libSymbol = nullptr;
89 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
90
91 try
92 {
93 if( archLib->FindSymbol( symbol->GetLibId() ) )
94 continue;
95
96 libSymbol = GetLibSymbol( symbol->GetLibId(), true );
97 }
98 catch( const IO_ERROR& )
99 {
100 // Queue up error messages for later.
101 tmp.Printf( _( "Failed to add symbol %s to library file '%s'." ),
103 aFileName );
104
105 // Don't bail out here. Attempt to add as many of the symbols to the library
106 // as possible.
107 }
108 catch( ... )
109 {
110 tmp = _( "Unexpected exception occurred." );
111 }
112
113 if( libSymbol )
114 {
115 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
116
117 // Use the full LIB_ID as the symbol name to prevent symbol name collisions.
118 flattenedSymbol->SetName( symbol->GetLibId().GetUniStringLibId() );
119
120 // AddSymbol() does first clone the symbol before adding.
121 archLib->AddSymbol( flattenedSymbol.get() );
122 }
123 else
124 {
125 tmp.Printf( _( "Symbol %s not found in any library or cache." ),
126 symbol->GetLibId().GetUniStringLibId() );
127 }
128
129 if( !tmp.empty() && !errorMsg.Contains( symbol->GetLibId().GetUniStringLibId() ) )
130 {
131 if( errorMsg.empty() )
132 errorMsg += tmp;
133 else
134 errorMsg += "\n" + tmp;
135 }
136 }
137 }
138
139 if( !errorMsg.empty() )
140 {
141 tmp.Printf( _( "Errors occurred creating symbol library %s." ), aFileName );
142 DisplayErrorMessage( this, tmp, errorMsg );
143 }
144
145 archLib->EnableBuffering( false );
146
147 try
148 {
149 archLib->Save( false );
150 }
151 catch( const IO_ERROR& ioe )
152 {
153 errorMsg.Printf( _( "Failed to save symbol library file '%s'." ), aFileName );
154 DisplayErrorMessage( this, errorMsg, ioe.What() );
155 return false;
156 }
157 catch( std::exception& error )
158 {
159 errorMsg.Printf( _( "Failed to save symbol library file '%s'." ), aFileName );
160 DisplayErrorMessage( this, errorMsg, error.what() );
161 return false;
162 }
163
164 return true;
165}
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
wxString GetUniStringLibId() const
Definition: lib_id.h:141
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition: lib_id.h:111
Define a library symbol object.
Definition: lib_symbol.h:98
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:460
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:172
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299

References _, DisplayErrorMessage(), LIB_SYMBOL::Flatten(), SCH_SCREENS::GetFirst(), SCH_SYMBOL::GetLibId(), SCH_BASE_FRAME::GetLibSymbol(), SCH_SCREENS::GetNext(), LIB_ID::GetUniStringLibId(), LIB_ID::GetUniStringLibItemName(), LT_EESCHEMA, SCH_SYMBOL_T, Schematic(), and IO_ERROR::What().

Referenced by CreateArchiveLibraryCacheFile().

◆ CreateArchiveLibraryCacheFile()

bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile ( bool  aUseCurrentSheetFilename = false)

Create a symbol library file with the name of the root document plus the '-cache' suffix,.

This file will contain all symbols used in the current schematic.

Parameters
aUseCurrentSheetFilenameset to false to use the root sheet filename (default) or true to use the currently opened sheet.
Returns
true if the file was written successfully.

Definition at line 42 of file libarch.cpp.

43{
44 wxFileName fn;
45
46 if( aUseCurrentSheetFilename )
47 fn = GetScreen()->GetFileName();
48 else
50
51 fn.SetName( fn.GetName() + "-cache" );
53
54 bool success = CreateArchiveLibrary( fn.GetFullPath() );
55
56 // Update the schematic symbol library links.
57 // because the lib cache has changed
58 SCH_SCREENS schematic( Schematic().Root() );
59 schematic.UpdateSymbolLinks();
60
61 return success;
62}
bool CreateArchiveLibrary(const wxString &aFileName)
Create a library aFileName that contains all symbols used in the current schematic.
Definition: libarch.cpp:65
const std::string LegacySymbolLibFileExtension

References CreateArchiveLibrary(), SCH_SCREEN::GetFileName(), GetScreen(), LegacySymbolLibFileExtension, SCHEMATIC::RootScreen(), Schematic(), and SCH_SCREENS::UpdateSymbolLinks().

◆ createCanvas()

void SCH_BASE_FRAME::createCanvas ( )
inherited

Definition at line 338 of file sch_base_frame.cpp.

339{
341
342 SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_frameSize,
345}
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.

References SCH_BASE_FRAME::ActivateGalCanvas(), 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 813 of file eda_base_frame.cpp.

814{
815#if defined( __WXOSX_MAC__ )
817#else
818 m_infoBar = new WX_INFOBAR( this, &m_auimgr );
819
820 m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
821#endif
822}
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:75

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

◆ CreateScreens()

void SCH_EDIT_FRAME::CreateScreens ( )

Definition at line 677 of file sch_edit_frame.cpp.

678{
681
683
684 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
685 m_schematic->Root().SetScreen( rootScreen );
686 SetScreen( Schematic().RootScreen() );
687
688 m_schematic->RootScreen()->SetFileName( wxEmptyString );
689
690 // Don't leave root page number empty
691 SCH_SHEET_PATH rootSheetPath;
692 rootSheetPath.push_back( &m_schematic->Root() );
693 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
694 m_schematic->Root().AddInstance( rootSheetPath );
695 m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) );
696
697 if( GetScreen() == nullptr )
698 {
699 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
700 SetScreen( screen );
701 }
702}
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:104
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:76
SCH_SHEET & Root() const
Definition: schematic.h:90
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:104
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1249
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1204
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:161

References SCH_SHEET::AddInstance(), GetScreen(), m_schematic, KIWAY_HOLDER::Prj(), SCH_SHEET_PATH::push_back(), SCHEMATIC::Reset(), SCHEMATIC::Root(), SCHEMATIC::RootScreen(), Schematic(), SCH_SCREEN::SetFileName(), SCH_SHEET::SetPageNumber(), BASE_SCREEN::SetPageNumber(), SCHEMATIC::SetProject(), SCHEMATIC::SetRoot(), SetScreen(), and SCH_SHEET::SetScreen().

Referenced by importFile(), and OpenProjectFiles().

◆ 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 if( m_socketServer )
55 {
56 // this helps prevent any events that could come in during deletion
57 m_socketServer->Notify( false );
58 delete m_socketServer;
59 }
60
61 m_socketServer = new wxSocketServer( addr );
62
63 m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
64 m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
65 m_socketServer->Notify( true );
66}
wxSocketServer * m_socketServer
Definition: kiway_player.h:218
static const wxString HOSTNAME(wxT("localhost"))
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:163

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 110 of file tools_holder.cpp.

111{
112 if( m_toolStack.empty() )
114 else
115 return m_toolStack.back();
116}
static TOOL_ACTION selectionTool
Definition: actions.h:156
std::vector< std::string > m_toolStack
Definition: tools_holder.h:176
const std::string & GetName() const
Return name of the action.
Definition: tool_action.h:101

References TOOL_ACTION::GetName(), TOOLS_HOLDER::m_toolStack, and ACTIONS::selectionTool.

Referenced by TOOLS_HOLDER::ShowChangedLanguage().

◆ DefaultExecFlags()

void SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

Reset the execution flags to defaults for external netlist and bom generators.

Definition at line 748 of file sch_edit_frame.h.

748{ m_exec_flags = wxEXEC_SYNC; }

References m_exec_flags.

Referenced by WriteNetListFile().

◆ DeleteAnnotation()

void SCH_EDIT_FRAME::DeleteAnnotation ( ANNOTATE_SCOPE_T  aAnnotateScope,
bool  aRecursive,
bool *  appendUndo 
)

Clear the current symbol annotation.

Parameters
aCurrentSheetOnlyWhere to clear the annotation. See ANNOTATE_SCOPE_T
appendUndotrue to add the action to the previous undo list

Definition at line 60 of file annotate.cpp.

62{
63 auto clearSymbolAnnotation =
64 [&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
65 {
66 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
67
68 SaveCopyInUndoList( aScreen, symbol, UNDO_REDO::CHANGED, *aAppendUndo );
69 *aAppendUndo = true;
70 symbol->ClearAnnotation( aSheet, aResetPrefixes );
71 };
72
73 auto clearSheetAnnotation =
74 [&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
75 {
76 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
77 clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
78 };
79
81 SCH_SCREEN* screen = GetScreen();
82 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
83
84 switch( aAnnotateScope )
85 {
86 case ANNOTATE_ALL:
87 {
88 for( const SCH_SHEET_PATH& sheet : sheets )
89 clearSheetAnnotation( sheet.LastScreen(), nullptr, false );
90
91 break;
92 }
94 {
95 clearSheetAnnotation( screen, &currentSheet, false );
96
97 if( aRecursive )
98 {
99 SCH_SHEET_LIST subSheets;
100
101 std::vector<SCH_ITEM*> tempSubSheets;
102 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
103
104 for( SCH_ITEM* item : tempSubSheets )
105 {
106 SCH_SHEET_PATH subSheetPath = currentSheet;
107 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
108
109 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
110 }
111
112 for( SCH_SHEET_PATH sheet : subSheets )
113 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
114 }
115
116 break;
117 }
118
120 {
122 EE_SELECTION& selection = selTool->RequestSelection();
123 SCH_SHEET_LIST selectedSheets;
124
125 for( EDA_ITEM* item : selection.Items() )
126 {
127 if( item->Type() == SCH_SYMBOL_T )
128 clearSymbolAnnotation( item, screen, &currentSheet, false );
129
130 if( item->Type() == SCH_SHEET_T && aRecursive )
131 {
132 SCH_SHEET_PATH subSheetPath = currentSheet;
133 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
134
135 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
136 }
137 }
138
139 for( SCH_SHEET_PATH sheet : selectedSheets )
140 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
141
142 break;
143 }
144 }
145
146 // Update the references for the sheet that is currently being displayed.
148
149 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
150
151 if( erc_dlg )
152 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
153
154 SyncView();
155 GetCanvas()->Refresh();
156 OnModify();
157
158 // Must go after OnModify() so the connectivity graph has been updated
160}
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.

References ANNOTATE_ALL, ANNOTATE_CURRENT_SHEET, ANNOTATE_SELECTION, CHANGED, SCH_SYMBOL::ClearAnnotation(), DIALOG_ERC_WINDOW_NAME, SCH_BASE_FRAME::GetCanvas(), GetCurrentSheet(), GetScreen(), SCHEMATIC::GetSheets(), SCH_SCREEN::GetSheets(), SCH_SHEET_LIST::GetSheetsWithinPath(), TOOL_MANAGER::GetTool(), SCH_SHEET_PATH::LastScreen(), TOOLS_HOLDER::m_toolManager, OnModify(), SCH_SHEET_PATH::push_back(), EDA_DRAW_PANEL_GAL::Refresh(), EE_SELECTION_TOOL::RequestSelection(), SaveCopyInUndoList(), SCH_SHEET_T, SCH_SYMBOL_T, Schematic(), SCH_BASE_FRAME::SyncView(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and UpdateNetHighlightStatus().

Referenced by DIALOG_ANNOTATE::OnClearAnnotationClick().

◆ DeleteJunction()

void SCH_EDIT_FRAME::DeleteJunction ( SCH_ITEM aItem,
bool  aAppend = false 
)

Removes a given junction and heals any wire segments under the junction.

Parameters
aItemThe junction to delete
aAppendTrue if we are updating an ongoing commit

Note that std::list or similar is required here as we may insert values in the loop below. This will invalidate iterators in a std::vector or std::deque

Definition at line 374 of file bus-wire-junction.cpp.

375{
376 SCH_SCREEN* screen = GetScreen();
377 PICKED_ITEMS_LIST undoList;
379
380 auto remove_item =
381 [&]( SCH_ITEM* aItem ) -> void
382 {
383 aItem->SetFlags( STRUCT_DELETED );
384 undoList.PushItem( ITEM_PICKER( screen, aItem, UNDO_REDO::DELETED ) );
385 };
386
387 remove_item( aJunction );
388 RemoveFromScreen( aJunction, screen );
389
392 std::list<SCH_LINE*> lines;
393
394 for( SCH_ITEM* item : screen->Items().Overlapping( SCH_LINE_T, aJunction->GetPosition() ) )
395 {
396 SCH_LINE* line = static_cast<SCH_LINE*>( item );
397
398 if( line->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
399 && line->IsEndPoint( aJunction->GetPosition() )
400 && !( line->GetEditFlags() & STRUCT_DELETED ) )
401 {
402 lines.push_back( line );
403 }
404 }
405
406 alg::for_all_pairs( lines.begin(), lines.end(),
407 [&]( SCH_LINE* firstLine, SCH_LINE* secondLine )
408 {
409 if( ( firstLine->GetEditFlags() & STRUCT_DELETED )
410 || ( secondLine->GetEditFlags() & STRUCT_DELETED )
411 || !secondLine->IsParallel( firstLine ) )
412 {
413 return;
414 }
415
416 // Remove identical lines
417 if( firstLine->IsEndPoint( secondLine->GetStartPoint() )
418 && firstLine->IsEndPoint( secondLine->GetEndPoint() ) )
419 {
420 remove_item( firstLine );
421 return;
422 }
423
424 // Try to merge the remaining lines
425 if( SCH_LINE* line = secondLine->MergeOverlap( screen, firstLine, false ) )
426 {
427 remove_item( firstLine );
428 remove_item( secondLine );
429 undoList.PushItem( ITEM_PICKER( screen, line, UNDO_REDO::NEWITEM ) );
430 AddToScreen( line, screen );
431
432 if( line->IsSelected() )
433 selectionTool->AddItemToSel( line, true /*quiet mode*/ );
434
435 lines.push_back( line );
436 }
437 } );
438
439 SaveCopyInUndoList( undoList, UNDO_REDO::DELETED, aAppend );
440
441 for( SCH_LINE* line : lines )
442 {
443 if( line->GetEditFlags() & STRUCT_DELETED )
444 {
445 if( line->IsSelected() )
446 selectionTool->RemoveItemFromSel( line, true /*quiet mode*/ );
447
448 RemoveFromScreen( line, screen );
449 }
450 }
451}
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:147
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
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,...
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:441
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_line.h:72
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
#define STRUCT_DELETED
flag indication structures to be erased
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
Definition: kicad_algo.h:83

References DELETED, alg::for_all_pairs(), EDA_ITEM::GetEditFlags(), SCH_LINE::GetEndPoint(), EDA_ITEM::GetPosition(), GetScreen(), SCH_LINE::GetStartPoint(), TOOL_MANAGER::GetTool(), SCH_LINE::IsEndPoint(), SCH_LINE::IsType(), SCH_SCREEN::Items(), TOOLS_HOLDER::m_toolManager, SCH_LINE::MergeOverlap(), EE_RTREE::Overlapping(), PICKED_ITEMS_LIST::PushItem(), SCH_BASE_FRAME::RemoveFromScreen(), SCH_LINE_T, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::DoDelete().

◆ Destroy()

◆ DismissModal()

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

Definition at line 182 of file kiway_player.cpp.

183{
184 m_modal_ret_val = aRetVal;
185 m_modal_string = aResult;
186
187 if( m_modal_loop )
188 {
189 m_modal_loop->Exit();
190 m_modal_loop = nullptr; // this marks it as dismissed.
191 }
192
193 Show( false );
194}
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
bool m_modal_ret_val
Definition: kiway_player.h:216

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().

◆ DisplayConstraintsMsg()

void EDA_DRAW_FRAME::DisplayConstraintsMsg ( const wxString &  msg)
inherited

Definition at line 572 of file eda_draw_frame.cpp.

573{
574 SetStatusText( msg, 7 );
575}

Referenced by EDIT_TOOL::doMoveSelection(), and DRAWING_TOOL::UpdateStatusBar().

◆ DisplayCurrentSheet()

void SCH_EDIT_FRAME::DisplayCurrentSheet ( )

Draw the current sheet on the display.

Definition at line 1886 of file sch_edit_frame.cpp.

1887{
1891
1892 wxASSERT( screen );
1893
1894 SetScreen( screen );
1895
1896 // update the References
1899
1900 if( !screen->m_zoomInitialized )
1901 {
1903 }
1904 else
1905 {
1906 // Set zoom to last used in this screen
1907 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
1908 RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
1909 }
1910
1911 UpdateTitle();
1912
1913 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
1914
1917 editTool->UpdateNetHighlighting( dummy );
1918
1920}
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
Definition: hierarch.cpp:139
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:72
virtual void RedrawScreen(const VECTOR2I &aCenterPoint, bool aWarpPointer)
Handle actions specific to the schematic editor.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
bool m_zoomInitialized
Definition: sch_screen.h:562
Generic, UI-independent tool event.
Definition: tool_event.h:156
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74

References ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, dummy(), SCH_BASE_FRAME::GetCanvas(), GetCurrentSheet(), GetScreen(), TOOL_MANAGER::GetTool(), SCH_DRAW_PANEL::GetView(), HardRedraw(), initScreenZoom(), SCH_SHEET_PATH::LastScreen(), m_hierarchy, TOOLS_HOLDER::m_toolManager, SCH_SCREEN::m_zoomInitialized, SCH_BASE_FRAME::RedrawScreen(), TOOL_MANAGER::RunAction(), KIGFX::SCH_VIEW::SetScale(), SetScreen(), SetSheetNumberAndCount(), SCH_SHEET_PATH::UpdateAllScreenReferences(), HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and UpdateTitle().

Referenced by SCH_NAVIGATE_TOOL::Back(), SCH_NAVIGATE_TOOL::changeSheet(), SCH_EDITOR_CONTROL::FindNext(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_NAVIGATE_TOOL::Forward(), DIALOG_ERC::OnERCItemSelected(), OnPageSettingsChange(), PutDataInPreviousState(), SCH_EDITOR_CONTROL::Revert(), and EE_SELECTION_TOOL::SyncSelection().

◆ DisplayGridMsg()

void EDA_DRAW_FRAME::DisplayGridMsg ( )
virtualinherited

Display current grid size in the status bar.

Reimplemented in GERBVIEW_FRAME, PCB_BASE_FRAME, and PL_EDITOR_FRAME.

Definition at line 578 of file eda_draw_frame.cpp.

579{
580 wxString msg;
581
582 msg.Printf( "grid %s", MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x, false ) );
583
584 SetStatusText( msg, 4 );
585}
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().

References EDA_DRAW_FRAME::GetCanvas(), and UNITS_PROVIDER::MessageTextFromValue().

Referenced by SCH_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from TOOLS_HOLDER.

Definition at line 566 of file eda_draw_frame.cpp.

567{
568 SetStatusText( msg, 6 );
569}

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 588 of file eda_draw_frame.cpp.

589{
590 wxString msg;
591
592 switch( GetUserUnits() )
593 {
594 case EDA_UNITS::INCHES: msg = _( "inches" ); break;
595 case EDA_UNITS::MILS: msg = _( "mils" ); break;
596 case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
597 default: msg = _( "Units" ); break;
598 }
599
600 SetStatusText( msg, 5 );
601}
EDA_UNITS GetUserUnits() const

References _, UNITS_PROVIDER::GetUserUnits(), INCHES, MILLIMETRES, and MILS.

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

◆ doAutoSave()

bool SCH_EDIT_FRAME::doAutoSave ( )
overrideprotectedvirtual

Save the schematic files that have been modified and not yet saved.

Returns
true if the auto save was successful otherwise false.

Reimplemented from EDA_BASE_FRAME.

Definition at line 1114 of file eeschema/files-io.cpp.

1115{
1116 wxFileName tmpFileName = Schematic().Root().GetFileName();
1117 wxFileName fn = tmpFileName;
1118 wxFileName tmp;
1119 SCH_SCREENS screens( Schematic().Root() );
1120
1121 // Don't run autosave if content has not been modified
1122 if( !IsContentModified() )
1123 return true;
1124
1125 bool autoSaveOk = true;
1126
1127 if( fn.GetPath().IsEmpty() )
1128 tmp.AssignDir( Prj().GetProjectPath() );
1129 else
1130 tmp.AssignDir( fn.GetPath() );
1131
1132 if( !tmp.IsOk() )
1133 return false;
1134
1135 if( !IsWritable( tmp ) )
1136 return false;
1137
1138 wxString title = GetTitle(); // Save frame title, that can be modified by the save process
1139
1140 for( size_t i = 0; i < screens.GetCount(); i++ )
1141 {
1142 // Only create auto save files for the schematics that have been modified.
1143 if( !screens.GetScreen( i )->IsContentModified() )
1144 continue;
1145
1146 tmpFileName = fn = screens.GetScreen( i )->GetFileName();
1147
1148 // Auto save file name is the normal file name prefixed with GetAutoSavePrefix().
1149 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
1150
1151 if( saveSchematicFile( screens.GetSheet( i ), fn.GetFullPath() ) )
1152 screens.GetScreen( i )->SetContentModified();
1153 else
1154 autoSaveOk = false;
1155 }
1156
1157 if( autoSaveOk && updateAutoSaveFile() )
1158 {
1159 m_autoSaveState = false;
1160
1161 if( !Kiface().IsSingle() &&
1162 GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
1163 {
1165 }
1166 }
1167
1168 SetTitle( title );
1169
1170 return autoSaveOk;
1171}
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Checks if aFileName can be written.
static REPORTER & GetInstance()
Definition: reporter.cpp:117
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:299
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.

References EDA_BASE_FRAME::GetAutoSaveFilePrefix(), SCH_SCREENS::GetCount(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetFileName(), NULL_REPORTER::GetInstance(), SCH_SCREENS::GetScreen(), EDA_BASE_FRAME::GetSettingsManager(), SCH_SCREENS::GetSheet(), BASE_SCREEN::IsContentModified(), IsContentModified(), EDA_BASE_FRAME::IsWritable(), Kiface(), EDA_BASE_FRAME::m_autoSaveState, KIWAY_HOLDER::Prj(), SCHEMATIC::Root(), saveSchematicFile(), Schematic(), BASE_SCREEN::SetContentModified(), SETTINGS_MANAGER::TriggerBackupIfNeeded(), and updateAutoSaveFile().

◆ doCloseWindow()

void SCH_EDIT_FRAME::doCloseWindow ( )
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 822 of file sch_edit_frame.cpp.

823{
824 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
825
826 // Shutdown all running tools
827 if( m_toolManager )
829
831
832 // Close the find dialog and preserve its setting if it is displayed.
834 {
837
838 m_findReplaceDialog->Destroy();
839 m_findReplaceDialog = nullptr;
840 }
841
842 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
843
844 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
845 {
846 hierarchy_pane.Show( false );
847 m_auimgr.Update();
848 }
849
850 if( Kiway().Player( FRAME_SIMULATOR, false ) )
852
853 SCH_SCREENS screens( Schematic().Root() );
854 wxFileName fn;
855
856 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
857 {
858 fn = Prj().AbsolutePath( screen->GetFileName() );
859
860 // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
861 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
862
863 if( fn.IsFileWritable() )
864 wxRemoveFile( fn.GetFullPath() );
865 }
866
867 wxFileName tmpFn = Prj().GetProjectFullName();
868 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
869
870 if( autoSaveFileName.IsFileWritable() )
871 wxRemoveFile( autoSaveFileName.GetFullPath() );
872
873 sheetlist.ClearModifyStatus();
874
875 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
876
877 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
878 UpdateFileHistory( fileName );
879
880 // Make sure local settings are persisted
882
884
885 // all sub sheets are deleted, only the main sheet is usable
887
888 // Clear view before destroying schematic as repaints depend on schematic being valid
889 SetScreen( nullptr );
890
891 Schematic().Reset();
892
893 Destroy();
894}
wxArrayString GetFindEntries() const
wxArrayString GetReplaceEntries() const
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxArrayString m_replaceStringHistoryList
wxArrayString m_findStringHistoryList
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:130
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:119
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:148
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:304
std::shared_ptr< NGSPICE_SIMULATOR_SETTINGS > m_NgspiceSimulatorSettings
Ngspice simulator settings.
const wxString & getAutoSaveFileName() const
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:221
void clear()
Forwarded method from std::vector.

References PROJECT::AbsolutePath(), SCH_SHEET_PATH::clear(), SCH_SCREEN::Clear(), SCH_SHEET_LIST::ClearModifyStatus(), KIWAY_PLAYER::Destroy(), FRAME_SIMULATOR, getAutoSaveFileName(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), GetCurrentSheet(), DIALOG_SCH_FIND::GetFindEntries(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), PROJECT::GetProjectFile(), PROJECT::GetProjectFullName(), DIALOG_SCH_FIND::GetReplaceEntries(), SCHEMATIC::GetSheets(), KIWAY_HOLDER::Kiway(), EDA_BASE_FRAME::m_auimgr, m_findReplaceDialog, EDA_DRAW_FRAME::m_findStringHistoryList, SCHEMATIC_SETTINGS::m_NgspiceSimulatorSettings, EDA_DRAW_FRAME::m_replaceStringHistoryList, PROJECT_FILE::m_SchematicSettings, TOOLS_HOLDER::m_toolManager, KIWAY_HOLDER::Prj(), RecordERCExclusions(), SCHEMATIC::Reset(), SCHEMATIC::RootScreen(), SaveProjectSettings(), Schematic(), SchematicHierarchyPaneName(), SetScreen(), TOOL_MANAGER::ShutdownAllTools(), and EDA_BASE_FRAME::UpdateFileHistory().

◆ DoWithAcceptedFiles()

void EDA_BASE_FRAME::DoWithAcceptedFiles ( )
protectedvirtualinherited

Execute action on accepted dropped file.

Called in OnDropFiles and should be populated with the action to execute in inherited classes.

Reimplemented in GERBVIEW_FRAME, KICAD_MANAGER_FRAME, and PL_EDITOR_FRAME.

Definition at line 1138 of file eda_base_frame.cpp.

1139{
1140 for( const wxFileName& file : m_AcceptedFiles )
1141 {
1142 wxString fn = file.GetFullPath();
1143 m_toolManager->RunAction( *m_acceptedExts.at( file.GetExt() ), true, &fn );
1144 }
1145}
std::vector< wxFileName > m_AcceptedFiles

References EDA_BASE_FRAME::m_acceptedExts, EDA_BASE_FRAME::m_AcceptedFiles, TOOLS_HOLDER::m_toolManager, and TOOL_MANAGER::RunAction().

Referenced by EDA_BASE_FRAME::OnDropFiles().

◆ DrawCurrentSheetToClipboard()

void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard ( )

Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.

Definition at line 477 of file sheet.cpp.

478{
479 wxRect DrawArea;
480 BASE_SCREEN* screen = GetScreen();
481
482 DrawArea.SetSize( GetPageSizeIU() );
483
484 // Calculate a reasonable dc size, in pixels, and the dc scale to fit
485 // the drawings into the dc size
486 // scale is the ratio resolution (in PPI) / internal units
487 double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
488 double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS;
489 double scale = ppi / inch2Iu;
490
491 wxSize dcsize = DrawArea.GetSize();
492
493 int maxdim = std::max( dcsize.x, dcsize.y );
494
495 // the max size in pixels of the bitmap used to build the sheet copy
496 const int maxbitmapsize = 5600;
497
498 while( int( maxdim * scale ) > maxbitmapsize )
499 {
500 ppi = ppi / 1.5;
501 scale = ppi / inch2Iu;
502 }
503
504 dcsize.x *= scale;
505 dcsize.y *= scale;
506
507 // Set draw offset, zoom... to values needed to draw in the memory DC
508 // after saving initial values:
509 VECTOR2I tmp_startvisu = screen->m_StartVisu;
510 VECTOR2I old_org = screen->m_DrawOrg;
511 screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
512 screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
513
514 wxMemoryDC dc;
515 wxBitmap image( dcsize );
516 dc.SelectObject( image );
517 dc.Clear();
518
519 GRResetPenAndBrush( &dc );
520 GRForceBlackPen( false );
521 dc.SetUserScale( scale, scale );
522
524 // Init the color of the layer actually used to print the drawing sheet:
527
529
530 {
531 wxLogNull doNotLog; // disable logging of failed clipboard actions
532
533 if( wxTheClipboard->Open() )
534 {
535 // This data objects are held by the clipboard, so do not delete them in the app.
536 wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
537 wxTheClipboard->SetData( clipbrd_data );
538 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
539 wxTheClipboard->Close();
540 }
541 }
542
543 // Deselect Bitmap from DC in order to delete the MemoryDC
544 dc.SelectObject( wxNullBitmap );
545
546 GRForceBlackPen( false );
547
548 screen->m_StartVisu = tmp_startvisu;
549 screen->m_DrawOrg = old_org;
550}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
VECTOR2I m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:88
VECTOR2I m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:93
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void SetPrintDC(wxDC *aDC)
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:150
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:72
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:217
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:382
const int scale
const double IU_PER_MILS
Definition: base_units.h:78

References SCH_BASE_FRAME::GetLayerColor(), SCH_BASE_FRAME::GetPageSizeIU(), SCH_BASE_FRAME::GetRenderSettings(), GetScreen(), GRForceBlackPen(), GRResetPenAndBrush(), image, EDA_IU_SCALE::IU_PER_MILS, LAYER_DRAWINGSHEET, LAYER_SCHEMATIC_DRAWINGSHEET, BASE_SCREEN::m_DrawOrg, BASE_SCREEN::m_StartVisu, PrintPage(), scale, schIUScale, KIGFX::RENDER_SETTINGS::SetLayerColor(), KIGFX::RENDER_SETTINGS::SetPrintDC(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_EDITOR_CONTROL::DrawSheetOnClipboard().

◆ EditSheetProperties()

bool SCH_EDIT_FRAME::EditSheetProperties ( SCH_SHEET aSheet,
SCH_SHEET_PATH aHierarchy,
bool *  aClearAnnotationNewItems 
)

Edit an existing sheet or add a new sheet to the schematic.

When aSheet is a new sheet:

  • and the file name already exists in the schematic hierarchy, the screen associated with the sheet found in the hierarchy is associated with aSheet.
  • and the file name already exists on the system, then aSheet is loaded with the existing file.
  • and the file name does not exist in the schematic hierarchy or on the file system, then a new screen is created and associated with aSheet.

When aSheet is an existing sheet:

  • and the file name already exists in the schematic hierarchy, the current associated screen is replace by the one found in the hierarchy.
  • and the file name already exists on the system, the current associated screen file name is changed and the file is loaded.
  • and the file name does not exist in the schematic hierarchy or on the file system, the current associated screen file name is changed and saved to disk.

Note: the screen is not refresh. The caller is responsible to do that

Parameters
aSheetis the sheet to edit
aHierarchyis the current hierarchy containing aSheet
aClearAnnotationNewItemsis a reference to a bool to know if the items managed by this sheet need to have their annotation cleared i.e. when an existing item list is used. it can happens when the edited sheet used an existing file, or becomes a new instance of a already existing sheet.

Definition at line 461 of file sheet.cpp.

463{
464 if( aSheet == nullptr || aHierarchy == nullptr )
465 return false;
466
467 // Get the new texts
468 DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
469
470 if( dlg.ShowModal() == wxID_CANCEL )
471 return false;
472
473 return true;
474}

Referenced by SCH_DRAWING_TOOLS::DrawSheet(), and SCH_EDIT_TOOL::Properties().

◆ eeconfig()

EESCHEMA_SETTINGS * SCH_BASE_FRAME::eeconfig ( ) const
inherited

Definition at line 131 of file sch_base_frame.cpp.

132{
133 return dynamic_cast<EESCHEMA_SETTINGS*>( config() );
134}
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(), AllowCaseSensitiveFileNameClashes(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDITOR_CONTROL::ChangeLineMode(), EE_SELECTION_TOOL::CollectHits(), DIALOG_BOM::DIALOG_BOM(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::editFieldText(), ExecuteRemoteCommand(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), GetSchematicJunctionSize(), GetShowAllPins(), EE_SELECTION_TOOL::GuessSelectionCandidates(), DIALOG_BOM::installGeneratorsList(), KiwayMailIn(), SCH_EDITOR_CONDITIONS::lineModeFunc(), LoadSettings(), EE_SELECTION_TOOL::Main(), SCH_EDITOR_CONTROL::NextLineMode(), DIALOG_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_TEXT_PROPERTIES::onBorderChecked(), DIALOG_PRINT_USING_PRINTER::OnMonochromeChecked(), OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_PRINTOUT::PrintPage(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), DIALOG_PRINT_USING_PRINTER::SavePrintOptions(), SaveSettings(), EE_SELECTION_TOOL::Selectable(), SelectUnit(), setupUIConditions(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), EE_SELECTION_TOOL::SyncSelection(), SCH_EDITOR_CONTROL::ToggleAnnotateAuto(), SCH_EDITOR_CONTROL::ToggleAnnotateRecursive(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), ToggleSchematicHierarchy(), DIALOG_PRINT_USING_PRINTER::TransferDataToWindow(), and DIALOG_BOM::~DIALOG_BOM().

◆ ensureWindowIsOnScreen()

void EDA_BASE_FRAME::ensureWindowIsOnScreen ( )
protectedinherited

Definition at line 640 of file eda_base_frame.cpp.

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

References EDA_BASE_FRAME::GetWindowSize(), and traceDisplayLocation.

Referenced by EDA_BASE_FRAME::OnSize().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

◆ ExecuteRemoteCommand()

void SCH_EDIT_FRAME::ExecuteRemoteCommand ( const char *  cmdline)
overridevirtual

Execute a remote command sent by Pcbnew via a socket connection.

When user selects a footprint or pin in Pcbnew, Eeschema shows that same symbol or pin and moves cursor on the item. The socket port used is KICAD_SCH_PORT_SERVICE_NUMBER which defaults to 4243.

Valid commands are:

  • $PART: "reference" Put cursor on symbol.
  • $PART: "reference" $REF: "ref" Put cursor on symbol reference.
  • $PART: "reference" $VAL: "value" Put cursor on symbol value.
  • $PART: "reference" $PAD: "pin name" Put cursor on the symbol pin.
  • $NET: "netname" Highlight a specified net
  • $CLEAR: "HIGHLIGHTED" Clear symbols highlight

They are a keyword followed by a quoted string.

Parameters
cmdlineis the command received from Pcbnew.

Reimplemented from KIWAY_PLAYER.

Definition at line 186 of file eeschema/cross-probing.cpp.

187{
189 char line[1024];
190
191 strncpy( line, cmdline, sizeof( line ) - 1 );
192 line[ sizeof( line ) - 1 ] = '\0';
193
194 char* idcmd = strtok( line, " \n\r" );
195 char* text = strtok( nullptr, "\"\n\r" );
196
197 if( idcmd == nullptr )
198 return;
199
200 CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
201
202 if( strcmp( idcmd, "$NET:" ) == 0 )
203 {
204 if( !crossProbingSettings.auto_highlight )
205 return;
206
207 wxString netName = FROM_UTF8( text );
208
209 if( auto sg = Schematic().ConnectionGraph()->FindFirstSubgraphByName( netName ) )
210 m_highlightedConn = sg->m_driver_connection;
211 else
212 m_highlightedConn = nullptr;
213
215
216 SetStatusText( _( "Selected net:" ) + wxS( " " ) + UnescapeString( netName ) );
217 return;
218 }
219
220 if( strcmp( idcmd, "$CLEAR:" ) == 0 )
221 {
222 // Cross-probing is now done through selection so we no longer need a clear command
223 return;
224 }
225
226 if( !crossProbingSettings.on_selection )
227 return;
228
229 if( text == nullptr )
230 return;
231
232 if( strcmp( idcmd, "$PART:" ) != 0 )
233 return;
234
235 wxString part_ref = FROM_UTF8( text );
236
237 /* look for a complement */
238 idcmd = strtok( nullptr, " \n\r" );
239
240 if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew)
241 {
242 // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing
243 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
244 return;
245 }
246
247 text = strtok( nullptr, "\"\n\r" );
248
249 if( text == nullptr )
250 return;
251
252 wxString msg = FROM_UTF8( text );
253
254 if( strcmp( idcmd, "$REF:" ) == 0 )
255 {
256 // Highlighting the reference itself isn't actually that useful, and it's harder to
257 // see. Highlight the parent and display the message.
258 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
259 }
260 else if( strcmp( idcmd, "$VAL:" ) == 0 )
261 {
262 // Highlighting the value itself isn't actually that useful, and it's harder to see.
263 // Highlight the parent and display the message.
264 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
265 }
266 else if( strcmp( idcmd, "$PAD:" ) == 0 )
267 {
268 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_PIN, msg );
269 }
270 else
271 {
272 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
273 }
274}
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:170
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:254
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
@ HIGHLIGHT_SYMBOL
@ HIGHLIGHT_PIN
wxString UnescapeString(const wxString &aSource)
Cross-probing behavior.
Definition: app_settings.h:31
bool on_selection
Synchronize the selection for multiple items too.
Definition: app_settings.h:32
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:35

References _, CROSS_PROBING_SETTINGS::auto_highlight, editor, SCH_BASE_FRAME::eeconfig(), FROM_UTF8(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), HIGHLIGHT_PIN, HIGHLIGHT_SYMBOL, APP_SETTINGS_BASE::m_CrossProbing, m_highlightedConn, TOOLS_HOLDER::m_toolManager, CROSS_PROBING_SETTINGS::on_selection, TOOL_MANAGER::RunAction(), Schematic(), text, UnescapeString(), and EE_ACTIONS::updateNetHighlighting.

Referenced by KiwayMailIn().

◆ findDialogs()

std::vector< wxWindow * > EDA_DRAW_FRAME::findDialogs ( )
protectedinherited

Definition at line 898 of file eda_draw_frame.cpp.

899{
900 std::vector<wxWindow*> dialogs;
901
902 for( wxWindow* window : GetChildren() )
903 {
904 if( dynamic_cast<DIALOG_SHIM*>( window ) )
905 dialogs.push_back( window );
906 }
907
908 return dialogs;
909}
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83

Referenced by PCB_BASE_FRAME::FocusOnItems(), and EDA_DRAW_FRAME::FocusOnLocation().

◆ findQuasiModalDialog()

wxWindow * EDA_BASE_FRAME::findQuasiModalDialog ( )
privateinherited

Definition at line 168 of file eda_base_frame.cpp.

169{
170 for( wxWindow* iter : GetChildren() )
171 {
172 DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
173
174 if( dlg && dlg->IsQuasiModal() )
175 return dlg;
176 }
177
178 // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
179 // so we have to look for it separately.
180 if( m_ident == FRAME_SCH )
181 {
182 wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
183
184 if( cvpcb )
185 return cvpcb;
186 }
187
188 return nullptr;
189}
bool IsQuasiModal() const
Definition: dialog_shim.h:106

References FRAME_SCH, DIALOG_SHIM::IsQuasiModal(), and EDA_BASE_FRAME::m_ident.

Referenced by EDA_BASE_FRAME::ProcessEvent(), and EDA_BASE_FRAME::windowClosing().

◆ FinishAUIInitialization()

void EDA_BASE_FRAME::FinishAUIInitialization ( )
inherited

Definition at line 825 of file eda_base_frame.cpp.

826{
827#if defined( __WXOSX_MAC__ )
828 m_auimgr.Update();
829#else
830 // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
831 // hiding it.
832 m_auimgr.Update();
833
834 // We don't want the infobar displayed right away
835 m_auimgr.GetPane( "InfoBar" ).Hide();
836 m_auimgr.Update();
837#endif
838}

References EDA_BASE_FRAME::m_auimgr.

◆ FixupJunctions()

void SCH_EDIT_FRAME::FixupJunctions ( )

Definition at line 1726 of file sch_edit_frame.cpp.

1727{
1728 // Save the current sheet, to retrieve it later
1729 SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1730
1731 SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1732
1733 for( const SCH_SHEET_PATH& sheet : sheetList )
1734 {
1735 size_t num_undos = m_undoList.m_CommandsList.size();
1736
1737 // We require a set here to avoid adding multiple junctions to the same spot
1738 std::set<wxPoint> junctions;
1739
1740 SetCurrentSheet( sheet );
1742
1744
1745 EE_SELECTION allItems;
1746
1747 for( auto item : screen->Items() )
1748 allItems.Add( item );
1749
1751
1752 // Check if we modified anything during this routine
1753 // Needs to happen for every sheet to set the proper modified flag
1754 if( m_undoList.m_CommandsList.size() > num_undos )
1755 OnModify();
1756 }
1757
1758 // Reselect the initial sheet:
1759 SetCurrentSheet( oldsheetpath );
1761 SetScreen( GetCurrentSheet().LastScreen() );
1762}
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:78
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32

References SELECTION::Add(), EE_ACTIONS::addNeededJunctions, GetCurrentSheet(), SCHEMATIC::GetSheets(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), UNDO_REDO_CONTAINER::m_CommandsList, TOOLS_HOLDER::m_toolManager, EDA_BASE_FRAME::m_undoList, OnModify(), TOOL_MANAGER::RunAction(), Schematic(), SetCurrentSheet(), SetScreen(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

Referenced by importFile(), and OpenProjectFiles().

◆ FocusOnItem()

void SCH_EDIT_FRAME::FocusOnItem ( SCH_ITEM aItem)

Definition at line 1778 of file sch_edit_frame.cpp.

1779{
1780 static KIID lastBrightenedItemID( niluuid );
1781
1782 SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1784 SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1785
1786 if( lastItem && lastItem != aItem )
1787 {
1788 lastItem->ClearBrightened();
1789
1790 UpdateItem( lastItem );
1791 lastBrightenedItemID = niluuid;
1792 }
1793
1794 if( aItem )
1795 {
1796 if( !aItem->IsBrightened() )
1797 {
1798 aItem->SetBrightened();
1799
1800 UpdateItem( aItem );
1801 lastBrightenedItemID = aItem->m_Uuid;
1802 }
1803
1805 }
1806}
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:256
void ClearBrightened()
Definition: eda_item.h:122
void SetBrightened()
Definition: eda_item.h:119
bool IsBrightened() const
Definition: eda_item.h:110
Definition: kiid.h:47
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
KIID niluuid(0)

References EDA_ITEM::ClearBrightened(), dummy(), EDA_DRAW_FRAME::FocusOnLocation(), EDA_ITEM::GetFocusPosition(), SCH_SHEET_LIST::GetItem(), SCHEMATIC::GetSheets(), EDA_ITEM::IsBrightened(), EDA_ITEM::m_Uuid, niluuid, Schematic(), EDA_ITEM::SetBrightened(), and UpdateItem().

Referenced by SCH_EDITOR_CONTROL::FindSymbolAndItem(), HardRedraw(), DIALOG_ERC::OnCancelClick(), DIALOG_ERC::OnCloseErcDialog(), DIALOG_ERC::OnERCItemSelected(), SetCurrentSheet(), and EE_SELECTION_TOOL::SyncSelection().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const VECTOR2I 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 912 of file eda_draw_frame.cpp.

913{
914 bool centerView = false;
916
917 // Center if we're off the current view, or within 10% of its edge
918 r.Inflate( - (int) r.GetWidth() / 10 );
919
920 if( !r.Contains( aPos ) )
921 centerView = true;
922
923 std::vector<BOX2D> dialogScreenRects;
924
925 for( wxWindow* dialog : findDialogs() )
926 {
927 dialogScreenRects.emplace_back( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
928 dialog->GetSize() );
929 }
930
931 // Center if we're behind an obscuring dialog, or within 10% of its edge
932 for( BOX2D rect : dialogScreenRects )
933 {
934 rect.Inflate( rect.GetWidth() / 10 );
935
936 if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
937 centerView = true;
938 }
939
940 if( centerView )
941 {
942 try
943 {
944 GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
945 }
946 catch( const ClipperLib::clipperException& exc )
947 {
948 wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
949 exc.what() );
950 }
951 }
952
954}
std::vector< wxWindow * > findDialogs()
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
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.
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:508
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:574
E_SERIE r
Definition: eserie.cpp:41

References EDA_DRAW_FRAME::findDialogs(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetView(), EDA_DRAW_PANEL_GAL::GetViewControls(), KIGFX::VIEW::GetViewport(), r, KIGFX::VIEW::SetCenter(), and KIGFX::VIEW_CONTROLS::SetCrossHairCursorPosition().

Referenced by PCB_SELECTION_TOOL::doSyncSelection(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindNext(), FocusOnItem(), PCB_BASE_FRAME::FocusOnItems(), DIALOG_DRC::OnDRCItemSelected(), and EE_SELECTION_TOOL::SyncSelection().

◆ GetAboutTitle()

const wxString & EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

◆ getAutoSaveFileName()

const wxString & SCH_EDIT_FRAME::getAutoSaveFileName ( ) const
private

Definition at line 1502 of file eeschema/files-io.cpp.

1503{
1504 static wxString autoSaveFileName( wxT( "#auto_saved_files#" ) );
1505
1506 return autoSaveFileName;
1507}

Referenced by doCloseWindow(), OpenProjectFiles(), and updateAutoSaveFile().

◆ GetAutoSaveFilePrefix()

static wxString EDA_BASE_FRAME::GetAutoSaveFilePrefix ( )
inlinestaticprotectedinherited

◆ GetAutoSaveInterval()

int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inherited

Definition at line 297 of file eda_base_frame.cpp.

298{
299 return Pgm().GetCommonSettings()->m_System.autosave_interval;
300}

References Pgm().

Referenced by EDA_DRAW_FRAME::CommonSettingsChanged(), EDA_BASE_FRAME::onAutoSaveTimer(), and EDA_BASE_FRAME::ProcessEvent().

◆ 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 320 of file sch_base_frame.cpp.

321{
322 return static_cast<SCH_DRAW_PANEL*>( EDA_DRAW_FRAME::GetCanvas() );
323}

References EDA_DRAW_FRAME::GetCanvas().

Referenced by SCH_BASE_FRAME::ActivateGalCanvas(), AddItemToScreenAndUndoList(), AddJunction(), SCH_BASE_FRAME::AddToScreen(), AnnotateSymbols(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), SCH_NAVIGATE_TOOL::changeSheet(), SYMBOL_VIEWER_FRAME::ClickOnSymbolList(), SCH_BASE_FRAME::CommonSettingsChanged(), CommonSettingsChanged(), SYMBOL_EDIT_FRAME::CommonSettingsChanged(), SYMBOL_VIEWER_FRAME::CommonSettingsChanged(), DIALOG_CHOOSE_SYMBOL::ConstructRightPanel(), DeleteAnnotation(), DisplayCurrentSheet(), SYMBOL_VIEWER_FRAME::doCloseWindow(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties(), SYMBOL_EDITOR_EDIT_TOOL::editTextProperties(), EE_INSPECTION_TOOL::ExcludeMarker(), DIALOG_ERC::ExcludeMarker(), SCH_EDITOR_CONTROL::FindNext(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), GetDocumentExtents(), SCH_BASE_FRAME::GetRenderSettings(), SCH_BASE_FRAME::HardRedraw(), HardRedraw(), SCH_EDITOR_CONTROL::ImportFPAssignments(), SCH_EDIT_TOOL::Init(), KiwayMailIn(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), DIALOG_MIGRATE_BUSES::onAcceptClicked(), DIALOG_ANNOTATE::OnApplyClick(), DIALOG_ERC::OnERCItemRClick(), EE_SELECTION_TOOL::OnIdle(), DIALOG_MIGRATE_BUSES::onItemSelected(), OnModify(), OnPageSettingsChange(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), DIALOG_UPDATE_FROM_PCB::OnUpdateClick(), SYMBOL_TREE_PANE::onUpdateUI(), SCH_EDITOR_CONTROL::PageSetup(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), SCH_DRAWING_TOOLS::PlaceSymbol(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_EDIT_TOOL::Properties(), PutDataInPreviousState(), SYMBOL_EDIT_FRAME::RebuildView(), RecalculateConnections(), RecomputeIntersheetRefs(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), SCH_EDITOR_CONTROL::Redo(), DIALOG_ERC::redrawDrawPanel(), SCH_BASE_FRAME::RedrawScreen(), SCH_BASE_FRAME::RefreshZoomDependentItems(), 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_EDITOR_CONTROL::Revert(), RollbackSchematicFromUndo(), SaveSymbolToSchematic(), EE_SELECTION_TOOL::selectMultiple(), SetCurrentSheet(), SYMBOL_EDIT_FRAME::SetCurSymbol(), EE_POINT_EDITOR::setEditedPoint(), SetScreen(), SYMBOL_VIEWER_FRAME::SetSelectedLibrary(), setupTools(), SYMBOL_EDIT_FRAME::setupTools(), SYMBOL_VIEWER_FRAME::setupTools(), ShowAllIntersheetRefs(), SYMBOL_EDIT_FRAME::ShowChangedLanguage(), SYMBOL_EDITOR_CONTROL::ShowElectricalTypes(), SYMBOL_EDITOR_CONTROL::ShowPinNumbers(), ShowSchematicSetupDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDIT_FRAME::SwitchCanvas(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), SCH_BASE_FRAME::SyncView(), TestDanglingEnds(), DIALOG_ERC::testErc(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LINE_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_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(), and SYMBOL_VIEWER_FRAME::~SYMBOL_VIEWER_FRAME().

◆ GetColorSettings()

COLOR_SETTINGS * SCH_BASE_FRAME::GetColorSettings ( bool  aForceRefresh = false) const
overridevirtualinherited

Returns a pointer to the active color theme settings.

Reimplemented from EDA_DRAW_FRAME.

Reimplemented in SYMBOL_EDIT_FRAME.

Definition at line 506 of file sch_base_frame.cpp.

507{
508 if( !m_colorSettings || aForceRefresh )
509 {
510 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
512 wxString colorTheme = cfg->m_ColorTheme;
513
515 {
517
518 if( !symCfg->m_UseEeschemaColorSettings )
519 colorTheme = symCfg->m_ColorTheme;
520 }
521
522 COLOR_SETTINGS* colorSettings = mgr.GetColorSettings( colorTheme );
523
524 const_cast<SCH_BASE_FRAME*>( this )->m_colorSettings = colorSettings;
525 }
526
527 return m_colorSettings;
528}
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:187
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool IsType(FRAME_T aType) const
COLOR_SETTINGS * m_colorSettings
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
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.

References FRAME_SCH_SYMBOL_EDITOR, SETTINGS_MANAGER::GetAppSettings(), SETTINGS_MANAGER::GetColorSettings(), EDA_BASE_FRAME::IsType(), EDA_DRAW_FRAME::m_colorSettings, APP_SETTINGS_BASE::m_ColorTheme, SYMBOL_EDITOR_SETTINGS::m_UseEeschemaColorSettings, and Pgm().

Referenced by SCH_BASE_FRAME::CommonSettingsChanged(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), DIALOG_JUNCTION_PROPS::DIALOG_JUNCTION_PROPS(), DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES(), DIALOG_LINE_PROPERTIES::DIALOG_LINE_PROPERTIES(), DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES(), DIALOG_SHEET_PIN_PROPERTIES::DIALOG_SHEET_PIN_PROPERTIES(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_WIRE_BUS_PROPERTIES::DIALOG_WIRE_BUS_PROPERTIES(), SCH_BASE_FRAME::GetDrawBgColor(), SCH_BASE_FRAME::GetLayerColor(), PrintPage(), SCH_PRINTOUT::PrintPage(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), and DIALOG_SHEET_PROPERTIES::TransferDataToWindow().

◆ GetCurrentFileName()

wxString SCH_EDIT_FRAME::GetCurrentFileName ( ) const
overridevirtual

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 from EDA_BASE_FRAME.

Definition at line 1809 of file sch_edit_frame.cpp.

1810{
1811 return Schematic().GetFileName();
1812}
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:166

References SCHEMATIC::GetFileName(), and Schematic().

Referenced by OpenProjectFiles().

◆ GetCurrentSelection()

SELECTION & SCH_EDIT_FRAME::GetCurrentSelection ( )
overridevirtual

Get the current selection from the canvas area.

Returns
the current selection.

Reimplemented from TOOLS_HOLDER.

Definition at line 1815 of file sch_edit_frame.cpp.

1816{
1817 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1818}

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

◆ GetCurrentSheet()

SCH_SHEET_PATH & SCH_EDIT_FRAME::GetCurrentSheet ( ) const

Definition at line 705 of file sch_edit_frame.cpp.

706{
707 return m_schematic->CurrentSheet();
708}
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119

References SCHEMATIC::CurrentSheet(), and m_schematic.

Referenced by AddItemToScreenAndUndoList(), AddSheetAndUpdateDisplay(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), AnnotateSymbols(), SCH_EDITOR_CONTROL::AssignNetclass(), AutoRotateItem(), SCH_NAVIGATE_TOOL::CanGoNext(), SCH_NAVIGATE_TOOL::CanGoPrevious(), SCH_NAVIGATE_TOOL::CanGoUp(), CheckAnnotate(), CommonSettingsChanged(), DIALOG_PLOT_SCHEMATIC::createDXFFiles(), DIALOG_PLOT_SCHEMATIC::createHPGLFiles(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPSFiles(), DIALOG_PLOT_SCHEMATIC::createSVGFiles(), DeleteAnnotation(), DisplayCurrentSheet(), KIGFX::SCH_VIEW::DisplaySheet(), doCloseWindow(), SCH_EDITOR_CONTROL::doCopy(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::editFieldText(), SCH_EDIT_TOOL::EditPageNumber(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::FindNext(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), FixupJunctions(), SCH_PIN::GetMsgPanelInfo(), SCH_SYMBOL::GetMsgPanelInfo(), GetScreen(), GetScreenDesc(), GetUniqueFilenameForCurrentSheet(), HardRedraw(), SCH_EDITOR_CONTROL::HasMatch(), importFile(), EE_SELECTION_TOOL::Init(), SCH_DRAWING_TOOLS::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_NAVIGATE_TOOL::Next(), DIALOG_ERC::OnERCItemSelected(), DIALOG_MIGRATE_BUSES::onItemSelected(), SCH_PRINTOUT::OnPrintPage(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), HIERARCHY_NAVIG_PANEL::onRightClick(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), DIALOG_UPDATE_FROM_PCB::OnUpdateClick(), DIALOG_SHEET_PROPERTIES::OnUpdateUI(), OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceSymbol(), DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG(), SCH_NAVIGATE_TOOL::Previous(), DIALOG_CHANGE_SYMBOLS::processMatchingSymbols(), SCH_EDIT_TOOL::Properties(), SCH_EDITOR_CONTROL::ReplaceAll(), SCH_EDITOR_CONTROL::ReplaceAndFindNext(), SCH_EDITOR_CONTROL::RescueLegacyProject(), SCH_EDITOR_CONTROL::RescueSymbolLibTableProject(), SCH_NAVIGATE_TOOL::ResetHistory(), DIALOG_PLOT_SCHEMATIC::restoreEnvironment(), SCH_EDITOR_CONTROL::Revert(), SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs(), SaveSymbolToSchematic(), SelectUnit(), SendSelectItemsToPcb(), SetCurrentSheet(), SetSheetNumberAndCount(), ShowFindReplaceDialog(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_FIELDS_TABLE::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), SCH_EDITOR_CONTROL::UpdateFind(), HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and UpdateTitle().

◆ GetDocumentExtents()

const BOX2I SCH_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 1697 of file sch_edit_frame.cpp.

1698{
1699 BOX2I bBoxDoc;
1700
1701 if( aIncludeAllVisible )
1702 {
1703 // Get the whole page size and return that
1706 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1707 }
1708 else
1709 {
1710 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
1712 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
1713
1714 // Calc the bounding box of all items on screen except the page border
1715 for( EDA_ITEM* item : GetScreen()->Items() )
1716 {
1717 if( item != dsAsItem ) // Ignore the drawing-sheet itself
1718 bBoxDoc.Merge( item->GetBoundingBox() );
1719 }
1720 }
1721
1722 return bBoxDoc;
1723}
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:100
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:153
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:144
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:130
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References SCH_BASE_FRAME::GetCanvas(), KIGFX::SCH_VIEW::GetDrawingSheet(), PAGE_INFO::GetHeightIU(), SCH_SCREEN::GetPageSettings(), GetScreen(), SCH_DRAW_PANEL::GetView(), PAGE_INFO::GetWidthIU(), SCH_SCREEN::Items(), EDA_IU_SCALE::IU_PER_MILS, BOX2< Vec >::Merge(), and schIUScale.

◆ 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 141 of file tools_holder.h.

141{ return m_immediateActions; }
bool m_immediateActions
Definition: tools_holder.h:183

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 147 of file tools_holder.h.

147{ return m_dragAction; }
MOUSE_DRAG_ACTION m_dragAction
Definition: tools_holder.h:187

References TOOLS_HOLDER::m_dragAction.

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

◆ GetDrawBgColor()

COLOR4D SCH_BASE_FRAME::GetDrawBgColor ( ) const
overridevirtualinherited

Reimplemented from EDA_DRAW_FRAME.

Definition at line 531 of file sch_base_frame.cpp.

532{
534}
COLOR4D GetColor(int aLayer) const
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376

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 908 of file eda_base_frame.cpp.

910{
911 if( !aFileHistory )
912 aFileHistory = m_fileHistory;
913
914 wxASSERT( aFileHistory );
915
916 int baseId = aFileHistory->GetBaseId();
917
918 wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
919
920 unsigned i = cmdId - baseId;
921
922 if( i < aFileHistory->GetCount() )
923 {
924 wxString fn = aFileHistory->GetHistoryFile( i );
925
926 if( wxFileName::FileExists( fn ) )
927 {
928 return fn;
929 }
930 else
931 {
932 DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
933 aFileHistory->RemoveFileFromHistory( i );
934 }
935 }
936
937 // Update the menubar to update the file history menu
938 if( GetMenuBar() )
939 {
940