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)
 
std::vector< PARAM_CFG * > & GetProjectFileParameters ()
 Return the project file parameter list for Eeschema. More...
 
void SaveProjectSettings (bool aAskForSave) 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...
 
const ERC_SETTINGSGetErcSettings ()
 
void UpdateErcSettings (const ERC_SETTINGS &aSettings)
 
int AddTemplateFieldName (const TEMPLATE_FIELDNAME &aFieldName)
 Insert or append a wanted symbol field name into the field names template. More...
 
void DeleteAllTemplateFieldNames ()
 Remove all template field names. More...
 
std::vector< PARAM_CFG * > & GetConfigurationSettings ()
 Return the Eeschema applications settings. More...
 
void LoadSettings (wxConfigBase *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (wxConfigBase *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)
 
void ConvertTextType (SCH_TEXT *aText, KICAD_T aNewType)
 Change a text type to another one. More...
 
bool EditSheet (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 SaveUndoItemInUndoList (SCH_ITEM *aItem, bool aAppend=false)
 Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap the data back. 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 () const
 Return a template field names list for read only access. More...
 
const TEMPLATE_FIELDNAMEGetTemplateFieldName (const wxString &aName) const
 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 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...
 
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...
 
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, bool aCenterView=false)
 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)
 
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 wxConfigBase * config ()
 Returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_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 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...
 
virtual wxString GetCanvasTypeKey ()
 
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
 
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
 
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 UpdateTitle ()
 Set the main window title bar text. More...
 
void NormalizeSchematicOnFirstLoad (bool recalculateConnections)
 Perform all cleanup and normalization steps so that the whole schematic is in a good state. More...
 
bool checkSheetForRecursion (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
 Verify that aSheet will not cause a recursion error in aHierarchy. 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...
 
bool allowCaseSensitiveFileNameClashes (const wxString &aSchematicFileName)
 Check aSchematicFileName for a potential file name case sensitivity clashes. More...
 

Private Attributes

wxString m_SelectedNetName
 
std::vector< PARAM_CFG * > m_projectFileParams
 
std::vector< PARAM_CFG * > m_configSettings
 
ERC_SETTINGS m_ercSettings
 
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...
 
SCH_ITEMm_undoItem
 Copy of the current item being edited. 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 116 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 229 of file sch_edit_frame.cpp.

229  :
230  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
231  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
232  m_item_to_repeat( nullptr )
233 {
235  g_ConnectionGraph = new CONNECTION_GRAPH( this );
236 
237  m_showBorderAndTitleBlock = true; // true to show sheet references
238  m_showAllPins = false;
240  m_printMonochrome = true;
241  m_printSheetReference = true;
242  SetShowPageLimits( true );
243  m_undoItem = NULL;
244  m_hasAutoSave = true;
247  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
248  m_AboutTitle = "Eeschema";
249 
250  m_findReplaceDialog = nullptr;
251  m_findReplaceStatusPopup = nullptr;
252 
253  SetForceHVLines( true );
255 
256  // Give an icon
257  wxIcon icon;
258  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
259  SetIcon( icon );
260 
261  // Initialize grid id to the default value (50 mils):
263 
264  LoadSettings( config() );
265 
266  CreateScreens();
267 
268  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
269 
270  setupTools();
271  ReCreateMenuBar();
275 
276  // Initialize common print setup dialog settings.
277  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
278  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
279  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
280  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
281 
282  m_auimgr.SetManagedWindow( this );
283 
284  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
285  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
286  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
287  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
288  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
289 
290  m_auimgr.Update();
291 
293 
294  // Init grid size and visibility
296 
297  if( GetCanvas() )
299 
300  InitExitKey();
301 
302  // Net list generator
304 
305  UpdateTitle();
306 
307  // Default shutdown reason until a file is loaded
308  SetShutdownBlockReason( _( "New schematic file is unsaved" ) );
309 }
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.
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:109
wxString m_AboutTitle
virtual wxConfigBase * config()
Returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
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:79
const BITMAP_OPAQUE icon_eeschema_xpm[1]
void ReCreateHToolbar() override
static TOOL_ACTION gridPreset
Definition: actions.h:131
#define SCH_EDIT_FRAME_NAME
#define NULL
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
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
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
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:31
SCH_ITEM * m_undoItem
Copy of the current item being edited.
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
void SetShowPageLimits(bool aShow)
void ReCreateVToolbar() override
ACTION_TOOLBAR * m_drawToolBar

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

◆ ~SCH_EDIT_FRAME()

SCH_EDIT_FRAME::~SCH_EDIT_FRAME ( )
override

Definition at line 312 of file sch_edit_frame.cpp.

313 {
314  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
315 
316  SetScreen( NULL );
317 
318  delete g_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
319  delete g_ConnectionGraph;
320  delete m_undoItem;
321  delete g_RootSheet;
322 
323  g_CurrentSheet = nullptr;
324  g_ConnectionGraph = nullptr;
325  g_RootSheet = NULL;
326 
327  // Since the file menu contains file history menus, we must ensure that the menu
328  // destructor is called before the file history objects are deleted since their destructor
329  // unregisters the menu from the history.
330  wxMenu* fileMenu = GetMenuBar()->Remove( 0 );
331  delete fileMenu;
332 }
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
#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.
SCH_ITEM * m_undoItem
Copy of the current item being edited.
SCH_SHEET * g_RootSheet

References g_ConnectionGraph, g_CurrentSheet, g_RootSheet, m_item_to_repeat, m_undoItem, NULL, and SetScreen().

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

603 {
604  GetCanvas()->SetEvtHandlerEnabled( true );
605  GetCanvas()->StartDrawing();
606 }
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().

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

959 {
960  SCH_SCREEN* screen = GetScreen();
961 
962  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
963 
964  SCH_SHEET* parentSheet = nullptr;
965  SCH_COMPONENT* parentComponent = nullptr;
966  SCH_ITEM* undoItem = aItem;
967 
968  if( aItem->Type() == SCH_SHEET_PIN_T )
969  {
970  parentSheet = (SCH_SHEET*) aItem->GetParent();
971 
972  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
973  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
974 
975  undoItem = parentSheet;
976  }
977 
978  else if( aItem->Type() == SCH_FIELD_T )
979  {
980  parentComponent = (SCH_COMPONENT*) aItem->GetParent();
981 
982  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
983  wxT( "Cannot place field in invalid schematic component object." ) );
984 
985  undoItem = parentComponent;
986  }
987 
988  if( aItem->IsNew() )
989  {
990  if( aItem->Type() == SCH_SHEET_PIN_T )
991  {
992  // Sheet pins are owned by their parent sheet.
993  SaveCopyInUndoList( undoItem, UR_CHANGED, aUndoAppend ); // save the parent sheet
994 
995  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
996  }
997  else if( aItem->Type() == SCH_FIELD_T )
998  {
999  // Component fields are also owned by their parent, but new component fields
1000  // are handled elsewhere.
1001  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1002  }
1003  else
1004  {
1005  if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1006  AddToScreen( aItem );
1007 
1008  SaveCopyForRepeatItem( aItem );
1009  SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
1010  }
1011 
1012  // Update connectivity info for new item
1013  if( !aItem->IsMoving() )
1015  }
1016  else
1017  {
1018  SaveUndoItemInUndoList( undoItem, aUndoAppend );
1019  }
1020 
1021  aItem->ClearFlags( IS_NEW );
1022 
1023  screen->SetModify();
1024  RefreshItem( aItem );
1025 
1026  if( !aItem->IsMoving() && aItem->IsConnectable() )
1027  {
1028  std::vector< wxPoint > pts;
1029  aItem->GetConnectionPoints( pts );
1030 
1031  for( auto i = pts.begin(); i != pts.end(); i++ )
1032  {
1033  for( auto j = i + 1; j != pts.end(); j++ )
1034  TrimWire( *i, *j );
1035 
1036  if( screen->IsJunctionNeeded( *i, true ) )
1037  AddJunction( *i, true, false );
1038  }
1039 
1040  TestDanglingEnds();
1041 
1042  for( SCH_ITEM* item : aItem->ConnectedItems() )
1043  RefreshItem( item );
1044  }
1045 
1046  aItem->ClearEditFlags();
1047  GetCanvas()->Refresh();
1048 }
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:317
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:332
bool IsMoving() const
Definition: base_struct.h:220
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_item.h:327
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:179
bool IsNew() const
Definition: base_struct.h:218
#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:215
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
void SaveUndoItemInUndoList(SCH_ITEM *aItem, bool aAppend=false)
Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap...
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...
std::unordered_set< SCH_ITEM * > & ConnectedItems()
Retrieves the set of items connected to this item (schematic only)
Definition: sch_item.cpp:138
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:206
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:256
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:273
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:264
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

