KiCad PCB EDA Suite
SCH_EDIT_FRAME Class Reference

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

#include <schframe.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
 Function GetScreen returns 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)
 
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=0) override
 Function GeneralControl performs 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...
 
const TEMPLATE_FIELDNAMESGetTemplateFieldNames ()
 Return a template field names list for read only access. More...
 
const TEMPLATESGetTemplates ()
 Return the field names template for read only access. 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=NULL) 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
 
void InstallConfigFrame (wxCommandEvent &event)
 
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)
 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 (wxDC *aDC)
 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, bool aWarpMouse)
 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...
 
void SendMessageToPCBNEW (EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
 Send a message to Pcbnew via a socket connection. 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) override
 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, bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits)
 Annotate the components in the schematic that are not currently annotated. More...
 
int CheckAnnotate (wxArrayString *aMessageList, bool aOneSheetOnly)
 Check for annotation errors. More...
 
SCH_SHEET_PATHGetCurrentSheet ()
 
void SetCurrentSheet (const SCH_SHEET_PATH &aSheet)
 
void DisplayCurrentSheet ()
 Draw the current sheet on the display. More...
 
bool SetCurrentSheetHighlightFlags ()
 Set or reset the BRIGHTENED of connected objects inside the current sheet, according to the highlighted net name. More...
 
wxString GetUniqueFilenameForCurrentSheet ()
 
void SetSheetNumberAndCount ()
 Set the m_ScreenNumber and m_NumberOfScreens members for screens. More...
 
void OnPrint (wxCommandEvent &event)
 Show the print dialog. More...
 
wxPageSetupDialogData & GetPageSetupData ()
 
void SetPreviewPosition (const wxPoint &aPoint)
 
void SetPreviewSize (const wxSize &aSize)
 
const wxPointGetPreviewPosition ()
 
const wxSize & GetPreviewSize ()
 
void SetPrintDialogPosition (const wxPoint &aPoint)
 
void SetPrintDialogSize (const wxSize &aSize)
 
const wxPointGetPrintDialogPosition ()
 
const wxSize & GetPrintDialogSize ()
 
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 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 ImportFile (const wxString &aFileName, int aFileType) override
 Load the given filename but sets the path to the current project path. More...
 
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)
 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 CheckJunctionsInList (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 (wxDC *DC)
 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
 
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
 Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the internal units of this particular view. More...
 
const wxPointGetAuxOrigin () const override
 Function GetAuxOrigin returns the origin of the axis used for plotting and various exports. More...
 
void SetAuxOrigin (const wxPoint &aPosition) override
 
const wxPointGetGridOrigin () const override
 Function GetGridOrigin returns the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const wxPoint &aPoint) override
 
COLOR4D GetDrawBgColor () const override
 
void SetDrawBgColor (COLOR4D aColor) override
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
void UpdateStatusBar () override
 Function UpdateStatusBar updates the status bar information. More...
 
