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...
 
void OnPageSettingsChange () override
 Called when modifying the page settings. More...
 
bool SetCurrentSheetHighlightFlags (std::vector< EDA_ITEM * > *aItemsToRedrawList)
 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 wxPoint & GetAuxOrigin () const override
 Return the origin of the axis used for plotting and various exports. More...
 
void SetAuxOrigin (const wxPoint &aPosition) override
 
const wxPoint & GetGridOrigin () 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 wxPoint & GetScrollCenterPosition () 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...
 
wxComboBox * m_gridSelectBox
 
wxComboBox * 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...
 
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 450 of file sch_edit_frame.cpp.

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

451 {
452  Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
454 
455  delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem()
456 
457  SetScreen( NULL );
458 
459  delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
460  delete m_undoItem;
461  delete m_findReplaceData;
462  delete m_findReplaceStatus;
463 
464  delete g_RootSheet;
465  g_RootSheet = NULL;
466 }
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 1347 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().

1348 {
1349  SCH_SCREEN* screen = GetScreen();
1350  SCH_ITEM* item = screen->GetCurItem();
1351 
1352  wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
1353 
1354  m_canvas->SetAutoPanRequest( false );
1355 
1356  SCH_SHEET* parentSheet = nullptr;
1357  SCH_COMPONENT* parentComponent = nullptr;
1358  SCH_ITEM* undoItem = item;
1359 
1360  if( item->Type() == SCH_SHEET_PIN_T )
1361  {
1362  parentSheet = (SCH_SHEET*) item->GetParent();
1363 
1364  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1365  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1366 
1367  undoItem = parentSheet;
1368  }
1369 
1370  else if( item->Type() == SCH_FIELD_T )
1371  {
1372  parentComponent = (SCH_COMPONENT*) item->GetParent();
1373 
1374  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
1375  wxT( "Cannot place field in invalid schematic component object." ) );
1376 
1377  undoItem = parentComponent;
1378  }
1379 
1380  if( item->IsNew() )
1381  {
1382  // When a new sheet is added to the hierarchy, a clear annotation can be needed
1383  // for all new sheet paths added by the new sheet (if this sheet is loaded from
1384  // and existing sheet or a existing file, it can also contain subsheets)
1385  bool doClearAnnotation = false;
1386  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1387 
1388  if( item->Type() == SCH_SHEET_T )
1389  {
1390  // Fix the size and position of the new sheet using the last values set by
1391  // the m_mouseCaptureCallback function.
1392  m_canvas->SetMouseCapture( NULL, NULL );
1393 
1394  if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet, &doClearAnnotation ) )
1395  {
1396  screen->SetCurItem( NULL );
1397  delete item;
1398 
1399  return;
1400  }
1401 
1403 
1404  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1405  AddToScreen( item );
1406 
1407  SetRepeatItem( item );
1408  SaveCopyInUndoList( undoItem, UR_NEW );
1409  }
1410  else if( item->Type() == SCH_SHEET_PIN_T )
1411  {
1412  // Sheet pins are owned by their parent sheet.
1413  SaveCopyInUndoList( undoItem, UR_CHANGED ); // save the parent sheet
1414 
1415  parentSheet->AddPin( (SCH_SHEET_PIN*) item );
1416  }
1417  else if( item->Type() == SCH_FIELD_T )
1418  {
1419  // Component fields are also owned by their parent, but new component fields
1420  // are handled elsewhere.
1421  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1422  }
1423  else
1424  {
1425  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1426  AddToScreen( item );
1427 
1428  SetRepeatItem( item );
1429  SaveCopyInUndoList( undoItem, UR_NEW );
1430  }
1431 
1432  if( doClearAnnotation )
1433  {
1434  // Clear annotation of new sheet paths: the new sheet and its sub-sheets
1435  // If needed the missing alternate references of components will be created
1436  SCH_SCREENS screensList( g_RootSheet );
1437  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1438  }
1439  }
1440  else
1441  {
1442  SaveUndoItemInUndoList( undoItem );
1443  }
1444 
1445  item->ClearFlags();
1446 
1447  screen->SetModify();
1448  screen->SetCurItem( NULL );
1449  m_canvas->SetMouseCapture( NULL, NULL );
1451 
1452  RefreshItem( item );
1453 
1454  if( item->IsConnectable() )
1455  {
1456  std::vector< wxPoint > pts;
1457  item->GetConnectionPoints( pts );
1458 
1459  for( auto i = pts.begin(); i != pts.end(); i++ )
1460  {
1461  for( auto j = i + 1; j != pts.end(); j++ )
1462  TrimWire( *i, *j, true );
1463 
1464  if( screen->IsJunctionNeeded( *i, true ) )
1465  AddJunction( *i, true );
1466  }
1467 
1468  TestDanglingEnds();
1469  }
1470 
1471  GetCanvas()->Refresh();
1472 }
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...
virtual void SetAutoPanRequest(bool aEnable)=0
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
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:70
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 801 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().