References AddJunction(), SCH_SHEET::AddPin(), SCH_BASE_FRAME::AddToScreen(), SCH_SCREEN::CheckIfOnDrawList(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearFlags(), SCH_ITEM::ConnectedItems(), 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(), SaveUndoItemInUndoList(), 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:201
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:180
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:237

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

413 {
414  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
415  ACTION_MENU* helpMenu = new ACTION_MENU( false );
416 
417  helpMenu->SetTool( commonControl );
418 
419  helpMenu->Add( ACTIONS::help );
420  helpMenu->Add( ACTIONS::gettingStarted );
421  helpMenu->Add( ACTIONS::listHotKeys );
422  helpMenu->Add( ACTIONS::getInvolved );
423 
424  helpMenu->AppendSeparator();
425  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
426 
427  aMenuBar->Append( helpMenu, _( "&Help" ) );
428 }
static TOOL_ACTION listHotKeys
Definition: actions.h:167
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:31
static TOOL_ACTION help
Definition: actions.h:166
TOOL_MANAGER * m_toolManager
static TOOL_ACTION getInvolved
Definition: actions.h:168
static TOOL_ACTION gettingStarted
Definition: actions.h:165

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

351 {
352  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
353  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
354 
355  aMenu.AddSeparator( 1000 );
357  aMenu.AddItem( ACTIONS::zoomIn, SELECTION_CONDITIONS::ShowAlways, 1000 );
358  aMenu.AddItem( ACTIONS::zoomOut, SELECTION_CONDITIONS::ShowAlways, 1000 );
360 
361  aMenu.AddSeparator( 1000 );
362 
363  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
364  zoomMenu->SetTool( commonTools );
365  aToolMenu.AddSubMenu( zoomMenu );
366 
367  auto gridMenu = std::make_shared<GRID_MENU>( this );
368  gridMenu->SetTool( commonTools );
369  aToolMenu.AddSubMenu( gridMenu );
370 
371  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
372  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
373 }
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()

int SCH_EDIT_FRAME::AddTemplateFieldName ( const TEMPLATE_FIELDNAME aFieldName)
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.
Returns
int - the index within the config container at which aFieldName was added, or -1 if the name is illegal because it matches a default field name.

Definition at line 286 of file sch_edit_frame.h.

287  {
288  return m_templateFieldNames.AddTemplateFieldName( aFieldName );
289  }
TEMPLATES m_templateFieldNames
int AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName)
Function AddTemplateFieldName inserts or appends a wanted symbol field name into the fieldnames templ...

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

408 {
409  auto screen = aScreen;
410 
411  if( aScreen == nullptr )
412  screen = GetScreen();
413 
414  screen->Append( (SCH_ITEM*) aItem );
415 
416  if( screen == GetScreen() )
417  {
418  GetCanvas()->GetView()->Add( aItem );
419  RefreshItem( aItem, true ); // handle any additional parent semantics
420  }
421 }
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:136

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)
private

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