COMPONENT_SELECTION SelectComponentFromLibrary (const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
 Function SelectComponentFromLib Calls the library viewer to select component to import into schematic. More...
 
virtual void OnEditSymbolLibTable (wxCommandEvent &aEvent)
 
LIB_ALIASGetLibAlias (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
 Load symbol from symbol library table. More...
 
LIB_PARTGetLibPart (const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
 
COMPONENT_SELECTION SelectComponentFromLibBrowser (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 OnCharHook (wxKeyEvent &event)
 this function capture the key event before it is sent to the GUI. More...
 
bool LockFile (const wxString &aFileName)
 Function LockFile marks a schematic file as being in use. More...
 
void ReleaseFile ()
 Function ReleaseFile Release the current file marked in use. More...
 
wxPoint GetCrossHairPosition (bool aInvertY=false) const
 Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates. More...
 
void SetCrossHairPosition (const wxPoint &aPosition, bool aSnapToGrid=true)
 Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) units. More...
 
wxPoint GetCursorPosition (bool aOnGrid, wxRealPoint *aGridSize=NULL) const
 Function GetCursorPosition returns the current cursor position in logical (drawing) units. More...
 
wxPoint GetNearestGridPosition (const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
 Function GetNearestGridPosition returns the nearest aGridSize location to aPosition. More...
 
wxPoint GetCrossHairScreenPosition () const
 Function GetCursorScreenPosition returns the cross hair position in device (display) units.b. More...
 
void SetMousePosition (const wxPoint &aPosition)
 
wxPoint RefPos (bool useMouse) const
 Function RefPos Return the reference position, coming from either the mouse position or the cursor position. More...
 
const wxPointGetScrollCenterPosition () const
 
void SetScrollCenterPosition (const wxPoint &aPoint)
 
bool GetShowBorderAndTitleBlock () const
 
void SetShowBorderAndTitleBlock (bool aShow)
 
bool ShowPageLimits () const
 
void SetShowPageLimits (bool aShow)
 
EDA_DRAW_PANELGetCanvas ()
 
void OnMenuOpen (wxMenuEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void SkipNextLeftButtonReleaseEvent ()
 function 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
 Function GetHotkeyConfig() Returns a structure containing currently used hotkey mapping. More...
 
virtual void AddMenuZoomAndGrid (wxMenu *aMasterMenu)
 Function AddMenuZoomAndGrid (virtual) 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
 Function GetZoomLevelCoeff returns 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
 
bool GetToolToggled (int aToolId)
 Checks all the toolbars and returns true if the given tool id is toggled. More...
 
virtual void SetToolID (int aId, int aCursor, const wxString &aToolMsg)
 Function SetToolID sets 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
 Function IsGridVisible() , virtual. More...
 
virtual void SetGridVisibility (bool aVisible)
 Function SetGridVisibility() , virtual It may be overloaded by derived classes. More...
 
virtual COLOR4D GetGridColor ()
 Function GetGridColor() , virtual. More...
 
virtual void SetGridColor (COLOR4D aColor)
 Function SetGridColor() , virtual. More...
 
wxPoint GetGridPosition (const wxPoint &aPosition) const
 Function GetGridPosition returns the nearest grid position to aPosition if a screen is defined and snap to grid is enabled. More...
 
virtual void SetNextGrid ()
 Function SetNextGrid() changes the grid size settings to the next one available. More...
 
virtual void SetPrevGrid ()
 Function SetPrevGrid() changes the grid size settings to the previous one available. More...
 
void SetPresetGrid (int aIndex)
 Function SetPresetGrid() changes 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)
 Functions OnSelectZoom sets 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 OnUpdateUnits (wxUpdateUIEvent &aEvent)
 
void OnUpdateCrossHairStyle (wxUpdateUIEvent &aEvent)
 
virtual void OnSize (wxSizeEvent &event)
 Function OnSize recalculates the size of toolbars and display panel when the frame size changes. More...
 
void OnEraseBackground (wxEraseEvent &SizeEvent)
 
virtual void OnZoom (wxCommandEvent &event)
 Function OnZoom Called from any zoom event (toolbar , hotkey or popup ) More...
 
void SetNextZoom ()
 Function SetNextZoom() changes the zoom to the next one available. More...
 
void SetPrevZoom ()
 Function SetPrevZoom() changes the zoom to the previous one available. More...
 
void SetPresetZoom (int aIndex)
 Function SetPresetZoom() changes zoom to one of the preset values. More...
 
void RedrawScreen (const wxPoint &aCenterPoint, bool aWarpPointer)
 Function RedrawScreen redraws the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterPoint at the center of the screen. More...
 
void RedrawScreen2 (const wxPoint &posBefore)
 Function RedrawScreen2 puts the crosshair back to the screen position it had before zooming. More...
 
void Zoom_Automatique (bool aWarpPointer)
 Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void Window_Zoom (EDA_RECT &Rect)
 Compute the zoom factor and the new draw offset to draw the selected area (Rect) in full window screen. More...
 
double GetZoom ()
 Function GetZoom. More...
 
void DrawWorkSheet (wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Function DrawWorkSheet 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)
 Function OnActivate (virtual) is called when activating the frame. More...
 
void DisplayUnitsMsg ()
 Function DisplayUnitsMsg displays current unit pane on the status bar. More...
 
virtual bool HandleBlockBegin (wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
 Initialize a block command. More...
 
void CopyToClipboard (wxCommandEvent &event)
 Function CopyToClipboard copies the current page or the current block to the clipboard. More...
 
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)
 Function SetMsgPanel clears the message panel and populates it with the contents of aList. More...
 
void SetMsgPanel (EDA_ITEM *aItem)
 
virtual void UpdateMsgPanel ()
 Function UpdateMsgPanel redraws the message panel. More...
 
void PushPreferences (const EDA_DRAW_PANEL *aParentCanvas)
 Function PushPreferences Pushes a few preferences from a parent window to a child window. More...
 
wxString CoordinateToString (int aValue, bool aConvertToMils=false) const
 Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inches or mm according to the current user units setting. More...
 
wxString LengthDoubleToString (double aValue, bool aConvertToMils=false) const
 Function LengthDoubleToString is a helper to convert the double value aValue to a string in inches or mm according to the current user units setting. More...
 
virtual void UseGalCanvas (bool aEnable)
 Function UseGalCanvas used to switch between standard and GAL-based canvas. 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
 Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame. More...
 
void SetGalCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
TOOL_MANAGERGetToolManager () const
 Function GetToolManager returns the tool manager instance, if any. More...
 
virtual void * GetDisplayOptions ()
 Function GetDisplayOptions A way to pass info to draw functions. More...
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for rendering. More...
 
VTBL_ENTRY void ReadPcbNetlist (const wxString &aNetlistFileName, const wxString &aCmpFileName, REPORTER *aReporter, bool aChangeFootprint, bool aDeleteBadTracks, bool aDeleteExtraFootprints, bool aSelectByTimestamp, bool aDeleteSinglePadNets, bool aIsDryRun)
 Function ReadPcbNetlist provides access to PcbNew's function ReadPcbNetlist. More...
 
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...
 
bool Enable (bool enable) override
 
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)
 
void PrintMsg (const wxString &text)
 
wxString ConfigBaseName ()
 Function ConfigBaseName. More...
 
virtual void OnSelectPreferredEditor (wxCommandEvent &event)
 Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit or display files (reports ... More...
 
int ReadHotkeyConfig (struct EDA_HOTKEY_CONFIG *aDescList)
 Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys. More...
 
int ReadHotkeyConfigFile (const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
 Function ReadHotkeyConfigFile Read an old configuration file (&ltfile&gt.key) and fill the current hotkey list with hotkeys. 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...
 
virtual void ShowChangedLanguage ()
 Function ShowChangedLanguage redraws the menus and what not in current language. More...
 
virtual void ShowChangedIcons ()
 Function ShowChangedIcons redraws items menus after a icon was changed option. More...
 
void AddMenuIconsOptions (wxMenu *MasterMenu)
 Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice, and add it as submenu to MasterMenu. 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 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 addCurrentItemToList (bool aRedraw=true)
 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...
 
void SetScreen (BASE_SCREEN *aScreen)
 
virtual void unitsChangeRefresh ()
 Function unitsChangeRefresh is 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 GeneralControlKeyMovement (int aHotKey, wxPoint *aPos, bool aSnapToGrid)
 Function GeneralControlKeyMovement 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
 
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting () const
 Returns the canvas type stored in the application settings. More...
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
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 OnChangeIconsOptions (wxCommandEvent &event) override
 Function OnChangeIconsOptions is an event handler called on a icons options in menus or toolbars 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...
 
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_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...
 
wxChoice * m_gridSelectBox
 Choice box to choose the grid size. More...
 
wxChoice * m_zoomSelectBox
 Choice box to choose the zoom value. More...
 
wxAuiToolBar * m_drawToolBar
 The tool bar that contains the buttons for quick access to the application draw tools. More...
 
wxAuiToolBar * m_optionsToolBar
 The options tool bar typcially located on the left edge of the main window. More...
 
EDA_MSG_PANELm_messagePanel
 Panel used to display information at the bottom of the main window. More...
 
int m_MsgFrameHeight
 
bool m_movingCursorWithKeyboard
 One-shot to avoid a recursive mouse event during hotkey movement. More...
 
bool m_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 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...
 
void 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, wxDC *aDC)
 Start moving aItem using the mouse. More...
 
SCH_TEXTCreateNewText (wxDC *aDC, 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 an other one. More...
 
void BeginSegment (wxDC *DC, 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 (wxDC *DC)
 Erase the last segment at the current mouse position. More...
 
void DeleteConnection (bool DeleteFullConnection)
 
void Edge (DRAWSEGMENT *Segment, wxDC *DC)
 
void SetNewWidth (DRAWSEGMENT *DrawSegm, wxDC *DC)
 
void Layer (DRAWSEGMENT *Segment, wxDC *DC)
 
DRAWSEGMENTBegin_Edge (DRAWSEGMENT *Segment, wxDC *DC)
 
SCH_BITMAPCreateNewImage (wxDC *aDC)
 
void MoveImage (SCH_BITMAP *aItem, 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...
 
bool LoadCacheLibrary (const wxString &aFileName)
 Loads the cache library associated to the aFileName. More...
 
int EditLine (SCH_LINE *aLine, bool aRedraw)
 Function EditLine displays the dialog for editing the parameters of aLine. More...
 
bool validateSheet (SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
 
SCH_SHEET_PINCreateSheetPin (SCH_SHEET *aSheet, wxDC *aDC)
 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, wxDC *aDC)
 Automatically create a sheet pin from the hierarchical labels in the schematic referenced by aSheet. More...
 
SCH_COMPONENTLoad_Component (wxDC *aDC, 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, wxDC *DC)
 
void SetInitCmp (SCH_COMPONENT *DrawComponent, wxDC *DC)
 
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 edition. More...
 
void GetSchematicFromUndoList (wxCommandEvent &event)
 Perform an undo the last edition. More...
 
void copyBlockItems (PICKED_ITEMS_LIST &aItemsList)
 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
 
wxPoint m_previewPosition
 
wxSize m_previewSize
 
wxPoint m_printDialogPosition
 
wxSize m_printDialogSize
 
bool m_printMonochrome
 Print monochrome instead of grey scale. More...
 
bool m_printSheetReference
 
DIALOG_SCH_FINDm_dlgFindReplace
 
wxPoint m_findDialogPosition
 
wxSize m_findDialogSize
 
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...
 
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 118 of file schframe.h.

Member Typedef Documentation

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

Definition at line 170 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 schframe.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 g_RootSheet;
462  delete m_findReplaceData;
463 
464  m_CurrentSheet = NULL;
465  m_undoItem = NULL;
466  g_RootSheet = NULL;
467  m_findReplaceData = NULL;
468 }
virtual void OnEditSymbolLibTable(wxCommandEvent &aEvent)
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:141
wxFindReplaceData * m_findReplaceData
Definition: schframe.h:128
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:121
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
Definition: schframe.h:141
SCH_ITEM * m_undoItem
Copy of the current item being edited.
Definition: schframe.h:145

Member Function Documentation

void SCH_EDIT_FRAME::addCurrentItemToList ( bool  aRedraw = true)
protected

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

Parameters
aRedraw= true (default) to redrw -the screen after adding the item.

Definition at line 1356 of file schframe.cpp.

References SCH_SCREEN::Append(), SCH_SCREEN::CheckIfOnDrawList(), EDA_ITEM::ClearFlags(), p2t::cmp(), SCH_ITEM::GetConnectionPoints(), SCH_SCREEN::GetCurItem(), EDA_ITEM::GetParent(), 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(), SCH_SCREEN::TestDanglingEnds(), EDA_ITEM::Type(), UR_CHANGED, and UR_NEW.

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

1357 {
1358  SCH_SCREEN* screen = GetScreen();
1359  SCH_ITEM* item = screen->GetCurItem();
1360 
1361  wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
1362 
1363  m_canvas->SetAutoPanRequest( false );
1364 
1365  SCH_ITEM* undoItem = item;
1366 
1367  if( item->Type() == SCH_SHEET_PIN_T )
1368  {
1369  SCH_SHEET* sheet = (SCH_SHEET*) item->GetParent();
1370 
1371  wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
1372  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1373 
1374  undoItem = sheet;
1375  }
1376 
1377  else if( item->Type() == SCH_FIELD_T )
1378  {
1379  SCH_COMPONENT* cmp = (SCH_COMPONENT*) item->GetParent();
1380 
1381  wxCHECK_RET( (cmp != NULL) && (cmp->Type() == SCH_COMPONENT_T),
1382  wxT( "Cannot place field in invalid schematic component object." ) );
1383 
1384  undoItem = cmp;
1385  }
1386 
1387  if( item->IsNew() )
1388  {
1389  if( item->Type() == SCH_SHEET_T )
1390  {
1391  // Fix the size and position of the new sheet using the last values set by
1392  // the m_mouseCaptureCallback function.
1393  m_canvas->SetMouseCapture( NULL, NULL );
1394 
1395  if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet ) )
1396  {
1397  screen->SetCurItem( NULL );
1398  delete item;
1399 
1400  if( aRedraw )
1401  GetCanvas()->Refresh();
1402 
1403  return;
1404  }
1405 
1407  }
1408 
1409  if( undoItem == item )
1410  {
1411  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1412  screen->Append( item );
1413 
1414  SetRepeatItem( item );
1415 
1416  SaveCopyInUndoList( undoItem, UR_NEW );
1417  }
1418  else
1419  {
1420  // Here, item is not a basic schematic item, but an item inside
1421  // a parent basic schematic item,
1422  // currently: sheet pin or component field.
1423  // currently, only a sheet pin can be found as new item,
1424  // because new component fields have a specific handling, and do not appears here
1425  SaveCopyInUndoList( undoItem, UR_CHANGED );
1426 
1427  if( item->Type() == SCH_SHEET_PIN_T )
1428  ( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item );
1429  else
1430  wxLogMessage( wxT( "addCurrentItemToList: expected type = SCH_SHEET_PIN_T, actual type = %d" ),
1431  item->Type() );
1432  }
1433  }
1434  else
1435  {
1436  SaveUndoItemInUndoList( undoItem );
1437  }
1438 
1439  item->ClearFlags();
1440  screen->SetModify();
1441  screen->SetCurItem( NULL );
1442  m_canvas->SetMouseCapture( NULL, NULL );
1444 
1445  if( item->IsConnectable() )
1446  {
1447  std::vector< wxPoint > pts;
1448  item->GetConnectionPoints( pts );
1449  for( auto i = pts.begin(); i != pts.end(); i++ )
1450  {
1451  for( auto j = i + 1; j != pts.end(); j++ )
1452  TrimWire( *i, *j, true );
1453 
1454  if( screen->IsJunctionNeeded( *i, true ) )
1455  AddJunction( *i, true );
1456  }
1457  screen->TestDanglingEnds();
1458  }
1459 
1460  if( aRedraw )
1461  GetCanvas()->Refresh();
1462 }
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:225
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
bool IsNew() const
Definition: base_struct.h:243
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:350
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:331
EDA_ITEM * GetParent() const
Definition: base_struct.h:235
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
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...
Definition: schframe.cpp:609
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:121
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
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 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...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
void SetAutoPanRequest(bool aEnable)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
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:93
void Append(SCH_ITEM *aItem)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schframe.cpp:497
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:877
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:281
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:45
bool cmp(const Point *a, const Point *b)
Definition: shapes.h:219
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:200
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
SCH_JUNCTION * SCH_EDIT_FRAME::AddJunction ( const wxPoint aPosition,
bool  aPutInUndoList = false 
)
private

Add a new junction at aPosition.

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

References SCH_SCREEN::Append(), BreakSegments(), GetScreen(), OnModify(), SaveCopyInUndoList(), SCH_SCREEN::TestDanglingEnds(), and UR_NEW.

Referenced by CheckJunctionsInList(), EndSegment(), OnLeftClick(), and Process_Special_Functions().

641 {
642  SCH_JUNCTION* junction = new SCH_JUNCTION( aPosition );
643  SCH_SCREEN* screen = GetScreen();
644  bool broken_segments = false;
645 
646  screen->Append( junction );
647  broken_segments = BreakSegments( aPosition, aAppend );
648  screen->TestDanglingEnds();
649  OnModify();
650  SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
651  return junction;
652 }
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
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...
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
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 Append(SCH_ITEM *aItem)
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:877
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 645 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 OnRightClick().

646 {
647  wxString msg;
648  SCH_SCREEN* screen = GetScreen();
649 
650  msg = AddHotkeyName( _( "Delete Junction" ), g_Schematic_Hokeys_Descr, HK_DELETE );
651  AddMenuItem( aMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
652 
653  if( !aJunction->IsNew() )
654  {
656  AddMenuItem( aMenu, ID_SCH_DRAG_ITEM, _( "Drag Junction" ), KiBitmap( drag_xpm ) );
657 
658  if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) )
659  AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
660  KiBitmap( break_line_xpm ) );
661  }
662 
663  if( screen->GetWireOrBus( aJunction->GetPosition() ) )
664  {
665  AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
666  KiBitmap( delete_node_xpm ) );
667  AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
668  KiBitmap( delete_connection_xpm ) );
669  }
670 }
bool IsNew() const
Definition: base_struct.h:243
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:55
SCH_COLLECTOR m_collectedItems
List of collected items.
Definition: schframe.h:143
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
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:88
SCH_LINE * GetWire(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
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:917
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]
void EDA_BASE_FRAME::AddMenuIconsOptions ( wxMenu *  MasterMenu)
inherited

Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice, and add it as submenu to MasterMenu.

Parameters
MasterMenuThe main menu. The sub menu list will be accessible from the menu item with id ID_KICAD_SELECT_ICONS_OPTIONS

Definition at line 692 of file basicframe.cpp.

References AddMenuItem(), ID_KICAD_SELECT_ICONS_IN_MENUS, ID_KICAD_SELECT_ICONS_OPTIONS, KiBitmap(), and Pgm().

Referenced by preparePreferencesMenu(), PL_EDITOR_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), and GERBVIEW_FRAME::ReCreateMenuBar().

693 {
694  wxMenu* menu = NULL;
695  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
696 
697  if( item ) // This menu exists, do nothing
698  return;
699 
700  menu = new wxMenu;
701 
702  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
703  _( "Icons in Menus" ), wxEmptyString,
704  wxITEM_CHECK ) );
705  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
706 
707  AddMenuItem( MasterMenu, menu,
709  _( "Icons Options" ),
710  _( "Select show icons in menus and icons sizes" ),
711  KiBitmap( icon_xpm ) );
712 }
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:55
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
void EDA_DRAW_FRAME::AddMenuZoomAndGrid ( wxMenu *  aMasterMenu)
virtualinherited

Function AddMenuZoomAndGrid (virtual) 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 239 of file zoom.cpp.

References AddHotkeyName(), AddMenuItem(), BASE_SCREEN::BuildGridsChoiceList(), g_UserUnit, BASE_SCREEN::GetGrid(), BASE_SCREEN::GetGridCount(), EDA_DRAW_PANEL::GetScreen(), BASE_SCREEN::GetZoom(), HK_ZOOM_AUTO, HK_ZOOM_CENTER, HK_ZOOM_IN, HK_ZOOM_OUT, HK_ZOOM_REDRAW, 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().