802 {
803  SCH_JUNCTION* junction = new SCH_JUNCTION( aPosition );
804  bool broken_segments = false;
805 
806  AddToScreen( junction );
807  broken_segments = BreakSegments( aPosition, aAppend );
809  OnModify();
810  SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
811 
812  auto view = GetCanvas()->GetView();
813  view->ClearPreview();
814  view->ShowPreview( false );
815  view->ClearHiddenFlags();
816 
817  return junction;
818 }
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:133
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 1540 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().

1541 {
1542  int maxZoomIds;
1543  double zoom;
1544  wxString msg;
1545  BASE_SCREEN* screen = m_canvas->GetScreen();
1546 
1547  msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER );
1548  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
1549  msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN );
1550  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) );
1551  msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT );
1552  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) );
1553  msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW );
1554  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) );
1555  msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO );
1556  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) );
1557 
1558 
1559  wxMenu* zoom_choice = new wxMenu;
1560  AddMenuItem( MasterMenu, zoom_choice,
1561  ID_POPUP_ZOOM_SELECT, _( "Zoom" ),
1562  KiBitmap( zoom_selection_xpm ) );
1563 
1564  zoom = screen->GetZoom();
1566  maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ?
1567  maxZoomIds : screen->m_ZoomList.size();
1568 
1569  // Populate zoom submenu.
1570  for( int i = 0; i < maxZoomIds; i++ )
1571  {
1572  msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );
1573 
1574  zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
1575  wxEmptyString, wxITEM_CHECK );
1576  if( zoom == screen->m_ZoomList[i] )
1577  zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
1578  }
1579 
1580  // Create grid submenu as required.
1581  if( screen->GetGridCount() )
1582  {
1583  wxMenu* gridMenu = new wxMenu;
1584  AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
1585  _( "Grid" ), KiBitmap( grid_select_xpm ) );
1586 
1587  wxArrayString gridsList;
1588  int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1589 
1590  for( unsigned i = 0; i < gridsList.GetCount(); i++ )
1591  {
1592  GRID_TYPE& grid = screen->GetGrid( i );
1593  gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
1594 
1595  if( (int)i == icurr )
1596  gridMenu->Check( grid.m_CmdId, true );
1597  }
1598  }
1599 
1600  MasterMenu->AppendSeparator();
1601  AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
1602 }
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:281
Definition: common.h:161
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 821 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().

822 {
823  SCH_NO_CONNECT* no_connect = new SCH_NO_CONNECT( aPosition );
824 
825  SetRepeatItem( no_connect );
826  AddToScreen( no_connect );
829  OnModify();
830 
831  auto view = GetCanvas()->GetView();
832  view->ClearPreview();
833  view->ShowPreview( false );
834  view->ClearHiddenFlags();
835 
836  SaveCopyInUndoList( no_connect, UR_NEW );
837  return no_connect;
838 }
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:133
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 627 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().

