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
 

Public Member Functions

 SCH_EDIT_FRAME (KIWAY *aKiway, wxWindow *aParent)
 
 ~SCH_EDIT_FRAME ()
 
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
 
void SetShowAllPins (bool aEnable)
 
bool GetFootprintPreview () const
 
void SetFootprintPreview (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 SetSpiceAjustPassiveValues (bool aEnable)
 
const wxString & GetPlotDirectoryName () const
 accessor to the destination directory to use when generating plot files. More...
 
void SetPlotDirectoryName (const wxString &aDirName)
 
void Process_Special_Functions (wxCommandEvent &event)
 
void Process_Config (wxCommandEvent &event)
 
void OnSelectTool (wxCommandEvent &aEvent)
 
bool GeneralControl (wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey) override
 Perform application specific control using aDC at aPosition in logical units. More...
 
PARAM_CFG_ARRAYGetProjectFileParametersList ()
 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...
 
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...
 
PARAM_CFG_ARRAYGetConfigurationSettings ()
 Return the Eeschema applications settings. More...
 
void LoadSettings (wxConfigBase *aCfg) override
 Function LoadSettings loads common frame parameters from a configuration file. More...
 
void SaveSettings (wxConfigBase *aCfg) override
 Function SaveSettings saves common frame parameters to a configuration data file. More...
 
void RedrawActiveWindow (wxDC *DC, bool EraseBg) override
 
void CreateScreens ()
 
void ReCreateHToolbar () override
 
void ReCreateVToolbar () override
 
void ReCreateOptToolbar ()
 
void ReCreateMenuBar () override
 Function ReCreateMenuBar Creates recreates the menu bar. More...
 
EDA_HOTKEYGetHotKeyDescription (int aCommand) const override
 > More...
 
bool OnHotKey (wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem) override
 
void OnModify ()
 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...
 
virtual wxString GetScreenDesc () const override
 
virtual 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 OnLeftClick (wxDC *aDC, const wxPoint &aPosition) override
 
void OnLeftDClick (wxDC *aDC, const wxPoint &aPosition) override
 Function OnLeftDClick called on a double click event from the drawpanel mouse handler if an editable item is found (text, component) Call the suitable dialog editor. More...
 
bool OnRightClick (const wxPoint &aPosition, wxMenu *PopMenu) override
 
void OnSelectOptionToolbar (wxCommandEvent &event)
 
double BestZoom () override
 Return the zoom level which displays the full page on screen. More...
 
SCH_ITEMLocateAndShowItem (const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0, bool *aClarifySelectionMenuCancelled=nullptr)
 Check the schematic at aPosition in logical (drawing) units for a item matching the types in aFilterList. More...
 
SCH_ITEMLocateItem (const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0)
 Check for items at aPosition matching the types in aFilterList. More...
 
bool DeleteItemAtCrossHair ()
 Delete the item found under the cross hair. More...
 
bool HighlightConnectionAtPosition (wxPoint aPosition)
 Highlight the connection found at aPosition. More...
 
SCH_ITEMFindComponentAndItem (const wxString &aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
 Finds a component in the schematic and an item in this component. More...
 
bool BreakSegment (SCH_LINE *aSegment, const wxPoint &aPoint, bool aAppend=false, SCH_LINE **aNewSegment=NULL)
 Breaks a single segment into two at the specified point. More...
 
bool BreakSegments (const wxPoint &aPoint, bool aAppend=false)
 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 (bool aApped=false)
 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 eeschema for highlighting. More...
 
NETLIST_OBJECT_LISTBuildNetListBase (bool updateStatusText=true)
 Create a flat list which stores all connected objects. More...
 
bool CreateNetlist (int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL, bool silent=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...
 
bool SetCurrentSheetHighlightFlags ()
 Set or reset the BRIGHTENED of connected objects inside the current sheet, according to the highlighted net name. More...
 
wxString GetUniqueFilenameForCurrentSheet ()
 
void SetSheetNumberAndCount ()
 Set the m_ScreenNumber and m_NumberOfScreens members for screens. More...
 
void OnPrint (wxCommandEvent &event)
 Show the print dialog. More...
 
wxPageSetupDialogData & GetPageSetupData ()
 
bool GetPrintMonochrome ()
 
void SetPrintMonochrome (bool aMonochrome)
 
bool GetPrintSheetReference ()
 
void SetPrintSheetReference (bool aShow)
 
void PlotSchematic (wxCommandEvent &event)
 
void Save_File (wxCommandEvent &event)
 
void OnSaveProject (wxCommandEvent &aEvent)
 Command event handler to save the entire project and create a component library archive. More...
 
bool SaveProject ()
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 
bool AppendSchematic ()
 Import a KiCad schematic into the current page. More...
 
bool LoadCmpToFootprintLinkFile ()
 Loads a .cmp file from CvPcb and update the footprint field of components. More...
 
bool ProcessCmpToFootprintLinkFile (const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
 Read the footprint info from each line in the stuff file by reference designator. More...
 
bool SaveEEFile (SCH_SCREEN *aScreen, bool aSaveUnderNewName=false, bool aCreateBackupFile=CREATE_BACKUP_FILE)
 Save aScreen to a schematic file. More...
 
bool IsSearchCacheObsolete (const SCH_FIND_REPLACE_DATA &aSearchCriteria)
 
bool AskToSaveChanges ()
 Checks if any of the screens has unsaved changes and asks the user whether to save or drop them. 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...
 
wxPoint GetLastSheetPinPosition () const
 
void DeleteItem (SCH_ITEM *aItem, bool aAppend=false)
 Remove aItem from the current screen and saves it in the undo list. More...
 
void DeleteItemsInList (PICKED_ITEMS_LIST &aItemsList, bool aAppend=false)
 Removes all items (and unused junctions that connect to them) and saves each in the undo list. More...
 
void DeleteJunction (SCH_ITEM *aItem, bool aAppend=false)
 Removes a given junction and heals any wire segments under the junction. More...
 
void CheckListConnections (PICKED_ITEMS_LIST &aItemsList, bool aAppend=false)
 Adds junctions if needed to each item in the list after they have been moved. More...
 
int GetLabelIncrement () const
 
void OrientComponent (COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
 Rotate and mirror a component. More...
 
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 Key (wxDC *DC, int hotkey, EDA_ITEM *DrawStruct)
 
void InitBlockPasteInfos () override
 Initialize the parameters used by the block paste command. More...
 
virtual int BlockCommand (EDA_KEY aKey) override
 Return the block command internal code (BLOCK_MOVE, BLOCK_DUPLICATE...) corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when block command is started by dragging the mouse. More...
 
virtual void HandleBlockPlace (wxDC *DC) override
 Call after HandleBlockEnd, when a block command needs to be executed after the block is moved to its new place. More...
 
virtual bool HandleBlockEnd (wxDC *aDC) override
 Handle the "end" of a block command, i.e. More...
 
void RepeatDrawItem ()
 Repeat the last item placement if the last item was a bus, bus entry, label, or component. More...
 
void SetRepeatItem (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 SetUndoItem (const SCH_ITEM *aItem)
 Clone aItem which can be used to restore the state of the item being edited when the user cancels the editing in progress. More...
 
SCH_ITEMGetUndoItem () const
 
void SaveUndoItemInUndoList (SCH_ITEM *aItem)
 Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap the data back. 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, LSET aPrintMask, bool aPrintMirrorMode, void *aData=NULL) override
 Plot or print the current sheet to the clipboard. More...
 
void SetSimulatorCommand (const wxString &aCommand)
 
wxString GetSimulatorCommand () const
 
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 doUpdatePcb (const wxString &aUpdateOptions="")
 Updates netlist and sends it to pcbnew. More...
 
void SetCurrentSheet (SCH_SHEET_PATH *aSheet)
 
void InstallPreferences (PAGED_DIALOG *aParent) override
 Allows Eeschema to install its preferences panels into the preferences dialog. More...
 
void CommonSettingsChanged () override
 Called after the preferences dialog is run. More...
 
void ShowChangedLanguage () override
 Function ShowChangedLanguage redraws the menus and what not in current language. More...
 
void DuplicateItemsInList (SCH_SCREEN *screen, PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMoveVector)
 
virtual void SetScreen (BASE_SCREEN *aScreen) override
 
virtual const BOX2I GetDocumentExtents () const override
 
void createCanvas ()
 
SCH_DRAW_PANELGetCanvas () const override
 
KIGFX::SCH_RENDER_SETTINGSGetRenderSettings ()
 
void OnSwitchCanvas (wxCommandEvent &aEvent)
 switches currently used canvas ( Cairo / OpenGL). More...
 
void OnUpdateSwitchCanvas (wxUpdateUIEvent &aEvent)
 Update UI called when switches currently used canvas (Cairo / OpenGL). More...
 
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 wxString GetZoomLevelIndicator () const override
 Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level indicator in dialogs. More...
 
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 SelectComponentFromLibTree (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...
 
void OnConfigurePaths (wxCommandEvent &aEvent)
 
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...
 
virtual void OnEditSymbolLibTable (wxCommandEvent &aEvent)
 
LIB_ALIASGetLibAlias (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowError=false)
 Load symbol from symbol library table. More...
 
LIB_PARTGetLibPart (const LIB_ID &aLibId, bool aUseCacheLib=false, 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 Zoom_Automatique (bool aWarpPointer) override
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
virtual void Window_Zoom (EDA_RECT &aRect) override
 
virtual void RedrawScreen (const wxPoint &aCenterPoint, bool aWarpPointer) override
 Redraw the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterPoint at the center of the screen. More...
 
virtual void RedrawScreen2 (const wxPoint &posBefore) override
 Put the crosshair back to the screen position it had before zooming. More...
 
virtual void CenterScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 
void AddToScreen (SCH_ITEM *aItem)
 Add an item to the screen (and view) More...
 
void AddToScreen (DLIST< SCH_ITEM > &aItems)
 Add a list of items to the screen (and view) More...
 
void RemoveFromScreen (SCH_ITEM *aItem)
 Remove an item from the screen (and view) More...
 
void RefreshItem (SCH_ITEM *aItem, bool isAddOrDelete=false)
 Mark an item for refresh. More...
 
void SyncView ()
 Mark all items for refresh. More...
 
virtual void OnCharHook (wxKeyEvent &event)
 Capture the key event before it is sent to the GUI. 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...
 
EDA_UNITS_T GetUserUnits () const override
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS_T aUnits)
 
int GetLastGridSizeId () const
 
void SetLastGridSizeId (int aId)
 
wxPoint GetCrossHairPosition (bool aInvertY=false) const
 Return the current cross hair position in logical (drawing) coordinates. More...
 
void SetCrossHairPosition (const wxPoint &aPosition, bool aSnapToGrid=true)
 Set the screen cross hair position to aPosition in logical (drawing) units. More...
 
wxPoint GetCursorPosition (bool aOnGrid, wxRealPoint *aGridSize=NULL) const
 Return the current cursor position in logical (drawing) units. More...
 
wxPoint GetNearestGridPosition (const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
 Return the nearest aGridSize location to aPosition. More...
 
wxPoint GetCrossHairScreenPosition () const
 Return the cross hair position in device (display) units.b. More...
 
void SetMousePosition (const wxPoint &aPosition)
 
wxPoint RefPos (bool useMouse) const
 Return the reference position, coming from either the mouse position or the cursor position. More...
 
const wxPointGetScrollCenterPosition () const
 
void SetScrollCenterPosition (const wxPoint &aPoint)
 
virtual COLOR4D GetDrawBgColor () const
 
virtual void SetDrawBgColor (COLOR4D aColor)
 
bool GetShowBorderAndTitleBlock () const
 
void SetShowBorderAndTitleBlock (bool aShow)
 
bool ShowPageLimits () const
 
void SetShowPageLimits (bool aShow)
 
void OnMenuOpen (wxMenuEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void SkipNextLeftButtonReleaseEvent ()
 After calling this function, if the left mouse button is down, the next left mouse button release event will be ignored. More...
 
int WriteHotkeyConfig (struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL) override
 > More...
 
EDA_HOTKEY_CONFIGGetHotkeyConfig () const
 Return a structure containing currently used hotkey mapping. More...
 
virtual void AddMenuZoomAndGrid (wxMenu *aMasterMenu)
 Add standard zoom commands and submenu zoom and grid selection to a popup menu uses zoom hotkeys info base to add hotkeys info to menu commands. More...
 
double GetZoomLevelCoeff () const
 Return the coefficient to convert internal display scale factor to zoom level. More...
 
void EraseMsgBox ()
 
void Process_PageSettings (wxCommandEvent &event)
 
virtual void ReCreateAuxiliaryToolbar ()
 
wxAuiToolBar * GetMainToolBar () const
 
wxAuiToolBar * GetOptionsToolBar () const
 
wxAuiToolBar * GetDrawToolBar () const
 
wxAuiToolBar * GetAuxiliaryToolBar () const
 
bool GetToolToggled (int aToolId)
 Checks all the toolbars and returns true if the given tool id is toggled. More...
 
wxAuiToolBarItem * GetToolbarTool (int aToolId)
 Checks all the toolbars and returns a reference to the given tool id or nullptr if not found. More...
 
virtual void SetToolID (int aId, int aCursor, const wxString &aToolMsg)
 Set the tool command ID to aId and sets the cursor to aCursor. More...
 
virtual void SetNoToolSelected ()
 Select the ID_NO_TOOL_SELECTED id tool (Idle tool) More...
 
int GetToolId () const
 
virtual bool IsGridVisible () const
 
virtual void SetGridVisibility (bool aVisible)
 It may be overloaded by derived classes. More...
 
virtual COLOR4D GetGridColor ()
 
virtual void SetGridColor (COLOR4D aColor)
 
wxPoint GetGridPosition (const wxPoint &aPosition) const
 Return the nearest grid position to aPosition if a screen is defined and snap to grid is enabled. More...
 
virtual void SetNextGrid ()
 Change the grid size settings to the next one available. More...
 
virtual void SetPrevGrid ()
 Change the grid size settings to the previous one available. More...
 
void SetPresetGrid (int aIndex)
 Change the grid size to one of the preset values. More...
 
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 OnToggleGridState (wxCommandEvent &aEvent)
 
void OnSelectUnits (wxCommandEvent &aEvent)
 
void OnToggleCrossHairStyle (wxCommandEvent &aEvent)
 
void OnUpdateUndo (wxUpdateUIEvent &aEvent)
 
void OnUpdateRedo (wxUpdateUIEvent &aEvent)
 
void OnUpdateGrid (wxUpdateUIEvent &aEvent)
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 
void OnUpdateUnits (wxUpdateUIEvent &aEvent)
 
void OnUpdateCrossHairStyle (wxUpdateUIEvent &aEvent)
 
virtual void OnSize (wxSizeEvent &event)
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnEraseBackground (wxEraseEvent &SizeEvent)
 
virtual void OnZoom (wxCommandEvent &event)
 
void SetNextZoom ()
 Change the zoom to the next one available. More...
 
void SetNextZoomAndRedraw (const wxPoint &aCenterPoint, bool aWarpPointer)
 Change the zoom to the next one available redraws the screen and warp the mouse pointer on request. More...
 
void SetPrevZoom ()
 Change the zoom to the previous one available. More...
 
void SetPreviousZoomAndRedraw (const wxPoint &aCenterPoint, bool aWarpPointer)
 Change the zoom to the previous one available redraws the screen and warp the mouse pointer on request. More...
 
void SetPresetZoom (int aIndex)
 Change zoom to one of the preset values. More...
 
void FocusOnLocation (const wxPoint &aPos, bool aWarpCursor=true, 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 DrawWorkSheet (wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Draws on screen the page layout with the frame and the basic inscriptions. More...
 
void DisplayToolMsg (const wxString &msg)
 
virtual void ToolOnRightClick (wxCommandEvent &event)
 
void AdjustScrollBars (const wxPoint &aCenterPosition)
 
virtual void OnActivate (wxActivateEvent &event)
 Called when activating the frame. More...
 
void DisplayUnitsMsg ()
 Display current unit pane on the status bar. More...
 
void CopyToClipboard (wxCommandEvent &event)
 Copy the current page or the current block to the clipboard. 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...
 
void ClearMsgPanel (void)
 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...
 
void PushPreferences (const EDA_DRAW_PANEL *aParentCanvas)
 Push preferences from a parent window to a child window. More...
 
virtual void UseGalCanvas (bool aEnable)
 Use to switch between standard and GAL-based canvas. More...
 
virtual bool SwitchCanvas (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Changes the current rendering backend. More...
 
bool IsGalCanvasActive () const
 Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use. More...
 
EDA_DRAW_PANEL_GALGetGalCanvas () const
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
void SetGalCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
TOOL_MANAGERGetToolManager () const
 Return the tool manager instance, if any. More...
 
virtual void * GetDisplayOptions ()
 A way to pass info to draw functions. More...
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Return a reference to the gal rendering options used by GAL for rendering. More...
 
virtual void SyncMenusAndToolbars (wxEvent &aEvent)
 Update the toolbars and menus (mostly settings/check buttons/checkboxes) with the current controller state. More...
 
bool GetShowAxis () const
 
bool GetShowGridAxis () const
 
bool GetShowOriginAxis () const
 
VTBL_ENTRY 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 ProcessEvent (wxEvent &aEvent) override
 Function ProcessEvent overrides the default process event handler to implement the auto save feature. More...
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
void GetKicadHelp (wxCommandEvent &event)
 
void GetKicadContribute (wxCommandEvent &event)
 
void GetKicadAbout (wxCommandEvent &event)
 
bool ShowPreferences (EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
 
void PrintMsg (const wxString &text)
 
wxString ConfigBaseName ()
 Function ConfigBaseName. More...
 
void ImportHotkeyConfigFromFile (EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
 Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it. More...
 
void ExportHotkeyConfigToFile (EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
 Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
 Function GetFileFromHistory fetches the file name from the file history list. More...
 
void UpdateFileHistory (const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
 Function UpdateFileHistory Updates the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
bool IsWritable (const wxFileName &aFileName)
 Function IsWritable checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName, const wxString &aBackupFileExtension)
 Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
bool PostCommandMenuEvent (int evt_type)
 Function PostCommandMenuEvent. More...
 
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...
 

Static Public Member Functions

static wxString GetDefaultFieldName (int aFieldNdx)
 Return a default symbol field name for field aFieldNdx for all components. More...
 
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting ()
 Returns the canvas type stored in the application settings. More...
 

Static Public Attributes

static const wxCursor CURSOR_PROBE
 

Probe cursor, used by circuit simulator

More...
 
static const wxCursor CURSOR_TUNE
 

Tuner cursor, used by circuit simulator

More...
 

Protected Member Functions

const wxSize & GetLastSheetPinTextSize ()
 Initializing accessor for the pin text size. More...
 
virtual bool doAutoSave () override
 Save the schematic files that have been modified and not yet saved. More...
 
virtual bool isAutoSaveRequired () const override
 Returns true if the schematic has been modified. More...
 
void addCurrentItemToScreen ()
 Add the item currently being edited to the schematic and adds the changes to the undo/redo container. More...
 
void updateFindReplaceView (wxFindDialogEvent &aEvent)
 
void backAnnotateFootprints (const std::string &aChangedSetOfReferences)
 
bool prepareForNetlist ()
 Verify that annotation is complete so that a proper netlist is even possible. More...
 
void sendNetlist ()
 Send the kicad netlist over to CVPCB. More...
 
void OnOpenLibraryViewer (wxCommandEvent &event)
 Open the library viewer only to browse library contents. More...
 
bool DisplayListComponentsInLib (wxString &aLibrary, wxString &aBuffer, wxString &aPreviousChoice)
 Select a component from the list of components in a library. More...
 
wxString SelectLibraryFromList ()
 Dispaly a list of loaded libraries in the symbol library and allows the user to select a library. More...
 
bool SelectPartNameToLoad (wxString &aLibrary, wxString &aBufName)
 Function SelectPartNameToLoad Select a part name from the list of components (parts) found in a library. More...
 
bool saveSymbolLibTables (bool aGlobal, bool aProject)
 Saves Symbol Library Tables to disk. More...
 
virtual bool HandleBlockBegin (wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0) override
 Initialize a block command. More...
 
double bestZoom (double sizeX, double sizeY, double scaleFactor, wxPoint centre)
 
virtual void unitsChangeRefresh ()
 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...
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory)
 
bool GeneralControlKeyMovement (int aHotKey, wxPoint *aPos, bool aSnapToGrid)
 Handle the common part of GeneralControl dedicated to global cursor keys (i.e. More...
 
void RefreshCrossHair (const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC *aDC)
 Move and refresh the crosshair after movement and call the mouse capture function. More...
 
bool isBusy () const
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
bool saveCanvasImageToFile (const wxString &aFileName, wxBitmapType aBitmapType=wxBITMAP_TYPE_PNG)
 
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)
 
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)
 Function onAutoSaveTimer handles the auto save timer event. More...
 
virtual wxConfigBase * config ()
 Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
virtual const SEARCH_STACKsys_search ()
 Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_MANAGER_FRAME. More...
 
virtual wxString help_name ()
 

Protected Attributes

TEMPLATES m_templateFieldNames
 
wxPoint m_repeatStep
 the increment value of the position of an item when it is repeated More...
 
int m_repeatDeltaLabel
 the increment value of labels like bus members when they are repeated More...
 
bool m_galCanvasActive
 whether to use new GAL engine More...
 
bool m_useSingleCanvasPane
 
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...
 
EDA_HOTKEY_CONFIGm_hotkeysDescrList
 
int m_LastGridSizeId
 
bool m_drawGrid
 
bool m_showPageLimits
 true to display the page limits More...
 
COLOR4D m_gridColor
 Grid color. More...
 
COLOR4D m_drawBgColor
 the background color of the draw canvas BLACK for Pcbnew, BLACK or WHITE for eeschema More...
 
double m_zoomLevelCoeff
 a suitable value to convert the internal zoom scaling factor More...
 
int m_UndoRedoCountMax
 default Undo/Redo command Max depth, to be handed More...
 
EDA_UNITS_T m_UserUnits
 
EDA_DRAW_PANELm_canvas
 The area to draw on. More...
 
TOOL_MANAGERm_toolManager
 
TOOL_DISPATCHERm_toolDispatcher
 
ACTIONSm_actions
 
int m_lastDrawToolId
 Tool ID of previously active draw tool bar button. More...
 
bool m_showAxis
 True shows the X and Y axis indicators. More...
 
bool m_showGridAxis
 True shows the grid axis indicators. More...
 
bool m_showOriginAxis
 True shows the origin axis used to indicate the coordinate offset for drill, gerber, and component position files. More...
 
bool m_showBorderAndTitleBlock
 True shows the drawing border and title block. More...
 
long m_firstRunDialogSetting
 Key to control whether first run dialog is shown on startup. More...
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
wxAuiToolBar * m_auxiliaryToolBar
 Auxiliary tool bar typically shown below the main tool bar at the top of the main window. More...
 
wxAuiToolBar * m_drawToolBar
 The tool bar that contains the buttons for quick access to the application draw tools. More...
 
wxAuiToolBar * m_optionsToolBar
 The options tool bar typcially located on the left edge of the main window. More...
 
EDA_MSG_PANELm_messagePanel
 Panel used to display information at the bottom of the main window. More...
 
int m_MsgFrameHeight
 
bool m_movingCursorWithKeyboard
 One-shot to avoid a recursive mouse event during hotkey movement. More...
 
bool m_canvasTypeDirty
 Flag indicating that drawing canvas type needs to be saved to config. More...
 
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
 Id Type (pcb, schematic, library..) More...
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_configFrameName
 prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTOR is used More...
 
wxAuiToolBar * m_mainToolBar
 Standard horizontal Toolbar. More...
 
wxString m_AboutTitle
 Name of program displayed in About. More...
 
wxAuiManager m_auimgr
 
bool m_hasAutoSave
 Flag to indicate if this frame supports auto save. More...
 
bool m_autoSaveState
 Flag to indicate the last auto save state. More...
 
int m_autoSaveInterval
 The auto save interval time in seconds. More...
 
wxTimer * m_autoSaveTimer
 The timer used to implement the auto save feature;. More...
 
wxString m_perspective
 wxAuiManager perspective. More...
 
wxString m_mruPath
 Most recently used path. More...
 

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...
 
static const wxChar CANVAS_TYPE_KEY [] = wxT( "canvas_type" )
 

Key in KifaceSettings to store the canvas type.

More...
 

Private Member Functions

void OnAutoplaceFields (wxCommandEvent &aEvent)
 Handle the ID_AUTOPLACE_FIELDS event. More...
 
void OnMoveItem (wxCommandEvent &aEvent)
 Handle the ID_SCH_MOVE_ITEM event used to move schematic items. More...
 
void OnRotate (wxCommandEvent &aEvent)
 Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic items and blocks. More...
 
void OnEditItem (wxCommandEvent &aEvent)
 Handle the ID_SCH_EDIT_ITEM event used to edit schematic items. More...
 
void SelectAllFromSheet (wxCommandEvent &aEvent)
 Handle the ID_POPUP_SCH_SELECT_ON_PCB event used to select items in Pcbnew based on the sheet they are placed on. More...
 
void OnDragItem (wxCommandEvent &aEvent)
 Handle the ID_SCH_DRAG_ITEM event used to drag schematic items. More...
 
void OnOrient (wxCommandEvent &aEvent)
 Handle the ID_SCH_MIRROR_X, ID_SCH_MIRROR_Y, and ID_SCH_ORIENT_NORMAL events used to orient schematic items and blocks. More...
 
void OnExit (wxCommandEvent &event)
 
void OnAnnotate (wxCommandEvent &event)
 
void OnErc (wxCommandEvent &event)
 
void OnCreateNetlist (wxCommandEvent &event)
 
void OnUpdatePCB (wxCommandEvent &event)
 
void OnSimulate (wxCommandEvent &event)
 
void OnCreateBillOfMaterials (wxCommandEvent &event)
 
void OnLaunchBomManager (wxCommandEvent &event)
 
void OnFindItems (wxCommandEvent &event)
 
void OnFindDialogClose (wxFindDialogEvent &event)
 
void OnFindDrcMarker (wxFindDialogEvent &event)
 
void OnFindCompnentInLib (wxFindDialogEvent &event)
 
void OnFindSchematicItem (wxFindDialogEvent &aEvent)
 Find an item in the schematic matching the search criteria in aEvent. More...
 
void OnFindReplace (wxFindDialogEvent &aEvent)
 Perform a search and replace of text in an item in the schematic matching the search and replace criteria in aEvent. More...
 
void OnLoadFile (wxCommandEvent &event)
 
void OnLoadCmpToFootprintLinkFile (wxCommandEvent &event)
 
void OnUpdateFields (wxCommandEvent &event)
 
void OnNewProject (wxCommandEvent &event)
 
void OnLoadProject (wxCommandEvent &event)
 
void OnAppendProject (wxCommandEvent &event)
 
void OnImportProject (wxCommandEvent &event)
 
void OnOpenPcbnew (wxCommandEvent &event)
 
void OnOpenPcbModuleEditor (wxCommandEvent &event)
 
void OnOpenCvpcb (wxCommandEvent &event)
 
void OnOpenLibraryEditor (wxCommandEvent &event)
 
void OnRescueProject (wxCommandEvent &event)
 
void OnRemapSymbols (wxCommandEvent &aEvent)
 
void OnEditComponentSymbolsId (wxCommandEvent &aEvent)
 
void OnPreferencesOptions (wxCommandEvent &event)
 
void OnCancelCurrentCommand (wxCommandEvent &aEvent)
 
void OnSelectItem (wxCommandEvent &aEvent)
 
void OnCopySchematicItemRequest (wxCommandEvent &event)
 Command event handler for duplicating the item at the current location. More...
 
void OnUpdatePaste (wxUpdateUIEvent &event)
 
void OnUpdateHiddenPins (wxUpdateUIEvent &event)
 
void OnUpdateBusOrientation (wxUpdateUIEvent &event)
 
void OnUpdateSelectTool (wxUpdateUIEvent &aEvent)
 
void OnUpdateSave (wxUpdateUIEvent &aEvent)
 
void OnUpdateSaveSheet (wxUpdateUIEvent &aEvent)
 
void OnUpdateHierarchySheet (wxUpdateUIEvent &aEvent)
 
void OnUpdateRemapSymbols (wxUpdateUIEvent &aEvent)
 
void CloseErc ()
 Close the ERC dialog if it is open. More...
 
void UpdateTitle ()
 Set the main window title bar text. More...
 
SCH_BUS_WIRE_ENTRYCreateBusWireEntry ()
 
SCH_BUS_BUS_ENTRYCreateBusBusEntry ()
 
void SetBusEntryShape (wxDC *DC, SCH_BUS_ENTRY_BASE *BusEntry, char entry_shape)
 
SCH_NO_CONNECTAddNoConnect (const wxPoint &aPosition)
 Add no connect item to the current schematic sheet at aPosition. More...
 
SCH_JUNCTIONAddJunction (const wxPoint &aPosition, bool aPutInUndoList=false)
 Add a new junction at aPosition. More...
 
void SaveWireImage ()
 Save a copy of the current wire image in the undo list. More...
 
void GetSchematicConnections (std::vector< wxPoint > &aConnections)
 Collects a unique list of all possible connection points in the schematic. More...
 
bool SchematicCleanUp (bool aAppend=false)
 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, bool aAppend=true)
 If any single wire passes through both points, remove the portion between the two points, potentially splitting the wire into two. More...
 
void PrepareMoveItem (SCH_ITEM *aItem)
 Start moving aItem using the mouse. More...
 
SCH_TEXTCreateNewText (int aType)
 
void EditSchematicText (SCH_TEXT *TextStruct)
 
void ChangeTextOrient (SCH_TEXT *aTextItem)
 
void OnConvertTextType (wxCommandEvent &aEvent)
 Command event handler to change a text type to another one. More...
 
void BeginSegment (int type)
 Creates a new segment ( WIRE, BUS ) or terminates the current segment in progress. More...
 
void EndSegment ()
 Terminate a bus, wire, or line creation. More...
 
void DeleteCurrentSegment ()
 Erase the last segment at the current mouse position. More...
 
void DeleteConnection (bool DeleteFullConnection)
 
SCH_BITMAPCreateNewImage (wxDC *aDC)
 
void RotateImage (SCH_BITMAP *aItem)
 
void MirrorImage (SCH_BITMAP *aItem, bool Is_X_axis)
 Mirror a bitmap. More...
 
void EditImage (SCH_BITMAP *aItem)
 
void InstallHierarchyFrame (wxPoint &pos)
 
SCH_SHEETCreateSheet (wxDC *DC)
 
void ReSizeSheet (SCH_SHEET *Sheet, wxDC *DC)
 
void RotateHierarchicalSheet (SCH_SHEET *aSheet, bool aRotCCW)
 Rotate a sheet object. More...
 
void MirrorSheet (SCH_SHEET *aSheet, bool aFromXaxis)
 Mirror a hierarchical sheet. More...
 
int EditLine (SCH_LINE *aLine, bool aRedraw)
 Function EditLine displays the dialog for editing the parameters of aLine. More...
 
bool importFile (const wxString &aFileName, int aFileType)
 Load the given filename but sets the path to the current project path. More...
 
bool validateSheet (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
 
SCH_SHEET_PINCreateSheetPin (SCH_SHEET *aSheet)
 Create a new SCH_SHEET_PIN object and add it to aSheet at the current cursor position. More...
 
int EditSheetPin (SCH_SHEET_PIN *aSheetPin, bool aRedraw)
 Display the dialog for editing the parameters of aSheetPin. More...
 
SCH_SHEET_PINImportSheetPin (SCH_SHEET *aSheet)
 Automatically create a sheet pin from the hierarchical labels in the schematic referenced by aSheet. More...
 
SCH_COMPONENTLoad_Component (const SCHLIB_FILTER *aFilter, SCH_BASE_FRAME::HISTORY_LIST &aHistoryList, bool aUseLibBrowser)
 Load a symbol library and places it on the current schematic. More...
 
void EditComponent (SCH_COMPONENT *aComponent)
 Display the edit component dialog to edit the parameters of aComponent. More...
 
void OnSelectUnit (wxCommandEvent &aEvent)
 
void ConvertPart (SCH_COMPONENT *DrawComponent)
 
void EditComponentFieldText (SCH_FIELD *aField)
 Display the edit field dialog to edit the parameters of aField. More...
 
void RotateField (SCH_FIELD *aField)
 
void PasteListOfItems (wxDC *DC)
 Paste a list of items from the block stack. 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 GetSchematicFromRedoList (wxCommandEvent &event)
 Redo the last edit. More...
 
void GetSchematicFromUndoList (wxCommandEvent &event)
 Perform an undo the last edit. More...
 
void copyBlockItems (PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMoveVector)
 Copy the list of block item. More...
 
void addJunctionMenuEntries (wxMenu *aMenu, SCH_JUNCTION *aJunction)
 Add the context menu items to aMenu for aJunction. More...
 

Private Attributes

SCH_SHEET_PATHm_CurrentSheet
 which sheet we are presently working on. More...
 
wxString m_DefaultSchematicFileName
 
wxString m_SelectedNetName
 
PARAM_CFG_ARRAY m_projectFileParams
 
PARAM_CFG_ARRAY m_configSettings
 
wxPageSetupDialogData m_pageSetupData
 
wxFindReplaceData * m_findReplaceData
 
wxString * m_findReplaceStatus
 
bool m_printMonochrome
 Print monochrome instead of grey scale. More...
 
bool m_printSheetReference
 
DIALOG_SCH_FINDm_dlgFindReplace
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
BLOCK_SELECTOR m_blockItems
 List of selected items. More...
 
SCH_ITEMm_item_to_repeat
 Last item to insert by the repeat command. More...
 
int m_repeatLabelDelta
 Repeat label number increment step. More...
 
SCH_COLLECTOR m_collectedItems
 List of collected items. More...
 
SCH_FIND_COLLECTOR m_foundItems
 List of find/replace items. More...
 
SCH_ITEMm_undoItem
 Copy of the current item being edited. More...
 
wxString m_simulatorCommand
 Command line used to call the circuit simulator (gnucap, spice, ...) 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...
 
int m_foundItemIndex
 An index to the last find item in the found items list m_foundItems. More...
 
bool m_showAllPins
 Flag to indicate show hidden pins. More...
 
wxString m_plotDirectoryName
 The name of the destination directory to use when generating plot files. More...
 
wxString m_netListFormat
 The name of the format to use when generating a net list. More...
 
bool m_spiceAjustPassiveValues
 Use netcodes (net number) as net names when generating spice net lists. More...
 

Static Private Attributes

static PINSHEETLABEL_SHAPE m_lastSheetPinType = NET_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...
 

Detailed Description

Schematic editor (Eeschema) main window.

Definition at line 117 of file sch_edit_frame.h.

Member Typedef Documentation

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

Definition at line 193 of file sch_base_frame.h.

Constructor & Destructor Documentation

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

Definition at line 449 of file sch_edit_frame.cpp.

References g_RootSheet, ID_EDIT_SYM_LIB_TABLE, and SCH_BASE_FRAME::OnEditSymbolLibTable().

450 {
451  Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
453 
454  delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem()
455 
456  SetScreen( NULL );
457 
458  delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
459  delete m_undoItem;
460  delete m_findReplaceData;
461  delete m_findReplaceStatus;
462 
463  delete g_RootSheet;
464  g_RootSheet = NULL;
465 }
wxString * m_findReplaceStatus
virtual void OnEditSymbolLibTable(wxCommandEvent &aEvent)
virtual void SetScreen(BASE_SCREEN *aScreen) override
wxFindReplaceData * m_findReplaceData
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
SCH_ITEM * m_undoItem
Copy of the current item being edited.

Member Function Documentation

void SCH_EDIT_FRAME::addCurrentItemToScreen ( )
protected

Add the item currently being edited to the schematic and adds the changes to the undo/redo container.

Definition at line 1346 of file sch_edit_frame.cpp.

References SCH_SHEET::AddPin(), SCH_SCREEN::CheckIfOnDrawList(), SCH_SCREENS::ClearAnnotationOfNewSheetPaths(), EDA_ITEM::ClearFlags(), g_RootSheet, SCH_ITEM::GetConnectionPoints(), SCH_SCREEN::GetCurItem(), EDA_ITEM::GetParent(), i, SCH_ITEM::IsConnectable(), SCH_SCREEN::IsJunctionNeeded(), EDA_ITEM::IsNew(), SCH_COMPONENT_T, SCH_FIELD_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SCREEN::SetCurItem(), BASE_SCREEN::SetModify(), EDA_ITEM::Type(), UR_CHANGED, and UR_NEW.

Referenced by CreateBusBusEntry(), CreateBusWireEntry(), OnLeftClick(), and Process_Special_Functions().

1347 {
1348  SCH_SCREEN* screen = GetScreen();
1349  SCH_ITEM* item = screen->GetCurItem();
1350 
1351  wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
1352 
1353  m_canvas->SetAutoPanRequest( false );
1354 
1355  SCH_SHEET* parentSheet = nullptr;
1356  SCH_COMPONENT* parentComponent = nullptr;
1357  SCH_ITEM* undoItem = item;
1358 
1359  if( item->Type() == SCH_SHEET_PIN_T )
1360  {
1361  parentSheet = (SCH_SHEET*) item->GetParent();
1362 
1363  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1364  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1365 
1366  undoItem = parentSheet;
1367  }
1368 
1369  else if( item->Type() == SCH_FIELD_T )
1370  {
1371  parentComponent = (SCH_COMPONENT*) item->GetParent();
1372 
1373  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
1374  wxT( "Cannot place field in invalid schematic component object." ) );
1375 
1376  undoItem = parentComponent;
1377  }
1378 
1379  if( item->IsNew() )
1380  {
1381  // When a new sheet is added to the hierarchy, a clear annotation can be needed
1382  // for all new sheet paths added by the new sheet (if this sheet is loaded from
1383  // and existing sheet or a existing file, it can also contain subsheets)
1384  bool doClearAnnotation = false;
1385  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1386 
1387  if( item->Type() == SCH_SHEET_T )
1388  {
1389  // Fix the size and position of the new sheet using the last values set by
1390  // the m_mouseCaptureCallback function.
1391  m_canvas->SetMouseCapture( NULL, NULL );
1392 
1393  if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet, &doClearAnnotation ) )
1394  {
1395  screen->SetCurItem( NULL );
1396  delete item;
1397 
1398  return;
1399  }
1400 
1402 
1403  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1404  AddToScreen( item );
1405 
1406  SetRepeatItem( item );
1407  SaveCopyInUndoList( undoItem, UR_NEW );
1408  }
1409  else if( item->Type() == SCH_SHEET_PIN_T )
1410  {
1411  // Sheet pins are owned by their parent sheet.
1412  SaveCopyInUndoList( undoItem, UR_CHANGED ); // save the parent sheet
1413 
1414  parentSheet->AddPin( (SCH_SHEET_PIN*) item );
1415  }
1416  else if( item->Type() == SCH_FIELD_T )
1417  {
1418  // Component fields are also owned by their parent, but new component fields
1419  // are handled elsewhere.
1420  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1421  }
1422  else
1423  {
1424  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1425  AddToScreen( item );
1426 
1427  SetRepeatItem( item );
1428  SaveCopyInUndoList( undoItem, UR_NEW );
1429  }
1430 
1431  if( doClearAnnotation )
1432  {
1433  // Clear annotation of new sheet paths: the new sheet and its sub-sheets
1434  // If needed the missing alternate references of components will be created
1435  SCH_SCREENS screensList( g_RootSheet );
1436  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1437  }
1438  }
1439  else
1440  {
1441  SaveUndoItemInUndoList( undoItem );
1442  }
1443 
1444  item->ClearFlags();
1445 
1446  screen->SetModify();
1447  screen->SetCurItem( NULL );
1448  m_canvas->SetMouseCapture( NULL, NULL );
1450 
1451  RefreshItem( item );
1452 
1453  if( item->IsConnectable() )
1454  {
1455  std::vector< wxPoint > pts;
1456  item->GetConnectionPoints( pts );
1457 
1458  for( auto i = pts.begin(); i != pts.end(); i++ )
1459  {
1460  for( auto j = i + 1; j != pts.end(); j++ )
1461  TrimWire( *i, *j, true );
1462 
1463  if( screen->IsJunctionNeeded( *i, true ) )
1464  AddJunction( *i, true );
1465  }
1466 
1467  TestDanglingEnds();
1468  }
1469 
1470  GetCanvas()->Refresh();
1471 }
Class SCH_SHEET_LIST.
SCH_JUNCTION * AddJunction(const wxPoint &aPosition, bool aPutInUndoList=false)
Add a new junction at aPosition.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
bool IsNew() const
Definition: base_struct.h:219
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:325
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
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 AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:177
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:45
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void SaveUndoItemInUndoList(SCH_ITEM *aItem)
Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
SCH_DRAW_PANEL * GetCanvas() const override
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 a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
void SetAutoPanRequest(bool aEnable)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
size_t i
Definition: json11.cpp:597
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd, bool aAppend=true)
If any single wire passes through both points, remove the portion between the two points...
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void SetModify()
Definition: base_screen.h:324
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:205
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
SCH_JUNCTION * SCH_EDIT_FRAME::AddJunction ( const wxPoint aPosition,
bool  aPutInUndoList = false 
)
private

Add a new junction at aPosition.

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

References SCH_BASE_FRAME::AddToScreen(), BreakSegments(), KIGFX::SCH_VIEW::ClearPreview(), SCH_BASE_FRAME::GetCanvas(), SCH_DRAW_PANEL::GetView(), OnModify(), SaveCopyInUndoList(), TestDanglingEnds(), and UR_NEW.

Referenced by CheckListConnections(), EndSegment(), importFile(), OnLeftClick(), Process_Special_Functions(), and SetPrintSheetReference().

798 {
799  SCH_JUNCTION* junction = new SCH_JUNCTION( aPosition );
800  bool broken_segments = false;
801 
802  AddToScreen( junction );
803  broken_segments = BreakSegments( aPosition, aAppend );
805  OnModify();
806  SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
807 
808  auto view = GetCanvas()->GetView();
809  view->ClearPreview();
810  view->ShowPreview( false );
811  view->ClearHiddenFlags();
812 
813  return junction;
814 }
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
bool BreakSegments(const wxPoint &aPoint, bool aAppend=false)
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.
SCH_DRAW_PANEL * GetCanvas() const override
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:112
KIGFX::SCH_VIEW * GetView() const
void AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
void SCH_EDIT_FRAME::addJunctionMenuEntries ( wxMenu *  aMenu,
SCH_JUNCTION aJunction 
)
private

Add the context menu items to aMenu for aJunction.

Parameters
aMenuThe menu to add the items to.
aJunctionThe SCH_JUNCTION object selected.

Definition at line 667 of file eeschema/onrightclick.cpp.

References AddHotkeyName(), AddMenuItem(), EXCLUDE_END_POINTS_T, g_Schematic_Hokeys_Descr, SCH_JUNCTION::GetPosition(), GetScreen(), SCH_SCREEN::GetWire(), SCH_SCREEN::GetWireOrBus(), HK_DELETE, ID_POPUP_SCH_BREAK_WIRE, ID_POPUP_SCH_DELETE, ID_POPUP_SCH_DELETE_CONNECTION, ID_POPUP_SCH_DELETE_NODE, ID_SCH_DRAG_ITEM, SCH_COLLECTOR::IsDraggableJunction(), EDA_ITEM::IsNew(), KiBitmap(), and m_collectedItems.

Referenced by GetLabelIncrement(), and OnRightClick().

668 {
669  wxString msg;
670  SCH_SCREEN* screen = GetScreen();
671 
672  msg = AddHotkeyName( _( "Delete Junction" ), g_Schematic_Hokeys_Descr, HK_DELETE );
673  AddMenuItem( aMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
674 
675  if( !aJunction->IsNew() )
676  {
678  AddMenuItem( aMenu, ID_SCH_DRAG_ITEM, _( "Drag Junction" ), KiBitmap( drag_xpm ) );
679 
680  if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) )
681  AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
682  KiBitmap( break_line_xpm ) );
683  }
684 
685  if( screen->GetWireOrBus( aJunction->GetPosition() ) )
686  {
687  AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
688  KiBitmap( delete_node_xpm ) );
689  AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
690  KiBitmap( delete_connection_xpm ) );
691  }
692 }
bool IsNew() const
Definition: base_struct.h:219
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
SCH_COLLECTOR m_collectedItems
List of collected items.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
bool IsDraggableJunction() const
Function IsDraggableJunction tests to see if the collected items form a draggable junction...
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:103
SCH_LINE * GetWire(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Definition: sch_screen.h:462
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
SCH_LINE * GetWireOrBus(const wxPoint &aPosition)
Return a wire or bus item located at aPosition.
Definition: sch_screen.cpp:950
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]
void EDA_DRAW_FRAME::AddMenuZoomAndGrid ( wxMenu *  aMasterMenu)
virtualinherited

Add standard zoom commands and submenu zoom and grid selection to a popup menu uses zoom hotkeys info base to add hotkeys info to menu commands.

Parameters
aMasterMenu= the menu to populate.

Definition at line 1533 of file legacy_gal/eda_draw_frame.cpp.

References AddHotkeyName(), AddMenuItem(), BASE_SCREEN::BuildGridsChoiceList(), BASE_SCREEN::GetGrid(), BASE_SCREEN::GetGridCount(), EDA_DRAW_PANEL::GetScreen(), EDA_DRAW_FRAME::GetUserUnits(), BASE_SCREEN::GetZoom(), HK_ZOOM_AUTO, HK_ZOOM_CENTER, HK_ZOOM_IN, HK_ZOOM_OUT, HK_ZOOM_REDRAW, i, ID_POPUP_CANCEL, ID_POPUP_GRID_SELECT, ID_POPUP_ZOOM_CENTER, ID_POPUP_ZOOM_IN, ID_POPUP_ZOOM_LEVEL_END, ID_POPUP_ZOOM_LEVEL_START, ID_POPUP_ZOOM_OUT, ID_POPUP_ZOOM_PAGE, ID_POPUP_ZOOM_REDRAW, ID_POPUP_ZOOM_SELECT, INCHES, KiBitmap(), EDA_DRAW_FRAME::m_canvas, GRID_TYPE::m_CmdId, EDA_DRAW_FRAME::m_hotkeysDescrList, EDA_DRAW_FRAME::m_zoomLevelCoeff, and BASE_SCREEN::m_ZoomList.

Referenced by EDA_DRAW_PANEL::OnRightClick().

1534 {
1535  int maxZoomIds;
1536  double zoom;
1537  wxString msg;
1538  BASE_SCREEN* screen = m_canvas->GetScreen();
1539 
1540  msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER );
1541  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
1542  msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN );
1543  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) );
1544  msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT );
1545  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) );
1546  msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW );
1547  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) );
1548  msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO );
1549  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) );
1550 
1551 
1552  wxMenu* zoom_choice = new wxMenu;
1553  AddMenuItem( MasterMenu, zoom_choice,
1554  ID_POPUP_ZOOM_SELECT, _( "Zoom" ),
1555  KiBitmap( zoom_selection_xpm ) );
1556 
1557  zoom = screen->GetZoom();
1559  maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ?
1560  maxZoomIds : screen->m_ZoomList.size();
1561 
1562  // Populate zoom submenu.
1563  for( int i = 0; i < maxZoomIds; i++ )
1564  {
1565  msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );
1566 
1567  zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
1568  wxEmptyString, wxITEM_CHECK );
1569  if( zoom == screen->m_ZoomList[i] )
1570  zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
1571  }
1572 
1573  // Create grid submenu as required.
1574  if( screen->GetGridCount() )
1575  {
1576  wxMenu* gridMenu = new wxMenu;
1577  AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
1578  _( "Grid" ), KiBitmap( grid_select_xpm ) );
1579 
1580  wxArrayString gridsList;
1581  int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1582 
1583  for( unsigned i = 0; i < gridsList.GetCount(); i++ )
1584  {
1585  GRID_TYPE& grid = screen->GetGrid( i );
1586  gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
1587 
1588  if( (int)i == icurr )
1589  gridMenu->Check( grid.m_CmdId, true );
1590  }
1591  }
1592 
1593  MasterMenu->AppendSeparator();
1594  AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
1595 }
virtual BASE_SCREEN * GetScreen()=0
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:105
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
Definition: common.h:160
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:115
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:45
size_t i
Definition: json11.cpp:597
int m_CmdId
Definition: base_screen.h:48
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
SCH_NO_CONNECT * SCH_EDIT_FRAME::AddNoConnect ( const wxPoint aPosition)
private