240 {
241  int maxZoomIds;
242  double zoom;
243  wxString msg;
244  BASE_SCREEN* screen = m_canvas->GetScreen();
245 
246  msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER );
247  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
248  msg = AddHotkeyName( _( "Zoom in" ), m_hotkeysDescrList, HK_ZOOM_IN );
249  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) );
250  msg = AddHotkeyName( _( "Zoom out" ), m_hotkeysDescrList, HK_ZOOM_OUT );
251  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) );
252  msg = AddHotkeyName( _( "Redraw view" ), m_hotkeysDescrList, HK_ZOOM_REDRAW );
253  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) );
254  msg = AddHotkeyName( _( "Zoom auto" ), m_hotkeysDescrList, HK_ZOOM_AUTO );
255  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) );
256 
257 
258  wxMenu* zoom_choice = new wxMenu;
259  AddMenuItem( MasterMenu, zoom_choice,
260  ID_POPUP_ZOOM_SELECT, _( "Zoom Select" ),
261  KiBitmap( zoom_selection_xpm ) );
262 
263  zoom = screen->GetZoom();
265  maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ?
266  maxZoomIds : screen->m_ZoomList.size();
267 
268  // Populate zoom submenu.
269  for( int i = 0; i < maxZoomIds; i++ )
270  {
271  msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );
272 
273  zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
274  wxEmptyString, wxITEM_CHECK );
275  if( zoom == screen->m_ZoomList[i] )
276  zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
277  }
278 
279  // Create grid submenu as required.
280  if( screen->GetGridCount() )
281  {
282  wxMenu* gridMenu = new wxMenu;
283  AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
284  _( "Grid Select" ), KiBitmap( grid_select_xpm ) );
285 
286  wxArrayString gridsList;
287  int icurr = screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES );
288 
289  for( unsigned i = 0; i < gridsList.GetCount(); i++ )
290  {
291  GRID_TYPE& grid = screen->GetGrid( i );
292  gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
293 
294  if( (int)i == icurr )
295  gridMenu->Check( grid.m_CmdId, true );
296  }
297  }
298 
299  MasterMenu->AppendSeparator();
300  AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
301 }
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:55
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
size_t GetGridCount() const
Function GetGridCount().
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:77
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: common.h:145
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:86
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.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
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 655 of file bus-wire-junction.cpp.

References SCH_SCREEN::Append(), GetScreen(), EDA_DRAW_FRAME::m_canvas, OnModify(), EDA_DRAW_PANEL::Refresh(), SaveCopyInUndoList(), SchematicCleanUp(), SetRepeatItem(), and UR_NEW.

Referenced by OnLeftClick().

656 {
657  SCH_NO_CONNECT* no_connect = new SCH_NO_CONNECT( aPosition );
658 
659  SetRepeatItem( no_connect );
660  GetScreen()->Append( no_connect );
662  OnModify();
663  m_canvas->Refresh();
664  SaveCopyInUndoList( no_connect, UR_NEW );
665  return no_connect;
666 }
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
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.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void Append(SCH_ITEM *aItem)
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 305 of file schframe.h.

References TEMPLATES::AddTemplateFieldName().

Referenced by OnPreferencesOptions().

306  {
307  return m_TemplateFieldNames.AddTemplateFieldName( aFieldName );
308  }
int AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName)
Function AddTemplateFieldName inserts or appends a wanted symbol field name into the fieldnames templ...
TEMPLATES m_TemplateFieldNames
Definition: schframe.h:184
void EDA_DRAW_FRAME::AdjustScrollBars ( const wxPoint aCenterPosition)
inherited

Definition at line 922 of file draw_frame.cpp.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetLeft(), EDA_DRAW_FRAME::GetPageSizeIU(), BOX2< Vec >::GetRight(), BASE_SCREEN::GetScalingFactor(), EDA_DRAW_FRAME::GetScreen(), BOX2< Vec >::GetSize(), BOX2< Vec >::GetTop(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), KiROUND(), EDA_DRAW_FRAME::m_canvas, BASE_SCREEN::m_Center, BASE_SCREEN::m_DrawOrg, BASE_SCREEN::m_ScrollbarNumber, BASE_SCREEN::m_ScrollbarPos, BASE_SCREEN::m_ScrollPixelsPerUnitX, BASE_SCREEN::m_ScrollPixelsPerUnitY, min, BOX2< Vec >::MoveBottomTo(), BOX2< Vec >::MoveLeftTo(), BOX2< Vec >::MoveRightTo(), BOX2< Vec >::MoveTopTo(), scale, EDA_DRAW_FRAME::SetScrollCenterPosition(), traceScrollSettings(), VIRT_MAX, VIRT_MIN, wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by EDA_DRAW_FRAME::RedrawScreen(), EDA_DRAW_FRAME::RedrawScreen2(), and EDA_DRAW_FRAME::UseGalCanvas().

923 {
924  BASE_SCREEN* screen = GetScreen();
925 
926  if( !screen || !m_canvas )
927  return;
928 
929  double scale = screen->GetScalingFactor();
930 
931  wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
932  aCenterPositionIU.x, aCenterPositionIU.y, scale );
933 
934  // Calculate the portion of the drawing that can be displayed in the
935  // client area at the current zoom level.
936 
937  // visible viewport in device units ~ pixels
938  wxSize clientSizeDU = m_canvas->GetClientSize();
939 
940  // Size of the client window in IU
941  DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
942 
943  // Full drawing or "page" rectangle in internal units
944  DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
945 
946  // Account for scrollbars
947  wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
948  wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);
949  wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2;
950 
951  // The upper left corner of the client rectangle in internal units.
952  double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0;
953  double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0;
954 
955  // If drawn around the center, adjust the client rectangle accordingly.
956  if( screen->m_Center )
957  {
958  // half page offset.
959  xIU += pageRectIU.GetWidth() / 2.0;
960  yIU += pageRectIU.GetHeight() / 2.0;
961  }
962 
963  DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
964  wxPoint centerPositionIU;
965 
966  // put "int" limits on the clientRect
967  if( clientRectIU.GetLeft() < VIRT_MIN )
968  clientRectIU.MoveLeftTo( VIRT_MIN );
969  if( clientRectIU.GetTop() < VIRT_MIN )
970  clientRectIU.MoveTopTo( VIRT_MIN );
971  if( clientRectIU.GetRight() > VIRT_MAX )
972  clientRectIU.MoveRightTo( VIRT_MAX );
973  if( clientRectIU.GetBottom() > VIRT_MAX )
974  clientRectIU.MoveBottomTo( VIRT_MAX );
975 
976  centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
977  centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
978 
979  if( screen->m_Center )
980  {
981  centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
982  centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
983  }
984 
985  DSIZE virtualSizeIU;
986 
987  if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
988  {
989  virtualSizeIU.x = pageRectIU.GetSize().x;
990  }
991  else
992  {
993  double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
994  double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
995 
996  if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
997  {
998  if( pageCenterX > clientCenterX )
999  virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
1000  else if( pageCenterX < clientCenterX )
1001  virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
1002  else
1003  virtualSizeIU.x = clientRectIU.GetWidth();
1004  }
1005  else
1006  {
1007  if( pageCenterX > clientCenterX )
1008  virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
1009  else if( pageCenterX < clientCenterX )
1010  virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
1011  else
1012  virtualSizeIU.x = pageRectIU.GetWidth();
1013  }
1014  }
1015 
1016  if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
1017  {
1018  virtualSizeIU.y = pageRectIU.GetSize().y;
1019  }
1020  else
1021  {
1022  double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
1023  double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
1024 
1025  if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
1026  {
1027  if( pageCenterY > clientCenterY )
1028  virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
1029  else if( pageCenterY < clientCenterY )
1030  virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
1031  else
1032  virtualSizeIU.y = clientRectIU.GetHeight();
1033  }
1034  else
1035  {
1036  if( pageCenterY > clientCenterY )
1037  virtualSizeIU.y = pageRectIU.GetHeight() +
1038  ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
1039  else if( pageCenterY < clientCenterY )
1040  virtualSizeIU.y = pageRectIU.GetHeight() +
1041  ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
1042  else
1043  virtualSizeIU.y = pageRectIU.GetHeight();
1044  }
1045  }
1046 
1047  // put "int" limits on the virtualSizeIU
1048  virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
1049  virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
1050 
1051  if( screen->m_Center )
1052  {
1053  screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
1054  screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
1055  }
1056  else
1057  {
1058  screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
1059  screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
1060  }
1061 
1062  /* Always set scrollbar pixels per unit to 1 unless you want the zoom
1063  * around cursor to jump around. This reported problem occurs when the
1064  * zoom point is not on a pixel per unit increment. If you set the
1065  * pixels per unit to 10, you have potential for the zoom point to
1066  * jump around +/-5 pixels from the nearest grid point.
1067  */
1068  screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
1069 
1070  // Number of scroll bar units for the given zoom level in device units.
1071  double unitsX = virtualSizeIU.x * scale;
1072  double unitsY = virtualSizeIU.y * scale;
1073 
1074  // Store the requested center position for later use
1075  SetScrollCenterPosition( aCenterPositionIU );
1076 
1077  // Calculate the scroll bar position in internal units to place the
1078  // center position at the center of client rectangle.
1079  double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
1080  double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
1081 
1082  // Convert scroll bar position to device units.
1083  posX = KiROUND( posX * scale );
1084  posY = KiROUND( posY * scale );
1085 
1086  if( posX < 0 )
1087  {
1088  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1089  posX = 0;
1090  }
1091 
1092  if( posX > unitsX )
1093  {
1094  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1095  posX = unitsX;
1096  }
1097 
1098  if( posY < 0 )
1099  {
1100  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1101  posY = 0;
1102  }
1103 
1104  if( posY > unitsY )
1105  {
1106  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1107  posY = unitsY;
1108  }
1109 
1110  screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
1111  screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
1112 
1113  wxLogTrace( traceScrollSettings,
1114  wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
1115  virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
1116  screen->m_DrawOrg.x, screen->m_DrawOrg.y,
1118  screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
1119  screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
1120 
1121  bool noRefresh = true;
1122 
1123  m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
1124  screen->m_ScrollPixelsPerUnitY,
1125  screen->m_ScrollbarNumber.x,
1126  screen->m_ScrollbarNumber.y,
1127  screen->m_ScrollbarPos.x,
1128  screen->m_ScrollbarPos.y, noRefresh );
1129 }
wxSize m_ScrollbarNumber
Current virtual draw area size in scroll units.
#define VIRT_MAX
max X or Y coordinate in virtual space
Definition: draw_frame.cpp:919
int m_ScrollPixelsPerUnitY
Pixels per scroll unit in the vertical direction.
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
#define VIRT_MIN
min X or Y coordinate in virtual space
Definition: draw_frame.cpp:918
void SetScrollCenterPosition(const wxPoint &aPoint)
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
virtual const wxSize GetPageSizeIU() const =0
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:341
bool m_Center
Center on screen.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
int m_ScrollPixelsPerUnitX
Pixels per scroll unit in the horizontal direction.
wxPoint m_ScrollbarPos
Current scroll bar position in scroll units.
static const wxString traceScrollSettings(wxT("KicadScrollSettings"))
Definition for enabling and disabling scroll bar setting trace output.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
static const double MAX_AXIS
Definition: draw_frame.cpp:916
const int scale
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
#define min(a, b)
Definition: auxiliary.h:85
void SCH_EDIT_FRAME::AnnotateComponents ( bool  aAnnotateSchematic,
ANNOTATE_ORDER_T  aSortOption,
ANNOTATE_OPTION_T  aAlgoOption,
bool  aResetAnnotation,
bool  aRepairTimestamps,
bool  aLockUnits 
)

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

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 60 of file annotate.cpp.