628 {
629  GetScreen()->Append( aItem );
630  GetCanvas()->GetView()->Add( aItem );
631  RefreshItem( aItem, true ); // handle any additional parent semantics
632 }
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:345
void SCH_BASE_FRAME::AddToScreen ( DLIST< SCH_ITEM > &  aItems)
inherited

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

Definition at line 635 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().

636 {
637  for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() )
638  {
639  GetCanvas()->GetView()->Add( item );
640  RefreshItem( item, true ); // handle any additional parent semantics
641  }
642 
643  GetScreen()->Append( aItems );
644 }
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:345
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 ...
#define VALUE
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:111
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:70
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.
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 880 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().

883 {
884  if( m_messagePanel == NULL )
885  return;
886 
887  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
888 }
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 382 of file eeschema/files-io.cpp.

References PART_LIBS::AddLibrary(), SCH_SCREEN::Append(), EDA_DRAW_FRAME::AppendMsgPanel(), PART_LIBS::CacheName(), 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_SCREENS::TestDanglingEnds(), SCH_SHEET_LIST::TestForRecursion(), SCH_SCREENS::UpdateSymbolLinks(), IO_ERROR::What(), and SCH_BASE_FRAME::Zoom_Automatique().

Referenced by OnAppendProject(), and SetPrintSheetReference().