906 {
907  wxString msg;
908  SCH_SCREENS screens;
909  wxFileName fn = aSchematicFileName;
910 
911  wxCHECK( fn.IsAbsolute(), false );
912 
914  && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
915  {
916  msg.Printf( _( "The file name \"%s\" can cause issues with an existing file name\n"
917  "already defined in the schematic on systems that support case\n"
918  "insensitive file names. This will cause issues if you copy this\n"
919  "project to an operating system that supports case insensitive file\n"
920  "names.\n\nDo you wish to continue?" ),
921  fn.GetName() );
922 
923  wxRichMessageDialog dlg( this, msg, _( "Warning" ),
924  wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
925  dlg.ShowCheckBox( _( "Do not show this message again." ) );
926  dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
927  wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
928 
929  if( dlg.ShowModal() == wxID_NO )
930  return false;
931 
932  m_showSheetFileNameCaseSensitivityDlg = !dlg.IsCheckBoxChecked();
933  }
934 
935  return true;
936 }
bool m_showSheetFileNameCaseSensitivityDlg
#define _(s)
Definition: 3d_actions.cpp:31
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:498

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

Referenced by EditSheet().

◆ 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 82 of file eeschema/annotate.cpp.

90 {
91  SCH_REFERENCE_LIST references;
92 
93  SCH_SCREENS screens;
94 
95  // Build the sheet list.
96  SCH_SHEET_LIST sheets( g_RootSheet );
97 
98  // Map of locked components
99  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
100 
101  // Map of previous annotation for building info messages
102  std::map<timestamp_t, wxString> previousAnnotation;
103 
104  // Test for and replace duplicate time stamps in components and sheets. Duplicate
105  // time stamps can happen with old schematics, schematic conversions, or manual
106  // editing of files.
107  if( aRepairTimestamps )
108  {
109  int count = screens.ReplaceDuplicateTimeStamps();
110 
111  if( count )
112  {
113  wxString msg;
114  msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
115  aReporter.ReportTail( msg, REPORTER::RPT_WARNING );
116  }
117  }
118 
119  // If units must be locked, collect all the sets that must be annotated together.
120  if( aLockUnits )
121  {
122  if( aAnnotateSchematic )
123  {
124  sheets.GetMultiUnitComponents( lockedComponents );
125  }
126  else
127  {
128  g_CurrentSheet->GetMultiUnitComponents( lockedComponents );
129  }
130  }
131 
132  // Store previous annotations for building info messages
133  mapExistingAnnotation( previousAnnotation );
134 
135  // If it is an annotation for all the components, reset previous annotation.
136  if( aResetAnnotation )
137  DeleteAnnotation( !aAnnotateSchematic );
138 
139  // Set sheet number and number of sheets.
141 
142  // Build component list
143  if( aAnnotateSchematic )
144  {
145  sheets.GetComponents( references );
146  }
147  else
148  {
149  g_CurrentSheet->GetComponents( references );
150  }
151 
152  // Break full components reference in name (prefix) and number:
153  // example: IC1 become IC, and 1
154  references.SplitReferences();
155 
156  switch( aSortOption )
157  {
158  default:
159  case SORT_BY_X_POSITION:
160  references.SortByXCoordinate();
161  break;
162 
163  case SORT_BY_Y_POSITION:
164  references.SortByYCoordinate();
165  break;
166  }
167 
168  bool useSheetNum = false;
169  int idStep = 100;
170 
171  switch( aAlgoOption )
172  {
173  default:
174  case INCREMENTAL_BY_REF:
175  break;
176 
177  case SHEET_NUMBER_X_100:
178  useSheetNum = true;
179  break;
180 
181  case SHEET_NUMBER_X_1000:
182  useSheetNum = true;
183  idStep = 1000;
184  break;
185  }
186 
187  // Recalculate and update reference numbers in schematic
188  references.Annotate( useSheetNum, idStep, aStartNumber, lockedComponents );
189  references.UpdateAnnotation();
190 
191  for( size_t i = 0; i < references.GetCount(); i++ )
192  {
193  SCH_COMPONENT* comp = references[ i ].GetComp();
194  wxString prevRef = previousAnnotation[ comp->GetTimeStamp() ];
195  wxString newRef = comp->GetField( REFERENCE )->GetFullyQualifiedText();
196  wxString msg;
197 
198  if( prevRef.Length() )
199  {
200  if( newRef == prevRef )
201  continue;
202 
203  if( comp->GetUnitCount() > 1 )
204  msg.Printf( _( "Updated %s (unit %s) from %s to %s" ),
205  GetChars( comp->GetField( VALUE )->GetShownText() ),
206  LIB_PART::SubReference( comp->GetUnit(), false ),
207  GetChars( prevRef ),
208  GetChars( newRef ) );
209  else
210  msg.Printf( _( "Updated %s from %s to %s" ),
211  GetChars( comp->GetField( VALUE )->GetShownText() ),
212  GetChars( prevRef ),
213  GetChars( newRef ) );
214  }
215  else
216  {
217  if( comp->GetUnitCount() > 1 )
218  msg.Printf( _( "Annotated %s (unit %s) as %s" ),
219  GetChars( comp->GetField( VALUE )->GetShownText() ),
220  LIB_PART::SubReference( comp->GetUnit(), false ),
221  GetChars( newRef ) );
222  else
223  msg.Printf( _( "Annotated %s as %s" ),
224  GetChars( comp->GetField( VALUE )->GetShownText() ),
225  GetChars( newRef ) );
226  }
227 
228  aReporter.Report( msg, REPORTER::RPT_ACTION );
229  }
230 
231  // Final control (just in case ... ).
232  if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) )
233  aReporter.ReportTail( _( "Annotation complete." ), REPORTER::RPT_ACTION );
234 
235  // Update on screen references, that can be modified by previous calculations:
238 
239  SyncView();
240  GetCanvas()->Refresh();
241  OnModify();
242 }
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.
void SortByYCoordinate()
Function sortByYCoordinate sorts the list of references by Y position.
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...
void mapExistingAnnotation(std::map< timestamp_t, wxString > &aMap)
Field Reference of part, i.e. "IC21".
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.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)
Function ReportTail Places the report at the end of the list, for objects that support report orderin...
Definition: reporter.h:111
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.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:213
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.
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.
Annotate by Y position from top to bottom.
Annotate using the first free reference number starting at the sheet number * 100.
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 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:31
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.
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:75
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
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.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:498

References _, SCH_REFERENCE_LIST::Annotate(), CheckAnnotate(), DeleteAnnotation(), g_CurrentSheet, g_RootSheet, SCH_BASE_FRAME::GetCanvas(), GetChars(), SCH_SHEET_PATH::GetComponents(), SCH_SHEET_LIST::GetComponents(), SCH_REFERENCE_LIST::GetCount(), SCH_COMPONENT::GetField(), SCH_FIELD::GetFullyQualifiedText(), SCH_SHEET_PATH::GetMultiUnitComponents(), SCH_SHEET_LIST::GetMultiUnitComponents(), EDA_TEXT::GetShownText(), EDA_ITEM::GetTimeStamp(), SCH_COMPONENT::GetUnit(), SCH_COMPONENT::GetUnitCount(), INCREMENTAL_BY_REF, mapExistingAnnotation(), OnModify(), REFERENCE, EDA_DRAW_PANEL_GAL::Refresh(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), REPORTER::Report(), REPORTER::ReportTail(), REPORTER::RPT_ACTION, REPORTER::RPT_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 559 of file eda_draw_frame.cpp.

561 {
562  if( m_messagePanel )
563  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
564 }
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(), EditSheet(), importFile(), LoadSheetFromFile(), SCH_PRINTOUT::OnPrintPage(), OpenProjectFiles(), SaveEEFile(), LIB_EDIT_FRAME::saveLibrary(), PCB_EDIT_FRAME::SavePcbFile(), 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 435 of file eeschema/files-io.cpp.