References SCH_REFERENCE_LIST::Annotate(), CheckAnnotate(), DeleteAnnotation(), DisplayInfoMessage(), g_RootSheet, SCH_SHEET_PATH::GetComponents(), SCH_SHEET_LIST::GetComponents(), SCH_SHEET_PATH::GetMultiUnitComponents(), SCH_SHEET_LIST::GetMultiUnitComponents(), INCREMENTAL_BY_REF, EDA_DRAW_FRAME::m_canvas, m_CurrentSheet, OnModify(), EDA_DRAW_PANEL::Refresh(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), 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(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and SCH_REFERENCE_LIST::UpdateAnnotation().

Referenced by DIALOG_ANNOTATE::OnApplyClick().

66 {
67  SCH_REFERENCE_LIST references;
68 
69  SCH_SCREENS screens;
70 
71  // Build the sheet list.
72  SCH_SHEET_LIST sheets( g_RootSheet );
73 
74  // Map of locked components
75  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
76 
77  // Test for and replace duplicate time stamps in components and sheets. Duplicate
78  // time stamps can happen with old schematics, schematic conversions, or manual
79  // editing of files.
80  if( aRepairTimestamps )
81  {
82  int count = screens.ReplaceDuplicateTimeStamps();
83 
84  if( count )
85  {
86  wxString msg;
87  msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
88  DisplayInfoMessage( NULL, msg );
89  }
90  }
91 
92  // If units must be locked, collect all the sets that must be annotated together.
93  if( aLockUnits )
94  {
95  if( aAnnotateSchematic )
96  {
97  sheets.GetMultiUnitComponents( lockedComponents );
98  }
99  else
100  {
101  m_CurrentSheet->GetMultiUnitComponents( lockedComponents );
102  }
103  }
104 
105  // If it is an annotation for all the components, reset previous annotation.
106  if( aResetAnnotation )
107  DeleteAnnotation( !aAnnotateSchematic );
108 
109  // Set sheet number and number of sheets.
111 
112  // Build component list
113  if( aAnnotateSchematic )
114  {
115  sheets.GetComponents( references );
116  }
117  else
118  {
119  m_CurrentSheet->GetComponents( references );
120  }
121 
122  // Break full components reference in name (prefix) and number:
123  // example: IC1 become IC, and 1
124  references.SplitReferences();
125 
126  switch( aSortOption )
127  {
128  default:
129  case SORT_BY_X_POSITION:
130  references.SortByXCoordinate();
131  break;
132 
133  case SORT_BY_Y_POSITION:
134  references.SortByYCoordinate();
135  break;
136  }
137 
138  bool useSheetNum = false;
139  int idStep = 100;
140 
141  switch( aAlgoOption )
142  {
143  default:
144  case INCREMENTAL_BY_REF:
145  break;
146 
147  case SHEET_NUMBER_X_100:
148  useSheetNum = true;
149  break;
150 
151  case SHEET_NUMBER_X_1000:
152  useSheetNum = true;
153  idStep = 1000;
154  break;
155  }
156 
157  // Recalculate and update reference numbers in schematic
158  references.Annotate( useSheetNum, idStep, lockedComponents );
159  references.UpdateAnnotation();
160 
161  wxArrayString errors;
162 
163  // Final control (just in case ... ).
164  if( CheckAnnotate( &errors, !aAnnotateSchematic ) )
165  {
166  wxString msg;
167 
168  for( size_t i = 0; i < errors.GetCount(); i++ )
169  msg += errors[i];
170 
171  // wxLogWarning is a cheap and dirty way to dump a potentially long list of
172  // strings to a dialog that can be saved to a file. This should be replaced
173  // by a more elegant solution.
174  wxLogWarning( msg );
175  }
176 
177  OnModify();
178 
179  // Update on screen references, that can be modified by previous calculations:
182 
183  m_canvas->Refresh( true );
184 }
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.
Annotate using the first free reference number starting at the sheet number * 100.
Definition: schframe.h:96
void SortByYCoordinate()
Function sortByYCoordinate sorts the list of references by Y position.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
int CheckAnnotate(wxArrayString *aMessageList, bool aOneSheetOnly)
Check for annotation errors.
Definition: annotate.cpp:187
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
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.
Definition: schframe.h:121
void UpdateAnnotation()
function UpdateAnnotation Updates the reference components for the schematic project (or the current ...
Annotate by X position from left to right.
Definition: schframe.h:86
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
void SortByXCoordinate()
Function sortByXCoordinate sorts the list of references by X position.
void DeleteAnnotation(bool aCurrentSheetOnly)
Clear the current component annotation.
Definition: annotate.cpp:39
void Annotate(bool aUseSheetNum, int aSheetIntervalId, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap)
Function Annotate set the reference designators in the list that have not been annotated.
Annotate by Y position from top to bottom.
Definition: schframe.h:87
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:104
Annotate incrementally using the first free reference number.
Definition: schframe.h:95
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...
Annotate using the first free reference number starting at the sheet number * 1000.
Definition: schframe.h:98
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schframe.cpp:497
void SplitReferences()
Function SplitReferences attempts to split all reference designators into a name (U) and number (1)...
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 ...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
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 764 of file 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(), SCH_PRINTOUT::OnPrintPage(), OpenProjectFiles(), LIB_VIEW_FRAME::RedrawActiveWindow(), SaveEEFile(), LIB_EDIT_FRAME::saveLibrary(), PCB_EDIT_FRAME::SavePcbFile(), ShowNewTrackWhenMovingCursor(), and PCB_EDIT_FRAME::Solve().

767 {
768  if( m_messagePanel == NULL )
769  return;
770 
771  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
772 }
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:129
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 385 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(), 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(), SCH_SCREENS::GetLibNicknames(), GetNewTimeStamp(), LIB_TABLE_ROW::GetOptions(), GetScreen(), SCH_SCREEN::GetSheet(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName(), SYMBOL_LIB_TABLE_ROW::GetType(), LIB_TABLE::HasLibrary(), ID_POPUP_GRID_LEVEL_1000, LIB_TABLE::IsEmpty(), IsOK(), KIWAY_HOLDER::Kiway(), SCH_PLUGIN::Load(), LIB_TABLE::Load(), EDA_DRAW_FRAME::m_canvas, EDA_DRAW_FRAME::m_LastGridSizeId, name, OnModify(), KIWAY_HOLDER::Prj(), EDA_DRAW_PANEL::Refresh(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), SchematicFileWildcard(), BASE_SCREEN::SetGrid(), SCH_SHEET::SetName(), SetSheetNumberAndCount(), EDA_ITEM::SetTimeStamp(), SCH_COLLECTOR::SheetsOnly, SCH_SHEET_LIST::TestForRecursion(), SCH_SCREENS::UpdateSymbolLinks(), IO_ERROR::What(), and EDA_DRAW_FRAME::Zoom_Automatique().

Referenced by OnAppendProject().

386 {
387  wxString msg;
388  wxString fullFileName;
389 
390  SCH_SCREEN* screen = GetScreen();
391 
392  if( !screen )
393  {
394  wxLogError( wxT( "Document not ready, cannot import" ) );
395  return false;
396  }
397 
398  // open file chooser dialog
399  wxString path = wxPathOnly( Prj().GetProjectFullName() );
400 
401  wxFileDialog dlg( this, _( "Append Schematic" ), path,
402  wxEmptyString, SchematicFileWildcard(),
403  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
404 
405  if( dlg.ShowModal() == wxID_CANCEL )
406  return false;
407 
408  fullFileName = dlg.GetPath();
409 
410  wxFileName fn = fullFileName;
411 
412  if( fn.IsRelative() )
413  {
414  fn.MakeAbsolute();
415  fullFileName = fn.GetFullPath();
416  }
417 
418  wxString cache_name = PART_LIBS::CacheName( fullFileName );
419 
420  if( !!cache_name )
421  {
422  PART_LIBS* libs = Prj().SchLibs();
423 
424  try
425  {
426  if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
427  lib->SetCache();
428  }
429  catch( const IO_ERROR& ioe )
430  {
431  DisplayError( this, ioe.What() );
432  }
433  }
434 
435  wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
436 
437  // Load the schematic into a temporary sheet.
438  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
439  std::unique_ptr< SCH_SHEET> newSheet( new SCH_SHEET );
440 
441  newSheet->SetFileName( fullFileName );
442 
443  try
444  {
445  pi->Load( fullFileName, &Kiway(), newSheet.get() );
446 
447  if( !pi->GetError().IsEmpty() )
448  {
449  DisplayErrorMessage( this,
450  _( "The entire schematic could not be load. Errors "
451  "occurred attempting to load hierarchical sheet "
452  "schematics." ),
453  pi->GetError() );
454  }
455  }
456  catch( const IO_ERROR& ioe )
457  {
458  msg.Printf( _( "Error occurred loading schematic file '%s'." ), fullFileName );
459  DisplayErrorMessage( this, msg, ioe.What() );
460 
461  msg.Printf( _( "Failed to load schematic '%s'" ), fullFileName );
462  AppendMsgPanel( wxEmptyString, msg, CYAN );
463 
464  return false;
465  }
466 
467  // Make sure any new sheet changes do not cause any recursion issues.
468  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy.
469  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the import.
470 
471  wxFileName destFile = screen->GetFileName();
472 
473  if( destFile.IsRelative() )
474  destFile.MakeAbsolute( Prj().GetProjectPath() );
475 
476  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath( wxPATH_UNIX ) ) )
477  {
478  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
479  "has the sheet <%s> or one of it's subsheets as a parent somewhere in "
480  "the schematic hierarchy." ),
481  destFile.GetFullPath() );
482  DisplayError( this, msg );
483  return false;
484  }
485 
486  wxArrayString names;
487 
488  // Make sure the imported schematic has been remapped to the symbol library table.
489  SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
490 
491  if( newScreens.HasNoFullyDefinedLibIds() )
492  {
493  if( !IsOK( this,
494  "This schematic has not been remapped to the symbol library table. "
495  "Therefore, all of the library symbol links will be broken. Do you "
496  "want to continue?" ) )
497  return false;
498  }
499  else
500  {
501  // If there are symbol libraries in the imported schematic that are not in the
502  // symbol library table of this project, there could be a lot of broken symbol
503  // library links. Attempt to add the missing libraries to the project symbol
504  // library table.
505  newScreens.GetLibNicknames( names );
506  wxArrayString newLibNames;
507 
508  for( auto name : names )
509  {
510  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
511  newLibNames.Add( name );
512  }
513 
514  wxFileName symLibTableFn( fn.GetPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
515 
516  if( !newLibNames.IsEmpty() && symLibTableFn.Exists() && symLibTableFn.IsFileReadable() )
517  {
518  SYMBOL_LIB_TABLE table;
519 
520  try
521  {
522  table.Load( symLibTableFn.GetFullPath() );
523  }
524  catch( const IO_ERROR& ioe )
525  {
526  msg.Printf( _( "An error occurred loading the symbol library table '%s'." ),
527  symLibTableFn.GetFullPath() );
528  DisplayErrorMessage( NULL, msg, ioe.What() );
529  }
530 
531  if( !table.IsEmpty() )
532  {
533  for( auto libName : newLibNames )
534  {
535  if( !table.HasLibrary( libName ) )
536  continue;
537 
538  // Don't expand environment variable because KIPRJMOD will not be correct
539  // for a different project.
540  wxString uri = table.GetFullURI( libName, false );
541 
542  wxFileName newLib;
543 
544  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  {
569  newLibName = wxString::Format( "%s%d", libName, libNameCnt );
570  }
571 
572  SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( newLibName,
573  uri,
574  row->GetType(),
575  row->GetOptions(),
576  row->GetDescr() );
577  Prj().SchSymbolLibTable()->InsertRow( newRow );
578 
579  if( libName != newLibName )
580  newScreens.ChangeSymbolLibNickname( libName, newLibName );
581  }
582  }
583  }
584  }
585 
586  // Check for duplicate sheet names in the current page.
587  wxArrayString duplicateSheetNames;
588  SCH_TYPE_COLLECTOR sheets;
589 
590  sheets.Collect( screen->GetDrawItems(), SCH_COLLECTOR::SheetsOnly );
591 
592  for( int i = 0; i < sheets.GetCount(); ++i )
593  {
594  if( newSheet->GetScreen()->GetSheet( ( ( SCH_SHEET* ) sheets[i] )->GetName() ) )
595  duplicateSheetNames.Add( ( ( SCH_SHEET* ) sheets[i] )->GetName() );
596  }
597 
598  if( !duplicateSheetNames.IsEmpty() )
599  {
600  msg.Printf( "Duplicate sheet names exist on the current page. Do you want to "
601  "automatically rename the duplicate sheet names?" );
602  if( !IsOK( this, msg ) )
603  return false;
604  }
605 
606  SCH_SCREEN* newScreen = newSheet->GetScreen();
607  wxCHECK_MSG( newScreen, false, "No screen defined for imported sheet." );
608 
609  for( auto duplicateName : duplicateSheetNames )
610  {
611  SCH_SHEET* renamedSheet = newScreen->GetSheet( duplicateName );
612 
613  wxCHECK2_MSG( renamedSheet, continue,
614  "Sheet " + duplicateName + " not found in imported schematic." );
615 
616  timestamp_t newtimestamp = GetNewTimeStamp();
617  renamedSheet->SetTimeStamp( newtimestamp );
618  renamedSheet->SetName( wxString::Format( "Sheet%8.8lX", (unsigned long) newtimestamp ) );
619  }
620 
621  // Clear all annotation in the imported schematic to prevent clashes with existing annotation.
622  newScreens.ClearAnnotation();
623 
624  // It is finally save to add the imported schematic.
625  screen->Append( newScreen );
626 
627  SCH_SCREENS allScreens;
628  allScreens.ReplaceDuplicateTimeStamps();
629 
630  OnModify();
631 
632  // redraw base screen (ROOT) if necessary
633  SCH_SCREENS screens( GetCurrentSheet().Last() );
634 
635  screens.UpdateSymbolLinks( true );
637  Zoom_Automatique( false );
639  m_canvas->Refresh( true );
640  return true;
641 }
Class SCH_SHEET_LIST.
int GetCount() const
Function GetCount returns the number of objects in the list.
static const wxString & GetSymbolLibTableFileName()
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: base_struct.h:171
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...
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()
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
SCH_SHEET * GetSheet(const wxString &aName)
Returns a sheet object pointer that is named aName.
Definition: sch_screen.cpp:628
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
const wxString & GetFileName() const
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
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
timestamp_t GetNewTimeStamp()
Definition: common.cpp:166
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
void SetName(const wxString &aName)
Definition: sch_sheet.h:269
const wxString GetType() const override
Return the type of symbol library table represented by this row.
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:577
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:78
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
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:764
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
SCH_ITEM * GetDrawItems() const
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
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)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schframe.cpp:497
void Collect(SCH_ITEM *aBoard, const KICAD_T aScanList[])
Function Collect scans a BOARD_ITEM using this class's Inspector method, which does the collection...
static const KICAD_T SheetsOnly[]
A scan list for schematic sheet items only.
const char * name
bool HasLibrary(const wxString &aNickname) const
Test for the existence of aNickname in the library table.
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.
Object used to load, save, search, and otherwise manipulate symbol library files. ...
size_t GetLibNicknames(wxArrayString &aLibNicknames)
Fetch all of the symbol library nickames into aLibNicknames.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:131
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:230
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 835 of file eeschema/files-io.cpp.