383 {
384  wxString msg;
385  wxString fullFileName;
386  SCH_SCREEN* screen = GetScreen();
387 
388  if( !screen )
389  {
390  wxLogError( wxT( "Document not ready, cannot import" ) );
391  return false;
392  }
393 
394  // open file chooser dialog
395  wxString path = wxPathOnly( Prj().GetProjectFullName() );
396 
397  wxFileDialog dlg( this, _( "Append Schematic" ), path, wxEmptyString,
398  SchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
399 
400  if( dlg.ShowModal() == wxID_CANCEL )
401  return false;
402 
403  fullFileName = dlg.GetPath();
404 
405  wxFileName fn = fullFileName;
406 
407  if( fn.IsRelative() )
408  {
409  fn.MakeAbsolute();
410  fullFileName = fn.GetFullPath();
411  }
412 
413  wxString cache_name = PART_LIBS::CacheName( fullFileName );
414 
415  if( !!cache_name )
416  {
417  PART_LIBS* libs = Prj().SchLibs();
418 
419  try
420  {
421  if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
422  lib->SetCache();
423  }
424  catch( const IO_ERROR& ioe )
425  {
426  DisplayError( this, ioe.What() );
427  }
428  }
429 
430  wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
431 
432  // Load the schematic into a temporary sheet.
433  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
434  std::unique_ptr< SCH_SHEET> newSheet( new SCH_SHEET );
435 
436  newSheet->SetFileName( fullFileName );
437 
438  try
439  {
440  pi->Load( fullFileName, &Kiway(), newSheet.get() );
441 
442  if( !pi->GetError().IsEmpty() )
443  {
444  DisplayErrorMessage( this,
445  _( "The entire schematic could not be loaded. Errors "
446  "occurred attempting to load hierarchical sheet "
447  "schematics." ),
448  pi->GetError() );
449  }
450  }
451  catch( const IO_ERROR& ioe )
452  {
453  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), fullFileName );
454  DisplayErrorMessage( this, msg, ioe.What() );
455 
456  msg.Printf( _( "Failed to load schematic \"%s\"" ), fullFileName );
457  AppendMsgPanel( wxEmptyString, msg, CYAN );
458 
459  return false;
460  }
461 
462  // Make sure any new sheet changes do not cause any recursion issues.
463  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy.
464  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the import.
465 
466  wxFileName destFile = screen->GetFileName();
467 
468  if( destFile.IsRelative() )
469  destFile.MakeAbsolute( Prj().GetProjectPath() );
470 
471  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath( wxPATH_UNIX ) ) )
472  {
473  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
474  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
475  "the schematic hierarchy." ),
476  destFile.GetFullPath() );
477  DisplayError( this, msg );
478  return false;
479  }
480 
481  wxArrayString names;
482 
483  // Make sure the imported schematic has been remapped to the symbol library table.
484  SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
485 
486  if( newScreens.HasNoFullyDefinedLibIds() )
487  {
488  DisplayInfoMessage( this,
489  "This schematic has not been remapped to the symbol library\n"
490  "table. The project this schematic belongs to must first be\n"
491  "remapped before it can be imported into the current project." );
492  return false;
493  }
494  else
495  {
496  // If there are symbol libraries in the imported schematic that are not in the
497  // symbol library table of this project, there could be a lot of broken symbol
498  // library links. Attempt to add the missing libraries to the project symbol
499  // library table.
500  newScreens.GetLibNicknames( names );
501  wxArrayString newLibNames;
502 
503  for( const auto& name : names )
504  {
505  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
506  newLibNames.Add( name );
507  }
508 
509  wxFileName symLibTableFn( fn.GetPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
510 
511  if( !newLibNames.IsEmpty() && symLibTableFn.Exists() && symLibTableFn.IsFileReadable() )
512  {
513  SYMBOL_LIB_TABLE table;
514 
515  try
516  {
517  table.Load( symLibTableFn.GetFullPath() );
518  }
519  catch( const IO_ERROR& ioe )
520  {
521  msg.Printf( _( "An error occurred loading the symbol library table \"%s\"." ),
522  symLibTableFn.GetFullPath() );
523  DisplayErrorMessage( NULL, msg, ioe.What() );
524  }
525 
526  if( !table.IsEmpty() )
527  {
528  for( const auto& libName : newLibNames )
529  {
530  if( !table.HasLibrary( libName ) )
531  continue;
532 
533  // Don't expand environment variable because KIPRJMOD will not be correct
534  // for a different project.
535  wxString uri = table.GetFullURI( libName, false );
536  wxFileName newLib;
537 
538  if( uri.Contains( "${KIPRJMOD}" ) )
539  {
540  newLib.SetPath( fn.GetPath() );
541  newLib.SetFullName( uri.AfterLast( '}' ) );
542  uri = newLib.GetFullPath();
543  }
544  else if( uri.Contains( "$(KIPRJMOD)" ) )
545  {
546  newLib.SetPath( fn.GetPath() );
547  newLib.SetFullName( uri.AfterLast( ')' ) );
548  uri = newLib.GetFullPath();
549  }
550  else
551  {
552  uri = table.GetFullURI( libName );
553  }
554 
555  // Add the library from the imported project to the current project
556  // symbol library table.
557  const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
558 
559  wxCHECK2_MSG( row, continue, "Library '" + libName +
560  "' missing from symbol library table '" +
561  symLibTableFn.GetFullPath() + "'." );
562 
563  wxString newLibName = libName;
564  int libNameCnt = 1;
565 
566  // Rename the imported symbol library if it already exists.
567  while( Prj().SchSymbolLibTable()->HasLibrary( newLibName ) )
568  newLibName = wxString::Format( "%s%d", libName, libNameCnt );
569 
570  auto newRow = new SYMBOL_LIB_TABLE_ROW( newLibName, uri, row->GetType(),
571  row->GetOptions(), row->GetDescr() );
572  Prj().SchSymbolLibTable()->InsertRow( newRow );
573 
574  if( libName != newLibName )
575  newScreens.ChangeSymbolLibNickname( libName, newLibName );
576  }
577  }
578  }
579  }
580 
581  newScreens.ClearAnnotation();
582 
583  // Check for duplicate sheet names in the current page.
584  wxArrayString duplicateSheetNames;
585  SCH_TYPE_COLLECTOR sheets;
586 
587  sheets.Collect( screen->GetDrawItems(), SCH_COLLECTOR::SheetsOnly );
588 
589  for( int i = 0; i < sheets.GetCount(); ++i )
590  {
591  if( newSheet->GetScreen()->GetSheet( ( ( SCH_SHEET* ) sheets[i] )->GetName() ) )
592  duplicateSheetNames.Add( ( ( SCH_SHEET* ) sheets[i] )->GetName() );
593  }
594 
595  if( !duplicateSheetNames.IsEmpty() )
596  {
597  msg.Printf( "Duplicate sheet names exist on the current page. Do you want to "
598  "automatically rename the duplicate sheet names?" );
599  if( !IsOK( this, msg ) )
600  return false;
601  }
602 
603  SCH_SCREEN* newScreen = newSheet->GetScreen();
604  wxCHECK_MSG( newScreen, false, "No screen defined for imported sheet." );
605 
606  for( const auto& duplicateName : duplicateSheetNames )
607  {
608  SCH_SHEET* renamedSheet = newScreen->GetSheet( duplicateName );
609 
610  wxCHECK2_MSG( renamedSheet, continue,
611  "Sheet " + duplicateName + " not found in imported schematic." );
612 
613  timestamp_t newtimestamp = GetNewTimeStamp();
614  renamedSheet->SetTimeStamp( newtimestamp );
615  renamedSheet->SetName( wxString::Format( "Sheet%8.8lX", (unsigned long) newtimestamp ) );
616  }
617 
618  // It is finally safe to add the imported schematic.
619  screen->Append( newScreen );
620 
621  SCH_SCREENS allScreens;
622  allScreens.ReplaceDuplicateTimeStamps();
623 
624  SCH_SCREENS screens( GetCurrentSheet().Last() );
625  screens.UpdateSymbolLinks( true );
626 
627  // Clear all annotation in the imported schematic to prevent clashes with existing annotation.
628  // Must be done after updating the symbol links as we need to know about multi-unit parts.
629  // screens.ClearAnnotation();
630 
631  screens.TestDanglingEnds();
632 
634  Zoom_Automatique( false );
636 
637  SyncView();
638  HardRedraw(); // Full reinit of the current screen and the display.
639  OnModify();
640 
641  return true;
642 }
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:53
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 901 of file eeschema/files-io.cpp.

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

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

