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

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 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 (bool aForceUpdate=false)
 Run the Hierarchy Navigator dialog. More...
 
HIERARCHY_NAVIG_DLGFindHierarchyNavigator ()
 
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 wxPoint &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
 Break a single segment into two at the specified point. More...
 
bool BreakSegments (const wxPoint &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 SendMessageToPCBNEW (EDA_ITEM *aObjectToSync, SCH_SYMBOL *aPart)
 Send a message to Pcbnew via a socket connection. 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 *appendUndo)
 Clear the current symbol annotation. More...
 
void AnnotateSymbols (ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, REPORTER &aReporter)
 Annotate the symbols in the schematic that are not currently annotated. More...
 
int CheckAnnotate (ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL)
 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 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 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 wxPoint &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 wxPoint &aStart, const wxPoint &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< wxPoint > GetSchematicConnections ()
 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)
 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)
 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...
 
SCH_ITEMGetRepeatItem () const
 Return the item which is 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 InstallPreferences (PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
 Allow Eeschema to install its preferences panels into the preferences dialog. 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)
 
void SaveSymbolToSchematic (const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
 Update a schematic symbol from a LIB_SYMBOL. More...
 
void RecomputeIntersheetRefs ()
 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 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 wxPoint & GetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const wxPoint &aPoint) override
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
void UpdateStatusBar () override
 Update the status bar information. More...
 
PICKED_SYMBOL PickSymbolFromLibTree (const SCHLIB_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
 Call the library viewer to select symbol to import into schematic. More...
 
LIB_SYMBOLGetLibSymbol (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
 Load symbol from symbol library table. More...
 
PICKED_SYMBOL PickSymbolFromLibBrowser (wxTopLevelWindow *aParent, const SCHLIB_FILTER *aFilter, const LIB_ID &aPreselectedLibId, int aUnit, int aConvert)
 Call the library viewer to select symbol to import into schematic. More...
 
virtual void RedrawScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
virtual void CenterScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
void AddToScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen)
 Add an item to the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void RemoveFromScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen)
 Remove an item from the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void UpdateItem (EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
 Mark an item for refresh. More...
 
void RefreshSelection ()
 Mark selected items for refresh. More...
 
void SyncView ()
 Mark all items for refresh. More...
 
COLOR4D GetLayerColor (SCH_LAYER_ID aLayer)
 Helper to retrieve a layer color from the global color settings. More...
 
COLOR_SETTINGSGetColorSettings () const override
 Returns a pointer to the active color theme settings. More...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
void ScriptingConsoleEnableDisable ()
 Toggles the scripting console visibility. More...
 
bool IsScriptingConsoleVisible ()
 Gets the current visibility of the scripting console window. More...
 
wxFindReplaceData & GetFindReplaceData ()
 
wxArrayString & GetFindHistoryList ()
 
bool GetShowPolarCoords () const
 For those frames that support polar coordinates. More...
 
void SetShowPolarCoords (bool aShow)
 
void ToggleUserUnits () override
 
void GetUnitPair (EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
 Get the pair or units in current use. More...
 
wxPoint GetNearestGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
wxPoint GetNearestHalfGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize / 2 location to aPosition. More...
 
virtual ORIGIN_TRANSFORMSGetOriginTransforms ()
 Return a reference to the default ORIGIN_TRANSFORMS object. More...
 
virtual void SetDrawBgColor (const COLOR4D &aColor)
 
bool ShowPageLimits () const
 
void SetShowPageLimits (bool aShow)
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
 
void EraseMsgBox ()
 
virtual void ReCreateAuxiliaryToolbar ()
 
virtual void UpdateToolbarControlSizes ()
 Update the sizes of any controls in the toolbars of the frame. More...
 
bool IsGridVisible () const
 
virtual void SetGridVisibility (bool aVisible)
 
virtual COLOR4D GetGridColor ()
 
virtual void SetGridColor (const COLOR4D &aColor)
 
void OnSelectGrid (wxCommandEvent &event)
 Command event handler for selecting grid sizes. More...
 
void OnGridSettings (wxCommandEvent &event)
 
void UpdateGridSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.). More...
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 Update the checked item in the grid combobox. More...
 
void UpdateZoomSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.) More...
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 Update the checked item in the zoom combobox. More...
 
const wxString GetZoomLevelIndicator () const
 Return a human readable value for display in dialogs. More...
 
virtual void OnSelectZoom (wxCommandEvent &event)
 Set the zoom factor when selected by the zoom list box in the main tool bar. More...
 
virtual void OnSize (wxSizeEvent &event) override
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
virtual void Zoom_Automatique (bool aWarpPointer)
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void FocusOnLocation (const wxPoint &aPos)
 Useful to focus on a particular location, in find functions. More...
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Construct a "basic" menu for a tool, containing only items that apply to all tools (e.g. More...
 
void PrintDrawingSheet (const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Prints the drawing-sheet (frame and title block). More...
 
void DisplayToolMsg (const wxString &msg) override
 
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 ActivateGalCanvas ()
 Use to start up the GAL drawing canvas. 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)
 
EDA_UNITS GetUserUnits () const
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS aUnits)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
SETTINGS_MANAGERGetSettingsManager () const
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &aKeyEvent)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuEvent (wxMenuEvent &event)
 The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
virtual void RegisterUIUpdateHandler (int aID, const ACTION_CONDITIONS &aConditions) override
 Register a UI update handler for the control with ID aID. More...
 
virtual void RegisterUIUpdateHandler (const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
 Register an action's update conditions with the UI layer to allow the UI to appropriately display the state of its controls. More...
 
virtual void UnregisterUIUpdateHandler (int aID) override
 Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler. More...
 
virtual void UnregisterUIUpdateHandler (const TOOL_ACTION &aAction)
 Unregister a UI handler for an action that was registered using RegisterUIUpdateHandler. More...
 
void OnMaximize (wxMaximizeEvent &aEvent)
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
FRAME_T GetFrameType () const
 
virtual const SEARCH_STACKsys_search ()
 Return a SEARCH_STACK pertaining to entire program. More...
 
virtual wxString help_name ()
 
void OnKicadAbout (wxCommandEvent &event)
 
void OnPreferences (wxCommandEvent &event)
 Displays the preferences and settings of all opened editors paged dialog. More...
 
void PrintMsg (const wxString &text)
 
void CreateInfoBar ()
 
void FinishAUIInitialization ()
 
WX_INFOBARGetInfoBar ()
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left of the infobar, and an optional closebox to the right. More...
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton, std::function< void(void)> aCallback)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left of the infobar, and an optional closebox to the right. More...
 
void ShowInfoBarWarning (const wxString &aWarningMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left of the infobar. More...
 
void ShowInfoBarMsg (const wxString &aMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of the infobar. More...
 
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 std::string &actionName)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const std::string &actionName)
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
bool GetDoImmediateActions () const
 Indicate that hotkeys should perform an immediate action even if another tool is currently active. More...
 
MOUSE_DRAG_ACTION GetDragAction () const
 Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects. More...
 
bool GetMoveWarpsCursor () const
 Indicate that a move operation should warp the mouse pointer to the origin of the move object. More...
 
HOLDER_TYPE GetType () const
 
KIWAYKiway () const
 Return a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Return a reference to the PROJECT associated with this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 It is only used for debugging, since "this" is not a wxWindow*. More...
 

Static Public Member Functions

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

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)
 
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...
 
virtual void handleActivateEvent (wxActivateEvent &aEvent)
 Handle a window activation event. More...
 
void onActivate (wxActivateEvent &aEvent)
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 An event handler called on a language menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 
void onSystemColorChange (wxSysColourChangedEvent &aEvent)
 
void initExitKey ()
 Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id. More...
 
void ensureWindowIsOnScreen ()
 

Static Protected Member Functions

static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

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

Static Protected Attributes

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

Private Member Functions

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
 

Private Attributes

SCHEMATICm_schematic
 The currently loaded schematic. More...
 
const SCH_CONNECTIONm_highlightedConn
 The highlighted net or bus, or nullptr. More...
 
wxPageSetupDialogData m_pageSetupData
 
SCH_ITEMm_item_to_repeat
 Last item to insert by the repeat command. 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
 

Friends

class SCH_EDITOR_CONTROL
 

Detailed Description

Schematic editor (Eeschema) main window.

Definition at line 130 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 109 of file eda_base_frame.h.

Constructor & Destructor Documentation

◆ SCH_EDIT_FRAME()

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

Definition at line 213 of file sch_edit_frame.cpp.