436 {
437  wxString fullFileName;
438  SCH_SCREEN* screen = GetScreen();
439 
440  if( !screen )
441  {
442  wxLogError( wxT( "Document not ready, cannot import" ) );
443  return false;
444  }
445 
446  // open file chooser dialog
447  wxString path = wxPathOnly( Prj().GetProjectFullName() );
448 
449  wxFileDialog dlg( this, _( "Append Schematic" ), path, wxEmptyString,
450  SchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
451 
452  if( dlg.ShowModal() == wxID_CANCEL )
453  return false;
454 
455  fullFileName = dlg.GetPath();
456 
457  if( !LoadSheetFromFile( GetCurrentSheet().Last(), &GetCurrentSheet(), fullFileName ) )
458  return false;
459 
460  SCH_SCREENS screens( GetCurrentSheet().Last() );
461  screens.TestDanglingEnds();
462 
466 
467  SyncView();
468  HardRedraw(); // Full reinit of the current screen and the display.
469  OnModify();
470 
471  return true;
472 }
wxString SchematicFileWildcard()
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:109
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:31
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:498

References _, GetCurrentSheet(), GetScreen(), HardRedraw(), ID_POPUP_GRID_LEVEL_1000, LoadSheetFromFile(), EDA_DRAW_FRAME::m_LastGridSizeId, EDA_BASE_FRAME::m_toolManager, OnModify(), KIWAY_HOLDER::Prj(), TOOL_MANAGER::RunAction(), SchematicFileWildcard(), 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 710 of file eeschema/files-io.cpp.

711 {
712  SCH_SCREENS screenList;
713 
714  // Save any currently open and modified project files.
715  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
716  {
717  if( screen->IsModify() )
718  {
719  if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
720  "Save changes?" ),
721  [&]()->bool { return SaveProject(); } ) )
722  {
723  return false;
724  }
725  }
726  }
727 
728  return true;
729 }
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:981
#define _(s)
Definition: 3d_actions.cpp:31
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:970
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:498

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)
Function IsPointOnSegment.
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:31
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 304 of file sch_base_frame.cpp.

305 {
306  GetCanvas()->GetView()->SetCenter( aCenterPoint );
307 
308  if( aWarpPointer )
309  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
310 
311  GetCanvas()->Refresh();
312 }
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 221 of file eda_base_frame.h.

222  {
223  SetUserUnits( aUnits );
225  }
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 245 of file eeschema/annotate.cpp.

246 {
247  // build the screen list
248  SCH_SHEET_LIST sheetList( g_RootSheet );
249  SCH_REFERENCE_LIST componentsList;
250 
251  // Build the list of components
252  if( !aOneSheetOnly )
253  sheetList.GetComponents( componentsList );
254  else
255  g_CurrentSheet->GetComponents( componentsList );
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.

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

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:98
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:31

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:278
#define _(s)
Definition: 3d_actions.cpp:31
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:264
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:498

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 
)
private

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:236
SCH_SHEET_LIST.
const wxString & GetFileName() const
Definition: sch_screen.h:157
SCH_SCREEN * LastScreen()
Function LastScreen.
#define _(s)
Definition: 3d_actions.cpp:31
SCH_SHEET * g_RootSheet

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

Referenced by EditSheet(), and LoadSheetFromFile().

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

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

References m_exec_flags.

◆ ClearFindReplaceStatus()

void SCH_EDIT_FRAME::ClearFindReplaceStatus ( )

Definition at line 736 of file sch_edit_frame.cpp.

737 {
738  m_findReplaceStatusPopup->Hide();
739 }
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 1105 of file sch_edit_frame.cpp.

1106 {
1107  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1108 
1109  RecreateToolbars();
1110  Layout();
1111  SendSizeEvent();
1112 }
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()

wxConfigBase * EDA_BASE_FRAME::config ( )
virtualinherited

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

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 584 of file eda_base_frame.cpp.

585 {
586  // KICAD_MANAGER_FRAME overrides this
587  wxConfigBase* ret = Kiface().KifaceSettings();
588  //wxASSERT( ret );
589  return ret;
590 }
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.

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

Referenced by CVPCB_MAINFRAME::CVPCB_MAINFRAME(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), PCB_EDIT_FRAME::GetSettings(), LIB_VIEW_FRAME::LIB_VIEW_FRAME(), SIM_PLOT_FRAME::onClose(), FOOTPRINT_WIZARD_FRAME::OnCloseWindow(), OpenProjectFiles(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and EDA_BASE_FRAME::windowClosing().

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

346  {
347  wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
348  return baseCfgName;
349  }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

Referenced by DISPLAY_FOOTPRINTS_FRAME::LoadSettings(), FOOTPRINT_VIEWER_FRAME::LoadSettings(), EDA_BASE_FRAME::LoadSettings(), EDA_DRAW_FRAME::LoadSettings(), DISPLAY_FOOTPRINTS_FRAME::SaveSettings(), FOOTPRINT_VIEWER_FRAME::SaveSettings(), EDA_BASE_FRAME::SaveSettings(), EDA_DRAW_FRAME::SaveSettings(), 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:236
bool IsSelected() const
Definition: base_struct.h:223
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:109
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:255
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:61
void UpdatePins(SCH_SHEET_PATH *aSheet=nullptr)
Updates the local cache of SCH_PIN_CONNECTION objects for each pin.
Define a library symbol object.
unsigned STATUS_FLAGS
Definition: base_struct.h:156
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
#define _(s)
Definition: 3d_actions.cpp:31
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:256
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
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:257
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:302
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:245
bool IsSelected() const
Definition: base_struct.h:223
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:109
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:307
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:303
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:218
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:255
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:260
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:238
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:315
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:210
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:243
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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:981
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:249
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:31
virtual void SetName(const wxString &aName)
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:970
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:498

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:278
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:498

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

336 {
338 
339  // Allows only a CAIRO or OPENGL canvas:
342  {
344  }
345 
346  SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
349 }
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:498

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:236
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:245
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:123
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
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:238
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:210
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:243
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
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 436 of file sch_edit_frame.cpp.

437 {
438  if( g_RootSheet == NULL )
439  g_RootSheet = new SCH_SHEET();
440 
441  if( g_RootSheet->GetScreen() == NULL )
442  {
443  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
445  g_RootSheet->SetScreen( screen );
447  }
448 
449  g_RootSheet->GetScreen()->SetFileName( wxEmptyString );
450 
454 
455  if( GetScreen() == NULL )
456  {
457  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
459  SetScreen( screen );
460  }
461 
462  GetScreen()->SetZoom( 32.0 );
463 }
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:111
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:278
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:206
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 779 of file sheet.cpp.

780 {
781  wxString text;
782  SCH_SHEET_PIN* sheetPin;
783 
784  if( aLabel )
785  {
786  text = aLabel->GetText();
787  m_lastSheetPinType = aLabel->GetShape();
788  }
789 
790  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
791  sheetPin->SetFlags( IS_NEW );
792  sheetPin->SetTextSize( GetLastSheetPinTextSize() );
793  sheetPin->SetShape( m_lastSheetPinType );
794 
795  if( !aLabel )
796  {
797  DIALOG_EDIT_SHEET_PIN dlg( this, sheetPin );
798 
799  if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
800  {
801  delete sheetPin;
802  return nullptr;
803  }
804  }
805 
806  m_lastSheetPinType = sheetPin->GetShape();
807  m_lastSheetPinTextSize = sheetPin->GetTextSize();
808 
809  sheetPin->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
810 
811  return sheetPin;
812 }
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:245
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:255
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:767
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.h:195
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:243

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

268 {
269  if( m_toolStack.empty() )
270  return ACTIONS::selectionTool.GetName();
271  else
272  return m_toolStack.back();
273 }
std::vector< std::string > m_toolStack
static TOOL_ACTION selectionTool
Definition: actions.h:143

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

◆ DefaultExecFlags()

void SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

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

Definition at line 1043 of file sch_edit_frame.h.

1043 { 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 ( )
inline

Remove all template field names.

Definition at line 294 of file sch_edit_frame.h.

295  {
297  }
TEMPLATES m_templateFieldNames
void DeleteAllTemplateFieldNames()
Function DeleteAllTemplateFieldNames deletes the entire contents.

References TEMPLATES::DeleteAllTemplateFieldNames(), 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 59 of file eeschema/annotate.cpp.

60 {
61  if( aCurrentSheetOnly )
62  {
63  SCH_SCREEN* screen = GetScreen();
64  wxCHECK_RET( screen != NULL, wxT( "Attempt to clear annotation of a NULL screen." ) );
66  }
67  else
68  {
69  SCH_SCREENS ScreenList;
70  ScreenList.ClearAnnotation();
71  }
72 
73  // Update the references for the sheet that is currently being displayed.
75 
76  SyncView();
77  GetCanvas()->Refresh();
78  OnModify();
79 }
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:742
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:498

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:406
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:255
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:260
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:136

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:109
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:623
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::OnLeftClickMarkersList(), OnPageSettingsChange(), and HIERARCHY_NAVIG_DLG::onSelectSheetPath().

◆ DisplayGridMsg()

void EDA_DRAW_FRAME::DisplayGridMsg ( )
inherited

Display current grid pane on the status bar.

Definition at line 385 of file eda_draw_frame.cpp.

386 {
387  wxString line;
388  wxString gridformatter;
389 
390  switch( m_userUnits )
391  {
392  case EDA_UNITS::INCHES:
393  gridformatter = "grid %.3f";
394  break;
395 
397  gridformatter = "grid %.4f";
398  break;
399 
400  default:
401  gridformatter = "grid %f";
402  break;
403  }
404 
405  wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
406  double grid = To_User_Unit( m_userUnits, curr_grid_size.x );
407  line.Printf( gridformatter, grid );
408 
409  SetStatusText( line, 4 );
410 }
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 376 of file eda_draw_frame.cpp.

377 {
378  SetStatusText( msg, 6 );
379 }

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

414 {
415  wxString msg;
416 
417  switch( m_userUnits )
418  {
419  case EDA_UNITS::INCHES:
420  msg = _( "Inches" );
421  break;
423  msg = _( "mm" );
424  break;
425  default: msg = _( "Units" ); break;
426  }
427 
428  SetStatusText( msg, 5 );
429 }
#define _(s)
Definition: 3d_actions.cpp:31
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 545 of file eeschema/files-io.cpp.

546 {
547  wxFileName tmpFileName = g_RootSheet->GetFileName();
548  wxFileName fn = tmpFileName;
549  wxFileName tmp;
550  SCH_SCREENS screens;
551 
552  bool autoSaveOk = true;
553 
554  tmp.AssignDir( fn.GetPath() );
555 
556  if( !tmp.IsOk() )
557  return false;
558 
559  if( !IsWritable( tmp ) )
560  return false;
561 
562  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
563  {
564  // Only create auto save files for the schematics that have been modified.
565  if( !screen->IsSave() )
566  continue;
567 
568  tmpFileName = fn = screen->GetFileName();
569 
570  // Auto save file name is the normal file name prefixed with GetAutoSavePrefix().
571  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
572 
573  screen->SetFileName( fn.GetFullPath() );
574 
575  if( SaveEEFile( screen, false, NO_BACKUP_FILE ) )
576  screen->SetModify();
577  else
578  autoSaveOk = false;
579 
580  screen->SetFileName( tmpFileName.GetFullPath() );
581  }
582 
583  if( autoSaveOk )
584  m_autoSaveState = false;
585 
586  return autoSaveOk;
587 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:981
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(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:616
static wxString GetAutoSaveFilePrefix()
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:970
SCH_SHEET * g_RootSheet
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:498

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

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

834 {
835  wxRect DrawArea;
836  BASE_SCREEN* screen = GetScreen();
837 
838  DrawArea.SetSize( GetPageSizeIU() );
839 
840  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
841  // the drawings into the dc size
842  // scale is the ratio resolution (in PPI) / internal units
843  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
844  double inch2Iu = 1000.0 * IU_PER_MILS;
845  double scale = ppi / inch2Iu;
846 
847  wxSize dcsize = DrawArea.GetSize();
848 
849  int maxdim = std::max( dcsize.x, dcsize.y );
850 
851  // the max size in pixels of the bitmap used to byuild the sheet copy
852  const int maxbitmapsize = 3000;
853 
854  while( int( maxdim * scale ) > maxbitmapsize )
855  {
856  ppi = ppi / 1.5;
857  scale = ppi / inch2Iu;
858  }
859 
860  dcsize.x *= scale;
861  dcsize.y *= scale;
862 
863  // Set draw offset, zoom... to values needed to draw in the memory DC
864  // after saving initial values:
865  wxPoint tmp_startvisu = screen->m_StartVisu;
866  double tmpzoom = screen->GetZoom();
867  wxPoint old_org = screen->m_DrawOrg;
868  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
869  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
870 
871  screen->SetZoom( 1 ); // we use zoom = 1 in draw functions.
872 
873  wxMemoryDC dc;
874  wxBitmap image( dcsize );
875  dc.SelectObject( image );
876 
877  GRResetPenAndBrush( &dc );
878  GRForceBlackPen( false );
879  screen->m_IsPrinting = true;
880  dc.SetUserScale( scale, scale );
881 
882  dc.Clear();
883  PrintPage( &dc );
884  screen->m_IsPrinting = false;
885 
886  if( wxTheClipboard->Open() )
887  {
888  // This data objects are held by the clipboard, so do not delete them in the app.
889  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
890  wxTheClipboard->SetData( clipbrd_data );
891  wxTheClipboard->Close();
892  }
893 
894  // Deselect Bitmap from DC in order to delete the MemoryDC
895  dc.SelectObject( wxNullBitmap );
896 
897  GRForceBlackPen( false );
898 
899  screen->m_StartVisu = tmp_startvisu;
900  screen->m_DrawOrg = old_org;
901  screen->SetZoom( tmpzoom );
902 }
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().

◆ EditSheet()

bool SCH_EDIT_FRAME::EditSheet ( 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 512 of file sheet.cpp.

514 {
515  if( aSheet == NULL || aHierarchy == NULL )
516  return false;
517 
518  // Get the new texts
519  DIALOG_SCH_SHEET_PROPS dlg( this, aSheet );
520 
521  if( dlg.ShowModal() == wxID_CANCEL )
522  return false;
523 
524  wxFileName fileName = dlg.GetFileName();
525  fileName.SetExt( SchematicFileExtension );
526 
527  wxString msg;
528  bool renameFile = false;
529  bool loadFromFile = false;
530  bool clearAnnotation = false;
531  bool restoreSheet = false;
532  bool isExistingSheet = false;
533  SCH_SCREEN* useScreen = NULL;
534 
535  // Relative file names are relative to the path of the current sheet. This allows for
536  // nesting of schematic files in subfolders.
537  if( !fileName.IsAbsolute() )
538  {
539  const SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
540 
541  wxCHECK_MSG( currentScreen, false, "Invalid sheet path object." );
542 
543  wxFileName currentSheetFileName = currentScreen->GetFileName();
544 
545  wxCHECK_MSG( fileName.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() ), false,
546  "Cannot normalize new sheet schematic file path." );
547  }
548 
549  wxString newFilename = fileName.GetFullPath();
550 
551  // Search for a schematic file having the same filename already in use in the hierarchy
552  // or on disk, in order to reuse it.
553  if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
554  {
555  loadFromFile = wxFileExists( newFilename );
556  wxLogDebug( "Sheet requested file \"%s\", %s",
557  newFilename,
558  ( loadFromFile ) ? "found" : "not found" );
559  }
560 
561  // Inside Eeschema, filenames are stored using unix notation
562  newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
563 
564  if( aSheet->GetScreen() == NULL ) // New sheet.
565  {
566  if( !allowCaseSensitiveFileNameClashes( newFilename ) )
567  return false;
568 
569  if( useScreen || loadFromFile ) // Load from existing file.
570  {
571  clearAnnotation = true;
572 
573  wxString existsMsg;
574  wxString linkMsg;
575  existsMsg.Printf( _( "\"%s\" already exists." ), fileName.GetFullName() );
576  linkMsg.Printf( _( "Link \"%s\" to this file?" ), dlg.GetSheetName() );
577  msg.Printf( wxT( "%s\n\n%s" ), existsMsg, linkMsg );
578 
579  if( !IsOK( this, msg ) )
580  return false;
581 
582  }
583  else // New file.
584  {
585  InitSheet( aSheet, newFilename );
586  }
587  }
588  else // Existing sheet.
589  {
590  bool isUndoable = true;
591  wxString replaceMsg;
592  wxString newMsg;
593  wxString noUndoMsg;
594 
595  isExistingSheet = true;
596 
597  if( !allowCaseSensitiveFileNameClashes( newFilename ) )
598  return false;
599 
600  // Changing the filename of a sheet can modify the full hierarchy structure
601  // and can be not always undoable.
602  // So prepare messages for user notifications:
603  replaceMsg.Printf( _( "Change \"%s\" link from \"%s\" to \"%s\"?" ),
604  dlg.GetSheetName(), aSheet->GetFileName(), fileName.GetFullName() );
605  newMsg.Printf( _( "Create new file \"%s\" with contents of \"%s\"?" ),
606  fileName.GetFullName(), aSheet->GetFileName() );
607  noUndoMsg = _( "This action cannot be undone." );
608 
609  // We are always using here a case insensitive comparison
610  // to avoid issues under Windows, although under Unix
611  // filenames are case sensitive.
612  // But many users create schematic under both Unix and Windows
613  // **
614  // N.B. 1: aSheet->GetFileName() will return a relative path
615  // aSheet->GetScreen()->GetFileName() returns a full path
616  //
617  // N.B. 2: newFilename uses the unix notation for separator.
618  // so we must use it also to compare the old filename to the new filename
619  wxString oldFilename = aSheet->GetScreen()->GetFileName();
620  oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
621 
622  if( newFilename.Cmp( oldFilename ) != 0 )
623  {
624  // Sheet file name changes cannot be undone.
625  isUndoable = false;
626 
627  if( useScreen || loadFromFile ) // Load from existing file.
628  {
629  clearAnnotation = true;
630 
631  msg.Printf( wxT( "%s\n\n%s" ), replaceMsg, noUndoMsg );
632 
633  if( !IsOK( this, msg ) )
634  return false;
635 
636  if( loadFromFile )
637  aSheet->SetScreen( NULL );
638  }
639  else // Save to new file name.
640  {
641  if( aSheet->GetScreenCount() > 1 )
642  {
643  msg.Printf( wxT( "%s\n\n%s" ), newMsg, noUndoMsg );
644 
645  if( !IsOK( this, msg ) )
646  return false;
647  }
648 
649  renameFile = true;
650  }
651  }
652 
653  if( isUndoable )
654  SaveCopyInUndoList( aSheet, UR_CHANGED );
655 
656  if( renameFile )
657  {
658  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
659 
660  // If the the associated screen is shared by more than one sheet, do not
661  // change the filename of the corresponding screen here.
662  // (a new screen will be created later)
663  // if it is not shared, update the filename
664  if( aSheet->GetScreenCount() <= 1 )
665  aSheet->GetScreen()->SetFileName( newFilename );
666 
667  try
668  {
669  pi->Save( newFilename, aSheet->GetScreen(), &Kiway() );
670  }
671  catch( const IO_ERROR& ioe )
672  {
673  msg.Printf( _( "Error occurred saving schematic file \"%s\"." ), newFilename );
674  DisplayErrorMessage( this, msg, ioe.What() );
675 
676  msg.Printf( _( "Failed to save schematic \"%s\"" ), newFilename );
677  AppendMsgPanel( wxEmptyString, msg, CYAN );
678 
679  return false;
680  }
681 
682  // If the the associated screen is shared by more than one sheet, remove the
683  // screen and reload the file to a new screen. Failure to do this will trash
684  // the screen reference counting in complex hierarchies.
685  if( aSheet->GetScreenCount() > 1 )
686  {
687  aSheet->SetScreen( NULL );
688  loadFromFile = true;
689  }
690  }
691  }
692 
693  wxFileName userFileName = dlg.GetFileName();
694  userFileName.SetExt( SchematicFileExtension );
695 
696  if( useScreen )
697  {
698  // Create a temporary sheet for recursion testing to prevent a possible recursion error.
699  std::unique_ptr< SCH_SHEET> tmpSheet( new SCH_SHEET );
700  tmpSheet->SetName( dlg.GetSheetName() );
701  tmpSheet->SetFileName( userFileName.GetFullPath() );
702  tmpSheet->SetScreen( useScreen );
703 
704  // No need to check for valid library IDs if we are using an existing screen.
705  if( checkSheetForRecursion( tmpSheet.get(), aHierarchy ) )
706  {
707  if( restoreSheet )
708  aHierarchy->LastScreen()->Append( aSheet );
709 
710  return false;
711  }
712 
713  // It's safe to set the sheet screen now.
714  aSheet->SetScreen( useScreen );
715  }
716  else if( loadFromFile )
717  {
718  if( isExistingSheet )
719  {
720  // Temporarily remove the sheet from the current schematic page so that recursion
721  // and symbol library link tests can be performed with the modified sheet settings.
722  restoreSheet = true;
723  aHierarchy->LastScreen()->Remove( aSheet );
724  }
725 
726  if( !LoadSheetFromFile( aSheet, aHierarchy, newFilename ) )
727  {
728  if( restoreSheet )
729  aHierarchy->LastScreen()->Append( aSheet );
730 
731  return false;
732  }
733 
734  if( restoreSheet )
735  aHierarchy->LastScreen()->Append( aSheet );
736  }
737 
738  wxString tmpFn = userFileName.GetFullPath();
739 
740  if( wxFileName::GetPathSeparator() == '\\' )
741  tmpFn.Replace( "\\", "/" );
742 
743  aSheet->SetFileName( tmpFn );
744  aSheet->SetFileNameSize( dlg.GetFileNameTextSize() );
745  aSheet->SetName( dlg.GetSheetName() );
746  aSheet->SetSheetNameSize( dlg.GetSheetNameTextSize() );
747 
748  if( aSheet->GetName().IsEmpty() )
749  aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ),
750  (long unsigned) aSheet->GetTimeStamp() ) );
751 
752  if( aClearAnnotationNewItems )
753  *aClearAnnotationNewItems = clearAnnotation;
754 
755  GetCanvas()->GetView()->Update( aSheet );
756 
757  OnModify();
758 
759  return true;
760 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
const wxString & GetFileName() const
Definition: sch_screen.h:157
void SetFileNameSize(int aSize)
Definition: sch_sheet.h:276
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:540
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
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:249
bool checkSheetForRecursion(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Verify that aSheet will not cause a recursion error in aHierarchy.
Definition: sheet.cpp:44
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:464
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:111
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:93
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:235
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:278
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
Definition: sch_sheet.cpp:134
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
bool allowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:905
wxString GetName() const
Definition: sch_sheet.h:269
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void SetSheetNameSize(int aSize)
Definition: sch_sheet.h:273
void SetName(const wxString &aName)
Definition: sch_sheet.h:270
const std::string SchematicFileExtension
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: colors.h:59
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.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:213
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
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:206
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:616
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:497
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
SCH_SCREEN * LastScreen()
Function LastScreen.
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
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:175
#define _(s)
Definition: 3d_actions.cpp:31
Implementing DIALOG_SCH_SHEET_PROPS_BASE.
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 SetFileName(const wxString &aFileName)
Definition: sch_screen.h:155
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
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:280

References _, allowCaseSensitiveFileNameClashes(), SCH_SCREEN::Append(), EDA_DRAW_FRAME::AppendMsgPanel(), checkSheetForRecursion(), CYAN, DisplayErrorMessage(), Format(), g_RootSheet, SCH_BASE_FRAME::GetCanvas(), DIALOG_SCH_SHEET_PROPS::GetFileName(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetFileName(), DIALOG_SCH_SHEET_PROPS::GetFileNameTextSize(), SCH_SHEET::GetName(), SCH_SHEET::GetScreen(), SCH_SHEET::GetScreenCount(), DIALOG_SCH_SHEET_PROPS::GetSheetName(), DIALOG_SCH_SHEET_PROPS::GetSheetNameTextSize(), EDA_ITEM::GetTimeStamp(), SCH_DRAW_PANEL::GetView(), InitSheet(), IsOK(), KIWAY_HOLDER::Kiway(), SCH_SHEET_PATH::LastScreen(), LoadSheetFromFile(), NULL, OnModify(), SCH_SCREEN::Remove(), SaveCopyInUndoList(), SchematicFileExtension, SCH_SHEET::SearchHierarchy(), SCH_SCREEN::SetFileName(), SCH_SHEET::SetFileName(), SCH_SHEET::SetFileNameSize(), SCH_SHEET::SetName(), SCH_SHEET::SetScreen(), SCH_SHEET::SetSheetNameSize(), KIGFX::VIEW::Update(), UR_CHANGED, and IO_ERROR::What().

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

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

Definition at line 245 of file eda_draw_frame.cpp.

246 {
247  if( m_messagePanel )
249 }
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 174 of file eeschema/cross-probing.cpp.

175 {
177  char line[1024];
178 
179  strncpy( line, cmdline, sizeof(line) - 1 );
180  line[ sizeof(line) - 1 ] = '\0';
181 
182  char* idcmd = strtok( line, " \n\r" );
183  char* text = strtok( NULL, "\"\n\r" );
184 
185  if( idcmd == NULL )
186  return;
187 
188  if( strcmp( idcmd, "$NET:" ) == 0 )
189  {
190  m_SelectedNetName = FROM_UTF8( text );
192 
193  SetStatusText( _( "Selected net: " ) + UnescapeString( m_SelectedNetName ) );
194  return;
195  }
196 
197  if( strcmp( idcmd, "$CLEAR:" ) == 0 )
198  {
199  if( text && strcmp( text, "HIGHLIGHTED" ) == 0 )
200  {
201  GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
202  GetCanvas()->Refresh();
203  }
204 
205  return;
206  }
207 
208  if( text == NULL )
209  return;
210 
211  if( strcmp( idcmd, "$PART:" ) != 0 )
212  return;
213 
214  wxString part_ref = FROM_UTF8( text );
215 
216  /* look for a complement */
217  idcmd = strtok( NULL, " \n\r" );
218 
219  if( idcmd == NULL ) // Highlight component only (from Cvpcb or Pcbnew)
220  {
221  // Highlight component part_ref, or clear Highlight, if part_ref is not existing
222  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
223  return;
224  }
225 
226  text = strtok( NULL, "\"\n\r" );
227 
228  if( text == NULL )
229  return;
230 
231  wxString msg = FROM_UTF8( text );
232 
233  if( strcmp( idcmd, "$REF:" ) == 0 )
234  {
235  // Highlighting the reference itself isn't actually that useful, and it's harder to
236  // see. Highlight the parent and display the message.
237  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
238  }
239  else if( strcmp( idcmd, "$VAL:" ) == 0 )
240  {
241  // Highlighting the value itself isn't actually that useful, and it's harder to see.
242  // Highlight the parent and display the message.
243  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
244  }
245  else if( strcmp( idcmd, "$PAD:" ) == 0 )
246  {
247  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_PIN, msg );
248  }
249  else
250  {
251  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
252  }
253 }
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:109
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:204
void HighlightItem(EDA_ITEM *aItem, LIB_PIN *aPin=nullptr)
Definition: sch_view.cpp:225
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:31
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 678 of file sch_edit_frame.cpp.

679 {
680  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
681 
682  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
683 }
#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 1158 of file sch_edit_frame.cpp.

1159 {
1160  // Save the current sheet, to retrieve it later
1161  auto currSheet = GetCurrentSheet();
1162 
1163  SCH_SHEET_LIST sheetList;
1164  sheetList.BuildSheetList( g_RootSheet );
1165 
1166  for( const SCH_SHEET_PATH& sheet : sheetList )
1167  {
1168  // We require a set here to avoid adding multiple junctions to the same spot
1169  std::set<wxPoint> junctions;
1170 
1171  SetCurrentSheet( sheet );
1173 
1174  auto screen = GetCurrentSheet().LastScreen();
1175  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1176  {
1177  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1178  auto xform = cmp->GetTransform();
1179 
1180  for( const SCH_PIN& pin : cmp->GetPins() )
1181  {
1182  auto pos = cmp->GetPosition() + xform.TransformCoordinate( pin.GetPosition() );
1183 
1184  // Test if a _new_ junction is needed, and add it if missing
1185  if( screen->IsJunctionNeeded( pos, true ) )
1186  junctions.insert( pos );
1187  }
1188  }
1189 
1190  for( auto& pos : junctions )
1191  AddJunction( pos );
1192  }
1193 
1194  // Reselect the initial sheet:
1195  SetCurrentSheet( currSheet );
1197  SetScreen( GetCurrentSheet().LastScreen() );
1198 }
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().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const wxPoint aPos,
bool  aCenterView = false 
)
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.
aCenterViewis true if the new cursor position should be centered on canvas.

Definition at line 732 of file eda_draw_frame.cpp.

733 {
734  if( aCenterView )
735  {
736  wxWindow* dialog = findDialog( GetChildren() );
737 
738  // If a dialog partly obscures the window, then center on the uncovered area.
739  if( dialog )
740  {
741  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
742  dialog->GetSize() );
743  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
744  }
745  else
746  GetCanvas()->GetView()->SetCenter( aPos );
747  }
748 
750 }
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
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.

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

Referenced by DIALOG_DRC_CONTROL::doSelectionMenu(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindNext(), DIALOG_DRC_CONTROL::focusOnItem(), DIALOG_ERC::OnLeftClickMarkersList(), DIALOG_ERC::OnLeftDblClickMarkersList(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnLeftDClickItem(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem(), and DIALOG_FIND::search().

◆ GetAboutTitle()

const wxString& EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

Definition at line 475 of file eda_base_frame.h.

475 { 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 233 of file sch_edit_frame.h.

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

References m_autoplaceAlign.

Referenced by PANEL_EESCHEMA_SETTINGS::TransferDataToWindow().

◆ GetAutoplaceFields()

◆ GetAutoplaceJustify()

bool SCH_EDIT_FRAME::GetAutoplaceJustify ( ) const
inline

Definition at line 236 of file sch_edit_frame.h.

236 { 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 167 of file eda_base_frame.h.

168  {
169  return wxT( "_autosave-" );
170  }

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

290 { 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 145 of file sch_base_frame.cpp.

146 {
147  wxASSERT( GetScreen() );
148  return GetScreen()->GetAuxOrigin();
149 }
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 159 of file eda_base_frame.h.

160  {
161  return wxT( "-bak" );
162  }

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

323 {
324  return static_cast<SCH_DRAW_PANEL*>( EDA_DRAW_FRAME::GetCanvas() );
325 }
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(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::editFieldProperties(), LIB_EDIT_TOOL::editGraphicProperties(), EditSheet(), 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(), 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(), DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::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().

◆ GetCanvasTypeKey()

virtual wxString EDA_DRAW_FRAME::GetCanvasTypeKey ( )
inlineprotectedvirtualinherited
Returns
the key in KifaceSettings to store the canvas type. the base version returns only CanvasTypeKeyBase. Can be overriden to return a key specific of a frame name

Definition at line 170 of file eda_draw_frame.h.

170 { return CanvasTypeKeyBase; }
#define CanvasTypeKeyBase
The key to store the canvas type in config.

References CanvasTypeKeyBase.

Referenced by EDA_DRAW_FRAME::LoadCanvasTypeSetting(), and EDA_DRAW_FRAME::saveCanvasTypeSetting().

◆ GetConfigurationSettings()

std::vector< PARAM_CFG * > & SCH_EDIT_FRAME::GetConfigurationSettings ( )

Return the Eeschema applications settings.

This replaces the old statically define list that had the project file settings and the application settings mixed together. This was confusing and caused some settings to get saved and loaded incorrectly. Currently, only the settings that are needed at start up by the main window are defined here. There are other locally used settings scattered throughout the Eeschema source code. If you need to define a configuration setting that need to be loaded at run time, this is the place to define it.

Definition at line 343 of file eeschema_config.cpp.

344 {
345  if( !m_configSettings.empty() )
34