902 {
903  SCH_SCREENS screenList;
904 
905  // Save any currently open and modified project files.
906  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
907  {
908  if( screen->IsModify() )
909  {
910  if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. Save changes?" ),
911  [&]()->bool { return SaveProject(); } ) )
912  {
913  return false;
914  }
915  }
916  }
917 
918  return true;
919 }
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:70
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 716 of file sch_edit_frame.cpp.

Referenced by DeleteAllTemplateFieldNames().

717 {
718  double sizeX = (double) GetScreen()->GetPageSettings().GetWidthIU();
719  double sizeY = (double) GetScreen()->GetPageSettings().GetHeightIU();
720  wxPoint centre( wxPoint( sizeX / 2, sizeY / 2 ) );
721 
722  // The sheet boundary already affords us some margin, so add only an
723  // additional 5%.
724  double margin_scale_factor = 1.05;
725 
726  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
727 }
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 667 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().

669 {
670  if( !IsPointOnSegment( aSegment->GetStartPoint(), aSegment->GetEndPoint(), aPoint )
671  || aSegment->IsEndPoint( aPoint ) )
672  return false;
673 
674  SaveCopyInUndoList( aSegment, UR_CHANGED, aAppend );
675  SCH_LINE* newSegment = new SCH_LINE( *aSegment );
676  SaveCopyInUndoList( newSegment, UR_NEW, true );
677 
678  newSegment->SetStartPoint( aPoint );
679  AddToScreen( newSegment );
680 
681  RefreshItem( aSegment );
682  aSegment->SetEndPoint( aPoint );
683 
684  if( aNewSegment )
685  *aNewSegment = newSegment;
686 
687  return true;
688 }
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 691 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().