213  :
214  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
216  m_highlightedConn( nullptr ),
217  m_item_to_repeat( nullptr )
218 {
219  m_maximizeByDefault = true;
220  m_schematic = new SCHEMATIC( nullptr );
221 
222  m_showBorderAndTitleBlock = true; // true to show sheet references
223  m_hasAutoSave = true;
224  m_aboutTitle = _( "KiCad Schematic Editor" );
225 
226  m_findReplaceDialog = nullptr;
227 
228  // Give an icon
229  wxIcon icon;
230  wxIconBundle icon_bundle;
231 
232  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema ) );
233  icon_bundle.AddIcon( icon );
234  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
235  icon_bundle.AddIcon( icon );
236  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
237  icon_bundle.AddIcon( icon );
238 
239  SetIcons( icon_bundle );
240 
241  LoadSettings( eeconfig() );
242 
243  // NB: also links the schematic to the loaded project
244  CreateScreens();
245 
246  setupTools();
248  ReCreateMenuBar();
252 
253  // Initialize common print setup dialog settings.
254  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
255  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
256  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
257  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
258 
259  m_auimgr.SetManagedWindow( this );
260 
261  CreateInfoBar();
262  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
263  .Top().Layer( 6 ) );
264  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
265  .Left().Layer( 3 ) );
266  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
267  .Right().Layer( 2 ) );
268  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
269  .Center() );
270  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
271  .Bottom().Layer( 6 ) );
272 
274 
277 
279 
280  initScreenZoom();
281 
282  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
283  // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
284  Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
285 
286  if( GetCanvas() )
287  {
288  GetCanvas()->GetGAL()->SetAxesEnabled( false );
289 
290  if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
291  p->SetSchematic( m_schematic );
292  }
293 
294  setupUnits( eeconfig() );
295 
296  // Net list generator
298 
299  UpdateTitle();
300 
301  // Default shutdown reason until a file is loaded
302  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
303 
304  // Ensure the window is on top
305  Raise();
306 }
void onSize(wxSizeEvent &aEvent)
SCHEMATIC * m_schematic
The currently loaded schematic.
void DefaultExecFlags()
Reset the execution flags to defaults for external netlist and bom generators.
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
Holds all the data relating to one schematic.
Definition: schematic.h:59
ACTION_TOOLBAR * m_optionsToolBar
void ReCreateMenuBar() override
Recreates the menu bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void UpdateTitle()
Set the main window title bar text.
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
EESCHEMA_SETTINGS * eeconfig() const
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 ReCreateHToolbar() override
#define SCH_EDIT_FRAME_NAME
wxPageSetupDialogData m_pageSetupData
void FinishAUIInitialization()
EDA_MSG_PANEL * m_messagePanel
bool m_showBorderAndTitleBlock
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
DIALOG_SCH_FIND * m_findReplaceDialog
#define KICAD_DEFAULT_DRAWFRAME_STYLE
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void ReCreateOptToolbar() override
bool LoadProjectSettings()
Load the KiCad project file (*.pro) settings specific to Eeschema.
const SCH_CONNECTION * m_highlightedConn
The highlighted net or bus, or nullptr.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void setupUnits(APP_SETTINGS_BASE *aCfg)
wxString m_aboutTitle
void ReCreateVToolbar() override
ACTION_TOOLBAR * m_drawToolBar

References _, PCAD2KICAD::Center, KIGFX::eeconfig(), icon_eeschema, icon_eeschema_16, icon_eeschema_32, KiBitmap(), PCAD2KICAD::Left, onSize(), PCAD2KICAD::Right, and KIPLATFORM::APP::SetShutdownBlockReason().

◆ ~SCH_EDIT_FRAME()

SCH_EDIT_FRAME::~SCH_EDIT_FRAME ( )
override

Definition at line 309 of file sch_edit_frame.cpp.