Add no connect item to the current schematic sheet at aPosition.

Parameters
aPositionThe position in logical (drawing) units to add the no connect.
Returns
The no connect item added.

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

References SCH_BASE_FRAME::AddToScreen(), KIGFX::SCH_VIEW::ClearPreview(), SCH_BASE_FRAME::GetCanvas(), SCH_DRAW_PANEL::GetView(), OnModify(), SaveCopyInUndoList(), SchematicCleanUp(), SetRepeatItem(), TestDanglingEnds(), and UR_NEW.

Referenced by OnLeftClick(), and SetPrintSheetReference().

818 {
819  SCH_NO_CONNECT* no_connect = new SCH_NO_CONNECT( aPosition );
820 
821  SetRepeatItem( no_connect );
822  AddToScreen( no_connect );
825  OnModify();
826 
827  auto view = GetCanvas()->GetView();
828  view->ClearPreview();
829  view->ShowPreview( false );
830  view->ClearHiddenFlags();
831 
832  SaveCopyInUndoList( no_connect, UR_NEW );
833  return no_connect;
834 }
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
SCH_DRAW_PANEL * GetCanvas() const override
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:112
KIGFX::SCH_VIEW * GetView() const
void AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
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 300 of file sch_edit_frame.h.

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

Referenced by PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow().