692 {
693  bool brokenSegments = false;
694 
695  for( SCH_ITEM* segment = GetScreen()->GetDrawItems(); segment; segment = segment->Next() )
696  {
697  if( ( segment->Type() != SCH_LINE_T ) || ( segment->GetLayer() == LAYER_NOTES ) )
698  continue;
699 
700  brokenSegments |= BreakSegment( (SCH_LINE*) segment, aPoint, aAppend || brokenSegments );
701  }
702 
703  return brokenSegments;
704 }
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 707 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().

708 {
709  bool brokenSegments = false;
710 
711  for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
712  {
713  if( item->Type() == SCH_JUNCTION_T )
714  {
715  SCH_JUNCTION* junction = ( SCH_JUNCTION* ) item;
716 
717  if( BreakSegments( junction->GetPosition(), brokenSegments || aAppend ) )
718  brokenSegments = true;
719  }
720  else
721  {
722  SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( item );
723  if( busEntry )
724  {
725  if( BreakSegments( busEntry->GetPosition(), brokenSegments || aAppend )
726  || BreakSegments( busEntry->m_End(), brokenSegments || aAppend ) )
727  brokenSegments = true;
728  }
729  }
730  }
731 
732  return brokenSegments;
733 }
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 466 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().

467 {
468  GetCanvas()->GetView()->SetCenter( aCenterPoint );
469 
470  if( aWarpPointer )
471  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
472 
473  GetGalCanvas()->Refresh();
474 }
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:600
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:925
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(), and EDA_ITEM::Type().

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