References dummy(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), OnSaveProject(), and YesNoCancelDialog().

Referenced by OnImportProject(), and OpenProjectFiles().

836 {
837  SCH_SCREENS screenList;
838 
839  // Save any currently open and modified project files.
840  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
841  {
842  if( screen->IsModify() )
843  {
844  int response = YesNoCancelDialog( m_parent, _(
845  "The current schematic has been modified. Do you wish to save the changes?" ),
846  wxEmptyString,
847  _( "Save and Load" ),
848  _( "Load Without Saving" )
849  );
850 
851  if( response == wxID_CANCEL )
852  {
853  return false;
854  }
855  else if( response == wxID_YES )
856  {
857  wxCommandEvent dummy;
858  OnSaveProject( dummy );
859  }
860  // else wxID_NO, so do not save
861 
862  break;
863  }
864  }
865 
866  return true;
867 }
SCH_SCREEN * GetNext()
void OnSaveProject(wxCommandEvent &aEvent)
Command event handler to save the entire project and create a component library archive.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
SCH_SCREEN * GetFirst()
int YesNoCancelDialog(wxWindow *aParent, const wxString &aPrimaryMessage, const wxString &aSecondaryMessage, const wxString &aYesButtonText, const wxString &aNoButtonText, const wxString &aCancelButtonText)
Function YesNoCancelDialog displays a yes/no/cancel dialog with aMessage and returns the user respons...
Definition: confirm.cpp:168
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
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_SHEET_LIST::GetComponents(), SCH_REFERENCE_LIST::GetCount(), SCH_COMPONENT::GetField(), STRING_FORMATTER::GetString(), EDA_TEXT::GetText(), EDA_TEXT::IsVisible(), OnModify(), Scan(), EDA_TEXT::SetText(), EDA_TEXT::SetVisible(), 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  OnModify();
125 }
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'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 ...
Definition: schframe.cpp:773
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:175
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:55
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
const PTREE CPTREE
Definition: ptree.h:55
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
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:176
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
unsigned GetCount()
Function GetCount.
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
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:141
DRAWSEGMENT* SCH_EDIT_FRAME::Begin_Edge ( DRAWSEGMENT Segment,
wxDC *  DC 
)
private
void SCH_EDIT_FRAME::BeginSegment ( wxDC *  DC,
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 an other 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 164 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().

165 {
166  SCH_LINE* segment;
167  SCH_LINE* nextSegment;
168  wxPoint cursorpos = GetCrossHairPosition();
169 
170  // We should know if a segment is currently in progress
171  segment = (SCH_LINE*) GetScreen()->GetCurItem();
172  if( segment ) // a current item exists, but not necessary a currently edited item
173  {
174  if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) )
175  {
176  if( segment->GetFlags() )
177  {
178  wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ),
179  segment->GetFlags() );
180  }
181  // no wire, bus or graphic line in progress
182  segment = NULL;
183  }
184  }
185 
186  if( !segment ) // first point : Create the first wire or bus segment
187  {
188  switch( type )
189  {
190  default:
191  segment = new SCH_LINE( cursorpos, LAYER_NOTES );
192  break;
193 
194  case LAYER_WIRE:
195  segment = new SCH_LINE( cursorpos, LAYER_WIRE );
196 
197  /* A junction will be created later, when we'll know the
198  * segment end position, and if the junction is really needed */
199  break;
200 
201  case LAYER_BUS:
202  segment = new SCH_LINE( cursorpos, LAYER_BUS );
203  break;
204  }
205 
206  segment->SetFlags( IS_NEW );
207  s_wires.PushBack( segment );
208  GetScreen()->SetCurItem( segment );
209 
210  // We need 2 segments to go from a given start pin to an end point when the horizontal
211  // and vertical lines only switch is on.
212  if( GetForceHVLines() )
213  {
214  nextSegment = new SCH_LINE( *segment );
215  nextSegment->SetFlags( IS_NEW );
216  s_wires.PushBack( nextSegment );
217  GetScreen()->SetCurItem( nextSegment );
218  }
219 
221  SetRepeatItem( NULL );
222  }
223  else // A segment is in progress: terminates the current segment and add a new segment.
224  {
225  SCH_LINE* prevSegment = segment->Back();
226 
227  // Be aware prevSegment can be null when the horizontal and vertical lines only switch is off
228  // when we create the first segment.
229 
230  if( !GetForceHVLines() )
231  {
232  // If only one segment is needed and it has a zero length, do not create a new one.
233  if( segment->IsNull() )
234  return;
235  }
236  else
237  {
238  wxCHECK_RET( prevSegment != NULL, wxT( "Failed to create second line segment." ) );
239 
240  // If two segments are required and they both have zero length, do not
241  // create a new one.
242  if( prevSegment && prevSegment->IsNull() && segment->IsNull() )
243  return;
244  }
245 
246  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
247 
248  // Terminate the command if the end point is on a pin, junction, or another wire or bus.
249  if( GetScreen()->IsTerminalPoint( cursorpos, segment->GetLayer() ) )
250  {
251  EndSegment();
252  return;
253  }
254 
255  // Create a new segment, and chain it after the current new segment.
256  nextSegment = new SCH_LINE( *segment );
257  nextSegment->SetStartPoint( cursorpos );
258  s_wires.PushBack( nextSegment );
259 
260  segment->SetEndPoint( cursorpos );
261  segment->ClearFlags( IS_NEW );
262  segment->SetFlags( SELECTED );
263  nextSegment->SetFlags( IS_NEW );
264  GetScreen()->SetCurItem( nextSegment );
265  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
266  }
267 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
bool GetForceHVLines() const
Definition: schframe.h:236
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.
Definition: schframe.cpp:471
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:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
#define SELECTED
Definition: base_struct.h:134
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:78
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:93
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.
SCH_LINE * Back() const
Definition: sch_line.h:62
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:281
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
static DLIST< SCH_ITEM > s_wires
double SCH_EDIT_FRAME::BestZoom ( )
overridevirtual

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

Implements EDA_DRAW_FRAME.

Definition at line 718 of file schframe.cpp.

References max.

719 {
720  int dx, dy;
721  wxSize size;
722 
723  dx = GetScreen()->GetPageSettings().GetWidthIU();
724  dy = GetScreen()->GetPageSettings().GetHeightIU();
725 
726  size = m_canvas->GetClientSize();
727 
728  // Reserve no margin because best zoom shows the full page
729  // and margins are already included in function that draws the sheet refernces
730  double margin_scale_factor = 1.0;
731  double zx =(double) dx / ( margin_scale_factor * (double)size.x );
732  double zy = (double) dy / ( margin_scale_factor * (double)size.y );
733 
734  double bestzoom = std::max( zx, zy );
735 
736  SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
737 
738  return bestzoom;
739 }
void SetScrollCenterPosition(const wxPoint &aPoint)
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
#define max(a, b)
Definition: auxiliary.h:86
const PAGE_INFO & GetPageSettings() const
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 55 of file eeschema/block.cpp.

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

56 {
57  int cmd = BLOCK_IDLE;
58 
59  switch( key )
60  {
61  default:
62  cmd = key & 0xFF;
63  break;
64 
65  case 0:
66  cmd = BLOCK_MOVE;
67  break;
68 
69  case GR_KB_SHIFT:
70  cmd = BLOCK_DUPLICATE;
71  break;
72 
73  case GR_KB_ALT:
74  cmd = BLOCK_ROTATE;
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 GR_KB_ALT
Definition: common.h:65
#define GR_KB_SHIFT
Definition: common.h:66
#define GR_KB_SHIFTCTRL
Definition: common.h:67
#define MOUSE_MIDDLE
Definition: common.h:68
#define GR_KB_CTRL
Definition: common.h:64
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 573 of file bus-wire-junction.cpp.

References SCH_SCREEN::Append(), SCH_LINE::GetEndPoint(), GetScreen(), SCH_LINE::GetStartPoint(), SCH_LINE::IsEndPoint(), IsPointOnSegment(), SaveCopyInUndoList(), SCH_LINE::SetEndPoint(), SCH_LINE::SetStartPoint(), UR_CHANGED, and UR_NEW.

Referenced by BreakSegments(), and TrimWire().

575 {
576  if( !IsPointOnSegment( aSegment->GetStartPoint(), aSegment->GetEndPoint(), aPoint )
577  || aSegment->IsEndPoint( aPoint ) )
578  return false;
579 
580  SaveCopyInUndoList( aSegment, UR_CHANGED, aAppend );
581  SCH_LINE* newSegment = new SCH_LINE( *aSegment );
582  SaveCopyInUndoList( newSegment, UR_NEW, true );
583 
584  newSegment->SetStartPoint( aPoint );
585  aSegment->SetEndPoint( aPoint );
586  GetScreen()->Append( newSegment );
587 
588  if( aNewSegment )
589  *aNewSegment = newSegment;
590 
591  return true;
592 }
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
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
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.
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 Append(SCH_ITEM *aItem)
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 595 of file bus-wire-junction.cpp.

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

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

596 {
597  bool brokenSegments = false;
598 
599  for( SCH_ITEM* segment = GetScreen()->GetDrawItems(); segment; segment = segment->Next() )
600  {
601  if( ( segment->Type() != SCH_LINE_T ) || ( segment->GetLayer() == LAYER_NOTES ) )
602  continue;
603 
604  brokenSegments |= BreakSegment( (SCH_LINE*) segment, aPoint, aAppend || brokenSegments );
605  }
606 
607  return brokenSegments;
608 }
EDA_ITEM * Next() const
Definition: base_struct.h:233
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
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 611 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 DisplayCurrentSheet(), ImportFile(), OpenProjectFiles(), and SchematicCleanUp().

612 {
613  bool brokenSegments = false;
614 
615  for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
616  {
617  if( item->Type() == SCH_JUNCTION_T )
618  {
619  SCH_JUNCTION* junction = ( SCH_JUNCTION* ) item;
620 
621  if( BreakSegments( junction->GetPosition(), brokenSegments || aAppend ) )
622  brokenSegments = true;
623  }
624  else
625  {
626  SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( item );
627  if( busEntry )
628  {
629  if( BreakSegments( busEntry->GetPosition(), brokenSegments || aAppend )
630  || BreakSegments( busEntry->m_End(), brokenSegments || aAppend ) )
631  brokenSegments = true;
632  }
633  }
634  }
635 
636  return brokenSegments;
637 }
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:233
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:88
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 168 of file eeschema/netlist.cpp.

References Format(), and g_RootSheet.

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

169 {
170  // I own this list until I return it to the new owner.
171  std::unique_ptr<NETLIST_OBJECT_LIST> ret( new NETLIST_OBJECT_LIST() );
172 
173  // Creates the flattened sheet list:
174  SCH_SHEET_LIST aSheets( g_RootSheet );
175 
176  // Build netlist info
177  bool success = ret->BuildNetListInfo( aSheets );
178 
179  if( !success )
180  {
181  if( updateStatusText )
182  SetStatusText( _( "No Objects" ) );
183  return ret.release();
184  }
185 
186  wxString msg = wxString::Format( _( "Net count = %d" ), int( ret->size() ) );
187 
188  if( updateStatusText )
189  SetStatusText( msg );
190 
191  return ret.release();
192 }
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:55
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::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(), SaveCopyInUndoList(), SCH_TEXT::SetLabelSpinStyle(), and UR_CHANGED.

Referenced by OnRotate().

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  OnModify();
63 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
virtual bool CanIncrementLabel() const override
Definition: sch_text.h:183
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
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:277
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.
int SCH_EDIT_FRAME::CheckAnnotate ( wxArrayString *  aMessageList,
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
aMessageListA wxArrayString to store error messages.
aOneSheetOnlyCheck the current sheet only if true. Otherwise check the entire schematic.

Definition at line 187 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(), prepareForNetlist(), and DIALOG_ERC::TestErc().

188 {
189  // build the screen list
190  SCH_SHEET_LIST sheetList( g_RootSheet );
191  SCH_REFERENCE_LIST componentsList;
192 
193  // Build the list of components
194  if( !aOneSheetOnly )
195  sheetList.GetComponents( componentsList );
196  else
197  m_CurrentSheet->GetComponents( componentsList );
198 
199  return componentsList.CheckAnnotation( aMessageList );
200 }
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.
int CheckAnnotation(wxArrayString *aMessageList)
Function CheckAnnotation check for annotations errors.
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.
Definition: schframe.h:121
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
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 597 of file basicframe.cpp.

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

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

599 {
600  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
601  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
602 
603  wxFileName autoSaveFileName = aFileName;
604 
605  // Check for auto save file.
606  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
607 
608  wxLogTrace( traceAutoSave,
609  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
610 
611  if( !autoSaveFileName.FileExists() )
612  return;
613 
614  wxString msg = wxString::Format( _(
615  "Well this is potentially embarrassing!\n"
616  "It appears that the last time you were editing the file\n"
617  "'%s'\n"
618  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
619  GetChars( aFileName.GetFullName() )
620  );
621 
622  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
623 
624  // Make a backup of the current file, delete the file, and rename the auto save file to
625  // the file name.
626  if( response == wxYES )
627  {
628  // Get the backup file name.
629  wxFileName backupFileName = aFileName;
630  backupFileName.SetExt( aBackupFileExtension );
631 
632  // If an old backup file exists, delete it. If an old copy of the file exists, rename
633  // it to the backup file name
634  if( aFileName.FileExists() )
635  {
636  // Remove the old file backup file.
637  if( backupFileName.FileExists() )
638  wxRemoveFile( backupFileName.GetFullPath() );
639 
640  // Rename the old file to the backup file name.
641  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
642  {
643  msg.Printf( _( "Could not create backup file <%s>" ),
644  GetChars( backupFileName.GetFullPath() ) );
645  wxMessageBox( msg );
646  }
647  }
648 
649  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
650  {
651  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
652  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
653  }
654  }
655  else
656  {
657  wxLogTrace( traceAutoSave,
658  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
659 
660  // Remove the auto save file when using the previous file as is.
661  wxRemoveFile( autoSaveFileName.GetFullPath() );
662  }
663 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
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
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
Definition: wxstruct.h:71
const wxChar traceAutoSave[]
Flag to enable auto save feature debug tracing.
Definition: basicframe.cpp:53
void SCH_EDIT_FRAME::CheckJunctionsInList ( 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 118 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(), SCH_SCREEN::IsJunctionNeeded(), IsPointOnSegment(), SCH_LINE_T, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by HandleBlockEnd(), and HandleBlockPlace().

119 {
120  std::vector< wxPoint > pts;
121  std::vector< wxPoint > connections;
122 
123  GetSchematicConnections( connections );
124  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
125  {
126  SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
127  item->GetConnectionPoints( pts );
128  if( item->Type() == SCH_LINE_T )
129  {
130  SCH_LINE* line = (SCH_LINE*) item;
131  for( auto i : connections )
132  if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
133  pts.push_back( i );
134  }
135  }
136 
137  // We always have some overlapping connection points. Drop duplicates here
138  std::sort( pts.begin(), pts.end(),
139  []( const wxPoint& a, const wxPoint& b ) -> bool
140  { return a.x < b.x || (a.x == b.x && a.y < b.y); } );
141  pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
142 
143  for( auto point : pts )
144  {
145  if( GetScreen()->IsJunctionNeeded( point, true ) )
146  {
147  AddJunction( point, aAppend );
148  aAppend = true;
149  }
150  }
151 }
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:225
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:350
wxPoint GetEndPoint() const
Definition: sch_line.h:80
wxPoint GetStartPoint() const
Definition: sch_line.h:76
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
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.
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 1463 of file schframe.h.

1463 { m_exec_flags &= ~( aFlags ); }
int m_exec_flags
Flags of the wxExecute() function to call a custom net list generator.
Definition: schframe.h:150
wxConfigBase * EDA_BASE_FRAME::config ( )
protectedvirtualinherited
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 268 of file wxstruct.h.

References EDA_BASE_FRAME::m_configFrameName.

Referenced by EDA_BASE_FRAME::LoadSettings(), EDA_DRAW_FRAME::LoadSettings(), EDA_BASE_FRAME::SaveSettings(), and EDA_DRAW_FRAME::SaveSettings().

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

Definition at line 381 of file getpart.cpp.

References EDA_ITEM::ClearFlags(), DisplayError(), SCH_COMPONENT::Draw(), g_GhostColor, g_XorMode, SCH_COMPONENT::GetConvert(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetLibId(), SCH_BASE_FRAME::GetLibPart(), GetScreen(), GR_DEFAULT_DRAWMODE, LIB_PART::HasConversion(), EDA_ITEM::IsMoving(), EDA_DRAW_FRAME::m_canvas, OnModify(), SCH_COMPONENT::SetConvert(), EDA_ITEM::SetFlags(), and SCH_SCREEN::TestDanglingEnds().

Referenced by Process_Special_Functions().

382 {
383  if( !aComponent )
384  return;
385 
386  LIB_ID id = aComponent->GetLibId();
387  LIB_PART* part = GetLibPart( id );
388 
389  if( part )
390  {
391  wxString msg;
392 
393  if( !part->HasConversion() )
394  {
395  msg.Printf( _( "No alternate body style found for symbol '%s' in library '%s'." ),
396  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
397  DisplayError( this, msg );
398  return;
399  }
400 
401  STATUS_FLAGS flags = aComponent->GetFlags();
402 
403  if( aComponent->GetFlags() )
404  aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
405  else
406  aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
407 
408  aComponent->SetConvert( aComponent->GetConvert() + 1 );
409 
410  // ensure m_Convert = 0, 1 or 2
411  // 0 and 1 = shape 1 = not converted
412  // 2 = shape 2 = first converted shape
413  // > 2 is not used but could be used for more shapes
414  // like multiple shapes for a programmable component
415  // When m_Convert = val max, return to the first shape
416  if( aComponent->GetConvert() > 2 )
417  aComponent->SetConvert( 1 );
418 
419  // The alternate symbol may cause a change in the connection status so test the
420  // connections so the connection indicators are drawn correctly.
422  aComponent->ClearFlags();
423  aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
424 
425  /* Redraw the component in the new position. */
426  if( aComponent->IsMoving() )
427  aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
428  else
429  aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
430 
431  OnModify();
432  }
433 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
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 ...
Definition: schframe.cpp:773
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
Define a library symbol object.
unsigned STATUS_FLAGS
Definition: base_struct.h:158
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:877
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
COLOR4D g_GhostColor
Draw color for moving objects.
Definition: common.cpp:57
wxString EDA_DRAW_FRAME::CoordinateToString ( int  aValue,
bool  aConvertToMils = false 
) const
inherited

Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inches or mm according to the current user units setting.

Parameters
aValueThe coordinate to convert.
aConvertToMilsConvert inch values to mils if true. This setting has no effect if the current user unit is millimeters.
Returns
The converted string for display in user interface elements.

Definition at line 823 of file draw_frame.cpp.

References CoordinateToString().

824 {
825  return ::CoordinateToString( aValue, aConvertToMils );
826 }
wxString CoordinateToString(int aValue, bool aConvertToMils)
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: base_units.cpp:118
void SCH_EDIT_FRAME::copyBlockItems ( PICKED_ITEMS_LIST aItemsList)
private

Copy the list of block item.

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

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

References EDA_ITEM::ClearFlags(), BLOCK_SELECTOR::ClearListAndDeleteItems(), DuplicateStruct(), PICKED_ITEMS_LIST::GetCount(), PICKED_ITEMS_LIST::GetPickedItem(), m_blockItems, BLOCK_SELECTOR::PushItem(), EDA_ITEM::SetParent(), and UR_DELETED.

Referenced by HandleBlockEnd().

435 {
436  m_blockItems.ClearListAndDeleteItems(); // delete previous saved list, if exists
437 
438  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
439  {
440  // Clear m_Flag member of selected items:
441  aItemsList.GetPickedItem( ii )->ClearFlags();
442 
443  /* Make a copy of the original picked item. */
444  SCH_ITEM* copy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
445  copy->SetParent( NULL );
446 
447  // In list the wrapper is owner of the schematic item, we can use the UR_DELETED
448  // status for the picker because pickers with this status are owner of the picked item
449  // (or TODO ?: create a new status like UR_DUPLICATE)
450  ITEM_PICKER item( copy, UR_DELETED );
451 
452  m_blockItems.PushItem( item );
453  }
454 }
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed b...
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:240
SCH_ITEM * DuplicateStruct(SCH_ITEM *aDrawStruct, bool aClone=false)
Routine to create a new copy of given struct.
unsigned GetCount() const
Function GetCount.
BLOCK_SELECTOR m_blockItems
List of selected items.
Definition: schframe.h:140
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:281
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.
void EDA_DRAW_FRAME::CopyToClipboard ( wxCommandEvent &  event)
inherited

Function CopyToClipboard copies the current page or the current block to the clipboard.

Definition at line 43 of file copy_to_clipboard.cpp.

References DrawPageOnClipboard(), EDA_DRAW_PANEL::EndMouseCapture(), EDA_DRAW_PANEL::GetDefaultCursor(), EDA_DRAW_FRAME::GetScreen(), ID_GEN_COPY_BLOCK_TO_CLIPBOARD, BASE_SCREEN::IsBlockActive(), and EDA_DRAW_FRAME::m_canvas.

44 {
45  DrawPageOnClipboard( this );
46 
47  if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
48  {
49  if( GetScreen()->IsBlockActive() )
50  m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
51 
53  }
54 }
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
bool IsBlockActive() const
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:341
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
static bool DrawPageOnClipboard(EDA_DRAW_FRAME *aFrame)
int GetDefaultCursor() const
Function GetDefaultCursor.
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 67 of file libarch.cpp.

References DisplayError(), DisplayErrorMessage(), LIB_ID::Format(), SCH_SCREENS::GetFirst(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibItemName(), SCH_BASE_FRAME::GetLibPart(), LIB_PART::GetName(), SCH_SCREENS::GetNext(), LIBRARY_TYPE_EESCHEMA, SCH_ITEM::Next(), SCH_COMPONENT_T, LIB_PART::SetName(), and UTF8::wx_str().

Referenced by CreateArchiveLibraryCacheFile().

68 {
69  wxString tmp;
70  wxString errorMsg;
71  SCH_SCREENS screens;
72 
73  // Create a new empty library to archive components:
74  std::unique_ptr<PART_LIB> archLib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
75 
76  // Save symbols to file only when the library will be fully filled
77  archLib->EnableBuffering();
78 
79  /* Examine all screens (not hierarchical sheets) used in the schematic and build a
80  * library of unique symbols found in all screens. Complex hierarchies are not a
81  * problem because we just want to know the library symbols used in the schematic
82  * not their reference.
83  */
84  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
85  {
86  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
87  {
88  if( item->Type() != SCH_COMPONENT_T )
89  continue;
90 
91  LIB_PART* part = nullptr;
92  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
93 
94  try
95  {
96  if( archLib->FindAlias( component->GetLibId() ) )
97  continue;
98 
99  part = GetLibPart( component->GetLibId(), true );
100  }
101  catch( const IO_ERROR& ioe )
102  {
103  // Queue up error messages for later.
104  tmp.Printf( _( "Failed to add symbol %s to library file." ),
105  component->GetLibId().GetLibItemName().wx_str(), aFileName );
106 
107  // Don't bail out here. Attempt to add as many of the symbols to the library
108  // as possible.
109  }
110  catch( ... )
111  {
112  tmp = _( "Unexpected exception occurred." );
113  }
114 
115  if( part )
116  {
117  // Use the full LIB_ID as the symbol name to prevent symbol name collisions.
118  wxString oldName = part->GetName();
119  part->SetName( component->GetLibId().Format() );
120 
121  // AddPart() does first clone the part before adding.
122  archLib->AddPart( part );
123  part->SetName( oldName );
124  }
125  else
126  {
127  tmp.Printf( _( "Symbol %s not found in any library or cache." ),
128  component->GetLibId().Format().wx_str() );
129  }
130 
131  if( !tmp.empty() )
132  {
133  if( errorMsg.empty() )
134  errorMsg += tmp;
135  else
136  errorMsg += "\n" + tmp;
137  }
138  }
139  }
140 
141  if( !errorMsg.empty() )
142  {
143  tmp.Printf( _( "Errors occurred creating symbol library %s." ), aFileName );
144  DisplayErrorMessage( this, tmp, errorMsg );
145  }
146 
147  archLib->EnableBuffering( false );
148 
149  try
150  {
151  archLib->Save( false );
152  }
153  catch( ... /* IO_ERROR ioe */ )
154  {
155  errorMsg.Printf( _( "Failed to save symbol library file '%s'" ), aFileName );
156  DisplayError( this, errorMsg );
157  return false;
158  }
159 
160  return true;
161 }
SCH_SCREEN * GetNext()
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
SCH_ITEM * Next() const
wxString wx_str() const
Definition: utf8.cpp:48
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
const wxString & GetName() const
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
Define a library symbol object.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
const LIB_ID & GetLibId() const
UTF8 Format() const
Definition: lib_id.cpp:263
virtual void SetName(const wxString &aName)
SCH_SCREEN * GetFirst()
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:73
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
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.
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 44 of file libarch.cpp.

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

Referenced by OnSaveProject(), and Save_File().

45 {
46  wxFileName fn;
47 
48  if( aUseCurrentSheetFilename )
49  fn = GetScreen()->GetFileName();
50  else
52 
53  fn.SetName( fn.GetName() + "-cache" );
54  fn.SetExt( SchematicLibraryFileExtension );
55 
56  bool success = CreateArchiveLibrary( fn.GetFullPath() );
57 
58  // Update the schematic symbol library links.
59  // because the lib cache has changed
60  SCH_SCREENS schematic;
61  schematic.UpdateSymbolLinks();
62 
63  return success;
64 }
const wxString & GetFileName() const
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the ful...
const wxString SchematicLibraryFileExtension
bool CreateArchiveLibrary(const wxString &aFileName)
Create a library aFileName that contains all components used in the current schematic.
Definition: libarch.cpp:67
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
SCH_BUS_BUS_ENTRY * SCH_EDIT_FRAME::CreateBusBusEntry ( )
private

Definition at line 42 of file busentry.cpp.

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

Referenced by OnLeftClick().

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.
void addCurrentItemToList(bool aRedraw=true)
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
Definition: schframe.cpp:1356
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
static int s_LastShape
Definition: busentry.cpp:39
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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 addCurrentItemToList(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetScreen(), IS_NEW, s_LastShape, SCH_SCREEN::SetCurItem(), and EDA_ITEM::SetFlags().

Referenced by OnLeftClick().

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 }
void addCurrentItemToList(bool aRedraw=true)
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
Definition: schframe.cpp:1356
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
static int s_LastShape
Definition: busentry.cpp:39
Class for a wire to bus entry.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
bool SCH_EDIT_FRAME::CreateNetlist ( int  aFormat,
const wxString &  aFullFileName,
unsigned  aNetlistOptions,
REPORTER aReporter = NULL,
bool  silent = false 
)
override

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 109 of file eeschema/netlist.cpp.

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

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

111 {
112  if( !aSilent ) // checks for errors and invokes annotation dialog as neccessary
113  {
114  if( !prepareForNetlist() )
115  return false;
116  }
117  else // performs similar function as prepareForNetlist but without a dialog.
118  {
119  SCH_SCREENS schematic;
120  schematic.UpdateSymbolLinks();
121  SCH_SHEET_LIST sheets( g_RootSheet );
122  sheets.AnnotatePowerSymbols();
123  }
124 
125  std::unique_ptr<NETLIST_OBJECT_LIST> connectedItemsList( BuildNetListBase() );
126 
127  bool success = WriteNetListFile( connectedItemsList.release(), aFormat,
128  aFullFileName, aNetlistOptions, aReporter );
129 
130  return success;
131 }
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:55
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.
Definition: netform.cpp:46
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
SCH_BITMAP * SCH_EDIT_FRAME::CreateNewImage ( wxDC *  aDC)
private

Definition at line 101 of file edit_bitmap.cpp.

References abortMoveBitmap(), SCH_BITMAP::Draw(), GetChars(), EDA_DRAW_FRAME::GetCrossHairPosition(), GetScreen(), GR_DEFAULT_DRAWMODE, IS_MOVED, IS_NEW, EDA_DRAW_FRAME::m_canvas, moveBitmap(), OnModify(), SCH_BITMAP::ReadImageFile(), SCH_SCREEN::SetCurItem(), EDA_ITEM::SetFlags(), and EDA_DRAW_PANEL::SetMouseCapture().

Referenced by OnLeftClick().

102 {
103  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
104  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
105  wxFD_OPEN );
106  int diag = fileDlg.ShowModal();
107 
108  if( diag != wxID_OK )
109  return NULL;
110 
111  wxString fullFilename = fileDlg.GetPath();
112 
113  if( !wxFileExists( fullFilename ) )
114  {
115  wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) );
116  return NULL;
117  }
118 
120 
121  SCH_BITMAP* image = new SCH_BITMAP( pos );
122 
123  if( !image->ReadImageFile( fullFilename ) )
124  {
125  wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) );
126  delete image;
127  return NULL;
128  }
129 
130 
131  image->SetFlags( IS_NEW | IS_MOVED );
132  image->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
133 
135  GetScreen()->SetCurItem( image );
136 
137  OnModify();
138  return image;
139 }
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_bitmap.cpp:114
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
static void moveBitmap(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: edit_bitmap.cpp:73
static void abortMoveBitmap(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: edit_bitmap.cpp:37
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
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 SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:80
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126
SCH_TEXT * SCH_EDIT_FRAME::CreateNewText ( wxDC *  aDC,
int  aType 
)
private

Definition at line 66 of file edit_label.cpp.

References DisplayError(), SCH_TEXT::Draw(), EditSchematicText(), g_XorMode, 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, EDA_DRAW_FRAME::m_canvas, 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(), and Process_Special_Functions().

67 {
68  SCH_TEXT* textItem = NULL;
69 
70  SetRepeatItem( NULL );
71 
72  switch( aType )
73  {
74  case LAYER_NOTES:
75  textItem = new SCH_TEXT( GetCrossHairPosition() );
76  break;
77 
78  case LAYER_LOCLABEL:
79  textItem = new SCH_LABEL( GetCrossHairPosition() );
80  break;
81 
82  case LAYER_HIERLABEL:
83  textItem = new SCH_HIERLABEL( GetCrossHairPosition() );
84  textItem->SetShape( lastGlobalLabelShape );
85  break;
86 
87  case LAYER_GLOBLABEL:
88  textItem = new SCH_GLOBALLABEL( GetCrossHairPosition() );
89  textItem->SetShape( lastGlobalLabelShape );
90  break;
91 
92  default:
93  DisplayError( this, wxT( "SCH_EDIT_FRAME::CreateNewText() Internal error" ) );
94  return NULL;
95  }
96 
97  textItem->SetBold( lastTextBold );
98  textItem->SetItalic( lastTextItalic );
100  textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
101  textItem->SetFlags( IS_NEW | IS_MOVED );
102 
103  EditSchematicText( textItem );
104 
105  if( textItem->GetText().IsEmpty() )
106  {
107  delete textItem;
108  return NULL;
109  }
110 
111  lastTextBold = textItem->IsBold();
112  lastTextItalic = textItem->IsItalic();
114 
115  if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) ||
116  ( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) )
117  {
118  lastGlobalLabelShape = textItem->GetShape();
119  }
120 
121  // Prepare display to move the new item
122  textItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
123  PrepareMoveItem( (SCH_ITEM*) textItem, aDC );
124 
125  return textItem;
126 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:118
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:120
virtual void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:344
bool IsItalic() const
Definition: eda_text.h:170
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:277
void SetItalic(bool isItalic)
Definition: eda_text.h:169
int GetLabelSpinStyle() const
Definition: sch_text.h:116
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
static bool lastTextItalic
Definition: edit_label.cpp:47
bool IsBold() const
Definition: eda_text.h:173
void PrepareMoveItem(SCH_ITEM *aItem, wxDC *aDC)
Start moving aItem using the mouse.
Definition: schedit.cpp:759
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
void EditSchematicText(SCH_TEXT *TextStruct)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
static bool lastTextBold
Definition: edit_label.cpp:46
void SetBold(bool aBold)
Definition: eda_text.h:172
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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...
int GetDefaultTextSize()
Default size for text in general.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126
void SCH_EDIT_FRAME::CreateScreens ( )

Definition at line 546 of file schframe.cpp.

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

Referenced by 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
wxString m_DefaultSchematicFileName
Definition: schframe.h:122
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:141
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:103
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:121
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
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:89
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void SetMaxUndoItems(int aMax)
void SetFileName(const wxString &aFileName)
SCH_SHEET * SCH_EDIT_FRAME::CreateSheet ( wxDC *  DC)
private

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

412 {
413  SetRepeatItem( NULL );
414 
415  SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
416 
417  sheet->SetFlags( IS_NEW | IS_RESIZED );
418  sheet->SetTimeStamp( GetNewTimeStamp() );
419  sheet->SetParent( GetScreen() );
420  sheet->SetScreen( NULL );
421 
422  // need to check if this is being added to the GetDrawItems().
423  // also need to update the hierarchy, if we are adding
424  // a sheet to a screen that already has multiple instances (!)
425  GetScreen()->SetCurItem( sheet );
427  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
428  m_canvas->CrossHairOff( aDC );
429 
431 
433  m_canvas->CrossHairOn( aDC );
434 
435  return sheet;
436 }
static void ExitSheet(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: sheet.cpp:367
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:103
wxPoint GetResizePosition() const
Return the position of the lower right corner of the sheet in drawing units.
Definition: sch_sheet.cpp:905
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
timestamp_t GetNewTimeStamp()
Definition: common.cpp:166
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:240
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:325
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:252
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:93
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:259
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:128
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 SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:230
SCH_SHEET_PIN * SCH_EDIT_FRAME::CreateSheetPin ( SCH_SHEET aSheet,
wxDC *  aDC 
)
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.
aDCThe device context to draw on.
Returns
The new sheet pin object created or NULL if the task was aborted by the user.

Definition at line 110 of file sheetlab.cpp.

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

Referenced by OnLeftClick().

111 {
112  wxString line;
113  SCH_SHEET_PIN* sheetPin;
114 
115  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
116  sheetPin->SetFlags( IS_NEW );
117  sheetPin->SetTextSize( GetLastSheetPinTextSize() );
118  sheetPin->SetShape( m_lastSheetPinType );
119 
120  int response = EditSheetPin( sheetPin, false );
121 
122  if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
123  {
124  delete sheetPin;
125  return NULL;
126  }
127 
128  m_lastSheetPinType = sheetPin->GetShape();
129  m_lastSheetPinTextSize = sheetPin->GetTextSize();
130 
131  sheetPin->SetPosition( GetCrossHairPosition() );
132  sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
133  PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC );
134 
135  OnModify();
136  return sheetPin;
137 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
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 ...
Definition: schframe.cpp:773
static wxSize m_lastSheetPinTextSize
Last sheet pin text size.
Definition: schframe.h:180
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
void PrepareMoveItem(SCH_ITEM *aItem, wxDC *aDC)
Start moving aItem using the mouse.
Definition: schedit.cpp:759
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
static PINSHEETLABEL_SHAPE m_lastSheetPinType
Last sheet pin type.
Definition: schframe.h:179
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
const wxSize & GetLastSheetPinTextSize()
Initializing accessor for the pin text size.
Definition: sheetlab.cpp:50
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
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:215
int EditSheetPin(SCH_SHEET_PIN *aSheetPin, bool aRedraw)
Display the dialog for editing the parameters of aSheetPin.
Definition: sheetlab.cpp:61
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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 SCH_EDIT_FRAME::DefaultExecFlags ( )
inline

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

Definition at line 1448 of file schframe.h.

Referenced by WriteNetListFile().

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

Remove all template field names.

Definition at line 331 of file schframe.h.

References TEMPLATES::DeleteAllTemplateFieldNames().

Referenced by OnPreferencesOptions().

332  {
334  }
TEMPLATES m_TemplateFieldNames
Definition: schframe.h:184
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 39 of file annotate.cpp.

References SCH_SCREEN::ClearAnnotation(), SCH_SCREENS::ClearAnnotation(), EDA_DRAW_FRAME::GetCanvas(), GetScreen(), m_CurrentSheet, OnModify(), EDA_DRAW_PANEL::Refresh(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

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

40 {
41  if( aCurrentSheetOnly )
42  {
43  SCH_SCREEN* screen = GetScreen();
44  wxCHECK_RET( screen != NULL, wxT( "Attempt to clear annotation of a NULL screen." ) );
46  }
47  else
48  {
49  SCH_SCREENS ScreenList;
50  ScreenList.ClearAnnotation();
51  }
52 
53  // Update the references for the sheet that is currently being displayed.
55  GetCanvas()->Refresh();
56  OnModify();
57 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:331
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:121
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:683
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void SCH_EDIT_FRAME::DeleteConnection ( bool  DeleteFullConnection)
private

Definition at line 626 of file schedit.cpp.

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

Referenced by Process_Special_Functions().

627 {
628  PICKED_ITEMS_LIST pickList;
629  SCH_SCREEN* screen = GetScreen();
631 
632  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
633  {
634  DeleteItemsInList( pickList );
635  SchematicCleanUp( true );
636  OnModify();
637  }
638 }
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 ...
Definition: schframe.cpp:773
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
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
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void SCH_EDIT_FRAME::DeleteCurrentSegment ( wxDC *  DC)
private

Erase the last segment at the current mouse position.

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

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

400 {
401  SCH_SCREEN* screen = GetScreen();
402 
403  SetRepeatItem( NULL );
404 
405  if( ( screen->GetCurItem() == NULL ) || !screen->GetCurItem()->IsNew() )
406  return;
407 
408  DrawSegment( m_canvas, DC, wxDefaultPosition, false );
409 
410  screen->Remove( screen->GetCurItem() );
412  screen->SetCurItem( NULL );
413 }
bool IsNew() const
Definition: base_struct.h:243
static void DrawSegment(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Mouse capture callback for drawing line segments.
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:171
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
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 174 of file operations_on_items_lists.cpp.

References EDA_ITEM::GetBoundingBox(), SCH_SHEET::GetBoundingBox(), SCH_ITEM::GetConnectionPoints(), EDA_ITEM::GetFlags(), EDA_ITEM::GetParent(), GetScreen(), SCH_ITEM::IsConnectable(), EDA_DRAW_FRAME::m_canvas, PICKED_ITEMS_LIST::PushItem(), EDA_DRAW_PANEL::RefreshDrawingRect(), 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(), and Process_Special_Functions().

175 {
176  wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item." ) );
177  wxCHECK_RET( !( aItem->GetFlags() & STRUCT_DELETED ),
178  wxT( "Cannot delete item that is already deleted." ) );
179 
180  // Here, aItem is not null.
181  SCH_SCREEN* screen = GetScreen();
182 
183  if( aItem->Type() == SCH_SHEET_PIN_T )
184  {
185  // This item is attached to a node, and is not accessible by the global list directly.
186  SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
187  wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
188  wxT( "Sheet label has invalid parent item." ) );
189  SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED, aAppend );
190  sheet->RemovePin( (SCH_SHEET_PIN*) aItem );
192  }
193  else
194  {
195  PICKED_ITEMS_LIST itemsList;
196  ITEM_PICKER picker( aItem, UR_DELETED );
197 
198  aItem->SetFlags( STRUCT_DELETED );
199  itemsList.PushItem( picker );
200  screen->Remove( aItem );
201 
202  if( aItem->IsConnectable() && aItem->Type() != SCH_JUNCTION_T )
203  {
204  std::vector< wxPoint > pts;
205  aItem->GetConnectionPoints( pts );
206  for( auto point : pts )
207  {
208  SCH_ITEM* junction;
209  if( !screen->IsJunctionNeeded( point )
210  && ( junction = screen->GetItem( point, 0, SCH_JUNCTION_T ) ) )
211  {
212  ITEM_PICKER picker_juction( junction, UR_DELETED );
213  junction->SetFlags( STRUCT_DELETED );
214  itemsList.PushItem( picker_juction );
215  screen->Remove( junction );
216  }
217  }
218  }
219 
220  SaveCopyInUndoList( itemsList, UR_DELETED, aAppend );
222  }
223 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
EDA_ITEM * GetParent() const
Definition: base_struct.h:235
void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
Definition: draw_panel.cpp:305
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:186
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:498
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
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:136
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
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.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool SCH_EDIT_FRAME::DeleteItemAtCrossHair ( wxDC *  aDC)

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.

Parameters
aDCThe device context to update if and item is deleted.
Returns
True if an item was deleted.

Definition at line 641 of file schedit.cpp.

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

Referenced by OnHotKey(), and OnLeftClick().

642 {
643  SCH_ITEM* item;
644  SCH_SCREEN* screen = GetScreen();
645 
647 
648  if( item )
649  {
650  bool itemHasConnections = item->IsConnectable();
651 
652  screen->SetCurItem( NULL );
653  SetRepeatItem( NULL );
654  DeleteItem( item );
655 
656  if( itemHasConnections && screen->TestDanglingEnds() )
657  m_canvas->Refresh();
658 
659  OnModify();
660  return true;
661  }
662 
663  return false;
664 }
static const KICAD_T ParentItems[]
A scan list for only parent schematic items.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
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.
Definition: schframe.cpp:471
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:877
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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 154 of file operations_on_items_lists.cpp.

References SCH_SCREEN::ClearDrawingState(), DeleteItem(), PICKED_ITEMS_LIST::GetCount(), EDA_ITEM::GetFlags(), PICKED_ITEMS_LIST::GetPickedItem(), GetScreen(), STRUCT_DELETED, and UR_DELETED.

Referenced by DeleteConnection(), and HandleBlockEnd().

155 {
156  PICKED_ITEMS_LIST itemsList;
157 
158  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
159  {
160  SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
161  ITEM_PICKER itemWrapper( item, UR_DELETED );
162 
163  if( item->GetFlags() & STRUCT_DELETED )
164  continue;
165 
166  DeleteItem( item, aAppend );
167  aAppend = true;
168  }
169 
171 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:136
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
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:565
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 KIWAY_PLAYER::DismissModal ( bool  aRetVal,
const wxString &  aResult = wxEmptyString 
)
protectedinherited