301  {
302  return m_templateFieldNames.AddTemplateFieldName( aFieldName );
303  }
TEMPLATES m_templateFieldNames
int AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName)
Function AddTemplateFieldName inserts or appends a wanted symbol field name into the fieldnames templ...
void SCH_BASE_FRAME::AddToScreen ( SCH_ITEM aItem)
inherited

Add an item to the screen (and view)

Definition at line 628 of file sch_base_frame.cpp.

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

Referenced by AddJunction(), AddNoConnect(), BreakSegment(), DeleteJunction(), DuplicateItemsInList(), EndSegment(), ExitSheet(), OnConvertTextType(), PasteListOfItems(), PutDataInPreviousState(), RepeatDrawItem(), and SchematicCleanUp().

629 {
630  GetScreen()->Append( aItem );
631  GetCanvas()->GetView()->Add( aItem );
632  RefreshItem( aItem, true ); // handle any additional parent semantics
633 }
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
KIGFX::SCH_VIEW * GetView() const
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:162
void RefreshItem(SCH_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:344
void SCH_BASE_FRAME::AddToScreen ( DLIST< SCH_ITEM > &  aItems)
inherited

Add a list of items to the screen (and view)

Definition at line 636 of file sch_base_frame.cpp.

References KIGFX::VIEW::Add(), SCH_SCREEN::Append(), DLIST< T >::begin(), SCH_BASE_FRAME::GetCanvas(), SCH_BASE_FRAME::GetScreen(), SCH_DRAW_PANEL::GetView(), SCH_ITEM::Next(), and SCH_BASE_FRAME::RefreshItem().

637 {
638  for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() )
639  {
640  GetCanvas()->GetView()->Add( item );
641  RefreshItem( item, true ); // handle any additional parent semantics
642  }
643 
644  GetScreen()->Append( aItems );
645 }
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
T * begin() const
Definition: dlist.h:218
SCH_ITEM * Next() const
SCH_DRAW_PANEL * GetCanvas() const override
KIGFX::SCH_VIEW * GetView() const
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:162
void RefreshItem(SCH_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:344
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void EDA_DRAW_FRAME::AdjustScrollBars ( const wxPoint aCenterPosition)
inherited

Definition at line 1019 of file legacy_gal/eda_draw_frame.cpp.

1020 {
1021 }
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 annotate.cpp.

References SCH_REFERENCE_LIST::Annotate(), CheckAnnotate(), DeleteAnnotation(), 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(), i, INCREMENTAL_BY_REF, m_CurrentSheet, mapExistingAnnotation(), OnModify(), REFERENCE, SCH_DRAW_PANEL::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 DeleteAllTemplateFieldNames(), and DIALOG_ANNOTATE::OnApplyClick().

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  m_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  m_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...
Class SCH_SHEET_LIST.
void SortByYCoordinate()
Function sortByYCoordinate sorts the list of references by Y position.
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:80
Annotate incrementally using the first free reference number.
int GetUnitCount() const
Return the number of units per package of the symbol.
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 UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
Field Reference of part, i.e. "IC21".
Class SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierar...
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
void UpdateAnnotation()
function UpdateAnnotation Updates the reference components for the schematic project (or the current ...
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
void SortByXCoordinate()
Function sortByXCoordinate sorts the list of references by X position.
void DeleteAnnotation(bool aCurrentSheetOnly)
Clear the current component annotation.
Definition: annotate.cpp:59
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:109
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
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.
int GetUnit() const
void mapExistingAnnotation(std::map< timestamp_t, wxString > &aMap)
Definition: annotate.cpp:41
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...
int CheckAnnotate(REPORTER &aReporter, bool aOneSheetOnly)
Check for annotation errors.
Definition: annotate.cpp:245
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:92
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)...
size_t i
Definition: json11.cpp:597
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.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
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 GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
unsigned GetCount()
Function GetCount.
#define VALUE
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
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 873 of file legacy_gal/eda_draw_frame.cpp.

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

Referenced by AppendSchematic(), PCB_BASE_FRAME::Compile_Ratsnest(), LIB_EDIT_FRAME::DisplayCmpDoc(), GERBER_FILE_IMAGE::DisplayImageInfo(), EditSheet(), importFile(), OpenProjectFiles(), SaveEEFile(), LIB_EDIT_FRAME::saveLibrary(), PCB_EDIT_FRAME::SavePcbFile(), ShowNewTrackWhenMovingCursor(), and LIB_VIEW_FRAME::updatePreviewSymbol().

876 {
877  if( m_messagePanel == NULL )
878  return;
879 
880  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
881 }
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:163
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
bool SCH_EDIT_FRAME::AppendSchematic ( )

Import a KiCad schematic into the current page.

In order to import a schematic a lot of things have to happen to before the contents of the imported schematic can be appended to the current page. The following list describes this process:

  • Load the schematic into a temporary SCH_SHEET object.
  • Make sure the imported schematic does not cause any hierarchy recursion issues.
  • Verify the imported schematic uses fully qualified LIB_ID objects (symbol library table).
  • Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes:
    • Check if the symbol library already exists in the project or global symbol library table.
    • Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project.
    • Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes.
    • Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes.
  • Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic.
  • Clear all of the annotation in the imported schematic to prevent clashes.
  • Append the objects from the temporary sheet to the current page.
  • Replace any duplicate time stamps.
  • Refresh the symbol library links.
Returns
True if the project was imported properly.

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

References PART_LIBS::AddLibrary(), SCH_SCREEN::Append(), EDA_DRAW_FRAME::AppendMsgPanel(), PART_LIBS::CacheName(), SCH_SCREENS::ClearAnnotation(), SCH_TYPE_COLLECTOR::Collect(), CYAN, DisplayError(), DisplayErrorMessage(), DisplayInfoMessage(), SYMBOL_LIB_TABLE::FindRow(), Format(), g_RootSheet, COLLECTOR::GetCount(), GetCurrentSheet(), LIB_TABLE_ROW::GetDescr(), SCH_SCREEN::GetDrawItems(), SCH_PLUGIN::GetError(), SCH_SCREEN::GetFileName(), LIB_TABLE::GetFullURI(), GetNewTimeStamp(), LIB_TABLE_ROW::GetOptions(), GetScreen(), SCH_SCREEN::GetSheet(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName(), SYMBOL_LIB_TABLE_ROW::GetType(), HardRedraw(), LIB_TABLE::HasLibrary(), i, ID_POPUP_GRID_LEVEL_1000, LIB_TABLE::IsEmpty(), IsOK(), KIWAY_HOLDER::Kiway(), SCH_PLUGIN::Load(), LIB_TABLE::Load(), EDA_DRAW_FRAME::m_LastGridSizeId, name, OnModify(), KIWAY_HOLDER::Prj(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), SchematicFileWildcard(), BASE_SCREEN::SetGrid(), SCH_SHEET::SetName(), SetSheetNumberAndCount(), EDA_ITEM::SetTimeStamp(), SCH_COLLECTOR::SheetsOnly, SCH_BASE_FRAME::SyncView(), SCH_SHEET_LIST::TestForRecursion(), SCH_SCREENS::UpdateSymbolLinks(), IO_ERROR::What(), and SCH_BASE_FRAME::Zoom_Automatique().

Referenced by OnAppendProject(), and SetPrintSheetReference().

381 {
382  wxString msg;
383  wxString fullFileName;
384  SCH_SCREEN* screen = GetScreen();
385 
386  if( !screen )
387  {
388  wxLogError( wxT( "Document not ready, cannot import" ) );
389  return false;
390  }
391 
392  // open file chooser dialog
393  wxString path = wxPathOnly( Prj().GetProjectFullName() );
394 
395  wxFileDialog dlg( this, _( "Append Schematic" ), path, wxEmptyString,
396  SchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
397 
398  if( dlg.ShowModal() == wxID_CANCEL )
399  return false;
400 
401  fullFileName = dlg.GetPath();
402 
403  wxFileName fn = fullFileName;
404 
405  if( fn.IsRelative() )
406  {
407  fn.MakeAbsolute();
408  fullFileName = fn.GetFullPath();
409  }
410 
411  wxString cache_name = PART_LIBS::CacheName( fullFileName );
412 
413  if( !!cache_name )
414  {
415  PART_LIBS* libs = Prj().SchLibs();
416 
417  try
418  {
419  if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
420  lib->SetCache();
421  }
422  catch( const IO_ERROR& ioe )
423  {
424  DisplayError( this, ioe.What() );
425  }
426  }
427 
428  wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
429 
430  // Load the schematic into a temporary sheet.
431  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
432  std::unique_ptr< SCH_SHEET> newSheet( new SCH_SHEET );
433 
434  newSheet->SetFileName( fullFileName );
435 
436  try
437  {
438  pi->Load( fullFileName, &Kiway(), newSheet.get() );
439 
440  if( !pi->GetError().IsEmpty() )
441  {
442  DisplayErrorMessage( this,
443  _( "The entire schematic could not be loaded. Errors "
444  "occurred attempting to load hierarchical sheet "
445  "schematics." ),
446  pi->GetError() );
447  }
448  }
449  catch( const IO_ERROR& ioe )
450  {
451  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), fullFileName );
452  DisplayErrorMessage( this, msg, ioe.What() );
453 
454  msg.Printf( _( "Failed to load schematic \"%s\"" ), fullFileName );
455  AppendMsgPanel( wxEmptyString, msg, CYAN );
456 
457  return false;
458  }
459 
460  // Make sure any new sheet changes do not cause any recursion issues.
461  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy.
462  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the import.
463 
464  wxFileName destFile = screen->GetFileName();
465 
466  if( destFile.IsRelative() )
467  destFile.MakeAbsolute( Prj().GetProjectPath() );
468 
469  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath( wxPATH_UNIX ) ) )
470  {
471  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
472  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
473  "the schematic hierarchy." ),
474  destFile.GetFullPath() );
475  DisplayError( this, msg );
476  return false;
477  }
478 
479  wxArrayString names;
480 
481  // Make sure the imported schematic has been remapped to the symbol library table.
482  SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
483 
484  if( newScreens.HasNoFullyDefinedLibIds() )
485  {
486  DisplayInfoMessage( this,
487  "This schematic has not been remapped to the symbol library\n"
488  "table. The project this schematic belongs to must first be\n"
489  "remapped before it can be imported into the current project." );
490  return false;
491  }
492  else
493  {
494  // If there are symbol libraries in the imported schematic that are not in the
495  // symbol library table of this project, there could be a lot of broken symbol
496  // library links. Attempt to add the missing libraries to the project symbol
497  // library table.
498  newScreens.GetLibNicknames( names );
499  wxArrayString newLibNames;
500 
501  for( const auto& name : names )
502  {
503  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
504  newLibNames.Add( name );
505  }
506 
507  wxFileName symLibTableFn( fn.GetPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
508 
509  if( !newLibNames.IsEmpty() && symLibTableFn.Exists() && symLibTableFn.IsFileReadable() )
510  {
511  SYMBOL_LIB_TABLE table;
512 
513  try
514  {
515  table.Load( symLibTableFn.GetFullPath() );
516  }
517  catch( const IO_ERROR& ioe )
518  {
519  msg.Printf( _( "An error occurred loading the symbol library table \"%s\"." ),
520  symLibTableFn.GetFullPath() );
521  DisplayErrorMessage( NULL, msg, ioe.What() );
522  }
523 
524  if( !table.IsEmpty() )
525  {
526  for( const auto& libName : newLibNames )
527  {
528  if( !table.HasLibrary( libName ) )
529  continue;
530 
531  // Don't expand environment variable because KIPRJMOD will not be correct
532  // for a different project.
533  wxString uri = table.GetFullURI( libName, false );
534  wxFileName newLib;
535 
536  if( uri.Contains( "${KIPRJMOD}" ) )
537  {
538  newLib.SetPath( fn.GetPath() );
539  newLib.SetFullName( uri.AfterLast( '}' ) );
540  uri = newLib.GetFullPath();
541  }
542  else if( uri.Contains( "$(KIPRJMOD)" ) )
543  {
544  newLib.SetPath( fn.GetPath() );
545  newLib.SetFullName( uri.AfterLast( ')' ) );
546  uri = newLib.GetFullPath();
547  }
548  else
549  {
550  uri = table.GetFullURI( libName );
551  }
552 
553  // Add the library from the imported project to the current project
554  // symbol library table.
555  const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
556 
557  wxCHECK2_MSG( row, continue, "Library '" + libName +
558  "' missing from symbol library table '" +
559  symLibTableFn.GetFullPath() + "'." );
560 
561  wxString newLibName = libName;
562  int libNameCnt = 1;
563 
564  // Rename the imported symbol library if it already exists.
565  while( Prj().SchSymbolLibTable()->HasLibrary( newLibName ) )
566  newLibName = wxString::Format( "%s%d", libName, libNameCnt );
567 
568  auto newRow = new SYMBOL_LIB_TABLE_ROW( newLibName, uri, row->GetType(),
569  row->GetOptions(), row->GetDescr() );
570  Prj().SchSymbolLibTable()->InsertRow( newRow );
571 
572  if( libName != newLibName )
573  newScreens.ChangeSymbolLibNickname( libName, newLibName );
574  }
575  }
576  }
577  }
578 
579  // Check for duplicate sheet names in the current page.
580  wxArrayString duplicateSheetNames;
581  SCH_TYPE_COLLECTOR sheets;
582 
583  sheets.Collect( screen->GetDrawItems(), SCH_COLLECTOR::SheetsOnly );
584 
585  for( int i = 0; i < sheets.GetCount(); ++i )
586  {
587  if( newSheet->GetScreen()->GetSheet( ( ( SCH_SHEET* ) sheets[i] )->GetName() ) )
588  duplicateSheetNames.Add( ( ( SCH_SHEET* ) sheets[i] )->GetName() );
589  }
590 
591  if( !duplicateSheetNames.IsEmpty() )
592  {
593  msg.Printf( "Duplicate sheet names exist on the current page. Do you want to "
594  "automatically rename the duplicate sheet names?" );
595  if( !IsOK( this, msg ) )
596  return false;
597  }
598 
599  SCH_SCREEN* newScreen = newSheet->GetScreen();
600  wxCHECK_MSG( newScreen, false, "No screen defined for imported sheet." );
601 
602  for( const auto& duplicateName : duplicateSheetNames )
603  {
604  SCH_SHEET* renamedSheet = newScreen->GetSheet( duplicateName );
605 
606  wxCHECK2_MSG( renamedSheet, continue,
607  "Sheet " + duplicateName + " not found in imported schematic." );
608 
609  timestamp_t newtimestamp = GetNewTimeStamp();
610  renamedSheet->SetTimeStamp( newtimestamp );
611  renamedSheet->SetName( wxString::Format( "Sheet%8.8lX", (unsigned long) newtimestamp ) );
612  }
613 
614  // It is finally safe to add the imported schematic.
615  screen->Append( newScreen );
616 
617  SCH_SCREENS allScreens;
618  allScreens.ReplaceDuplicateTimeStamps();
619 
620  SCH_SCREENS screens( GetCurrentSheet().Last() );
621  screens.UpdateSymbolLinks( true );
622 
623  // Clear all annotation in the imported schematic to prevent clashes with existing annotation.
624  // Must be done after updating the symbol links as we need to know about multi-unit parts.
625  screens.ClearAnnotation();
626 
628  Zoom_Automatique( false );
630 
631  SyncView();
632  HardRedraw(); // Full reinit of the current screen and the display.
633  OnModify();
634 
635  return true;
636 }
Class SCH_SHEET_LIST.
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
static const wxString & GetSymbolLibTableFileName()
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
virtual void Zoom_Automatique(bool aWarpPointer) override
Redraw the screen with best zoom level and the best centering that shows all the page or the board...
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
Class TYPE_COLLECTOR merely gathers up all SCH_ITEMs of a given set of KICAD_T type(s).
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
wxString SchematicFileWildcard()
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:52
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
SCH_SHEET * GetSheet(const wxString &aName)
Returns a sheet object pointer that is named aName.
Definition: sch_screen.cpp:624
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
const wxString & GetFileName() const
Definition: sch_screen.h:131
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
static const wxString CacheName(const wxString &aFullProjectFilename)
Return the name of the cache library after potentially fixing it from an older naming scheme...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
void SetName(const wxString &aName)
Definition: sch_sheet.h:269
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SyncView()
Mark all items for refresh.
const wxString GetType() const override
Return the type of symbol library table represented by this row.
SCH_SHEET_PATH & GetCurrentSheet()
PART_LIB * AddLibrary(const wxString &aFileName)
Allocate and adds a part library to the library list.
Definition: colors.h:59
int m_LastGridSizeId
Definition: draw_frame.h:107
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
const wxString & GetDescr() const
Return the description of the library referenced by this row.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
A collection of PART_LIB objects.
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:523
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:160
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
const char * name
Definition: DXF_plotter.cpp:61
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.h:162
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
size_t i
Definition: json11.cpp:597
void Collect(SCH_ITEM *aBoard, const KICAD_T aScanList[])
Function Collect scans a BOARD_ITEM using this class&#39;s Inspector method, which does the collection...
static const KICAD_T SheetsOnly[]
A scan list for schematic sheet items only.
int ReplaceDuplicateTimeStamps()
Test all sheet and component objects in the schematic for duplicate time stamps and replaces them as ...
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:277
Object used to load, save, search, and otherwise manipulate symbol library files. ...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
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)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:295
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
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 895 of file eeschema/files-io.cpp.

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

Referenced by OnImportProject(), OpenProjectFiles(), and SetPrintSheetReference().

896 {
897  SCH_SCREENS screenList;
898 
899  // Save any currently open and modified project files.
900  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
901  {
902  if( screen->IsModify() )
903  {
904  if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. Save changes?" ),
905  [&]()->bool { return SaveProject(); } ) )
906  {
907  return false;
908  }
909  }
910  }
911 
912  return true;
913 }
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons...
Definition: confirm.cpp:213
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
void SCH_EDIT_FRAME::backAnnotateFootprints ( const std::string &  aChangedSetOfReferences)
protected

Definition at line 51 of file backanno.cpp.

References FOOTPRINT, Format(), FROM_UTF8(), g_RootSheet, SCH_BASE_FRAME::GetCanvas(), SCH_SHEET_LIST::GetComponents(), SCH_REFERENCE_LIST::GetCount(), SCH_COMPONENT::GetField(), STRING_FORMATTER::GetString(), EDA_TEXT::GetText(), EDA_TEXT::IsVisible(), OnModify(), SCH_DRAW_PANEL::Refresh(), Scan(), EDA_TEXT::SetText(), EDA_TEXT::SetVisible(), SCH_BASE_FRAME::SyncView(), and THROW_IO_ERROR.

Referenced by KiwayMailIn().

52 {
53  // Build a flat list of components in schematic:
54  SCH_REFERENCE_LIST refs;
55  SCH_SHEET_LIST sheets( g_RootSheet );
56  bool isChanged = false;
57 
58  sheets.GetComponents( refs, false );
59 
60  DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
61  PTREE doc;
62 
63  try
64  {
65  Scan( &doc, &lexer );
66 
67 #if defined(DEBUG) && 0
69  Format( &sf, 0, 0, doc );
70  printf( "%s: '%s'\n", __func__, sf.GetString().c_str() );
71 #endif
72 
73  CPTREE& back_anno = doc.get_child( "back_annotation" );
74  wxString footprint;
75 
76  for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
77  {
78  wxASSERT( ref->first == "ref" );
79 
80  wxString reference = (UTF8&) ref->second.front().first;
81 
82  // Ensure the "fpid" node contains a footprint name,
83  // and get it if exists
84  if( ref->second.get_child( "fpid" ).size() )
85  {
86  wxString tmp = (UTF8&) ref->second.get_child( "fpid" ).front().first;
87  footprint = tmp;
88  }
89  else
90  footprint.Empty();
91 
92  // Search the component in the flat list
93  for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
94  {
95  if( reference == refs[ii].GetRef() )
96  {
97  // We have found a candidate.
98  // Note: it can be not unique (multiple parts per package)
99  // So we *do not* stop the search here
100  SCH_COMPONENT* component = refs[ii].GetComp();
101  SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
102  const wxString& oldfp = fpfield->GetText();
103 
104  if( !oldfp && fpfield->IsVisible() )
105  {
106  fpfield->SetVisible( false );
107  }
108 
109  if( oldfp != footprint )
110  isChanged = true;
111 
112  fpfield->SetText( footprint );
113  }
114  }
115  }
116  }
117  catch( const PTREE_ERROR& ex )
118  {
119  // remap the exception to something the caller is likely to understand.
120  THROW_IO_ERROR( ex.what() );
121  }
122 
123  if( isChanged )
124  {
125  SyncView();
126  GetCanvas()->Refresh();
127  OnModify();
128  }
129 }
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
Class SCH_SHEET_LIST.
Class SCH_FIELD instances are attached to a component and provide a place for the component&#39;s value...
Definition: sch_field.h:56
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:53
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Function Scan fills an empty PTREE with information from a KiCad s-expresion stream.
Definition: ptree.cpp:90
void SetVisible(bool aVisible)
Definition: eda_text.h:188
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...
Field Name Module PCB, i.e. "16DIP300".
Class SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierar...
boost::property_tree::ptree PTREE
Definition: ptree.h:54
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
const PTREE CPTREE
Definition: ptree.h:55
void SyncView()
Mark all items for refresh.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
SCH_DRAW_PANEL * GetCanvas() const override
#define THROW_IO_ERROR(msg)
const std::string & GetString()
Definition: richio.h:475
boost::property_tree::ptree_error PTREE_ERROR
Definition: ptree.h:56
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
bool IsVisible() const
Definition: eda_text.h:189
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
unsigned GetCount()
Function GetCount.
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
Class DSNLEXER implements a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79
virtual void SetText(const wxString &aText)
Definition: eda_text.h:154
void SCH_EDIT_FRAME::BeginSegment ( int  type)
private

Creates a new segment ( WIRE, BUS ) or terminates the current segment in progress.

If the end of the current segment is on a different segment, place a junction if needed and terminates the command. If the end of the current segment is on a pin, terminate the command. In all other cases starts a new segment.

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

References AbortCreateNewLine(), SCH_LINE::Back(), EDA_DRAW_PANEL::CallMouseCapture(), EDA_ITEM::ClearFlags(), DrawSegment(), EndSegment(), EDA_DRAW_FRAME::GetCrossHairPosition(), SCH_SCREEN::GetCurItem(), EDA_ITEM::GetFlags(), GetForceHVLines(), SCH_ITEM::GetLayer(), GetScreen(), IS_NEW, SCH_LINE::IsNull(), LAYER_BUS, LAYER_NOTES, LAYER_WIRE, EDA_DRAW_FRAME::m_canvas, DLIST< T >::PushBack(), SCH_LINE_T, SELECTED, SCH_SCREEN::SetCurItem(), SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), EDA_DRAW_PANEL::SetMouseCapture(), SetRepeatItem(), SCH_LINE::SetStartPoint(), and EDA_ITEM::Type().

Referenced by OnLeftClick(), and SetPrintSheetReference().

