KiCad PCB EDA Suite
SCH_EDIT_FRAME Class Reference

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

#include <sch_edit_frame.h>

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

Public Types

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

Public Member Functions

 SCH_EDIT_FRAME (KIWAY *aKiway, wxWindow *aParent)
 
 ~SCH_EDIT_FRAME () override
 
SCH_SCREENGetScreen () const override
 Return a pointer to a BASE_SCREEN or one of its derivatives. More...
 
SELECTIONGetCurrentSelection () override
 Get the current selection from the canvas area. More...
 
SCHEMATICSchematic () const
 
bool GetShowAllPins () const override
 Allow edit frame to show/hide hidden pins. More...
 
void SaveProjectSettings () override
 Save changes to the project settings to the project (.pro) file. More...
 
bool LoadProjectSettings ()
 Load the KiCad project file (*.pro) settings specific to Eeschema. More...
 
void ShowSchematicSetupDialog (const wxString &aInitialPage=wxEmptyString)
 
void LoadSettings (APP_SETTINGS_BASE *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (APP_SETTINGS_BASE *aCfg) override
 Save common frame parameters to a configuration data file. More...
 
void CreateScreens ()
 
void ReCreateHToolbar () override
 
void ReCreateVToolbar () override
 
void ReCreateOptToolbar () override
 
void 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 and update other data structures and GUI elements. More...
 
void RecordERCExclusions ()
 Scan existing markers and record data from any that are Excluded. More...
 
void ResolveERCExclusions ()
 Update markers to match recorded exclusions. More...
 
SEVERITY GetSeverity (int aErrorCode) const override
 
wxString GetScreenDesc () const override
 Return a human-readable description of the current screen. More...
 
void ExecuteRemoteCommand (const char *cmdline) override
 Execute a remote command sent by Pcbnew via a socket connection. More...
 
void KiwayMailIn (KIWAY_EXPRESS &aEvent) override
 Receive KIWAY_EXPRESS messages from other players. More...
 
void AutoRotateItem (SCH_SCREEN *aScreen, SCH_ITEM *aItem)
 Automatically set the rotation of an item (if the item supports it) More...
 
void AddItemToScreenAndUndoList (SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
 Add an item to the schematic and adds the changes to the undo/redo container. More...
 
void ShowFindReplaceDialog (bool aReplace)
 Run the Find or Find & Replace dialog. More...
 
void UpdateHierarchyNavigator ()
 Update the hierarchy navigation tree and history. More...
 
void UpdateHierarchySelection ()
 Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy pane). More...
 
void ShowFindReplaceStatus (const wxString &aMsg, int aStatusTime)
 
void ClearFindReplaceStatus ()
 
void OnFindDialogClose ()
 Notification that the Find dialog has closed. More...
 
void BreakSegment (SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
 Break a single segment into two at the specified point. More...
 
bool BreakSegments (const VECTOR2I &aPoint, SCH_SCREEN *aScreen=nullptr)
 Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an intersection is found. More...
 
bool BreakSegmentsOnJunctions (SCH_SCREEN *aScreen=nullptr)
 Test all junctions and bus entries in the schematic for intersections with wires and buses and breaks any intersections into multiple segments. More...
 
void TestDanglingEnds ()
 Test all of the connectable objects in the schematic for unused connection points. More...
 
void SendSelectItemsToPcb (const std::vector< EDA_ITEM * > &aItems, bool aForce)
 Sends items to Pcbnew for selection. More...
 
void SendCrossProbeNetName (const wxString &aNetName)
 Sends a net name to Pcbnew for highlighting. More...
 
void SetCrossProbeConnection (const SCH_CONNECTION *aConnection)
 Send a connection (net or bus) to Pcbnew for highlighting. More...
 
void SendCrossProbeClearHighlight ()
 Tell Pcbnew to clear the existing highlighted net, if one exists. More...
 
const SCH_CONNECTIONGetHighlightedConnection () const
 
void SetHighlightedConnection (const SCH_CONNECTION *aConnection)
 
bool ReadyToNetlist (const wxString &aAnnotateMessage)
 Check if we are ready to write a netlist file for the current schematic. More...
 
bool WriteNetListFile (int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=nullptr)
 Create a netlist file. More...
 
void DeleteAnnotation (ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive, bool *appendUndo)
 Clear the current symbol annotation. More...
 
void AnnotateSymbols (ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, REPORTER &aReporter, bool appendUndo=false)
 Annotate the symbols in the schematic that are not currently annotated. More...
 
int CheckAnnotate (ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL, bool aRecursive=true)
 Check for annotation errors. More...
 
int ModalAnnotate (const wxString &aMessage)
 Run a modal version of the annotate dialog for a specific purpose. More...
 
SCH_SHEET_PATHGetCurrentSheet () const
 
void SetCurrentSheet (const SCH_SHEET_PATH &aSheet)
 
void UpdateItem (EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
 Mark an item for refresh. More...
 
void HardRedraw () override
 Rebuild the GAL and redraw the screen. More...
 
void DisplayCurrentSheet ()
 Draw the current sheet on the display. More...
 
void DrawCurrentSheetToClipboard ()
 Use the wxWidgets print code to draw an image of the current sheet onto the clipboard. More...
 
void OnPageSettingsChange () override
 Called when modifying the page settings. More...
 
void SetSheetNumberAndCount ()
 Set the m_ScreenNumber and m_NumberOfScreens members for screens. More...
 
wxPageSetupDialogData & GetPageSetupData ()
 
void NewProject ()
 
void LoadProject ()
 
bool SaveProject (bool aSaveAs=false)
 Save the currently-open schematic (including its hierarchy) and associated project. More...
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 Open a project or set of files given by aFileList. More...
 
wxString GetCurrentFileName () const override
 Get the full filename + path of the currently opened file in the frame. More...
 
bool AppendSchematic ()
 Import a KiCad schematic into the current sheet. More...
 
bool AddSheetAndUpdateDisplay (const wxString aFullFileName)
 Add a sheet file into the current sheet and updates display. More...
 
bool AskToSaveChanges ()
 Check if any of the screens has unsaved changes and asks the user whether to save or drop them. More...
 
SCH_JUNCTIONAddJunction (SCH_SCREEN *aScreen, const VECTOR2I &aPos, bool aAppendToUndo, bool aFinal=true)
 
bool SchematicCleanUp (SCH_SCREEN *aScreen=nullptr)
 Perform routine schematic cleaning including breaking wire and buses and deleting identical objects superimposed on top of each other. More...
 
bool TrimWire (const VECTOR2I &aStart, const VECTOR2I &aEnd)
 If any single wire passes through both points, remove the portion between the two points, potentially splitting the wire into two. More...
 
void OnOpenPcbnew (wxCommandEvent &event)
 
void OnOpenCvpcb (wxCommandEvent &event)
 
void OnUpdatePCB (wxCommandEvent &event)
 
void OnAnnotate (wxCommandEvent &event)
 
bool CheckSheetForRecursion (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
 Verify that aSheet will not cause a recursion error in aHierarchy. More...
 
bool AllowCaseSensitiveFileNameClashes (const wxString &aSchematicFileName)
 Check aSchematicFileName for a potential file name case sensitivity clashes. More...
 
bool EditSheetProperties (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
 Edit an existing sheet or add a new sheet to the schematic. More...
 
void InitSheet (SCH_SHEET *aSheet, const wxString &aNewFilename)
 
bool LoadSheetFromFile (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
 Load a the KiCad schematic file aFileName into the sheet aSheet. More...
 
void DeleteJunction (SCH_ITEM *aItem, bool aAppend=false)
 Removes a given junction and heals any wire segments under the junction. More...
 
void ConvertPart (SCH_SYMBOL *aSymbol)
 
void SelectUnit (SCH_SYMBOL *aSymbol, int aUnit)
 
void StartNewUndo ()
 Create a new, blank stack for future Undo commands to be pushed to. More...
 
void SaveCopyInUndoList (SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
 Create a copy of the current schematic item, and put it in the undo list. More...
 
void SaveCopyInUndoList (const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
 Create a new entry in undo list of commands. More...
 
void PutDataInPreviousState (PICKED_ITEMS_LIST *aList)
 Restore an undo or redo command to put data pointed by aList in the previous state. More...
 
void ClearUndoORRedoList (UNDO_REDO_LIST whichList, int aItemCount=-1) override
 Free the undo or redo list from aList element. More...
 
void SaveCopyForRepeatItem (const SCH_ITEM *aItem)
 Clone aItem and owns that clone in this container. More...
 
void AddCopyForRepeatItem (const SCH_ITEM *aItem)
 
const std::vector< std::unique_ptr< SCH_ITEM > > & GetRepeatItems () const
 Return the items which are to be repeated with the insert key. More...
 
EDA_ITEMGetItem (const KIID &aId) const override
 Fetch an item by KIID. More...
 
void RollbackSchematicFromUndo ()
 Perform an undo of the last edit WITHOUT logging a corresponding redo. More...
 
bool CreateArchiveLibraryCacheFile (bool aUseCurrentSheetFilename=false)
 Create a symbol library file with the name of the root document plus the '-cache' suffix,. More...
 
bool CreateArchiveLibrary (const wxString &aFileName)
 Create a library aFileName that contains all symbols used in the current schematic. More...
 
virtual void PrintPage (const RENDER_SETTINGS *aSettings) override
 Plot or print the current sheet to the clipboard. More...
 
void SetNetListerCommand (const wxString &aCommand)
 
void DefaultExecFlags ()
 Reset the execution flags to defaults for external netlist and bom generators. More...
 
void SetExecFlags (const int aFlags)
 Set (adds) specified flags for next execution of external generator of the netlist or bom. More...
 
void ClearExecFlags (const int aFlags)
 Clear (removes) specified flags that not needed for next execution of external generator of the netlist or bom. More...
 
wxString GetNetListerCommand () const
 
void RecalculateConnections (SCH_CLEANUP_FLAGS aCleanupFlags)
 Generate the connection data for the entire schematic hierarchy. More...
 
void CommonSettingsChanged (bool aEnvVarsChanged, bool aTextVarsChanged) override
 Called after the preferences dialog is run. More...
 
void UpdateNetHighlightStatus ()
 
void ShowChangedLanguage () override
 
void SetScreen (BASE_SCREEN *aScreen) override
 
const BOX2I GetDocumentExtents (bool aIncludeAllVisible=true) const override
 Returns bbox of document with option to not include some items. More...
 
int GetSchematicJunctionSize ()
 
void FocusOnItem (SCH_ITEM *aItem)
 
bool IsSyncingSelection ()
 
void SaveSymbolToSchematic (const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
 Update a schematic symbol from a LIB_SYMBOL. More...
 
void RecomputeIntersheetRefs ()
 Update the schematic's page reference map for all global labels, and refresh the labels so that they are redrawn with up-to-date references. More...
 
void ShowAllIntersheetRefs (bool aShow)
 
virtual void CheckForAutoSaveFile (const wxFileName &aFileName) override
 This overloaded version checks if the auto save master file "#auto_saved_files#" exists and recovers all of the schematic files listed in it. More...
 
void ToggleSchematicHierarchy ()
 Toggle the show/hide state of the left side schematic navigation panel. More...
 
void createCanvas ()
 
SCH_DRAW_PANELGetCanvas () const override
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
EESCHEMA_SETTINGSeeconfig () const
 
SYMBOL_EDITOR_SETTINGSlibeditconfig () const
 
KIGFX::SCH_RENDER_SETTINGSGetRenderSettings ()
 
COLOR4D GetDrawBgColor () const override
 
void SetPageSettings (const PAGE_INFO &aPageSettings) override
 
const PAGE_INFOGetPageSettings () const override
 
const wxSize GetPageSizeIU () const override
 Works off of GetPageSettings() to return the size of the paper page in the internal units of this particular view. More...
 
const VECTOR2IGetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const VECTOR2I &aPoint) override
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
void UpdateStatusBar () override
 Update the status bar information. More...
 
PICKED_SYMBOL PickSymbolFromLibTree (const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
 Call the library viewer to select symbol to import into schematic. More...
 
LIB_SYMBOLGetLibSymbol (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
 Load symbol from symbol library table. More...
 
PICKED_SYMBOL PickSymbolFromLibBrowser (wxTopLevelWindow *aParent, const SYMBOL_LIBRARY_FILTER *aFilter, const LIB_ID &aPreselectedLibId, int aUnit, int aConvert)
 Call the library viewer to select symbol to import into schematic. More...
 
wxString SelectLibraryFromList ()
 Display a list of loaded libraries and allows the user to select a library. More...
 
SYMBOL_LIB_TABLESelectSymLibTable (bool aOptional=false)
 Display a dialog asking the user to select a symbol library table. More...
 
virtual void RedrawScreen (const VECTOR2I &aCenterPoint, bool aWarpPointer)
 
void AddToScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen)
 Add an item to the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void RemoveFromScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen)
 Remove an item from the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void RefreshZoomDependentItems ()
 Mark selected items for refresh. More...
 
void SyncView ()
 Mark all items for refresh. More...
 
COLOR4D GetLayerColor (SCH_LAYER_ID aLayer)
 Helper to retrieve a layer color from the global color settings. More...
 
COLOR_SETTINGSGetColorSettings (bool aForceRefresh=false) const override
 Returns a pointer to the active color theme settings. More...
 
void ActivateGalCanvas () override
 Use to start up the GAL drawing canvas. More...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
void ScriptingConsoleEnableDisable ()
 Toggles the scripting console visibility. More...
 
bool IsScriptingConsoleVisible ()
 Gets the current visibility of the scripting console window. More...
 
EDA_SEARCH_DATAGetFindReplaceData ()
 
wxArrayString & GetFindHistoryList ()
 
bool GetShowPolarCoords () const
 For those frames that support polar coordinates. More...
 
void SetShowPolarCoords (bool aShow)
 
void ToggleUserUnits () override
 
void GetUnitPair (EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
 Get the pair or units in current use. More...
 
VECTOR2I GetNearestGridPosition (const VECTOR2I &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
VECTOR2I GetNearestHalfGridPosition (const VECTOR2I &aPosition) const
 Return the nearest aGridSize / 2 location to aPosition. More...
 
virtual void SetDrawBgColor (const COLOR4D &aColor)
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
 
void EraseMsgBox ()
 
virtual void ReCreateAuxiliaryToolbar ()
 
virtual void UpdateToolbarControlSizes ()
 Update the sizes of any controls in the toolbars of the frame. More...
 
bool IsGridVisible () const
 
virtual void SetGridVisibility (bool aVisible)
 
virtual COLOR4D GetGridColor ()
 
virtual void SetGridColor (const COLOR4D &aColor)
 
void OnSelectGrid (wxCommandEvent &event)
 Command event handler for selecting grid sizes. More...
 
void OnGridSettings (wxCommandEvent &event)
 
void UpdateGridSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.). More...
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 Update the checked item in the grid wxchoice. More...
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 Update the checked item in the zoom wxchoice. More...
 
void UpdateZoomSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.) More...
 
const wxString GetZoomLevelIndicator () const
 Return a human readable value for display in dialogs. More...
 
virtual void OnSelectZoom (wxCommandEvent &event)
 Set the zoom factor when selected by the zoom list box in the main tool bar. More...
 
virtual void OnSize (wxSizeEvent &event) override
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
virtual void Zoom_Automatique (bool aWarpPointer)
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void FocusOnLocation (const VECTOR2I &aPos)
 Useful to focus on a particular location, in find functions. More...
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Construct a "basic" menu for a tool, containing only items that apply to all tools (e.g. More...
 
void PrintDrawingSheet (const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Prints the drawing-sheet (frame and title block). More...
 
void DisplayToolMsg (const wxString &msg) override
 
void DisplayConstraintsMsg (const wxString &msg)
 
void DisplayUnitsMsg ()
 Display current unit pane in the status bar. More...
 
virtual void DisplayGridMsg ()
 Display current grid size in the status bar. More...
 
void AppendMsgPanel (const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
 Append a message to the message panel. More...
 
virtual void ClearMsgPanel ()
 Clear all messages from the message panel. More...
 
void SetMsgPanel (const std::vector< MSG_PANEL_ITEM > &aList)
 Clear the message panel and populates it with the contents of aList. More...
 
void SetMsgPanel (EDA_ITEM *aItem)
 
void SetMsgPanel (const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
 Helper function that erases the msg panel and then appends a single message. More...
 
virtual void UpdateMsgPanel ()
 Redraw the message panel. More...
 
virtual void SwitchCanvas (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Changes the current rendering backend. More...
 
void SetCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
wxWindow * GetToolCanvas () const override
 Canvas access. More...
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Return a reference to the gal rendering options used by GAL for rendering. More...
 
void RefreshCanvas () override
 
void RecreateToolbars ()
 Rebuild all toolbars, and update the checked state of check tools. More...
 
virtual bool ShowModal (wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
 Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until this KIWAY_PLAYER derivative calls DismissModal(). More...
 
bool Destroy () override
 Our version of Destroy() which is virtual from wxWidgets. More...
 
bool IsModal () const override
 Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame. More...
 
void SetModal (bool aIsModal)
 
bool IsDismissed ()
 
void DismissModal (bool aRetVal, const wxString &aResult=wxEmptyString)
 
void CreateServer (int service, bool local=true)
 
void OnSockRequest (wxSocketEvent &evt)
 
void OnSockRequestServer (wxSocketEvent &evt)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
ORIGIN_TRANSFORMSGetOriginTransforms () override
 Return a reference to the default ORIGIN_TRANSFORMS object. More...
 
SETTINGS_MANAGERGetSettingsManager () const
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &aKeyEvent)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuEvent (wxMenuEvent &event)
 The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
virtual void RegisterUIUpdateHandler (int aID, const ACTION_CONDITIONS &aConditions) override
 Register a UI update handler for the control with ID aID. More...
 
virtual void RegisterUIUpdateHandler (const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
 Register an action's update conditions with the UI layer to allow the UI to appropriately display the state of its controls. More...
 
virtual void UnregisterUIUpdateHandler (int aID) override
 Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler. More...
 
virtual void UnregisterUIUpdateHandler (const TOOL_ACTION &aAction)
 Unregister a UI handler for an action that was registered using RegisterUIUpdateHandler. More...
 
void OnMaximize (wxMaximizeEvent &aEvent)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
FRAME_T GetFrameType () const
 
virtual const SEARCH_STACKsys_search ()
 Return a SEARCH_STACK pertaining to entire program. More...
 
virtual wxString help_name ()
 
void OnKicadAbout (wxCommandEvent &event)
 
void OnPreferences (wxCommandEvent &event)
 Displays the preferences and settings of all opened editors paged dialog. More...
 
void ShowPreferences (wxString aStartPage, wxString aStartParentPage)
 Displays the preferences and settings of all opened editors paged dialog, starting with a particular page. 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 ReCreateMenuBar ()
 Recreates the menu bar. More...
 
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
 
const wxString & GetUntranslatedAboutTitle () const
 
wxSize GetWindowSize ()
 Get the undecorated window size that can be used for restoring the window size. More...
 
virtual void ClearUndoRedoList ()
 Clear the undo and redo list using ClearUndoORRedoList() More...
 
virtual void PushCommandToUndoList (PICKED_ITEMS_LIST *aItem)
 Add a command to undo in the undo list. More...
 
virtual void PushCommandToRedoList (PICKED_ITEMS_LIST *aItem)
 Add a command to redo in the redo list. More...
 
virtual PICKED_ITEMS_LISTPopCommandFromUndoList ()
 Return the last command to undo and remove it from list, nothing is deleted. More...
 
virtual PICKED_ITEMS_LISTPopCommandFromRedoList ()
 Return the last command to undo and remove it from list, nothing is deleted. More...
 
virtual int GetUndoCommandCount () const
 
virtual int GetRedoCommandCount () const
 
int GetMaxUndoItems () const
 
bool NonUserClose (bool aForce)
 
virtual void HandleSystemColorChange ()
 Update the UI in response to a change in the system colors. More...
 
TOOL_MANAGERGetToolManager () const
 Return the MVC controller. More...
 
virtual void PushTool (const TOOL_EVENT &aEvent)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const TOOL_EVENT &aEvent)
 Pops a tool from the stack. More...
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
bool GetDoImmediateActions () const
 Indicate that hotkeys should perform an immediate action even if another tool is currently active. More...
 
MOUSE_DRAG_ACTION GetDragAction () const
 Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects. More...
 
bool GetMoveWarpsCursor () const
 Indicate that a move operation should warp the mouse pointer to the origin of the move object. More...
 
HOLDER_TYPE GetType () const
 
KIWAYKiway () const
 Return a reference to the KIWAY that this object has an opportunity to participate in. More...
 
bool HasKiway () const
 Safety check before asking for the Kiway reference. More...
 
PROJECTPrj () const
 Return a reference to the PROJECT associated with this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 It is only used for debugging, since "this" is not a wxWindow*. More...
 
EDA_UNITS GetUserUnits () const
 
void SetUserUnits (EDA_UNITS aUnits)
 
const EDA_IU_SCALEGetIuScale () const
 
wxString StringFromValue (double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aValue in internal units into a united string. More...
 
wxString StringFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=false)
 
wxString MessageTextFromValue (double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 A lower-precision version of StringFromValue(). More...
 
wxString MessageTextFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=true)
 
int ValueFromString (const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aTextValue in aUnits to internal units used by the frame. More...
 
EDA_ANGLE AngleValueFromString (const wxString &aTextValue)
 

Static Public Member Functions

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

Protected Member Functions

bool doAutoSave () override
 Save the schematic files that have been modified and not yet saved. More...
 
void doReCreateMenuBar () override
 
void sendNetlistToCvpcb ()
 Send the KiCad netlist over to CVPCB. More...
 
void onSize (wxSizeEvent &aEvent)
 
void handleActivateEvent (wxActivateEvent &aEvent) override
 Handle a window activation event. More...
 
void handleIconizeEvent (wxIconizeEvent &aEvent) override
 Handle a window iconize event. More...
 
bool saveSymbolLibTables (bool aGlobal, bool aProject)
 Save Symbol Library Tables to disk. More...
 
void unitsChangeRefresh () override
 Called when when the units setting has changed to allow for any derived classes to handle refreshing and controls that have units based measurements in them. More...
 
void setupUnits (APP_SETTINGS_BASE *aCfg)
 
std::vector< wxWindow * > findDialogs ()
 
void resolveCanvasType ()
 Determines the Canvas type to load (with prompt if required) and initializes m_canvasType. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting ()
 Returns the canvas type stored in the application settings. More...
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
void onActivate (wxActivateEvent &aEvent)
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 An event handler called on a language menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 
void onIconize (wxIconizeEvent &aEvent)
 
virtual bool isAutoSaveRequired () const
 Return the auto save status of the application. 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 ()
 
virtual void OnDropFiles (wxDropFilesEvent &aEvent)
 Handles event fired when a file is dropped to the window. More...
 
virtual void DoWithAcceptedFiles ()
 Execute action on accepted dropped file. More...
 

Static Protected Member Functions

static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

SCHEMATIC_SETTINGS m_base_frame_defaults
 These are only used by symbol_editor. More...
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 
COLOR4D m_gridColor
 
COLOR4D m_drawBgColor
 
int m_undoRedoCountMax
 
bool m_polarCoords
 
bool m_showBorderAndTitleBlock
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
ACTION_TOOLBARm_mainToolBar
 
ACTION_TOOLBARm_auxiliaryToolBar
 
ACTION_TOOLBARm_drawToolBar
 
ACTION_TOOLBARm_optionsToolBar
 
std::unique_ptr< EDA_SEARCH_DATAm_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_msgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 
SEARCH_PANEm_searchPane
 The current canvas type. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 < Points to nested event_loop. NULL means not modal and dismissed. More...
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
std::vector< wxFileName > m_AcceptedFiles
 
FRAME_T m_ident
 
wxPoint m_framePos
 
wxSize m_frameSize
 
bool m_maximizeByDefault
 
int m_displayIndex
 
wxPoint m_normalFramePos
 
wxSize m_normalFrameSize
 
wxString m_aboutTitle
 
wxAuiManager m_auimgr
 
wxString m_perspective
 
WX_INFOBARm_infoBar
 
wxString m_configName
 
SETTINGS_MANAGERm_settingsManager
 
FILE_HISTORYm_fileHistory
 
bool m_supportsAutoSave
 
bool m_autoSavePending
 
bool m_autoSaveRequired
 
wxTimer * m_autoSaveTimer
 
UNDO_REDO_CONTAINER m_undoList
 
UNDO_REDO_CONTAINER m_redoList
 
wxString m_mruPath
 
ORIGIN_TRANSFORMS m_originTransforms
 
std::map< int, UIUpdateHandlerm_uiUpdateMap
 < Map containing the UI update handlers registered with wx for each action. More...
 
bool m_isClosing
 Set by NonUserClose() to indicate that the user did not request the current close. More...
 
bool m_isNonUserClose
 
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
 Associates files extensions with action to execute. More...
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
TOOL_DISPATCHERm_toolDispatcher
 
SELECTION m_dummySelection
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
MOUSE_DRAG_ACTION m_dragAction
 
bool m_moveWarpsCursor
 

Static Protected Attributes

static bool m_openGLFailureOccured = false
 Has any failure occured when switching to OpenGL in any EDA_DRAW_FRAME? More...
 
static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 < Default style flags used for wxAUI toolbars. More...
 

Private Member Functions

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

Private Attributes

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

Friends

class SCH_EDITOR_CONTROL
 
class SCH_FIND_REPLACE_TOOL
 

Detailed Description

Schematic editor (Eeschema) main window.

Definition at line 97 of file sch_edit_frame.h.

Member Enumeration Documentation

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 

Definition at line 39 of file kiway_holder.h.

◆ UNDO_REDO_LIST

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

Enumerator
UNDO_LIST 
REDO_LIST 

Definition at line 111 of file eda_base_frame.h.

112 {
113 UNDO_LIST,
115 };

Constructor & Destructor Documentation

◆ SCH_EDIT_FRAME()

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

Definition at line 116 of file sch_edit_frame.cpp.

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

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

◆ ~SCH_EDIT_FRAME()

SCH_EDIT_FRAME::~SCH_EDIT_FRAME ( )
override

Definition at line 287 of file sch_edit_frame.cpp.

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

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

Member Function Documentation

◆ ActivateGalCanvas()

void SCH_BASE_FRAME::ActivateGalCanvas ( )
overridevirtualinherited

Use to start up the GAL drawing canvas.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 348 of file sch_base_frame.cpp.

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

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

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

◆ AddCopyForRepeatItem()

void SCH_EDIT_FRAME::AddCopyForRepeatItem ( const SCH_ITEM aItem)

Definition at line 607 of file sch_edit_frame.cpp.

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

References EDA_ITEM::Clone(), and m_items_to_repeat.

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

◆ AddItemToScreenAndUndoList()

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

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

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

Definition at line 1287 of file sch_edit_frame.cpp.

1289{
1290 wxCHECK_RET( aItem != nullptr, wxT( "Cannot add null item to list." ) );
1291
1292 SCH_SHEET* parentSheet = nullptr;
1293 SCH_SYMBOL* parentSymbol = nullptr;
1294 SCH_ITEM* undoItem = aItem;
1295
1296 if( aItem->Type() == SCH_SHEET_PIN_T )
1297 {
1298 parentSheet = (SCH_SHEET*) aItem->GetParent();
1299
1300 wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1301 wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1302
1303 undoItem = parentSheet;
1304 }
1305
1306 else if( aItem->Type() == SCH_FIELD_T )
1307 {
1308 parentSymbol = (SCH_SYMBOL*) aItem->GetParent();
1309
1310 wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_SYMBOL_T,
1311 wxT( "Cannot place field in invalid schematic symbol." ) );
1312
1313 undoItem = parentSymbol;
1314 }
1315
1316 if( aItem->IsNew() )
1317 {
1318 if( aItem->Type() == SCH_SHEET_PIN_T )
1319 {
1320 // Sheet pins are owned by their parent sheet.
1321 SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1322
1323 parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1324 }
1325 else if( aItem->Type() == SCH_FIELD_T )
1326 {
1327 // Symbol fields are also owned by their parent, but new symbol fields are
1328 // handled elsewhere.
1329 wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1330 }
1331 else
1332 {
1333 if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1334 AddToScreen( aItem, aScreen );
1335
1336 SaveCopyForRepeatItem( aItem );
1337 SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1338 }
1339
1340 // Update connectivity info for new item
1341 if( !aItem->IsMoving() && aItem->IsConnectable() )
1343 }
1344
1345 aItem->ClearFlags( IS_NEW );
1346
1347 aScreen->SetContentModified();
1348 UpdateItem( aItem );
1349
1350 if( !aItem->IsMoving() && aItem->IsConnectable() )
1351 {
1352 std::vector<VECTOR2I> pts = aItem->GetConnectionPoints();
1353
1354 bool connected = true;
1355 for( auto i = pts.begin(); i != pts.end(); i++ )
1356 {
1357 for( auto j = i + 1; j != pts.end(); j++ )
1358 TrimWire( *i, *j );
1359
1360 if( aScreen->IsExplicitJunctionNeeded( *i ) )
1361 {
1362 AddJunction( aScreen, *i, true, false );
1363 connected = true;
1364 }
1365 }
1366
1367 if( connected )
1368 {
1369 AutoRotateItem( aScreen, aItem );
1370 }
1371
1373
1374 for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1375 UpdateItem( item );
1376 }
1377
1378 aItem->ClearEditFlags();
1379 GetCanvas()->Refresh();
1380}
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
void ClearEditFlags()
Definition: eda_item.h:158
bool IsMoving() const
Definition: eda_item.h:104
bool IsNew() const
Definition: eda_item.h:103
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
bool TrimWire(const VECTOR2I &aStart, const VECTOR2I &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCH_SHEET_PATH & GetCurrentSheet() const
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const VECTOR2I &aPos, bool aAppendToUndo, bool aFinal=true)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
virtual bool IsConnectable() const
Definition: sch_item.h:349
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:187
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
bool IsExplicitJunctionNeeded(const VECTOR2I &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
Definition: sch_screen.cpp:478
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:370
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:369
Schematic symbol object.
Definition: sch_symbol.h:81
#define IS_NEW
New item, just created.
@ LOCAL_CLEANUP
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157

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

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

◆ AddJunction()

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

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

423{
424 SCH_JUNCTION* junction = new SCH_JUNCTION( aPos );
425
426 AddToScreen( junction, aScreen );
427 SaveCopyInUndoList( aScreen, junction, UNDO_REDO::NEWITEM, aUndoAppend );
428 BreakSegments( aPos );
429
430 if( aFinal )
431 {
433
435 OnModify();
436
437 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
438 view->ClearPreview();
439 view->ShowPreview( false );
440 view->ClearHiddenFlags();
441 }
442
443 return junction;
444}
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:185
void ShowPreview(bool aShow=true)
Definition: view.cpp:1649
void ClearPreview()
Definition: view.cpp:1613
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
bool BreakSegments(const VECTOR2I &aPoint, SCH_SCREEN *aScreen=nullptr)
Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an int...
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.

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

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

◆ AddSheetAndUpdateDisplay()

bool SCH_EDIT_FRAME::AddSheetAndUpdateDisplay ( const wxString  aFullFileName)

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

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

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

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

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

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

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 462 of file eda_base_frame.cpp.

463{
465 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
466
467 helpMenu->Add( ACTIONS::help );
468 helpMenu->Add( ACTIONS::gettingStarted );
469 helpMenu->Add( ACTIONS::listHotKeys );
470 helpMenu->Add( ACTIONS::getInvolved );
471 helpMenu->Add( ACTIONS::donate );
472 helpMenu->Add( ACTIONS::reportBug );
473
474 helpMenu->AppendSeparator();
475 helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
476
477 // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
478 aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
479}
static TOOL_ACTION reportBug
Cursor control event types.
Definition: actions.h:187
static TOOL_ACTION donate
Definition: actions.h:185
static TOOL_ACTION listHotKeys
Definition: actions.h:184
static TOOL_ACTION getInvolved
Definition: actions.h:186
static TOOL_ACTION gettingStarted
Definition: actions.h:182
static TOOL_ACTION help
Definition: actions.h:183
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
Handle actions that are shared between different applications.

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

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

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

577{
579 CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
580
581 aMenu.AddSeparator( 1000 );
582
583 std::shared_ptr<ZOOM_MENU> zoomMenu = std::make_shared<ZOOM_MENU>( this );
584 zoomMenu->SetTool( commonTools );
585 aToolMenu.RegisterSubMenu( zoomMenu );
586
587 std::shared_ptr<GRID_MENU> gridMenu = std::make_shared<GRID_MENU>( this );
588 gridMenu->SetTool( commonTools );
589 aToolMenu.RegisterSubMenu( gridMenu );
590
591 aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
592 aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
593}
Handles action that are shared between different applications.
Definition: common_tools.h:38
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44

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

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

◆ AddToScreen()

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

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

Definition at line 440 of file sch_base_frame.cpp.

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

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

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

◆ AllowCaseSensitiveFileNameClashes()

bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes ( const wxString &  aSchematicFileName)

Check aSchematicFileName for a potential file name case sensitivity clashes.

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

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

Definition at line 623 of file sheet.cpp.

624{
625 wxString msg;
626 SCH_SCREENS screens( Schematic().Root() );
627 wxFileName fn = aSchematicFileName;
628
629 wxCHECK( fn.IsAbsolute(), false );
630
631 if( eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog
632 && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
633 {
634 msg.Printf( _( "The file name '%s' can cause issues with an existing file name\n"
635 "already defined in the schematic on systems that support case\n"
636 "insensitive file names. This will cause issues if you copy this\n"
637 "project to an operating system that supports case insensitive file\n"
638 "names.\n\nDo you wish to continue?" ),
639 fn.GetName() );
640
641 wxRichMessageDialog dlg( this, msg, _( "Warning" ),
642 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
643 dlg.ShowCheckBox( _( "Do not show this message again." ) );
644 dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
645 wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
646
647 if( dlg.ShowModal() == wxID_NO )
648 return false;
649
651 !dlg.IsCheckBoxChecked();
652 }
653
654 return true;
655}
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:656

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

◆ AngleValueFromString()

EDA_ANGLE UNITS_PROVIDER::AngleValueFromString ( const wxString &  aTextValue)
inlineinherited

Definition at line 116 of file units_provider.h.

117 {
119 aTextValue );
120
121 return EDA_ANGLE( angle, DEGREES_T );
122 }
const EDA_IU_SCALE & GetIuScale() const
@ DEGREES_T
Definition: eda_angle.h:31
double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:456
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), DEGREES, DEGREES_T, EDA_UNIT_UTILS::UI::DoubleValueFromString(), and UNITS_PROVIDER::GetIuScale().

Referenced by FP_TEXT_GRID_TABLE::SetValue().

◆ AnnotateSymbols()

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

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

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

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

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

Definition at line 194 of file annotate.cpp.

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

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

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

◆ AppendMsgPanel()

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

Append a message to the message panel.

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

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

Definition at line 736 of file eda_draw_frame.cpp.

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

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

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

◆ AppendSchematic()

bool SCH_EDIT_FRAME::AppendSchematic ( )

Import a KiCad schematic into the current sheet.

Returns
True if the schematic was imported properly.

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

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

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

Referenced by OnAppendProject().

◆ AskToSaveChanges()

bool SCH_EDIT_FRAME::AskToSaveChanges ( )

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

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

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

1305{
1306 SCH_SCREENS screenList( Schematic().Root() );
1307
1308 // Save any currently open and modified project files.
1309 for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1310 {
1311 SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
1312
1313 // Simulator must be closed before loading another schematic, otherwise it may crash.
1314 // If there are any changes in the simulator the user will be prompted to save them.
1315 if( simFrame && !simFrame->Close() )
1316 return false;
1317
1318 if( screen->IsContentModified() )
1319 {
1320 if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
1321 "Save changes?" ),
1322 [&]() -> bool
1323 {
1324 return SaveProject();
1325 } ) )
1326 {
1327 return false;
1328 }
1329 }
1330 }
1331
1332 return true;
1333}
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
Implementing SIM_PLOT_FRAME_BASE.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:260
@ FRAME_SIMULATOR
Definition: frame_type.h:38

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

Referenced by OnImportProject(), and OpenProjectFiles().

◆ AutoRotateItem()

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

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

Definition at line 1261 of file sch_edit_frame.cpp.

1262{
1263 if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
1264 {
1265 auto label = static_cast<SCH_LABEL_BASE*>( aItem );
1266 if( label->AutoRotateOnPlacement() )
1267 {
1268 auto textSpin = aScreen->GetLabelOrientationForPoint(
1269 label->GetPosition(), label->GetTextSpinStyle(), &GetCurrentSheet() );
1270 if( textSpin != label->GetTextSpinStyle() )
1271 {
1272 label->SetTextSpinStyle( textSpin );
1273 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1274 {
1275 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1276 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1277 {
1278 otherLabel->AutoplaceFields( aScreen, false );
1279 }
1280 }
1281 }
1282 }
1283 }
1284}
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:162
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:376
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
TEXT_SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, TEXT_SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:487
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152

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

Referenced by AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::Main(), SCH_EDIT_TOOL::Swap(), and DIALOG_LABEL_PROPERTIES::TransferDataFromWindow().

◆ BreakSegment()

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

Break a single segment into two at the specified point.

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

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

274{
275 if( aScreen == nullptr )
276 aScreen = GetScreen();
277
278 // Save the copy of aSegment before breaking it
279 SaveCopyInUndoList( aScreen, aSegment, UNDO_REDO::CHANGED, true );
280
281 SCH_LINE* newSegment = aSegment->BreakAt( aPoint );
282 aSegment->SetFlags( IS_CHANGED | IS_BROKEN );
283 newSegment->SetFlags( IS_NEW | IS_BROKEN );
284 AddToScreen( newSegment, aScreen );
285
286 SaveCopyInUndoList( aScreen, newSegment, UNDO_REDO::NEWITEM, true );
287
288 UpdateItem( aSegment, false, true );
289
290 if( aNewSegment )
291 *aNewSegment = newSegment;
292}
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
Definition: sch_line.cpp:561
#define IS_CHANGED
Item was edited, and modified.
#define IS_BROKEN
Is a segment just broken by BreakSegment.

References SCH_BASE_FRAME::AddToScreen(), SCH_LINE::BreakAt(), CHANGED, GetScreen(), IS_BROKEN, IS_CHANGED, IS_NEW, NEWITEM, SaveCopyInUndoList(), EDA_ITEM::SetFlags(), and UpdateItem().

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

◆ BreakSegments()

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

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

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

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

296{
297 if( aScreen == nullptr )
298 aScreen = GetScreen();
299
300 bool brokenSegments = false;
301
302 for( SCH_LINE* wire : aScreen->GetBusesAndWires( aPoint, true ) )
303 {
304 BreakSegment( wire, aPoint, nullptr, aScreen );
305 brokenSegments = true;
306 }
307
308 return brokenSegments;
309}
void BreakSegment(SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
Break a single segment into two at the specified point.
std::vector< SCH_LINE * > GetBusesAndWires(const VECTOR2I &aPosition, bool aIgnoreEndpoints=false) const
Return buses and wires passing through aPosition.

References BreakSegment(), SCH_SCREEN::GetBusesAndWires(), and GetScreen().

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 312 of file bus-wire-junction.cpp.

313{
314 if( aScreen == nullptr )
315 aScreen = GetScreen();
316
317 bool brokenSegments = false;
318
319 std::set<VECTOR2I> point_set;
320
321 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_JUNCTION_T ) )
322 point_set.insert( item->GetPosition() );
323
324 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_BUS_WIRE_ENTRY_T ) )
325 {
326 SCH_BUS_WIRE_ENTRY* entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
327 point_set.insert( entry->GetPosition() );
328 point_set.insert( entry->GetEnd() );
329 }
330
331 for( const VECTOR2I& pt : point_set )
332 {
333 BreakSegments( pt, aScreen );
334 brokenSegments = true;
335 }
336
337 return brokenSegments;
338}
VECTOR2I GetPosition() const override
VECTOR2I GetEnd() const
Class for a wire to bus entry.
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:144
@ SCH_JUNCTION_T
Definition: typeinfo.h:142

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

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

References _, ACTIONS::cancelInteractive, DIALOG_ERC_WINDOW_NAME, Format(), FRAME_SCH_SYMBOL_EDITOR, FRAME_SCH_VIEWER, FRAME_SCH_VIEWER_MODAL, FRAME_SIMULATOR, SCH_SCREEN::GetFileName(), SCHEMATIC::GetSheets(), HandleUnsavedChanges(), SCH_SHEET_LIST::IsModified(), SCHEMATIC::IsValid(), Kiface(), KIWAY_HOLDER::Kiway(), TOOLS_HOLDER::m_toolManager, KIWAY::Player(), SCHEMATIC::RootScreen(), TOOL_MANAGER::RunAction(), Schematic(), and KIPLATFORM::APP::SupportsShutdownBlockReason().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1352 of file eda_base_frame.cpp.

1353{
1354 SetUserUnits( aUnits );
1356
1357 wxCommandEvent e( UNITS_CHANGED );
1358 e.SetClientData( this );
1359 ProcessEventLocally( e );
1360}
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void SetUserUnits(EDA_UNITS aUnits)

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

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

◆ CheckAnnotate()

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

Check for annotation errors.

The following list of items are checked:

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

Definition at line 441 of file annotate.cpp.

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

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

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

◆ CheckForAutoSaveFile()

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

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

Parameters
aFileNameis the project auto save master file name.

Reimplemented from EDA_BASE_FRAME.

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

1396{
1397 if( !IsGUI() )
1398 return;
1399
1400 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1401
1402 wxLogTrace( traceAutoSave,
1403 wxT( "Checking for auto save file " ) + aFileName.GetFullPath() );
1404
1405 if( !aFileName.FileExists() )
1406 return;
1407
1408 wxString msg = _(
1409 "Well this is potentially embarrassing!\n"
1410 "It appears that the last time you were editing one or more of the schematic files\n"
1411 "were not saved properly. Do you wish to restore the last saved edits you made?" );
1412
1413 int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1414 this );
1415
1416 wxTextFile autoSaveFile( aFileName.GetFullPath() );
1417
1418 if( !autoSaveFile.Open() )
1419 {
1420 msg.Printf( _( "The file '%s` could not be opened.\n"
1421 "Manual recovery of automatically saved files is required." ),
1422 aFileName.GetFullPath() );
1423
1424 wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1425 return;
1426 }
1427
1428 if( response == wxYES )
1429 {
1430 wxArrayString unrecoveredFiles;
1431
1432 for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
1433 fn = autoSaveFile.GetNextLine() )
1434 {
1435 wxFileName recoveredFn = fn;
1436 wxString tmp = recoveredFn.GetName();
1437
1438 // Strip "_autosave-" prefix from the auto save file name.
1439 tmp.Replace( GetAutoSaveFilePrefix(), wxT( "" ), false );
1440 recoveredFn.SetName( tmp );
1441
1442 wxFileName backupFn = recoveredFn;
1443
1444 backupFn.SetExt( backupFn.GetExt() + BackupFileSuffix );
1445
1446 wxLogTrace( traceAutoSave, wxT( "Recovering auto save file:\n"
1447 " Original file: '%s'\n"
1448 " Backup file: '%s'\n"
1449 " Auto save file: '%s'" ),
1450 recoveredFn.GetFullPath(), backupFn.GetFullPath(), fn );
1451
1452 if( !wxFileExists( fn ) )
1453 {
1454 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1455 }
1456 // Attempt to back up the last schematic file before overwriting it with the auto
1457 // save file.
1458 else if( !wxCopyFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) )
1459 {
1460 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1461 }
1462 // Attempt to replace last saved file with auto save file
1463 else if( !wxRenameFile( fn, recoveredFn.GetFullPath() ) )
1464 {
1465 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1466 }
1467 }
1468
1469 if( !unrecoveredFiles.IsEmpty() )
1470 {
1471 msg = _( "The following automatically saved file(s) could not be restored\n" );
1472
1473 for( size_t i = 0; i < unrecoveredFiles.GetCount(); i++ )
1474 msg += unrecoveredFiles[i] + wxT( "\n" );
1475
1476 msg += _( "Manual recovery will be required to restore the file(s) above." );
1477 wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
1478 this );
1479 }
1480 }
1481 else
1482 {
1483 wxArrayString unremovedFiles;
1484
1485 for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
1486 fn = autoSaveFile.GetNextLine() )
1487 {
1488 wxLogTrace( traceAutoSave, wxT( "Removing auto save file " ) + fn );
1489
1490 if( wxFileExists( fn ) && !wxRemoveFile( fn ) )
1491 unremovedFiles.Add( fn );
1492 }
1493
1494 if( !unremovedFiles.IsEmpty() )
1495 {
1496 msg = _( "The following automatically saved file(s) could not be removed\n" );
1497
1498 for( size_t i = 0; i < unremovedFiles.GetCount(); i++ )
1499 msg += unremovedFiles[i] + wxT( "\n" );
1500
1501 msg += _( "Manual removal will be required for the file(s) above." );
1502 wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
1503 this );
1504 }
1505 }
1506
1507 // Remove the auto save master file.
1508 wxLogTrace( traceAutoSave, wxT( "Removing auto save file '%s'" ), aFileName.GetFullPath() );
1509
1510 if( !wxRemoveFile( aFileName.GetFullPath() ) )
1511 {
1512 msg.Printf( _( "The automatic save master file\n"
1513 "'%s'\n"
1514 "could not be deleted." ), aFileName.GetFullPath() );
1515
1516 wxMessageDialog dlg( this, msg, Pgm().App().GetAppDisplayName(),
1517 wxOK | wxICON_EXCLAMATION | wxCENTER );
1518
1519 dlg.SetExtendedMessage(
1520 _( "This file must be manually removed or the auto save feature will be\n"
1521 "shown every time the schematic editor is launched." ) );
1522
1523 dlg.ShowModal();
1524 }
1525}
static wxString GetAutoSaveFilePrefix()
bool IsGUI()
Determine if the application is running with a GUI.
Definition: confirm.cpp:40
const std::string BackupFileSuffix
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

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

Referenced by OpenProjectFiles().

◆ checkForNoFullyDefinedLibIds()

bool SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds ( SCH_SHEET aSheet)
private

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

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

Definition at line 75 of file sheet.cpp.

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

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

Referenced by LoadSheetFromFile().

◆ CheckSheetForRecursion()

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

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

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

Definition at line 47 of file sheet.cpp.

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

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

751{ 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 969 of file eda_base_frame.cpp.

970{
971 if( !aFileHistory )
972 aFileHistory = m_fileHistory;
973
974 wxASSERT( aFileHistory );
975
976 aFileHistory->ClearFileHistory();
977
978 // Update the menubar to update the file history menu
979 if( GetMenuBar() )
980 {
982 GetMenuBar()->Refresh();
983 }
984}
FILE_HISTORY * m_fileHistory
void ClearFileHistory()
Clear all entries from the file history.

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

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

◆ ClearFindReplaceStatus()

void SCH_EDIT_FRAME::ClearFindReplaceStatus ( )

Definition at line 1066 of file sch_edit_frame.cpp.

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

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

Referenced by SCH_FIND_REPLACE_TOOL::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 404 of file schematic_undo_redo.cpp.

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

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

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

◆ ClearUndoRedoList()

◆ commonInit()

void EDA_BASE_FRAME::commonInit ( FRAME_T  aFrameType)
privateinherited

Collect common initialization functions used in all CTORs.

Definition at line 117 of file eda_base_frame.cpp.

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

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

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

◆ CommonSettingsChanged()

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

Called after the preferences dialog is run.

Reimplemented from SCH_BASE_FRAME.

Definition at line 1531 of file sch_edit_frame.cpp.

1532{
1533 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1534
1535 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1536
1538
1540
1541 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1544
1545 KIGFX::VIEW* view = GetCanvas()->GetView();
1549
1550 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
1551
1552 if( !cfg->m_Drawing.field_names.IsEmpty() )
1554
1556
1557 for( SCH_ITEM* item : screen->Items() )
1558 item->ClearCaches();
1559
1560 for( std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
1561 libSymbol.second->ClearCaches();
1562
1564
1566 Layout();
1567 SendSizeEvent();
1568}
WINDOW_SETTINGS m_Window
Definition: app_settings.h:187
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void ForceRefresh()
Force a redraw.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
void SetDefaultFont(const wxString &aFont)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:393
These settings were stored in SCH_BASE_FRAME previously.
TEMPLATES m_TemplateFieldNames
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:203
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void ShowAllIntersheetRefs(bool aShow)
int GetSchematicJunctionSize()
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:481
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
@ LAYER_ERC_WARN
Definition: layer_ids.h:369
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:371
@ LAYER_ERC_ERR
Definition: layer_ids.h:370

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

◆ config()

APP_SETTINGS_BASE * EDA_BASE_FRAME::config ( ) const
virtualinherited

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

Reimplemented in SYMBOL_EDIT_FRAME, KICAD_MANAGER_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 809 of file eda_base_frame.cpp.

810{
811 // KICAD_MANAGER_FRAME overrides this
812 return Kiface().KifaceSettings();
813}
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93

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

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

◆ ConfigBaseName()

wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineoverridevirtualinherited

Get the configuration base name.

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

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

Reimplemented from TOOLS_HOLDER.

Definition at line 350 of file eda_base_frame.h.

351 {
352 wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
353 return baseCfgName;
354 }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

◆ ConvertPart()

void SCH_EDIT_FRAME::ConvertPart ( SCH_SYMBOL aSymbol)

Definition at line 278 of file picksymbol.cpp.

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

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

Referenced by SCH_EDIT_TOOL::ConvertDeMorgan().

◆ CreateArchiveLibrary()

bool SCH_EDIT_FRAME::CreateArchiveLibrary ( const wxString &  aFileName)

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

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

Definition at line 65 of file libarch.cpp.

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

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

Referenced by CreateArchiveLibraryCacheFile().

◆ CreateArchiveLibraryCacheFile()

bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile ( bool  aUseCurrentSheetFilename = false)

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

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

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

Definition at line 42 of file libarch.cpp.

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

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

◆ createCanvas()

void SCH_BASE_FRAME::createCanvas ( )
inherited

Definition at line 338 of file sch_base_frame.cpp.

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

References SCH_BASE_FRAME::ActivateGalCanvas(), EDA_DRAW_FRAME::GetGalDisplayOptions(), EDA_DRAW_FRAME::loadCanvasTypeSetting(), EDA_DRAW_FRAME::m_canvasType, EDA_BASE_FRAME::m_frameSize, and EDA_DRAW_FRAME::SetCanvas().

Referenced by SCH_BASE_FRAME::SCH_BASE_FRAME().

◆ CreateInfoBar()

void EDA_BASE_FRAME::CreateInfoBar ( )
inherited

Definition at line 834 of file eda_base_frame.cpp.

835{
836#if defined( __WXOSX_MAC__ )
838#else
839 m_infoBar = new WX_INFOBAR( this, &m_auimgr );
840
841 m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxS( "InfoBar" ) ).Top().Layer(1) );
842#endif
843}
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75

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

Referenced by SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME().

◆ CreateScreens()

void SCH_EDIT_FRAME::CreateScreens ( )

Definition at line 657 of file sch_edit_frame.cpp.

658{
661
662 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
663 m_schematic->SetRoot( rootSheet );
664
665 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
666 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
667 m_schematic->Root().SetScreen( rootScreen );
668 SetScreen( Schematic().RootScreen() );
669
670
671 m_schematic->RootScreen()->SetFileName( wxEmptyString );
672
673 // Don't leave root page number empty
674 SCH_SHEET_PATH rootSheetPath;
675
676 rootSheetPath.push_back( rootSheet );
677 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
678 rootSheetPath.SetPageNumber( wxT( "1" ) );
679
680 if( GetScreen() == nullptr )
681 {
682 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
683 SetScreen( screen );
684 }
685}
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
Definition: kiid.h:48
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:54
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:107
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:79
SCH_SHEET & Root() const
Definition: schematic.h:91
const KIID & GetUuid() const
Definition: sch_screen.h:526
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162

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

Referenced by importFile(), and OpenProjectFiles().

◆ CreateServer()

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

Definition at line 43 of file eda_dde.cpp.

44{
45 wxIPV4address addr;
46
47 // Set the port number
48 addr.Service( service );
49
50 // Listen on localhost only if requested
51 if( local )
52 addr.Hostname( HOSTNAME );
53
54 if( m_socketServer )
55 {
56 // this helps prevent any events that could come in during deletion
57 m_socketServer->Notify( false );
58 delete m_socketServer;
59 }
60
61 m_socketServer = new wxSocketServer( addr );
62
63 m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
64 m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
65 m_socketServer->Notify( true );
66}
wxSocketServer * m_socketServer
Definition: kiway_player.h:204
static const wxString HOSTNAME(wxT("localhost"))
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:163

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

Referenced by SaveFileAs().

◆ CurrentToolName()

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

Definition at line 110 of file tools_holder.cpp.

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

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

Referenced by TOOLS_HOLDER::ShowChangedLanguage().

◆ DefaultExecFlags()

void SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

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

Definition at line 736 of file sch_edit_frame.h.

736{ m_exec_flags = wxEXEC_SYNC; }

References m_exec_flags.

Referenced by WriteNetListFile().

◆ DeleteAnnotation()

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

Clear the current symbol annotation.

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

Definition at line 60 of file annotate.cpp.

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

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

Referenced by DIALOG_ANNOTATE::OnClearAnnotationClick().

◆ DeleteJunction()

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

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

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

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

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

342{
343 SCH_SCREEN* screen = GetScreen();
344 PICKED_ITEMS_LIST undoList;
346
347 auto remove_item =
348 [&]( SCH_ITEM* aItem ) -> void
349 {
350 aItem->SetFlags( STRUCT_DELETED );
351 undoList.PushItem( ITEM_PICKER( screen, aItem, UNDO_REDO::DELETED ) );
352 };
353
354 remove_item( aJunction );
355 RemoveFromScreen( aJunction, screen );
356
359 std::list<SCH_LINE*> lines;
360
361 for( SCH_ITEM* item : screen->Items().Overlapping( SCH_LINE_T, aJunction->GetPosition() ) )
362 {
363 SCH_LINE* line = static_cast<SCH_LINE*>( item );
364
365 if( line->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
366 && line->IsEndPoint( aJunction->GetPosition() )
367 && !( line->GetEditFlags() & STRUCT_DELETED ) )
368 {
369 lines.push_back( line );
370 }
371 }
372
373 alg::for_all_pairs( lines.begin(), lines.end(),
374 [&]( SCH_LINE* firstLine, SCH_LINE* secondLine )
375 {
376 if( ( firstLine->GetEditFlags() & STRUCT_DELETED )
377 || ( secondLine->GetEditFlags() & STRUCT_DELETED )
378 || !secondLine->IsParallel( firstLine ) )
379 {
380 return;
381 }
382
383 // Remove identical lines
384 if( firstLine->IsEndPoint( secondLine->GetStartPoint() )
385 && firstLine->IsEndPoint( secondLine->GetEndPoint() ) )
386 {
387 remove_item( firstLine );
388 return;
389 }
390
391 // Try to merge the remaining lines
392 if( SCH_LINE* line = secondLine->MergeOverlap( screen, firstLine, false ) )
393 {
394 remove_item( firstLine );
395 remove_item( secondLine );
396 undoList.PushItem( ITEM_PICKER( screen, line, UNDO_REDO::NEWITEM ) );
397 AddToScreen( line, screen );
398
399 if( line->IsSelected() )
400 selectionTool->AddItemToSel( line, true /*quiet mode*/ );
401
402 lines.push_back( line );
403 }
404 } );
405
406 SaveCopyInUndoList( undoList, UNDO_REDO::DELETED, aAppend );
407
408 for( SCH_LINE* line : lines )
409 {
410 if( line->GetEditFlags() & STRUCT_DELETED )
411 {
412 if( line->IsSelected() )
413 selectionTool->RemoveItemFromSel( line, true /*quiet mode*/ );
414
415 RemoveFromScreen( line, screen );
416 }
417 }
418}
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:145
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
VECTOR2I GetEndPoint() const
Definition: sch_line.h:143
VECTOR2I GetStartPoint() const
Definition: sch_line.h:138
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:440
bool IsEndPoint(const VECTOR2I &aPoint) const
Definition: sch_line.h:92
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_line.h:72
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
#define STRUCT_DELETED
flag indication structures to be erased
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
Definition: kicad_algo.h:83
@ SCH_LINE_T
Definition: typeinfo.h:146

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

Referenced by SCH_EDIT_TOOL::DoDelete().

◆ Destroy()

◆ DismissModal()

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

Definition at line 182 of file kiway_player.cpp.

183{
184 m_modal_ret_val = aRetVal;
185 m_modal_string = aResult;
186
187 if( m_modal_loop )
188 {
189 m_modal_loop->Exit();
190 m_modal_loop = nullptr; // this marks it as dismissed.
191 }
192
193 Show( false );
194}
wxString m_modal_string
Definition: kiway_player.h:201
WX_EVENT_LOOP * m_modal_loop
< Points to nested event_loop. NULL means not modal and dismissed.
Definition: kiway_player.h:199
bool m_modal_ret_val
Definition: kiway_player.h:202

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

603{
604 SetStatusText( msg, 7 );
605}

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

◆ DisplayCurrentSheet()

void SCH_EDIT_FRAME::DisplayCurrentSheet ( )

Draw the current sheet on the display.

Definition at line 1804 of file sch_edit_frame.cpp.

1805{
1809
1810 wxASSERT( screen );
1811
1812 SetScreen( screen );
1813
1814 // update the References
1817
1819
1820 auto visit =
1821 [&]( EDA_ITEM* item )
1822 {
1824 && !m_findReplaceData->findString.IsEmpty()
1825 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
1826 {
1827 item->SetForceVisible( true );
1828 selectionTool->BrightenItem( item );
1829 }
1830 else if( item->IsBrightened() )
1831 {
1832 item->SetForceVisible( false );
1833 selectionTool->UnbrightenItem( item );
1834 }
1835 };
1836
1837 for( SCH_ITEM* item : screen->Items() )
1838 {
1839 visit( item );
1840
1841 item->RunOnChildren(
1842 [&]( SCH_ITEM* aChild )
1843 {
1844 visit( aChild );
1845 } );
1846 }
1847
1848 if( !screen->m_zoomInitialized )
1849 {
1851 }
1852 else
1853 {
1854 // Set zoom to last used in this screen
1855 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
1856 RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
1857 }
1858
1859 updateTitle();
1860
1861 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
1862
1865 editTool->UpdateNetHighlighting( dummy );
1866
1868}
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:73
virtual void RedrawScreen(const VECTOR2I &aCenterPoint, bool aWarpPointer)
Handle actions specific to the schematic editor.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
bool m_zoomInitialized
Definition: sch_screen.h:605
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
Generic, UI-independent tool event.
Definition: tool_event.h:156
std::vector< FAB_LAYER_COLOR > dummy

References SELECTION_TOOL::BrightenItem(), ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, dummy, SCH_BASE_FRAME::GetCanvas(), GetCurrentSheet(), GetScreen(), TOOL_MANAGER::GetTool(), SCH_DRAW_PANEL::GetView(), HardRedraw(), initScreenZoom(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EDA_DRAW_FRAME::m_findReplaceData, m_findReplaceDialog, m_hierarchy, TOOLS_HOLDER::m_toolManager, SCH_SCREEN::m_zoomInitialized, SCH_BASE_FRAME::RedrawScreen(), TOOL_MANAGER::RunAction(), KIGFX::SCH_VIEW::SetScale(), SetScreen(), SetSheetNumberAndCount(), SELECTION_TOOL::UnbrightenItem(), SCH_SHEET_PATH::UpdateAllScreenReferences(), HIERARCHY_PANE::UpdateHierarchySelection(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and updateTitle().

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

◆ DisplayGridMsg()

void EDA_DRAW_FRAME::DisplayGridMsg ( )
virtualinherited

Display current grid size in the status bar.

Reimplemented in GERBVIEW_FRAME, PCB_BASE_FRAME, and PL_EDITOR_FRAME.

Definition at line 608 of file eda_draw_frame.cpp.

609{
610 wxString msg;
611
612 msg.Printf( wxS( "grid %s" ), MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x, false ) );
613
614 SetStatusText( msg, 4 );
615}
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().

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

Referenced by SCH_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from TOOLS_HOLDER.

Definition at line 596 of file eda_draw_frame.cpp.

597{
598 SetStatusText( msg, 6 );
599}

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

619{
620 wxString msg;
621
622 switch( GetUserUnits() )
623 {
624 case EDA_UNITS::INCHES: msg = _( "inches" ); break;
625 case EDA_UNITS::MILS: msg = _( "mils" ); break;
626 case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
627 default: msg = _( "Units" ); break;
628 }
629
630 SetStatusText( msg, 5 );
631}
EDA_UNITS GetUserUnits() const

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

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

◆ doAutoSave()

bool SCH_EDIT_FRAME::doAutoSave ( )
overrideprotectedvirtual

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

Returns
true if the auto save was successful otherwise false.

Reimplemented from EDA_BASE_FRAME.

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

1130{
1131 wxFileName tmpFileName = Schematic().Root().GetFileName();
1132 wxFileName fn = tmpFileName;
1133 wxFileName tmp;
1134 SCH_SCREENS screens( Schematic().Root() );
1135
1136 // Don't run autosave if content has not been modified
1137 if( !IsContentModified() )
1138 return true;
1139
1140 bool autoSaveOk = true;
1141
1142 if( fn.GetPath().IsEmpty() )
1143 tmp.AssignDir( Prj().GetProjectPath() );
1144 else
1145 tmp.AssignDir( fn.GetPath() );
1146
1147 if( !tmp.IsOk() )
1148 return false;
1149
1150 if( !IsWritable( tmp ) )
1151 return false;
1152
1153 wxString title = GetTitle(); // Save frame title, that can be modified by the save process
1154
1155 for( size_t i = 0; i < screens.GetCount(); i++ )
1156 {
1157 // Only create auto save files for the schematics that have been modified.
1158 if( !screens.GetScreen( i )->IsContentModified() )
1159 continue;
1160
1161 tmpFileName = fn = screens.GetScreen( i )->GetFileName();
1162
1163 // Auto save file name is the normal file name prefixed with GetAutoSavePrefix().
1164 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
1165
1166 if( saveSchematicFile( screens.GetSheet( i ), fn.GetFullPath() ) )
1167 {
1168 // This was only an auto-save, not a real save. Reset the modified flag.
1169 screens.GetScreen( i )->SetContentModified();
1170 }
1171 else
1172 {
1173 autoSaveOk = false;
1174 }
1175 }
1176
1177 if( autoSaveOk && updateAutoSaveFile() )
1178 {
1179 m_autoSaveRequired = false;
1180 m_autoSavePending = false;
1181
1182 if( !Kiface().IsSingle()
1183 && GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
1184 {
1186 }
1187 }
1188
1189 SetTitle( title );
1190
1191 return autoSaveOk;
1192}
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Checks if aFileName can be written.
static REPORTER & GetInstance()
Definition: reporter.cpp:117
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:302
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.

References EDA_BASE_FRAME::GetAutoSaveFilePrefix(), SCH_SCREENS::GetCount(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetFileName(), NULL_REPORTER::GetInstance(), SCH_SCREENS::GetScreen(), EDA_BASE_FRAME::GetSettingsManager(), SCH_SCREENS::GetSheet(), BASE_SCREEN::IsContentModified(), IsContentModified(), EDA_BASE_FRAME::IsWritable(), Kiface(), EDA_BASE_FRAME::m_autoSavePending, EDA_BASE_FRAME::m_autoSaveRequired, 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 809 of file sch_edit_frame.cpp.

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

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

◆ doReCreateMenuBar()

void SCH_EDIT_FRAME::doReCreateMenuBar ( )
overrideprotectedvirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 43 of file eeschema/menubar.cpp.

44{
46 // wxWidgets handles the Mac Application menu behind the scenes, but that means
47 // we always have to start from scratch with a new wxMenuBar.
48 wxMenuBar* oldMenuBar = GetMenuBar();
49 WX_MENUBAR* menuBar = new WX_MENUBAR();
50
51 //-- File menu -----------------------------------------------------------
52 //
53 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
54 static ACTION_MENU* openRecentMenu;
55
56 if( Kiface().IsSingle() ) // When not under a project mgr
57 {
58 FILE_HISTORY& fileHistory = GetFileHistory();
59
60 // Add this menu to the list of menus managed by the file history
61 // (the file history will be updated when adding/removing files in history)
62 if( !openRecentMenu )
63 {
64 openRecentMenu = new ACTION_MENU( false, selTool );
65 openRecentMenu->SetIcon( BITMAPS::recent );
66
67 fileHistory.UseMenu( openRecentMenu );
68 fileHistory.AddFilesToMenu( openRecentMenu );
69 }
70
71 // Ensure the title is up to date after changing language
72 openRecentMenu->SetTitle( _( "Open Recent" ) );
73 fileHistory.UpdateClearText( openRecentMenu, _( "Clear Recent Files" ) );
74
75 fileMenu->Add( ACTIONS::doNew );
76 fileMenu->Add( ACTIONS::open );
77
78 wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
79
80 // Add the file menu condition here since it needs the item ID for the submenu
82 cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
83 RegisterUIUpdateHandler( item->GetId(), cond );
84 fileMenu->AppendSeparator();
85 }
86
87 fileMenu->Add( ACTIONS::save );
88
89 if( Kiface().IsSingle() )
90 fileMenu->Add( ACTIONS::saveAs );
91 else
93
94 fileMenu->Add( ACTIONS::revert );
95
96 fileMenu->AppendSeparator();
97
98 fileMenu->Add( _( "Insert Schematic Sheet Content..." ),
99 _( "Append schematic sheet content from another project to the current sheet" ),
102
103 fileMenu->AppendSeparator();
104
105 // Import submenu
106 ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
107 submenuImport->SetTitle( _( "Import" ) );
108 submenuImport->SetIcon( BITMAPS::import );
109 submenuImport->Add( _( "Non-KiCad Schematic..." ),
110 _( "Replace current schematic sheet with one imported from another application" ),
113
114 submenuImport->Add( EE_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
115 fileMenu->Add( submenuImport );
116
117
118 // Export submenu
119 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
120 submenuExport->SetTitle( _( "Export" ) );
121 submenuExport->SetIcon( BITMAPS::export_file );
122 submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
123 submenuExport->Add( EE_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
125 _( "Symbols to Library..." ) );
127 _( "Symbols to New Library..." ) );
128 fileMenu->Add( submenuExport );
129
130 fileMenu->AppendSeparator();
131 fileMenu->Add( EE_ACTIONS::schematicSetup );
132
133 fileMenu->AppendSeparator();
134 fileMenu->Add( ACTIONS::pageSettings );
135 fileMenu->Add( ACTIONS::print );
136 fileMenu->Add( ACTIONS::plot );
137
138 fileMenu->AppendSeparator();
139 fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
140
141
142 //-- Edit menu -----------------------------------------------------------
143 //
144 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
145
146 editMenu->Add( ACTIONS::undo );
147 editMenu->Add( ACTIONS::redo );
148
149 editMenu->AppendSeparator();
150 editMenu->Add( ACTIONS::cut );
151 editMenu->Add( ACTIONS::copy );
152 editMenu->Add( ACTIONS::paste );
153 editMenu->Add( ACTIONS::pasteSpecial );
154 editMenu->Add( ACTIONS::doDelete );
155
156 editMenu->AppendSeparator();
157 editMenu->Add( ACTIONS::selectAll );
158
159 editMenu->AppendSeparator();
160 editMenu->Add( ACTIONS::find );
161 editMenu->Add( ACTIONS::findAndReplace );
162
163 editMenu->AppendSeparator();
164 editMenu->Add( ACTIONS::deleteTool );
166 editMenu->Add( EE_ACTIONS::changeSymbols );
167 editMenu->Add( EE_ACTIONS::editPageNumber );
168
169 //-- View menu -----------------------------------------------------------
170 //
171 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
172
173 viewMenu->Add( ACTIONS::showSymbolBrowser );
175 viewMenu->Add( EE_ACTIONS::navigateBack );
176 viewMenu->Add( EE_ACTIONS::navigateUp );
177 viewMenu->Add( EE_ACTIONS::navigateForward );
179 viewMenu->Add( EE_ACTIONS::navigateNext );
180
181 viewMenu->AppendSeparator();
182 viewMenu->Add( ACTIONS::zoomInCenter );
183 viewMenu->Add( ACTIONS::zoomOutCenter );
184 viewMenu->Add( ACTIONS::zoomFitScreen );
185 viewMenu->Add( ACTIONS::zoomFitObjects );
186 viewMenu->Add( ACTIONS::zoomTool );
187 viewMenu->Add( ACTIONS::zoomRedraw );
188
189 viewMenu->AppendSeparator();
191 viewMenu->Add( ACTIONS::gridProperties );
192
193 // Units submenu
194 ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
195 unitsSubMenu->SetTitle( _( "&Units" ) );
196 unitsSubMenu->SetIcon( BITMAPS::unit_mm );
198 unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
200 viewMenu->Add( unitsSubMenu );
201
203
204 viewMenu->AppendSeparator();
210
211#ifdef __APPLE__
212 viewMenu->AppendSeparator();
213#endif
214
215 //-- Place menu -----------------------------------------------------------
216 //
217 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
218
219 placeMenu->Add( EE_ACTIONS::placeSymbol );
220 placeMenu->Add( EE_ACTIONS::placePower );
221 placeMenu->Add( EE_ACTIONS::drawWire );
222 placeMenu->Add( EE_ACTIONS::drawBus );
224 placeMenu->Add( EE_ACTIONS::placeNoConnect );
225 placeMenu->Add( EE_ACTIONS::placeJunction );
226 placeMenu->Add( EE_ACTIONS::placeLabel );
227 placeMenu->Add( EE_ACTIONS::placeClassLabel );
228 placeMenu->Add( EE_ACTIONS::placeGlobalLabel );
229
230 placeMenu->AppendSeparator();
231 placeMenu->Add( EE_ACTIONS::placeHierLabel );
232 placeMenu->Add( EE_ACTIONS::drawSheet );
233 placeMenu->Add( EE_ACTIONS::importSheetPin );
234
235 placeMenu->AppendSeparator();
237 placeMenu->Add( EE_ACTIONS::drawTextBox );
238 placeMenu->Add( EE_ACTIONS::drawRectangle );
239 placeMenu->Add( EE_ACTIONS::drawCircle );
240 placeMenu->Add( EE_ACTIONS::drawArc );
241 placeMenu->Add( EE_ACTIONS::drawLines );
242 placeMenu->Add( EE_ACTIONS::placeImage );
243
244
245 //-- Inspect menu -----------------------------------------------
246 //
247 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
248
249 inspectMenu->Add( EE_ACTIONS::runERC );
250 inspectMenu->Add( ACTIONS::prevMarker );
251 inspectMenu->Add( ACTIONS::nextMarker );
252 inspectMenu->Add( ACTIONS::excludeMarker );
253
254#ifdef KICAD_SPICE
255 inspectMenu->AppendSeparator();
256 inspectMenu->Add( EE_ACTIONS::runSimulation );
257#endif
258
259
260 //-- Tools menu -----------------------------------------------
261 //
262 ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
263
264 wxMenuItem* update = toolsMenu->Add( ACTIONS::updatePcbFromSchematic );
265 update->Enable( !Kiface().IsSingle() );
266
267 toolsMenu->Add( EE_ACTIONS::showPcbNew );
268
269 toolsMenu->AppendSeparator();
270 toolsMenu->Add( ACTIONS::showSymbolEditor );
271 toolsMenu->Add( EE_ACTIONS::updateSymbols );
272
273 toolsMenu->AppendSeparator();
274 toolsMenu->Add( EE_ACTIONS::rescueSymbols );
275 toolsMenu->Add( EE_ACTIONS::remapSymbols );
276
277 if( ADVANCED_CFG::GetCfg().m_ShowRepairSchematic )
278 toolsMenu->Add( EE_ACTIONS::repairSchematic );
279
280 toolsMenu->AppendSeparator();
281 toolsMenu->Add( EE_ACTIONS::editSymbolFields );
283
284 toolsMenu->AppendSeparator();
285 toolsMenu->Add( EE_ACTIONS::annotate );
286
287 toolsMenu->AppendSeparator();
288 toolsMenu->Add( EE_ACTIONS::assignFootprints );
289 toolsMenu->Add( EE_ACTIONS::generateBOM );
290
291 toolsMenu->AppendSeparator();
292 update = toolsMenu->Add( ACTIONS::updateSchematicFromPcb );
293 update->Enable( !Kiface().IsSingle() );
294
295 //-- Preferences menu -----------------------------------------------
296 //
297 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
298
299 prefsMenu->Add( ACTIONS::configurePaths );
300 prefsMenu->Add( ACTIONS::showSymbolLibTable );
301
302 // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
303 // Mac, and it needs the wxID_PREFERENCES id to find it.
304 prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
305 _( "Show preferences for all open tools" ),
306 wxID_PREFERENCES,
308
309 prefsMenu->AppendSeparator();
310 AddMenuLanguageList( prefsMenu, selTool );
311
312
313 //-- Menubar -------------------------------------------------------------
314 //
315 menuBar->Append( fileMenu, _( "&File" ) );
316 menuBar->Append( editMenu, _( "&Edit" ) );
317 menuBar->Append( viewMenu, _( "&View" ) );
318 menuBar->Append( placeMenu, _( "&Place" ) );
319 menuBar->Append( inspectMenu, _( "&Inspect" ) );
320 menuBar->Append( toolsMenu, _( "&Tools" ) );
321 menuBar->Append( prefsMenu, _( "P&references" ) );
322 AddStandardHelpMenu( menuBar );
323
324 SetMenuBar( menuBar );
325 delete oldMenuBar;
326}
@ import_document
@ add_document
static TOOL_ACTION gridProperties
Definition: actions.h:144
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:167
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION excludeMarker
Definition: actions.h:89
static TOOL_ACTION nextMarker
Definition: actions.h:88
static TOOL_ACTION zoomRedraw
Definition: actions.h:92
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION showSymbolLibTable
Definition: actions.h:180
static TOOL_ACTION showSymbolEditor
Definition: actions.h:164
static TOOL_ACTION showSymbolBrowser
Definition: actions.h:163
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION findAndReplace
Definition: actions.h:79
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION prevMarker
Definition: actions.h:87
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:101
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:168
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomFitObjects
Definition: actions.h:99
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION configurePaths
Definition: actions.h:179
static TOOL_ACTION selectAll
Definition: actions.h:71
static TOOL_ACTION find
Definition: actions.h:78
void AddQuitOrClose(KIFACE_BASE *aKiface, wxString aAppname="")
Add either a standard Quit or Close item to the menu.
static constexpr bool CHECK
Definition: action_menu.h:189
ACTION_MENU * Clone() const
Create a deep, recursive copy of this ACTION_MENU.
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
static constexpr bool NORMAL
Definition: action_menu.h:188
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
FILE_HISTORY & GetFileHistory()
Get the frame's main file history.
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:173
static TOOL_ACTION repairSchematic
Definition: ee_actions.h:232
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:167
static TOOL_ACTION runERC
Definition: ee_actions.h:150
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:213
static TOOL_ACTION navigateForward
Definition: ee_actions.h:201
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:79
static TOOL_ACTION navigateBack
Definition: ee_actions.h:202
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:215
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:217
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:88
static TOOL_ACTION drawWire
Definition: ee_actions.h:81
static TOOL_ACTION drawCircle
Definition: ee_actions.h:96
static TOOL_ACTION drawBus
Definition: ee_actions.h:82
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:216
static TOOL_ACTION placePower
Definition: ee_actions.h:80
static TOOL_ACTION drawLines
Definition: ee_actions.h:98
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:92
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:174
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:160
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:166
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:214
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION exportSymbolsToLibrary
Definition: ee_actions.h:177
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:228
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:152
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:94
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:163
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:95
static TOOL_ACTION annotate
Definition: ee_actions.h:151
static TOOL_ACTION placeImage
Definition: ee_actions.h:99
static TOOL_ACTION updateSymbols
Definition: ee_actions.h:157
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:205
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:93
static TOOL_ACTION changeSymbols
Definition: ee_actions.h:156
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION drawSheet
Definition: ee_actions.h:91
static TOOL_ACTION runSimulation
Definition: ee_actions.h:244
static TOOL_ACTION navigateNext
Definition: ee_actions.h:204
static TOOL_ACTION navigateUp
Definition: ee_actions.h:200
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:153
static TOOL_ACTION placeLabel
Definition: ee_actions.h:87
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
static TOOL_ACTION editTextAndGraphics
Definition: ee_actions.h:210
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:172
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:86
static TOOL_ACTION placeJunction
Definition: ee_actions.h:85
static TOOL_ACTION generateBOM
Definition: ee_actions.h:175
static TOOL_ACTION navigatePrevious
Definition: ee_actions.h:203
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:84
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:162
static TOOL_ACTION exportSymbolsToNewLibrary
Definition: ee_actions.h:178
This class implements a file history object to store a list of files, that can then be added to a men...
Definition: file_history.h:43
static SELECTION_CONDITION FileHistoryNotEmpty(const FILE_HISTORY &aHistory)
Create a SELECTION_CONDITION that can be used to enable a menu item when the file history has items i...
void UpdateClearText(wxMenu *aMenu, wxString aClearText)
Update the text displayed on the menu item that clears the entire menu.
void AddFilesToMenu() override
Add the files to all registered menus.
Definition: file_history.h:98
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:46
@ ID_IMPORT_NON_KICAD_SCH
Definition: eeschema_id.h:63
@ ID_APPEND_PROJECT
Definition: id.h:74
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)

References _, ACTION_MENU::Add(), add_document, FILE_HISTORY::AddFilesToMenu(), AddMenuLanguageList(), ACTION_MENU::AddQuitOrClose(), EDA_BASE_FRAME::AddStandardHelpMenu(), EE_ACTIONS::annotate, EE_ACTIONS::assignFootprints, EE_ACTIONS::changeSymbols, ACTION_MENU::CHECK, ACTION_MENU::Clone(), ACTIONS::configurePaths, ACTIONS::copy, ACTIONS::cut, ACTIONS::deleteTool, ACTIONS::doDelete, ACTIONS::doNew, EE_ACTIONS::drawArc, EE_ACTIONS::drawBus, EE_ACTIONS::drawCircle, EE_ACTIONS::drawLines, EE_ACTIONS::drawRectangle, EE_ACTIONS::drawSheet, EE_ACTIONS::drawSheetOnClipboard, EE_ACTIONS::drawTextBox, EE_ACTIONS::drawWire, EE_ACTIONS::editPageNumber, EE_ACTIONS::editSymbolFields, EE_ACTIONS::editSymbolLibraryLinks, EE_ACTIONS::editTextAndGraphics, ACTION_CONDITIONS::Enable(), ACTIONS::excludeMarker, export_file, EE_ACTIONS::exportNetlist, EE_ACTIONS::exportSymbolsToLibrary, EE_ACTIONS::exportSymbolsToNewLibrary, FILE_HISTORY::FileHistoryNotEmpty(), ACTIONS::find, ACTIONS::findAndReplace, EE_ACTIONS::generateBOM, ADVANCED_CFG::GetCfg(), EDA_BASE_FRAME::GetFileHistory(), TOOL_MANAGER::GetTool(), ACTIONS::gridProperties, ID_APPEND_PROJECT, ID_IMPORT_NON_KICAD_SCH, import, import_document, EE_ACTIONS::importFPAssignments, EE_ACTIONS::importSheetPin, ACTIONS::inchesUnits, Kiface(), TOOLS_HOLDER::m_toolManager, ACTIONS::millimetersUnits, ACTIONS::milsUnits, EE_ACTIONS::navigateBack, EE_ACTIONS::navigateForward, EE_ACTIONS::navigateNext, EE_ACTIONS::navigatePrevious, EE_ACTIONS::navigateUp, ACTIONS::nextMarker, ACTION_MENU::NORMAL, ACTIONS::open, ACTIONS::pageSettings, ACTIONS::paste, ACTIONS::pasteSpecial, EE_ACTIONS::placeBusWireEntry, EE_ACTIONS::placeClassLabel, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeImage, EE_ACTIONS::placeJunction, EE_ACTIONS::placeLabel, EE_ACTIONS::placeNoConnect, EE_ACTIONS::placePower, EE_ACTIONS::placeSchematicText, EE_ACTIONS::placeSymbol, ACTIONS::plot, preference, ACTIONS::prevMarker, ACTIONS::print, recent, ACTIONS::redo, EDA_BASE_FRAME::RegisterUIUpdateHandler(), EE_ACTIONS::remapSymbols, EE_ACTIONS::repairSchematic, EE_ACTIONS::rescueSymbols, ACTIONS::revert, EE_ACTIONS::runERC, EE_ACTIONS::runSimulation, ACTIONS::save, ACTIONS::saveAs, EE_ACTIONS::saveCurrSheetCopyAs, EE_ACTIONS::schematicSetup, ACTIONS::selectAll, ACTION_MENU::SetIcon(), ACTION_MENU::SetTitle(), EE_ACTIONS::showHierarchy, EE_ACTIONS::showPcbNew, ACTIONS::showSymbolBrowser, ACTIONS::showSymbolEditor, ACTIONS::showSymbolLibTable, ACTIONS::toggleCursorStyle, EE_ACTIONS::toggleERCErrors, EE_ACTIONS::toggleERCExclusions, EE_ACTIONS::toggleERCWarnings, ACTIONS::toggleGrid, EE_ACTIONS::toggleHiddenFields, EE_ACTIONS::toggleHiddenPins, ACTIONS::undo, unit_mm, FILE_HISTORY::UpdateClearText(), ACTIONS::updatePcbFromSchematic, ACTIONS::updateSchematicFromPcb, EE_ACTIONS::updateSymbols, ACTIONS::zoomFitObjects, ACTIONS::zoomFitScreen, ACTIONS::zoomInCenter, ACTIONS::zoomOutCenter, ACTIONS::zoomRedraw, and ACTIONS::zoomTool.

◆ DoWithAcceptedFiles()

void EDA_BASE_FRAME::DoWithAcceptedFiles ( )
protectedvirtualinherited

Execute action on accepted dropped file.

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

Reimplemented in GERBVIEW_FRAME, KICAD_MANAGER_FRAME, and PL_EDITOR_FRAME.

Definition at line 1178 of file eda_base_frame.cpp.

1179{
1180 for( const wxFileName& file : m_AcceptedFiles )
1181 {
1182 wxString fn = file.GetFullPath();
1183 m_toolManager->RunAction( *m_acceptedExts.at( file.GetExt() ), true, &fn );
1184 }
1185}
std::vector< wxFileName > m_AcceptedFiles

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

Referenced by EDA_BASE_FRAME::OnDropFiles().

◆ DrawCurrentSheetToClipboard()

void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard ( )

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

Definition at line 543 of file sheet.cpp.

544{
545 wxRect DrawArea;
546 BASE_SCREEN* screen = GetScreen();
547
548 DrawArea.SetSize( GetPageSizeIU() );
549
550 // Calculate a reasonable dc size, in pixels, and the dc scale to fit
551 // the drawings into the dc size
552 // scale is the ratio resolution (in PPI) / internal units
553 double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
554 double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS;
555 double scale = ppi / inch2Iu;
556
557 wxSize dcsize = DrawArea.GetSize();
558
559 int maxdim = std::max( dcsize.x, dcsize.y );
560
561 // the max size in pixels of the bitmap used to build the sheet copy
562 const int maxbitmapsize = 5600;
563
564 while( int( maxdim * scale ) > maxbitmapsize )
565 {
566 ppi = ppi / 1.5;
567 scale = ppi / inch2Iu;
568 }
569
570 dcsize.x *= scale;
571 dcsize.y *= scale;
572
573 // Set draw offset, zoom... to values needed to draw in the memory DC
574 // after saving initial values:
575 VECTOR2I tmp_startvisu = screen->m_StartVisu;
576 VECTOR2I old_org = screen->m_DrawOrg;
577 screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
578 screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
579
580 wxMemoryDC dc;
581 wxBitmap image( dcsize );
582 dc.SelectObject( image );
583 dc.Clear();
584
585 GRResetPenAndBrush( &dc );
586 GRForceBlackPen( false );
587 dc.SetUserScale( scale, scale );
588
590
591 cfg->SetPrintDC( &dc );
592
593 // Init the color of the layer actually used to print the drawing sheet:
595
596 cfg->SetDefaultFont( eeconfig()->m_Appearance.default_font );
597
598 PrintPage( cfg );
599
600 {
601 wxLogNull doNotLog; // disable logging of failed clipboard actions
602
603 if( wxTheClipboard->Open() )
604 {
605 // This data objects are held by the clipboard, so do not delete them in the app.
606 wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
607 wxTheClipboard->SetData( clipbrd_data );
608 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
609 wxTheClipboard->Close();
610 }
611 }
612
613 // Deselect Bitmap from DC in order to delete the MemoryDC
614 dc.SelectObject( wxNullBitmap );
615
616 GRForceBlackPen( false );
617
618 screen->m_StartVisu = tmp_startvisu;
619 screen->m_DrawOrg = old_org;
620}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
VECTOR2I m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:88
VECTOR2I m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:93
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetPrintDC(wxDC *aDC)
Store schematic specific render settings.
Definition: sch_painter.h:71
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:150
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:72
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:217
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:382
const int scale
const double IU_PER_MILS
Definition: base_units.h:78

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

Referenced by SCH_EDITOR_CONTROL::DrawSheetOnClipboard().

◆ EditSheetProperties()

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

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

When aSheet is a new sheet:

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

When aSheet is an existing sheet:

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

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

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

Definition at line 527 of file sheet.cpp.

529{
530 if( aSheet == nullptr || aHierarchy == nullptr )
531 return false;
532
533 // Get the new texts
534 DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
535
536 if( dlg.ShowModal() == wxID_CANCEL )
537 return false;
538
539 return true;
540}

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

◆ eeconfig()

EESCHEMA_SETTINGS * SCH_BASE_FRAME::eeconfig ( ) const
inherited

Definition at line 131 of file sch_base_frame.cpp.

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

References EDA_BASE_FRAME::config().

Referenced by SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), AllowCaseSensitiveFileNameClashes(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDITOR_CONTROL::ChangeLineMode(), EE_SELECTION_TOOL::CollectHits(), DIALOG_BOM::DIALOG_BOM(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), DrawCurrentSheetToClipboard(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::editFieldText(), ExecuteRemoteCommand(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), GetSchematicJunctionSize(), GetShowAllPins(), EE_SELECTION_TOOL::GuessSelectionCandidates(), DIALOG_BOM::installGeneratorsList(), KiwayMailIn(), SCH_EDITOR_CONDITIONS::lineModeFunc(), LoadSettings(), EE_SELECTION_TOOL::Main(), SCH_EDITOR_CONTROL::NextLineMode(), DIALOG_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_TEXT_PROPERTIES::onBorderChecked(), DIALOG_PRINT_USING_PRINTER::OnOutputChoice(), OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_PRINTOUT::PrintPage(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), DIALOG_PRINT_USING_PRINTER::SavePrintOptions(), SaveSettings(), EE_SELECTION_TOOL::Selectable(), SelectUnit(), setupUIConditions(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), EE_SELECTION_TOOL::SyncSelection(), SCH_EDITOR_CONTROL::ToggleAnnotateAuto(), SCH_EDITOR_CONTROL::ToggleAnnotateRecursive(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), ToggleSchematicHierarchy(), DIALOG_PRINT_USING_PRINTER::TransferDataToWindow(), and DIALOG_BOM::~DIALOG_BOM().

◆ ensureWindowIsOnScreen()

void EDA_BASE_FRAME::ensureWindowIsOnScreen ( )
protectedinherited

Definition at line 659 of file eda_base_frame.cpp.

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

References EDA_BASE_FRAME::GetWindowSize(), and traceDisplayLocation.

Referenced by EDA_BASE_FRAME::OnSize().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

◆ ExecuteRemoteCommand()

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

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

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

Valid commands are:

  • $PART: "reference" Put cursor on symbol.
  • $PART: "reference" $REF: "ref" Put cursor on symbol reference.
  • $PART: "reference" $VAL: "value" Put cursor on symbol value.
  • $PART: "reference" $PAD: "pin name" Put cursor on the symbol pin.
  • $NET: