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 KIWAY_HOLDER

Public Types

typedef std::vector< COMPONENT_SELECTIONHISTORY_LIST
 
enum  HOLDER_TYPE { DIALOG, FRAME, PANEL, SCREEN }
 

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...
 
void OnCloseWindow (wxCloseEvent &Event)
 
bool GetForceHVLines () const
 
void SetForceHVLines (bool aForceHVdirection)
 
bool GetShowAllPins () const override
 Allow some frames to show/hide hidden pins. More...
 
void SetShowAllPins (bool aEnable)
 
bool GetSelectPinSelectSymbol () const override
 Allow some frames to select the parent symbol when trying to select a pin. More...
 
void SetSelectPinSelectSymbol (bool aEnable)
 
bool GetShowFootprintPreviews () const
 
void SetShowFootprintPreviews (bool aEnable)
 
bool GetNavigatorStaysOpen () const
 
void SetNavigatorStaysOpen (bool aEnable)
 
bool GetAutoplaceFields () const
 
void SetAutoplaceFields (bool aEnable)
 
bool GetAutoplaceAlign () const
 
void SetAutoplaceAlign (bool aEnable)
 
bool GetAutoplaceJustify () const
 
void SetAutoplaceJustify (bool aEnable)
 
const wxString & GetNetListFormatName () const
 
void SetNetListFormatName (const wxString &aFormat)
 
bool GetSpiceAjustPassiveValues () const
 
void SetSpiceAdjustPassiveValues (bool aEnable)
 
const wxString & GetPlotDirectoryName () const
 accessor to the destination directory to use when generating plot files. More...
 
void SetPlotDirectoryName (const wxString &aDirName)
 
void AddFormattingParameters (std::vector< PARAM_CFG * > &params)
 
std::vector< PARAM_CFG * > & GetProjectFileParameters ()
 Return the project file parameter list for Eeschema. More...
 
void SaveProjectSettings () override
 Save changes to the project settings to the project (.pro) file. More...
 
bool LoadProjectFile ()
 Loads the KiCad project file (*.pro) settings specific to Eeschema. More...
 
void DoShowSchematicSetupDialog (const wxString &aInitialPage=wxEmptyString, const wxString &aInitialParentPage=wxEmptyString)
 
void AddTemplateFieldName (const TEMPLATE_FIELDNAME &aFieldName, bool aGlobal)
 Insert or append a wanted symbol field name into the field names template. More...
 
void DeleteAllTemplateFieldNames (bool aGlobal)
 Remove all global or project fieldname templates. More...
 
void LoadSettings (APP_SETTINGS_BASE *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (APP_SETTINGS_BASE *aCfg) override
 Saves common frame parameters to a configuration data file. More...
 
void CreateScreens ()
 
void ReCreateHToolbar () override
 
void ReCreateVToolbar () override
 
void ReCreateOptToolbar () override
 
void ReCreateMenuBar () override
 Recreates the menu bar. More...
 
bool IsContentModified () override
 Get if the current schematic has been modified but not saved. More...
 
void OnModify () override
 Must be called after a schematic change in order to set the "modify" flag of the current screen and update the date in frame reference. More...
 
wxString GetScreenDesc () const override
 Return a human-readable description of the current screen. More...
 
void ExecuteRemoteCommand (const char *cmdline) override
 Execute a remote command send by Pcbnew via a socket, port KICAD_SCH_PORT_SERVICE_NUMBER (currently 4243) this is a virtual function called by EDA_DRAW_FRAME::OnSockRequest(). More...
 
void KiwayMailIn (KIWAY_EXPRESS &aEvent) override
 Function KiwayMailIn receives KIWAY_EXPRESS messages from other players. More...
 
void AddItemToScreenAndUndoList (SCH_ITEM *aItem, bool aUndoAppend=false)
 Add an item to the schematic and adds the changes to the undo/redo container. More...
 
void ShowFindReplaceDialog (bool aReplace)
 Run the Find or Find & Replace dialog. More...
 
void UpdateHierarchyNavigator (bool aForceUpdate=false)
 Run the Hierarchy Navigator dialog. More...
 
HIERARCHY_NAVIG_DLGFindHierarchyNavigator ()
 
void ShowFindReplaceStatus (const wxString &aMsg)
 
void ClearFindReplaceStatus ()
 
wxFindReplaceData * GetFindReplaceData ()
 Get the find criteria (as set by the dialog). More...
 
void OnFindDialogClose ()
 Notification that the Find dialog has closed. More...
 
bool BreakSegment (SCH_LINE *aSegment, const wxPoint &aPoint, SCH_LINE **aNewSegment=NULL, SCH_SCREEN *aScreen=nullptr)
 Breaks a single segment into two at the specified point. More...
 
bool BreakSegments (const wxPoint &aPoint, SCH_SCREEN *aScreen=nullptr)
 Checks 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)
 Tests all junctions and bus entries in the schematic for intersections with wires and buses and breaks any intersections into multiple segments. More...
 
bool TestDanglingEnds ()
 Test all of the connectable objects in the schematic for unused connection points. More...
 
void SendMessageToPCBNEW (EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
 Send a message to Pcbnew via a socket connection. More...
 
void SendCrossProbeNetName (const wxString &aNetName)
 Sends a net name to pcbnew for highlighting. More...
 
void SendCrossProbeClearHighlight ()
 Tells PcbNew to clear the existing highlighted net, if one exists. More...
 
const wxString & GetSelectedNetName () const
 
void SetSelectedNetName (const wxString &aNetName)
 
NETLIST_OBJECT_LISTBuildNetListBase (bool updateStatusText=true)
 Create a flat list which stores all connected objects. More...
 
NETLIST_OBJECT_LISTCreateNetlist (bool aSilent=false, bool aSilentAnnotate=false)
 Create a netlist for the current schematic. More...
 
bool WriteNetListFile (NETLIST_OBJECT_LIST *aConnectedItemsList, int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL)
 Create a netlist file. More...
 
void DeleteAnnotation (bool aCurrentSheetOnly)
 Clear the current component annotation. More...
 
void AnnotateComponents (bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption, ANNOTATE_OPTION_T aAlgoOption, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits, REPORTER &aReporter)
 Annotate the components in the schematic that are not currently annotated. More...
 
int CheckAnnotate (REPORTER &aReporter, bool aOneSheetOnly)
 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 ()
 
void SetCurrentSheet (const SCH_SHEET_PATH &aSheet)
 
void HardRedraw () override
 Rebuild the GAL and redraw the screen. More...
 
void DisplayCurrentSheet ()
 Draw the current sheet on the display. More...
 
void DrawCurrentSheetToClipboard ()
 Use the wxWidgets print code to draw an image of the current sheet onto the clipboard. More...
 
void OnPageSettingsChange () override
 Called when modifying the page settings. More...
 
wxString GetUniqueFilenameForCurrentSheet ()
 
void SetSheetNumberAndCount ()
 Set the m_ScreenNumber and m_NumberOfScreens members for screens. More...
 
void Print ()
 Show the print dialog. More...
 
wxPageSetupDialogData & GetPageSetupData ()
 
bool GetPrintMonochrome ()
 
void SetPrintMonochrome (bool aMonochrome)
 
bool GetPrintSheetReference ()
 
void SetPrintSheetReference (bool aShow)
 
void PlotSchematic ()
 
void NewProject ()
 
void LoadProject ()
 
void Save_File (bool doSaveAs=false)
 
bool SaveProject ()
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList. More...
 
bool AppendSchematic ()
 Import a KiCad schematic into the current sheet. More...
 
bool SaveEEFile (SCH_SCREEN *aScreen, bool aSaveUnderNewName=false, bool aCreateBackupFile=CREATE_BACKUP_FILE)
 Save aScreen to a schematic file. More...
 
bool AskToSaveChanges ()
 Checks if any of the screens has unsaved changes and asks the user whether to save or drop them. More...
 
SCH_JUNCTIONAddJunction (const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
 
SCH_TEXTGetNextNewText ()
 Gets the next queued text item. More...
 
SCH_TEXTCreateNewText (int aType)
 
bool SchematicCleanUp (SCH_SCREEN *aScreen=nullptr)
 Performs routine schematic cleaning including breaking wire and buses and deleting identical objects superimposed on top of each other. More...
 
bool TrimWire (const wxPoint &aStart, const wxPoint &aEnd)
 If any single wire passes through both points, remove the portion between the two points, potentially splitting the wire into two. More...
 
void GetSchematicConnections (std::vector< wxPoint > &aConnections)
 Collects a unique list of all possible connection points in the schematic. More...
 
void OnOpenPcbnew (wxCommandEvent &event)
 
void OnOpenCvpcb (wxCommandEvent &event)
 
void OnRescueProject (wxCommandEvent &event)
 
void OnRemapSymbols (wxCommandEvent &aEvent)
 
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...
 
void ConvertTextType (SCH_TEXT *aText, KICAD_T aNewType)
 Change a text type to another one. 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...
 
SCH_SHEET_PINCreateSheetPin (SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
 Create a new SCH_SHEET_PIN object and add it to aSheet at the current cursor position. More...
 
SCH_HIERLABELImportHierLabel (SCH_SHEET *aSheet)
 Import a hierarchical label with no attached sheet pin. More...
 
void DeleteJunction (SCH_ITEM *aItem, bool aAppend=false)
 Removes a given junction and heals any wire segments under the junction. More...
 
int GetLabelIncrement () const
 
void ConvertPart (SCH_COMPONENT *aComponent)
 
void SelectUnit (SCH_COMPONENT *aComponent, int aUnit)
 
void SaveCopyInUndoList (SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
 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_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
 Create a new entry in undo list of commands. More...
 
void PutDataInPreviousState (PICKED_ITEMS_LIST *aList, bool aRedoCommand)
 Restore an undo or redo command to put data pointed by aList in the previous state. More...
 
void SaveCopyForRepeatItem (SCH_ITEM *aItem)
 Clone aItem and owns that clone in this container. More...
 
SCH_ITEMGetRepeatItem () const
 Return the item which is to be repeated with the insert key. More...
 
void RollbackSchematicFromUndo ()
 Performs 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 components used in the current schematic. More...
 
bool rescueProject (RESCUER &aRescuer, bool aRunningOnDemand)
 Perform rescue operations to recover old projects from before certain changes were made. More...
 
bool RescueLegacyProject (bool aRunningOnDemand)
 
bool RescueSymbolLibTableProject (bool aRunningOnDemand)
 
virtual void PrintPage (wxDC *aDC) 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)
 Generates the connection data for the entire schematic hierarchy. More...
 
void InstallPreferences (PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
 Allows Eeschema to install its preferences panels into the preferences dialog. More...
 
void CommonSettingsChanged (bool aEnvVarsChanged) override
 Called after the preferences dialog is run. More...
 
void ShowChangedLanguage () override
 Redraw the menus and what not in current language. More...
 
void SyncToolbars () override
 Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state. More...
 
void SetScreen (BASE_SCREEN *aScreen) override
 
const BOX2I GetDocumentExtents () const override
 
void FixupJunctions ()
 
void createCanvas ()
 
SCH_DRAW_PANELGetCanvas () const override
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
KIGFX::SCH_RENDER_SETTINGSGetRenderSettings ()
 
bool GetShowElectricalType ()
 Allow some frames to show/hide pin electrical type names. More...
 
void SetShowElectricalType (bool aShow)
 
const wxPoint GetRepeatStep () const
 
void SetRepeatStep (const wxPoint &aStep)
 Sets the repeat step value for repeat command. More...
 
int GetRepeatDeltaLabel () const
 
void SetRepeatDeltaLabel (int aDelta)
 Sets the repeat delta label value for repeat command. More...
 
const bool GetRepeatComponent ()
 
void SetRepeatComponent (bool aRepeat)
 If true, keep placing new copies of the same symbol on each click. More...
 
const bool GetUseAllUnits ()
 
void SetUseAllUnits (bool aUseAll)
 Sets whether to utilize all units of a component when placing. More...
 
const wxString GetZoomLevelIndicator () const override
 Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level indicator in dialogs. More...
 
void SetDragActionIsMove (bool aValue)
 
bool GetDragActionIsMove () const
 
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 wxPointGetAuxOrigin () const override
 Return the origin of the axis used for plotting and various exports. More...
 
void SetAuxOrigin (const wxPoint &aPosition) override
 
const wxPointGetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const wxPoint &aPoint) override
 
void OnGridSettings (wxCommandEvent &aEvent) override
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
void UpdateStatusBar () override
 Update the status bar information. More...
 
COMPONENT_SELECTION SelectCompFromLibTree (const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
 Function SelectComponentFromLib Calls the library viewer to select component to import into schematic. More...
 
const TEMPLATE_FIELDNAMESGetTemplateFieldNames ()
 Return a template field names list for read only access. More...
 
const TEMPLATE_FIELDNAMESGetTemplateFieldNames (bool aGlobal)
 Return a specific template field names list (global or project) for read only access. More...
 
const TEMPLATE_FIELDNAMEGetTemplateFieldName (const wxString &aName)
 Search for aName in the the template field name list. More...
 
LIB_PARTGetLibPart (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
 Load symbol from symbol library table. More...
 
LIB_PARTGetFlattenedLibPart (const LIB_ID &aLibId, bool aShowErrorMsg=false)
 
COMPONENT_SELECTION SelectComponentFromLibBrowser (wxTopLevelWindow *aParent, const SCHLIB_FILTER *aFilter, const LIB_ID &aPreselectedLibid, int aUnit, int aConvert)
 Function SelectComponentFromLibBrowser Calls the library viewer to select component to import into schematic. More...
 
virtual void RedrawScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
virtual void CenterScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
void FocusOnItem (SCH_ITEM *aItem)
 
void AddToScreen (EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
 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=nullptr)
 Remove an item from the screen (and view) aScreen is the screen the item is located on, if not the current screen. More...
 
void RefreshItem (EDA_ITEM *aItem, bool isAddOrDelete=false)
 Mark an item for refresh. More...
 
void RefreshSelection ()
 Mark selected items for refresh. More...
 
void SyncView ()
 Mark all items for refresh. More...
 
COLOR4D GetLayerColor (SCH_LAYER_ID aLayer)
 Helper to retrieve a layer color from the global color settings. More...
 
COLOR_SETTINGSGetColorSettings () override
 Returns a pointer to the active color theme settings. More...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
wxArrayString & GetFindHistoryList ()
 
bool GetShowPolarCoords () const
 For those frames that support polar coordinates. More...
 
void SetShowPolarCoords (bool aShow)
 
int GetLastGridSizeId () const
 
void SetLastGridSizeId (int aId)
 
wxPoint GetNearestGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
virtual COLOR4D GetDrawBgColor () const
 
virtual void SetDrawBgColor (COLOR4D aColor)
 
bool ShowPageLimits () const
 
void SetShowPageLimits (bool aShow)
 
double GetZoomLevelCoeff () const
 Return the coefficient to convert internal display scale factor to zoom level. More...
 
void EraseMsgBox ()
 
virtual void ReCreateAuxiliaryToolbar ()
 
virtual bool IsGridVisible () const
 
virtual void SetGridVisibility (bool aVisible)
 
virtual COLOR4D GetGridColor ()
 
virtual void SetGridColor (COLOR4D aColor)
 
virtual void OnSelectGrid (wxCommandEvent &event)
 Command event handler for selecting grid sizes. More...
 
virtual void OnSelectZoom (wxCommandEvent &event)
 Set the zoom factor when selected by the zoom list box in the main tool bar. More...
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 
virtual void OnSize (wxSizeEvent &event)
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
virtual void Zoom_Automatique (bool aWarpPointer)
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void FocusOnLocation (const wxPoint &aPos)
 Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor) at a given coordinate and reframes the drawing if the requested point is out of view or if center on location is requested. More...
 
double GetZoom ()
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Function CreateBasicMenu. More...
 
void PrintWorkSheet (wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString, COLOR4D aColor=COLOR4D::UNSPECIFIED)
 Prints the page layout with the frame and the basic inscriptions. More...
 
void DisplayToolMsg (const wxString &msg) override
 
void DisplayUnitsMsg ()
 Display current unit pane on the status bar. More...
 
void DisplayGridMsg ()
 Display current grid pane on the status bar. More...
 
void CreateServer (int service, bool local=true)
 
void OnSockRequest (wxSocketEvent &evt)
 
void OnSockRequestServer (wxSocketEvent &evt)
 
void AppendMsgPanel (const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=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)
 
virtual void UpdateMsgPanel ()
 Redraw the message panel. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting ()
 Returns the canvas type stored in the application settings. More...
 
virtual void ActivateGalCanvas ()
 Use to start up the GAL drawing canvas. More...
 
virtual void SwitchCanvas (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Changes the current rendering backend. More...
 
void SetCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Return a reference to the gal rendering options used by GAL for rendering. More...
 
void RefreshCanvas () override
 Notification to refresh the drawing canvas (if any). More...
 
void RecreateToolbars ()
 Rebuild all toolbars, and update the checked state of ckeck tools. More...
 
virtual bool ShowModal (wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
 Function ShowModal puts up 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 ()
 
void SetModal (bool aIsModal)
 
bool IsDismissed ()
 Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been dismissed yet with DismissModal(). More...
 
void DismissModal (bool aRetVal, const wxString &aResult=wxEmptyString)
 
EDA_UNITS GetUserUnits () const
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS aUnits)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
SETTINGS_MANAGERGetSettingsManager () const
 
virtual int GetSeverity (int aErrorCode) const
 
TOOL_MANAGERGetToolManager () const
 Return the MVC controller. More...
 
virtual void PushTool (const std::string &actionName)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const std::string &actionName)
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
bool GetDoImmediateActions () const
 Indicates that hotkeys should perform an immediate action even if another tool is currently active. More...
 
bool GetDragSelects () const
 Indicates that a drag should draw a selection rectangle, even when started over an item. More...
 
bool GetMoveWarpsCursor () const
 Indicates that a move operation should warp the mouse pointer to the origin of the move object. More...
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &event)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuOpen (wxMenuEvent &event)
 Workaround some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) 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)
 
void PrintMsg (const wxString &text)
 
virtual APP_SETTINGS_BASEconfig ()
 Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
void LoadWindowSettings (WINDOW_SETTINGS *aCfg)
 Loads window settings from the given settings object Normally called by LoadSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window. More...
 
void SaveWindowSettings (WINDOW_SETTINGS *aCfg)
 Saves window settings to the given settings object Normally called by SaveSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window. More...
 
virtual WINDOW_SETTINGSGetWindowSettings (APP_SETTINGS_BASE *aCfg)
 Returns a pointer to the window settings for this frame. More...
 
wxString ConfigBaseName ()
 
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=NULL)
 Fetches the file name from the file history list. More...
 
void ClearFileHistory (FILE_HISTORY *aFileHistory=NULL)
 Removes all files from the file history. More...
 
void UpdateFileHistory (const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
 Update the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
void AddStandardHelpMenu (wxMenuBar *aMenuBar)
 Adds the standard KiCad help menu to the menubar. More...
 
bool IsWritable (const wxFileName &aFileName)
 Checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName)
 Check if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
const wxString & GetAboutTitle () const
 
void SetShutdownBlockReason (const wxString &reason)
 Sets the block reason why the window/application is preventing OS shutdown. More...
 
void RemoveShutdownBlockReason ()
 Removes any shutdown block reason set. More...
 
bool SupportsShutdownBlockReason ()
 Whether or not the window supports setting a shutdown block reason. More...
 
HOLDER_TYPE GetType ()
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Protected Member Functions

const wxSize & GetLastSheetPinTextSize ()
 Initializing accessor for the pin text size. More...
 
bool doAutoSave () override
 Save the schematic files that have been modified and not yet saved. More...
 
bool isAutoSaveRequired () const override
 Returns true if the schematic has been modified. More...
 
bool prepareForNetlist ()
 Verify that annotation is complete so that a proper netlist is even possible. More...
 
void sendNetlistToCvpcb ()
 Send the kicad netlist over to CVPCB. More...
 
bool saveSymbolLibTables (bool aGlobal, bool aProject)
 Saves 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 InitExitKey ()
 Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id. More...
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 Function language_change is an event handler called on a language menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 

Static Protected Member Functions

static wxString GetBackupSuffix ()
 
static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

TEMPLATES m_templateFieldNames
 
wxPoint m_repeatStep
 
int m_repeatDeltaLabel
 
bool m_showPinElectricalTypeName
 
bool m_dragActionIsMove
 
bool m_repeatComponent
 
bool m_useAllUnits
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 prevents opening same file multiple times. More...
 
int m_LastGridSizeId
 
bool m_drawGrid
 
bool m_showPageLimits
 
COLOR4D m_gridColor
 
COLOR4D m_drawBgColor
 
double m_zoomLevelCoeff
 
int m_UndoRedoCountMax
 
bool m_PolarCoords
 
TOOL_DISPATCHERm_toolDispatcher
 
bool m_showBorderAndTitleBlock
 
long m_firstRunDialogSetting
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
ACTION_TOOLBARm_mainToolBar
 
ACTION_TOOLBARm_auxiliaryToolBar
 
ACTION_TOOLBARm_drawToolBar
 
ACTION_TOOLBARm_optionsToolBar
 
wxFindReplaceData * m_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_MsgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
 The current canvas type. More...
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
FRAME_T m_Ident
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_AboutTitle
 
wxAuiManager m_auimgr
 
wxString m_configName
 
SETTINGS_MANAGERm_settingsManager
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
bool m_dragSelects
 
bool m_moveWarpsCursor
 
bool m_hasAutoSave
 
bool m_autoSaveState
 
int m_autoSaveInterval
 
wxTimer * m_autoSaveTimer
 
wxString m_perspective
 
wxString m_mruPath
 
EDA_UNITS m_userUnits
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private Member Functions

void setupTools ()
 
void OnExit (wxCommandEvent &event)
 
void OnLoadFile (wxCommandEvent &event)
 
void OnAppendProject (wxCommandEvent &event)
 
void OnImportProject (wxCommandEvent &event)
 
void OnClearFileHistory (wxCommandEvent &aEvent)
 
void UpdateTitle ()
 Set the main window title bar text. More...
 
bool checkForNoFullyDefinedLibIds (SCH_SHEET *aSheet)
 Verify that the symbol library links aSheet and all of it's 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...
 

Private Attributes

wxString m_SelectedNetName
 
std::vector< PARAM_CFG * > m_projectFileParams
 
std::vector< PARAM_CFG * > m_configSettings
 
wxPageSetupDialogData m_pageSetupData
 
bool m_printMonochrome
 Print monochrome instead of grey scale. More...
 
bool m_printSheetReference
 
SCH_ITEMm_item_to_repeat
 Last item to insert by the repeat command. More...
 
int m_repeatLabelDelta
 Repeat label number increment step. 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...
 
bool m_forceHVLines
 force H or V directions for wires, bus, line More...
 
bool m_autoplaceFields
 automatically place component fields More...
 
bool m_autoplaceJustify
 allow autoplace to change justification More...
 
bool m_autoplaceAlign
 align autoplaced fields to the grid More...
 
bool m_footprintPreview
 whether to show footprint previews More...
 
bool m_navigatorStaysOpen
 whether to keep Navigator open More...
 
bool m_showIllegalSymbolLibDialog
 
bool m_showSheetFileNameCaseSensitivityDlg
 
DIALOG_SCH_FINDm_findReplaceDialog
 
STATUS_TEXT_POPUPm_findReplaceStatusPopup
 
bool m_showAllPins
 
bool m_selectPinSelectSymbol
 
wxString m_plotDirectoryName
 
wxString m_netListFormat
 
bool m_spiceAjustPassiveValues
 Use netcodes (net number) as net names when generating spice net lists. More...
 

Static Private Attributes

static PINSHEETLABEL_SHAPE m_lastSheetPinType = PINSHEETLABEL_SHAPE::PS_INPUT
 Last sheet pin type. More...
 
static wxSize m_lastSheetPinTextSize
 Last sheet pin text size. More...
 
static wxPoint m_lastSheetPinPosition
 Last sheet pin position. More...
 

Friends

class SCH_EDITOR_CONTROL
 

Detailed Description

Schematic editor (Eeschema) main window.

Definition at line 117 of file sch_edit_frame.h.

Member Typedef Documentation

◆ HISTORY_LIST

typedef std::vector<COMPONENT_SELECTION> SCH_BASE_FRAME::HISTORY_LIST
inherited

Definition at line 216 of file sch_base_frame.h.

Member Enumeration Documentation

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 
SCREEN 

Definition at line 42 of file kiway_holder.h.

Constructor & Destructor Documentation

◆ SCH_EDIT_FRAME()

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

Definition at line 210 of file sch_edit_frame.cpp.

210  :
211  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
212  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
213  m_item_to_repeat( nullptr )
214 {
216  g_ConnectionGraph = new CONNECTION_GRAPH( this );
217  g_ErcSettings = new ERC_SETTINGS();
218 
219  m_showBorderAndTitleBlock = true; // true to show sheet references
220  m_showAllPins = false;
222  m_printMonochrome = true;
223  m_printSheetReference = true;
224  SetShowPageLimits( true );
225  m_hasAutoSave = true;
228  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
229  m_AboutTitle = "Eeschema";
230 
231  m_findReplaceDialog = nullptr;
232  m_findReplaceStatusPopup = nullptr;
233 
234  SetForceHVLines( true );
236 
237  // Give an icon
238  wxIcon icon;
239  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
240  SetIcon( icon );
241 
242  // Initialize grid id to the default value (50 mils):
244 
245  LoadSettings( config() );
246 
247  CreateScreens();
248 
249  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
250 
251  setupTools();
252  ReCreateMenuBar();
256 
257  // Initialize common print setup dialog settings.
258  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
259  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
260  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
261  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
262 
263  m_auimgr.SetManagedWindow( this );
264 
265  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
266  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
267  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
268  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
269  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
270 
271  m_auimgr.Update();
272 
274 
275  // Init grid size and visibility
277 
278  if( GetCanvas() )
280 
281  InitExitKey();
282 
283  // Net list generator
285 
286  UpdateTitle();
287 
288  // Default shutdown reason until a file is loaded
289  SetShutdownBlockReason( _( "New schematic file is unsaved" ) );
290 }
STATUS_TEXT_POPUP * m_findReplaceStatusPopup
void DefaultExecFlags()
Reset the execution flags to defaults for external netlist and bom generators.
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
void SetShutdownBlockReason(const wxString &reason)
Sets the block reason why the window/application is preventing OS shutdown.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SetForceHVLines(bool aForceHVdirection)
ACTION_TOOLBAR * m_optionsToolBar
Calculates the connectivity of a schematic and generates netlists.
ERC_SETTINGS * g_ErcSettings
This also wants to live in the eventual SCHEMATIC object.
void ReCreateMenuBar() override
Recreates the menu bar.
virtual bool IsGridVisible() const
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
wxString m_AboutTitle
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
void SetSpiceAdjustPassiveValues(bool aEnable)
bool m_selectPinSelectSymbol
bool m_showSheetFileNameCaseSensitivityDlg
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
const BITMAP_OPAQUE icon_eeschema_xpm[1]
void ReCreateHToolbar() override
static TOOL_ACTION gridPreset
Definition: actions.h:134
#define SCH_EDIT_FRAME_NAME
wxPageSetupDialogData m_pageSetupData
EDA_MSG_PANEL * m_messagePanel
bool m_showBorderAndTitleBlock
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
DIALOG_SCH_FIND * m_findReplaceDialog
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Container for ERC settings.
Definition: erc_settings.h:37
SCH_SHEET_PATH.
bool m_printMonochrome
Print monochrome instead of grey scale.
void InitExitKey()
Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void ReCreateOptToolbar() override
bool m_showIllegalSymbolLibDialog
bool m_printSheetReference
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
#define _(s)
Definition: 3d_actions.cpp:33
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
void SetShowPageLimits(bool aShow)
virtual APP_SETTINGS_BASE * config()
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ReCreateVToolbar() override
ACTION_TOOLBAR * m_drawToolBar

References _, PCAD2KICAD::Center, g_ConnectionGraph, g_CurrentSheet, g_ErcSettings, ACTIONS::gridPreset, icon_eeschema_xpm, ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_LEVEL_50, KiBitmap(), PCAD2KICAD::Left, PCAD2KICAD::Right, and ACTIONS::zoomFitScreen.

◆ ~SCH_EDIT_FRAME()

SCH_EDIT_FRAME::~SCH_EDIT_FRAME ( )
override

Definition at line 293 of file sch_edit_frame.cpp.

294 {
295  // Shutdown all running tools
296  if( m_toolManager )
298 
299  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
300 
301  SetScreen( NULL );
302 
303  delete g_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
304  delete g_ConnectionGraph;
305  delete g_RootSheet;
306  delete g_ErcSettings;
307 
308  g_CurrentSheet = nullptr;
309  g_ConnectionGraph = nullptr;
310  g_RootSheet = nullptr;
311  g_ErcSettings = nullptr;
312 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SetScreen(BASE_SCREEN *aScreen) override
ERC_SETTINGS * g_ErcSettings
This also wants to live in the eventual SCHEMATIC object.
#define NULL
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
TOOL_MANAGER * m_toolManager
SCH_SHEET * g_RootSheet

References g_ConnectionGraph, g_CurrentSheet, g_ErcSettings, g_RootSheet, m_item_to_repeat, EDA_BASE_FRAME::m_toolManager, NULL, SetScreen(), and TOOL_MANAGER::ShutdownAllTools().

Member Function Documentation

◆ ActivateGalCanvas()

void EDA_DRAW_FRAME::ActivateGalCanvas ( )
virtualinherited

Use to start up the GAL drawing canvas.

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

Definition at line 561 of file eda_draw_frame.cpp.

562 {
563  GetCanvas()->SetEvtHandlerEnabled( true );
564  GetCanvas()->StartDrawing();
565 }
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.

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

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

◆ AddFormattingParameters()

void SCH_EDIT_FRAME::AddFormattingParameters ( std::vector< PARAM_CFG * > &  params)

Definition at line 368 of file eeschema_config.cpp.

369 {
370  EESCHEMA_SETTINGS* appSettings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
371 
372  params.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ),
373  LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) );
374  params.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ),
375  LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) );
376 
377  params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LabSize" ),
379  Mils2iu( DEFAULT_SIZE_TEXT ),
380  5, 1000, nullptr, 1 / IU_PER_MILS ) );
381  params.push_back( new PARAM_CFG_DOUBLE( wxT( "TextOffsetRatio" ),
383  (double) TXT_MARGIN / DEFAULT_SIZE_TEXT,
384  -200.0, 200.0 ) );
385  params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LineThickness" ),
387  Mils2iu( appSettings->m_Drawing.default_line_thickness ),
388  5, 1000, nullptr, 1 / IU_PER_MILS ) );
389 
390  params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "BusThickness" ),
392  Mils2iu( appSettings->m_Drawing.default_bus_thickness ),
393  5, 1000, nullptr, 1 / IU_PER_MILS ) );
394  params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "WireThickness" ),
396  Mils2iu( appSettings->m_Drawing.default_wire_thickness ),
397  5, 1000, nullptr, 1 / IU_PER_MILS ) );
398  params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "JunctionSize" ),
400  Mils2iu( appSettings->m_Drawing.default_junction_size ),
401  5, 1000, nullptr, 1 / IU_PER_MILS ) );
402 }
static int s_defaultTextSize
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:70
static int * SubpartFirstIdPtr()
return a reference to m_subpartFirstId, only for read/save setting functions
Configuration parameter - Double Precision Class.
static int s_defaultBusThickness
Configuration parameter - Integer Class with unit conversion.
#define TXT_MARGIN
The thickness to draw busses that do not have a specific width (can be changed in preference menu)
Definition: general.h:51
static int g_SymbolSize
Definition: sch_junction.h:37
static int s_drawDefaultLineThickness
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Configuration parameter - Integer Class.
static int s_defaultWireThickness
static double s_textOffsetRatio
#define IU_PER_MILS
Definition: plotter.cpp:137
static int * SubpartIdSeparatorPtr()
return a reference to m_subpartIdSeparator, only for read/save setting functions

References EESCHEMA_SETTINGS::DRAWING::default_bus_thickness, EESCHEMA_SETTINGS::DRAWING::default_junction_size, EESCHEMA_SETTINGS::DRAWING::default_line_thickness, DEFAULT_SIZE_TEXT, EESCHEMA_SETTINGS::DRAWING::default_wire_thickness, SCH_JUNCTION::g_SymbolSize, IU_PER_MILS, Kiface(), EESCHEMA_SETTINGS::m_Drawing, s_defaultBusThickness, s_defaultTextSize, s_defaultWireThickness, s_drawDefaultLineThickness, s_textOffsetRatio, LIB_PART::SubpartFirstIdPtr(), LIB_PART::SubpartIdSeparatorPtr(), and TXT_MARGIN.

Referenced by GetProjectFileParameters(), and DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction().

◆ AddItemToScreenAndUndoList()

void SCH_EDIT_FRAME::AddItemToScreenAndUndoList ( SCH_ITEM aItem,
bool  aUndoAppend = false 
)

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

943 {
944  SCH_SCREEN* screen = GetScreen();
945 
946  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
947 
948  SCH_SHEET* parentSheet = nullptr;
949  SCH_COMPONENT* parentComponent = nullptr;
950  SCH_ITEM* undoItem = aItem;
951 
952  if( aItem->Type() == SCH_SHEET_PIN_T )
953  {
954  parentSheet = (SCH_SHEET*) aItem->GetParent();
955 
956  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
957  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
958 
959  undoItem = parentSheet;
960  }
961 
962  else if( aItem->Type() == SCH_FIELD_T )
963  {
964  parentComponent = (SCH_COMPONENT*) aItem->GetParent();
965 
966  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
967  wxT( "Cannot place field in invalid schematic component object." ) );
968 
969  undoItem = parentComponent;
970  }
971 
972  if( aItem->IsNew() )
973  {
974  if( aItem->Type() == SCH_SHEET_PIN_T )
975  {
976  // Sheet pins are owned by their parent sheet.
977  SaveCopyInUndoList( undoItem, UR_CHANGED, aUndoAppend ); // save the parent sheet
978 
979  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
980  }
981  else if( aItem->Type() == SCH_FIELD_T )
982  {
983  // Component fields are also owned by their parent, but new component fields
984  // are handled elsewhere.
985  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
986  }
987  else
988  {
989  if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
990  AddToScreen( aItem );
991 
992  SaveCopyForRepeatItem( aItem );
993  SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
994  }
995 
996  // Update connectivity info for new item
997  if( !aItem->IsMoving() )
999  }
1000 
1001  aItem->ClearFlags( IS_NEW );
1002 
1003  screen->SetModify();
1004  RefreshItem( aItem );
1005 
1006  if( !aItem->IsMoving() && aItem->IsConnectable() )
1007  {
1008  std::vector< wxPoint > pts;
1009  aItem->GetConnectionPoints( pts );
1010 
1011  for( auto i = pts.begin(); i != pts.end(); i++ )
1012  {
1013  for( auto j = i + 1; j != pts.end(); j++ )
1014  TrimWire( *i, *j );
1015 
1016  if( screen->IsJunctionNeeded( *i, true ) )
1017  AddJunction( *i, true, false );
1018  }
1019 
1020  TestDanglingEnds();
1021 
1022  for( SCH_ITEM* item : aItem->ConnectedItems( *g_CurrentSheet ) )
1023  RefreshItem( item );
1024  }
1025 
1026  aItem->ClearEditFlags();
1027  GetCanvas()->Refresh();
1028 }
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:337
ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieves the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:138
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:335
bool IsMoving() const
Definition: base_struct.h:222
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_item.h:347
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:230
bool IsNew() const
Definition: base_struct.h:220
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define NULL
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
EDA_ITEM * GetParent() const
Definition: base_struct.h:217
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void SetModify()
Definition: base_screen.h:224
void ClearEditFlags()
Definition: base_struct.h:275
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:267
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References AddJunction(), SCH_SHEET::AddPin(), SCH_BASE_FRAME::AddToScreen(), SCH_SCREEN::CheckIfOnDrawList(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearFlags(), SCH_ITEM::ConnectedItems(), g_CurrentSheet, SCH_BASE_FRAME::GetCanvas(), SCH_ITEM::GetConnectionPoints(), EDA_ITEM::GetParent(), GetScreen(), IS_NEW, SCH_ITEM::IsConnectable(), SCH_SCREEN::IsJunctionNeeded(), EDA_ITEM::IsMoving(), EDA_ITEM::IsNew(), LOCAL_CLEANUP, NULL, RecalculateConnections(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_BASE_FRAME::RefreshItem(), SaveCopyForRepeatItem(), SaveCopyInUndoList(), SCH_COMPONENT_T, SCH_FIELD_T, SCH_SHEET_PIN_T, SCH_SHEET_T, BASE_SCREEN::SetModify(), TestDanglingEnds(), TrimWire(), EDA_ITEM::Type(), UR_CHANGED, and UR_NEW.

Referenced by SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ AddJunction()

SCH_JUNCTION * SCH_EDIT_FRAME::AddJunction ( const wxPoint aPos,
bool  aAppendToUndo = false,
bool  aFinal = true 
)

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

430 {
431  SCH_JUNCTION* junction = new SCH_JUNCTION( aPos );
432 
433  AddToScreen( junction );
434  SaveCopyInUndoList( junction, UR_NEW, aUndoAppend );
435  BreakSegments( aPos );
436 
437  if( aFinal )
438  {
440 
442  OnModify();
443 
444  auto view = GetCanvas()->GetView();
445  view->ClearPreview();
446  view->ShowPreview( false );
447  view->ClearHiddenFlags();
448  }
449 
450  return junction;
451 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
bool BreakSegments(const wxPoint &aPoint, SCH_SCREEN *aScreen=nullptr)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:205
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void ClearPreview()
Definition: sch_view.cpp:181
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
TOOL_MANAGER * m_toolManager
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267

References SCH_BASE_FRAME::AddToScreen(), BreakSegments(), KIGFX::SCH_VIEW::ClearPreview(), SCH_BASE_FRAME::GetCanvas(), SCH_DRAW_PANEL::GetView(), EDA_BASE_FRAME::m_toolManager, OnModify(), TOOL_MANAGER::PostEvent(), SaveCopyInUndoList(), EVENTS::SelectedItemsModified, TestDanglingEnds(), and UR_NEW.

Referenced by AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), SCH_EDIT_TOOL::BreakWire(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), FixupJunctions(), SCH_MOVE_TOOL::Main(), and SCH_DRAWING_TOOLS::SingleClickPlace().

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 397 of file eda_base_frame.cpp.

398 {
399  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
400  ACTION_MENU* helpMenu = new ACTION_MENU( false );
401 
402  helpMenu->SetTool( commonControl );
403 
404  helpMenu->Add( ACTIONS::help );
405  helpMenu->Add( ACTIONS::gettingStarted );
406  helpMenu->Add( ACTIONS::listHotKeys );
407  helpMenu->Add( ACTIONS::getInvolved );
408 
409  helpMenu->AppendSeparator();
410  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
411 
412  aMenuBar->Append( helpMenu, _( "&Help" ) );
413 }
static TOOL_ACTION listHotKeys
Definition: actions.h:171
ACTION_MENU.
Definition: action_menu.h:43
const BITMAP_OPAQUE about_xpm[1]
Definition: about.cpp:84
COMMON_CONTROL.
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION help
Definition: actions.h:170
TOOL_MANAGER * m_toolManager
static TOOL_ACTION getInvolved
Definition: actions.h:172
static TOOL_ACTION gettingStarted
Definition: actions.h:169

References _, about_xpm, ACTIONS::getInvolved, ACTIONS::gettingStarted, TOOL_MANAGER::GetTool(), ACTIONS::help, ACTIONS::listHotKeys, and EDA_BASE_FRAME::m_toolManager.

Referenced by EDA_3D_VIEWER::CreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), ReCreateMenuBar(), and PCB_EDIT_FRAME::ReCreateMenuBar().

◆ AddStandardSubMenus()

void EDA_DRAW_FRAME::AddStandardSubMenus ( TOOL_MENU aMenu)
inherited

Function CreateBasicMenu.

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

Definition at line 338 of file eda_draw_frame.cpp.

339 {
340  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
341  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
342 
343  aMenu.AddSeparator( 1000 );
345  aMenu.AddItem( ACTIONS::zoomIn, SELECTION_CONDITIONS::ShowAlways, 1000 );
346  aMenu.AddItem( ACTIONS::zoomOut, SELECTION_CONDITIONS::ShowAlways, 1000 );
348 
349  aMenu.AddSeparator( 1000 );
350 
351  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
352  zoomMenu->SetTool( commonTools );
353  aToolMenu.AddSubMenu( zoomMenu );
354 
355  auto gridMenu = std::make_shared<GRID_MENU>( this );
356  gridMenu->SetTool( commonTools );
357  aToolMenu.AddSubMenu( gridMenu );
358 
359  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
360  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
361 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
COMMON_TOOLS.
Definition: common_tools.h:38
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION zoomCenter
Definition: actions.h:92
static TOOL_ACTION zoomIn
Definition: actions.h:88
static TOOL_ACTION zoomOut
Definition: actions.h:89
TOOL_MANAGER * m_toolManager

References CONDITIONAL_MENU::AddSeparator(), TOOL_MENU::AddSubMenu(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), EDA_BASE_FRAME::m_toolManager, SELECTION_CONDITIONS::ShowAlways(), ACTIONS::zoomCenter, ACTIONS::zoomFitScreen, ACTIONS::zoomIn, and ACTIONS::zoomOut.

Referenced by PICKER_TOOL::Init(), EE_SELECTION_TOOL::Init(), SELECTION_TOOL::Init(), and EDIT_TOOL::Init().

◆ AddTemplateFieldName()

void SCH_EDIT_FRAME::AddTemplateFieldName ( const TEMPLATE_FIELDNAME aFieldName,
bool  aGlobal 
)
inline

Insert or append a wanted symbol field name into the field names template.

Should be used for any symbol property editor. If the name already exists, it overwrites the same name.

Parameters
aFieldNameis a full description of the wanted field, and it must not match any of the default field names.
aGlobalindicates whether to add to the global or project table

Definition at line 283 of file sch_edit_frame.h.

284  {
285  m_templateFieldNames.AddTemplateFieldName( aFieldName, aGlobal );
286  }
void AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName, bool aGlobal)
Function AddTemplateFieldName inserts or appends a wanted symbol field name into the fieldnames templ...
TEMPLATES m_templateFieldNames

References TEMPLATES::AddTemplateFieldName(), and SCH_BASE_FRAME::m_templateFieldNames.

Referenced by PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow().

◆ AddToScreen()

void SCH_BASE_FRAME::AddToScreen ( EDA_ITEM aItem,
SCH_SCREEN aScreen = nullptr 
)
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 448 of file sch_base_frame.cpp.

449 {
450  auto screen = aScreen;
451 
452  if( aScreen == nullptr )
453  screen = GetScreen();
454 
455  screen->Append( (SCH_ITEM*) aItem );
456 
457  if( screen == GetScreen() )
458  {
459  GetCanvas()->GetView()->Add( aItem );
460  RefreshItem( aItem, true ); // handle any additional parent semantics
461  }
462 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147

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

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

◆ AllowCaseSensitiveFileNameClashes()

bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes ( const wxString &  aSchematicFileName)

Check aSchematicFileName for a potential file name case sensitivity clashes.

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

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

Definition at line 637 of file sheet.cpp.

638 {
639  wxString msg;
640  SCH_SCREENS screens;
641  wxFileName fn = aSchematicFileName;
642 
643  wxCHECK( fn.IsAbsolute(), false );
644 
646  && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
647  {
648  msg.Printf( _( "The file name \"%s\" can cause issues with an existing file name\n"
649  "already defined in the schematic on systems that support case\n"
650  "insensitive file names. This will cause issues if you copy this\n"
651  "project to an operating system that supports case insensitive file\n"
652  "names.\n\nDo you wish to continue?" ),
653  fn.GetName() );
654 
655  wxRichMessageDialog dlg( this, msg, _( "Warning" ),
656  wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
657  dlg.ShowCheckBox( _( "Do not show this message again." ) );
658  dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
659  wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
660 
661  if( dlg.ShowModal() == wxID_NO )
662  return false;
663 
664  m_showSheetFileNameCaseSensitivityDlg = !dlg.IsCheckBoxChecked();
665  }
666 
667  return true;
668 }
bool m_showSheetFileNameCaseSensitivityDlg
#define _(s)
Definition: 3d_actions.cpp:33
bool CanCauseCaseSensitivityIssue(const wxString &aSchematicFileName) const
Check aSchematicFileName for a potential file name case sensitivity issue.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References _, SCH_SCREENS::CanCauseCaseSensitivityIssue(), and m_showSheetFileNameCaseSensitivityDlg.

Referenced by DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow().

◆ AnnotateComponents()

void SCH_EDIT_FRAME::AnnotateComponents ( bool  aAnnotateSchematic,
ANNOTATE_ORDER_T  aSortOption,
ANNOTATE_OPTION_T  aAlgoOption,
int  aStartNumber,
bool  aResetAnnotation,
bool  aRepairTimestamps,
bool  aLockUnits,
REPORTER aReporter 
)

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

Parameters
aAnnotateSchematicAnnotate the entire schematic if true. Otherwise annotate the current sheet only.
aSortOptionDefine the annotation order. See ANNOTATE_ORDER_T.
aAlgoOptionDefine the annotation style. See ANNOTATE_OPTION_T.
aStartNumberThe start number for non-sheet-based annotation styles.
aResetAnnotationClear any previous annotation if true. Otherwise, keep the existing component 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.
aLockUnitsWhen both aLockUnits and aResetAnnotation are true, all unit associations should be kept when reannotating. That is, if two components were R8A and R8B, they may become R3A and R3B, but not R3A and R3C or R3C and R4D. When aResetAnnotation is true but aLockUnits is false, the usual behavior of annotating each part individually is performed. When aResetAnnotation is false, this option has no effect.
aReporterA sink for error messages. Use NULL_REPORTER if you don't need errors.

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

Definition at line 84 of file eeschema/annotate.cpp.

92 {
93  SCH_REFERENCE_LIST references;
94 
95  SCH_SCREENS screens;
96 
97  // Build the sheet list.
98  SCH_SHEET_LIST sheets( g_RootSheet );
99 
100  // Map of locked components
101  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
102 
103  // Map of previous annotation for building info messages
104  std::map<wxString, wxString> previousAnnotation;
105 
106  // Test for and replace duplicate time stamps in components and sheets. Duplicate
107  // time stamps can happen with old schematics, schematic conversions, or manual
108  // editing of files.
109  if( aRepairTimestamps )
110  {
111  int count = screens.ReplaceDuplicateTimeStamps();
112 
113  if( count )
114  {
115  wxString msg;
116  msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
117  aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
118  }
119  }
120 
121  // If units must be locked, collect all the sets that must be annotated together.
122  if( aLockUnits )
123  {
124  if( aAnnotateSchematic )
125  sheets.GetMultiUnitComponents( lockedComponents );
126  else
127  g_CurrentSheet->GetMultiUnitComponents( lockedComponents );
128  }
129 
130  // Store previous annotations for building info messages
131  mapExistingAnnotation( previousAnnotation );
132 
133  // If it is an annotation for all the components, reset previous annotation.
134  if( aResetAnnotation )
135  DeleteAnnotation( !aAnnotateSchematic );
136 
137  // Set sheet number and number of sheets.
139 
140  // Build component list
141  if( aAnnotateSchematic )
142  sheets.GetComponents( references );
143  else
144  g_CurrentSheet->GetComponents( references );
145 
146  // Break full components reference in name (prefix) and number:
147  // example: IC1 become IC, and 1
148  references.SplitReferences();
149 
150  switch( aSortOption )
151  {
152  default:
153  case SORT_BY_X_POSITION: references.SortByXCoordinate(); break;
154  case SORT_BY_Y_POSITION: references.SortByYCoordinate(); break;
155  }
156 
157  bool useSheetNum = false;
158  int idStep = 100;
159 
160  switch( aAlgoOption )
161  {
162  default:
163  case INCREMENTAL_BY_REF:
164  break;
165 
166  case SHEET_NUMBER_X_100:
167  useSheetNum = true;
168  break;
169 
170  case SHEET_NUMBER_X_1000:
171  useSheetNum = true;
172  idStep = 1000;
173  break;
174  }
175 
176  // Recalculate and update reference numbers in schematic
177  references.Annotate( useSheetNum, idStep, aStartNumber, lockedComponents );
178  references.UpdateAnnotation();
179 
180  for( size_t i = 0; i < references.GetCount(); i++ )
181  {
182  SCH_COMPONENT* comp = references[ i ].GetComp();
183  SCH_SHEET_PATH* curr_sheetpath = &references[ i ].GetSheetPath();
184  KIID_PATH curr_full_uuid = curr_sheetpath->Path();
185  curr_full_uuid.push_back( comp->m_Uuid );
186 
187  wxString prevRef = previousAnnotation[ curr_full_uuid.AsString() ];
188 
189  wxString newRef = comp->GetRef( curr_sheetpath );
190 
191  if( comp->GetUnitCount() > 1 )
192  newRef << LIB_PART::SubReference( comp->GetUnitSelection( curr_sheetpath ) );
193 
194  wxString msg;
195 
196  if( prevRef.Length() )
197  {
198  if( newRef == prevRef )
199  continue;
200 
201  if( comp->GetUnitCount() > 1 )
202  msg.Printf( _( "Updated %s (unit %s) from %s to %s" ),
203  comp->GetField( VALUE )->GetShownText(),
204  LIB_PART::SubReference( comp->GetUnit(), false ),
205  prevRef, newRef );
206  else
207  msg.Printf( _( "Updated %s from %s to %s" ),
208  comp->GetField( VALUE )->GetShownText(),
209  prevRef, newRef );
210  }
211  else
212  {
213  if( comp->GetUnitCount() > 1 )
214  msg.Printf( _( "Annotated %s (unit %s) as %s" ),
215  comp->GetField( VALUE )->GetShownText(),
216  LIB_PART::SubReference( comp->GetUnit(), false ),
217  newRef );
218  else
219  msg.Printf( _( "Annotated %s as %s" ),
220  comp->GetField( VALUE )->GetShownText(),
221  newRef );
222  }
223 
224  aReporter.Report( msg, RPT_SEVERITY_ACTION );
225  }
226 
227  // Final control (just in case ... ).
228  if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) )
229  aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
230 
231  // Update on screen references, that can be modified by previous calculations:
234 
235  SyncView();
236  GetCanvas()->Refresh();
237  OnModify();
238 }
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet.
void mapExistingAnnotation(std::map< wxString, wxString > &aMap)
SCH_SHEET_LIST.
void SortByYCoordinate()
Function sortByYCoordinate sorts the list of references by Y position.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Function ReportTail Places the report at the end of the list, for objects that support report orderin...
Definition: reporter.h:92
int GetUnitCount() const
Return the number of units per package of the symbol.
Annotate incrementally using the first free reference number.
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierarchy,...
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
void UpdateAnnotation()
function UpdateAnnotation Updates the reference components for the schematic project (or the current ...
#define VALUE
int GetUnit() const
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SortByXCoordinate()
Function sortByXCoordinate sorts the list of references by X position.
void DeleteAnnotation(bool aCurrentSheetOnly)
Clear the current component annotation.
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap)
Function Annotate set the reference designators in the list that have not been annotated.
SCH_SHEET_PATH.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Type SCH_MULTI_UNIT_REFERENCE_MAP is used to create a map of reference designators for multi-unit par...
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
int CheckAnnotate(REPORTER &aReporter, bool aOneSheetOnly)
Check for annotation errors.
const KIID m_Uuid
Definition: base_struct.h:169
Annotate by Y position from top to bottom.
Annotate using the first free reference number starting at the sheet number * 100.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SplitReferences()
Function SplitReferences attempts to split all reference designators into a name (U) and number (1).
#define _(s)
Definition: 3d_actions.cpp:33
wxString AsString() const
Definition: common.h:123
Annotate by X position from left to right.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Annotate using the first free reference number starting at the sheet number * 1000.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
int ReplaceDuplicateTimeStamps()
Test all sheet and component objects in the schematic for duplicate time stamps and replaces them as ...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
SCH_SHEET * g_RootSheet
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
unsigned GetCount()
Function GetCount.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References _, SCH_REFERENCE_LIST::Annotate(), KIID_PATH::AsString(), CheckAnnotate(), DeleteAnnotation(), g_CurrentSheet, g_RootSheet, SCH_BASE_FRAME::GetCanvas(), SCH_SHEET_PATH::GetComponents(), SCH_SHEET_LIST::GetComponents(), SCH_REFERENCE_LIST::GetCount(), SCH_COMPONENT::GetField(), SCH_SHEET_PATH::GetMultiUnitComponents(), SCH_SHEET_LIST::GetMultiUnitComponents(), SCH_COMPONENT::GetRef(), EDA_TEXT::GetShownText(), SCH_COMPONENT::GetUnit(), SCH_COMPONENT::GetUnitCount(), SCH_COMPONENT::GetUnitSelection(), INCREMENTAL_BY_REF, EDA_ITEM::m_Uuid, mapExistingAnnotation(), OnModify(), SCH_SHEET_PATH::Path(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), REPORTER::Report(), REPORTER::ReportTail(), RPT_SEVERITY_ACTION, RPT_SEVERITY_WARNING, SetSheetNumberAndCount(), SHEET_NUMBER_X_100, SHEET_NUMBER_X_1000, SORT_BY_X_POSITION, SORT_BY_Y_POSITION, SCH_REFERENCE_LIST::SortByXCoordinate(), SCH_REFERENCE_LIST::SortByYCoordinate(), SCH_REFERENCE_LIST::SplitReferences(), LIB_PART::SubReference(), SCH_BASE_FRAME::SyncView(), SCH_SHEET_PATH::UpdateAllScreenReferences(), SCH_REFERENCE_LIST::UpdateAnnotation(), and VALUE.

Referenced by CreateNetlist(), KiwayMailIn(), and DIALOG_ANNOTATE::OnApplyClick().

◆ AppendMsgPanel()

void EDA_DRAW_FRAME::AppendMsgPanel ( const wxString &  textUpper,
const wxString &  textLower,
COLOR4D  color,
int  pad = 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
textUpper- The message upper text.
textLower- The message lower text.
color- A color ID from the KiCad color list (see colors.h).
pad- Number of spaces to pad between messages (default = 4).

Definition at line 518 of file eda_draw_frame.cpp.

520 {
521  if( m_messagePanel )
522  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
523 }
int color
Definition: DXF_plotter.cpp:61
EDA_MSG_PANEL * m_messagePanel
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, COLOR4D aColor, int aPad=6)
Function AppendMessage appends a message to the message panel.
Definition: msgpanel.cpp:110

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

Referenced by PCB_BASE_FRAME::Compile_Ratsnest(), LIB_EDIT_FRAME::DisplayCmpDoc(), GERBER_FILE_IMAGE::DisplayImageInfo(), importFile(), LoadSheetFromFile(), SCH_PRINTOUT::OnPrintPage(), OpenProjectFiles(), SaveEEFile(), LIB_EDIT_FRAME::saveLibrary(), PCB_EDIT_FRAME::SavePcbFile(), DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow(), and LIB_VIEW_FRAME::updatePreviewSymbol().

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

445 {
446  wxString fullFileName;
447  SCH_SCREEN* screen = GetScreen();
448 
449  if( !screen )
450  {
451  wxLogError( wxT( "Document not ready, cannot import" ) );
452  return false;
453  }
454 
455  // open file chooser dialog
456  wxString path = wxPathOnly( Prj().GetProjectFullName() );
457 
458  wxFileDialog dlg( this, _( "Append Schematic" ), path, wxEmptyString,
459  LegacySchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
460 
461  if( dlg.ShowModal() == wxID_CANCEL )
462  return false;
463 
464  fullFileName = dlg.GetPath();
465 
466  if( !LoadSheetFromFile( GetCurrentSheet().Last(), &GetCurrentSheet(), fullFileName ) )
467  return false;
468 
469  SCH_SCREENS screens( GetCurrentSheet().Last() );
470  screens.TestDanglingEnds();
471 
475 
476  SyncView();
477  HardRedraw(); // Full reinit of the current screen and the display.
478  OnModify();
479 
480  return true;
481 }
wxString LegacySchematicFileWildcard()
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:102
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SyncView()
Mark all items for refresh.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_SHEET_PATH & GetCurrentSheet()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
#define _(s)
Definition: 3d_actions.cpp:33
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
TOOL_MANAGER * m_toolManager
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References _, GetCurrentSheet(), GetScreen(), HardRedraw(), ID_POPUP_GRID_LEVEL_1000, LegacySchematicFileWildcard(), LoadSheetFromFile(), EDA_DRAW_FRAME::m_LastGridSizeId, EDA_BASE_FRAME::m_toolManager, OnModify(), KIWAY_HOLDER::Prj(), TOOL_MANAGER::RunAction(), BASE_SCREEN::SetGrid(), SetSheetNumberAndCount(), SCH_BASE_FRAME::SyncView(), SCH_SCREENS::TestDanglingEnds(), and ACTIONS::zoomFitScreen.

Referenced by OnAppendProject().

◆ AskToSaveChanges()

bool SCH_EDIT_FRAME::AskToSaveChanges ( )

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

740 {
741  SCH_SCREENS screenList;
742 
743  // Save any currently open and modified project files.
744  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
745  {
746  if( screen->IsModify() )
747  {
748  if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
749  "Save changes?" ),
750  [&]()->bool { return SaveProject(); } ) )
751  {
752  return false;
753  }
754  }
755  }
756 
757  return true;
758 }
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:201
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
#define _(s)
Definition: 3d_actions.cpp:33
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References _, SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), HandleUnsavedChanges(), and SaveProject().

Referenced by OnImportProject(), and OpenProjectFiles().

◆ BreakSegment()

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

Breaks a single segment into two at the specified point.

NOTE: always appends to the existing undo state.

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

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

278 {
279  if( !IsPointOnSegment( aSegment->GetStartPoint(), aSegment->GetEndPoint(), aPoint )
280  || aSegment->IsEndPoint( aPoint ) )
281  return false;
282 
283  if( aScreen == nullptr )
284  aScreen = GetScreen();
285 
286  SCH_LINE* newSegment = new SCH_LINE( *aSegment );
287 
288  newSegment->SetStartPoint( aPoint );
289  AddToScreen( newSegment, aScreen );
290 
291  SaveCopyInUndoList( newSegment, UR_NEW, true );
292  SaveCopyInUndoList( aSegment, UR_CHANGED, true );
293 
294  RefreshItem( aSegment );
295  aSegment->SetEndPoint( aPoint );
296 
297  if( aNewSegment )
298  *aNewSegment = newSegment;
299 
300  return true;
301 }
wxPoint GetStartPoint() const
Definition: sch_line.h:97
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:101
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:98
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:90
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
wxPoint GetEndPoint() const
Definition: sch_line.h:100

References SCH_BASE_FRAME::AddToScreen(), SCH_LINE::GetEndPoint(), GetScreen(), SCH_LINE::GetStartPoint(), SCH_LINE::IsEndPoint(), IsPointOnSegment(), SCH_BASE_FRAME::RefreshItem(), SaveCopyInUndoList(), SCH_LINE::SetEndPoint(), SCH_LINE::SetStartPoint(), UR_CHANGED, and UR_NEW.

Referenced by BreakSegments(), and TrimWire().

◆ BreakSegments()

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

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

NOTE: 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 304 of file bus-wire-junction.cpp.

305 {
306  static const KICAD_T wiresAndBusses[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
307 
308  if( aScreen == nullptr )
309  aScreen = GetScreen();
310 
311  bool brokenSegments = false;
312  std::vector<SCH_LINE*> wires;
313  EDA_RECT bbox( aPoint, wxSize( 2, 2 ) );
314 
315  for( auto item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
316  {
317  if( item->IsType( wiresAndBusses ) )
318  wires.push_back( static_cast<SCH_LINE*>( item ) );
319  }
320 
321  for( auto wire : wires )
322  brokenSegments |= BreakSegment( wire, aPoint, NULL, aScreen );
323 
324  return brokenSegments;
325 }
bool BreakSegment(SCH_LINE *aSegment, const wxPoint &aPoint, SCH_LINE **aNewSegment=NULL, SCH_SCREEN *aScreen=nullptr)
Breaks a single segment into two at the specified point.
EE_TYPE Overlapping(const EDA_RECT &aRect)
Definition: sch_rtree.h:224
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define NULL
EE_RTREE & Items()
Definition: sch_screen.h:127
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

References BreakSegment(), EOT, GetScreen(), SCH_SCREEN::Items(), NULL, EE_RTREE::Overlapping(), SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, and SCH_LINE_T.

Referenced by AddJunction(), BreakSegmentsOnJunctions(), and SCH_EDIT_TOOL::BreakWire().

◆ BreakSegmentsOnJunctions()

bool SCH_EDIT_FRAME::BreakSegmentsOnJunctions ( SCH_SCREEN aScreen = nullptr)

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

NOTE: 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 328 of file bus-wire-junction.cpp.

329 {
330  if( aScreen == nullptr )
331  aScreen = GetScreen();
332 
333  bool brokenSegments = false;
334 
335  std::set<wxPoint> point_set;
336  for( auto item : aScreen->Items().OfType( SCH_JUNCTION_T ) )
337  point_set.insert( item->GetPosition() );
338 
339  for( auto item : aScreen->Items().OfType( SCH_BUS_WIRE_ENTRY_T ) )
340  {
341  auto entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
342  point_set.insert( entry->GetPosition() );
343  point_set.insert( entry->m_End() );
344  }
345 
346 
347  for( auto pt : point_set )
348  brokenSegments |= BreakSegments( pt, aScreen );
349 
350  return brokenSegments;
351 }
bool BreakSegments(const wxPoint &aPoint, SCH_SCREEN *aScreen=nullptr)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
EE_RTREE & Items()
Definition: sch_screen.h:127

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

Referenced by SchematicCleanUp().

◆ BuildNetListBase()

NETLIST_OBJECT_LIST * SCH_EDIT_FRAME::BuildNetListBase ( bool  updateStatusText = true)

Create a flat list which stores all connected objects.

Parameters
updateStatusTextdecides if window StatusText should be modified.
Returns
NETLIST_OBJECT_LIST* - caller owns the object.

Definition at line 238 of file netlist_generator.cpp.

239 {
240  // Ensure netlist is up to date
242 
243  // I own this list until I return it to the new owner.
244  std::unique_ptr<NETLIST_OBJECT_LIST> ret( new NETLIST_OBJECT_LIST() );
245 
246  // Creates the flattened sheet list:
247  SCH_SHEET_LIST aSheets( g_RootSheet );
248 
249  // Build netlist info
250  bool success = ret->BuildNetListInfo( aSheets );
251 
252  if( !success )
253  {
254  if( updateStatusText )
255  SetStatusText( _( "No Objects" ) );
256  return ret.release();
257  }
258 
259  wxString msg = wxString::Format( _( "Net count = %d" ), int( ret->size() ) );
260 
261  if( updateStatusText )
262  SetStatusText( msg );
263 
264  return ret.release();
265 }
SCH_SHEET_LIST.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
SCH_SHEET * g_RootSheet

References _, Format(), g_RootSheet, NO_CLEANUP, and RecalculateConnections().

Referenced by CreateNetlist(), KiwayMailIn(), sendNetlistToCvpcb(), DIALOG_ERC::TestErc(), and SIM_PLOT_FRAME::updateNetlistExporter().

◆ CenterScreen()

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

Definition at line 307 of file sch_base_frame.cpp.

308 {
309  GetCanvas()->GetView()->SetCenter( aCenterPoint );
310 
311  if( aWarpPointer )
312  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
313 
314  GetCanvas()->Refresh();
315 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:604
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...

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

Referenced by SCH_EDITOR_CONTROL::FindComponentAndItem().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inlineinherited

Definition at line 225 of file eda_base_frame.h.

226  {
227  SetUserUnits( aUnits );
229  }
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void SetUserUnits(EDA_UNITS aUnits)

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

Referenced by COMMON_TOOLS::ImperialUnits(), COMMON_TOOLS::MetricUnits(), and COMMON_TOOLS::ToggleUnits().

◆ CheckAnnotate()

int SCH_EDIT_FRAME::CheckAnnotate ( REPORTER aReporter,
bool  aOneSheetOnly 
)

Check for annotation errors.

The following list of items are checked:

  • Components that are not annotated.
  • Duplicate component references.
  • Multiple part per package components where the part number is greater number of parts in the package.
  • Multiple part per package components where the reference designator is different between parts.
Returns
Number of annotation errors found.
Parameters
aReporterA sink for error messages. Use NULL_REPORTER if you don't need errors.
aOneSheetOnlyCheck the current sheet only if true. Otherwise check the entire schematic.

Definition at line 241 of file eeschema/annotate.cpp.

242 {
243  // build the screen list
244  SCH_SHEET_LIST sheetList( g_RootSheet );
245  SCH_REFERENCE_LIST componentsList;
246 
247  // Build the list of components
248  if( !aOneSheetOnly )
249  sheetList.GetComponents( componentsList );
250  else
251  g_CurrentSheet->GetComponents( componentsList );
252 
253  // Empty schematic does not need annotation
254  if( componentsList.GetCount() == 0 )
255  return 0;
256 
257  return componentsList.CheckAnnotation( aReporter );
258 }
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet.
SCH_SHEET_LIST.
SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierarchy,...
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
SCH_SHEET * g_RootSheet
int CheckAnnotation(REPORTER &aReporter)
Function CheckAnnotation check for annotations errors.
unsigned GetCount()
Function GetCount.

References SCH_REFERENCE_LIST::CheckAnnotation(), g_CurrentSheet, g_RootSheet, SCH_SHEET_PATH::GetComponents(), SCH_SHEET_LIST::GetComponents(), and SCH_REFERENCE_LIST::GetCount().

Referenced by AnnotateComponents(), prepareForNetlist(), and DIALOG_ERC::TestErc().

◆ CheckForAutoSaveFile()

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

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

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

Parameters
aFileNameA wxFileName object containing the file name to check.

Definition at line 735 of file eda_base_frame.cpp.

736 {
737  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
738 
739  wxFileName autoSaveFileName = aFileName;
740 
741  // Check for auto save file.
742  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
743 
744  wxLogTrace( traceAutoSave,
745  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
746 
747  if( !autoSaveFileName.FileExists() )
748  return;
749 
750  wxString msg = wxString::Format( _(
751  "Well this is potentially embarrassing!\n"
752  "It appears that the last time you were editing the file\n"
753  "\"%s\"\n"
754  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
755  GetChars( aFileName.GetFullName() )
756  );
757 
758  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
759 
760  // Make a backup of the current file, delete the file, and rename the auto save file to
761  // the file name.
762  if( response == wxYES )
763  {
764  // Get the backup file name.
765  wxFileName backupFileName = aFileName;
766  backupFileName.SetExt( aFileName.GetExt() + GetBackupSuffix() );
767 
768  // If an old backup file exists, delete it. If an old copy of the file exists, rename
769  // it to the backup file name
770  if( aFileName.FileExists() )
771  {
772  // Rename the old file to the backup file name.
773  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath(), true ) )
774  {
775  msg.Printf( _( "Could not create backup file \"%s\"" ),
776  GetChars( backupFileName.GetFullPath() ) );
777  wxMessageBox( msg );
778  }
779  }
780 
781  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
782  {
783  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
784  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
785  }
786  }
787  else
788  {
789  wxLogTrace( traceAutoSave,
790  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
791 
792  // Remove the auto save file when using the previous file as is.
793  wxRemoveFile( autoSaveFileName.GetFullPath() );
794  }
795 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
static wxString GetBackupSuffix()
static wxString GetAutoSaveFilePrefix()
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33

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

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

◆ checkForNoFullyDefinedLibIds()

bool SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds ( SCH_SHEET aSheet)
private

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

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

Definition at line 72 of file sheet.cpp.

73 {
74  wxASSERT( aSheet && aSheet->GetScreen() );
75 
76  wxString msg;
77  SCH_SCREENS newScreens( aSheet );
78 
79  if( newScreens.HasNoFullyDefinedLibIds() )
80  {
81  msg.Printf( _( "The schematic \"%s\" has not had it's symbol library links remapped "
82  "to the symbol library table. The project this schematic belongs to "
83  "must first be remapped before it can be imported into the current "
84  "project." ), aSheet->GetScreen()->GetFileName() );
85  DisplayInfoMessage( this, msg );
86  return true;
87  }
88 
89  return false;
90 }
const wxString & GetFileName() const
Definition: sch_screen.h:157
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
#define _(s)
Definition: 3d_actions.cpp:33
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

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 resursion error in aHierarchy.

Definition at line 44 of file sheet.cpp.

45 {
46  wxASSERT( aSheet && aHierarchy );
47 
48  wxString msg;
49  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the full schematic sheet hierarchy.
50  SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
51 
52  wxFileName destFile = aHierarchy->LastScreen()->GetFileName();
53 
54  // SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
55  // something is seriously broken.
56  wxASSERT( destFile.IsAbsolute() );
57 
58  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
59  {
60  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
61  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
62  "the schematic hierarchy." ),
63  destFile.GetFullPath() );
64  DisplayError( this, msg );
65  return true;
66  }
67 
68  return false;
69 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
SCH_SHEET_LIST.
const wxString & GetFileName() const
Definition: sch_screen.h:157
SCH_SCREEN * LastScreen()
Function LastScreen.
#define _(s)
Definition: 3d_actions.cpp:33
SCH_SHEET * g_RootSheet

References _, DisplayError(), g_RootSheet, SCH_SCREEN::GetFileName(), SCH_SHEET_PATH::LastScreen(), and SCH_SHEET_LIST::TestForRecursion().

Referenced by LoadSheetFromFile(), and DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow().

◆ 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
aFlags= wxEXEC_* flags, see wxExecute docs.

Definition at line 1026 of file sch_edit_frame.h.

1026 { 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 = NULL)
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 643 of file eda_base_frame.cpp.

644 {
645  if( !aFileHistory )
646  aFileHistory = &Kiface().GetFileHistory();
647 
648  aFileHistory->ClearFileHistory();
649 }
void ClearFileHistory()
Clear all entries from the file history.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:125

References FILE_HISTORY::ClearFileHistory(), KIFACE_I::GetFileHistory(), and Kiface().

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

◆ ClearFindReplaceStatus()

void SCH_EDIT_FRAME::ClearFindReplaceStatus ( )

Definition at line 714 of file sch_edit_frame.cpp.

715 {
716  m_findReplaceStatusPopup->Hide();
717 }
STATUS_TEXT_POPUP * m_findReplaceStatusPopup

References m_findReplaceStatusPopup.

Referenced by SCH_EDITOR_CONTROL::FindNext().

◆ ClearMsgPanel()

◆ CommonSettingsChanged()

void SCH_EDIT_FRAME::CommonSettingsChanged ( bool  aEnvVarsChanged)
overridevirtual

Called after the preferences dialog is run.

Reimplemented from EDA_BASE_FRAME.

Definition at line 1085 of file sch_edit_frame.cpp.

1086 {
1087  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1088 
1089  RecreateToolbars();
1090  Layout();
1091  SendSizeEvent();
1092 }
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck tools.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.

References EDA_DRAW_FRAME::CommonSettingsChanged(), and EDA_DRAW_FRAME::RecreateToolbars().

◆ config()

APP_SETTINGS_BASE * EDA_BASE_FRAME::config ( )
virtualinherited

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

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 572 of file eda_base_frame.cpp.

573 {
574  // KICAD_MANAGER_FRAME overrides this
576  //wxASSERT( ret );
577  return ret;
578 }
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:103
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:75
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.

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

Referenced by BM2CMP_FRAME::BM2CMP_FRAME(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), LIB_VIEW_FRAME::LIB_VIEW_FRAME(), SIM_PLOT_FRAME::onClose(), FOOTPRINT_WIZARD_FRAME::OnCloseWindow(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), SaveProject(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), EDA_BASE_FRAME::windowClosing(), and BM2CMP_FRAME::~BM2CMP_FRAME().

◆ ConfigBaseName()

wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited
Returns
a base name prefix used in Load/Save settings to build the full name of keys used in config. 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 config can be used.

Definition at line 379 of file eda_base_frame.h.

380  {
381  wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
382  return baseCfgName;
383  }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

Referenced by EDA_DRAW_FRAME::LoadSettings(), EDA_BASE_FRAME::SaveWindowSettings(), and ACTION_MANAGER::UpdateHotKeys().

◆ ConvertPart()

void SCH_EDIT_FRAME::ConvertPart ( SCH_COMPONENT aComponent)

Definition at line 243 of file getpart.cpp.

244 {
245  if( !aComponent )
246  return;
247 
248  LIB_ID id = aComponent->GetLibId();
249  LIB_PART* part = GetLibPart( id );
250 
251  if( part )
252  {
253  wxString msg;
254 
255  if( !part->HasConversion() )
256  {
257  msg.Printf( _( "No alternate body style found for symbol \"%s\" in library \"%s\"." ),
258  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
259  DisplayError( this, msg );
260  return;
261  }
262 
263  STATUS_FLAGS savedFlags = aComponent->GetFlags();
264 
265  aComponent->SetConvert( aComponent->GetConvert() + 1 );
266 
267  // ensure m_Convert = 1 or 2
268  // 1 = shape 1 = not converted
269  // 2 = shape 2 = first converted shape
270  // > 2 is not used but could be used for more shapes
271  // like multiple shapes for a programmable component
272  // When m_Convert = val max, return to the first shape
273  if( aComponent->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN )
274  aComponent->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
275 
276  // The alternate symbol may cause a change in the connection status so test the
277  // connections so the connection indicators are drawn correctly.
278  aComponent->UpdatePins();
280  aComponent->ClearFlags();
281  aComponent->SetFlags( savedFlags ); // Restore m_Flags (modified by SetConvert())
282 
283  // If selected make sure all the now-included pins are selected
284  if( aComponent->IsSelected() )
285  m_toolManager->RunAction( EE_ACTIONS::addItemToSel, true, aComponent );
286 
287  RefreshItem( aComponent );
288  OnModify();
289  }
290 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
bool IsSelected() const
Definition: base_struct.h:225
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SetConvert(int aConvert)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:61
Define a library symbol object.
unsigned STATUS_FLAGS
Definition: base_struct.h:159
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
#define _(s)
Definition: 3d_actions.cpp:33
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
int GetConvert() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
TOOL_MANAGER * m_toolManager
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:259
const LIB_ID & GetLibId() const

References _, EE_ACTIONS::addItemToSel, EDA_ITEM::ClearFlags(), DisplayError(), SCH_COMPONENT::GetConvert(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetLibId(), SCH_BASE_FRAME::GetLibPart(), LIB_PART::HasConversion(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::m_toolManager, OnModify(), SCH_BASE_FRAME::RefreshItem(), TOOL_MANAGER::RunAction(), SCH_COMPONENT::SetConvert(), EDA_ITEM::SetFlags(), TestDanglingEnds(), and SCH_COMPONENT::UpdatePins().

Referenced by SCH_EDIT_TOOL::ConvertDeMorgan().

◆ ConvertTextType()

void SCH_EDIT_FRAME::ConvertTextType ( SCH_TEXT aText,
KICAD_T  aNewType 
)

Change a text type to another one.

The new text, label, hierarchical label, or global label is created from the old text and the old text object is deleted.

A tricky case is when the 'old" text is being edited (i.e. moving) because we must create a new text, and prepare the undo/redo command data for this change and the current move/edit command

Definition at line 190 of file edit_label.cpp.

191 {
192  KICAD_T oldType = aText->Type();
193  bool selected = aText->IsSelected();
194 
195  wxCHECK_RET( aText->CanIncrementLabel(), "Cannot convert text type." );
196 
197  if( oldType == aNewType )
198  return;
199 
200  SCH_TEXT* newtext = nullptr;
201  const wxPoint& position = aText->GetPosition();
202  LABEL_SPIN_STYLE orientation = aText->GetLabelSpinStyle();
203  wxString txt = UnescapeString( aText->GetText() );
204 
205  // There can be characters in a SCH_TEXT object that can break labels so we have to
206  // fix them here.
207  if( oldType == SCH_TEXT_T )
208  {
209  txt.Replace( "\n", "_" );
210  txt.Replace( "\r", "_" );
211  txt.Replace( "\t", "_" );
212  txt.Replace( " ", "_" );
213  }
214 
215  // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
216  if( aNewType != SCH_TEXT_T )
217  txt = EscapeString( txt, CTX_NETNAME );
218 
219  switch( aNewType )
220  {
221  case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
222  case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
223  case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
224  case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
225 
226  default:
227  wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", aNewType ) );
228  return;
229  }
230 
231  // Copy the old text item settings to the new one. Justifications are not copied
232  // because they are not used in labels. Justifications will be set to default value
233  // in the new text item type.
234  //
235  newtext->SetFlags( aText->GetEditFlags() );
236  newtext->SetShape( aText->GetShape() );
237  newtext->SetLabelSpinStyle( orientation );
238  newtext->SetTextSize( aText->GetTextSize() );
239  newtext->SetThickness( aText->GetThickness() );
240  newtext->SetItalic( aText->IsItalic() );
241  newtext->SetBold( aText->IsBold() );
242  newtext->SetIsDangling( aText->IsDangling() );
243 
244  if( selected )
246 
247  if( !aText->IsNew() )
248  {
249  SaveCopyInUndoList( aText, UR_DELETED );
250  SaveCopyInUndoList( newtext, UR_NEW, true );
251 
252  RemoveFromScreen( aText );
253  AddToScreen( newtext );
254  }
255 
256  if( selected )
258 
259  // Otherwise, pointer is owned by the undo stack
260  if( aText->IsNew() )
261  delete aText;
262 
263  if( aNewType == SCH_TEXT_T )
264  {
265  if( newtext->IsDangling() )
266  {
267  newtext->SetIsDangling( false );
268  GetCanvas()->GetView()->Update( newtext, KIGFX::REPAINT );
269  }
270  }
271  else
273 
274  OnModify();
275 }
bool IsDangling() const override
Definition: sch_text.h:304
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
bool IsBold() const
Definition: eda_text.h:167
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:244
bool IsSelected() const
Definition: base_struct.h:225
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
void SetItalic(bool isItalic)
Definition: eda_text.h:163
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
bool CanIncrementLabel() const override
Definition: sch_text.h:309
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:305
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool IsNew() const
Definition: base_struct.h:220
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:62
bool IsItalic() const
Definition: eda_text.h:164
Item is being added to the view.
Definition: view_item.h:60
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:61
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:262
const wxSize & GetTextSize() const
Definition: eda_text.h:223
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:237
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_text.h:317
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
These Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which ar...
Definition: string.cpp:50
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
TOOL_MANAGER * m_toolManager
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:206
void SetBold(bool aBold)
Definition: eda_text.h:166
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
void SetThickness(int aNewThickness)
Set the pen width.
Definition: eda_text.h:143
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:242
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References EE_ACTIONS::addItemToSel, SCH_BASE_FRAME::AddToScreen(), SCH_TEXT::CanIncrementLabel(), CTX_NETNAME, EscapeString(), Format(), SCH_BASE_FRAME::GetCanvas(), EDA_ITEM::GetEditFlags(), SCH_TEXT::GetLabelSpinStyle(), SCH_TEXT::GetPosition(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), SCH_DRAW_PANEL::GetView(), EDA_TEXT::IsBold(), SCH_TEXT::IsDangling(), EDA_TEXT::IsItalic(), EDA_ITEM::IsNew(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::m_toolManager, OnModify(), SCH_BASE_FRAME::RemoveFromScreen(), EE_ACTIONS::removeItemFromSel, KIGFX::REPAINT, TOOL_MANAGER::RunAction(), SaveCopyInUndoList(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_TEXT_T, EDA_TEXT::SetBold(), EDA_ITEM::SetFlags(), SCH_TEXT::SetIsDangling(), EDA_TEXT::SetItalic(), SCH_TEXT::SetLabelSpinStyle(), SCH_TEXT::SetShape(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), TestDanglingEnds(), EDA_ITEM::Type(), UnescapeString(), KIGFX::VIEW::Update(), UR_DELETED, and UR_NEW.

Referenced by SCH_EDIT_TOOL::ChangeTextType().

◆ CreateArchiveLibrary()

bool SCH_EDIT_FRAME::CreateArchiveLibrary ( const wxString &  aFileName)

Create a library aFileName that contains all components 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;
70 
71  // Create a new empty library to archive components:
72  std::unique_ptr<PART_LIB> archLib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
73 
74  // Save symbols to file only when the library will be fully filled
75  archLib->EnableBuffering();
76 
77  /* Examine all screens (not hierarchical sheets) used in the schematic and build a
78  * library of unique symbols found in all screens. Complex hierarchies are not a
79  * problem because we just want to know the library symbols used in the schematic
80  * not their reference.
81  */
82  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
83  {
84 
85  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
86  {
87  LIB_PART* part = nullptr;
88  auto component = static_cast<SCH_COMPONENT*>( aItem );
89 
90  try
91  {
92  if( archLib->FindPart( component->GetLibId() ) )
93  continue;
94 
95  part = GetLibPart( component->GetLibId(), true );
96  }
97  catch( const IO_ERROR& )
98  {
99  // Queue up error messages for later.
100  tmp.Printf( _( "Failed to add symbol \"%s\" to library file \"%s\"." ),
101  component->GetLibId().GetUniStringLibItemName(), aFileName );
102 
103  // Don't bail out here. Attempt to add as many of the symbols to the library
104  // as possible.
105  }
106  catch( ... )
107  {
108  tmp = _( "Unexpected exception occurred." );
109  }
110 
111  if( part )
112  {
113  // Use the full LIB_ID as the symbol name to prevent symbol name collisions.
114  wxString oldName = part->GetName();
115  part->SetName( component->GetLibId().GetUniStringLibId() );
116 
117  // AddPart() does first clone the part before adding.
118  archLib->AddPart( part );
119  part->SetName( oldName );
120  }
121  else
122  {
123  tmp.Printf( _( "Symbol %s not found in any library or cache." ),
124  component->GetLibId().GetUniStringLibId() );
125  }
126 
127  if( !tmp.empty() && !errorMsg.Contains( component->GetLibId().GetUniStringLibId() ) )
128  {
129  if( errorMsg.empty() )
130  errorMsg += tmp;
131  else
132  errorMsg += "\n" + tmp;
133  }
134  }
135  }
136 
137  if( !errorMsg.empty() )
138  {
139  tmp.Printf( _( "Errors occurred creating symbol library %s." ), aFileName );
140  DisplayErrorMessage( this, tmp, errorMsg );
141  }
142 
143  archLib->EnableBuffering( false );
144 
145  try
146  {
147  archLib->Save( false );
148  }
149  catch( const IO_ERROR& ioe )
150  {
151  errorMsg.Printf( _( "Failed to save symbol library file \"%s\"" ), aFileName );
152  DisplayErrorMessage( this, errorMsg, ioe.What() );
153  return false;
154  }
155  catch( std::exception& error )
156  {
157  errorMsg.Printf( _( "Failed to save symbol library file \"%s\"" ), aFileName );
158  DisplayErrorMessage( this, errorMsg, error.what() );
159  return false;
160  }
161 
162  return true;
163 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
wxString GetName() const override
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Define a library symbol object.
#define _(s)
Definition: 3d_actions.cpp:33
virtual void SetName(const wxString &aName)
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
Object used to load, save, search, and otherwise manipulate symbol library files.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References _, DisplayErrorMessage(), SCH_SCREENS::GetFirst(), SCH_BASE_FRAME::GetLibPart(), LIB_PART::GetName(), SCH_SCREENS::GetNext(), LIBRARY_TYPE_EESCHEMA, SCH_COMPONENT_T, LIB_PART::SetName(), 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 components used in the current schematic.

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

Definition at line 42 of file libarch.cpp.

43 {
44  wxFileName fn;
45 
46  if( aUseCurrentSheetFilename )
47  fn = GetScreen()->GetFileName();
48  else
50 
51  fn.SetName( fn.GetName() + "-cache" );
52  fn.SetExt( SchematicLibraryFileExtension );
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;
59  schematic.UpdateSymbolLinks();
60 
61  return success;
62 }
const wxString & GetFileName() const
Definition: sch_screen.h:157
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const std::string SchematicLibraryFileExtension
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the ful...
SCH_SHEET * g_RootSheet
bool CreateArchiveLibrary(const wxString &aFileName)
Create a library aFileName that contains all components used in the current schematic.
Definition: libarch.cpp:65
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References CreateArchiveLibrary(), g_RootSheet, SCH_SCREEN::GetFileName(), GetScreen(), SCH_SHEET::GetScreen(), SchematicLibraryFileExtension, and SCH_SCREENS::UpdateSymbolLinks().

Referenced by Save_File(), and SaveProject().

◆ createCanvas()

void SCH_BASE_FRAME::createCanvas ( )
inherited

Definition at line 374 of file sch_base_frame.cpp.

375 {
377 
378  // Allows only a CAIRO or OPENGL canvas:
381  {
383  }
384 
385  SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
388 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)

References EDA_DRAW_FRAME::ActivateGalCanvas(), EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, EDA_DRAW_FRAME::GetGalDisplayOptions(), EDA_DRAW_FRAME::LoadCanvasTypeSetting(), EDA_DRAW_FRAME::m_canvasType, EDA_BASE_FRAME::m_FrameSize, and EDA_DRAW_FRAME::SetCanvas().

Referenced by SCH_BASE_FRAME::SCH_BASE_FRAME().

◆ CreateNetlist()

NETLIST_OBJECT_LIST * SCH_EDIT_FRAME::CreateNetlist ( bool  aSilent = false,
bool  aSilentAnnotate = false 
)

Create a netlist for the current schematic.

  • Test for some issues (missing or duplicate references and sheet names)
  • Build netlist info
  • Create the netlist file (different formats)
Parameters
aSilentis true if annotation error dialog should be skipped
aSilentAnnotateis true if components should be reannotated silently
Returns
a unique_ptr to the netlist

Definition at line 211 of file netlist_generator.cpp.

213 {
214  if( !aSilent ) // checks for errors and invokes annotation dialog as neccessary
215  {
216  if( !prepareForNetlist() )
217  return nullptr;
218  }
219  else // performs similar function as prepareForNetlist but without a dialog.
220  {
221  SCH_SCREENS schematic;
222  schematic.UpdateSymbolLinks();
223  SCH_SHEET_LIST sheets( g_RootSheet );
224  sheets.AnnotatePowerSymbols();
225 
226  if( aSilentAnnotate )
227  AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
229  }
230 
231  // TODO(JE) This is really going to turn into "PrepareForNetlist"
232  // when the old netlister (BuildNetListBase) is removed
233 
234  return BuildNetListBase();
235 }
SCH_SHEET_LIST.
NETLIST_OBJECT_LIST * BuildNetListBase(bool updateStatusText=true)
Create a flat list which stores all connected objects.
void AnnotateComponents(bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption, ANNOTATE_OPTION_T aAlgoOption, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits, REPORTER &aReporter)
Annotate the components in the schematic that are not currently annotated.
Annotate incrementally using the first free reference number.
bool prepareForNetlist()
Verify that annotation is complete so that a proper netlist is even possible.
Annotate by position of component in the schematic sheet object list.
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the ful...
SCH_SHEET * g_RootSheet
static REPORTER & GetInstance()
Definition: reporter.cpp:104
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References AnnotateComponents(), SCH_SHEET_LIST::AnnotatePowerSymbols(), BuildNetListBase(), g_RootSheet, NULL_REPORTER::GetInstance(), INCREMENTAL_BY_REF, prepareForNetlist(), UNSORTED, and SCH_SCREENS::UpdateSymbolLinks().

Referenced by DIALOG_BOM::OnRunGenerator(), and NETLIST_DIALOG::TransferDataFromWindow().

◆ CreateNewText()

SCH_TEXT * SCH_EDIT_FRAME::CreateNewText ( int  aType)

Definition at line 61 of file edit_label.cpp.

62 {
64  SCH_TEXT* textItem = nullptr;
65 
66  s_queuedTexts.clear();
67 
68  switch( aType )
69  {
70  case LAYER_NOTES:
71  textItem = new SCH_TEXT( cursorPos );
72  break;
73 
74  case LAYER_LOCLABEL:
75  textItem = new SCH_LABEL( cursorPos );
76  break;
77 
78  case LAYER_HIERLABEL:
79  textItem = new SCH_HIERLABEL( cursorPos );
80  textItem->SetShape( lastGlobalLabelShape );
81  break;
82 
83  case LAYER_GLOBLABEL:
84  textItem = new SCH_GLOBALLABEL( cursorPos );
85  textItem->SetShape( lastGlobalLabelShape );
86  break;
87 
88  default:
89  DisplayError( this, wxT( "SCH_EDIT_FRAME::CreateNewText() Internal error" ) );
90  return nullptr;
91  }
92 
93  textItem->SetBold( lastTextBold );
94  textItem->SetItalic( lastTextItalic );
96  textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
97  textItem->SetFlags( IS_NEW | IS_MOVED );
98 
99  if( InvokeDialogLabelEditor( this, textItem ) != wxID_OK || textItem->GetText().IsEmpty() )
100  {
101  delete textItem;
102  return nullptr;
103  }
104 
105  if( aType != LAYER_NOTES )
106  {
107  UTF8 text( textItem->GetText() );
108  int brace_count = 0;
109  int bracket_count = 0;
110  bool last_space = false;
111  UTF8 token;
112 
113  for( auto chIt = text.ubegin(); chIt != text.uend(); chIt++ )
114  {
115  switch( *chIt )
116  {
117  case '{':
118  brace_count++;
119  last_space = false;
120  break;
121 
122  case '[':
123  bracket_count++;
124  last_space = false;
125  break;
126 
127  case '}':
128  brace_count = std::max( 0, brace_count - 1 );
129  last_space = false;
130  break;
131 
132  case ']':
133  bracket_count = std::max( 0, bracket_count - 1 );
134  last_space = false;
135  break;
136 
137  case ' ':
138  case '\n':
139  case '\r':
140  case '\t':
141  if( !token.empty() && bracket_count == 0 && brace_count == 0 )
142  {
143  std::unique_ptr<SCH_TEXT> nextitem( static_cast<SCH_TEXT*>( textItem->Clone() ) );
144  nextitem->SetText( token.wx_str() );
145  s_queuedTexts.push_back( std::move( nextitem ) );
146  token.clear();
147  continue;
148  }
149 
150  // Skip leading whitespace
151  if( token.empty() || last_space )
152  continue;
153 
154  last_space = true;
155  break;
156 
157  default:
158  last_space = false;
159  break;
160  }
161 
162  token += *chIt;
163  }
164 
165  if( !token.empty() )
166  {
167  std::unique_ptr<SCH_TEXT> nextitem( static_cast<SCH_TEXT*>( textItem->Clone() ) );
168  nextitem->SetText( token.wx_str() );
169  s_queuedTexts.push_back( std::move( nextitem ) );
170  }
171 
172  delete textItem;
173  textItem = GetNextNewText();
174 
175  if( !textItem )
176  return nullptr;
177  }
178 
179  lastTextBold = textItem->IsBold();
180  lastTextItalic = textItem->IsItalic();
182 
183  if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T )
184  lastGlobalLabelShape = textItem->GetShape();
185 
186  return textItem;
187 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to...
Definition: utf8.h:73
bool IsBold() const
Definition: eda_text.h:167
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:244
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
static PINSHEETLABEL_SHAPE lastGlobalLabelShape
Definition: edit_label.cpp:42
void SetItalic(bool isItalic)
Definition: eda_text.h:163
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
static bool lastTextItalic
Definition: edit_label.cpp:45
int InvokeDialogLabelEditor(SCH_EDIT_FRAME *aCaller, SCH_TEXT *aTextItem)
Launches the "Edit Text/Label" dialog.
bool IsItalic() const
Definition: eda_text.h:164
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
static std::deque< std::unique_ptr< SCH_TEXT > > s_queuedTexts
Definition: edit_label.cpp:47
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:118
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
static LABEL_SPIN_STYLE lastTextOrientation
Definition: edit_label.cpp:43
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:237
SCH_TEXT * GetNextNewText()
Gets the next queued text item.
Definition: edit_label.cpp:49
wxString wx_str() const
Definition: utf8.cpp:51
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:206
static bool lastTextBold
Definition: edit_label.cpp:44
void clear()
Definition: utf8.h:113
void SetBold(bool aBold)
Definition: eda_text.h:166
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
int GetDefaultTextSize()
Default size for text in general.
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:242
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
bool empty() const
Definition: utf8.h:108
#define IS_MOVED
Item being moved.
Definition: base_struct.h:119

References UTF8::clear(), SCH_TEXT::Clone(), DisplayError(), UTF8::empty(), SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), GetDefaultTextSize(), SCH_TEXT::GetLabelSpinStyle(), GetNextNewText(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), EDA_DRAW_PANEL_GAL::GetViewControls(), InvokeDialogLabelEditor(), IS_MOVED, IS_NEW, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), lastGlobalLabelShape, lastTextBold, lastTextItalic, lastTextOrientation, LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, s_queuedTexts, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EDA_TEXT::SetBold(), EDA_ITEM::SetFlags(), EDA_TEXT::SetItalic(), SCH_TEXT::SetLabelSpinStyle(), SCH_TEXT::SetShape(), EDA_TEXT::SetTextSize(), EDA_ITEM::Type(), and UTF8::wx_str().

Referenced by SCH_DRAWING_TOOLS::TwoClickPlace().

◆ CreateScreens()

void SCH_EDIT_FRAME::CreateScreens ( )

Definition at line 413 of file sch_edit_frame.cpp.

414 {
415  if( g_RootSheet == NULL )
416  g_RootSheet = new SCH_SHEET();
417 
418  if( g_RootSheet->GetScreen() == NULL )
419  {
420  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
422  g_RootSheet->SetScreen( screen );
424  }
425 
426  g_RootSheet->GetScreen()->SetFileName( wxEmptyString );
427 
431 
432  if( GetScreen() == NULL )
433  {
434  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
436  SetScreen( screen );
437  }
438 
439  GetScreen()->SetZoom( 32.0 );
440 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SetScreen(BASE_SCREEN *aScreen) override
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:149
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define NULL
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
Definition: base_screen.cpp:88
void clear()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
void SetMaxUndoItems(int aMax)
Definition: base_screen.h:213
SCH_SHEET * g_RootSheet
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:155

References SCH_SHEET_PATH::clear(), g_ConnectionGraph, g_CurrentSheet, g_RootSheet, GetScreen(), SCH_SHEET::GetScreen(), KIWAY_HOLDER::Kiway(), EDA_DRAW_FRAME::m_UndoRedoCountMax, NULL, SCH_SHEET_PATH::push_back(), CONNECTION_GRAPH::Reset(), SCH_SCREEN::SetFileName(), BASE_SCREEN::SetMaxUndoItems(), SCH_SHEET::SetScreen(), SetScreen(), and BASE_SCREEN::SetZoom().

Referenced by importFile(), and OpenProjectFiles().

◆ CreateServer()

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

Definition at line 49 of file eda_dde.cpp.

50 {
51  wxIPV4address addr;
52 
53  // Set the port number
54  addr.Service( service );
55 
56  // Listen on localhost only if requested
57  if( local )
58  addr.Hostname( HOSTNAME );
59 
60  delete m_socketServer;
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 }
static const wxString HOSTNAME(wxT("localhost"))
wxSocketServer * m_socketServer

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

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

◆ CreateSheetPin()

SCH_SHEET_PIN * SCH_EDIT_FRAME::CreateSheetPin ( SCH_SHEET aSheet,
SCH_HIERLABEL aLabel 
)

Create a new SCH_SHEET_PIN object and add it to aSheet at the current cursor position.

Parameters
aSheetThe sheet to add the new sheet pin to.
Returns
The new sheet pin object created or NULL if the task was aborted by the user.

Definition at line 511 of file sheet.cpp.

512 {
513  wxString text;
514  SCH_SHEET_PIN* sheetPin;
515 
516  if( aLabel )
517  {
518  text = aLabel->GetText();
519  m_lastSheetPinType = aLabel->GetShape();
520  }
521 
522  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
523  sheetPin->SetFlags( IS_NEW );
524  sheetPin->SetTextSize( GetLastSheetPinTextSize() );
525  sheetPin->SetShape( m_lastSheetPinType );
526 
527  if( !aLabel )
528  {
529  DIALOG_EDIT_SHEET_PIN dlg( this, sheetPin );
530 
531  if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
532  {
533  delete sheetPin;
534  return nullptr;
535  }
536  }
537 
538  m_lastSheetPinType = sheetPin->GetShape();
539  m_lastSheetPinTextSize = sheetPin->GetTextSize();
540 
541  sheetPin->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
542 
543  return sheetPin;
544 }
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:244
static wxSize m_lastSheetPinTextSize
Last sheet pin text size.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
static PINSHEETLABEL_SHAPE m_lastSheetPinType
Last sheet pin type.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
const wxSize & GetLastSheetPinTextSize()
Initializing accessor for the pin text size.
Definition: sheet.cpp:499
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.h:204
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:242

References SCH_BASE_FRAME::GetCanvas(), GetLastSheetPinTextSize(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), EDA_TEXT::GetTextSize(), IS_NEW, m_lastSheetPinTextSize, m_lastSheetPinType, EDA_ITEM::SetFlags(), SCH_SHEET_PIN::SetPosition(), SCH_TEXT::SetShape(), and EDA_TEXT::SetTextSize().

Referenced by SCH_DRAWING_TOOLS::TwoClickPlace().

◆ CurrentToolName()

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

Definition at line 252 of file eda_base_frame.cpp.

253 {
254  if( m_toolStack.empty() )
255  return ACTIONS::selectionTool.GetName();
256  else
257  return m_toolStack.back();
258 }
std::vector< std::string > m_toolStack
static TOOL_ACTION selectionTool
Definition: actions.h:146

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

Referenced by TOOL_MANAGER::processEvent().

◆ DefaultExecFlags()

void SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

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

Definition at line 1011 of file sch_edit_frame.h.

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

References m_exec_flags.

Referenced by WriteNetListFile().

◆ DeleteAllTemplateFieldNames()

void SCH_EDIT_FRAME::DeleteAllTemplateFieldNames ( bool  aGlobal)
inline

Remove all global or project fieldname templates.

Definition at line 291 of file sch_edit_frame.h.

292  {
294  }
TEMPLATES m_templateFieldNames
void DeleteAllFieldNameTemplates(bool aGlobal)
Function DeleteAllFieldNameTemplates deletes the entire contents.

References TEMPLATES::DeleteAllFieldNameTemplates(), and SCH_BASE_FRAME::m_templateFieldNames.

Referenced by PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow().

◆ DeleteAnnotation()

void SCH_EDIT_FRAME::DeleteAnnotation ( bool  aCurrentSheetOnly)

Clear the current component annotation.

Parameters
aCurrentSheetOnlyClear only the annotation for the current sheet if true. Otherwise clear the entire schematic annotation.

Definition at line 61 of file eeschema/annotate.cpp.

62 {
63  if( aCurrentSheetOnly )
64  {
65  SCH_SCREEN* screen = GetScreen();
66  wxCHECK_RET( screen != NULL, wxT( "Attempt to clear annotation of a NULL screen." ) );
68  }
69  else
70  {
71  SCH_SCREENS ScreenList;
72  ScreenList.ClearAnnotation();
73  }
74 
75  // Update the references for the sheet that is currently being displayed.
77 
78  SyncView();
79  GetCanvas()->Refresh();
80  OnModify();
81 }
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define NULL
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:732
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References SCH_SCREEN::ClearAnnotation(), SCH_SCREENS::ClearAnnotation(), g_CurrentSheet, SCH_BASE_FRAME::GetCanvas(), GetScreen(), NULL, OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_BASE_FRAME::SyncView(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

Referenced by AnnotateComponents(), and DIALOG_ANNOTATE::OnClearAnnotationCmpClick().

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

355 {
356  SCH_SCREEN* screen = GetScreen();
357  PICKED_ITEMS_LIST undoList;
359  KICAD_T wiresAndBusses[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
360 
361  auto remove_item = [ & ]( SCH_ITEM* aItem ) -> void
362  {
363  aItem->SetFlags( STRUCT_DELETED );
364  undoList.PushItem( ITEM_PICKER( aItem, UR_DELETED ) );
365  };
366 
367  remove_item( aJunction );
368  RemoveFromScreen( aJunction );
369 
372  std::list<SCH_LINE*> lines;
373 
374  for( auto item : screen->Items().Overlapping( SCH_LINE_T, aJunction->GetPosition() ) )
375  {
376  auto line = static_cast<SCH_LINE*>( item );
377 
378  if( line->IsType( wiresAndBusses ) && line->IsEndPoint( aJunction->GetPosition() )
379  && !( line->GetEditFlags() & STRUCT_DELETED ) )
380  lines.push_back( line );
381  }
382 
384  lines.begin(), lines.end(), [&]( SCH_LINE* firstLine, SCH_LINE* secondLine ) {
385  if( ( firstLine->GetEditFlags() & STRUCT_DELETED )
386  || ( secondLine->GetEditFlags() & STRUCT_DELETED )
387  || !secondLine->IsParallel( firstLine ) )
388  return;
389 
390  // Remove identical lines
391  if( firstLine->IsEndPoint( secondLine->GetStartPoint() )
392  && firstLine->IsEndPoint( secondLine->GetEndPoint() ) )
393  {
394  remove_item( firstLine );
395  return;
396  }
397 
398  // Try to merge the remaining lines
399  if( SCH_LINE* line = secondLine->MergeOverlap( firstLine ) )
400  {
401  remove_item( firstLine );
402  remove_item( secondLine );
403  undoList.PushItem( ITEM_PICKER( line, UR_NEW ) );
404  AddToScreen( line );
405 
406  if( line->IsSelected() )
407  selectionTool->AddItemToSel( line, true /*quiet mode*/ );
408 
409  lines.push_back( line );
410  }
411  } );
412 
413  SaveCopyInUndoList( undoList, UR_DELETED, aAppend );
414 
415 
416  for( auto line : lines )
417  {
418  if( line->GetEditFlags() & STRUCT_DELETED )
419  {
420  if( line->IsSelected() )
421  selectionTool->RemoveItemFromSel( line, true /*quiet mode*/ );
422 
423  RemoveFromScreen( line );
424  }
425  }
426 }
SCH_LINE * MergeOverlap(SCH_LINE *aLine)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:396
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
EE_TYPE Overlapping(const EDA_RECT &aRect)
Definition: sch_rtree.h:224
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
Definition: kicad_algo.h:63
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:262
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:90
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
int AddItemToSel(const TOOL_EVENT &aEvent)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
EE_RTREE & Items()
Definition: sch_screen.h:127
TOOL_MANAGER * m_toolManager
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147

References EE_SELECTION_TOOL::AddItemToSel(), SCH_BASE_FRAME::AddToScreen(), EOT, alg::for_all_pairs(), EDA_ITEM::GetEditFlags(), SCH_ITEM::GetPosition(), GetScreen(), TOOL_MANAGER::GetTool(), SCH_LINE::IsEndPoint(), SCH_SCREEN::Items(), EDA_BASE_FRAME::m_toolManager, SCH_LINE::MergeOverlap(), EE_RTREE::Overlapping(), PICKED_ITEMS_LIST::PushItem(), SCH_BASE_FRAME::RemoveFromScreen(), EE_SELECTION_TOOL::RemoveItemFromSel(), SaveCopyInUndoList(), SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, SCH_LINE_T, STRUCT_DELETED, UR_DELETED, and UR_NEW.

Referenced by SCH_EDIT_TOOL::DoDelete().

◆ Destroy()

◆ DismissModal()

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

Definition at line 160 of file kiway_player.cpp.

161 {
162  m_modal_ret_val = aRetVal;
163  m_modal_string = aResult;
164 
165  if( m_modal_loop )
166  {
167  m_modal_loop->Exit();
168  m_modal_loop = 0; // this marks it as dismissed.
169  }
170 
171  Show( false );
172 }
bool m_modal_ret_val
Definition: kiway_player.h:192
wxString m_modal_string
Definition: kiway_player.h:191
WX_EVENT_LOOP * m_modal_loop
Definition: kiway_player.h:189

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

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint(), LIB_VIEW_FRAME::FinishModal(), LIB_VIEW_FRAME::OnCloseWindow(), FOOTPRINT_VIEWER_FRAME::OnCloseWindow(), and FOOTPRINT_WIZARD_FRAME::OnCloseWindow().

◆ DisplayCurrentSheet()

void SCH_EDIT_FRAME::DisplayCurrentSheet ( )

Draw the current sheet on the display.

Definition at line 218 of file hierarch.cpp.

219 {
222 
223  SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
224 
225  wxASSERT( screen );
226 
227  // Switch to current sheet,
228  // and update the grid size, because it can be modified in latest screen
229  SetScreen( screen );
231 
232  // update the References
235 
236  if( !screen->m_Initialized )
237  {
239  screen->m_Initialized = true;
240  screen->ClearUndoORRedoList( screen->m_UndoList, 1 );
241  }
242  else
243  {
244  // RedrawScreen() will set zoom to last used
245  RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
246  }
247 
248  UpdateTitle();
249 
252  editTool->UpdateNetHighlighting( dummy );
253 
254  HardRedraw(); // Ensure any item has its view updated, especially the worksheet items
255 }
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
void SetScreen(BASE_SCREEN *aScreen) override
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_EDITOR_CONTROL.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void HardRedraw() override
Rebuild the GAL and redraw the screen.
UNDO_REDO_CONTAINER m_UndoList
Objects list for the undo command (old data)
Definition: base_screen.h:132
bool m_Initialized
Definition: base_screen.h:129
TOOL_EVENT.
Definition: tool_event.h:171
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Updates net highlighting after an edit
SCH_SCREEN * LastScreen()
Function LastScreen.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
TOOL_MANAGER * m_toolManager
virtual void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Free the undo or redo list from aList element.
Definition: sch_screen.cpp:627
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.

References ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, SCH_SCREEN::ClearUndoORRedoList(), dummy(), g_CurrentSheet, GetScreen(), TOOL_MANAGER::GetTool(), HardRedraw(), ID_POPUP_GRID_LEVEL_1000, SCH_SHEET_PATH::LastScreen(), BASE_SCREEN::m_Initialized, EDA_DRAW_FRAME::m_LastGridSizeId, EDA_BASE_FRAME::m_toolManager, BASE_SCREEN::m_UndoList, SCH_BASE_FRAME::RedrawScreen(), TOOL_MANAGER::RunAction(), BASE_SCREEN::SetGrid(), SetScreen(), SetSheetNumberAndCount(), SCH_SHEET_PATH::UpdateAllScreenReferences(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), UpdateTitle(), and ACTIONS::zoomFitScreen.

Referenced by SCH_EDITOR_CONTROL::EnterSheet(), SCH_EDITOR_CONTROL::FindComponentAndItem(), SCH_EDITOR_CONTROL::LeaveSheet(), DIALOG_ERC::OnERCItemSelected(), OnPageSettingsChange(), and HIERARCHY_NAVIG_DLG::onSelectSheetPath().

◆ DisplayGridMsg()

void EDA_DRAW_FRAME::DisplayGridMsg ( )
inherited

Display current grid pane on the status bar.

Definition at line 373 of file eda_draw_frame.cpp.

374 {
375  wxString line;
376  wxString gridformatter;
377 
378  switch( m_userUnits )
379  {
380  case EDA_UNITS::INCHES:
381  gridformatter = "grid %.3f";
382  break;
383 
385  gridformatter = "grid %.4f";
386  break;
387 
388  default:
389  gridformatter = "grid %f";
390  break;
391  }
392 
393  wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
394  double grid = To_User_Unit( m_userUnits, curr_grid_size.x );
395  line.Printf( gridformatter, grid );
396 
397  SetStatusText( line, 4 );
398 }
double To_User_Unit(EDA_UNITS aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:95
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:279
EDA_UNITS m_userUnits
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.

References BASE_SCREEN::GetGridSize(), EDA_DRAW_FRAME::GetScreen(), INCHES, EDA_BASE_FRAME::m_userUnits, MILLIMETRES, and To_User_Unit().

Referenced by SCH_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 364 of file eda_draw_frame.cpp.

365 {
366  SetStatusText( msg, 6 );
367 }

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

◆ DisplayUnitsMsg()

void EDA_DRAW_FRAME::DisplayUnitsMsg ( )
inherited

Display current unit pane on the status bar.

Definition at line 401 of file eda_draw_frame.cpp.

402 {
403  wxString msg;
404 
405  switch( m_userUnits )
406  {
407  case EDA_UNITS::INCHES:
408  msg = _( "Inches" );
409  break;
411  msg = _( "mm" );
412  break;
413  default: msg = _( "Units" ); break;
414  }
415 
416  SetStatusText( msg, 5 );
417 }
#define _(s)
Definition: 3d_actions.cpp:33
EDA_UNITS m_userUnits

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

Referenced by GERBVIEW_FRAME::updateGridSelectBox(), PCB_BASE_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 574 of file eeschema/files-io.cpp.

575 {
576  wxFileName tmpFileName = g_RootSheet->GetFileName();
577  wxFileName fn = tmpFileName;
578  wxFileName tmp;
579  SCH_SCREENS screens;
580 
581  bool autoSaveOk = true;
582 
583  tmp.AssignDir( fn.GetPath() );
584 
585  if( !tmp.IsOk() )
586  return false;
587 
588  if( !IsWritable( tmp ) )
589  return false;
590 
591  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
592  {
593  // Only create auto save files for the schematics that have been modified.
594  if( !screen->IsSave() )
595  continue;
596 
597  tmpFileName = fn = screen->GetFileName();
598 
599  // Auto save file name is the normal file name prefixed with GetAutoSavePrefix().
600  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
601 
602  screen->SetFileName( fn.GetFullPath() );
603 
604  if( SaveEEFile( screen, false, NO_BACKUP_FILE ) )
605  screen->SetModify();
606  else
607  autoSaveOk = false;
608 
609  screen->SetFileName( tmpFileName.GetFullPath() );
610  }
611 
612  if( autoSaveOk )
613  m_autoSaveState = false;
614 
615  return autoSaveOk;
616 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
bool IsWritable(const wxFileName &aFileName)
Checks if aFileName can be written.
#define NO_BACKUP_FILE
bool SaveEEFile(SCH_SCREEN *aScreen, bool aSaveUnderNewName=false, bool aCreateBackupFile=CREATE_BACKUP_FILE)
Save aScreen to a schematic file.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:491
static wxString GetAutoSaveFilePrefix()
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
SCH_SHEET * g_RootSheet
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References g_RootSheet, EDA_BASE_FRAME::GetAutoSaveFilePrefix(), SCH_SHEET::GetFileName(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), EDA_BASE_FRAME::IsWritable(), EDA_BASE_FRAME::m_autoSaveState, NO_BACKUP_FILE, and SaveEEFile().

◆ DoShowSchematicSetupDialog()

void SCH_EDIT_FRAME::DoShowSchematicSetupDialog ( const wxString &  aInitialPage = wxEmptyString,
const wxString &  aInitialParentPage = wxEmptyString 
)

Definition at line 462 of file eeschema_config.cpp.

464 {
465  DIALOG_SCHEMATIC_SETUP dlg( this );
466 
467  if( !aInitialPage.IsEmpty() )
468  dlg.SetInitialPage( aInitialPage, aInitialParentPage );
469 
470  if( dlg.ShowQuasiModal() == wxID_OK )
471  {
473 
474  GetCanvas()->Refresh();
475  OnModify();
476  }
477 }
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...

References SCH_BASE_FRAME::GetCanvas(), OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), SaveProjectSettings(), PAGED_DIALOG::SetInitialPage(), and DIALOG_SHIM::ShowQuasiModal().

Referenced by DIALOG_ERC::OnERCItemRClick(), and SCH_EDITOR_CONTROL::ShowSchematicSetup().

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

566 {
567  wxRect DrawArea;
568  BASE_SCREEN* screen = GetScreen();
569 
570  DrawArea.SetSize( GetPageSizeIU() );
571 
572  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
573  // the drawings into the dc size
574  // scale is the ratio resolution (in PPI) / internal units
575  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
576  double inch2Iu = 1000.0 * IU_PER_MILS;
577  double scale = ppi / inch2Iu;
578 
579  wxSize dcsize = DrawArea.GetSize();
580 
581  int maxdim = std::max( dcsize.x, dcsize.y );
582 
583  // the max size in pixels of the bitmap used to byuild the sheet copy
584  const int maxbitmapsize = 3000;
585 
586  while( int( maxdim * scale ) > maxbitmapsize )
587  {
588  ppi = ppi / 1.5;
589  scale = ppi / inch2Iu;
590  }
591 
592  dcsize.x *= scale;
593  dcsize.y *= scale;
594 
595  // Set draw offset, zoom... to values needed to draw in the memory DC
596  // after saving initial values:
597  wxPoint tmp_startvisu = screen->m_StartVisu;
598  double tmpzoom = screen->GetZoom();
599  wxPoint old_org = screen->m_DrawOrg;
600  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
601  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
602 
603  screen->SetZoom( 1 ); // we use zoom = 1 in draw functions.
604 
605  wxMemoryDC dc;
606  wxBitmap image( dcsize );
607  dc.SelectObject( image );
608 
609  GRResetPenAndBrush( &dc );
610  GRForceBlackPen( false );
611  screen->m_IsPrinting = true;
612  dc.SetUserScale( scale, scale );
613 
614  dc.Clear();
615  PrintPage( &dc );
616  screen->m_IsPrinting = false;
617 
618  if( wxTheClipboard->Open() )
619  {
620  // This data objects are held by the clipboard, so do not delete them in the app.
621  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
622  wxTheClipboard->SetData( clipbrd_data );
623  wxTheClipboard->Close();
624  }
625 
626  // Deselect Bitmap from DC in order to delete the MemoryDC
627  dc.SelectObject( wxNullBitmap );
628 
629  GRForceBlackPen( false );
630 
631  screen->m_StartVisu = tmp_startvisu;
632  screen->m_DrawOrg = old_org;
633  screen->SetZoom( tmpzoom );
634 }
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:120
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:240
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:117
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:201
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
Definition: base_screen.cpp:88
bool m_IsPrinting
Definition: base_screen.h:139
virtual void PrintPage(wxDC *aDC) override
Plot or print the current sheet to the clipboard.
const int scale
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:112
#define IU_PER_MILS
Definition: plotter.cpp:137

References SCH_BASE_FRAME::GetPageSizeIU(), GetScreen(), BASE_SCREEN::GetZoom(), GRForceBlackPen(), GRResetPenAndBrush(), IU_PER_MILS, BASE_SCREEN::m_DrawOrg, BASE_SCREEN::m_IsPrinting, BASE_SCREEN::m_StartVisu, PrintPage(), scale, BASE_SCREEN::SetZoom(), wxPoint::x, and wxPoint::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 existying file, or becomes a new instance of a already existing sheet.

Definition at line 479 of file sheet.cpp.

481 {
482  if( aSheet == NULL || aHierarchy == NULL )
483  return false;
484 
485  // Get the new texts
486  DIALOG_SCH_SHEET_PROPS dlg( this, aSheet, aClearAnnotationNewItems );
487 
488  if( dlg.ShowModal() == wxID_CANCEL )
489  return false;
490 
491  return true;
492 }
#define NULL

References NULL.

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

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

Definition at line 216 of file eda_draw_frame.cpp.

217 {
218  if( m_messagePanel )
220 }
EDA_MSG_PANEL * m_messagePanel
void EraseMsgBox()
Definition: msgpanel.cpp:216

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

Referenced by GERBVIEW_CONTROL::UpdateMessagePanel().

◆ ExecuteRemoteCommand()

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

Execute a remote command send by Pcbnew via a socket, port KICAD_SCH_PORT_SERVICE_NUMBER (currently 4243) this is a virtual function called by EDA_DRAW_FRAME::OnSockRequest().

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

Parameters
cmdline= received command from socket

When user selects a module or pin in Pcbnew, Eeschema shows that same component 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 component.
  • $PART: "reference" $REF: "ref" Put cursor on component reference.
  • $PART: "reference" $VAL: "value" Put cursor on component value.
  • $PART: "reference" $PAD: "pin name" Put cursor on the component pin.
  • $NET: "netname" Highlight a specified net
  • $CLEAR: "HIGHLIGHTED" Clear components highlight

They are a keyword followed by a quoted string.

Parameters
cmdline= received command from Pcbnew

Reimplemented from EDA_DRAW_FRAME.

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

174 {
176  char line[1024];
177 
178  strncpy( line, cmdline, sizeof(line) - 1 );
179  line[ sizeof(line) - 1 ] = '\0';
180 
181  char* idcmd = strtok( line, " \n\r" );
182  char* text = strtok( NULL, "\"\n\r" );
183 
184  if( idcmd == NULL )
185  return;
186 
187  if( strcmp( idcmd, "$NET:" ) == 0 )
188  {
189  m_SelectedNetName = FROM_UTF8( text );
191 
192  SetStatusText( _( "Selected net: " ) + UnescapeString( m_SelectedNetName ) );
193  return;
194  }
195 
196  if( strcmp( idcmd, "$CLEAR:" ) == 0 )
197  {
198  if( text && strcmp( text, "HIGHLIGHTED" ) == 0 )
199  {
200  GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
201  GetCanvas()->Refresh();
202  }
203 
204  return;
205  }
206 
207  if( text == NULL )
208  return;
209 
210  if( strcmp( idcmd, "$PART:" ) != 0 )
211  return;
212 
213  wxString part_ref = FROM_UTF8( text );
214 
215  /* look for a complement */
216  idcmd = strtok( NULL, " \n\r" );
217 
218  if( idcmd == NULL ) // Highlight component only (from Cvpcb or Pcbnew)
219  {
220  // Highlight component part_ref, or clear Highlight, if part_ref is not existing
221  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
222  return;
223  }
224 
225  text = strtok( NULL, "\"\n\r" );
226 
227  if( text == NULL )
228  return;
229 
230  wxString msg = FROM_UTF8( text );
231 
232  if( strcmp( idcmd, "$REF:" ) == 0 )
233  {
234  // Highlighting the reference itself isn't actually that useful, and it's harder to
235  // see. Highlight the parent and display the message.
236  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
237  }
238  else if( strcmp( idcmd, "$VAL:" ) == 0 )
239  {
240  // Highlighting the value itself isn't actually that useful, and it's harder to see.
241  // Highlight the parent and display the message.
242  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
243  }
244  else if( strcmp( idcmd, "$PAD:" ) == 0 )
245  {
246  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_PIN, msg );
247  }
248  else
249  {
250  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
251  }
252 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:62
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:204
void HighlightItem(EDA_ITEM *aItem, LIB_PIN *aPin=nullptr)
Definition: sch_view.cpp:226
SCH_EDITOR_CONTROL.
SCH_ITEM * FindComponentAndItem(const wxString &aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
Finds a component in the schematic and an item in this component.
#define NULL
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
wxString m_SelectedNetName
#define _(s)
Definition: 3d_actions.cpp:33
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
TOOL_MANAGER * m_toolManager

References _, SCH_EDITOR_CONTROL::FindComponentAndItem(), FROM_UTF8(), SCH_BASE_FRAME::GetCanvas(), TOOL_MANAGER::GetTool(), EDA_BASE_FRAME::GetToolManager(), SCH_DRAW_PANEL::GetView(), HIGHLIGHT_COMPONENT, HIGHLIGHT_PIN, KIGFX::SCH_VIEW::HighlightItem(), m_SelectedNetName, EDA_BASE_FRAME::m_toolManager, NULL, EDA_DRAW_PANEL_GAL::Refresh(), TOOL_MANAGER::RunAction(), UnescapeString(), and EE_ACTIONS::updateNetHighlighting.

Referenced by KiwayMailIn().

◆ FindHierarchyNavigator()

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

Definition at line 656 of file sch_edit_frame.cpp.

657 {
658  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
659 
660  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
661 }
#define HIERARCHY_NAVIG_DLG_WNAME
Definition: hierarch.h:35

References HIERARCHY_NAVIG_DLG_WNAME.

Referenced by OnCloseWindow(), and UpdateHierarchyNavigator().

◆ FixupJunctions()

void SCH_EDIT_FRAME::FixupJunctions ( )

Definition at line 1138 of file sch_edit_frame.cpp.

1139 {
1140  // Save the current sheet, to retrieve it later
1141  auto currSheet = GetCurrentSheet();
1142 
1143  SCH_SHEET_LIST sheetList;
1144  sheetList.BuildSheetList( g_RootSheet );
1145 
1146  for( const SCH_SHEET_PATH& sheet : sheetList )
1147  {
1148  // We require a set here to avoid adding multiple junctions to the same spot
1149  std::set<wxPoint> junctions;
1150 
1151  SetCurrentSheet( sheet );
1153 
1154  auto screen = GetCurrentSheet().LastScreen();
1155 
1156  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1157  {
1158  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1159  auto xform = cmp->GetTransform();
1160 
1161  for( const SCH_PIN* pin : cmp->GetSchPins( &sheet ) )
1162  {
1163  auto pos = cmp->GetPosition() + xform.TransformCoordinate( pin->GetPosition() );
1164 
1165  // Test if a _new_ junction is needed, and add it if missing
1166  if( screen->IsJunctionNeeded( pos, true ) )
1167  junctions.insert( pos );
1168  }
1169  }
1170 
1171  for( auto& pos : junctions )
1172  AddJunction( pos );
1173  }
1174 
1175  // Reselect the initial sheet:
1176  SetCurrentSheet( currSheet );
1178  SetScreen( GetCurrentSheet().LastScreen() );
1179 }
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
SCH_SHEET_LIST.
void SetScreen(BASE_SCREEN *aScreen) override
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
SCH_SHEET_PATH & GetCurrentSheet()
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
SCH_SHEET_PATH.
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
SCH_SCREEN * LastScreen()
Function LastScreen.
SCH_SHEET * g_RootSheet

References AddJunction(), SCH_SHEET_LIST::BuildSheetList(), g_RootSheet, GetCurrentSheet(), SCH_SHEET_PATH::LastScreen(), SCH_COMPONENT_T, SetCurrentSheet(), SetScreen(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

Referenced by OpenProjectFiles().

◆ FocusOnItem()

void SCH_BASE_FRAME::FocusOnItem ( SCH_ITEM aItem)
inherited

Definition at line 318 of file sch_base_frame.cpp.

319 {
320  static KIID lastBrightenedItemID( niluuid );
321 
322  SCH_SHEET_LIST sheetList( g_RootSheet );
324  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
325 
326  if( lastItem && lastItem != aItem )
327  {
328  lastItem->ClearBrightened();
329 
330  RefreshItem( lastItem );
331  lastBrightenedItemID = niluuid;
332  }
333 
334  if( aItem )
335  {
336  aItem->SetBrightened();
337 
338  RefreshItem( aItem );
339  lastBrightenedItemID = aItem->m_Uuid;
340 
341  wxPoint position = aItem->GetPosition();
342 
343  if( aItem->GetParent() && aItem->GetParent()->Type() == SCH_COMPONENT_T )
344  {
345  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
346  position += comp->GetPosition();
347  }
348 
349  FocusOnLocation( position );
350  }
351 }
SCH_SHEET_LIST.
void SetBrightened()
Definition: base_struct.h:233
void ClearBrightened()
Definition: base_struct.h:237
Definition: common.h:65
virtual wxPoint GetPosition() const =0
Function GetPosition.
KIID niluuid(0)
EDA_ITEM * GetParent() const
Definition: base_struct.h:217
SCH_SHEET_PATH.
const KIID m_Uuid
Definition: base_struct.h:169
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
wxPoint GetPosition() const override
Function GetPosition.
SCH_SHEET * g_RootSheet
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References EDA_ITEM::ClearBrightened(), dummy(), EDA_DRAW_FRAME::FocusOnLocation(), g_RootSheet, SCH_SHEET_LIST::GetItem(), EDA_ITEM::GetParent(), SCH_ITEM::GetPosition(), SCH_COMPONENT::GetPosition(), EDA_ITEM::m_Uuid, niluuid, SCH_BASE_FRAME::RefreshItem(), SCH_COMPONENT_T, EDA_ITEM::SetBrightened(), and EDA_ITEM::Type().

Referenced by HardRedraw(), EE_SELECTION_TOOL::Main(), DIALOG_ERC::OnButtonCloseClick(), DIALOG_ERC::OnCloseErcDialog(), DIALOG_ERC::OnERCItemSelected(), and SetCurrentSheet().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const wxPoint aPos)
inherited

Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor) at a given coordinate and reframes the drawing if the requested point is out of view or if center on location is requested.

Parameters
aPosis the point to go to.

Definition at line 688 of file eda_draw_frame.cpp.

689 {
690  bool centerView = false;
691  BOX2D r = GetCanvas()->GetView()->GetViewport();
692 
693  // Center if we're off the current view, or within 10% of its edge
694  r.Inflate( - (int) r.GetWidth() / 10 );
695 
696  if( !r.Contains( aPos ) )
697  centerView = true;
698 
699  // Center if we're behind an obscuring dialog, or within 10% of its edge
700  wxWindow* dialog = findDialog( GetChildren() );
701 
702  if( dialog )
703  {
704  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
705  dialog->GetSize() );
706  dialogRect.Inflate( dialogRect.GetWidth() / 10 );
707 
708  if( dialogRect.Contains( (wxPoint) GetCanvas()->GetView()->ToScreen( aPos ) ) )
709  centerView = true;
710  }
711 
712  if( centerView )
713  {
714  // If a dialog partly obscures the window, then center on the uncovered area.
715  if( dialog )
716  {
717  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
718  dialog->GetSize() );
719  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
720  }
721  else
722  GetCanvas()->GetView()->SetCenter( aPos );
723  }
724 
726 }
BOX2D GetViewport() const
Function GetViewport() Returns the current viewport visible area rectangle.
Definition: view.cpp:538
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:604
coord_type GetWidth() const
Definition: box2.h:196
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:150
wxWindow * findDialog(wxWindowList &aList)
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:301

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

Referenced by SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindNext(), PCB_BASE_FRAME::FocusOnItem(), SCH_BASE_FRAME::FocusOnItem(), and DIALOG_FIND::search().

◆ GetAboutTitle()

const wxString& EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

Definition at line 517 of file eda_base_frame.h.

517 { return m_AboutTitle; }
wxString m_AboutTitle

References EDA_BASE_FRAME::m_AboutTitle.

Referenced by DIALOG_ABOUT::DIALOG_ABOUT().

◆ GetAutoplaceAlign()

bool SCH_EDIT_FRAME::GetAutoplaceAlign ( ) const
inline

Definition at line 232 of file sch_edit_frame.h.

232 { return m_autoplaceAlign; }
bool m_autoplaceAlign
align autoplaced fields to the grid

References m_autoplaceAlign.

Referenced by PANEL_EESCHEMA_SETTINGS::TransferDataToWindow().

◆ GetAutoplaceFields()

bool SCH_EDIT_FRAME::GetAutoplaceFields ( ) const
inline

◆ GetAutoplaceJustify()

bool SCH_EDIT_FRAME::GetAutoplaceJustify ( ) const
inline

Definition at line 235 of file sch_edit_frame.h.

235 { return m_autoplaceJustify; }
bool m_autoplaceJustify
allow autoplace to change justification

References m_autoplaceJustify.

Referenced by PANEL_EESCHEMA_SETTINGS::TransferDataToWindow().

◆ GetAutoSaveFilePrefix()

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

Definition at line 171 of file eda_base_frame.h.

172  {
173  return wxT( "_autosave-" );
174  }

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), doAutoSave(), PCB_EDIT_FRAME::doAutoSave(), PCB_EDIT_FRAME::Files_io_from_id(), OnCloseWindow(), PCB_EDIT_FRAME::OnExportSTEP(), SaveEEFile(), and PCB_EDIT_FRAME::SavePcbFile().

◆ GetAutoSaveInterval()

int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 303 of file eda_base_frame.h.

303 { return m_autoSaveInterval; }

References EDA_BASE_FRAME::m_autoSaveInterval.

◆ GetAuxOrigin()

const wxPoint & SCH_BASE_FRAME::GetAuxOrigin ( ) const
overridevirtualinherited

Return the origin of the axis used for plotting and various exports.

Implements EDA_DRAW_FRAME.

Definition at line 148 of file sch_base_frame.cpp.

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

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

◆ GetBackupSuffix()

static wxString EDA_BASE_FRAME::GetBackupSuffix ( )
inlinestaticprotectedinherited
Returns
the suffix to be appended to the file extension on backup

Definition at line 163 of file eda_base_frame.h.

164  {
165  return wxT( "-bak" );
166  }

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), PCB_EDIT_FRAME::createBackupFile(), PCB_EDIT_FRAME::Files_io_from_id(), and SaveEEFile().

◆ GetCanvas()

SCH_DRAW_PANEL * SCH_BASE_FRAME::GetCanvas ( ) const
overridevirtualinherited

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

Returns
Pointer to GAL-based canvas.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 361 of file sch_base_frame.cpp.

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

References EDA_DRAW_FRAME::GetCanvas().

Referenced by AddItemToScreenAndUndoList(), AddJunction(), SCH_BASE_FRAME::AddToScreen(), AnnotateComponents(), SCH_EDITOR_CONTROL::BackAnnotateFootprints(), SCH_EDIT_TOOL::BreakWire(), SCH_BASE_FRAME::CenterScreen(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), ConvertTextType(), CreateNewText(), CreateSheetPin(), DeleteAnnotation(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EE_SELECTION_TOOL::doSelectionMenu(), DoShowSchematicSetupDialog(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::editFieldProperties(), LIB_EDIT_TOOL::editGraphicProperties(), LIB_EDIT_TOOL::editTextProperties(), ExecuteRemoteCommand(), SCH_EDITOR_CONTROL::FindComponentAndItem(), SCH_EDITOR_CONTROL::FindNext(), SCH_BASE_FRAME::GetRenderSettings(), SCH_BASE_FRAME::HardRedraw(), HardRedraw(), SCH_EDITOR_CONTROL::ImportFPAssignments(), KiwayMailIn(), LIB_VIEW_FRAME::LIB_VIEW_FRAME(), LIB_EDIT_FRAME::LoadSettings(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), SIM_PLOT_FRAME::NewPlotPanel(), DIALOG_MIGRATE_BUSES::onAcceptClicked(), DIALOG_EDIT_COMPONENTS_LIBID::onApplyButton(), DIALOG_ANNOTATE::OnApplyClick(), LIB_VIEW_FRAME::OnCloseWindow(), DIALOG_ERC::OnEraseDrcMarkersClick(), SCH_BASE_FRAME::OnGridSettings(), DIALOG_MIGRATE_BUSES::onItemSelected(), OnModify(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), OnRemapSymbols(), DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick(), DIALOG_UPDATE_FROM_PCB::OnUpdateClick(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), SCH_EDIT_TOOL::Properties(), PutDataInPreviousState(), LIB_EDIT_FRAME::RebuildView(), LIB_VIEW_FRAME::ReCreateListLib(), LIB_EDIT_FRAME::ReCreateMenuBar(), ReCreateMenuBar(), SCH_EDITOR_CONTROL::Redo(), DIALOG_ERC::RedrawDrawPanel(), SCH_BASE_FRAME::RedrawScreen(), SCH_BASE_FRAME::RefreshItem(), SCH_BASE_FRAME::RefreshSelection(), SCH_BASE_FRAME::RemoveFromScreen(), RescueLegacyProject(), rescueProject(), RescueSymbolLibTableProject(), DIALOG_EDIT_COMPONENTS_LIBID::revertChanges(), RollbackSchematicFromUndo(), SetCurrentSheet(), EE_POINT_EDITOR::setEditedPoint(), SCH_BASE_FRAME::SetScreen(), SetScreen(), LIB_VIEW_FRAME::SetSelectedLibrary(), LIB_VIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), setupTools(), LIB_CONTROL::ShowElectricalTypes(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_EDIT_FRAME::SwitchCanvas(), SCH_BASE_FRAME::SyncView(), TestDanglingEnds(), DIALOG_ERC::TestErc(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PANEL_LIBEDIT_SETTINGS::TransferDataFromWindow(), DIALOG_SET_GRID::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_LIBEDIT_COLOR_SETTINGS::TransferDataFromWindow(), DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow(), PANEL_SETUP_FORMATTING::TransferDataFromWindow(), DIALOG_EDIT_SHEET_PIN::TransferDataFromWindow(), DIALOG_UPDATE_FIELDS::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SCH_EDITOR_CONTROL::Undo(), SCH_EDIT_TOOL::UpdateFields(), SCH_EDITOR_CONTROL::UpdateFind(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), LIB_VIEW_FRAME::updatePreviewSymbol(), SCH_BASE_FRAME::UpdateStatusBar(), DIALOG_FIELDS_EDITOR_GLOBAL::~DIALOG_FIELDS_EDITOR_GLOBAL(), and LIB_VIEW_FRAME::~LIB_VIEW_FRAME().

◆ GetColorSettings()

COLOR_SETTINGS * SCH_BASE_FRAME::GetColorSettings ( )
overridevirtualinherited

Returns a pointer to the active color theme settings.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 496 of file sch_base_frame.cpp.

497 {
498  if( !m_colorSettings )
499  {
500  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
501  m_colorSettings = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
502  }
503 
504  return m_colorSettings;
505 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
COLOR_SETTINGS * m_colorSettings

References EDA_DRAW_FRAME::m_colorSettings, and Pgm().

Referenced by SCH_BASE_FRAME::GetLayerColor(), and