151 {
152  SCH_LINE* segment;
153  SCH_LINE* nextSegment;
154  wxPoint cursorpos = GetCrossHairPosition();
155 
156  // We should know if a segment is currently in progress
157  segment = (SCH_LINE*) GetScreen()->GetCurItem();
158  if( segment ) // a current item exists, but not necessary a currently edited item
159  {
160  if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) )
161  {
162  if( segment->GetFlags() )
163  wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ), segment->GetFlags() );
164 
165  // no wire, bus or graphic line in progress
166  segment = NULL;
167  }
168  }
169 
170  if( !segment ) // first point : Create the first wire or bus segment
171  {
172  switch( type )
173  {
174  default:
175  segment = new SCH_LINE( cursorpos, LAYER_NOTES );
176  break;
177 
178  case LAYER_WIRE:
179  segment = new SCH_LINE( cursorpos, LAYER_WIRE );
180 
181  /* A junction will be created later, when we'll know the
182  * segment end position, and if the junction is really needed */
183  break;
184 
185  case LAYER_BUS:
186  segment = new SCH_LINE( cursorpos, LAYER_BUS );
187  break;
188  }
189 
190  segment->SetFlags( IS_NEW );
191  s_wires.PushBack( segment );
192  GetScreen()->SetCurItem( segment );
193 
194  // We need 2 segments to go from a given start pin to an end point when the horizontal
195  // and vertical lines only switch is on.
196  if( GetForceHVLines() )
197  {
198  nextSegment = new SCH_LINE( *segment );
199  nextSegment->SetFlags( IS_NEW );
200  s_wires.PushBack( nextSegment );
201  GetScreen()->SetCurItem( nextSegment );
202  }
203 
205  SetRepeatItem( NULL );
206  }
207  else // A segment is in progress: terminates the current segment and add a new segment.
208  {
209  SCH_LINE* prevSegment = segment->Back();
210 
211  // Be aware prevSegment can be null when the horizontal and vertical lines only switch is off
212  // when we create the first segment.
213 
214  if( !GetForceHVLines() )
215  {
216  // If only one segment is needed and it has a zero length, do not create a new one.
217  if( segment->IsNull() )
218  return;
219  }
220  else
221  {
222  wxCHECK_RET( prevSegment != NULL, wxT( "Failed to create second line segment." ) );
223 
224  // If two segments are required and they both have zero length, do not
225  // create a new one.
226  if( prevSegment && prevSegment->IsNull() && segment->IsNull() )
227  return;
228  }
229 
230  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
231 
232  // Terminate the command if the end point is on a pin, junction, or another wire or bus.
233  if( GetScreen()->IsTerminalPoint( cursorpos, segment->GetLayer() ) )
234  {
235  EndSegment();
236  return;
237  }
238 
239  // Create a new segment, and chain it after the current new segment.
240  nextSegment = new SCH_LINE( *segment );
241  nextSegment->SetStartPoint( cursorpos );
242  s_wires.PushBack( nextSegment );
243 
244  segment->SetEndPoint( cursorpos );
245  segment->ClearFlags( IS_NEW );
246  segment->SetFlags( SELECTED );
247  nextSegment->SetFlags( IS_NEW );
248  GetScreen()->SetCurItem( nextSegment );
249  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
250  }
251 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
bool GetForceHVLines() const
static void DrawSegment(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Mouse capture callback for drawing line segments.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
void EndSegment()
Terminate a bus, wire, or line creation.
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:82
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define SELECTED
Definition: base_struct.h:121
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:78
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
bool IsNull() const
Definition: sch_line.h:74
static void AbortCreateNewLine(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
SCH_LINE * Back() const
Definition: sch_line.h:62
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
static DLIST< SCH_ITEM > s_wires
double EDA_DRAW_FRAME::bestZoom ( double  sizeX,
double  sizeY,
double  scaleFactor,
wxPoint  centre 
)
protectedinherited
double SCH_EDIT_FRAME::BestZoom ( )
overridevirtual

Return the zoom level which displays the full page on screen.

Implements EDA_DRAW_FRAME.

Definition at line 715 of file sch_edit_frame.cpp.

Referenced by DeleteAllTemplateFieldNames().

716 {
717  double sizeX = (double) GetScreen()->GetPageSettings().GetWidthIU();
718  double sizeY = (double) GetScreen()->GetPageSettings().GetHeightIU();
719  wxPoint centre( wxPoint( sizeX / 2, sizeY / 2 ) );
720 
721  // The sheet boundary already affords us some margin, so add only an
722  // additional 5%.
723  double margin_scale_factor = 1.05;
724 
725  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
726 }
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:126
int SCH_EDIT_FRAME::BlockCommand ( EDA_KEY  aKey)
overridevirtual

Return the block command internal code (BLOCK_MOVE, BLOCK_DUPLICATE...) corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when block command is started by dragging the mouse.

Parameters
aKey= the key modifiers (Alt, Shift ...)
Returns
the block command id (BLOCK_MOVE, BLOCK_DUPLICATE...)

Reimplemented from EDA_DRAW_FRAME.

Definition at line 59 of file eeschema/block.cpp.

References BLOCK_DELETE, BLOCK_DRAG, BLOCK_DUPLICATE, BLOCK_IDLE, BLOCK_MOVE, BLOCK_ZOOM, GR_KB_CTRL, GR_KB_SHIFT, GR_KB_SHIFTCTRL, and MOUSE_MIDDLE.

Referenced by GetLabelIncrement().

60 {
61  int cmd = BLOCK_IDLE;
62 
63  switch( key )
64  {
65  default:
66  cmd = key & 0xFF;
67  break;
68 
69  case 0:
70  cmd = BLOCK_MOVE;
71  break;
72 
73  case GR_KB_SHIFT:
74  cmd = BLOCK_DUPLICATE;
75  break;
76 
77  case GR_KB_CTRL:
78  cmd = BLOCK_DRAG;
79  break;
80 
81  case GR_KB_SHIFTCTRL:
82  cmd = BLOCK_DELETE;
83  break;
84 
85  case MOUSE_MIDDLE:
86  cmd = BLOCK_ZOOM;
87  break;
88  }
89 
90  return cmd;
91 }
#define MOUSE_MIDDLE
#define GR_KB_CTRL
#define GR_KB_SHIFT
#define GR_KB_SHIFTCTRL
bool SCH_EDIT_FRAME::BreakSegment ( SCH_LINE aSegment,
const wxPoint aPoint,
bool  aAppend = false,
SCH_LINE **  aNewSegment = NULL 
)

Breaks a single segment into two at the specified point.

Parameters
aSegmentLine segment to break
aPointPoint at which to break the segment
aAppendAdd the changes to the previous undo state
aNewSegmentPointer to the newly created segment (if given and created)
Returns
True if any wires or buses were broken.

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

References SCH_BASE_FRAME::AddToScreen(), SCH_LINE::GetEndPoint(), 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(), DeleteAllTemplateFieldNames(), and TrimWire().

665 {
666  if( !IsPointOnSegment( aSegment->GetStartPoint(), aSegment->GetEndPoint(), aPoint )
667  || aSegment->IsEndPoint( aPoint ) )
668  return false;
669 
670  SaveCopyInUndoList( aSegment, UR_CHANGED, aAppend );
671  SCH_LINE* newSegment = new SCH_LINE( *aSegment );
672  SaveCopyInUndoList( newSegment, UR_NEW, true );
673 
674  newSegment->SetStartPoint( aPoint );
675  AddToScreen( newSegment );
676 
677  RefreshItem( aSegment );
678  aSegment->SetEndPoint( aPoint );
679 
680  if( aNewSegment )
681  *aNewSegment = newSegment;
682 
683  return true;
684 }
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
wxPoint GetEndPoint() const
Definition: sch_line.h:80
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:82
wxPoint GetStartPoint() const
Definition: sch_line.h:76
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:78
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 AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:69
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
bool SCH_EDIT_FRAME::BreakSegments ( const wxPoint aPoint,
bool  aAppend = false 
)

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

Parameters
aPointTest this point for an intersection.
aAppendAdd the changes to the previous undo state
Returns
True if any wires or buses were broken.

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

References BreakSegment(), GetScreen(), LAYER_NOTES, EDA_ITEM::Next(), and SCH_LINE_T.

Referenced by AddJunction(), BreakSegmentsOnJunctions(), DeleteAllTemplateFieldNames(), and Process_Special_Functions().

688 {
689  bool brokenSegments = false;
690 
691  for( SCH_ITEM* segment = GetScreen()->GetDrawItems(); segment; segment = segment->Next() )
692  {
693  if( ( segment->Type() != SCH_LINE_T ) || ( segment->GetLayer() == LAYER_NOTES ) )
694  continue;
695 
696  brokenSegments |= BreakSegment( (SCH_LINE*) segment, aPoint, aAppend || brokenSegments );
697  }
698 
699  return brokenSegments;
700 }
EDA_ITEM * Next() const
Definition: base_struct.h:209
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
bool BreakSegment(SCH_LINE *aSegment, const wxPoint &aPoint, bool aAppend=false, SCH_LINE **aNewSegment=NULL)
Breaks a single segment into two at the specified point.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool SCH_EDIT_FRAME::BreakSegmentsOnJunctions ( bool  aApped = false)

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

Parameters
aAppendAdd the changes to the previous undo state
Returns
True if any wires or buses were broken.

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

References BreakSegments(), SCH_JUNCTION::GetPosition(), SCH_BUS_ENTRY_BASE::GetPosition(), GetScreen(), SCH_BUS_ENTRY_BASE::m_End(), EDA_ITEM::Next(), and SCH_JUNCTION_T.

Referenced by DeleteAllTemplateFieldNames(), importFile(), OpenProjectFiles(), and SchematicCleanUp().

704 {
705  bool brokenSegments = false;
706 
707  for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
708  {
709  if( item->Type() == SCH_JUNCTION_T )
710  {
711  SCH_JUNCTION* junction = ( SCH_JUNCTION* ) item;
712 
713  if( BreakSegments( junction->GetPosition(), brokenSegments || aAppend ) )
714  brokenSegments = true;
715  }
716  else
717  {
718  SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( item );
719  if( busEntry )
720  {
721  if( BreakSegments( busEntry->GetPosition(), brokenSegments || aAppend )
722  || BreakSegments( busEntry->m_End(), brokenSegments || aAppend ) )
723  brokenSegments = true;
724  }
725  }
726  }
727 
728  return brokenSegments;
729 }
bool BreakSegments(const wxPoint &aPoint, bool aAppend=false)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
wxPoint m_End() const
EDA_ITEM * Next() const
Definition: base_struct.h:209
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:103
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
wxPoint GetPosition() const override
Function GetPosition.
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 236 of file netlist_generator.cpp.

References Format(), and g_RootSheet.

Referenced by CreateNetlist(), DeleteAllTemplateFieldNames(), HighlightConnectionAtPosition(), OnLeftClick(), sendNetlist(), SetCurrentSheetHighlightFlags(), DIALOG_ERC::TestErc(), and SIM_PLOT_FRAME::updateNetlistExporter().

237 {
238  // I own this list until I return it to the new owner.
239  std::unique_ptr<NETLIST_OBJECT_LIST> ret( new NETLIST_OBJECT_LIST() );
240 
241  // Creates the flattened sheet list:
242  SCH_SHEET_LIST aSheets( g_RootSheet );
243 
244  // Build netlist info
245  bool success = ret->BuildNetListInfo( aSheets );
246 
247  if( !success )
248  {
249  if( updateStatusText )
250  SetStatusText( _( "No Objects" ) );
251  return ret.release();
252  }
253 
254  wxString msg = wxString::Format( _( "Net count = %d" ), int( ret->size() ) );
255 
256  if( updateStatusText )
257  SetStatusText( msg );
258 
259  return ret.release();
260 }
Class SCH_SHEET_LIST.
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
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 SCH_BASE_FRAME::CenterScreen ( const wxPoint aCenterPoint,
bool  aWarpPointer 
)
virtualinherited

Definition at line 467 of file sch_base_frame.cpp.

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

Referenced by FindComponentAndItem(), OnFindDrcMarker(), and updateFindReplaceView().

468 {
469  GetCanvas()->GetView()->SetCenter( aCenterPoint );
470 
471  if( aWarpPointer )
472  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
473 
474  GetGalCanvas()->Refresh();
475 }
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:599
SCH_DRAW_PANEL * GetCanvas() const override
KIGFX::SCH_VIEW * GetView() const
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...
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:921
void SCH_EDIT_FRAME::ChangeTextOrient ( SCH_TEXT aTextItem)
private

Definition at line 50 of file edit_label.cpp.

References SCH_TEXT::CanIncrementLabel(), EDA_ITEM::GetFlags(), SCH_TEXT::GetLabelSpinStyle(), OnModify(), SCH_BASE_FRAME::RefreshItem(), SaveCopyInUndoList(), SCH_TEXT::SetLabelSpinStyle(), and UR_CHANGED.

Referenced by OnRotate(), and SetPrintSheetReference().

51 {
52  wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(),
53  wxT( "Invalid schematic text item." ) );
54 
55  int orient = ( aTextItem->GetLabelSpinStyle() + 1 ) & 3;
56 
57  // Save current text orientation in undo list if is not already in edit.
58  if( aTextItem->GetFlags() == 0 )
59  SaveCopyInUndoList( aTextItem, UR_CHANGED );
60 
61  aTextItem->SetLabelSpinStyle( orient );
62 
63  RefreshItem( aTextItem );
64  OnModify();
65 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
virtual bool CanIncrementLabel() const override
Definition: sch_text.h:185
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
virtual void SetLabelSpinStyle(int aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:240
int GetLabelSpinStyle() const
Definition: sch_text.h:116
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 RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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 annotate.cpp.

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

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

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  m_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...
Class SCH_SHEET_LIST.
Class SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierar...
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
int CheckAnnotation(REPORTER &aReporter)
Function CheckAnnotation check for annotations errors.
void EDA_BASE_FRAME::CheckForAutoSaveFile ( const wxFileName &  aFileName,
const wxString &  aBackupFileExtension 
)
inherited

Function CheckForAutoSaveFile checks 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.
aBackupFileExtensionA wxString object containing the backup file extension used to create the backup file name.

Definition at line 585 of file eda_base_frame.cpp.

References AUTOSAVE_PREFIX_FILENAME, Format(), GetChars(), Pgm(), and traceAutoSave.

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

587 {
588  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
589  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
590 
591  wxFileName autoSaveFileName = aFileName;
592 
593  // Check for auto save file.
594  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
595 
596  wxLogTrace( traceAutoSave,
597  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
598 
599  if( !autoSaveFileName.FileExists() )
600  return;
601 
602  wxString msg = wxString::Format( _(
603  "Well this is potentially embarrassing!\n"
604  "It appears that the last time you were editing the file\n"
605  "\"%s\"\n"
606  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
607  GetChars( aFileName.GetFullName() )
608  );
609 
610  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
611 
612  // Make a backup of the current file, delete the file, and rename the auto save file to
613  // the file name.
614  if( response == wxYES )
615  {
616  // Get the backup file name.
617  wxFileName backupFileName = aFileName;
618  backupFileName.SetExt( aBackupFileExtension );
619 
620  // If an old backup file exists, delete it. If an old copy of the file exists, rename
621  // it to the backup file name
622  if( aFileName.FileExists() )
623  {
624  // Remove the old file backup file.
625  if( backupFileName.FileExists() )
626  wxRemoveFile( backupFileName.GetFullPath() );
627 
628  // Rename the old file to the backup file name.
629  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
630  {
631  msg.Printf( _( "Could not create backup file \"%s\"" ),
632  GetChars( backupFileName.GetFullPath() ) );
633  wxMessageBox( msg );
634  }
635  }
636 
637  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
638  {
639  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
640  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
641  }
642  }
643  else
644  {
645  wxLogTrace( traceAutoSave,
646  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
647 
648  // Remove the auto save file when using the previous file as is.
649  wxRemoveFile( autoSaveFileName.GetFullPath() );
650  }
651 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
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:92
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 SCH_EDIT_FRAME::CheckListConnections ( PICKED_ITEMS_LIST aItemsList,
bool  aAppend = false 
)

Adds junctions if needed to each item in the list after they have been moved.

Parameters
aItemsListThe list of items to check
aAppendTrue if we are updating a previous commit

Definition at line 108 of file operations_on_items_lists.cpp.

References AddJunction(), SCH_ITEM::GetConnectionPoints(), PICKED_ITEMS_LIST::GetCount(), SCH_LINE::GetEndPoint(), PICKED_ITEMS_LIST::GetPickedItem(), GetSchematicConnections(), GetScreen(), SCH_LINE::GetStartPoint(), i, SCH_ITEM::IsConnectable(), SCH_SCREEN::IsJunctionNeeded(), IsPointOnSegment(), SCH_LINE_T, TrimWire(), EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by GetLastSheetPinPosition(), and HandleBlockPlace().

109 {
110  std::vector< wxPoint > pts;
111  std::vector< wxPoint > connections;
112 
113  GetSchematicConnections( connections );
114  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
115  {
116  SCH_ITEM* item = static_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
117  std::vector< wxPoint > new_pts;
118 
119  if( !item->IsConnectable() )
120  continue;
121 
122  item->GetConnectionPoints( new_pts );
123  pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
124 
125  // If the item is a line, we also add any connection points from the rest of the schematic
126  // that terminate on the line after it is moved.
127  if( item->Type() == SCH_LINE_T )
128  {
129  SCH_LINE* line = (SCH_LINE*) item;
130  for( auto i : connections )
131  if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
132  pts.push_back( i );
133  }
134  else
135  {
136  // Clean up any wires that short non-wire connections in the list
137  for( auto point = new_pts.begin(); point != new_pts.end(); point++ )
138  {
139  for( auto second_point = point + 1; second_point != new_pts.end(); second_point++ )
140  {
141  aAppend |= TrimWire( *point, *second_point, aAppend );
142  }
143  }
144  }
145  }
146 
147  // We always have some overlapping connection points. Drop duplicates here
148  std::sort( pts.begin(), pts.end(),
149  []( const wxPoint& a, const wxPoint& b ) -> bool
150  { return a.x < b.x || (a.x == b.x && a.y < b.y); } );
151  pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
152 
153  for( auto point : pts )
154  {
155  if( GetScreen()->IsJunctionNeeded( point, true ) )
156  {
157  AddJunction( point, aAppend );
158  aAppend = true;
159  }
160  }
161 }
SCH_JUNCTION * AddJunction(const wxPoint &aPosition, bool aPutInUndoList=false)
Add a new junction at aPosition.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
void GetSchematicConnections(std::vector< wxPoint > &aConnections)
Collects a unique list of all possible connection points in the schematic.
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:325
wxPoint GetEndPoint() const
Definition: sch_line.h:80
wxPoint GetStartPoint() const
Definition: sch_line.h:76
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
unsigned GetCount() const
Function GetCount.
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
size_t i
Definition: json11.cpp:597
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd, bool aAppend=true)
If any single wire passes through both points, remove the portion between the two points...
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
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 1458 of file sch_edit_frame.h.

1458 { m_exec_flags &= ~( aFlags ); }
int m_exec_flags
Flags of the wxExecute() function to call a custom net list generator.
void SCH_EDIT_FRAME::CloseErc ( )
private

Close the ERC dialog if it is open.

Definition at line 841 of file sch_edit_frame.cpp.

References ID_DIALOG_ERC.

Referenced by OnLeftClick(), and SetPrintSheetReference().

842 {
843  // Find the ERC dialog if it's open and close it
844  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
845 
846  if( erc )
847  erc->Close( false );
848 }
eeschema ERC modeless dialog ID
Definition: id.h:284
void SCH_EDIT_FRAME::CommonSettingsChanged ( )
overridevirtual

Called after the preferences dialog is run.

Reimplemented from EDA_BASE_FRAME.

Definition at line 1505 of file sch_edit_frame.cpp.

References EDA_DRAW_FRAME::CommonSettingsChanged().

Referenced by GetNetListerCommand().

1506 {
1508 
1509  ReCreateHToolbar();
1510  ReCreateVToolbar();
1512  Layout();
1513  SendSizeEvent();
1514 }
void ReCreateOptToolbar()
Definition: tool_sch.cpp:279
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
void ReCreateHToolbar() override
Definition: tool_sch.cpp:46
void ReCreateVToolbar() override
Definition: tool_sch.cpp:191
wxConfigBase * EDA_BASE_FRAME::config ( )
protectedvirtualinherited

Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 360 of file eda_base_frame.cpp.

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

Referenced by CVPCB_MAINFRAME::CVPCB_MAINFRAME(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), EDA_BASE_FRAME::isAutoSaveRequired(), SIM_PLOT_FRAME::onClose(), FOOTPRINT_WIZARD_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnPreferencesOptions(), OnPreferencesOptions(), OpenProjectFiles(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and EDA_BASE_FRAME::windowClosing().

361 {
362  // KICAD_MANAGER_FRAME overrides this
363  wxConfigBase* ret = Kiface().KifaceSettings();
364  //wxASSERT( ret );
365  return ret;
366 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited

Function ConfigBaseName.

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, unless m_configFrameName contains a base name. this is the case of frames which can be shown in normal or modal mode. This is needed because we want only one base name prefix, regardless the mode used.

Definition at line 269 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_configFrameName.

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(), and EDA_DRAW_FRAME::SaveSettings().

270  {
271  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
272  return baseCfgName;
273  }
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
void SCH_EDIT_FRAME::ConvertPart ( SCH_COMPONENT DrawComponent)
private

Definition at line 371 of file getpart.cpp.

References EDA_ITEM::ClearFlags(), DisplayError(), SCH_COMPONENT::GetConvert(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetLibId(), SCH_BASE_FRAME::GetLibPart(), LIB_PART::HasConversion(), SCH_BASE_FRAME::RefreshItem(), SCH_COMPONENT::SetConvert(), and EDA_ITEM::SetFlags().

Referenced by GetLabelIncrement(), and Process_Special_Functions().

372 {
373  if( !aComponent )
374  return;
375 
376  LIB_ID id = aComponent->GetLibId();
377  LIB_PART* part = GetLibPart( id );
378 
379  if( part )
380  {
381  wxString msg;
382 
383  if( !part->HasConversion() )
384  {
385  msg.Printf( _( "No alternate body style found for symbol \"%s\" in library \"%s\"." ),
386  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
387  DisplayError( this, msg );
388  return;
389  }
390 
391  STATUS_FLAGS flags = aComponent->GetFlags();
392 
393  aComponent->SetConvert( aComponent->GetConvert() + 1 );
394 
395  // ensure m_Convert = 0, 1 or 2
396  // 0 and 1 = shape 1 = not converted
397  // 2 = shape 2 = first converted shape
398  // > 2 is not used but could be used for more shapes
399  // like multiple shapes for a programmable component
400  // When m_Convert = val max, return to the first shape
401  if( aComponent->GetConvert() > 2 )
402  aComponent->SetConvert( 1 );
403 
404  // The alternate symbol may cause a change in the connection status so test the
405  // connections so the connection indicators are drawn correctly.
407  aComponent->ClearFlags();
408  aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
409 
410  RefreshItem( aComponent );
411  OnModify();
412  }
413 }
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
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
Define a library symbol object.
unsigned STATUS_FLAGS
Definition: base_struct.h:147
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
void SCH_EDIT_FRAME::copyBlockItems ( PICKED_ITEMS_LIST aItemsList,
const wxPoint aMoveVector 
)
private

Copy the list of block item.

See also
m_blockItems
Parameters
aItemsListList to copy the block select items into.

Definition at line 397 of file eeschema/block.cpp.

References EDA_ITEM::ClearFlags(), BLOCK_SELECTOR::ClearListAndDeleteItems(), DuplicateStruct(), EDA_ITEM::GetBoundingBox(), PICKED_ITEMS_LIST::GetCount(), EDA_ITEM::GetFlags(), EDA_DRAW_FRAME::GetNearestGridPosition(), PICKED_ITEMS_LIST::GetPickedItem(), i, m_blockItems, SCH_ITEM::Move(), BLOCK_SELECTOR::PushItem(), EDA_ITEM::SetFlags(), EDA_ITEM::SetParent(), UR_NEW, and UR_TRANSIENT.

Referenced by GetLabelIncrement(), and HandleBlockEnd().

398 {
399  m_blockItems.ClearListAndDeleteItems(); // delete previous saved list, if exists
400 
401  wxRect bounds;
402 
403  if( aItemsList.GetCount() > 0 )
404  bounds = aItemsList.GetPickedItem( 0 )->GetBoundingBox();
405 
406  for( unsigned i = 1; i < aItemsList.GetCount(); ++i )
407  bounds.Union( aItemsList.GetPickedItem( i )->GetBoundingBox() );
408 
409  wxPoint center( ( bounds.GetLeft() + bounds.GetRight() ) / 2,
410  ( bounds.GetTop() + bounds.GetBottom() ) / 2 );
411  center = GetNearestGridPosition( center );
412 
413  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
414  {
415  // Clear m_Flag member of selected items:
416  aItemsList.GetPickedItem( ii )->ClearFlags();
417 
418  /* Make a copy of the original picked item. */
419  SCH_ITEM* copy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
420  copy->SetParent( NULL );
421  copy->SetFlags( copy->GetFlags() | UR_TRANSIENT );
422  copy->Move( -center );
423  ITEM_PICKER item( copy, UR_NEW );
424 
425  m_blockItems.PushItem( item );
426  }
427 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed b...
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
SCH_ITEM * DuplicateStruct(SCH_ITEM *aDrawStruct, bool aClone=false)
Routine to create a new copy of given struct.
unsigned GetCount() const
Function GetCount.
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
BLOCK_SELECTOR m_blockItems
List of selected items.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
size_t i
Definition: json11.cpp:597
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Definition: base_struct.h:142
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void PushItem(ITEM_PICKER &aItem)
Function PushItem adds aItem to the list of items.
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.
void EDA_DRAW_FRAME::CopyToClipboard ( wxCommandEvent &  event)
inherited

Copy the current page or the current block to the clipboard.

Definition at line 1637 of file legacy_gal/eda_draw_frame.cpp.

References DrawPageOnClipboard(), EDA_DRAW_PANEL::EndMouseCapture(), ID_GEN_COPY_BLOCK_TO_CLIPBOARD, and EDA_DRAW_FRAME::m_canvas.

Referenced by add_search_paths(), and findDialog().

1638 {
1639  DrawPageOnClipboard( this );
1640 
1641  if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
1642  {
1643  // fixme-gal
1644  //if( GetScreen()->IsBlockActive() )
1645  //m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
1646 
1648  }
1649 }
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
static bool DrawPageOnClipboard(EDA_DRAW_FRAME *aFrame)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
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.

References DisplayErrorMessage(), SCH_SCREENS::GetFirst(), SCH_COMPONENT::GetLibId(), SCH_BASE_FRAME::GetLibPart(), LIB_PART::GetName(), SCH_SCREENS::GetNext(), LIB_ID::GetUniStringLibId(), LIB_ID::GetUniStringLibItemName(), LIBRARY_TYPE_EESCHEMA, SCH_ITEM::Next(), SCH_COMPONENT_T, LIB_PART::SetName(), and IO_ERROR::What().

Referenced by CreateArchiveLibraryCacheFile(), and GetUndoItem().

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  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
85  {
86  if( item->Type() != SCH_COMPONENT_T )
87  continue;
88 
89  LIB_PART* part = nullptr;
90  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
91 
92  try
93  {
94  if( archLib->FindAlias( component->GetLibId() ) )
95  continue;
96 
97  part = GetLibPart( component->GetLibId(), true );
98  }
99  catch( const IO_ERROR& )
100  {
101  // Queue up error messages for later.
102  tmp.Printf( _( "Failed to add symbol \"%s\" to library file \"%s\"." ),
103  component->GetLibId().GetUniStringLibItemName(), aFileName );
104 
105  // Don't bail out here. Attempt to add as many of the symbols to the library
106  // as possible.
107  }
108  catch( ... )
109  {
110  tmp = _( "Unexpected exception occurred." );
111  }
112 
113  if( part )
114  {
115  // Use the full LIB_ID as the symbol name to prevent symbol name collisions.
116  wxString oldName = part->GetName();
117  part->SetName( component->GetLibId().GetUniStringLibId() );
118 
119  // AddPart() does first clone the part before adding.
120  archLib->AddPart( part );
121  part->SetName( oldName );
122  }
123  else
124  {
125  tmp.Printf( _( "Symbol %s not found in any library or cache." ),
126  component->GetLibId().GetUniStringLibId() );
127  }
128 
129  if( !tmp.empty() )
130  {
131  if( errorMsg.empty() )
132  errorMsg += tmp;
133  else
134  errorMsg += "\n" + tmp;
135  }
136  }
137  }
138 
139  if( !errorMsg.empty() )
140  {
141  tmp.Printf( _( "Errors occurred creating symbol library %s." ), aFileName );
142  DisplayErrorMessage( this, tmp, errorMsg );
143  }
144 
145  archLib->EnableBuffering( false );
146 
147  try
148  {
149  archLib->Save( false );
150  }
151  catch( const IO_ERROR& ioe )
152  {
153  errorMsg.Printf( _( "Failed to save symbol library file \"%s\"" ), aFileName );
154  DisplayErrorMessage( this, errorMsg, ioe.What() );
155  return false;
156  }
157  catch( std::exception& error )
158  {
159  errorMsg.Printf( _( "Failed to save symbol library file \"%s\"" ), aFileName );
160  DisplayErrorMessage( this, errorMsg, error.what() );
161  return false;
162  }
163 
164  return true;
165 }
const wxString GetUniStringLibItemName() const
Definition: lib_id.h:121
SCH_SCREEN * GetNext()
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
SCH_ITEM * Next() const
wxString GetUniStringLibId() const
Definition: lib_id.h:148
Define a library symbol object.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
const LIB_ID & GetLibId() const
const wxString & GetName() const
virtual void SetName(const wxString &aName)
SCH_SCREEN * GetFirst()
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
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
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.

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

Referenced by GetUndoItem(), Save_File(), and SaveProject().

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:131
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
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...
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:523
SCH_BUS_BUS_ENTRY * SCH_EDIT_FRAME::CreateBusBusEntry ( )
private

Definition at line 42 of file busentry.cpp.

References addCurrentItemToScreen(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetScreen(), IS_NEW, s_LastShape, SCH_SCREEN::SetCurItem(), and EDA_ITEM::SetFlags().

Referenced by OnLeftClick(), and SetPrintSheetReference().

43 {
44  // Create and place a new bus entry at cursor position
46 
47  busEntry->SetFlags( IS_NEW );
48  GetScreen()->SetCurItem( busEntry );
50  return busEntry;
51 }
Class for a bus to bus entry.
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
static int s_LastShape
Definition: busentry.cpp:39
void addCurrentItemToScreen()
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
SCH_BUS_WIRE_ENTRY * SCH_EDIT_FRAME::CreateBusWireEntry ( )
private

Definition at line 53 of file busentry.cpp.

References addCurrentItemToScreen(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetScreen(), IS_NEW, s_LastShape, SCH_SCREEN::SetCurItem(), and EDA_ITEM::SetFlags().

Referenced by OnLeftClick(), and SetPrintSheetReference().

54 {
55  // Create and place a new bus entry at cursor position
57 
58  busEntry->SetFlags( IS_NEW );
59  GetScreen()->SetCurItem( busEntry );
61  return busEntry;
62 }
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
static int s_LastShape
Definition: busentry.cpp:39
Class for a wire to bus entry.
void addCurrentItemToScreen()
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void SCH_BASE_FRAME::createCanvas ( )
inherited

Definition at line 585 of file sch_base_frame.cpp.

References 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_canvas, EDA_DRAW_FRAME::m_canvasType, EDA_BASE_FRAME::m_FrameSize, EDA_DRAW_FRAME::m_useSingleCanvasPane, EDA_DRAW_FRAME::SetGalCanvas(), and EDA_DRAW_FRAME::UseGalCanvas().

Referenced by SCH_BASE_FRAME::SCH_BASE_FRAME().

586 {
588 
589  // Allows only a CAIRO or OPENGL canvas:
593 
594  m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
596 
597  m_useSingleCanvasPane = true;
598 
599  SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
600  UseGalCanvas( true );
601 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:939
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
Definition: draw_frame.h:179
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
void SetGalCanvas(EDA_DRAW_PANEL_GAL *aPanel)
Definition: draw_frame.h:922
bool m_useSingleCanvasPane
Definition: draw_frame.h:98
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
bool SCH_EDIT_FRAME::CreateNetlist ( int  aFormat,
const wxString &  aFullFileName,
unsigned  aNetlistOptions,
REPORTER aReporter = NULL,
bool  silent = 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
aFormat= netlist format (NET_TYPE_PCBNEW ...)
aFullFileName= full netlist file name
aNetlistOptions= netlist options using OR'ed bits.

For SPICE netlist only: if NET_USE_NETNAMES is set, use net names from labels in schematic else use net numbers (net codes) if NET_USE_X_PREFIX is set : change "U" and "IC" reference prefix to "X"

Parameters
aReporter= a REPORTER to report error messages, mainly if a command line must be run (can be NULL
Returns
true if success.

Definition at line 211 of file netlist_generator.cpp.

References SCH_SHEET_LIST::AnnotatePowerSymbols(), BuildNetListBase(), g_RootSheet, prepareForNetlist(), SCH_SCREENS::UpdateSymbolLinks(), and WriteNetListFile().

Referenced by DeleteAllTemplateFieldNames(), NETLIST_DIALOG::GenNetlist(), DIALOG_BOM::OnRunPlugin(), and NETLIST_DIALOG::RunSimulator().

213 {
214  if( !aSilent ) // checks for errors and invokes annotation dialog as neccessary
215  {
216  if( !prepareForNetlist() )
217  return false;
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 
227  std::unique_ptr<NETLIST_OBJECT_LIST> connectedItemsList( BuildNetListBase() );
228 
229  bool success = WriteNetListFile( connectedItemsList.release(), aFormat,
230  aFullFileName, aNetlistOptions, aReporter );
231 
232  return success;
233 }
Class SCH_SHEET_LIST.
NETLIST_OBJECT_LIST * BuildNetListBase(bool updateStatusText=true)
Create a flat list which stores all connected objects.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
bool prepareForNetlist()
Verify that annotation is complete so that a proper netlist is even possible.
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the ful...
bool WriteNetListFile(NETLIST_OBJECT_LIST *aConnectedItemsList, int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL)
Create a netlist file.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
SCH_BITMAP * SCH_EDIT_FRAME::CreateNewImage ( wxDC *  aDC)
private

Definition at line 39 of file edit_bitmap.cpp.

References EDA_DRAW_FRAME::GetCrossHairPosition(), IS_NEW, PrepareMoveItem(), SCH_BITMAP::ReadImageFile(), and EDA_ITEM::SetFlags().

Referenced by OnLeftClick(), and SetPrintSheetReference().

40 {
41  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
42  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
43  wxFD_OPEN );
44 
45  if( fileDlg.ShowModal() != wxID_OK )
46  return nullptr;
47 
48  wxString fullFilename = fileDlg.GetPath();
49 
50  if( !wxFileExists( fullFilename ) )
51  {
52  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
53  return nullptr;
54  }
55 
57 
58  SCH_BITMAP* image = new SCH_BITMAP( pos );
59 
60  if( !image->ReadImageFile( fullFilename ) )
61  {
62  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
63  delete image;
64  return nullptr;
65  }
66 
67  image->SetFlags( IS_NEW );
68  PrepareMoveItem( image );
69 
70 // OnModify();
71  return image;
72 }
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void PrepareMoveItem(SCH_ITEM *aItem)
Start moving aItem using the mouse.
Definition: schedit.cpp:762
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:80
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
SCH_TEXT * SCH_EDIT_FRAME::CreateNewText ( int  aType)
private

Definition at line 68 of file edit_label.cpp.

References DisplayError(), EditSchematicText(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetDefaultTextSize(), SCH_TEXT::GetLabelSpinStyle(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), IS_MOVED, IS_NEW, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), lastGlobalLabelShape, lastTextBold, lastTextItalic, lastTextOrientation, LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, PrepareMoveItem(), SCH_GLOBAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T, EDA_TEXT::SetBold(), EDA_ITEM::SetFlags(), EDA_TEXT::SetItalic(), SCH_TEXT::SetLabelSpinStyle(), SetRepeatItem(), SCH_TEXT::SetShape(), EDA_TEXT::SetTextSize(), and EDA_ITEM::Type().

Referenced by OnLeftClick(), Process_Special_Functions(), and SetPrintSheetReference().

69 {
70  SCH_TEXT* textItem = NULL;
71 
72  SetRepeatItem( NULL );
73 
74  switch( aType )
75  {
76  case LAYER_NOTES:
77  textItem = new SCH_TEXT( GetCrossHairPosition() );
78  break;
79 
80  case LAYER_LOCLABEL:
81  textItem = new SCH_LABEL( GetCrossHairPosition() );
82  break;
83 
84  case LAYER_HIERLABEL:
85  textItem = new SCH_HIERLABEL( GetCrossHairPosition() );
86  textItem->SetShape( lastGlobalLabelShape );
87  break;
88 
89  case LAYER_GLOBLABEL:
90  textItem = new SCH_GLOBALLABEL( GetCrossHairPosition() );
91  textItem->SetShape( lastGlobalLabelShape );
92  break;
93 
94  default:
95  DisplayError( this, wxT( "SCH_EDIT_FRAME::CreateNewText() Internal error" ) );
96  return NULL;
97  }
98 
99  textItem->SetBold( lastTextBold );
100  textItem->SetItalic( lastTextItalic );
102  textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
103  textItem->SetFlags( IS_NEW | IS_MOVED );
104 
105  EditSchematicText( textItem );
106 
107  if( textItem->GetText().IsEmpty() )
108  {
109  delete textItem;
110  return NULL;
111  }
112 
113  lastTextBold = textItem->IsBold();
114  lastTextItalic = textItem->IsItalic();
116 
117  if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIERARCHICAL_LABEL_T )
118  lastGlobalLabelShape = textItem->GetShape();
119 
120  // Prepare display to move the new item
121  PrepareMoveItem( textItem );
122 
123  return textItem;
124 }
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:118
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:120
bool IsItalic() const
Definition: eda_text.h:183
static int lastTextOrientation
Definition: edit_label.cpp:45
static PINSHEETLABEL_SHAPE lastGlobalLabelShape
Definition: edit_label.cpp:44
virtual void SetLabelSpinStyle(int aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:240
void SetItalic(bool isItalic)
Definition: eda_text.h:182
int GetLabelSpinStyle() const
Definition: sch_text.h:116
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
static bool lastTextItalic
Definition: edit_label.cpp:47
bool IsBold() const
Definition: eda_text.h:186
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void PrepareMoveItem(SCH_ITEM *aItem)
Start moving aItem using the mouse.
Definition: schedit.cpp:762
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
void EditSchematicText(SCH_TEXT *TextStruct)
static bool lastTextBold
Definition: edit_label.cpp:46
void SetBold(bool aBold)
Definition: eda_text.h:185
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
int GetDefaultTextSize()
Default size for text in general.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
void SCH_EDIT_FRAME::CreateScreens ( )

Definition at line 545 of file sch_edit_frame.cpp.

References g_RootSheet, SCH_SHEET::GetScreen(), Kiway, SCH_SCREEN::SetFileName(), BASE_SCREEN::SetMaxUndoItems(), and SCH_SHEET::SetScreen().

Referenced by DeleteAllTemplateFieldNames(), importFile(), and OpenProjectFiles().

546 {
547  if( g_RootSheet == NULL )
548  {
549  g_RootSheet = new SCH_SHEET();
550  }
551 
552  if( g_RootSheet->GetScreen() == NULL )
553  {
554  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
556  g_RootSheet->SetScreen( screen );
558  }
559 
561 
562  m_CurrentSheet->clear();
563  m_CurrentSheet->push_back( g_RootSheet );
564 
565  if( GetScreen() == NULL )
566  {
567  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
569  SetScreen( screen );
570  }
571 
572  GetScreen()->SetZoom( 32.0 );
573 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
virtual void SetScreen(BASE_SCREEN *aScreen) override
wxString m_DefaultSchematicFileName
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:118
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void SetMaxUndoItems(int aMax)
Definition: base_screen.h:313
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:129
void EDA_DRAW_FRAME::CreateServer ( int  service,
bool  local = true 
)
inherited

Definition at line 49 of file eda_dde.cpp.

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

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

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
Definition: draw_frame.h:100
SCH_SHEET * SCH_EDIT_FRAME::CreateSheet ( wxDC *  DC)
private

Definition at line 406 of file sheet.cpp.

References EDA_DRAW_PANEL::CallMouseCapture(), EDA_DRAW_PANEL::CrossHairOff(), EDA_DRAW_PANEL::CrossHairOn(), ExitSheet(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetNewTimeStamp(), SCH_SHEET::GetResizePosition(), GetScreen(), IS_NEW, IS_RESIZED, EDA_DRAW_FRAME::m_canvas, EDA_DRAW_PANEL::MoveCursorToCrossHair(), resizeSheetWithMouseCursor(), EDA_DRAW_FRAME::SetCrossHairPosition(), SCH_SCREEN::SetCurItem(), EDA_ITEM::SetFlags(), EDA_DRAW_PANEL::SetMouseCapture(), EDA_ITEM::SetParent(), SetRepeatItem(), SCH_SHEET::SetScreen(), and EDA_ITEM::SetTimeStamp().

Referenced by OnLeftClick(), and SetPrintSheetReference().

407 {
408  SetRepeatItem( NULL );
409 
410  SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
411 
412  sheet->SetFlags( IS_NEW | IS_RESIZED );
413  sheet->SetTimeStamp( GetNewTimeStamp() );
414  sheet->SetParent( GetScreen() );
415  sheet->SetScreen( NULL );
416 
417  // need to check if this is being added to the GetDrawItems().
418  // also need to update the hierarchy, if we are adding
419  // a sheet to a screen that already has multiple instances (!)
420  GetScreen()->SetCurItem( sheet );
422  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
423  m_canvas->CrossHairOff( aDC );
424 
426 
428  m_canvas->CrossHairOn( aDC );
429 
430  return sheet;
431 }
static void ExitSheet(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: sheet.cpp:360
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
wxPoint GetResizePosition() const
Return the position of the lower right corner of the sheet in drawing units.
Definition: sch_sheet.cpp:904
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
virtual void CrossHairOn(wxDC *DC=nullptr)
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
static void resizeSheetWithMouseCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: sheet.cpp:316
virtual void CrossHairOff(wxDC *DC=nullptr)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:115
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
SCH_SHEET_PIN * SCH_EDIT_FRAME::CreateSheetPin ( SCH_SHEET aSheet)
private

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 77 of file sheetlab.cpp.

References EditSheetPin(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetLastSheetPinTextSize(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), EDA_TEXT::GetTextSize(), IS_NEW, m_lastSheetPinTextSize, m_lastSheetPinType, OnModify(), PrepareMoveItem(), EDA_ITEM::SetFlags(), SCH_SHEET_PIN::SetPosition(), SCH_TEXT::SetShape(), and EDA_TEXT::SetTextSize().

Referenced by GetLastSheetPinPosition(), and OnLeftClick().

78 {
79  wxString line;
80  SCH_SHEET_PIN* sheetPin;
81 
82  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
83  sheetPin->SetFlags( IS_NEW );
84  sheetPin->SetTextSize( GetLastSheetPinTextSize() );
85  sheetPin->SetShape( m_lastSheetPinType );
86 
87  int response = EditSheetPin( sheetPin, false );
88 
89  if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
90  {
91  delete sheetPin;
92  return NULL;
93  }
94 
95  m_lastSheetPinType = sheetPin->GetShape();
96  m_lastSheetPinTextSize = sheetPin->GetTextSize();
97 
98  sheetPin->SetPosition( GetCrossHairPosition() );
99  PrepareMoveItem( sheetPin );
100 
101  OnModify();
102  return sheetPin;
103 }
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:118
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:120
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
static wxSize m_lastSheetPinTextSize
Last sheet pin text size.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void PrepareMoveItem(SCH_ITEM *aItem)
Start moving aItem using the mouse.
Definition: schedit.cpp:762
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
static PINSHEETLABEL_SHAPE m_lastSheetPinType
Last sheet pin type.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
const wxSize & GetLastSheetPinTextSize()
Initializing accessor for the pin text size.
Definition: sheetlab.cpp:48
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.h:195
const wxSize & GetTextSize() const
Definition: eda_text.h:228
int EditSheetPin(SCH_SHEET_PIN *aSheetPin, bool aRedraw)
Display the dialog for editing the parameters of aSheetPin.
Definition: sheetlab.cpp:60
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

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

Definition at line 1443 of file sch_edit_frame.h.

Referenced by WriteNetListFile().

1443 { m_exec_flags = wxEXEC_SYNC; }
int m_exec_flags
Flags of the wxExecute() function to call a custom net list generator.
void SCH_EDIT_FRAME::DeleteAllTemplateFieldNames ( )
inline

Remove all template field names.

Definition at line 308 of file sch_edit_frame.h.

References SCH_COLLECTOR::AllItems, AnnotateComponents(), BestZoom(), BreakSegment(), BreakSegments(), BreakSegmentsOnJunctions(), BuildNetListBase(), CheckAnnotate(), CreateNetlist(), CreateScreens(), TEMPLATES::DeleteAllTemplateFieldNames(), DeleteAnnotation(), DeleteItemAtCrossHair(), DisplayCurrentSheet(), ExecuteRemoteCommand(), FindComponentAndItem(), GetConfigurationSettings(), GetCurrentSheet(), GetHotKeyDescription(), GetScreenDesc(), GetUniqueFilenameForCurrentSheet(), HardRedraw(), HighlightConnectionAtPosition(), KiwayMailIn(), LoadSettings(), LocateAndShowItem(), LocateItem(), SCH_BASE_FRAME::m_templateFieldNames, ModalAnnotate(), OnHotKey(), OnLeftClick(), OnLeftDClick(), OnModify(), OnPrint(), OnRightClick(), OnSelectOptionToolbar(), ReCreateHToolbar(), ReCreateMenuBar(), ReCreateOptToolbar(), ReCreateVToolbar(), RedrawActiveWindow(), SaveSettings(), SendCrossProbeNetName(), SendMessageToPCBNEW(), SetCurrentSheet(), SetCurrentSheetHighlightFlags(), SetSheetNumberAndCount(), TestDanglingEnds(), and WriteNetListFile().

Referenced by PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow().

309  {
311  }
TEMPLATES m_templateFieldNames
void DeleteAllTemplateFieldNames()
Function DeleteAllTemplateFieldNames deletes the entire contents.
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 annotate.cpp.

References SCH_SCREEN::ClearAnnotation(), SCH_SCREENS::ClearAnnotation(), SCH_BASE_FRAME::GetCanvas(), GetScreen(), m_CurrentSheet, OnModify(), SCH_DRAW_PANEL::Refresh(), SCH_BASE_FRAME::SyncView(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

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

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 OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
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 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_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
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:679
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
void SCH_EDIT_FRAME::DeleteConnection ( bool  DeleteFullConnection)
private

Definition at line 638 of file schedit.cpp.

References DeleteItemsInList(), SCH_SCREEN::GetConnection(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetScreen(), OnModify(), and SchematicCleanUp().

Referenced by Process_Special_Functions(), and SetPrintSheetReference().

639 {
640  PICKED_ITEMS_LIST pickList;
641  SCH_SCREEN* screen = GetScreen();
643 
644  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
645  {
646  DeleteItemsInList( pickList );
647  SchematicCleanUp( true );
648  OnModify();
649  }
650 }
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int GetConnection(const wxPoint &aPosition, PICKED_ITEMS_LIST &aList, bool aFullConnection)
Adds all of the wires and junctions to aList that make up a connection to the object at aPosition...
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
void DeleteItemsInList(PICKED_ITEMS_LIST &aItemsList, bool aAppend=false)
Removes all items (and unused junctions that connect to them) and saves each in the undo list...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void SCH_EDIT_FRAME::DeleteCurrentSegment ( )
private

Erase the last segment at the current mouse position.

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

References SCH_SCREEN::GetCurItem(), GetScreen(), EDA_ITEM::IsNew(), EDA_DRAW_FRAME::m_canvas, SCH_BASE_FRAME::RemoveFromScreen(), SCH_SCREEN::SetCurItem(), EDA_DRAW_PANEL::SetMouseCaptureCallback(), and SetRepeatItem().

Referenced by SetPrintSheetReference().

469 {
470  SCH_SCREEN* screen = GetScreen();
471 
472  SetRepeatItem( NULL );
473 
474  if( ( screen->GetCurItem() == NULL ) || !screen->GetCurItem()->IsNew() )
475  return;
476 
477  RemoveFromScreen( screen->GetCurItem() );
479  screen->SetCurItem( NULL );
480 }
bool IsNew() const
Definition: base_struct.h:219
void RemoveFromScreen(SCH_ITEM *aItem)
Remove an item from the screen (and view)
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
virtual void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
void SCH_EDIT_FRAME::DeleteItem ( SCH_ITEM aItem,
bool  aAppend = false 
)

Remove aItem from the current screen and saves it in the undo list.

Parameters
aItemThe item to remove from the current screen.
aAppendTrue if we are updating a previous Undo state

Definition at line 181 of file operations_on_items_lists.cpp.

References DeleteJunction(), SCH_ITEM::GetConnectionPoints(), EDA_ITEM::GetFlags(), EDA_ITEM::GetParent(), GetScreen(), SCH_BASE_FRAME::RefreshItem(), SCH_BASE_FRAME::RemoveFromScreen(), SCH_SHEET::RemovePin(), SaveCopyInUndoList(), SCH_JUNCTION_T, SCH_SHEET_PIN_T, SCH_SHEET_T, EDA_ITEM::SetFlags(), STRUCT_DELETED, EDA_ITEM::Type(), UR_CHANGED, and UR_DELETED.

Referenced by DeleteItemAtCrossHair(), DeleteItemsInList(), GetLastSheetPinPosition(), and Process_Special_Functions().

182 {
183  wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item." ) );
184  wxCHECK_RET( !( aItem->GetFlags() & STRUCT_DELETED ),
185  wxT( "Cannot delete item that is already deleted." ) );
186 
187  // Here, aItem is not null.
188  SCH_SCREEN* screen = GetScreen();
189 
190  if( aItem->Type() == SCH_SHEET_PIN_T )
191  {
192  // This item is attached to its parent hierarchical sheet,
193  // and is not accessible by the global list directly and cannot be removed from this list.
194  SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
195  wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
196  wxT( "Sheet label has invalid parent item." ) );
197  SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED, aAppend );
198  sheet->RemovePin( (SCH_SHEET_PIN*) aItem );
199  RefreshItem( sheet );
200  }
201  else if( aItem->Type() == SCH_JUNCTION_T )
202  {
203  DeleteJunction( aItem, aAppend );
204  }
205  else
206  {
207  aItem->SetFlags( STRUCT_DELETED );
208  SaveCopyInUndoList( aItem, UR_DELETED, aAppend );
209  RemoveFromScreen( aItem );
210 
211  std::vector< wxPoint > pts;
212  aItem->GetConnectionPoints( pts );
213  for( auto point : pts )
214  {
215  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
216  if( junction && !screen->IsJunctionNeeded( point ) )
217  DeleteJunction( junction, true );
218  }
219  }
220 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
void RemoveFromScreen(SCH_ITEM *aItem)
Remove an item from the screen (and view)
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:187
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
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:123
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool SCH_EDIT_FRAME::DeleteItemAtCrossHair ( )

Delete the item found under the cross hair.

If multiple items are found at the cross hair position, a context menu is displayed to clarify which item to delete. See LocateItem() for more information on locating multiple items.

Returns
True if an item was deleted.

Definition at line 653 of file schedit.cpp.

References DeleteItem(), SCH_BASE_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetScreen(), SCH_ITEM::IsConnectable(), LocateItem(), OnModify(), SCH_COLLECTOR::ParentItems, SCH_DRAW_PANEL::Refresh(), SCH_SCREEN::SetCurItem(), SetRepeatItem(), and TestDanglingEnds().

Referenced by DeleteAllTemplateFieldNames(), OnHotKey(), and OnLeftClick().

654 {
655  SCH_ITEM* item;
656  SCH_SCREEN* screen = GetScreen();
657 
659 
660  if( item )
661  {
662  bool itemHasConnections = item->IsConnectable();
663 
664  screen->SetCurItem( NULL );
665  SetRepeatItem( NULL );
666  DeleteItem( item );
667 
668  if( itemHasConnections )
670 
671  GetCanvas()->Refresh();
672  OnModify();
673  return true;
674  }
675 
676  return false;
677 }
static const KICAD_T ParentItems[]
A scan list for only parent schematic items.
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
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...
SCH_ITEM * LocateItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0)
Check for items at aPosition matching the types in aFilterList.
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
SCH_DRAW_PANEL * GetCanvas() const override
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void DeleteItem(SCH_ITEM *aItem, bool aAppend=false)
Remove aItem from the current screen and saves it in the undo list.
void SCH_EDIT_FRAME::DeleteItemsInList ( PICKED_ITEMS_LIST aItemsList,
bool  aAppend = false 
)

Removes all items (and unused junctions that connect to them) and saves each in the undo list.

Parameters
aItemsListThe list of items to delete
aAppendTrue if we are updating a previous commit

Definition at line 164 of file operations_on_items_lists.cpp.

References SCH_SCREEN::ClearDr