1468 { 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 842 of file sch_edit_frame.cpp.

References ID_DIALOG_ERC.

Referenced by OnLeftClick(), and SetPrintSheetReference().

843 {
844  // Find the ERC dialog if it's open and close it
845  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
846 
847  if( erc )
848  erc->Close( false );
849 }
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 1506 of file sch_edit_frame.cpp.

References EDA_DRAW_FRAME::CommonSettingsChanged().

Referenced by GetNetListerCommand().

1507 {
1509 
1510  ReCreateHToolbar();
1511  ReCreateVToolbar();
1513  Layout();
1514  SendSizeEvent();
1515 }
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 353 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().

354 {
355  if( !aComponent )
356  return;
357 
358  LIB_ID id = aComponent->GetLibId();
359  LIB_PART* part = GetLibPart( id );
360 
361  if( part )
362  {
363  wxString msg;
364 
365  if( !part->HasConversion() )
366  {
367  msg.Printf( _( "No alternate body style found for symbol \"%s\" in library \"%s\"." ),
368  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
369  DisplayError( this, msg );
370  return;
371  }
372 
373  STATUS_FLAGS flags = aComponent->GetFlags();
374 
375  aComponent->SetConvert( aComponent->GetConvert() + 1 );
376 
377  // ensure m_Convert = 0, 1 or 2
378  // 0 and 1 = shape 1 = not converted
379  // 2 = shape 2 = first converted shape
380  // > 2 is not used but could be used for more shapes
381  // like multiple shapes for a programmable component
382  // When m_Convert = val max, return to the first shape
383  if( aComponent->GetConvert() > 2 )
384  aComponent->SetConvert( 1 );
385 
386  // The alternate symbol may cause a change in the connection status so test the
387  // connections so the connection indicators are drawn correctly.
389  aComponent->ClearFlags();
390  aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
391 
392  RefreshItem( aComponent );
393  OnModify();
394  }
395 }
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 407 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().

408 {
409  m_blockItems.ClearListAndDeleteItems(); // delete previous saved list, if exists
410 
411  wxRect bounds;
412 
413  if( aItemsList.GetCount() > 0 )
414  bounds = aItemsList.GetPickedItem( 0 )->GetBoundingBox();
415 
416  for( unsigned i = 1; i < aItemsList.GetCount(); ++i )
417  bounds.Union( aItemsList.GetPickedItem( i )->GetBoundingBox() );
418 
419  wxPoint center( ( bounds.GetLeft() + bounds.GetRight() ) / 2,
420  ( bounds.GetTop() + bounds.GetBottom() ) / 2 );
421  center = GetNearestGridPosition( center );
422 
423  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
424  {
425  // Clear m_Flag member of selected items:
426  aItemsList.GetPickedItem( ii )->ClearFlags();
427 
428  /* Make a copy of the original picked item. */
429  SCH_ITEM* copy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
430  copy->SetParent( NULL );
431  copy->SetFlags( copy->GetFlags() | UR_TRANSIENT );
432  copy->Move( -center );
433  ITEM_PICKER item( copy, UR_NEW );
434 
435  m_blockItems.PushItem( item );
436  }
437 }
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 1644 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().

1645 {
1646  DrawPageOnClipboard( this );
1647 
1648  if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
1649  {
1650  // fixme-gal
1651  //if( GetScreen()->IsBlockActive() )
1652  //m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
1653 
1655  }
1656 }
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:70
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 584 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().

585 {
587 
588  // Allows only a CAIRO or OPENGL canvas:
592 
593  m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
595 
596  m_useSingleCanvasPane = true;
597 
598  SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
599  UseGalCanvas( true );
600 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:943
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
Definition: draw_frame.h:176
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:926
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 
56  wxPoint pos = GetCrossHairPosition();
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:756
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:756
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 546 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().

547 {
548  if( g_RootSheet == NULL )
549  {
550  g_RootSheet = new SCH_SHEET();
551  }
552 
553  if( g_RootSheet->GetScreen() == NULL )
554  {
555  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
557  g_RootSheet->SetScreen( screen );
559  }
560 
562 
563  m_CurrentSheet->clear();
564  m_CurrentSheet->push_back( g_RootSheet );
565 
566  if( GetScreen() == NULL )
567  {
568  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
570  SetScreen( screen );
571  }
572 
573  GetScreen()->SetZoom( 32.0 );
574 }
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:905
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:756
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 1453 of file sch_edit_frame.h.

Referenced by WriteNetListFile().

1453 { 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(), OnPageSettingsChange(), 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 634 of file schedit.cpp.

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

Referenced by Process_Special_Functions(), and SetPrintSheetReference().

635 {
636  PICKED_ITEMS_LIST pickList;
637  SCH_SCREEN* screen = GetScreen();
638  wxPoint pos = GetCrossHairPosition();
639 
640  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
641  {
642  DeleteItemsInList( pickList );
643  SchematicCleanUp( true );
644  OnModify();
645  }
646 }
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 464 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().

465 {
466  SCH_SCREEN* screen = GetScreen();
467 
468  SetRepeatItem( NULL );
469 
470  if( ( screen->GetCurItem() == NULL ) || !screen->GetCurItem()->IsNew() )
471  return;
472 
473  RemoveFromScreen( screen->GetCurItem() );
475  screen->SetCurItem( NULL );
476 }
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 649 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().

650 {
651  SCH_ITEM* item;
652  SCH_SCREEN* screen = GetScreen();
653 
655 
656  if( item )
657  {
658  bool itemHasConnections = item->IsConnectable();
659 
660  screen->SetCurItem( NULL );
661  SetRepeatItem( NULL );
662  DeleteItem( item );
663 
664  if( itemHasConnections )
666 
667  GetCanvas()->Refresh();
668  OnModify();
669  return true;
670  }
671 
672  return false;
673 }
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::ClearDrawingState(), DeleteItem(), PICKED_ITEMS_LIST::GetCount(), EDA_ITEM::GetFlags(), PICKED_ITEMS_LIST::GetPickedItem(), GetScreen(), and STRUCT_DELETED.

Referenced by DeleteConnection(), GetLastSheetPinPosition(), and HandleBlockEnd().

165 {
166  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
167  {
168  SCH_ITEM* item = static_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
169 
170  if( item->GetFlags() & STRUCT_DELETED )
171  continue;
172 
173  DeleteItem( item, aAppend );
174  aAppend = true;
175  }
176 
178 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:123
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:561