310 {
311  // Ensure m_canvasType is up to date, to save it in config
313 
314  // Close modeless dialogs
315  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
316 
317  if( open_dlg )
318  open_dlg->Close( true );
319 
320  // Shutdown all running tools
321  if( m_toolManager )
322  {
324  delete m_toolManager;
325  m_toolManager = nullptr;
326  }
327 
328  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
329 
330  SetScreen( nullptr );
331 
332  delete m_schematic;
333  m_schematic = nullptr;
334 
335  // Close the project if we are standalone, so it gets cleaned up properly
336  if( Kiface().IsSingle() )
337  {
338  try
339  {
340  GetSettingsManager()->UnloadProject( &Prj(), false );
341  }
342  catch( const nlohmann::detail::type_error& exc )
343  {
344  // This may be overkill and could be an assertion but we are more likely to
345  // find any settings manager errors this way.
346  wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
347  }
348  }
349 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
SCHEMATIC * m_schematic
The currently loaded schematic.
SETTINGS_MANAGER * GetSettingsManager() const
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetScreen(BASE_SCREEN *aScreen) override
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
#define DIALOG_ERC_WINDOW_NAME
Definition: dialog_erc.h:37
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.

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_item_to_repeat, m_schematic, TOOLS_HOLDER::m_toolManager, KIWAY_HOLDER::Prj(), SetScreen(), TOOL_MANAGER::ShutdownAllTools(), and SETTINGS_MANAGER::UnloadProject().

Member Function Documentation

◆ ActivateGalCanvas()

void EDA_DRAW_FRAME::ActivateGalCanvas ( )
virtualinherited

Use to start up the GAL drawing canvas.

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

Definition at line 726 of file eda_draw_frame.cpp.

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

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

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

◆ 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 1183 of file sch_edit_frame.cpp.

1185 {
1186  wxCHECK_RET( aItem != nullptr, wxT( "Cannot add null item to list." ) );
1187 
1188  SCH_SHEET* parentSheet = nullptr;
1189  SCH_SYMBOL* parentSymbol = nullptr;
1190  SCH_ITEM* undoItem = aItem;
1191 
1192  if( aItem->Type() == SCH_SHEET_PIN_T )
1193  {
1194  parentSheet = (SCH_SHEET*) aItem->GetParent();
1195 
1196  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1197  wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1198 
1199  undoItem = parentSheet;
1200  }
1201 
1202  else if( aItem->Type() == SCH_FIELD_T )
1203  {
1204  parentSymbol = (SCH_SYMBOL*) aItem->GetParent();
1205 
1206  wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_SYMBOL_T,
1207  wxT( "Cannot place field in invalid schematic symbol." ) );
1208 
1209  undoItem = parentSymbol;
1210  }
1211 
1212  if( aItem->IsNew() )
1213  {
1214  if( aItem->Type() == SCH_SHEET_PIN_T )
1215  {
1216  // Sheet pins are owned by their parent sheet.
1217  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1218 
1219  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1220  }
1221  else if( aItem->Type() == SCH_FIELD_T )
1222  {
1223  // Symbol fields are also owned by their parent, but new symbol fields are
1224  // handled elsewhere.
1225  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1226  }
1227  else
1228  {
1229  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1230  AddToScreen( aItem, aScreen );
1231 
1232  SaveCopyForRepeatItem( aItem );
1233  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1234  }
1235 
1236  // Update connectivity info for new item
1237  if( !aItem->IsMoving() )
1238  {
1240 
1241  if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
1242  inheritNetclass( GetCurrentSheet(), textItem );
1243  }
1244  }
1245 
1246  aItem->ClearFlags( IS_NEW );
1247 
1248  aScreen->SetContentModified();
1249  UpdateItem( aItem );
1250 
1251  if( !aItem->IsMoving() && aItem->IsConnectable() )
1252  {
1253  std::vector< wxPoint > pts = aItem->GetConnectionPoints();
1254 
1255  for( auto i = pts.begin(); i != pts.end(); i++ )
1256  {
1257  for( auto j = i + 1; j != pts.end(); j++ )
1258  TrimWire( *i, *j );
1259 
1260  if( aScreen->IsExplicitJunctionNeeded( *i ) )
1261  AddJunction( aScreen, *i, true, false );
1262  }
1263 
1264  TestDanglingEnds();
1265 
1266  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1267  UpdateItem( item );
1268  }
1269 
1270  aItem->ClearEditFlags();
1271  GetCanvas()->Refresh();
1272 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
#define IS_NEW
New item, just created.
bool IsMoving() const
Definition: eda_item.h:119
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:315
bool IsNew() const
Definition: eda_item.h:118
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
static void inheritNetclass(const SCH_SHEET_PATH &aSheetPath, SCH_TEXT *aItem)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
bool IsExplicitJunctionNeeded(const wxPoint &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
Definition: sch_screen.cpp:423
Schematic symbol object.
Definition: sch_symbol.h:78
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,...
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:177
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
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...
SCH_SHEET_PATH & GetCurrentSheet() const
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void ClearEditFlags()
Definition: eda_item.h:171
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:336

References AddJunction(), SCH_SHEET::AddPin(), SCH_BASE_FRAME::AddToScreen(), CHANGED, SCH_SCREEN::CheckIfOnDrawList(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearFlags(), SCH_ITEM::ConnectedItems(), SCH_BASE_FRAME::GetCanvas(), SCH_ITEM::GetConnectionPoints(), GetCurrentSheet(), EDA_ITEM::GetParent(), inheritNetclass(), 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 SCH_BASE_FRAME::UpdateItem().

Referenced by 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 wxPoint &  aPos,
bool  aAppendToUndo,
bool  aFinal = true 
)

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

457 {
458  SCH_JUNCTION* junction = new SCH_JUNCTION( aPos );
459 
460  AddToScreen( junction, aScreen );
461  SaveCopyInUndoList( aScreen, junction, UNDO_REDO::NEWITEM, aUndoAppend );
462  BreakSegments( aPos );
463 
464  if( aFinal )
465  {
467 
469  OnModify();
470 
471  KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
472  view->ClearPreview();
473  view->ShowPreview( false );
474  view->ClearHiddenFlags();
475  }
476 
477  return junction;
478 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:171
bool BreakSegments(const wxPoint &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...
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
void ShowPreview(bool aShow=true)
Definition: view.cpp:1628
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearPreview()
Definition: view.cpp:1592
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
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,...
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
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_EDIT_TOOL::BreakWire(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), and SCH_MOVE_TOOL::Main().

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 460 of file eda_base_frame.cpp.

461 {
462  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
463  ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
464 
465  helpMenu->Add( ACTIONS::help );
466  helpMenu->Add( ACTIONS::gettingStarted );
467  helpMenu->Add( ACTIONS::listHotKeys );
468  helpMenu->Add( ACTIONS::getInvolved );
469  helpMenu->Add( ACTIONS::donate );
470  helpMenu->Add( ACTIONS::reportBug );
471 
472  helpMenu->AppendSeparator();
473  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
474 
475  // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
476  aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
477 }
static TOOL_ACTION listHotKeys
Definition: actions.h:179
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
static TOOL_ACTION reportBug
Cursor control event types.
Definition: actions.h:182
static TOOL_ACTION donate
Definition: actions.h:180
#define _(s)
Handle actions that are shared between different applications.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION help
Definition: actions.h:178
static TOOL_ACTION getInvolved
Definition: actions.h:181
static TOOL_ACTION gettingStarted
Definition: actions.h:177

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

Referenced by EDA_3D_VIEWER_FRAME::CreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), 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 511 of file eda_draw_frame.cpp.

512 {
513  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
514  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
515 
516  aMenu.AddSeparator( 1000 );
517 
518  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
519  zoomMenu->SetTool( commonTools );
520  aToolMenu.AddSubMenu( zoomMenu );
521 
522  auto gridMenu = std::make_shared<GRID_MENU>( this );
523  gridMenu->SetTool( commonTools );
524  aToolMenu.AddSubMenu( gridMenu );
525 
526  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
527  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
528 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
Handles action that are shared between different applications.
Definition: common_tools.h:37
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158

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

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

◆ AddToScreen()

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

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

Definition at line 371 of file sch_base_frame.cpp.

372 {
373  auto screen = aScreen;
374 
375  if( aScreen == nullptr )
376  screen = GetScreen();
377 
378  screen->Append( (SCH_ITEM*) aItem );
379 
380  if( screen == GetScreen() )
381  {
382  GetCanvas()->GetView()->Add( aItem );
383  UpdateItem( aItem, true ); // handle any additional parent semantics
384  }
385 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:320
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

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(), DeleteJunction(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_MOVE_TOOL::getConnectedDragItems(), PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), and SchematicCleanUp().

◆ 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 550 of file sheet.cpp.

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

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,
int  aStartNumber,
bool  aResetAnnotation,
bool  aRepairTimestamps,
REPORTER aReporter 
)

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

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 131 of file annotate.cpp.

138 {
140  EE_SELECTION& selection = selTool->RequestSelection();
141 
142  SCH_REFERENCE_LIST references;
143  SCH_SCREENS screens( Schematic().Root() );
144  SCH_SHEET_LIST sheets = Schematic().GetSheets();
145  SCH_SHEET_PATH currentSheet = GetCurrentSheet();
146  bool appendUndo = false;
147 
148  // Map of locked symbols
149  SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
150 
151  // Map of previous annotation for building info messages
152  std::map<wxString, wxString> previousAnnotation;
153 
154  // Test for and replace duplicate time stamps in symbols and sheets. Duplicate
155  // time stamps can happen with old schematics, schematic conversions, or manual
156  // editing of files.
157  if( aRepairTimestamps )
158  {
159  int count = screens.ReplaceDuplicateTimeStamps();
160 
161  if( count )
162  {
163  wxString msg;
164  msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
165  aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
166  }
167  }
168 
169  // Collect all the sets that must be annotated together.
170  switch( aAnnotateScope )
171  {
172  case ANNOTATE_ALL:
173  sheets.GetMultiUnitSymbols( lockedSymbols );
174  break;
175 
177  currentSheet.GetMultiUnitSymbols( lockedSymbols );
178  break;
179 
180  case ANNOTATE_SELECTION:
181  selection.GetMultiUnitSymbols( lockedSymbols, currentSheet );
182  break;
183  }
184 
185  // Store previous annotations for building info messages
186  mapExistingAnnotation( previousAnnotation );
187 
188  // If it is an annotation for all the symbols, reset previous annotation.
189  if( aResetAnnotation )
190  DeleteAnnotation( aAnnotateScope, &appendUndo );
191 
192  // Set sheet number and number of sheets.
194 
195  // Build symbol list
196  switch( aAnnotateScope )
197  {
198  case ANNOTATE_ALL:
199  sheets.GetSymbols( references );
200  break;
201 
203  GetCurrentSheet().GetSymbols( references );
204  break;
205 
206  case ANNOTATE_SELECTION:
207  selection.GetSymbols( references, currentSheet );
208  break;
209  }
210 
211  // Build additional list of references to be used during reannotation
212  // to avoid duplicate designators (no additional references when annotating
213  // the full schematic)
214  SCH_REFERENCE_LIST additionalRefs;
215 
216  if( aAnnotateScope != ANNOTATE_ALL )
217  {
218  SCH_REFERENCE_LIST allRefs;
219  sheets.GetSymbols( allRefs );
220 
221  for( size_t i = 0; i < allRefs.GetCount(); i++ )
222  {
223  if( !references.Contains( allRefs[i] ) )
224  additionalRefs.AddItem( allRefs[i] );
225  }
226  }
227 
228  // Break full symbol reference into name (prefix) and number:
229  // example: IC1 become IC, and 1
230  references.SplitReferences();
231 
232  switch( aSortOption )
233  {
234  default:
235  case SORT_BY_X_POSITION: references.SortByXCoordinate(); break;
236  case SORT_BY_Y_POSITION: references.SortByYCoordinate(); break;
237  }
238 
239  bool useSheetNum = false;
240  int idStep = 100;
241 
242  switch( aAlgoOption )
243  {
244  default:
245  case INCREMENTAL_BY_REF:
246  break;
247 
248  case SHEET_NUMBER_X_100:
249  useSheetNum = true;
250  break;
251 
252  case SHEET_NUMBER_X_1000:
253  useSheetNum = true;
254  idStep = 1000;
255  break;
256  }
257 
258  // Recalculate and update reference numbers in schematic
259  references.Annotate( useSheetNum, idStep, aStartNumber, lockedSymbols, additionalRefs );
260 
261  for( size_t i = 0; i < references.GetCount(); i++ )
262  {
263  SCH_REFERENCE& ref = references[i];
264  SCH_SYMBOL* symbol = ref.GetSymbol();
265  SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
266 
267  SaveCopyInUndoList( sheet->LastScreen(), symbol, UNDO_REDO::CHANGED, appendUndo );
268  appendUndo = true;
269  ref.Annotate();
270 
271  KIID_PATH full_uuid = sheet->Path();
272  full_uuid.push_back( symbol->m_Uuid );
273 
274  wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
275  wxString newRef = symbol->GetRef( sheet );
276 
277  if( symbol->GetUnitCount() > 1 )
278  newRef << LIB_SYMBOL::SubReference( symbol->GetUnitSelection( sheet ) );
279 
280  wxString msg;
281 
282  if( prevRef.Length() )
283  {
284  if( newRef == prevRef )
285  continue;
286 
287  if( symbol->GetUnitCount() > 1 )
288  {
289  msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
290  symbol->GetValue( sheet, true ),
291  LIB_SYMBOL::SubReference( symbol->GetUnit(), false ),
292  prevRef,
293  newRef );
294  }
295  else
296  {
297  msg.Printf( _( "Updated %s from %s to %s." ),
298  symbol->GetValue( sheet, true ),
299  prevRef,
300  newRef );
301  }
302  }
303  else
304  {
305  if( symbol->GetUnitCount() > 1 )
306  {
307  msg.Printf( _( "Annotated %s (unit %s) as %s." ),
308  symbol->GetValue( sheet, true ),
309  LIB_SYMBOL::SubReference( symbol->GetUnit(), false ),
310  newRef );
311  }
312  else
313  {
314  msg.Printf( _( "Annotated %s as %s." ),
315  symbol->GetValue( sheet, true ),
316  newRef );
317  }
318  }
319 
320  aReporter.Report( msg, RPT_SEVERITY_ACTION );
321  }
322 
323  // Final control (just in case ... ).
324  if( !CheckAnnotate(
325  [ &aReporter ]( ERCE_T , const wxString& aMsg, SCH_REFERENCE* , SCH_REFERENCE* )
326  {
327  aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
328  },
329  aAnnotateScope ) )
330  {
331  aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
332  }
333 
334  // Update on screen references, that can be modified by previous calculations:
337 
338  wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
339 
340  if( erc_dlg )
341  static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
342 
343  SyncView();
344  GetCanvas()->Refresh();
345  OnModify();
346 
347  // Must go after OnModify() so the connectivity graph has been updated
349 }
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 sh...
void SortByYCoordinate()
Sort the list of references by Y position.
void UpdateNetHighlightStatus()
Annotate the selection.
void mapExistingAnnotation(std::map< wxString, wxString > &aMap)
Fill a map of uuid -> reference from the currently loaded schematic.
Definition: annotate.cpp:38
Annotate the full schematic.
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.
const SCH_SHEET_PATH & GetSheetPath() const
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:372
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
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
void DeleteAnnotation(ANNOTATE_SCOPE_T aAnnotateScope, bool *appendUndo)
Clear the current symbol annotation.
Definition: annotate.cpp:63
void AddItem(const SCH_REFERENCE &aItem)
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:480
SCH_SYMBOL * GetSymbol() const
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:443
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
int CheckAnnotate(ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL)
Check for annotation errors.
Definition: annotate.cpp:352
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
#define DIALOG_ERC_WINDOW_NAME
Definition: dialog_erc.h:37
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
void SortByXCoordinate()
Sort the list of references by X position.
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:533
void Annotate()
Update the annotation of the symbol according the current object state.
Annotate using the first free reference number starting at the sheet number * 100.
SCHEMATIC & Schematic() const
size_t GetCount() const
#define _(s)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
ERCE_T
ERC error codes.
Definition: erc_settings.h:36
bool Contains(const SCH_REFERENCE &aItem)
Return true if aItem exists in this list.
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:575
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
const KIID m_Uuid
Definition: eda_item.h:474
Annotate by Y position from top to bottom.
Annotate incrementally using the first free reference number.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent=false)
Set the reference designators in the list that have not been annotated.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_SCREEN * LastScreen()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
wxString AsString() const
Definition: kiid.cpp:310
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.
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...
Annotate by X position from left to right.
Annotate using the first free reference number starting at the sheet number * 1000.
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Annotate the current sheet.
int GetUnit() const
Definition: sch_symbol.h:195
A helper to define a symbol's reference designator in a schematic.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

References _, SCH_REFERENCE_LIST::AddItem(), SCH_REFERENCE::Annotate(), SCH_REFERENCE_LIST::Annotate(), ANNOTATE_ALL, ANNOTATE_CURRENT_SHEET, ANNOTATE_SELECTION, KIID_PATH::AsString(), CHANGED, CheckAnnotate(), SCH_REFERENCE_LIST::Contains(), DeleteAnnotation(), DIALOG_ERC_WINDOW_NAME, SCH_BASE_FRAME::GetCanvas(), SCH_REFERENCE_LIST::GetCount(), GetCurrentSheet(), SCH_SHEET_PATH::GetMultiUnitSymbols(), SCH_SHEET_LIST::GetMultiUnitSymbols(), SCH_SYMBOL::GetRef(), SCH_REFERENCE::GetSheetPath(), SCHEMATIC::GetSheets(), SCH_REFERENCE::GetSymbol(), SCH_SHEET_PATH::GetSymbols(), SCH_SHEET_LIST::GetSymbols(), TOOL_MANAGER::GetTool(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), SCH_SYMBOL::GetUnitSelection(), SCH_SYMBOL::GetValue(), INCREMENTAL_BY_REF, SCH_SHEET_PATH::LastScreen(), TOOLS_HOLDER::m_toolManager, EDA_ITEM::m_Uuid, mapExistingAnnotation(), OnModify(), SCH_SHEET_PATH::Path(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), REPORTER::Report(), REPORTER::ReportTail(), EE_SELECTION_TOOL::RequestSelection(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, SaveCopyInUndoList(), Schematic(), SetSheetNumberAndCount(), SHEET_NUMBER_X_100, SHEET_NUMBER_X_1000, SORT_BY_X_POSITION, SORT_BY_Y_POSITION, SCH_REFERENCE_LIST::SortByXCoordinate(), SCH_REFERENCE_LIST::SortByYCoordinate(), SCH_REFERENCE_LIST::SplitReferences(), LIB_SYMBOL::SubReference(), SCH_BASE_FRAME::SyncView(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and UpdateNetHighlightStatus().

Referenced by DIALOG_ANNOTATE::OnApplyClick().

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

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

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

Referenced by GERBER_FILE_IMAGE::DisplayImageInfo(), SYMBOL_VIEWER_FRAME::updatePreviewSymbol(), and 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 538 of file eeschema/files-io.cpp.

539 {
540  wxString fullFileName;
541  SCH_SCREEN* screen = GetScreen();
542 
543  if( !screen )
544  {
545  wxLogError( wxT( "Document not ready, cannot import" ) );
546  return false;
547  }
548 
549  // open file chooser dialog
550  wxString path = wxPathOnly( Prj().GetProjectFullName() );
551 
552  wxFileDialog dlg( this, _( "Insert Schematic" ), path, wxEmptyString,
553  KiCadSchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
554 
555  if( dlg.ShowModal() == wxID_CANCEL )
556  return false;
557 
558  fullFileName = dlg.GetPath();
559 
560  if( !LoadSheetFromFile( GetCurrentSheet().Last(), &GetCurrentSheet(), fullFileName ) )
561  return false;
562 
563  initScreenZoom();
565 
566  SyncView();
567  OnModify();
568  HardRedraw(); // Full reinit of the current screen and the display.
569 
571 
572  return true;
573 }
wxString KiCadSchematicFileWildcard()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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 SyncView()
Mark all items for refresh.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
#define _(s)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...

References _, GetCurrentSheet(), GetScreen(), HardRedraw(), initScreenZoom(), KiCadSchematicFileWildcard(), LoadSheetFromFile(), OnModify(), path, KIWAY_HOLDER::Prj(), SetSheetNumberAndCount(), SCH_BASE_FRAME::SyncView(), and UpdateHierarchyNavigator().

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 1273 of file eeschema/files-io.cpp.

1274 {
1275  SCH_SCREENS screenList( Schematic().Root() );
1276 
1277  // Save any currently open and modified project files.
1278  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1279  {
1280  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
1281 
1282  // Simulator must be closed before loading another schematic, otherwise it may crash.
1283  // If there are any changes in the simulator the user will be prompted to save them.
1284  if( simFrame && !simFrame->Close() )
1285  return false;
1286 
1287  if( screen->IsContentModified() )
1288  {
1289  if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
1290  "Save changes?" ),
1291  [&]() -> bool
1292  {
1293  return SaveProject();
1294  } ) )
1295  {
1296  return false;
1297  }
1298  }
1299  }
1300 
1301  return true;
1302 }
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:239
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:383
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
SCHEMATIC & Schematic() const
#define _(s)
Implementing SIM_PLOT_FRAME_BASE.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

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

Referenced by OnImportProject(), and OpenProjectFiles().

◆ BreakSegment()

bool SCH_EDIT_FRAME::BreakSegment ( SCH_LINE aSegment,
const wxPoint &  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 295 of file bus-wire-junction.cpp.

297 {
298  if( aScreen == nullptr )
299  aScreen = GetScreen();
300 
301  SCH_LINE* newSegment = static_cast<SCH_LINE*>( aSegment->Duplicate() );
302 
303  newSegment->SetStartPoint( aPoint );
304  newSegment->SetConnectivityDirty( true );
305  AddToScreen( newSegment, aScreen );
306 
307  SaveCopyInUndoList( aScreen, newSegment, UNDO_REDO::NEWITEM, true );
308  SaveCopyInUndoList( aScreen, aSegment, UNDO_REDO::CHANGED, true );
309 
310  UpdateItem( aSegment, false, true );
311  aSegment->SetEndPoint( aPoint );
312 
313  if( aNewSegment )
314  *aNewSegment = newSegment;
315 
316  return true;
317 }
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:85
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
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,...
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415

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

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

◆ BreakSegments()

bool SCH_EDIT_FRAME::BreakSegments ( const wxPoint &  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 320 of file bus-wire-junction.cpp.

321 {
322  static const KICAD_T wiresAndBuses[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
323 
324  if( aScreen == nullptr )
325  aScreen = GetScreen();
326 
327  bool brokenSegments = false;
328  std::vector<SCH_LINE*> wires;
329 
330  for( SCH_ITEM* item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
331  {
332  if( item->IsType( wiresAndBuses ) )
333  {
334  SCH_LINE* wire = static_cast<SCH_LINE*>( item );
335 
336  if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), aPoint )
337  && !wire->IsEndPoint( aPoint ) )
338  {
339  wires.push_back( wire );
340  }
341  }
342  }
343 
344  for( SCH_LINE* wire : wires )
345  brokenSegments |= BreakSegment( wire, aPoint, nullptr, aScreen );
346 
347  return brokenSegments;
348 }
wxPoint GetStartPoint() const
Definition: sch_line.h:90
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:80
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Definition: sch_rtree.h:235
bool BreakSegment(SCH_LINE *aSegment, const wxPoint &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
Break a single segment into two at the specified point.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References BreakSegment(), EOT, SCH_LINE::GetEndPoint(), GetScreen(), SCH_LINE::GetStartPoint(), SCH_LINE::IsEndPoint(), IsPointOnSegment(), SCH_SCREEN::Items(), EE_RTREE::Overlapping(), SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, 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 351 of file bus-wire-junction.cpp.

352 {
353  if( aScreen == nullptr )
354  aScreen = GetScreen();
355 
356  bool brokenSegments = false;
357 
358  std::set<wxPoint> point_set;
359 
360  for( SCH_ITEM* item : aScreen->Items().OfType( SCH_JUNCTION_T ) )
361  point_set.insert( item->GetPosition() );
362 
363  for( SCH_ITEM* item : aScreen->Items().OfType( SCH_BUS_WIRE_ENTRY_T ) )
364  {
365  SCH_BUS_WIRE_ENTRY* entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
366  point_set.insert( entry->GetPosition() );
367  point_set.insert( entry->GetEnd() );
368  }
369 
370 
371  for( const wxPoint& pt : point_set )
372  brokenSegments |= BreakSegments( pt, aScreen );
373 
374  return brokenSegments;
375 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
bool BreakSegments(const wxPoint &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...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Class for a wire to bus entry.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
wxPoint GetEnd() const
wxPoint GetPosition() const override

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 626 of file sch_edit_frame.cpp.

627 {
628  // Exit interactive editing
629  // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
630  // will cancel any drag currently in progress, but commit all changes from previous drags.
631  if( m_toolManager )
633 
634  // Shutdown blocks must be determined and vetoed as early as possible
635  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
636  && Schematic().GetSheets().IsModified() )
637  {
638  return false;
639  }
640 
641  if( Kiface().IsSingle() )
642  {
643  auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
644 
645  if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
646  return false;
647 
648  auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
649 
650  if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
651  return false;
652 
653  symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
654 
655  if( symbolViewer && !symbolViewer->Close() ) // Can close modal symbol viewer?
656  return false;
657  }
658  else
659  {
660  auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
661 
662  if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
663  {
664  if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
665  return false;
666  }
667  }
668 
669  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
670 
671  if( simFrame && !simFrame->Close() ) // Can close the simulator?
672  return false;
673 
674  // We may have gotten multiple events; don't clean up twice
675  if( !Schematic().IsValid() )
676  return false;
677 
678  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
679 
680  if( sheetlist.IsModified() )
681  {
682  wxFileName fileName = Schematic().RootScreen()->GetFileName();
683  wxString msg = _( "Save changes to '%s' before closing?" );
684 
685  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
686  [&]() -> bool
687  {
688  return SaveProject();
689  } ) )
690  {
691  return false;
692  }
693  }
694 
695  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
696  // board.
697  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
698 
699  if( open_dlg )
700  open_dlg->Close( true );
701 
702  return true;
703 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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:239
const wxString & GetFileName() const
Definition: sch_screen.h:145
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool IsModified() const
Check the entire hierarchy for any modifications.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:108
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
Symbol library viewer main window.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:383
#define DIALOG_ERC_WINDOW_NAME
Definition: dialog_erc.h:37
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
SCHEMATIC & Schematic() const
#define _(s)
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
Implementing SIM_PLOT_FRAME_BASE.
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
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:104
The symbol library editor main window.

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(), KIFACE_BASE::IsSingle(), SCHEMATIC::IsValid(), Kiface(), KIWAY_HOLDER::Kiway(), TOOLS_HOLDER::m_toolManager, KIWAY::Player(), SCHEMATIC::RootScreen(), TOOL_MANAGER::RunAction(), SaveProject(), Schematic(), and KIPLATFORM::APP::SupportsShutdownBlockReason().

◆ CenterScreen()

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

Definition at line 254 of file sch_base_frame.cpp.

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

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

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1203 of file eda_base_frame.cpp.

1204 {
1205  SetUserUnits( aUnits );
1207 
1208  wxCommandEvent e( UNITS_CHANGED );
1209  ProcessEventLocally( e );
1210 }
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void SetUserUnits(EDA_UNITS aUnits)

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

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

◆ CheckAnnotate()

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

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 352 of file annotate.cpp.

354 {
355  SCH_REFERENCE_LIST referenceList;
356  constexpr bool includePowerSymbols = false;
357 
358  // Build the list of symbols
359  switch( aAnnotateScope )
360  {
361  case ANNOTATE_ALL:
362  Schematic().GetSheets().GetSymbols( referenceList );
363  break;
364 
366  GetCurrentSheet().GetSymbols( referenceList, includePowerSymbols );
367  break;
368 
369  case ANNOTATE_SELECTION:
371  EE_SELECTION& selection = selTool->RequestSelection();
372  selection.GetSymbols( referenceList, GetCurrentSheet(), includePowerSymbols );
373  break;
374  }
375 
376  // Empty schematic does not need annotation
377  if( referenceList.GetCount() == 0 )
378  return 0;
379 
380  return referenceList.CheckAnnotation( aErrorHandler );
381 }
Annotate the selection.
Annotate the full schematic.
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.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
SCHEMATIC & Schematic() const
size_t GetCount() const
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
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.
SCH_SHEET_PATH & GetCurrentSheet() const
Annotate the current sheet.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSelectionPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false)
Adds SCH_REFERENCE object to aReferences for each symbol in the selection.

References ANNOTATE_ALL, ANNOTATE_CURRENT_SHEET, ANNOTATE_SELECTION, SCH_REFERENCE_LIST::CheckAnnotation(), SCH_REFERENCE_LIST::GetCount(), GetCurrentSheet(), SCHEMATIC::GetSheets(), EE_SELECTION::GetSymbols(), SCH_SHEET_PATH::GetSymbols(), SCH_SHEET_LIST::GetSymbols(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::m_toolManager, EE_SELECTION_TOOL::RequestSelection(), 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 1364 of file eeschema/files-io.cpp.

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

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 }
const wxString & GetFileName() const
Definition: sch_screen.h:145
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:105
#define _(s)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

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 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
const wxString & GetFileName() const
Definition: sch_screen.h:145
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...
SCHEMATIC & Schematic() const
#define _(s)
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
SCH_SCREEN * LastScreen()

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 778 of file sch_edit_frame.h.

778 { 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 976 of file eda_base_frame.cpp.

977 {
978  if( !aFileHistory )
979  aFileHistory = m_fileHistory;
980 
981  wxASSERT( aFileHistory );
982 
983  aFileHistory->ClearFileHistory();
984 
985  // Update the menubar to update the file history menu
986  if( GetMenuBar() )
987  {
988  ReCreateMenuBar();
989  GetMenuBar()->Refresh();
990  }
991 }
void ClearFileHistory()
Clear all entries from the file history.
FILE_HISTORY * m_fileHistory
virtual void ReCreateMenuBar()
Recreates the menu bar.

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

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

◆ ClearFindReplaceStatus()

void SCH_EDIT_FRAME::ClearFindReplaceStatus ( )

Definition at line 940 of file sch_edit_frame.cpp.

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

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 384 of file schematic_undo_redo.cpp.

385 {
386  if( aItemCount == 0 )
387  return;
388 
389  UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
390 
391  for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
392  {
393  command->ClearListAndDeleteItems();
394  delete command;
395  }
396 
397  list.m_CommandsList.clear();
398 }
UNDO_REDO_CONTAINER m_undoList
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
A holder to handle information on schematic or board items.
UNDO_REDO_CONTAINER m_redoList
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...

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

Referenced by DIALOG_SYMBOL_REMAP::OnRemapSymbols(), and SaveCopyInUndoList().

◆ ClearUndoRedoList()

void EDA_BASE_FRAME::ClearUndoRedoList ( )
virtualinherited

◆ 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 1469 of file sch_edit_frame.cpp.

1470 {
1471  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1472 
1473  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1475 
1477 
1478  RecreateToolbars();
1479  Layout();
1480  SendSizeEvent();
1481 }
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
int GetSchematicJunctionSize()
void ShowAllIntersheetRefs(bool aShow)
SCHEMATIC & Schematic() const
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
These settings were stored in SCH_BASE_FRAME previously.

References SCH_BASE_FRAME::CommonSettingsChanged(), GetSchematicJunctionSize(), SCHEMATIC_SETTINGS::m_IntersheetRefsShow, SCHEMATIC_SETTINGS::m_JunctionSize, EDA_DRAW_FRAME::RecreateToolbars(), Schematic(), SCHEMATIC::Settings(), 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 816 of file eda_base_frame.cpp.

817 {
818  // KICAD_MANAGER_FRAME overrides this
819  return Kiface().KifaceSettings();
820 }
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:92

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(), FOOTPRINT_WIZARD_FRAME::doCloseWindow(), SIM_PLOT_FRAME::doCloseWindow(), SCH_BASE_FRAME::eeconfig(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), GRID_MENU::GRID_MENU(), COMMON_TOOLS::GridFast1(), COMMON_TOOLS::GridFast2(), 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(), PL_EDITOR_FRAME::setupTools(), SYMBOL_VIEWER_FRAME::setupTools(), CVPCB_MAINFRAME::setupTools(), GERBVIEW_FRAME::setupTools(), setupTools(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataToWindow(), ZOOM_MENU::update(), GRID_MENU::update(), EDA_DRAW_FRAME::UpdateGridSelectBox(), EDA_DRAW_FRAME::UpdateZoomSelectBox(), EDA_BASE_FRAME::windowClosing(), ZOOM_MENU::ZOOM_MENU(), 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 358 of file eda_base_frame.h.

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

References EDA_BASE_FRAME::m_configName.

Referenced by EDA_BASE_FRAME::SaveWindowSettings().

◆ ConvertPart()

void SCH_EDIT_FRAME::ConvertPart ( SCH_SYMBOL aSymbol)

Definition at line 242 of file getpart.cpp.

243 {
244  if( !aSymbol || !aSymbol->GetLibSymbolRef() )
245  return;
246 
247  wxString msg;
248 
249  if( !aSymbol->GetLibSymbolRef()->HasConversion() )
250  {
251  LIB_ID id = aSymbol->GetLibSymbolRef()->GetLibId();
252 
253  msg.Printf( _( "No alternate body style found for symbol '%s' in library '%s'." ),
254  id.GetLibItemName().wx_str(),
255  id.GetLibNickname().wx_str() );
256  DisplayError( this, msg );
257  return;
258  }
259 
260  EDA_ITEM_FLAGS savedFlags = aSymbol->GetFlags();
261 
262  aSymbol->SetConvert( aSymbol->GetConvert() + 1 );
263 
264  // ensure m_convert = 1 or 2
265  // 1 = shape 1 = not converted
266  // 2 = shape 2 = first converted shape
267  // > 2 is not currently supported
268  // When m_convert = val max, return to the first shape
269  if( aSymbol->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN )
270  aSymbol->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
271 
273  aSymbol->ClearFlags();
274  aSymbol->SetFlags( savedFlags ); // Restore m_flags (modified by SetConvert())
275 
276  // If selected make sure all the now-included pins are selected
277  if( aSymbol->IsSelected() )
279 
280  UpdateItem( aSymbol, false, true );
281  OnModify();
282 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
bool IsSelected() const
Definition: eda_item.h:122
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
std::uint32_t EDA_ITEM_FLAGS
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:164
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
#define _(s)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
void SetConvert(int aConvert)
Definition: sch_symbol.cpp:349
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
int GetConvert() const
Definition: sch_symbol.h:223

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 SCH_BASE_FRAME::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'." ),
102  symbol->GetLibId().GetUniStringLibItemName(),
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 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
Define a library symbol object.
Definition: lib_symbol.h:96
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:365
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
SCHEMATIC & Schematic() const
#define _(s)
Schematic symbol object.
Definition: sch_symbol.h:78
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
wxString GetUniStringLibId() const
Definition: lib_id.h:134
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition: lib_id.h:114
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147

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
49  fn = Schematic().RootScreen()->GetFileName();
50 
51  fn.SetName( fn.GetName() + "-cache" );
52  fn.SetExt( LegacySymbolLibFileExtension );
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 }
const wxString & GetFileName() const
Definition: sch_screen.h:145
const std::string LegacySymbolLibFileExtension
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCHEMATIC & Schematic() const
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
bool CreateArchiveLibrary(const wxString &aFileName)
Create a library aFileName that contains all symbols used in the current schematic.
Definition: libarch.cpp:65
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

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

◆ createCanvas()

void SCH_BASE_FRAME::createCanvas ( )
inherited

Definition at line 293 of file sch_base_frame.cpp.

294 {
296 
297  SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_frameSize,
300 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.

References EDA_DRAW_FRAME::ActivateGalCanvas(), EDA_DRAW_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 841 of file eda_base_frame.cpp.

842 {
843 #if defined( __WXOSX_MAC__ )
845 #else
846  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
847 
848  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
849 #endif
850 }
wxAuiManager m_auimgr
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
Specialization of the wxAuiPaneInfo class for KiCad panels.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
WX_INFOBAR * m_infoBar

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

◆ CreateScreens()

void SCH_EDIT_FRAME::CreateScreens ( )

Definition at line 569 of file sch_edit_frame.cpp.

570 {
571  m_schematic->Reset();
572  m_schematic->SetProject( &Prj() );
573 
575 
576  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
577  m_schematic->Root().SetScreen( rootScreen );
578  SetScreen( Schematic().RootScreen() );
579 
580  m_schematic->RootScreen()->SetFileName( wxEmptyString );
581 
582  // Don't leave root page number empty
583  SCH_SHEET_PATH rootSheetPath;
584  rootSheetPath.push_back( &m_schematic->Root() );
585  m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
586  m_schematic->Root().AddInstance( rootSheetPath );
587  m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) );
588 
589  if( GetScreen() == nullptr )
590  {
591  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
592  SetScreen( screen );
593  }
594 }
SCHEMATIC * m_schematic
The currently loaded schematic.
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
void SetScreen(BASE_SCREEN *aScreen) override
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:172
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1183
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:104
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCHEMATIC & Schematic() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:76
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
SCH_SHEET & Root() const
Definition: schematic.h:92
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1138

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(), BASE_SCREEN::SetPageNumber(), SCH_SHEET::SetPageNumber(), SCHEMATIC::SetProject(), SCHEMATIC::SetRoot(), SCH_SHEET::SetScreen(), and 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  delete m_socketServer;
55  m_socketServer = new wxSocketServer( addr );
56 
57  m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
58  m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
59  m_socketServer->Notify( true );
60 }
static const wxString HOSTNAME(wxT("localhost"))
wxSocketServer * m_socketServer
Definition: kiway_player.h:218

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

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

◆ CurrentToolName()

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

Definition at line 100 of file tools_holder.cpp.

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

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

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

◆ DefaultExecFlags()

void SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

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

Definition at line 763 of file sch_edit_frame.h.

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

References m_exec_flags.

Referenced by WriteNetListFile().

◆ DeleteAnnotation()

void SCH_EDIT_FRAME::DeleteAnnotation ( ANNOTATE_SCOPE_T  aAnnotateScope,
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 63 of file annotate.cpp.

64 {
65  auto clearSymbolAnnotation =
66  [&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet )
67  {
68  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
69 
70  SaveCopyInUndoList( aScreen, symbol, UNDO_REDO::CHANGED, *aAppendUndo );
71  *aAppendUndo = true;
72  symbol->ClearAnnotation( aSheet );
73  };
74 
75  auto clearSheetAnnotation =
76  [&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet )
77  {
78  for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
79  clearSymbolAnnotation( item, aScreen, aSheet );
80  };
81 
82  SCH_SCREEN* screen = GetScreen();
83  SCH_SHEET_PATH currentSheet = GetCurrentSheet();
84 
85  switch( aAnnotateScope )
86  {
87  case ANNOTATE_ALL:
88  {
89  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
90  clearSheetAnnotation( sheet.LastScreen(), nullptr );
91 
92  break;
93  }
95  {
96  clearSheetAnnotation( screen, &currentSheet );
97  break;
98  }
99 
100  case ANNOTATE_SELECTION:
101  {
103  EE_SELECTION& selection = selTool->RequestSelection();
104 
105  for( EDA_ITEM* item : selection.Items() )
106  {
107  if( item->Type() == SCH_SYMBOL_T )
108  clearSymbolAnnotation( item, screen, &currentSheet );
109  }
110  break;
111  }
112  }
113 
114  // Update the references for the sheet that is currently being displayed.
116 
117  wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
118 
119  if( erc_dlg )
120  static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
121 
122  SyncView();
123  GetCanvas()->Refresh();
124  OnModify();
125 
126  // Must go after OnModify() so the connectivity graph has been updated
128 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
void UpdateNetHighlightStatus()
Annotate the selection.
Annotate the full schematic.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath)
Clear exiting symbol annotation.
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
#define DIALOG_ERC_WINDOW_NAME
Definition: dialog_erc.h:37
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
Schematic symbol object.
Definition: sch_symbol.h:78
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
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...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Annotate the current sheet.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

References ANNOTATE_ALL, ANNOTATE_CURRENT_SHEET, ANNOTATE_SELECTION, CHANGED, SCH_SYMBOL::ClearAnnotation(), DIALOG_ERC_WINDOW_NAME, SCH_BASE_FRAME::GetCanvas(), GetCurrentSheet(), GetScreen(), TOOL_MANAGER::GetTool(), SCH_SCREEN::Items(), TOOLS_HOLDER::m_toolManager, EE_RTREE::OfType(), OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), EE_SELECTION_TOOL::RequestSelection(), SaveCopyInUndoList(), SCH_SYMBOL_T, Schematic(), SCH_BASE_FRAME::SyncView(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and UpdateNetHighlightStatus().

Referenced by AnnotateSymbols(), and 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 378 of file bus-wire-junction.cpp.

379 {
380  SCH_SCREEN* screen = GetScreen();
381  PICKED_ITEMS_LIST undoList;
384 
385  auto remove_item = [ & ]( SCH_ITEM* aItem ) -> void
386  {
387  aItem->SetFlags( STRUCT_DELETED );
388  undoList.PushItem( ITEM_PICKER( screen, aItem, UNDO_REDO::DELETED ) );
389  };
390 
391  remove_item( aJunction );
392  RemoveFromScreen( aJunction, screen );
393 
396  std::list<SCH_LINE*> lines;
397 
398  for( SCH_ITEM* item : screen->Items().Overlapping( SCH_LINE_T, aJunction->GetPosition() ) )
399  {
400  SCH_LINE* line = static_cast<SCH_LINE*>( item );
401 
402  if( line->IsType( wiresAndBuses ) && line->IsEndPoint( aJunction->GetPosition() )
403  && !( line->GetEditFlags() & STRUCT_DELETED ) )
404  lines.push_back( line );
405  }
406 
407  alg::for_all_pairs( lines.begin(), lines.end(),
408  [&]( SCH_LINE* firstLine, SCH_LINE* secondLine )
409  {
410  if( ( firstLine->GetEditFlags() & STRUCT_DELETED )
411  || ( secondLine->GetEditFlags() & STRUCT_DELETED )
412  || !secondLine->IsParallel( firstLine ) )
413  {
414  return;
415  }
416 
417  // Remove identical lines
418  if( firstLine->IsEndPoint( secondLine->GetStartPoint() )
419  && firstLine->IsEndPoint( secondLine->GetEndPoint() ) )
420  {
421  remove_item( firstLine );
422  return;
423  }
424 
425  // Try to merge the remaining lines
426  if( SCH_LINE* line = secondLine->MergeOverlap( screen, firstLine, false ) )
427  {
428  remove_item( firstLine );
429  remove_item( secondLine );
430  undoList.PushItem( ITEM_PICKER( screen, line, UNDO_REDO::NEWITEM ) );
431  AddToScreen( line, screen );
432 
433  if( line->IsSelected() )
434  selectionTool->AddItemToSel( line, true /*quiet mode*/ );
435 
436  lines.push_back( line );
437  }
438  } );
439 
440  SaveCopyInUndoList( undoList, UNDO_REDO::DELETED, aAppend );
441 
442  for( SCH_LINE* line : lines )
443  {
444  if( line->GetEditFlags() & STRUCT_DELETED )
445  {
446  if( line->IsSelected() )
447  selectionTool->RemoveItemFromSel( line, true /*quiet mode*/ );
448 
449  RemoveFromScreen( line, screen );
450  }
451  }
452 }
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:509
bool IsSelected() const
Definition: eda_item.h:122
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
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,...
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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
#define STRUCT_DELETED
flag indication structures to be erased
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:80
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:157
A holder to handle information on schematic or board items.
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Definition: sch_rtree.h:235
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
int AddItemToSel(const TOOL_EVENT &aEvent)
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,...
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
bool IsType(const KICAD_T aScanTypes[]) const override
Check whether the item is one of the listed types.
Definition: sch_line.h:62
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

References EE_SELECTION_TOOL::AddItemToSel(), SCH_BASE_FRAME::AddToScreen(), DELETED, EOT, alg::for_all_pairs(), EDA_ITEM::GetEditFlags(), EDA_ITEM::GetPosition(), GetScreen(), TOOL_MANAGER::GetTool(), SCH_LINE::IsEndPoint(), SCH_LINE::IsType(), SCH_SCREEN::Items(), TOOLS_HOLDER::m_toolManager, SCH_LINE::MergeOverlap(), NEWITEM, EE_RTREE::Overlapping(), PICKED_ITEMS_LIST::PushItem(), SCH_BASE_FRAME::RemoveFromScreen(), EE_SELECTION_TOOL::RemoveItemFromSel(), SaveCopyInUndoList(), SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, 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 166 of file kiway_player.cpp.

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

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

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

◆ DisplayConstraintsMsg()

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

Definition at line 537 of file eda_draw_frame.cpp.

538 {
539  SetStatusText( msg, 7 );
540 }

Referenced by DRAWING_TOOL::updateStatusBar().

◆ DisplayCurrentSheet()

void SCH_EDIT_FRAME::DisplayCurrentSheet ( )

Draw the current sheet on the display.

Definition at line 285 of file hierarch.cpp.

286 {
289  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
290 
291  wxASSERT( screen );
292 
293  SetScreen( screen );
294 
295  // update the References
298 
299  if( !screen->m_zoomInitialized )
300  {
301  initScreenZoom();
302  }
303  else
304  {
305  // Set zoom to last used in this screen
306  GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
307  RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
308  }
309 
310  UpdateTitle();
311 
312  HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
313 
316  editTool->UpdateNetHighlighting( dummy );
317 
319 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
void SetScreen(BASE_SCREEN *aScreen) override
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Handle actions specific to the schematic editor.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:72
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SCH_SCREEN * LastScreen()
bool m_zoomInitialized
Definition: sch_screen.h:543
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
SCH_SHEET_PATH & GetCurrentSheet() const

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(), 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(), UpdateHierarchyNavigator(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and UpdateTitle().

Referenced by SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_NAVIGATE_TOOL::HypertextCommand(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), DIALOG_ERC::OnERCItemSelected(), OnPageSettingsChange(), HIERARCHY_NAVIG_DLG::onSelectSheetPath(), and PutDataInPreviousState().

◆ DisplayGridMsg()

void EDA_DRAW_FRAME::DisplayGridMsg ( )
virtualinherited

Display current grid size in the status bar.

Reimplemented in PCB_BASE_FRAME, GERBVIEW_FRAME, and PL_EDITOR_FRAME.

Definition at line 543 of file eda_draw_frame.cpp.

544 {
545  wxString line;
546 
547  line.Printf( "grid %s",
548  MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x,
549  false ) );
550 
551  SetStatusText( line, 4 );
552 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

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

Referenced by SCH_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from TOOLS_HOLDER.

Definition at line 531 of file eda_draw_frame.cpp.

532 {
533  SetStatusText( msg, 6 );
534 }

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

556 {
557  wxString msg;
558 
559  switch( m_userUnits )
560  {
561  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
562  case EDA_UNITS::MILS: msg = _( "mils" ); break;
563  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
564  default: msg = _( "Units" ); break;
565  }
566 
567  SetStatusText( msg, 5 );
568 }
#define _(s)
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.

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

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

◆ doAutoSave()

bool 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 1103 of file eeschema/files-io.cpp.

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

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 706 of file sch_edit_frame.cpp.

707 {
708  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
709 
710  // Shutdown all running tools
711  if( m_toolManager )
713 
715 
716  // Close the find dialog and preserve its setting if it is displayed.
717  if( m_findReplaceDialog )
718  {
721 
722  m_findReplaceDialog->Destroy();
723  m_findReplaceDialog = nullptr;
724  }
725 
726  if( FindHierarchyNavigator() )
727  FindHierarchyNavigator()->Close( true );
728 
729  if( Kiway().Player( FRAME_SIMULATOR, false ) )
731 
732  SCH_SCREENS screens( Schematic().Root() );
733  wxFileName fn;
734 
735  for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
736  {
737  fn = Prj().AbsolutePath( screen->GetFileName() );
738 
739  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
740  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
741 
742  if( fn.IsFileWritable() )
743  wxRemoveFile( fn.GetFullPath() );
744  }
745 
746  wxFileName tmpFn = Prj().GetProjectFullName();
747  wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
748 
749  if( autoSaveFileName.IsFileWritable() )
750  wxRemoveFile( autoSaveFileName.GetFullPath() );
751 
752  sheetlist.ClearModifyStatus();
753 
754  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
755 
756  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
757  UpdateFileHistory( fileName );
758 
759  Schematic().RootScreen()->Clear();
760 
761  // all sub sheets are deleted, only the main sheet is usable
763 
764  // Clear view before destroying schematic as repaints depend on schematic being valid
765  SetScreen( nullptr );
766 
767  Schematic().Reset();
768 
769  Destroy();
770 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
const wxString & getAutoSaveFileName() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
HIERARCHY_NAVIG_DLG * FindHierarchyNavigator()
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
wxArrayString GetFindEntries() const
void SetScreen(BASE_SCREEN *aScreen) override
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
wxArrayString m_findStringHistoryList
std::shared_ptr< NGSPICE_SIMULATOR_SETTINGS > m_NgspiceSimulatorSettings
Ngspice simulator settings.
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
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:269
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:228
wxArrayString GetReplaceEntries() const
wxArrayString m_replaceStringHistoryList
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCHEMATIC & Schematic() const
DIALOG_SCH_FIND * m_findReplaceDialog
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:116
void clear()
Forwarded method from std::vector.
static wxString GetAutoSaveFilePrefix()
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
SCH_SHEET_PATH & GetCurrentSheet() const
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

References PROJECT::AbsolutePath(), SCH_SHEET_PATH::clear(), SCH_SCREEN::Clear(), SCH_SHEET_LIST::ClearModifyStatus(), KIWAY_PLAYER::Destroy(), FindHierarchyNavigator(), 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(), 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(), Schematic(), SetScreen(), TOOL_MANAGER::ShutdownAllTools(), and EDA_BASE_FRAME::UpdateFileHistory().

◆ 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 474 of file sheet.cpp.

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

References SCH_BASE_FRAME::GetLayerColor(), SCH_BASE_FRAME::GetPageSizeIU(), SCH_BASE_FRAME::GetRenderSettings(), GetScreen(), GRForceBlackPen(), GRResetPenAndBrush(), image, IU_PER_MILS, LAYER_DRAWINGSHEET, LAYER_SCHEMATIC_DRAWINGSHEET, BASE_SCREEN::m_DrawOrg, BASE_SCREEN::m_StartVisu, PrintPage(), scale, KIGFX::RENDER_SETTINGS::SetLayerColor(), and KIGFX::RENDER_SETTINGS::SetPrintDC().

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 458 of file sheet.cpp.

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

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

◆ eeconfig()

EESCHEMA_SETTINGS * SCH_BASE_FRAME::eeconfig ( ) const
inherited

Definition at line 116 of file sch_base_frame.cpp.

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

References EDA_BASE_FRAME::config().

Referenced by SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), AllowCaseSensitiveFileNameClashes(), 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(), DIALOG_BOM::installGeneratorsList(), LoadSettings(), EE_SELECTION_TOOL::Main(), SCH_EDIT_TOOL::Mirror(), DIALOG_PRINT_USING_PRINTER::OnMonochromeChecked(), OpenProjectFiles(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_PRINTOUT::PrintPage(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Rotate(), DIALOG_PRINT_USING_PRINTER::SavePrintOptions(), SaveSettings(), EE_SELECTION_TOOL::Selectable(), SelectUnit(), setupUIConditions(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_EDITOR_CONTROL::ToggleForceHV(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow(), DIALOG_PRINT_USING_PRINTER::TransferDataToWindow(), and DIALOG_BOM::~DIALOG_BOM().

◆ ensureWindowIsOnScreen()

void EDA_BASE_FRAME::ensureWindowIsOnScreen ( )
protectedinherited

Definition at line 657 of file eda_base_frame.cpp.

658 {
659  wxDisplay display( wxDisplay::GetFromWindow( this ) );
660  wxRect clientSize = display.GetClientArea();
661  wxPoint pos = GetPosition();
662  wxSize size = GetWindowSize();
663 
664  wxLogTrace( traceDisplayLocation,
665  "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d", clientSize.x, clientSize.y,
666  clientSize.width, clientSize.height );
667 
668  if( pos.y < clientSize.y )
669  {
670  wxLogTrace( traceDisplayLocation,
671  "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d", pos.y,
672  clientSize.y );
673  pos.y = clientSize.y;
674  }
675 
676  if( pos.x < clientSize.x )
677  {
678  wxLogTrace( traceDisplayLocation,
679  "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d", pos.x,
680  clientSize.x );
681  pos.x = clientSize.x;
682  }
683 
684  if( pos.x + size.x - clientSize.x > clientSize.width )
685  {
686  int newWidth = clientSize.width - ( pos.x - clientSize.x );
687  wxLogTrace( traceDisplayLocation,
688  "ensureWindowIsOnScreen: effective width %d above available %d, setting to %d",
689  pos.x + size.x, clientSize.width, newWidth );
690  size.x = newWidth;
691  }
692 
693  if( pos.y + size.y - clientSize.y > clientSize.height )
694  {
695  int newHeight = clientSize.height - ( pos.y - clientSize.y );
696  wxLogTrace( traceDisplayLocation,
697  "ensureWindowIsOnScreen: effective height %d above available %d, setting to %d",
698  pos.y + size.y, clientSize.height, newHeight );
699  size.y = newHeight;
700  }
701 
702  wxLogTrace( traceDisplayLocation, "Updating window position (%d, %d) with size (%d, %d)",
703  pos.x, pos.y, size.x, size.y );
704 
705  SetSize( pos.x, pos.y, size.x, size.y );
706 }
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.

References EDA_BASE_FRAME::GetWindowSize(), and traceDisplayLocation.

Referenced by EDA_BASE_FRAME::OnSize().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

Definition at line 306 of file eda_draw_frame.cpp.

307 {
308  if( m_messagePanel )
310 }
EDA_MSG_PANEL * m_messagePanel
void EraseMsgBox()
Definition: msgpanel.cpp:198

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

Referenced by GERBVIEW_CONTROL::UpdateMessagePanel().

◆ ExecuteRemoteCommand()

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 294 of file eeschema/cross-probing.cpp.

295 {
297  char line[1024];
298 
299  strncpy( line, cmdline, sizeof( line ) - 1 );
300  line[ sizeof( line ) - 1 ] = '\0';
301 
302  char* idcmd = strtok( line, " \n\r" );
303  char* text = strtok( nullptr, "\"\n\r" );
304 
305  if( idcmd == nullptr )
306  return;
307 
308  CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
309 
310  if( strcmp( idcmd, "$NET:" ) == 0 )
311  {
312  if( !crossProbingSettings.auto_highlight )
313  return;
314 
315  wxString netName = FROM_UTF8( text );
316 
317  if( auto sg = Schematic().ConnectionGraph()->FindFirstSubgraphByName( netName ) )
318  m_highlightedConn = sg->m_driver_connection;
319  else
320  m_highlightedConn = nullptr;
321 
323 
324  SetStatusText( _( "Selected net:" ) + wxS( " " ) + UnescapeString( netName ) );
325  return;
326  }
327 
328  if( strcmp( idcmd, "$CLEAR:" ) == 0 )
329  {
330  // Cross-probing is now done through selection so we no longer need a clear command
331  return;
332  }
333 
334  if( text == nullptr )
335  return;
336 
337  if( strcmp( idcmd, "$PART:" ) != 0 )
338  return;
339 
340  wxString part_ref = FROM_UTF8( text );
341 
342  /* look for a complement */
343  idcmd = strtok( nullptr, " \n\r" );
344 
345  if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew)
346  {
347  // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing
348  editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
349  return;
350  }
351 
352  text = strtok( nullptr, "\"\n\r" );
353 
354  if( text == nullptr )
355  return;
356 
357  wxString msg = FROM_UTF8( text );
358 
359  if( strcmp( idcmd, "$REF:" ) == 0 )
360  {
361  // Highlighting the reference itself isn't actually that useful, and it's harder to
362  // see. Highlight the parent and display the message.
363  editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
364  }
365  else if( strcmp( idcmd, "$VAL:" ) == 0 )
366  {
367  // Highlighting the value itself isn't actually that useful, and it's harder to see.
368  // Highlight the parent and display the message.
369  editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
370  }
371  else if( strcmp( idcmd, "$PAD:" ) == 0 )
372  {
373  editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_PIN, msg );
374  }
375  else
376  {
377  editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
378  }
379 }
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
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:221
EESCHEMA_SETTINGS * eeconfig() const
Handle actions specific to the schematic editor.
Cross-probing behavior.
Definition: app_settings.h:30
SCHEMATIC & Schematic() const
#define _(s)
wxString UnescapeString(const wxString &aSource)
const SCH_CONNECTION * m_highlightedConn
The highlighted net or bus, or nullptr.
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:34
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:167

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

862 {
863  std::vector<wxWindow*> dialogs;
864 
865  for( wxWindow* window : GetChildren() )
866  {
867  if( dynamic_cast<DIALOG_SHIM*>( window ) )
868  dialogs.push_back( window );
869  }
870 
871  return dialogs;
872 }

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

◆ FindHierarchyNavigator()

HIERARCHY_NAVIG_DLG * SCH_EDIT_FRAME::FindHierarchyNavigator ( )
Returns
a reference to the Hierarchy Navigator dialog if exists, or nullptr.

Definition at line 889 of file sch_edit_frame.cpp.

890 {
891  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
892 
893  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
894 }
#define HIERARCHY_NAVIG_DLG_WNAME
Definition: hierarch.h:36

References HIERARCHY_NAVIG_DLG_WNAME.

Referenced by doCloseWindow(), and UpdateHierarchyNavigator().

◆ FinishAUIInitialization()

void EDA_BASE_FRAME::FinishAUIInitialization ( )
inherited

Definition at line 853 of file eda_base_frame.cpp.

854 {
855 #if defined( __WXOSX_MAC__ )
856  m_auimgr.Update();
857 #else
858  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
859  // hiding it.
860  m_auimgr.Update();
861 
862  // We don't want the infobar displayed right away
863  m_auimgr.GetPane( "InfoBar" ).Hide();
864  m_auimgr.Update();
865 #endif
866 }
wxAuiManager m_auimgr

References EDA_BASE_FRAME::m_auimgr.

◆ FixupJunctions()

void SCH_EDIT_FRAME::FixupJunctions ( )

Definition at line 1572 of file sch_edit_frame.cpp.

1573 {
1574  // Save the current sheet, to retrieve it later
1575  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1576 
1577  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1578 
1579  for( const SCH_SHEET_PATH& sheet : sheetList )
1580  {
1581  size_t num_undos = m_undoList.m_CommandsList.size();
1582 
1583  // We require a set here to avoid adding multiple junctions to the same spot
1584  std::set<wxPoint> junctions;
1585 
1586  SetCurrentSheet( sheet );
1588 
1589  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1590 
1591  EE_SELECTION allItems;
1592 
1593  for( auto item : screen->Items() )
1594  allItems.Add( item );
1595 
1597 
1598  // Check if we modified anything during this routine
1599  // Needs to happen for every sheet to set the proper modified flag
1600  if( m_undoList.m_CommandsList.size() > num_undos )
1601  OnModify();
1602  }
1603 
1604  // Reselect the initial sheet:
1605  SetCurrentSheet( oldsheetpath );
1607  SetScreen( GetCurrentSheet().LastScreen() );
1608 }
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
void SetScreen(BASE_SCREEN *aScreen) override
UNDO_REDO_CONTAINER m_undoList
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
SCHEMATIC & Schematic() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
SCH_SCREEN * LastScreen()
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...

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 1624 of file sch_edit_frame.cpp.

1625 {
1626  static KIID lastBrightenedItemID( niluuid );
1627 
1628  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1630  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1631 
1632  if( lastItem && lastItem != aItem )
1633  {
1634  lastItem->ClearBrightened();
1635 
1636  UpdateItem( lastItem );
1637  lastBrightenedItemID = niluuid;
1638  }
1639 
1640  if( aItem )
1641  {
1642  aItem->SetBrightened();
1643 
1644  UpdateItem( aItem );
1645  lastBrightenedItemID = aItem->m_Uuid;
1646 
1647  FocusOnLocation( aItem->GetFocusPosition() );
1648  }
1649 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
KIID niluuid(0)
virtual const wxPoint GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:258
void SetBrightened()
Definition: eda_item.h:129
void ClearBrightened()
Definition: eda_item.h:132
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
Definition: kiid.h:44
SCHEMATIC & Schematic() const
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const KIID m_Uuid
Definition: eda_item.h:474
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

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

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

◆ FocusOnLocation()

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

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

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

Parameters
aPosis the point to go to.

Definition at line 875 of file eda_draw_frame.cpp.

876 {
877  bool centerView = false;
878  BOX2D r = GetCanvas()->GetView()->GetViewport();
879 
880  // Center if we're off the current view, or within 10% of its edge
881  r.Inflate( - (int) r.GetWidth() / 10 );
882 
883  if( !r.Contains( aPos ) )
884  centerView = true;
885 
886  std::vector<BOX2D> dialogScreenRects;
887 
888  for( wxWindow* dialog : findDialogs() )
889  {
890  dialogScreenRects.emplace_back( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
891  dialog->GetSize() );
892  }
893 
894  // Center if we're behind an obscuring dialog, or within 10% of its edge
895  for( BOX2D rect : dialogScreenRects )
896  {
897  rect.Inflate( rect.GetWidth() / 10 );
898 
899  if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
900  centerView = true;
901  }
902 
903  if( centerView )
904  {
905  try
906  {
907  GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
908  }
909  catch( const ClipperLib::clipperException& exc )
910  {
911  wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
912  exc.what() );
913  }
914  }
915 
917 }
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:512
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
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.
E_SERIE r
Definition: eserie.cpp:41
std::vector< wxWindow * > findDialogs()

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_EDIT_FRAME::ExecuteRemoteCommand(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindNext(), PCB_BASE_FRAME::FocusOnItem(), FocusOnItem(), and DIALOG_FIND::search().

◆ GetAboutTitle()

const wxString& EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

◆ getAutoSaveFileName()

const wxString & SCH_EDIT_FRAME::getAutoSaveFileName ( ) const
private

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

1492 {
1493  static wxString autoSaveFileName( wxT( "#auto_saved_files#" ) );
1494 
1495  return autoSaveFileName;
1496 }

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

◆ GetAutoSaveFilePrefix()

static wxString EDA_BASE_FRAME::GetAutoSaveFilePrefix ( )
inlinestaticprotectedinherited
Returns
the string to prepend to a file name for automatic save.

Definition at line 602 of file eda_base_frame.h.

603  {
604  return wxT( "_autosave-" );
605  }

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), CheckForAutoSaveFile(), PCB_EDIT_FRAME::doAutoSave(), doAutoSave(), doCloseWindow(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::OnExportSTEP(), PCB_EDIT_FRAME::SavePcbFile(), saveSchematicFile(), and updateAutoSaveFile().

◆ GetAutoSaveInterval()

int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 204 of file eda_base_frame.h.

204 { return m_autoSaveInterval; }

References EDA_BASE_FRAME::m_autoSaveInterval.

◆ GetCanvas()

SCH_DRAW_PANEL * SCH_BASE_FRAME::GetCanvas ( ) const
overridevirtualinherited

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

Returns
Pointer to GAL-based canvas.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 275 of file sch_base_frame.cpp.

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

References EDA_DRAW_FRAME::GetCanvas().

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

◆ GetColorSettings()

COLOR_SETTINGS * SCH_BASE_FRAME::GetColorSettings ( ) const
overridevirtualinherited

Returns a pointer to the active color theme settings.

Reimplemented from EDA_DRAW_FRAME.

Reimplemented in SYMBOL_EDIT_FRAME.

Definition at line 429 of file sch_base_frame.cpp.

430 {
431  if( !m_colorSettings )
432  {
433  SETTINGS_MANAGER& settingsManager = Pgm().GetSettingsManager();
434  EESCHEMA_SETTINGS* cfg = settingsManager.GetAppSettings<EESCHEMA_SETTINGS>();
435  COLOR_SETTINGS* colorSettings = settingsManager.GetColorSettings( cfg->m_ColorTheme );
436 
437  const_cast<SCH_BASE_FRAME*>( this )->m_colorSettings = colorSettings;
438  }
439 
440  return m_colorSettings;
441 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * m_colorSettings
The current canvas type.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184

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

Referenced by SCH_BASE_FRAME::GetDrawBgColor(), SCH_BASE_FRAME::GetLayerColor(), SCH_PRINTOUT::PrintPage(), PrintPage(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow(), 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 1652 of file sch_edit_frame.cpp.

1653 {
1654  return Schematic().GetFileName();
1655 }
SCHEMATIC & Schematic() const
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:161

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 1658 of file sch_edit_frame.cpp.

1659 {
1660  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1661 }
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158

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

◆ GetCurrentSheet()