KiCad PCB EDA Suite
PCB_EDIT_FRAME Class Reference

PCB_EDIT_FRAME is the main frame for Pcbnew. More...

#include <pcb_edit_frame.h>

Inheritance diagram for PCB_EDIT_FRAME:
PCB_BASE_EDIT_FRAME PCB_BASE_FRAME EDA_DRAW_FRAME KIWAY_PLAYER EDA_BASE_FRAME KIWAY_HOLDER

Classes

struct  LAYER_TOOLBAR_ICON_VALUES
 Store the previous layer toolbar icon state information. More...
 

Public Types

enum  FETCH_NETLIST_MODE { NO_ANNOTATION, QUIET_ANNOTATION, ANNOTATION_DIALOG }
 Function FetchNetlistFromSchematic. More...
 
enum  HOLDER_TYPE { DIALOG, FRAME, PANEL, SCREEN }
 

Public Member Functions

virtual ~PCB_EDIT_FRAME ()
 
void LoadFootprints (NETLIST &aNetlist, REPORTER &aReporter)
 Function loadFootprints loads the footprints for each COMPONENT in aNetlist from the list of libraries. More...
 
void OnQuit (wxCommandEvent &event)
 
bool IsContentModified () override
 Get if the current board has been modified but not saved. More...
 
void PythonPluginsReload ()
 Reload the Python plugins if they are newer than the already loaded, and load new plugins if any Do nothing if KICAD_SCRIPTING is not defined. More...
 
void UpdateUserInterface ()
 Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...) More...
 
void ExecuteRemoteCommand (const char *cmdline) override
 Execute a remote command send by Eeschema via a socket, port KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) 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 ToPlotter (int aID)
 Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board. More...
 
void ExportSVG (wxCommandEvent &event)
 Function SVG_Print Shows the Export to SVG file dialog. More...
 
void OnUpdateLayerSelectBox (wxUpdateUIEvent &aEvent)
 
bool LayerManagerShown ()
 
bool MicrowaveToolbarShown ()
 
void OnUpdateSelectViaSize (wxUpdateUIEvent &aEvent)
 
void OnUpdateSelectTrackWidth (wxUpdateUIEvent &aEvent)
 
void OnLayerColorChange (wxCommandEvent &aEvent)
 
void RunEeschema ()
 
void UpdateTrackWidthSelectBox (wxChoice *aTrackWidthSelectBox, bool aEdit=true)
 
void UpdateViaSizeSelectBox (wxChoice *aViaSizeSelectBox, bool aEdit=true)
 
COLOR4D GetGridColor () override
 Function GetGridColor() , virtual. More...
 
void SetGridColor (COLOR4D aColor) override
 Function SetGridColor() , virtual. More...
 
void Process_Config (wxCommandEvent &event)
 
std::vector< PARAM_CFG * > & GetProjectFileParameters ()
 Function GetProjectFileParameters returns a project file parameter list for Pcbnew. More...
 
void SaveProjectSettings () override
 Function SaveProjectSettings saves changes to the project settings to the project (.pro) file. More...
 
bool LoadProjectSettings ()
 Load the current project's file configuration settings which are pertinent to this PCB_EDIT_FRAME instance. More...
 
void LoadSettings (APP_SETTINGS_BASE *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (APP_SETTINGS_BASE *aCfg) override
 Saves common frame parameters to a configuration data file. More...
 
wxString GetLastPath (LAST_PATH_TYPE aType)
 Get the last path for a particular type. More...
 
void SetLastPath (LAST_PATH_TYPE aType, const wxString &aLastPath)
 Set the path of the last file successfully read. More...
 
void RecordDRCExclusions ()
 Scan existing markers and record data from any that are Excluded. More...
 
void ResolveDRCExclusions ()
 Update markers to match recorded exclusions. More...
 
void OnCloseWindow (wxCloseEvent &Event) override
 
void Process_Special_Functions (wxCommandEvent &event)
 
void Tracks_and_Vias_Size_Event (wxCommandEvent &event)
 
void ReCreateHToolbar () override
 
void ReCreateAuxiliaryToolbar () override
 
void ReCreateVToolbar () override
 
void ReCreateMicrowaveVToolbar ()
 
void ReCreateOptToolbar () override
 
void ReCreateMenuBar () override
 Recreates the menu bar. More...
 
void ReCreateLayerBox (bool aForceResizeToolbar=true)
 Re create the layer Box by clearing the old list, and building le new one, from the new layers names and cole layers. More...
 
bool SetCurrentNetClass (const wxString &aNetClassName)
 Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter change calls BOARD_DESIGN_SETTINGS::SetCurrentNetClass() and update trace width and via size combo boxes on main toolbar Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar and some others parameters (netclass name ....) More...
 
void OnModify () override
 Function OnModify must be called after a board change to set the modified flag. More...
 
void SetActiveLayer (PCB_LAYER_ID aLayer) override
 Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYER_WIDGET. More...
 
PCB_LAYER_WIDGETGetLayerManager ()
 
void OnUpdateLayerAlpha (wxUpdateUIEvent &aEvent) override
 Update the UI to reflect changes to the current layer's transparency. More...
 
bool IsElementVisible (GAL_LAYER_ID aElement) const
 Function IsElementVisible tests whether a given element category is visible. More...
 
void SetElementVisibility (GAL_LAYER_ID aElement, bool aNewState)
 Function SetElementVisibility changes the visibility of an element category. More...
 
void SetVisibleAlls ()
 Function SetVisibleAlls Set the status of all visible element categories and layers to VISIBLE. More...
 
void ReFillLayerWidget ()
 Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading a new BOARD. More...
 
void ActivateGalCanvas () override
 

More...
 
void DoShowBoardSetupDialog (const wxString &aInitialPage=wxEmptyString, const wxString &aInitialParentPage=wxEmptyString)
 Function ShowBoardSetupDialog. More...
 
void PrepareLayerIndicator (bool aForceRebuild=false)
 
void ToggleLayersManager ()
 
void ToggleMicrowaveToolbar ()
 
int DoGenFootprintsPositionFile (const wxString &aFullFileName, bool aUnitsMM, bool aForceSmdItems, bool aTopSide, bool BottomSide, bool aFormatCSV=false)
 Function DoGenFootprintsPositionFile Creates an ascii footprint position file. More...
 
void GenFootprintsReport (wxCommandEvent &event)
 Function GenFootprintsReport Calls DoGenFootprintsReport to create a footprint reprot file See DoGenFootprintsReport for file format. More...
 
bool DoGenFootprintsReport (const wxString &aFullFilename, bool aUnitsMM)
 Function DoGenFootprintsReport Creates an ascii footprint report file giving some infos on footprints and board outlines. More...
 
void GenD356File (wxCommandEvent &event)
 
void OnFileHistory (wxCommandEvent &event)
 
void OnClearFileHistory (wxCommandEvent &aEvent)
 
void Files_io (wxCommandEvent &event)
 Function Files_io. More...
 
bool Files_io_from_id (int aId)
 Function Files_io_from_id Read and write board files. More...
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 Function OpenProjectFiles (was LoadOnePcbFile) loads a KiCad board (.kicad_pcb) from aFileName. More...
 
bool SavePcbFile (const wxString &aFileName, bool aCreateBackupFile=CREATE_BACKUP_FILE)
 Function SavePcbFile writes the board data structures to a aFileName Creates backup when requested and update flags (modified and saved flgs) More...
 
bool SavePcbCopy (const wxString &aFileName)
 Function SavePcbCopy writes the board data structures to a aFileName but unlike SavePcbFile, does not make anything else (no backup, borad fliename change, no flag changes ...) Used under a project mgr to save under a new name the current board. More...
 
bool Clear_Pcb (bool aQuery, bool aFinal=false)
 Function Clear_Pcb delete all and reinitialize the current board. More...
 
void SetBoard (BOARD *aBoard) override
 

More...
 
BOARD_ITEM_CONTAINERGetModel () const override
 

More...
 
int GetSeverity (int aErrorCode) const override
 

More...
 
void SetPageSettings (const PAGE_INFO &aPageSettings) override
 

More...
 
void RecreateCmpFileFromBoard (wxCommandEvent &aEvent)
 Function RecreateBOMFileFromBoard Recreates a .cmp file from the current loaded board this is the same as created by CvPcb. More...
 
void ArchiveModulesOnBoard (bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=NULL)
 Function ArchiveModulesOnBoard Save modules in a library: More...
 
void RecreateBOMFileFromBoard (wxCommandEvent &aEvent)
 Function RecreateBOMFileFromBoard Creates a BOM file from the current loaded board. More...
 
void ExportToGenCAD (wxCommandEvent &event)
 Function ExportToGenCAD creates a file in GenCAD 1.4 format from the current board. More...
 
void OnExportVRML (wxCommandEvent &event)
 Function OnExportVRML will export the current BOARD to a VRML file. More...
 
bool ExportVRML_File (const wxString &aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles, bool aUseRelativePaths, bool aUsePlainPCB, const wxString &a3D_Subdir, double aXRef, double aYRef)
 Function ExportVRML_File Creates the file(s) exporting current BOARD to a VRML file. More...
 
void OnExportIDF3 (wxCommandEvent &event)
 Function OnExportIDF3 will export the current BOARD to a IDFv3 board and lib files. More...
 
void OnExportHyperlynx (wxCommandEvent &event)
 Function OnExportHyperlynx will export the current BOARD to a Hyperlynx HYP file. More...
 
bool Export_IDF3 (BOARD *aPcb, const wxString &aFullFileName, bool aUseThou, double aXRef, double aYRef)
 Function Export_IDF3 Creates an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file. More...
 
void OnExportSTEP (wxCommandEvent &event)
 Function OnExportSTEP Exports the current BOARD to a STEP assembly. More...
 
bool ExportSpecctraFile (const wxString &aFullFilename)
 Function ExportSpecctraFile will export the current BOARD to a specctra dsn file. More...
 
bool ImportSpecctraSession (const wxString &aFullFilename)
 Function ImportSpecctraSession will import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and tracks in an existing and loaded BOARD. More...
 
void InstallFootprintPropertiesDialog (MODULE *Module)
 
int InstallExchangeModuleFrame (MODULE *aModule, bool updateMode, bool selectedMode)
 
void Exchange_Module (MODULE *aSrc, MODULE *aDest, BOARD_COMMIT &aCommit, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool reset3DModels=true)
 Function Exchange_Module Replaces OldModule by NewModule, using OldModule settings: position, orientation, pad netnames ...) OldModule is deleted or put in undo list. More...
 
void OnEditItemRequest (BOARD_ITEM *aItem) override
 Function OnEditItemRequest Install the corresponding dialog editor for the given item. More...
 
void SwitchLayer (wxDC *DC, PCB_LAYER_ID layer) override
 
int SetTrackSegmentWidth (TRACK *aTrackItem, PICKED_ITEMS_LIST *aItemsListPicker, bool aUseNetclassValue)
 Function SetTrackSegmentWidth Modify one track segment width or one via diameter (using DRC control). More...
 
void Edit_Zone_Params (ZONE_CONTAINER *zone_container)
 Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline. More...
 
void ShowTargetOptionsDialog (PCB_TARGET *aTarget)
 
void ShowDimensionPropertyDialog (DIMENSION *aDimension)
 
void InstallNetlistFrame ()
 
bool FetchNetlistFromSchematic (NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
 
void DoUpdatePCBFromNetlist (NETLIST &aNetlist, bool aUseTimestamps)
 Function DoUpdatePCBFromNetlist An automated version of UpdatePCBFromNetlist which skips the UI dialog. More...
 
bool ReadNetlistFromFile (const wxString &aFilename, NETLIST &aNetlist, REPORTER &aReporter)
 Reads a netlist from a file into a NETLIST object. More...
 
void OnNetlistChanged (BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
 Called after netlist is updated. More...
 
void LockModule (MODULE *aModule, bool aLocked)
 
void SendMessageToEESCHEMA (BOARD_ITEM *objectToSync)
 Function SendMessageToEESCHEMA sends a message to the schematic editor so that it may move its cursor to a part with the same reference as the objectToSync. More...
 
void SendCrossProbeNetName (const wxString &aNetName)
 Sends a net name to eeschema for highlighting. More...
 
MODULECreateMuWaveBaseFootprint (const wxString &aValue, int aTextSize, int aPadCount)
 Function CreateMuWaveBaseFootprint create a basic footprint for micro wave applications. More...
 
MODULECreate_MuWaveComponent (int shape_type)
 Create_MuWaveComponent creates a module "GAP" or "STUB" used in micro wave designs. More...
 
MODULECreate_MuWavePolygonShape ()
 
void ShowChangedLanguage () override
 Redraw the menus and what not in current language. More...
 
void UpdateTitle ()
 Function UpdateTitle sets the main window title bar text. More...
 
void On3DShapeLibWizard (wxCommandEvent &event)
 
void InstallPreferences (PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
 Allows Pcbnew to install its preferences panel into the preferences dialog. More...
 
void CommonSettingsChanged (bool aEnvVarsChanged) override
 Called after the preferences dialog is run. More...
 
void SyncToolbars () override
 Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state. More...
 
wxString CreateNewLibrary (const wxString &aLibName=wxEmptyString)
 Function CreateNewLibrary If a library name is given, creates a new footprint library in the project folder with the given name. More...
 
bool AddLibrary (const wxString &aLibName=wxEmptyString)
 Function AddLibrary Add an existing library to either the global or project library table. More...
 
void SaveCopyInUndoList (BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
 Function SaveCopyInUndoList Creates a new entry in undo list of commands. More...
 
void SaveCopyInUndoList (const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
 Function SaveCopyInUndoList Creates a new entry in undo list of commands. More...
 
void RestoreCopyFromRedoList (wxCommandEvent &aEvent)
 Function RestoreCopyFromRedoList Redo the last edit: More...
 
void RestoreCopyFromUndoList (wxCommandEvent &aEvent)
 Function RestoreCopyFromUndoList Undo the last edit: More...
 
void RollbackFromUndo ()
 Performs an undo of the last edit WITHOUT logging a corresponding redo. More...
 
void PutDataInPreviousState (PICKED_ITEMS_LIST *aList, bool aRedoCommand, bool aRebuildRatsnet=true)
 Function PutDataInPreviousState Used in undo or redo command. More...
 
bool UndoRedoBlocked () const
 Function UndoRedoBlocked Checks if the undo and redo operations are currently blocked. More...
 
void UndoRedoBlock (bool aBlock=true)
 Function UndoRedoBlock Enables/disable undo and redo operations. More...
 
void SetGridVisibility (bool aVisible) override
 Function SetGridVisibility() More...
 
int GetRotationAngle () const
 Function GetRotationAngle() Returns the angle used for rotate operations. More...
 
void SetRotationAngle (int aRotationAngle)
 Function SetRotationAngle() Sets the angle used for rotate operations. More...
 
void InstallTextOptionsFrame (BOARD_ITEM *aText)
 Routine for main window class to launch text properties dialog. More...
 
void InstallGraphicItemPropertiesDialog (BOARD_ITEM *aItem)
 
void OnGridSettings (wxCommandEvent &aEvent) override
 
EDA_3D_VIEWERGet3DViewerFrame ()
 
virtual void Update3DView (bool aForceReload, const wxString *aTitle=nullptr)
 Update the 3D view, if the viewer is opened by this frame. More...
 
MODULELoadFootprint (const LIB_ID &aFootprintId)
 Function LoadFootprint attempts to load aFootprintId from the footprint library table. More...
 
EDA_RECT GetBoardBoundingBox (bool aBoardEdgesOnly=false) const
 Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge segments). More...
 
const BOX2I GetDocumentExtents () const override
 
const PAGE_INFOGetPageSettings () const override
 
const wxSize GetPageSizeIU () const override
 Works off of GetPageSettings() to return the size of the paper page in the internal units of this particular view. More...
 
const wxPointGetAuxOrigin () const override
 Return the origin of the axis used for plotting and various exports. More...
 
void SetAuxOrigin (const wxPoint &aPoint) override
 
const wxPointGetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const wxPoint &aPoint) override
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
virtual BOARD_DESIGN_SETTINGSGetDesignSettings () const
 Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame. More...
 
virtual void SetDesignSettings (const BOARD_DESIGN_SETTINGS &aSettings)
 
COLOR_SETTINGSColorSettings ()
 Helper to retrieve the current color settings. More...
 
PCBNEW_SETTINGSSettings ()
 
void SetDrawBgColor (COLOR4D aColor) override
 
const PCB_DISPLAY_OPTIONSGetDisplayOptions () const
 Function GetDisplayOptions returns the display options current in use Display options are relative to the way tracks, vias, outlines and other things are shown (for instance solid or sketch mode) More...
 
void SetDisplayOptions (const PCB_DISPLAY_OPTIONS &aOptions)
 
const ZONE_SETTINGSGetZoneSettings () const
 
void SetZoneSettings (const ZONE_SETTINGS &aSettings)
 
virtual const PCB_PLOT_PARAMSGetPlotSettings () const
 Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame. More...
 
virtual void SetPlotSettings (const PCB_PLOT_PARAMS &aSettings)
 
BOARDGetBoard () const
 
void FocusOnItem (BOARD_ITEM *aItem)
 
virtual void UpdateStatusBar () override
 Update the status bar information. More...
 
PCB_SCREENGetScreen () const override
 Return a pointer to a BASE_SCREEN or one of its derivatives. More...
 
void UpdateGridSelectBox ()
 
const wxString GetZoomLevelIndicator () const override
 Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level indicator in dialogs. More...
 
EDA_3D_VIEWERCreateAndShow3D_Frame ()
 Shows the 3D view frame. More...
 
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide ()
 Function GetCollectorsGuide. More...
 
wxString SelectLibrary (const wxString &aNicknameExisting)
 Function SelectLibrary puts up a dialog and allows the user to pick a library, for unspecified use. More...
 
MODULEGetFootprintFromBoardByReference ()
 Function GetFootprintFromBoardByReference. More...
 
MODULECreateNewModule (const wxString &aModuleName)
 Function CreateNewModule Creates a new module or footprint, at position 0,0 The new module contains only 2 texts: a reference and a value: Reference = REF** Value = "VAL**" or Footprint name in lib Note: they are dummy texts, which will be replaced by the actual texts when the fooprint is placed on a board and a netlist is read. More...
 
void Edit_Module (MODULE *module, wxDC *DC)
 
void PlaceModule (MODULE *aModule, bool aRecreateRatsnest=true)
 Function PlaceModule places aModule at the current cursor position and updates module coordinates with the new position. More...
 
void InstallPadOptionsFrame (D_PAD *pad)
 
MODULESelectFootprintFromLibTree (LIB_ID aPreselect=LIB_ID())
 Function SelectFootprintFromLibTree opens a dialog to select a footprint. More...
 
virtual void AddModuleToBoard (MODULE *module)
 Adds the given module to the board. More...
 
wxString SelectFootprintFromLibBrowser ()
 Function SelectFootprintFromLibBrowser launches the footprint viewer to select the name of a footprint to load. More...
 
void Compile_Ratsnest (bool aDisplayStatus)
 Function Compile_Ratsnest Create the entire board ratsnest. More...
 
PCB_LAYER_ID SelectLayer (PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
 Install the dialog box for layer selection. More...
 
virtual PCB_LAYER_ID GetActiveLayer () const
 Function GetActiveLayer returns the active layer. More...
 
PCBNEW_SETTINGSGetSettings ()
 
void OnTogglePadDrawMode (wxCommandEvent &aEvent)
 
void OnToggleGraphicDrawMode (wxCommandEvent &aEvent)
 
void OnToggleEdgeDrawMode (wxCommandEvent &aEvent)
 
void OnToggleTextDrawMode (wxCommandEvent &aEvent)
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 
void SetFastGrid1 ()
 Function SetFastGrid1() More...
 
void SetFastGrid2 ()
 Function SetFastGrid2() More...
 
virtual bool IsGridVisible () const override
 Function IsGridVisible() More...
 
void DisplayGridMsg ()
 Function DisplayGridMsg() More...
 
PCB_DRAW_PANEL_GALGetCanvas () const override
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
wxFindReplaceData & GetFindReplaceData ()
 
wxArrayString & GetFindHistoryList ()
 
bool GetShowPolarCoords () const
 For those frames that support polar coordinates. More...
 
void SetShowPolarCoords (bool aShow)
 
int GetLastGridSizeId () const
 
void SetLastGridSizeId (int aId)
 
wxPoint GetNearestGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
virtual COLOR4D GetDrawBgColor () const
 
virtual COLOR_SETTINGSGetColorSettings ()
 Returns a pointer to the active color theme settings. More...
 
bool ShowPageLimits () const
 
void SetShowPageLimits (bool aShow)
 
virtual wxString GetScreenDesc () const
 
double GetZoomLevelCoeff () const
 Return the coefficient to convert internal display scale factor to zoom level. More...
 
void EraseMsgBox ()
 
virtual void OnSelectGrid (wxCommandEvent &event)
 Command event handler for selecting grid sizes. More...
 
virtual void OnSelectZoom (wxCommandEvent &event)
 Set the zoom factor when selected by the zoom list box in the main tool bar. More...
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 
virtual void OnSize (wxSizeEvent &event)
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
virtual void HardRedraw ()
 Rebuild the GAL and redraws the screen. More...
 
virtual void Zoom_Automatique (bool aWarpPointer)
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void FocusOnLocation (const wxPoint &aPos)
 Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor) at a given coordinate and reframes the drawing if the requested point is out of view or if center on location is requested. More...
 
double GetZoom ()
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Function CreateBasicMenu. More...
 
void PrintWorkSheet (wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString, COLOR4D aColor=COLOR4D::UNSPECIFIED)
 Prints the page layout with the frame and the basic inscriptions. More...
 
void DisplayToolMsg (const wxString &msg) override
 
virtual void OnPageSettingsChange ()
 Called when modifying the page settings. More...
 
void DisplayUnitsMsg ()
 Display current unit pane on the status bar. More...
 
void CreateServer (int service, bool local=true)
 
void OnSockRequest (wxSocketEvent &evt)
 
void OnSockRequestServer (wxSocketEvent &evt)
 
void AppendMsgPanel (const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
 Append a message to the message panel. More...
 
virtual void ClearMsgPanel ()
 Clear all messages from the message panel. More...
 
void SetMsgPanel (const std::vector< MSG_PANEL_ITEM > &aList)
 Clear the message panel and populates it with the contents of aList. More...
 
void SetMsgPanel (EDA_ITEM *aItem)
 
virtual void UpdateMsgPanel ()
 Redraw the message panel. More...
 
virtual void PrintPage (wxDC *aDC)
 Print the page pointed by current screen, set by the calling print function. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting ()
 Returns the canvas type stored in the application settings. More...
 
void SetCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Return a reference to the gal rendering options used by GAL for rendering. More...
 
void RefreshCanvas () override
 Notification to refresh the drawing canvas (if any). More...
 
void RecreateToolbars ()
 Rebuild all toolbars, and update the checked state of ckeck tools. More...
 
virtual bool ShowModal (wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
 Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until this KIWAY_PLAYER derivative calls DismissModal(). More...
 
bool Destroy () override
 Our version of Destroy() which is virtual from wxWidgets. More...
 
bool IsModal ()
 
void SetModal (bool aIsModal)
 
bool IsDismissed ()
 Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been dismissed yet with DismissModal(). More...
 
void DismissModal (bool aRetVal, const wxString &aResult=wxEmptyString)
 
EDA_UNITS GetUserUnits () const
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS aUnits)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
SETTINGS_MANAGERGetSettingsManager () const
 
TOOL_MANAGERGetToolManager () const
 Return the MVC controller. More...
 
virtual void PushTool (const std::string &actionName)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const std::string &actionName)
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
bool GetDoImmediateActions () const
 Indicates that hotkeys should perform an immediate action even if another tool is currently active. More...
 
bool GetDragSelects () const
 Indicates that a drag should draw a selection rectangle, even when started over an item. More...
 
bool GetMoveWarpsCursor () const
 Indicates that a move operation should warp the mouse pointer to the origin of the move object. More...
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &event)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuOpen (wxMenuEvent &event)
 Workaround some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
virtual const SEARCH_STACKsys_search ()
 Return a SEARCH_STACK pertaining to entire program. More...
 
virtual wxString help_name ()
 
void OnKicadAbout (wxCommandEvent &event)
 
void OnPreferences (wxCommandEvent &event)
 
void PrintMsg (const wxString &text)
 
virtual APP_SETTINGS_BASEconfig ()
 Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
void LoadWindowSettings (WINDOW_SETTINGS *aCfg)
 Loads window settings from the given settings object Normally called by LoadSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window. More...
 
void SaveWindowSettings (WINDOW_SETTINGS *aCfg)
 Saves window settings to the given settings object Normally called by SaveSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window. More...
 
virtual WINDOW_SETTINGSGetWindowSettings (APP_SETTINGS_BASE *aCfg)
 Returns a pointer to the window settings for this frame. More...
 
wxString ConfigBaseName ()
 
void ImportHotkeyConfigFromFile (std::map< std::string, TOOL_ACTION * > aActionMap, const wxString &aDefaultShortname)
 Prompt the user for a hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=NULL)
 Fetches the file name from the file history list. More...
 
void ClearFileHistory (FILE_HISTORY *aFileHistory=NULL)
 Removes all files from the file history. More...
 
void UpdateFileHistory (const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
 Update the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
void AddStandardHelpMenu (wxMenuBar *aMenuBar)
 Adds the standard KiCad help menu to the menubar. More...
 
bool IsWritable (const wxFileName &aFileName)
 Checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName)
 Check if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
const wxString & GetAboutTitle () const
 
void SetShutdownBlockReason (const wxString &reason)
 Sets the block reason why the window/application is preventing OS shutdown. More...
 
void RemoveShutdownBlockReason ()
 Removes any shutdown block reason set. More...
 
bool SupportsShutdownBlockReason ()
 Whether or not the window supports setting a shutdown block reason. More...
 
HOLDER_TYPE GetType ()
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Public Attributes

PCB_LAYER_BOX_SELECTORm_SelLayerBox
 
wxChoice * m_SelTrackWidthBox
 
wxChoice * m_SelViaSizeBox
 
bool m_show_microwave_tools
 
bool m_show_layer_manager_tools
 
bool m_ZoneFillsDirty
 
wxPoint m_UserGridSize
 
int m_FastGrid1
 
int m_FastGrid2
 

Protected Member Functions

void setupTools ()
 
wxString createBackupFile (const wxString &aFileName)
 
void SwitchCanvas (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
 switches currently used canvas (Cairo / OpenGL). More...
 
void onBoardLoaded ()
 Updates the state of the GUI after a new board is loaded or created. More...
 
void syncLayerWidgetLayer ()
 Function syncLayerWidgetLayer updates the currently layer "selection" within the PCB_LAYER_WIDGET. More...
 
void syncRenderStates ()
 Function syncRenderStates updates the "Render" checkboxes in the layer widget according to current toggle values determined by IsElementVisible(), and is helpful immediately after loading a BOARD which may have state information in it. More...
 
void syncLayerVisibilities ()
 Function syncLayerVisibilities updates each "Layer" checkbox in the layer widget according to each layer's current visibility determined by IsLayerVisible(), and is helpful immediately after loading a BOARD which may have state information in it. More...
 
bool doAutoSave () override
 Function doAutoSave performs auto save when the board has been modified and not saved within the auto save interval. More...
 
bool isAutoSaveRequired () const override
 Function isautoSaveRequired returns true if the board has been modified. More...
 
bool importFile (const wxString &aFileName, int aFileType)
 Load the given filename but sets the path to the current project path. More...
 
int inferLegacyEdgeClearance (BOARD *aBoard)
 Use the existing edge_cut line thicknesses to infer the edge clearace. More...
 
bool fixEagleNets (const std::unordered_map< wxString, wxString > &aRemap)
 Rematch orphaned zones and vias to schematic nets. More...
 
 PCB_EDIT_FRAME (KIWAY *aKiway, wxWindow *aParent)
 
void unitsChangeRefresh () override
 Called when when the units setting has changed to allow for any derived classes to handle refreshing and controls that have units based measurements in them. More...
 
void updateZoomSelectBox ()
 
MODULEloadFootprint (const LIB_ID &aFootprintId)
 Function loadFootprint attempts to load aFootprintId from the footprint library table. More...
 
virtual void SetScreen (BASE_SCREEN *aScreen)
 
void InitExitKey ()
 Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id. More...
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 Function language_change is an event handler called on a language menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 

Static Protected Member Functions

static const wxChar * pythonConsoleNameId ()
 Has meaning only if KICAD_SCRIPTING_WXPYTHON option is not defined. More...
 
static wxWindow * findPythonConsole ()
 
static wxString GetBackupSuffix ()
 
static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

std::vector< PARAM_CFG * > m_projectFileParams
 
wxString m_lastPath [LAST_PATH_SIZE]
 
std::set< wxString > m_drcExclusions
 
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
 
int m_rotationAngle
 User defined rotation angle (in tenths of a degree). More...
 
bool m_undoRedoBlocked
 Is undo/redo operation currently blocked? More...
 
PCB_LAYER_WIDGETm_Layers
 Layer manager. It is the responsibility of the child frames to instantiate this. More...
 
BOARDm_Pcb
 
PCB_DISPLAY_OPTIONS m_DisplayOptions
 
PCBNEW_SETTINGSm_Settings
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 prevents opening same file multiple times. More...
 
int m_LastGridSizeId
 
bool m_drawGrid
 
bool m_showPageLimits
 
COLOR4D m_gridColor
 
COLOR4D m_drawBgColor
 
double m_zoomLevelCoeff
 
int m_UndoRedoCountMax
 
bool m_PolarCoords
 
TOOL_DISPATCHERm_toolDispatcher
 
bool m_showBorderAndTitleBlock
 
long m_firstRunDialogSetting
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
ACTION_TOOLBARm_mainToolBar
 
ACTION_TOOLBARm_auxiliaryToolBar
 
ACTION_TOOLBARm_drawToolBar
 
ACTION_TOOLBARm_optionsToolBar
 
wxFindReplaceData * m_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_MsgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
 The current canvas type. More...
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
FRAME_T m_Ident
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_AboutTitle
 
wxAuiManager m_auimgr
 
wxString m_configName
 
SETTINGS_MANAGERm_settingsManager
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
bool m_dragSelects
 
bool m_moveWarpsCursor
 
bool m_hasAutoSave
 
bool m_autoSaveState
 
int m_autoSaveInterval
 
wxTimer * m_autoSaveTimer
 
wxString m_perspective
 
wxString m_mruPath
 
EDA_UNITS m_userUnits
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private Attributes

ACTION_TOOLBARm_microWaveToolBar
 The auxiliary right vertical tool bar used to access the microwave tools. More...
 

Friends

struct PCB::IFACE
 
class PCB_LAYER_WIDGET
 

Detailed Description

PCB_EDIT_FRAME is the main frame for Pcbnew.

See also class PCB_BASE_FRAME(): Basic class for Pcbnew and GerbView.

Definition at line 96 of file pcb_edit_frame.h.

Member Enumeration Documentation

◆ FETCH_NETLIST_MODE

Function FetchNetlistFromSchematic.

Parameters
aNetlista NETLIST owned by the caller. This function fills it in.
Returns
true if a netlist was fetched.
Enumerator
NO_ANNOTATION 
QUIET_ANNOTATION 
ANNOTATION_DIALOG 

Definition at line 874 of file pcb_edit_frame.h.

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 
SCREEN 

Definition at line 42 of file kiway_holder.h.

Constructor & Destructor Documentation

◆ PCB_EDIT_FRAME()

PCB_EDIT_FRAME::PCB_EDIT_FRAME ( KIWAY aKiway,
wxWindow *  aParent 
)
protected

◆ ~PCB_EDIT_FRAME()

PCB_EDIT_FRAME::~PCB_EDIT_FRAME ( )
virtual

Definition at line 332 of file pcb_edit_frame.cpp.

333 {
334  // Shutdown all running tools
335  if( m_toolManager )
337 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
TOOL_MANAGER * m_toolManager

Member Function Documentation

◆ ActivateGalCanvas()

void PCB_EDIT_FRAME::ActivateGalCanvas ( )
overridevirtual

Reimplemented from PCB_BASE_EDIT_FRAME.

Definition at line 599 of file pcb_edit_frame.cpp.

600 {
603  GetCanvas()->UpdateColors();
604  GetCanvas()->Refresh();
605 }
void ActivateGalCanvas() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetColorContext(COLOR_CONTEXT aContext=COLOR_CONTEXT::PCB)
COLOR_SETTINGS * ColorSettings()
Helper to retrieve the current color settings.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void UpdateColors()
Updates the color settings in the painter and GAL.

References PCB_BASE_EDIT_FRAME::ActivateGalCanvas(), and PCB.

Referenced by Refresh().

◆ AddLibrary()

bool PCB_BASE_EDIT_FRAME::AddLibrary ( const wxString &  aLibName = wxEmptyString)
inherited

Function AddLibrary Add an existing library to either the global or project library table.

Parameters
aFileNamethe library to add; a file open dialog will be displayed if empty.
Returns
true if successfully added

Definition at line 485 of file footprint_libraries_utils.cpp.

486 {
487  wxFileName fn( aFilename );
488 
489  if( aFilename.IsEmpty() )
490  {
491  if( !LibraryFileBrowser( true, fn,
493  true ) )
494  {
495  return false;
496  }
497  }
498 
499  wxString libPath = fn.GetFullPath();
500  wxString libName = fn.GetName();
501 
502  if( libName.IsEmpty() )
503  return false;
504 
505  bool saveInGlobalTable = false;
506  bool saveInProjectTable = false;
507  wxArrayString libTableNames;
508 
509  libTableNames.Add( _( "Global" ) );
510  libTableNames.Add( _( "Project" ) );
511 
512  switch( SelectSingleOption( this, _( "Select Library Table" ),
513  _( "Choose the Library Table to add the library to:" ),
514  libTableNames ) )
515  {
516  case 0: saveInGlobalTable = true; break;
517  case 1: saveInProjectTable = true; break;
518  default: return false;
519  }
520 
521  wxString type = IO_MGR::ShowType( IO_MGR::GuessPluginTypeFromLibPath( libPath ) );
522 
523  // try to use path normalized to an environmental variable or project path
524  wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
525 
526  if( normalizedPath.IsEmpty() )
527  normalizedPath = libPath;
528 
529  try
530  {
531  if( saveInGlobalTable )
532  {
533  auto row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
534  GFootprintTable.InsertRow( row );
536  }
537  else if( saveInProjectTable )
538  {
539  auto row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
540  Prj().PcbFootprintLibs()->InsertRow( row );
541  Prj().PcbFootprintLibs()->Save( Prj().FootprintLibTblName() );
542  }
543  }
544  catch( const IO_ERROR& ioe )
545  {
546  DisplayError( this, ioe.What() );
547  return false;
548  }
549 
550  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
551 
552  if( editor )
553  {
554  LIB_ID libID( libName, wxEmptyString );
555  editor->SyncLibraryTree( true );
556  editor->FocusOnLibID( libID );
557  }
558 
559  auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
560 
561  if( viewer )
562  viewer->ReCreateLibraryList();
563 
564  return true;
565 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
FP_LIB_TABLE_ROW.
Definition: fp_lib_table.h:42
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
FP_LIB_TABLE GFootprintTable
!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.
Component library viewer main window.
static const wxString ShowType(PCB_FILE_T aFileType)
Function ShowType returns a brief name for a plugin, given aFileType enum.
Definition: io_mgr.cpp:77
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
static PCB_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath)
Function GuessPluginTypeFromLibPath returns a plugin type given a footprint library's libPath.
Definition: io_mgr.cpp:124
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:341
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:427
wxString KiCadFootprintLibPathWildcard()
#define _(s)
Definition: 3d_actions.cpp:33
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
int SelectSingleOption(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
Displays a dialog with radioboxes asking the user to select an option.
Definition: confirm.cpp:293
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
const std::string KiCadFootprintLibPathExtension
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalizes a file path to an environmental variable, if possible.
Definition: env_paths.cpp:68
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.

References _, DisplayError(), FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_VIEWER, FP_LIB_TABLE::GetGlobalTableFileName(), GFootprintTable, IO_MGR::GuessPluginTypeFromLibPath(), LIB_TABLE::InsertRow(), KiCadFootprintLibPathExtension, KiCadFootprintLibPathWildcard(), KIWAY_HOLDER::Kiway(), EDA_DRAW_FRAME::LibraryFileBrowser(), NormalizePath(), PROJECT::PcbFootprintLibs(), Pgm(), KIWAY::Player(), KIWAY_HOLDER::Prj(), LIB_TABLE::Save(), SelectSingleOption(), IO_MGR::ShowType(), and IO_ERROR::What().

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary().

◆ AddModuleToBoard()

void PCB_BASE_FRAME::AddModuleToBoard ( MODULE module)
virtualinherited

Adds the given module to the board.

Parameters
module
aDC(can be NULL ) = the current Device Context, to draw the new footprint

Reimplemented in FOOTPRINT_EDIT_FRAME.

Definition at line 165 of file pcb_base_frame.cpp.

166 {
167  if( module )
168  {
169  GetBoard()->Add( module, ADD_MODE::APPEND );
170 
171  module->SetFlags( IS_NEW );
172  module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
173 
174  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
175  // built from a board)
176  if( module->IsFlipped() )
177  module->Flip( module->GetPosition(), m_Settings->m_FlipLeftRight );
178 
179  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
180  // it might be stored in another orientation if the lib is an archive built from a board)
181  module->SetOrientation( 0 );
182  }
183 }
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:292
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
void SetPosition(const wxPoint &aPos) override
PCBNEW_SETTINGS * m_Settings
void SetOrientation(double newangle)
BOARD * GetBoard() const
const wxPoint GetPosition() const override
Definition: class_module.h:210

References BOARD::Add(), APPEND, MODULE::Flip(), PCB_BASE_FRAME::GetBoard(), MODULE::GetPosition(), IS_NEW, MODULE::IsFlipped(), PCBNEW_SETTINGS::m_FlipLeftRight, PCB_BASE_FRAME::m_Settings, EDA_ITEM::SetFlags(), MODULE::SetOrientation(), and MODULE::SetPosition().

Referenced by FOOTPRINT_EDIT_FRAME::AddModuleToBoard(), and MWAVE::CreateMicrowaveInductor().

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 397 of file eda_base_frame.cpp.

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

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

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

◆ AddStandardSubMenus()

void EDA_DRAW_FRAME::AddStandardSubMenus ( TOOL_MENU aMenu)
inherited

Function CreateBasicMenu.

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

Definition at line 338 of file eda_draw_frame.cpp.

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

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

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

◆ AppendMsgPanel()

void EDA_DRAW_FRAME::AppendMsgPanel ( const wxString &  textUpper,
const wxString &  textLower,
COLOR4D  color,
int  pad = 6 
)
inherited

Append a message to the message panel.

This helper method checks to make sure the message panel exists in the frame and appends a message to it using the message panel AppendMessage() method.

Parameters
textUpper- The message upper text.
textLower- The message lower text.
color- A color ID from the KiCad color list (see colors.h).
pad- Number of spaces to pad between messages (default = 4).

Definition at line 518 of file eda_draw_frame.cpp.

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

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

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

◆ ArchiveModulesOnBoard()

void PCB_EDIT_FRAME::ArchiveModulesOnBoard ( bool  aStoreInNewLib,
const wxString &  aLibName = wxEmptyString,
wxString *  aLibPath = NULL 
)

Function ArchiveModulesOnBoard Save modules in a library:

Parameters
aStoreInNewLibtrue : save modules in a existing lib. Existing footprints will be kept or updated. This lib should be in fp lib table, and is type is .pretty false: save modules in a new lib. It it is an existing lib, previous footprints will be removed
aLibNameoptional library name to create, stops dialog call. must be called with aStoreInNewLib as true

Definition at line 617 of file footprint_libraries_utils.cpp.

619 {
620  if( GetBoard()->GetFirstModule() == NULL )
621  {
622  DisplayInfoMessage( this, _( "No footprints to archive!" ) );
623  return;
624  }
625 
626  wxString footprintName;
627 
628  if( !aStoreInNewLib )
629  {
630  // The footprints are saved in an existing .pretty library in the fp lib table
631  PROJECT& prj = Prj();
632  wxString last_nickname = prj.GetRString( PROJECT::PCB_LIB_NICKNAME );
633  wxString nickname = SelectLibrary( last_nickname );
634 
635  if( !nickname ) // Aborted
636  return;
637 
638  prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
639 
640  try
641  {
642  FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
643 
644  for( auto curr_fp : GetBoard()->Modules() )
645  {
646  if( !curr_fp->GetFPID().GetLibItemName().empty() ) // Can happen with old boards.
647  tbl->FootprintSave( nickname, curr_fp, false );
648  }
649  }
650  catch( const IO_ERROR& ioe )
651  {
652  DisplayError( this, ioe.What() );
653  }
654  }
655  else
656  {
657  // The footprints are saved in a new .pretty library.
658  // If this library already exists, all previous footprints will be deleted
659  wxString libPath = CreateNewLibrary( aLibName );
660 
661  if( libPath.IsEmpty() ) // Aborted
662  return;
663 
664 
665  if( aLibPath ) *aLibPath = libPath;
666 
668  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
669 
670  for( auto curr_fp : GetBoard()->Modules() )
671  {
672  try
673  {
674  if( !curr_fp->GetFPID().GetLibItemName().empty() ) // Can happen with old boards.
675  pi->FootprintSave( libPath, curr_fp );
676  }
677  catch( const IO_ERROR& ioe )
678  {
679  DisplayError( this, ioe.What() );
680  }
681  }
682  }
683 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
PROJECT holds project specific data.
Definition: project.h:59
RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destructor.
Definition: io_mgr.h:577
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:198
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:427
wxString CreateNewLibrary(const wxString &aLibName=wxEmptyString)
Function CreateNewLibrary If a library name is given, creates a new footprint library in the project ...
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:213
#define _(s)
Definition: 3d_actions.cpp:33
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Function PluginFind returns a PLUGIN which the caller can use to import, export, save,...
Definition: io_mgr.cpp:58
wxString SelectLibrary(const wxString &aNicknameExisting)
Function SelectLibrary puts up a dialog and allows the user to pick a library, for unspecified use.
BOARD * GetBoard() const
SAVE_T FootprintSave(const wxString &aNickname, const MODULE *aFootprint, bool aOverwrite=true)
Function FootprintSave.
PCB_FILE_T
Enum PCB_FILE_T is a set of file types that the IO_MGR knows about, and for which there has been a pl...
Definition: io_mgr.h:54
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
S-expression Pcbnew file format.
Definition: io_mgr.h:57

References _, PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DisplayError(), DisplayInfoMessage(), FP_LIB_TABLE::FootprintSave(), PCB_BASE_FRAME::GetBoard(), PROJECT::GetRString(), IO_MGR::KICAD_SEXP, NULL, PROJECT::PCB_LIB_NICKNAME, PROJECT::PcbFootprintLibs(), IO_MGR::PluginFind(), KIWAY_HOLDER::Prj(), PCB_BASE_FRAME::SelectLibrary(), PROJECT::SetRString(), and IO_ERROR::What().

Referenced by ArchiveModulesOnBoard(), importFile(), and Process_Special_Functions().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inlineinherited

Definition at line 225 of file eda_base_frame.h.

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

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

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

◆ CheckForAutoSaveFile()

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

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

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

Parameters
aFileNameA wxFileName object containing the file name to check.

Definition at line 735 of file eda_base_frame.cpp.

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

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

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

◆ Clear_Pcb()

bool PCB_EDIT_FRAME::Clear_Pcb ( bool  aQuery,
bool  aFinal = false 
)

Function Clear_Pcb delete all and reinitialize the current board.

Parameters
aQuery= true to prompt user for confirmation, false to initialize silently
aFinal= if true, we are clearing the board to exit, so don't run more events

Definition at line 39 of file initpcb.cpp.

40 {
41  if( GetBoard() == NULL )
42  return false;
43 
44  if( aQuery && !GetBoard()->IsEmpty() )
45  {
46  if( !IsOK( this,
47  _( "Current Board will be lost and this operation cannot be undone. Continue?" ) ) )
48  return false;
49  }
50 
51  // Release the lock file, if exists
52  ReleaseFile();
53 
54  // Clear undo and redo lists because we want a full deletion
56  GetScreen()->ClrModify();
57 
58  // Items visibility flags will be set because a new board will be created.
59  // Grid and ratsnest can be left to their previous state
60  bool showGrid = IsElementVisible( LAYER_GRID );
61  bool showRats = GetDisplayOptions().m_ShowGlobalRatsnest;
62 
63  if( !aFinal )
64  {
65  // delete the old BOARD and create a new BOARD so that the default
66  // layer names are put into the BOARD.
67  SetBoard( new BOARD() );
68  SetElementVisibility( LAYER_GRID, showGrid );
70 
71  // clear filename, to avoid overwriting an old file
72  GetBoard()->SetFileName( wxEmptyString );
73 
75 
77 
78  // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
79  GetBoard()->SetEnabledLayers( LSET().set() );
80 
81  // Default copper layers count set to 2: double layer board
83 
84  // Update display (some options depend on the board setup)
85  GetBoard()->SetVisibleLayers( LSET().set() );
89  UpdateTitle();
90 
91  Zoom_Automatique( false );
92  }
93 
94  return true;
95 }
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void SetCopperLayerCount(int aCount)
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building le new one, from the new layers names ...
void ReleaseFile()
Release the current file marked in use.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use Display options are relative to...
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:65
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
LSET is a set of PCB_LAYER_IDs.
void ResetNetHighLight()
Function ResetNetHighLight Reset all high light data to the init state.
Definition: class_board.h:348
#define NULL
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
void SetFileName(const wxString &aFileName)
Definition: class_board.h:216
void SetBoard(BOARD *aBoard) override
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
#define _(s)
Definition: 3d_actions.cpp:33
void ClrModify()
Definition: base_screen.h:225
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
BOARD * GetBoard() const
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading a ne...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void ReCreateAuxiliaryToolbar() override

References _, BASE_SCREEN::ClearUndoRedoList(), BASE_SCREEN::ClrModify(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetDisplayOptions(), PCB_BASE_FRAME::GetPageSizeIU(), PCB_BASE_FRAME::GetScreen(), BASE_SCREEN::InitDataPoints(), IsElementVisible(), IsOK(), LAYER_GRID, LAYER_RATSNEST, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, NULL, ReCreateAuxiliaryToolbar(), ReCreateLayerBox(), ReFillLayerWidget(), EDA_DRAW_FRAME::ReleaseFile(), BOARD::ResetNetHighLight(), SetBoard(), BOARD::SetCopperLayerCount(), SetElementVisibility(), BOARD::SetEnabledLayers(), BOARD::SetFileName(), BOARD::SetVisibleLayers(), UpdateTitle(), and EDA_DRAW_FRAME::Zoom_Automatique().

Referenced by Files_io_from_id(), and OpenProjectFiles().

◆ ClearFileHistory()

void EDA_BASE_FRAME::ClearFileHistory ( FILE_HISTORY aFileHistory = NULL)
inherited

Removes all files from the file history.

Parameters
aFileHistoryThe FILE_HISTORY in use. If null, the main application file history is used

Definition at line 643 of file eda_base_frame.cpp.

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

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

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

◆ ClearMsgPanel()

◆ ColorSettings()

◆ CommonSettingsChanged()

void PCB_EDIT_FRAME::CommonSettingsChanged ( bool  aEnvVarsChanged)
overridevirtual

Called after the preferences dialog is run.

Reimplemented from PCB_BASE_FRAME.

Definition at line 1214 of file pcb_edit_frame.cpp.

1215 {
1216  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1217 
1219 
1220  Layout();
1221  SendSizeEvent();
1222 }
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.

References PCB_BASE_FRAME::CommonSettingsChanged().

◆ Compile_Ratsnest()

void PCB_BASE_FRAME::Compile_Ratsnest ( bool  aDisplayStatus)
inherited

Function Compile_Ratsnest Create the entire board ratsnest.

Must be called after a board change (changes for pads, footprints or a read netlist ).

Parameters
aDC= the current device context (can be NULL)
aDisplayStatus: if true, display the computation results

Definition at line 44 of file pcbnew/ratsnest.cpp.

45 {
46  GetBoard()->GetConnectivity()->RecalculateRatsnest();
47  ClearMsgPanel();
48 
49  if( aDisplayStatus )
50  {
51  std::shared_ptr<CONNECTIVITY_DATA> conn = m_Pcb->GetConnectivity();
52  wxString msg;
53 
54  msg.Printf( wxT( " %d" ), conn->GetPadCount() );
55  AppendMsgPanel( _( "Pads" ), msg, RED );
56 
57  msg.Printf( wxT( " %d" ), conn->GetNetCount() - 1 /* Don't include "No Net" in count */ );
58  AppendMsgPanel( _( "Nets" ), msg, CYAN );
59 
60  SetMsgPanel( m_Pcb );
61  }
62 }
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
Definition: colors.h:59
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:306
Definition: colors.h:60
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
#define _(s)
Definition: 3d_actions.cpp:33
BOARD * GetBoard() const

References _, EDA_DRAW_FRAME::AppendMsgPanel(), EDA_DRAW_FRAME::ClearMsgPanel(), CYAN, PCB_BASE_FRAME::GetBoard(), BOARD::GetConnectivity(), PCB_BASE_FRAME::m_Pcb, RED, and EDA_DRAW_FRAME::SetMsgPanel().

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), ExportToGenCAD(), DIALOG_EXCHANGE_FOOTPRINTS::OnApplyClicked(), OpenProjectFiles(), PCBNEW_CONTROL::Paste(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ config()

APP_SETTINGS_BASE * EDA_BASE_FRAME::config ( )
virtualinherited

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

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 572 of file eda_base_frame.cpp.

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

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

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

◆ ConfigBaseName()

wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited
Returns
a base name prefix used in Load/Save settings to build the full name of keys used in config. This is usually the name of the frame set by CTOR, except for frames shown in multiple modes in which case the m_configName must be set to the base name so that a single config can be used.

Definition at line 379 of file eda_base_frame.h.

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

References EDA_BASE_FRAME::m_configName.

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

◆ Create_MuWaveComponent()

MODULE * PCB_EDIT_FRAME::Create_MuWaveComponent ( int  shape_type)

Create_MuWaveComponent creates a module "GAP" or "STUB" used in micro wave designs.

This module has 2 pads: PAD_ATTRIB_SMD, rectangular, H size = V size = current track width. the "gap" is isolation created between this 2 pads

Definition at line 93 of file microwave.cpp.

94 {
95  int oX;
96  D_PAD* pad;
97  MODULE* module;
98  wxString msg, cmp_name;
99  int pad_count = 2;
100  int angle = 0;
101  // Ref and value text size (O = use board default value.
102  // will be set to a value depending on the footprint size, if possible
103  int text_size = 0;
104 
105  // Enter the size of the gap or stub
106  int gap_size = GetDesignSettings().GetCurrentTrackWidth();
107 
108  switch( shape_type )
109  {
110  case 0:
111  msg = _( "Gap Size:" );
112  cmp_name = "muwave_gap";
113  text_size = gap_size;
114  break;
115 
116  case 1:
117  msg = _( "Stub Size:" );
118  cmp_name = "muwave_stub";
119  text_size = gap_size;
120  pad_count = 2;
121  break;
122 
123  case 2:
124  msg = _( "Arc Stub Radius Value:" );
125  cmp_name = "muwave_arcstub";
126  pad_count = 1;
127  break;
128 
129  default:
130  msg = wxT( "???" );
131  break;
132  }
133 
134  wxString value = StringFromValue( GetUserUnits(), gap_size );
135  WX_TEXT_ENTRY_DIALOG dlg( this, msg, _( "Create microwave module" ), value );
136 
137  if( dlg.ShowModal() != wxID_OK )
138  return NULL; // cancelled by user
139 
140  value = dlg.GetValue();
141  gap_size = ValueFromString( GetUserUnits(), value );
142 
143  bool abort = false;
144 
145  if( shape_type == 2 )
146  {
147  double fcoeff = 10.0, fval;
148  msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
149  WX_TEXT_ENTRY_DIALOG angledlg( this, _( "Angle in degrees:" ),
150  _( "Create microwave module" ), msg );
151 
152  if( angledlg.ShowModal() != wxID_OK )
153  return NULL; // cancelled by user
154 
155  msg = angledlg.GetValue();
156 
157  if( !msg.ToDouble( &fval ) )
158  {
159  DisplayError( this, _( "Incorrect number, abort" ) );
160  abort = true;
161  }
162 
163  angle = std::abs( KiROUND( fval * fcoeff ) );
164 
165  if( angle > 1800 )
166  angle = 1800;
167  }
168 
169  if( abort )
170  return NULL;
171 
172  module = CreateMuWaveBaseFootprint( cmp_name, text_size, pad_count );
173  auto it = module->Pads().begin();
174  pad = *it;
175 
176  switch( shape_type )
177  {
178  case 0: //Gap :
179  oX = -( gap_size + pad->GetSize().x ) / 2;
180  pad->SetX0( oX );
181 
182  pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
183 
184  pad = *( it + 1 );
185 
186  pad->SetX0( oX + gap_size + pad->GetSize().x );
187  pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
188  break;
189 
190  case 1: //Stub :
191  pad->SetName( wxT( "1" ) );
192  pad = *( it + 1 );
193  pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 );
194  pad->SetSize( wxSize( pad->GetSize().x, gap_size ) );
195  pad->SetY( pad->GetPos0().y + pad->GetPosition().y );
196  break;
197 
198  case 2: // Arc Stub created by a polygonal approach:
199  {
200  pad->SetShape( PAD_SHAPE_CUSTOM );
202 
203  int numPoints = (angle / 50) + 3; // Note: angles are in 0.1 degrees
204  std::vector<wxPoint> polyPoints;
205  polyPoints.reserve( numPoints );
206 
207  polyPoints.emplace_back( wxPoint( 0, 0 ) );
208 
209  int theta = -angle / 2;
210 
211  for( int ii = 1; ii<numPoints - 1; ii++ )
212  {
213  wxPoint pt( 0, -gap_size );
214  RotatePoint( &pt.x, &pt.y, theta );
215  polyPoints.push_back( pt );
216 
217  theta += 50;
218 
219  if( theta > angle / 2 )
220  theta = angle / 2;
221  }
222 
223  // Close the polygon:
224  polyPoints.push_back( polyPoints[0] );
225 
226  pad->AddPrimitivePoly( polyPoints, 0 ); // add a polygonal basic shape
227  }
228  break;
229 
230  default:
231  break;
232  }
233 
234  module->CalculateBoundingBox();
235  OnModify();
236  return module;
237 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
const wxPoint & GetPos0() const
Definition: class_pad.h:294
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
PADS & Pads()
Definition: class_module.h:173
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:234
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void SetY0(int y)
Definition: class_pad.h:296
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aMergePrimitives=true)
Has meaning only for free shape pads.
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: class_pad.h:274
#define NULL
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
Definition: class_pad.h:187
void SetSize(const wxSize &aSize)
Definition: class_pad.h:299
void SetY(int y)
Definition: class_pad.h:290
MODULE * CreateMuWaveBaseFootprint(const wxString &aValue, int aTextSize, int aPadCount)
Function CreateMuWaveBaseFootprint create a basic footprint for micro wave applications.
Definition: microwave.cpp:52
#define _(s)
Definition: 3d_actions.cpp:33
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:238
void SetX0(int x)
Definition: class_pad.h:297
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:444
const wxSize & GetSize() const
Definition: class_pad.h:300
const wxPoint GetPosition() const override
Definition: class_pad.h:241
void SetX(int x)
Definition: class_pad.h:291
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, D_PAD::AddPrimitivePoly(), PNS::angle(), MODULE::CalculateBoundingBox(), CreateMuWaveBaseFootprint(), DisplayError(), BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth(), PCB_BASE_FRAME::GetDesignSettings(), D_PAD::GetPos0(), D_PAD::GetPosition(), D_PAD::GetSize(), EDA_BASE_FRAME::GetUserUnits(), WX_TEXT_ENTRY_DIALOG::GetValue(), KiROUND(), NULL, OnModify(), PAD_SHAPE_CUSTOM, PAD_SHAPE_RECT, MODULE::Pads(), RotatePoint(), D_PAD::SetAnchorPadShape(), D_PAD::SetName(), D_PAD::SetShape(), D_PAD::SetSize(), D_PAD::SetX(), D_PAD::SetX0(), D_PAD::SetY(), D_PAD::SetY0(), StringFromValue(), ValueFromString(), wxPoint::x, and wxPoint::y.

◆ Create_MuWavePolygonShape()

MODULE * PCB_EDIT_FRAME::Create_MuWavePolygonShape ( )

Definition at line 428 of file microwave.cpp.

429 {
430  D_PAD* pad1, * pad2;
431  MODULE* module;
432  wxString cmp_name;
433  int pad_count = 2;
434  EDGE_MODULE* edge;
435 
436  MWAVE_POLYGONAL_SHAPE_DLG dlg( this, wxDefaultPosition );
437 
438  int ret = dlg.ShowModal();
439 
440  if( ret != wxID_OK )
441  {
442  PolyEdges.clear();
443  return NULL;
444  }
445 
446  if( PolyShapeType == 2 ) // mirrored
448 
451 
452  if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
453  {
454  DisplayError( this, _( "Shape has a null size!" ) );
455  return NULL;
456  }
457 
458  if( PolyEdges.size() == 0 )
459  {
460  DisplayError( this, _( "Shape has no points!" ) );
461  return NULL;
462  }
463 
464  cmp_name = wxT( "muwave_polygon" );
465 
466  // Create a footprint with 2 pads, orientation = 0, pos 0
467  module = CreateMuWaveBaseFootprint( cmp_name, 0, pad_count );
468 
469  // We try to place the footprint anchor to the middle of the shape len
470  wxPoint offset;
471  offset.x = -ShapeSize.x / 2;
472 
473  auto it = module->Pads().begin();
474 
475  pad1 = *it;
476  pad1->SetX0( offset.x );
477  pad1->SetX( pad1->GetPos0().x );
478 
479  pad2 = *( ++it );
480  pad2->SetX0( offset.x + ShapeSize.x );
481  pad2->SetX( pad2->GetPos0().x );
482 
483  // Add a polygonal edge (corners will be added later) on copper layer
484  edge = new EDGE_MODULE( module );
485  edge->SetShape( S_POLYGON );
486  edge->SetLayer( F_Cu );
487 
488  module->Add( edge, ADD_MODE::INSERT );
489 
490  // Get the corner buffer of the polygonal edge
491  std::vector<wxPoint> polyPoints;
492  polyPoints.reserve( PolyEdges.size() + 2 );
493 
494  // Init start point coord:
495  polyPoints.emplace_back( wxPoint( offset.x, 0 ) );
496 
497  wxPoint last_coordinate;
498 
499  for( wxRealPoint& pt: PolyEdges ) // Copy points
500  {
501  last_coordinate.x = KiROUND( pt.x * ShapeScaleX );
502  last_coordinate.y = -KiROUND( pt.y * ShapeScaleY );
503  last_coordinate += offset;
504  polyPoints.push_back( last_coordinate );
505  }
506 
507  // finish the polygonal shape
508  if( last_coordinate.y != 0 )
509  polyPoints.emplace_back( wxPoint( last_coordinate.x, 0 ) );
510 
511  switch( PolyShapeType )
512  {
513  case 0: // shape from file
514  case 2: // shape from file, mirrored (the mirror is already done)
515  break;
516 
517  case 1: // Symmetric shape: add the symmetric (mirrored) shape
518  for( int ndx = (int) polyPoints.size() - 1; ndx >= 0; --ndx )
519  {
520  wxPoint pt = polyPoints[ndx];
521  pt.y = -pt.y; // mirror about X axis
522  polyPoints.push_back( pt );
523  }
524  break;
525  }
526 
527  edge->SetPolyPoints( polyPoints );
528  // Set the polygon outline thickness to 0, only the polygonal shape is filled
529  // without extra thickness
530  edge->SetWidth( 0 );
531  PolyEdges.clear();
532  module->CalculateBoundingBox();
533  OnModify();
534  return module;
535 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
static wxSize ShapeSize
Definition: microwave.cpp:48
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
void SetShape(STROKE_T aShape)
const wxPoint & GetPos0() const
Definition: class_pad.h:294
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
polygon (not yet used for tracks, but could be in microwave apps)
PADS & Pads()
Definition: class_module.h:173
static int PolyShapeType
Definition: microwave.cpp:49
#define NULL
static double ShapeScaleX
Definition: microwave.cpp:47
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
MODULE * CreateMuWaveBaseFootprint(const wxString &aValue, int aTextSize, int aPadCount)
Function CreateMuWaveBaseFootprint create a basic footprint for micro wave applications.
Definition: microwave.cpp:52
#define _(s)
Definition: 3d_actions.cpp:33
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
void SetX0(int x)
Definition: class_pad.h:297
static double ShapeScaleY
Definition: microwave.cpp:47
void SetX(int x)
Definition: class_pad.h:291
static std::vector< wxRealPoint > PolyEdges
Definition: microwave.cpp:46
void SetWidth(int aWidth)

References _, MODULE::Add(), MODULE::CalculateBoundingBox(), CreateMuWaveBaseFootprint(), DisplayError(), F_Cu, D_PAD::GetPos0(), INSERT, KiROUND(), NULL, OnModify(), MODULE::Pads(), PolyEdges, PolyShapeType, S_POLYGON, BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetPolyPoints(), DRAWSEGMENT::SetShape(), DRAWSEGMENT::SetWidth(), D_PAD::SetX(), D_PAD::SetX0(), ShapeScaleX, ShapeScaleY, ShapeSize, wxPoint::x, and wxPoint::y.

◆ CreateAndShow3D_Frame()

EDA_3D_VIEWER * PCB_BASE_FRAME::CreateAndShow3D_Frame ( )
inherited

Shows the 3D view frame.

If it does not exist, it is created. If it exists, it is bring to the foreground

Definition at line 399 of file pcb_base_frame.cpp.

400 {
401  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
402 
403  if( !draw3DFrame )
404  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
405 
406  // Raising the window does not show the window on Windows if iconized. This should work
407  // on any platform.
408  if( draw3DFrame->IsIconized() )
409  draw3DFrame->Iconize( false );
410 
411  draw3DFrame->Raise();
412  draw3DFrame->Show( true );
413 
414  // Raising the window does not set the focus on Linux. This should work on any platform.
415  if( wxWindow::FindFocus() != draw3DFrame )
416  draw3DFrame->SetFocus();
417 
418  return draw3DFrame;
419 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
#define _(s)
Definition: 3d_actions.cpp:33
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:65
EDA_3D_VIEWER * Get3DViewerFrame()

References _, PCB_BASE_FRAME::Get3DViewerFrame(), and KIWAY_HOLDER::Kiway().

Referenced by CVPCB_FOOTPRINT_VIEWER_CONTROL::Show3DViewer(), and PCBNEW_CONTROL::Show3DViewer().

◆ createBackupFile()

wxString PCB_EDIT_FRAME::createBackupFile ( const wxString &  aFileName)
protected

Definition at line 656 of file pcbnew/files.cpp.

657 {
658  wxFileName fn = aFileName;
659  wxFileName backupFileName = aFileName;
660 
661  backupFileName.SetExt( fn.GetExt() + GetBackupSuffix() );
662 
663  // If an old backup file exists, delete it. If an old board file exists,
664  // rename it to the backup file name.
665  if( fn.FileExists() )
666  {
667  // Remove the old file xxx.000 if it exists.
668  if( backupFileName.FileExists() )
669  wxRemoveFile( backupFileName.GetFullPath() );
670 
671  // Rename the current file from <xxx>.kicad_pcb to <xxx>.kicad_pcb-bak
672  if( !wxRenameFile( fn.GetFullPath(), backupFileName.GetFullPath() ) )
673  {
674  wxString msg = wxString::Format( _(
675  "Warning: unable to create backup file \"%s\"" ),
676  GetChars( backupFileName.GetFullPath() )
677  );
678  DisplayError( NULL, msg );
679  }
680  }
681  else
682  {
683  backupFileName.Clear();
684  }
685 
686  return backupFileName.GetFullPath();
687 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
#define NULL
static wxString GetBackupSuffix()
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33

References _, DisplayError(), Format(), EDA_BASE_FRAME::GetBackupSuffix(), GetChars(), and NULL.

Referenced by SavePcbFile().

◆ CreateMuWaveBaseFootprint()

MODULE * PCB_EDIT_FRAME::CreateMuWaveBaseFootprint ( const wxString &  aValue,
int  aTextSize,
int  aPadCount 
)

Function CreateMuWaveBaseFootprint create a basic footprint for micro wave applications.

Parameters
aValue= the text value
aTextSize= the size of ref and value texts ( <= 0 to use board default values )
aPadCount= number of pads Pads settings are: PAD_ATTRIB_SMD, rectangular, H size = V size = current track width.

Definition at line 52 of file microwave.cpp.

54 {
55  MODULE* module = CreateNewModule( aValue );
56 
57  if( aTextSize > 0 )
58  {
59  module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) );
60  module->Reference().SetThickness( aTextSize/5 );
61  module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) );
62  module->Value().SetThickness( aTextSize/5 );
63  }
64 
65  // Create 2 pads used in gaps and stubs. The gap is between these 2 pads
66  // the stub is the pad 2
67  wxString Line;
68  int pad_num = 1;
69 
70  while( aPadCount-- )
71  {
72  D_PAD* pad = new D_PAD( module );
73 
74  module->Add( pad, ADD_MODE::INSERT );
75 
77  pad->SetSize( wxSize( tw, tw ) );
78 
79  pad->SetPosition( module->GetPosition() );
80  pad->SetShape( PAD_SHAPE_RECT );
82  pad->SetLayerSet( F_Cu );
83 
84  Line.Printf( wxT( "%d" ), pad_num );
85  pad->SetName( Line );
86  pad_num++;
87  }
88 
89  return module;
90 }
TEXTE_MODULE & Reference()
Definition: class_module.h:477
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:62
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:240
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
MODULE * CreateNewModule(const wxString &aModuleName)
Function CreateNewModule Creates a new module or footprint, at position 0,0 The new module contains o...
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
Definition: class_pad.h:187
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:476
void SetSize(const wxSize &aSize)
Definition: class_pad.h:299
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:423
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:445
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:238
const wxPoint GetPosition() const override
Definition: class_module.h:210
void SetThickness(int aNewThickness)
Set the pen width.
Definition: eda_text.h:143

References MODULE::Add(), PCB_BASE_FRAME::CreateNewModule(), F_Cu, BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth(), PCB_BASE_FRAME::GetDesignSettings(), MODULE::GetPosition(), INSERT, PAD_ATTRIB_SMD, PAD_SHAPE_RECT, MODULE::Reference(), D_PAD::SetAttribute(), D_PAD::SetLayerSet(), D_PAD::SetName(), D_PAD::SetPosition(), D_PAD::SetShape(), D_PAD::SetSize(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), and MODULE::Value().

Referenced by Create_MuWaveComponent(), and Create_MuWavePolygonShape().

◆ CreateNewLibrary()

wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary ( const wxString &  aLibName = wxEmptyString)
inherited

Function CreateNewLibrary If a library name is given, creates a new footprint library in the project folder with the given name.

If no library name is given it prompts user for a library path, then creates a new footprint library at that location. If library exists, user is warned about that, and is given a chance to abort the new creation, and in that case existing library is first deleted.

Returns
wxString - the newly created library path if library was successfully created, else wxEmptyString because user aborted or error.

Definition at line 393 of file footprint_libraries_utils.cpp.

394 {
395  // Kicad cannot write legacy format libraries, only .pretty new format
396  // because the legacy format cannot handle current features.
397  // The footprint library is actually a directory
398 
399  wxString initialPath = wxPathOnly( Prj().GetProjectFullName() );
400  wxFileName fn;
401  bool doAdd = false;
402 
403  if( aLibName.IsEmpty() )
404  {
405  fn = initialPath;
406 
407  if( !LibraryFileBrowser( false, fn,
409  {
410  return wxEmptyString;
411  }
412 
413  doAdd = true;
414  }
415  else
416  {
417  fn = aLibName;
418 
419  if( !fn.IsAbsolute() )
420  {
421  fn.SetName( aLibName );
422  fn.MakeAbsolute( initialPath );
423  }
424 
425  // Enforce the .pretty extension:
426  fn.SetExt( KiCadFootprintLibPathExtension );
427  }
428 
429  // We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries)
431  wxString libPath = fn.GetFullPath();
432 
433  try
434  {
435  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
436 
437  bool writable = false;
438  bool exists = false;
439 
440  try
441  {
442  writable = pi->IsFootprintLibWritable( libPath );
443  exists = true; // no exception was thrown, lib must exist.
444  }
445  catch( const IO_ERROR& )
446  { }
447 
448  if( exists )
449  {
450  if( !writable )
451  {
452  wxString msg = wxString::Format( FMT_LIB_READ_ONLY, libPath );
453  DisplayError( this, msg );
454  return wxEmptyString;
455  }
456  else
457  {
458  wxString msg = wxString::Format( _( "Library %s already exists." ), libPath );
459  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
460  dlg.SetOKLabel( _( "Overwrite" ) );
461  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
462 
463  if( dlg.ShowModal() == wxID_CANCEL )
464  return wxEmptyString;
465 
466  pi->FootprintLibDelete( libPath );
467  }
468  }
469 
470  pi->FootprintLibCreate( libPath );
471  }
472  catch( const IO_ERROR& ioe )
473  {
474  DisplayError( this, ioe.What() );
475  return wxEmptyString;
476  }
477 
478  if( doAdd )
479  AddLibrary( libPath );
480 
481  return libPath;
482 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destructor.
Definition: io_mgr.h:577
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
bool AddLibrary(const wxString &aLibName=wxEmptyString)
Function AddLibrary Add an existing library to either the global or project library table.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
#define FMT_LIB_READ_ONLY
wxString KiCadFootprintLibPathWildcard()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Function PluginFind returns a PLUGIN which the caller can use to import, export, save,...
Definition: io_mgr.cpp:58
PCB_FILE_T
Enum PCB_FILE_T is a set of file types that the IO_MGR knows about, and for which there has been a pl...
Definition: io_mgr.h:54
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
const std::string KiCadFootprintLibPathExtension
S-expression Pcbnew file format.
Definition: io_mgr.h:57

References _, PCB_BASE_EDIT_FRAME::AddLibrary(), DisplayError(), KIDIALOG::DoNotShowCheckbox(), FMT_LIB_READ_ONLY, Format(), IO_MGR::KICAD_SEXP, KiCadFootprintLibPathExtension, KiCadFootprintLibPathWildcard(), EDA_DRAW_FRAME::LibraryFileBrowser(), IO_MGR::PluginFind(), KIWAY_HOLDER::Prj(), KIDIALOG::ShowModal(), and IO_ERROR::What().

Referenced by ArchiveModulesOnBoard().

◆ CreateNewModule()

MODULE * PCB_BASE_FRAME::CreateNewModule ( const wxString &  aModuleName)
inherited

Function CreateNewModule Creates a new module or footprint, at position 0,0 The new module contains only 2 texts: a reference and a value: Reference = REF** Value = "VAL**" or Footprint name in lib Note: they are dummy texts, which will be replaced by the actual texts when the fooprint is placed on a board and a netlist is read.

Parameters
aModuleName= name of the new footprint in library
Returns
a reference to the new module

Definition at line 1012 of file footprint_libraries_utils.cpp.

1013 {
1014  // Creates a new footprint at position 0,0 which contains the minimal items:
1015  // the reference and the value.
1016  // Value : initialized to the footprint name.
1017  // put on fab layer (front side)
1018  // Reference : initialized to a default value (REF**).
1019  // put on silkscreen layer (front side)
1020 
1021  wxString moduleName = aModuleName;
1022 
1023  // Ask for the new module name
1024  if( moduleName.IsEmpty() )
1025  {
1026  WX_TEXT_ENTRY_DIALOG dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
1027  dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &moduleName ) );
1028 
1029  if( dlg.ShowModal() != wxID_OK )
1030  return NULL; //Aborted by user
1031  }
1032 
1033  moduleName.Trim( true );
1034  moduleName.Trim( false );
1035 
1036  if( moduleName.IsEmpty() )
1037  {
1039  return NULL;
1040  }
1041 
1042  // Creates the new module and add it to the head of the linked list of modules
1043  MODULE* module = new MODULE( GetBoard() );
1044 
1045  // Update parameters: timestamp ...
1046  module->SetLastEditTime();
1047 
1048  // Update its name in lib
1049  module->SetFPID( LIB_ID( wxEmptyString, moduleName ) );
1050 
1051  wxPoint default_pos;
1053 
1054  // Update reference:
1055  if( settings.m_RefDefaultText.empty() )
1056  module->SetReference( moduleName );
1057  else
1058  module->SetReference( settings.m_RefDefaultText );
1059 
1060  PCB_LAYER_ID layer = ToLAYER_ID( settings.m_RefDefaultlayer );
1061  module->Reference().SetThickness( settings.GetTextThickness( layer ) );
1062  module->Reference().SetTextSize( settings.GetTextSize( layer ) );
1063  module->Reference().SetItalic( settings.GetTextItalic( layer ) );
1064  module->Reference().SetKeepUpright( settings.GetTextUpright( layer ) );
1065  default_pos.y = GetDesignSettings().GetTextSize( layer ).y / 2;
1066  module->Reference().SetPosition( default_pos );
1067  module->Reference().SetLayer( layer );
1068  module->Reference().SetVisible( settings.m_RefDefaultVisibility );
1069 
1070  // Set the value field to a default value
1071  if( settings.m_ValueDefaultText.empty() )
1072  module->SetValue( moduleName );
1073  else
1074  module->SetValue( settings.m_ValueDefaultText );
1075 
1076  layer = ToLAYER_ID( settings.m_ValueDefaultlayer );
1077  module->Value().SetThickness( settings.GetTextThickness( layer ) );
1078  module->Value().SetTextSize( settings.GetTextSize( layer ) );
1079  module->Value().SetItalic( settings.GetTextItalic( layer ) );
1080  module->Value().SetKeepUpright( settings.GetTextUpright( layer ) );
1081  default_pos.y = -default_pos.y;
1082  module->Value().SetPosition( default_pos );
1083  module->Value().SetLayer( layer );
1084  module->Value().SetVisible( settings.m_ValueDefaultVisibility );
1085 
1086  SetMsgPanel( module );
1087  return module;
1088 }
wxString m_RefDefaultText
Default ref text on fp creation.
bool m_ValueDefaultVisibility
Default value text visibility on fp creation.
void SetKeepUpright(bool aKeepUpright)
TEXTE_MODULE & Reference()
Definition: class_module.h:477
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetItalic(bool isItalic)
Definition: eda_text.h:163
void SetVisible(bool aVisible)
Definition: eda_text.h:169
int m_ValueDefaultlayer
Default value text layer on fp creation.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
int GetTextThickness(PCB_LAYER_ID aLayer) const
Function GetTextThickness Returns the default text thickness from the layer class for the given layer...
bool GetTextUpright(PCB_LAYER_ID aLayer) const
bool GetTextItalic(PCB_LAYER_ID aLayer) const
#define FMT_NO_REF_ABORTED
PCB_LAYER_ID
A quick note on layer IDs:
#define NULL
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:476
void SetLastEditTime(timestamp_t aTime)
Definition: class_module.h:347
This class provides a custom wxValidator object for limiting the allowable characters when defining f...
Definition: validators.h:63
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:446
virtual void SetPosition(const wxPoint &aPos) override
wxString m_ValueDefaultText
Default value text on fp creation.
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:470
int m_RefDefaultlayer
Default ref text layer on fp creation.
BOARD * GetBoard() const
#define FMT_MOD_CREATE
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
bool m_RefDefaultVisibility
Default ref text visibility on fp creation.
void SetFPID(const LIB_ID &aFPID)
Definition: class_module.h:220
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Function GetTextSize Returns the default text size from the layer class for the given layer.
void SetThickness(int aNewThickness)
Set the pen width.
Definition: eda_text.h:143
#define FMT_MOD_REF
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References DisplayInfoMessage(), FMT_MOD_CREATE, FMT_MOD_REF, FMT_NO_REF_ABORTED, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetTextItalic(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), BOARD_DESIGN_SETTINGS::GetTextUpright(), BOARD_DESIGN_SETTINGS::m_RefDefaultlayer, BOARD_DESIGN_SETTINGS::m_RefDefaultText, BOARD_DESIGN_SETTINGS::m_RefDefaultVisibility, BOARD_DESIGN_SETTINGS::m_ValueDefaultlayer, BOARD_DESIGN_SETTINGS::m_ValueDefaultText, BOARD_DESIGN_SETTINGS::m_ValueDefaultVisibility, NULL, MODULE::Reference(), MODULE::SetFPID(), EDA_TEXT::SetItalic(), TEXTE_MODULE::SetKeepUpright(), MODULE::SetLastEditTime(), BOARD_ITEM::SetLayer(), EDA_DRAW_FRAME::SetMsgPanel(), TEXTE_MODULE::SetPosition(), MODULE::SetReference(), EDA_TEXT::SetTextSize(), WX_TEXT_ENTRY_DIALOG::SetTextValidator(), EDA_TEXT::SetThickness(), MODULE::SetValue(), EDA_TEXT::SetVisible(), ToLAYER_ID(), MODULE::Value(), and wxPoint::y.

Referenced by MWAVE::CreateMicrowaveInductor(), and CreateMuWaveBaseFootprint().

◆ CreateServer()

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

Definition at line 49 of file eda_dde.cpp.

50 {
51  wxIPV4address addr;
52 
53  // Set the port number
54  addr.Service( service );
55 
56  // Listen on localhost only if requested
57  if( local )
58  addr.Hostname( HOSTNAME );
59 
60  delete m_socketServer;
61  m_socketServer = new wxSocketServer( addr );
62 
63  m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
64  m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
65  m_socketServer->Notify( true );
66 }
static const wxString HOSTNAME(wxT("localhost"))
wxSocketServer * m_socketServer

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

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

◆ CurrentToolName()

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

Definition at line 252 of file eda_base_frame.cpp.

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

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

Referenced by TOOL_MANAGER::processEvent().

◆ Destroy()

◆ DismissModal()

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

Definition at line 160 of file kiway_player.cpp.

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

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

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

◆ DisplayGridMsg()

void PCB_BASE_FRAME::DisplayGridMsg ( )
inherited

Function DisplayGridMsg()

Display the current grid pane on the status bar.

Definition at line 588 of file pcb_base_frame.cpp.

589 {
590  wxString line;
591  wxString gridformatter;
592 
593  switch( m_userUnits )
594  {
595  case EDA_UNITS::INCHES:
596  gridformatter = "grid X %.6f Y %.6f";
597  break;
598 
600  gridformatter = "grid X %.6f Y %.6f";
601  break;
602 
603  default:
604  gridformatter = "grid X %f Y %f";
605  break;
606  }
607 
608  BASE_SCREEN* screen = GetScreen();
609  wxArrayString gridsList;
610 
611  int icurr = screen->BuildGridsChoiceList( gridsList, m_userUnits != EDA_UNITS::INCHES );
612  GRID_TYPE& grid = screen->GetGrid( icurr );
613  double grid_x = To_User_Unit( m_userUnits, grid.m_Size.x );
614  double grid_y = To_User_Unit( m_userUnits, grid.m_Size.y );
615  line.Printf( gridformatter, grid_x, grid_y );
616 
617  SetStatusText( line, 4 );
618 }
double To_User_Unit(EDA_UNITS aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:95
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:286
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
wxRealPoint m_Size
Definition: base_screen.h:47
GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
EDA_UNITS m_userUnits
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.

References BASE_SCREEN::BuildGridsChoiceList(), BASE_SCREEN::GetGrid(), PCB_BASE_FRAME::GetScreen(), INCHES, GRID_TYPE::m_Size, EDA_BASE_FRAME::m_userUnits, MILLIMETRES, and To_User_Unit().

Referenced by PCB_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 364 of file eda_draw_frame.cpp.

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

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

◆ DisplayUnitsMsg()

void EDA_DRAW_FRAME::DisplayUnitsMsg ( )
inherited

Display current unit pane on the status bar.

Definition at line 401 of file eda_draw_frame.cpp.

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

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

Referenced by GERBVIEW_FRAME::updateGridSelectBox(), PCB_BASE_FRAME::UpdateGridSelectBox(), SCH_BASE_FRAME::UpdateStatusBar(), and EDA_DRAW_FRAME::UpdateStatusBar().

◆ doAutoSave()

bool PCB_EDIT_FRAME::doAutoSave ( )
overrideprotectedvirtual

Function doAutoSave performs auto save when the board has been modified and not saved within the auto save interval.

Returns
true if the auto save was successful.

Reimplemented from EDA_BASE_FRAME.

Definition at line 834 of file pcbnew/files.cpp.

835 {
836  wxFileName tmpFileName;
837 
838  if( GetBoard()->GetFileName().IsEmpty() )
839  {
840  tmpFileName = wxFileName( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ),
842  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
843  }
844  else
845  {
846  tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
847  }
848 
849  wxFileName autoSaveFileName = tmpFileName;
850 
851  // Auto save file name is the board file name prepended with autosaveFilePrefix string.
852  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() );
853 
854  if( !autoSaveFileName.IsOk() )
855  return false;
856 
857  // If the board file path is not writable, try writing to a platform specific temp file
858  // path. If that path isn't writabe, give up.
859  if( !autoSaveFileName.IsDirWritable() )
860  {
861  autoSaveFileName.SetPath( wxFileName::GetTempDir() );
862 
863  if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
864  return false;
865  }
866 
867  wxLogTrace( traceAutoSave, "Creating auto save file <" + autoSaveFileName.GetFullPath() + ">" );
868 
869  if( SavePcbFile( autoSaveFileName.GetFullPath(), NO_BACKUP_FILE ) )
870  {
871  GetScreen()->SetModify();
872  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
873  UpdateTitle();
874  m_autoSaveState = false;
875  return true;
876  }
877 
878  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
879 
880  return false;
881 }
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const std::string KiCadPcbFileExtension
#define NO_BACKUP_FILE
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:413
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void SetFileName(const wxString &aFileName)
Definition: class_board.h:216
static wxString GetAutoSaveFilePrefix()
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
void SetModify()
Definition: base_screen.h:224
bool SavePcbFile(const wxString &aFileName, bool aCreateBackupFile=CREATE_BACKUP_FILE)
Function SavePcbFile writes the board data structures to a aFileName Creates backup when requested an...

References PROJECT::AbsolutePath(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetScreen(), KiCadPcbFileExtension, EDA_BASE_FRAME::m_autoSaveState, NO_BACKUP_FILE, KIWAY_HOLDER::Prj(), SavePcbFile(), BOARD::SetFileName(), BASE_SCREEN::SetModify(), traceAutoSave, and UpdateTitle().

Referenced by OnExportSTEP().

◆ DoGenFootprintsPositionFile()

int PCB_EDIT_FRAME::DoGenFootprintsPositionFile ( const wxString &  aFullFileName,
bool  aUnitsMM,
bool  aForceSmdItems,
bool  aTopSide,
bool  BottomSide,
bool  aFormatCSV = false 
)

Function DoGenFootprintsPositionFile Creates an ascii footprint position file.

Parameters
aFullFileName= the full file name of the file to create
aUnitsMM= false to use inches, true to use mm in coordinates
aForceSmdItems= true to force all footprints with smd pads in list = false to put only footprints with option "INSERT" in list
aTopSidetrue to list footprints on front (top) side,
BottomSidetrue to list footprints on back (bottom) side, if aTopSide and aTopSide are true, list footprints on both sides
aFormatCSV= true to use a comma separated file (CSV) format; defautl = false
Returns
the number of footprints found on aSide side, or -1 if the file could not be created

Definition at line 479 of file gen_footprints_placefile.cpp.

481 {
482  FILE * file = NULL;
483 
484  if( !aFullFileName.IsEmpty() )
485  {
486  file = wxFopen( aFullFileName, wxT( "wt" ) );
487 
488  if( file == NULL )
489  return -1;
490  }
491 
492  std::string data;
493  PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aForceSmdItems,
494  aTopSide, BottomSide, aFormatCSV );
495  data = exporter.GenPositionData();
496 
497  // if aFullFileName is empty, the file is not created, only the
498  // count of footprints to place is returned
499  if( file )
500  {
501  // Creates a footprint position file
502  // aSide = 0 -> Back (bottom) side)
503  // aSide = 1 -> Front (top) side)
504  // aSide = 2 -> both sides
505  fputs( data.c_str(), file );
506  fclose( file );
507  }
508 
509  return exporter.GetFootprintCount();
510 }
#define NULL
The ASCII format of the kicad place file is:
BOARD * GetBoard() const

References PLACE_FILE_EXPORTER::GenPositionData(), PCB_BASE_FRAME::GetBoard(), PLACE_FILE_EXPORTER::GetFootprintCount(), and NULL.

Referenced by DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles().

◆ DoGenFootprintsReport()

bool PCB_EDIT_FRAME::DoGenFootprintsReport ( const wxString &  aFullFilename,
bool  aUnitsMM 
)

Function DoGenFootprintsReport Creates an ascii footprint report file giving some infos on footprints and board outlines.

Parameters
aFullFilename= the full file name of the file to create
aUnitsMM= false to use inches, true to use mm in coordinates
Returns
true if OK, false if error

Definition at line 546 of file gen_footprints_placefile.cpp.

547 {
548  wxString msg;
549  FILE* rptfile;
550  wxPoint module_pos;
551 
552  rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
553 
554  if( rptfile == NULL )
555  return false;
556 
557  std::string data;
558  PLACE_FILE_EXPORTER exporter ( GetBoard(), aUnitsMM, false, true, true, false );
559  data = exporter.GenReportData();
560 
561  fputs( data.c_str(), rptfile );
562  fclose( rptfile );
563 
564  return true;
565 }
#define NULL
The ASCII format of the kicad place file is:
BOARD * GetBoard() const

References PLACE_FILE_EXPORTER::GenReportData(), PCB_BASE_FRAME::GetBoard(), and NULL.

Referenced by GenFootprintsReport().

◆ DoShowBoardSetupDialog()

void PCB_EDIT_FRAME::DoShowBoardSetupDialog ( const wxString &  aInitialPage = wxEmptyString,
const wxString &  aInitialParentPage = wxEmptyString 
)

Function ShowBoardSetupDialog.

Definition at line 608 of file pcb_edit_frame.cpp.

610 {
611  DIALOG_BOARD_SETUP dlg( this );
612 
613  if( !aInitialPage.IsEmpty() )
614  dlg.SetInitialPage( aInitialPage, aInitialParentPage );
615 
616  if( dlg.ShowQuasiModal() == wxID_OK )
617  {
619 
622 
623  for( auto module : GetBoard()->Modules() )
624  GetCanvas()->GetView()->Update( module );
625 
626  GetCanvas()->Refresh();
627 
628  //this event causes the routing tool to reload its design rules information
630  toolEvent.SetHasPosition( false );
631  m_toolManager->ProcessEvent( toolEvent );
632 
633  OnModify();
634  }
635 }
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Action belongs to a particular tool (i.e. a part of a pop-up menu)
Definition: tool_event.h:146
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
TOOL_EVENT.
Definition: tool_event.h:171
void SaveProjectSettings() override
Function SaveProjectSettings saves changes to the project settings to the project (....
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
TOOL_MANAGER * m_toolManager
BOARD * GetBoard() const
void ReCreateAuxiliaryToolbar() override

References AS_ACTIVE, GetBoard(), TOOL_EVENT::SetHasPosition(), PAGED_DIALOG::SetInitialPage(), DIALOG_SHIM::ShowQuasiModal(), TA_MODEL_CHANGE, TC_COMMAND, and UpdateUserInterface().

Referenced by DIALOG_DRC::OnDRCItemRClick(), and Tracks_and_Vias_Size_Event().

◆ DoUpdatePCBFromNetlist()

void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist ( NETLIST aNetlist,
bool  aUseTimestamps 
)

Function DoUpdatePCBFromNetlist An automated version of UpdatePCBFromNetlist which skips the UI dialog.

Parameters
aNetlist
aUseTimestamps

Definition at line 1052 of file pcb_edit_frame.cpp.

1053 {
1054  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1055  updater.SetLookupByTimestamp( aUseTimestamps );
1056  updater.SetDeleteUnusedComponents( false );
1057  updater.SetReplaceFootprints( true );
1058  updater.SetDeleteSinglePadNets( false );
1059  updater.SetWarnPadNoNetInNetlist( false );
1060  updater.UpdateNetlist( aNetlist );
1061 }
BOARD_NETLIST_UPDATER updates the BOARD with a new netlist.
BOARD * GetBoard() const

References GetBoard(), BOARD_NETLIST_UPDATER::SetDeleteSinglePadNets(), BOARD_NETLIST_UPDATER::SetDeleteUnusedComponents(), BOARD_NETLIST_UPDATER::SetLookupByTimestamp(), BOARD_NETLIST_UPDATER::SetReplaceFootprints(), BOARD_NETLIST_UPDATER::SetWarnPadNoNetInNetlist(), and BOARD_NETLIST_UPDATER::UpdateNetlist().

Referenced by importFile().

◆ Edit_Module()

void PCB_BASE_FRAME::Edit_Module ( MODULE module,
wxDC *  DC 
)
inherited

◆ Edit_Zone_Params()

void PCB_EDIT_FRAME::Edit_Zone_Params ( ZONE_CONTAINER zone_container)

Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline.

Definition at line 48 of file zones_by_polygon.cpp.

49 {
50  int dialogResult;
51  ZONE_SETTINGS zoneInfo = GetZoneSettings();
52 
53  BOARD_COMMIT commit( this );
54 
55  // Save initial zones configuration, for undo/redo, before adding new zone
56  // note the net name and the layer can be changed, so we must save all zones
60 
61  if( aZone->GetIsKeepout() )
62  {
63  // edit a keepout area on a copper layer
64  zoneInfo << *aZone;
65  dialogResult = InvokeKeepoutAreaEditor( this, &zoneInfo );
66  }
67  else if( IsCopperLayer( aZone->GetLayer() ) )
68  {
69  // edit a zone on a copper layer
70  zoneInfo << *aZone;
71  dialogResult = InvokeCopperZonesEditor( this, &zoneInfo );
72  }
73  else
74  {
75  zoneInfo << *aZone;
76  dialogResult = InvokeNonCopperZonesEditor( this, &zoneInfo );
77  }
78 
79  if( dialogResult == wxID_CANCEL )
80  {
83  return;
84  }
85 
86  SetZoneSettings( zoneInfo );
87  OnModify();
88 
89  if( dialogResult == ZONE_EXPORT_VALUES )
90  {
92  commit.Stage( s_PickedList );
93  commit.Push( _( "Modify zone properties" ) );
94  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
95  return;
96  }
97 
98  wxBusyCursor dummy;
99 
100  // Undraw old zone outlines
101  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
102  {
103  ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii );
104  GetCanvas()->GetView()->Update( edge_zone );
105  }
106 
107  zoneInfo.ExportSetting( *aZone );
108 
109  NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
110 
111  if( net ) // net == NULL should not occur
112  aZone->SetNetCode( net->GetNet() );
113 
114  // Combine zones if possible
116 
118 
119  // refill zones with the new properties applied
120  std::vector<ZONE_CONTAINER*> zones_to_refill;
121 
122  for( unsigned i = 0; i < s_PickedList.GetCount(); ++i )
123  {
124  ZONE_CONTAINER* zone = dyn_cast<ZONE_CONTAINER*>( s_PickedList.GetPickedItem( i ) );
125 
126  if( zone == nullptr )
127  {
128  wxASSERT_MSG( false, "Expected a zone after zone properties edit" );
129  continue;
130  }
131 
132  if( zone->IsFilled() )
133  zones_to_refill.push_back( zone );
134  }
135 
136  if( zones_to_refill.size() )
137  {
138  ZONE_FILLER filler ( GetBoard() );
139  wxString title = wxString::Format( _( "Refill %d Zones" ), (int) zones_to_refill.size() );
140  filler.InstallNewProgressReporter( this, title, 4 );
141  filler.Fill( zones_to_refill );
142  }
143 
144  commit.Stage( s_PickedList );
145  commit.Push( _( "Modify zone properties" ) );
146  GetBoard()->GetConnectivity()->RecalculateRatsnest();
147 
148  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
149 }
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
bool IsFilled() const
Definition: class_zone.h:188
int InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
void UpdateCopyOfZonesList(PICKED_ITEMS_LIST &aPickList, PICKED_ITEMS_LIST &aAuxiliaryList, BOARD *aPcb)
Function UpdateCopyOfZonesList Check a pick list to remove zones identical to their copies and set th...
bool OnAreaPolygonModified(PICKED_ITEMS_LIST *aModifiedZonesList, ZONE_CONTAINER *modified_area)
Function OnAreaPolygonModified Process an area that has been modified, by normalizing its polygon and...
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
#define ZONE_EXPORT_VALUES
Definition: zones.h:37
unsigned GetCount() const
Function GetCount.
static PICKED_ITEMS_LIST s_AuxiliaryList
int SaveCopyOfZones(PICKED_ITEMS_LIST &aPickList, BOARD *aPcb, int aNetCode, LAYER_NUM aLayer)
Function SaveCopyOfZones creates a copy of zones having a given netcode on a given layer,...
int m_NetcodeSelection
Net code selection for the current zone.
Definition: zone_settings.h:84
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:919
const ZONE_SETTINGS & GetZoneSettings() const
void SetNetCode(int aNetCode)
Definition: netinfo.h:226
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:306
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:58
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
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
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
int GetNet() const
Function GetNet.
Definition: netinfo.h:224
#define _(s)
Definition: 3d_actions.cpp:33
static PICKED_ITEMS_LIST s_PickedList
void ClearItemsList()
Function ClearItemsList deletes only the list of pickers, NOT the picked data itself.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:884
BOARD * GetBoard() const
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...

References _, PICKED_ITEMS_LIST::ClearItemsList(), PICKED_ITEMS_LIST::ClearListAndDeleteItems(), dummy(), ZONE_SETTINGS::ExportSetting(), ZONE_FILLER::Fill(), BOARD::FindNet(), Format(), BOARD::GetArea(), BOARD::GetAreaCount(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), PICKED_ITEMS_LIST::GetCount(), ZONE_CONTAINER::GetIsKeepout(), ZONE_CONTAINER::GetLayer(), NETINFO_ITEM::GetNet(), PICKED_ITEMS_LIST::GetPickedItem(), PCB_DRAW_PANEL_GAL::GetView(), PCB_BASE_FRAME::GetZoneSettings(), ZONE_FILLER::InstallNewProgressReporter(), InvokeCopperZonesEditor(), InvokeKeepoutAreaEditor(), InvokeNonCopperZonesEditor(), IsCopperLayer(), ZONE_CONTAINER::IsFilled(), ZONE_SETTINGS::m_NetcodeSelection, BOARD::OnAreaPolygonModified(), OnModify(), BOARD_COMMIT::Push(), s_AuxiliaryList, s_PickedList, SaveCopyOfZones(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_BASE_FRAME::SetZoneSettings(), BOARD_COMMIT::Stage(), UNDEFINED_LAYER, KIGFX::PCB_VIEW::Update(), UpdateCopyOfZonesList(), and ZONE_EXPORT_VALUES.

Referenced by OnEditItemRequest().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

Definition at line 216 of file eda_draw_frame.cpp.

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

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

Referenced by GERBVIEW_CONTROL::UpdateMessagePanel().

◆ Exchange_Module()

void PCB_EDIT_FRAME::Exchange_Module ( MODULE aSrc,
MODULE aDest,
BOARD_COMMIT aCommit,
bool  deleteExtraTexts = true,
bool  resetTextLayers = true,
bool  resetTextEffects = true,
bool  reset3DModels = true 
)

Function Exchange_Module Replaces OldModule by NewModule, using OldModule settings: position, orientation, pad netnames ...) OldModule is deleted or put in undo list.

Parameters
aSrc= footprint to replace
aDest= footprint to put
aCommit= commit that should store the changes

Definition at line 425 of file dialog_exchange_footprints.cpp.

428 {
429  aDest->SetParent( GetBoard() );
430 
431  PlaceModule( aDest, false );
432 
433  // PlaceModule will move the module to the cursor position, which we don't want. Copy
434  // the original position across.
435  aDest->SetPosition( aSrc->GetPosition() );
436 
437  if( aDest->GetLayer() != aSrc->GetLayer() )
438  aDest->Flip( aDest->GetPosition(), m_Settings->m_FlipLeftRight );
439 
440  if( aDest->GetOrientation() != aSrc->GetOrientation() )
441  aDest->Rotate( aDest->GetPosition(), aSrc->GetOrientation() );
442 
443  aDest->SetLocked( aSrc->IsLocked() );
444 
445  for( auto pad : aDest->Pads() )
446  {
447  D_PAD* oldPad = aSrc->FindPadByName( pad->GetName() );
448 
449  if( oldPad )
450  {
452  pad->SetNetCode( oldPad->GetNetCode() );
453  pad->SetPinFunction( oldPad->GetPinFunction() );
454  }
455  }
456 
457  // Copy reference
458  processTextItem( aSrc->Reference(), aDest->Reference(),
459  // never reset reference text
460  false,
461  resetTextLayers, resetTextEffects );
462 
463  // Copy value
464  processTextItem( aSrc->Value(), aDest->Value(),
465  // reset value text only when it is a proxy for the footprint ID
466  // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
467  aSrc->GetValue() == aSrc->GetFPID().GetLibItemName(),
468  resetTextLayers, resetTextEffects );
469 
470  // Copy fields in accordance with the reset* flags
471  for( auto item : aSrc->GraphicalItems() )
472  {
473  TEXTE_MODULE* srcItem = dyn_cast<TEXTE_MODULE*>( item );
474 
475  if( srcItem )
476  {
477  TEXTE_MODULE* destItem = getMatchingTextItem( srcItem, aDest );
478 
479  if( destItem )
480  processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects );
481  else if( !deleteExtraTexts )
482  aDest->Add( new TEXTE_MODULE( *srcItem ) );
483  }
484  }
485 
486  // Copy 3D model settings in accordance with the reset* flag
487  if( !reset3DModels )
488  aDest->Models() = aSrc->Models(); // Linked list of 3D models.
489 
490  // Updating other parameters
491  const_cast<KIID&>( aDest->m_Uuid ) = aSrc->m_Uuid;
492  aDest->SetPath( aSrc->GetPath() );
493  aDest->CalculateBoundingBox();
494 
495  aCommit.Remove( aSrc );
496  aCommit.Add( aDest );
497 
498  aDest->ClearFlags();
499 }
double GetOrientation() const
Definition: class_module.h:215
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
TEXTE_MODULE & Reference()
Definition: class_module.h:477
int GetNetCode() const
Function GetNetCode.
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
PADS & Pads()
Definition: class_module.h:173
const wxString GetValue() const
Function GetValue.
Definition: class_module.h:461
bool GetLocalRatsnestVisible() const
const LIB_ID & GetFPID() const
Definition: class_module.h:219
void SetLocalRatsnestVisible(bool aVisible)
const KIID_PATH & GetPath() const
Definition: class_module.h:228
DRAWINGS & GraphicalItems()
Definition: class_module.h:183
const wxString & GetPinFunction() const
Definition: class_pad.h:211
D_PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a D_PAD* with a matching name.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:476
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
void SetPosition(const wxPoint &aPos) override
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:301
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
const KIID m_Uuid
Definition: base_struct.h:169
TEXTE_MODULE * getMatchingTextItem(TEXTE_MODULE *aRefItem, MODULE *aModule)
PCBNEW_SETTINGS * m_Settings
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:205
void SetLocked(bool isLocked) override
Function SetLocked sets the MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: class_module.h:311
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
void processTextItem(const TEXTE_MODULE &aSrc, TEXTE_MODULE &aDest, bool resetText, bool resetTextLayers, bool resetTextEffects)
void SetPath(const KIID_PATH &aPath)
Definition: class_module.h:229
BOARD * GetBoard() const
void PlaceModule(MODULE *aModule, bool aRecreateRatsnest=true)
Function PlaceModule places aModule at the current cursor position and updates module coordinates wit...
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const wxPoint GetPosition() const override
Definition: class_module.h:210

References COMMIT::Add(), MODULE::Add(), MODULE::CalculateBoundingBox(), EDA_ITEM::ClearFlags(), MODULE::FindPadByName(), MODULE::Flip(), PCB_BASE_FRAME::GetBoard(), MODULE::GetFPID(), BOARD_ITEM::GetLayer(), LIB_ID::GetLibItemName(), BOARD_CONNECTED_ITEM::GetLocalRatsnestVisible(), getMatchingTextItem(), BOARD_CONNECTED_ITEM::GetNetCode(), MODULE::GetOrientation(), MODULE::GetPath(), D_PAD::GetPinFunction(), MODULE::GetPosition(), MODULE::GetValue(), MODULE::GraphicalItems(), MODULE::IsLocked(), PCBNEW_SETTINGS::m_FlipLeftRight, PCB_BASE_FRAME::m_Settings, EDA_ITEM::m_Uuid, MODULE::Models(), MODULE::Pads(), PCB_BASE_FRAME::PlaceModule(), processTextItem(), MODULE::Reference(), COMMIT::Remove(), MODULE::Rotate(), BOARD_CONNECTED_ITEM::SetLocalRatsnestVisible(), MODULE::SetLocked(), EDA_ITEM::SetParent(), MODULE::SetPath(), MODULE::SetPosition(), and MODULE::Value().

Referenced by DIALOG_EXCHANGE_FOOTPRINTS::processModule(), BOARD_NETLIST_UPDATER::replaceComponent(), and FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard().

◆ ExecuteRemoteCommand()

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

Execute a remote command send by Eeschema via a socket, port KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) this is a virtual function called by EDA_DRAW_FRAME::OnSockRequest().

Parameters
cmdline= received command from socket

Reimplemented from EDA_DRAW_FRAME.

Definition at line 63 of file pcbnew/cross-probing.cpp.

64 {
65  char line[1024];
66  wxString msg;
67  wxString modName;
68  char* idcmd;
69  char* text;
70  int netcode = -1;
71  MODULE* module = NULL;
72  D_PAD* pad = NULL;
73  BOARD* pcb = GetBoard();
74 
76  KIGFX::RENDER_SETTINGS* renderSettings = view->GetPainter()->GetSettings();
77 
78  strncpy( line, cmdline, sizeof(line) - 1 );
79  line[sizeof(line) - 1] = 0;
80 
81  idcmd = strtok( line, " \n\r" );
82  text = strtok( NULL, "\"\n\r" );
83 
84  if( idcmd == NULL )
85  return;
86 
87  if( strcmp( idcmd, "$NET:" ) == 0 )
88  {
89  wxString net_name = FROM_UTF8( text );
90 
91  NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
92 
93  if( netinfo )
94  {
95  netcode = netinfo->GetNet();
96 
97  MSG_PANEL_ITEMS items;
98  netinfo->GetMsgPanelInfo( GetUserUnits(), items );
99  SetMsgPanel( items );
100  }
101  }
102  else if( strcmp( idcmd, "$PIN:" ) == 0 )
103  {
104  wxString pinName = FROM_UTF8( text );
105 
106  text = strtok( NULL, " \n\r" );
107 
108  if( text && strcmp( text, "$PART:" ) == 0 )
109  text = strtok( NULL, "\"\n\r" );
110 
111  modName = FROM_UTF8( text );
112 
113  module = pcb->FindModuleByReference( modName );
114 
115  if( module )
116  pad = module->FindPadByName( pinName );
117 
118  if( pad )
119  netcode = pad->GetNetCode();
120 
121  if( module == NULL )
122  msg.Printf( _( "%s not found" ), modName );
123  else if( pad == NULL )
124  msg.Printf( _( "%s pin %s not found" ), modName, pinName );
125  else
126  msg.Printf( _( "%s pin %s found" ), modName, pinName );
127 
128  SetStatusText( msg );
129  }
130  else if( strcmp( idcmd, "$PART:" ) == 0 )
131  {
132  pcb->ResetNetHighLight();
133 
134  modName = FROM_UTF8( text );
135 
136  module = pcb->FindModuleByReference( modName );
137 
138  if( module )
139  msg.Printf( _( "%s found" ), modName );
140  else
141  msg.Printf( _( "%s not found" ), modName );
142 
143  SetStatusText( msg );
144  }
145  else if( strcmp( idcmd, "$SHEET:" ) == 0 )
146  {
147  msg.Printf( _( "Selecting all from sheet \"%s\"" ), FROM_UTF8( text ) );
148  wxString sheetUIID( FROM_UTF8( text ) );
149  SetStatusText( msg );
151  static_cast<void*>( &sheetUIID ) );
152  return;
153  }
154  else if( strcmp( idcmd, "$CLEAR" ) == 0 )
155  {
156  renderSettings->SetHighlight( false );
157  view->UpdateAllLayersColor();
158 
159  pcb->ResetNetHighLight();
160  SetMsgPanel( pcb );
161 
162  GetCanvas()->Refresh();
163  return;
164  }
165 
166  BOX2I bbox = { { 0, 0 }, { 0, 0 } };
167 
168  if( module )
169  {
170  bbox = module->GetBoundingBox();
171 
172  if( pad )
173  m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) pad );
174  else
175  m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) module );
176  }
177  else if( netcode > 0 )
178  {
179  renderSettings->SetHighlight( ( netcode >= 0 ), netcode );
180 
181  pcb->SetHighLightNet( netcode );
182 
183  auto merge_area = [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
184  {
185  if( aItem->GetNetCode() == netcode )
186  {
187  if( bbox.GetWidth() == 0 )
188  bbox = aItem->GetBoundingBox();
189  else
190  bbox.Merge( aItem->GetBoundingBox() );
191  }
192  };
193 
194  for( auto zone : pcb->Zones() )
195  merge_area( zone );
196 
197  for( auto track : pcb->Tracks() )
198  merge_area( track );
199 
200  for( auto mod : pcb->Modules() )
201  for ( auto mod_pad : mod->Pads() )
202  merge_area( mod_pad );
203  }
204  else
205  {
206  renderSettings->SetHighlight( false );
207  }
208 
209  if( bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
210  {
211  auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
212  auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false );
213  screenSize.x = std::max( 10.0, screenSize.x );
214  screenSize.y = std::max( 10.0, screenSize.y );
215  double ratio = std::max( fabs( bbSize.x / screenSize.x ),
216  fabs( bbSize.y / screenSize.y ) );
217 
218  // Try not to zoom on every cross-probe; it gets very noisy
219  if( ratio < 0.1 || ratio > 1.0 )
220  view->SetScale( view->GetScale() / ratio );
221 
222  view->SetCenter( bbox.Centre() );
223  }
224 
225  view->UpdateAllLayersColor();
226  // Ensure the display is refreshed, because in some installs the refresh is done only
227  // when the gal canvas has the focus, and that is not the case when crossprobing from
228  // Eeschema:
229  GetCanvas()->Refresh();
230 }
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:280
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
int GetNetCode() const
Function GetNetCode.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:62
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
Definition: painter.h:56
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:475
static TOOL_ACTION highlightItem
Definition: pcb_actions.h:413
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
D_PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a D_PAD* with a matching name.
void ResetNetHighLight()
Function ResetNetHighLight Reset all high light data to the init state.
Definition: class_board.h:348
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:604
#define NULL
MODULES & Modules()
Definition: class_board.h:229
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aHighlightItems=false)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer,...
Definition: painter.h:136
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
coord_type GetWidth() const
Definition: box2.h:196
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo returns the information about the NETINFO_ITEM in aList to display in the me...
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: box2.h:385
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: view.cpp:578
void SetHighLightNet(int aNetCode)
Function SetHighLightNet.
Definition: class_board.h:364
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:301
ZONE_CONTAINERS & Zones()
Definition: class_board.h:243
Vec Centre() const
Definition: box2.h:78
int GetNet() const
Function GetNet.
Definition: netinfo.h:224
static TOOL_ACTION selectOnSheetFromEeschema
Selects all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:94
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
#define _(s)
Definition: 3d_actions.cpp:33
coord_type GetHeight() const
Definition: box2.h:197
MODULE * FindModuleByReference(const wxString &aReference) const
Function FindModuleByReference searches for a MODULE within this board with the given reference desig...
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
TOOL_MANAGER * m_toolManager
BOARD * GetBoard() const
VIEW.
Definition: view.h:61
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:798
double GetScale() const
Function GetScale()
Definition: view.h:257
TRACKS & Tracks()
Definition: class_board.h:220
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, BOX2< Vec >::Centre(), BOARD::FindModuleByReference(), BOARD::FindNet(), MODULE::FindPadByName(), FROM_UTF8(), PCB_BASE_FRAME::GetBoard(), MODULE::GetBoundingBox(), PCB_BASE_FRAME::GetCanvas(), BOX2< Vec >::GetHeight(), NETINFO_ITEM::GetMsgPanelInfo(), NETINFO_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetCode(), KIGFX::VIEW::GetPainter(), KIGFX::VIEW::GetScale(), KIGFX::PAINTER::GetSettings(), EDA_BASE_FRAME::GetToolManager(), EDA_BASE_FRAME::GetUserUnits(), TOOL_MANAGER::GetView(), BOX2< Vec >::GetWidth(), PCB_ACTIONS::highlightItem, BOX2< Vec >::Inflate(), EDA_BASE_FRAME::m_toolManager, BOX2< Vec >::Merge(), BOARD::Modules(), NULL, EDA_DRAW_PANEL_GAL::Refresh(), BOARD::ResetNetHighLight(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectOnSheetFromEeschema, KIGFX::VIEW::SetCenter(), KIGFX::RENDER_SETTINGS::SetHighlight(), BOARD::SetHighLightNet(), EDA_DRAW_FRAME::SetMsgPanel(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), BOARD::Tracks(), KIGFX::VIEW::UpdateAllLayersColor(), VECTOR2< T >::x, and BOARD::Zones().

Referenced by KiwayMailIn().

◆ Export_IDF3()

bool PCB_EDIT_FRAME::Export_IDF3 ( BOARD aPcb,
const wxString &  aFullFileName,
bool  aUseThou,
double  aXRef,
double  aYRef 
)

Function Export_IDF3 Creates an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file.

Function Export_IDF3 generates IDFv3 compliant board (*.emn) and library (*.emp) files representing the user's PCB design.

Parameters
aPcb= a pointer to the board to be exported to IDF
aFullFileName= the full filename of the export file
aUseThou= set to true if the desired IDF unit is thou (mil)
aXRef= the board Reference Point in mm, X value
aYRef= the board Reference Point in mm, Y value
Returns
true if OK

Definition at line 553 of file pcbnew/exporters/export_idf.cpp.

555 {
556  IDF3_BOARD idfBoard( IDF3::CAD_ELEC );
557 
558  // Switch the locale to standard C (needed to print floating point numbers)
559  LOCALE_IO toggle;
560 
561  resolver = Prj().Get3DCacheManager()->GetResolver();
562 
563  bool ok = true;
564  double scale = MM_PER_IU; // we must scale internal units to mm for IDF
565  IDF3::IDF_UNIT idfUnit;
566 
567  if( aUseThou )
568  {
569  idfUnit = IDF3::UNIT_THOU;
570  idfBoard.SetUserPrecision( 1 );
571  }
572  else
573  {
574  idfUnit = IDF3::UNIT_MM;
575  idfBoard.SetUserPrecision( 5 );
576  }
577 
578  wxFileName brdName = aPcb->GetFileName();
579 
580  idfBoard.SetUserScale( scale );
581  idfBoard.SetBoardThickness( aPcb->GetDesignSettings().GetBoardThickness() * scale );
582  idfBoard.SetBoardName( TO_UTF8( brdName.GetFullName() ) );
583  idfBoard.SetBoardVersion( 0 );
584  idfBoard.SetLibraryVersion( 0 );
585 
586  std::ostringstream ostr;
587  ostr << "KiCad " << TO_UTF8( GetBuildVersion() );
588  idfBoard.SetIDFSource( ostr.str() );
589 
590  try
591  {
592  // set up the board reference point
593  idfBoard.SetUserOffset( -aXRef, aYRef );
594 
595  // Export the board outline
596  idf_export_outline( aPcb, idfBoard );
597 
598  // Output the drill holes and module (library) data.
599  for( auto module : aPcb->Modules() )
600  idf_export_module( aPcb, module, idfBoard );
601 
602  if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) )
603  {
604  wxString msg;
605  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( idfBoard.GetError().c_str() );
606  wxMessageBox( msg );
607 
608  ok = false;
609  }
610  }
611  catch( const IO_ERROR& ioe )
612  {
613  wxString msg;
614  msg << _( "IDF Export Failed:\n" ) << ioe.What();
615  wxMessageBox( msg );
616 
617  ok = false;
618  }
619  catch( const std::exception& e )
620  {
621  wxString msg;
622  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
623  wxMessageBox( msg );
624  ok = false;
625  }
626 
627  return ok;
628 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:62
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:202
static void idf_export_module(BOARD *aPcb, MODULE *aModule, IDF3_BOARD &aIDFBoard)
Function idf_export_module retrieves information from all board modules, adds drill holes to the DRIL...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
static FILENAME_RESOLVER * resolver
static void idf_export_outline(BOARD *aPcb, IDF3_BOARD &aIDFBoard)
Function idf_export_outline retrieves line segment information from the edge layer and compiles the d...
const wxString & GetFileName() const
Definition: class_board.h:218
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
MODULES & Modules()
Definition: class_board.h:229
wxString GetBuildVersion()
Get the full KiCad version string.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const int scale
#define _(s)
Definition: 3d_actions.cpp:33
#define UNIT_MM
Definition: units_scales.h:31
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References _, FROM_UTF8(), BOARD_DESIGN_SETTINGS::GetBoardThickness(), GetBuildVersion(), BOARD::GetDesignSettings(), BOARD::GetFileName(), idf_export_module(), idf_export_outline(), BOARD::Modules(), KIWAY_HOLDER::Prj(), resolver, scale, TO_UTF8, UNIT_MM, and IO_ERROR::What().

Referenced by OnExportIDF3().

◆ ExportSpecctraFile()

bool PCB_EDIT_FRAME::ExportSpecctraFile ( const wxString &  aFullFilename)

Function ExportSpecctraFile will export the current BOARD to a specctra dsn file.

See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the specification.

Returns
true if OK

Definition at line 82 of file specctra_export.cpp.

83 {
84  SPECCTRA_DB db;
85  bool ok = true;
86  wxString errorText;
87 
88  BASE_SCREEN* screen = GetScreen();
89  bool wasModified = screen->IsModify();
90 
91  db.SetPCB( SPECCTRA_DB::MakePCB() );
92 
93  LOCALE_IO toggle; // Switch the locale to standard C
94 
95  // DSN Images (=KiCad MODULES and pads) must be presented from the
96  // top view. So we temporarily flip any modules which are on the back
97  // side of the board to the front, and record this in the MODULE's flag field.
98  db.FlipMODULEs( GetBoard() );
99 
100  try
101  {
103  db.FromBOARD( GetBoard() );
104  db.ExportPCB( aFullFilename, true );
105 
106  // if an exception is thrown by FromBOARD or ExportPCB(), then
107  // ~SPECCTRA_DB() will close the file.
108  }
109  catch( const IO_ERROR& ioe )
110  {
111  ok = false;
112 
113  // copy the error string to safe place, ioe is in this scope only.
114  errorText = ioe.What();
115  }
116 
117  // done assuredly, even if an exception was thrown and caught.
118  db.RevertMODULEs( GetBoard() );
119 
120  // The two calls below to MODULE::Flip(), both set the
121  // modified flag, yet their actions cancel each other out, so it should
122  // be ok to clear the modify flag.
123  if( !wasModified )
124  screen->ClrModify();
125 
126  if( ok )
127  {
128  SetStatusText( wxString( _( "BOARD exported OK." ) ) );
129  }
130  else
131  {
132  DisplayErrorMessage( this,
133  _( "Unable to export, please fix and try again" ),
134  errorText );
135  }
136 
137  return ok;
138 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:202
void SetPCB(PCB *aPcb)
Function SetPCB deletes any existing PCB and replaces it with the given one.
Definition: specctra.h:3884
void FlipMODULEs(BOARD *aBoard)
Function FlipMODULEs flips the modules which are on the back side of the board to the front.
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:155
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
bool IsModify() const
Definition: base_screen.h:228
SPECCTRA_DB holds a DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3607
void RevertMODULEs(BOARD *aBoard)
Function RevertMODULEs flips the modules which were on the back side of the board back to the back.
void FromBOARD(BOARD *aBoard)
Function FromBOARD adds the entire BOARD to the PCB but does not write it out.
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Function ExportPCB writes the internal PCB instance out as a SPECTRA DSN format file.
Definition: specctra.cpp:3438
#define _(s)
Definition: 3d_actions.cpp:33
void ClrModify()
Definition: base_screen.h:225
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References _, BASE_SCREEN::ClrModify(), DisplayErrorMessage(), DSN::SPECCTRA_DB::ExportPCB(), DSN::SPECCTRA_DB::FlipMODULEs(), DSN::SPECCTRA_DB::FromBOARD(), GetBoard(), BASE_SCREEN::IsModify(), DSN::SPECCTRA_DB::MakePCB(), DSN::SPECCTRA_DB::RevertMODULEs(), DSN::SPECCTRA_DB::SetPCB(), BOARD::SynchronizeNetsAndNetClasses(), and IO_ERROR::What().

Referenced by ExportSpecctraDSN().

◆ ExportSVG()

void PCB_EDIT_FRAME::ExportSVG ( wxCommandEvent &  event)

Function SVG_Print Shows the Export to SVG file dialog.

Definition at line 858 of file pcb_edit_frame.cpp.

859 {
860  InvokeExportSVG( this, GetBoard() );
861 }
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.
BOARD * GetBoard() const

References GetBoard(), and InvokeExportSVG().

◆ ExportToGenCAD()

void PCB_EDIT_FRAME::ExportToGenCAD ( wxCommandEvent &  event)

Function ExportToGenCAD creates a file in GenCAD 1.4 format from the current board.

Definition at line 274 of file export_gencad.cpp.

275 {
276  // Build default output file name
277  wxString path = GetLastPath( LAST_PATH_GENCAD );
278 
279  if( path.IsEmpty() )
280  {
281  wxFileName brdFile = GetBoard()->GetFileName();
282  brdFile.SetExt( "cad" );
283  path = brdFile.GetFullPath();
284  }
285 
286  DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( this, path );
287 
288  if( optionsDialog.ShowModal() == wxID_CANCEL )
289  return;
290 
291  path = optionsDialog.GetFileName();
292  SetLastPath( LAST_PATH_GENCAD, path );
293  FILE* file = wxFopen( path, "wt" );
294 
295  if( !file )
296  {
297  DisplayError( this, wxString::Format( _( "Unable to create \"%s\"" ),
298  optionsDialog.GetFileName() ) );
299  return;
300  }
301 
302  // Get options
303  flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );
304  uniquePins = optionsDialog.GetOption( UNIQUE_PIN_NAMES );
305  individualShapes = optionsDialog.GetOption( INDIVIDUAL_SHAPES );
306  storeOriginCoords = optionsDialog.GetOption( STORE_ORIGIN_COORDS );
307 
308  // Switch the locale to standard C (needed to print floating point numbers)
309  LOCALE_IO toggle;
310 
311  // Update some board data, to ensure a reliable gencad export
313 
314  // Save the auxiliary origin for the rest of the module
315  GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().x : 0;
316  GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().y : 0;
317 
318  // No idea on *why* this should be needed... maybe to fix net names?
319  Compile_Ratsnest( true );
320 
321  /* Temporary modification of footprints that are flipped (i.e. on bottom
322  * layer) to convert them to non flipped footprints.
323  * This is necessary to easily export shapes to GenCAD,
324  * that are given as normal orientation (non flipped, rotation = 0))
325  * these changes will be undone later
326  */
327  BOARD* pcb = GetBoard();
328 
329  for( auto module : pcb->Modules() )
330  {
331  module->SetFlag( 0 );
332 
333  if( module->GetLayer() == B_Cu )
334  {
335  module->Flip( module->GetPosition(), Settings().m_FlipLeftRight );
336  module->SetFlag( 1 );
337  }
338  }
339 
340  /* Gencad has some mandatory and some optional sections: some importer
341  * need the padstack section (which is optional) anyway. Also the
342  * order of the section *is* important */
343 
344  CreateHeaderInfoData( file, this ); // Gencad header
345  CreateBoardSection( file, pcb ); // Board perimeter
346 
347  CreatePadsShapesSection( file, pcb ); // Pads and padstacks
348  CreateArtworksSection( file ); // Empty but mandatory
349 
350  /* Gencad splits a component info in shape, component and device.
351  * We don't do any sharing (it would be difficult since each module is
352  * customizable after placement) */
353  CreateShapesSection( file, pcb );
354  CreateComponentsSection( file, pcb );
355  CreateDevicesSection( file, pcb );
356 
357  // In a similar way the netlist is split in net, track and route
358  CreateSignalsSection( file, pcb );
359  CreateTracksInfoData( file, pcb );
360  CreateRoutesSection( file, pcb );
361 
362  fclose( file );
363 
364  // Undo the footprints modifications (flipped footprints)
365  for( auto module : pcb->Modules() )
366  {
367  if( module->GetFlag() )
368  {
369  module->Flip( module->GetPosition(), Settings().m_FlipLeftRight );
370  module->SetFlag( 0 );
371  }
372  }
373 
374  componentShapes.clear();
375  shapeNames.clear();
376 }
static void CreateBoardSection(FILE *aFile, BOARD *aPcb)
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
static void CreateShapesSection(FILE *aFile, BOARD *aPcb)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:202
void Compile_Ratsnest(bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
static void CreateRoutesSection(FILE *aFile, BOARD *aPcb)
static void CreateSignalsSection(FILE *aFile, BOARD *aPcb)
static bool uniquePins
static int GencadOffsetY
static bool flipBottomPads
const wxString & GetFileName() const
Definition: class_board.h:218
static void CreateTracksInfoData(FILE *aFile, BOARD *aPcb)
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
static void CreateArtworksSection(FILE *aFile)
static void CreateComponentsSection(FILE *aFile, BOARD *aPcb)
static bool individualShapes
MODULES & Modules()
Definition: class_board.h:229
static void CreatePadsShapesSection(FILE *aFile, BOARD *aPcb)
static bool storeOriginCoords
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
static bool CreateHeaderInfoData(FILE *aFile, PCB_EDIT_FRAME *frame)
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
static void CreateDevicesSection(FILE *aFile, BOARD *aPcb)
#define _(s)
Definition: 3d_actions.cpp:33
PCBNEW_SETTINGS & Settings()
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Function ComputeBoundingBox calculates the bounding box containing all board items (or board edge seg...
static int GencadOffsetX
BOARD * GetBoard() const
static std::map< MODULE *, int > componentShapes
static std::map< int, wxString > shapeNames
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.

References _, B_Cu, PCB_BASE_FRAME::Compile_Ratsnest(), componentShapes, BOARD::ComputeBoundingBox(), CreateArtworksSection(), CreateBoardSection(), CreateComponentsSection(), CreateDevicesSection(), CreateHeaderInfoData(), CreatePadsShapesSection(), CreateRoutesSection(), CreateShapesSection(), CreateSignalsSection(), CreateTracksInfoData(), DisplayError(), FLIP_BOTTOM_PADS, flipBottomPads, Format(), GencadOffsetX, GencadOffsetY, PCB_BASE_FRAME::GetAuxOrigin(), PCB_BASE_FRAME::GetBoard(), DIALOG_GENCAD_EXPORT_OPTIONS::GetFileName(), BOARD::GetFileName(), GetLastPath(), DIALOG_GENCAD_EXPORT_OPTIONS::GetOption(), INDIVIDUAL_SHAPES, individualShapes, LAST_PATH_GENCAD, PCBNEW_SETTINGS::m_FlipLeftRight, BOARD::Modules(), SetLastPath(), PCB_BASE_FRAME::Settings(), shapeNames, STORE_ORIGIN_COORDS, storeOriginCoords, UNIQUE_PIN_NAMES, uniquePins, USE_AUX_ORIGIN, wxPoint::x, and wxPoint::y.

◆ ExportVRML_File()

bool PCB_EDIT_FRAME::ExportVRML_File ( const wxString &  aFullFileName,
double  aMMtoWRMLunit,
bool  aExport3DFiles,
bool  aUseRelativePaths,
bool  aUsePlainPCB,
const wxString &  a3D_Subdir,
double  aXRef,
double  aYRef 
)

Function ExportVRML_File Creates the file(s) exporting current BOARD to a VRML file.

Note
When copying 3D shapes files, the new filename is build from the full path name, changing the separators by underscore. This is needed because files with the same shortname can exist in different directories
ExportVRML_File generates coordinates in board units (BIU) inside the file.
Todo:
Use mm inside the file. A general scale transform is applied to the whole file (1.0 to have the actual WRML unit im mm, 0.001 to have the actual WRML unit in meters.
Note
For 3D models built by a 3D modeler, the unit is 0,1 inches. A specific scale is applied to 3D models to convert them to internal units.
Parameters
aFullFileName= the full filename of the file to create
aMMtoWRMLunit= the VRML scaling factor: 1.0 to export in mm. 0.001 for meters
aExport3DFiles= true to copy 3D shapes in the subir a3D_Subdir
aUseRelativePathsset to true to use relative paths instead of absolute paths in the board VRML file URLs.
aUsePlainPCBset to true to export a board with no copper or silkskreen; this is useful for generating a VRML file which can be converted to a STEP model.
a3D_Subdir= sub directory where 3D shapes files are copied. This is only used when aExport3DFiles == true
aXRef= X value of PCB (0,0) reference point
aYRef= Y value of PCB (0,0) reference point
Returns
true if Ok.

Definition at line 1539 of file export_vrml.cpp.

1543 {
1544  BOARD* pcb = GetBoard();
1545  bool ok = true;
1546 
1547  USE_INLINES = aExport3DFiles;
1548  USE_DEFS = true;
1549  USE_RELPATH = aUseRelativePaths;
1550 
1551  cache = Prj().Get3DCacheManager();
1552  PROJ_DIR = Prj().GetProjectPath();
1553  SUBDIR_3D = a3D_Subdir;
1554  MODEL_VRML model3d;
1555  model_vrml = &model3d;
1556  model3d.SetScale( aMMtoWRMLunit );
1557 
1558  if( USE_INLINES )
1559  {
1560  BOARD_SCALE = MM_PER_IU / 2.54;
1561  model3d.SetOffset( -aXRef / 2.54, aYRef / 2.54 );
1562  }
1563  else
1564  {
1565  BOARD_SCALE = MM_PER_IU;
1566  model3d.SetOffset( -aXRef, aYRef );
1567  }
1568 
1569  // plain PCB or else PCB with copper and silkscreen
1570  model3d.m_plainPCB = aUsePlainPCB;
1571 
1572  try
1573  {
1574 
1575  // Preliminary computation: the z value for each layer
1576  compute_layer_Zs(model3d, pcb);
1577 
1578  // board edges and cutouts
1579  export_vrml_board(model3d, pcb);
1580 
1581  // Drawing and text on the board
1582  if( !aUsePlainPCB )
1583  export_vrml_drawings( model3d, pcb );
1584 
1585  // Export vias and trackage
1586  export_vrml_tracks( model3d, pcb );
1587 
1588  // Export zone fills
1589  if( !aUsePlainPCB )
1590  export_vrml_zones( model3d, pcb);
1591 
1592  if( USE_INLINES )
1593  {
1594  // check if the 3D Subdir exists - create if not
1595  wxFileName subdir( SUBDIR_3D, "" );
1596 
1597  if( ! subdir.DirExists() )
1598  {
1599  if( !wxDir::Make( subdir.GetFullPath() ) )
1600  throw( std::runtime_error( "Could not create 3D model subdirectory" ) );
1601  }
1602 
1603  OPEN_OSTREAM( output_file, TO_UTF8( aFullFileName ) );
1604 
1605  if( output_file.fail() )
1606  {
1607  std::ostringstream ostr;
1608  ostr << "Could not open file '" << TO_UTF8( aFullFileName ) << "'";
1609  throw( std::runtime_error( ostr.str().c_str() ) );
1610  }
1611 
1612  output_file.imbue( std::locale( "C" ) );
1613 
1614  // Begin with the usual VRML boilerplate
1615  wxString fn = aFullFileName;
1616  fn.Replace( "\\" , "/" );
1617  output_file << "#VRML V2.0 utf8\n";
1618  output_file << "WorldInfo {\n";
1619  output_file << " title \"" << TO_UTF8( fn ) << " - Generated by Pcbnew\"\n";
1620  output_file << "}\n";
1621  output_file << "Transform {\n";
1622  output_file << " scale " << std::setprecision( PRECISION );
1623  output_file << WORLD_SCALE << " ";
1624  output_file << WORLD_SCALE << " ";
1625  output_file << WORLD_SCALE << "\n";
1626  output_file << " children [\n";
1627 
1628  // Export footprints
1629  for( auto module : pcb->Modules() )
1630  export_vrml_module( model3d, pcb, module, &output_file );
1631 
1632  // write out the board and all layers
1633  write_layers( model3d, pcb, TO_UTF8( aFullFileName ), &output_file );
1634 
1635  // Close the outer 'transform' node
1636  output_file << "]\n}\n";
1637 
1638  CLOSE_STREAM( output_file );
1639  }
1640  else
1641  {
1642  // Export footprints
1643  for( auto module : pcb->Modules() )
1644  export_vrml_module( model3d, pcb, module, NULL );
1645 
1646  // write out the board and all layers
1647  write_layers( model3d, pcb, TO_UTF8( aFullFileName ), NULL );
1648  }
1649  }
1650  catch( const std::exception& e )
1651  {
1652  wxString msg;
1653  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
1654  wxMessageBox( msg );
1655 
1656  ok = false;
1657  }
1658 
1659  return ok;
1660 }
static double BOARD_SCALE
Definition: export_vrml.cpp:70
static S3D_CACHE * cache
Definition: export_vrml.cpp:65
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:62
static double WORLD_SCALE
Definition: export_vrml.cpp:69
static bool USE_INLINES
Definition: export_vrml.cpp:66
static MODEL_VRML * model_vrml
void SetOffset(double aXoff, double aYoff)
static void compute_layer_Zs(MODEL_VRML &aModel, BOARD *pcb)
bool SetScale(double aWorldScale)
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
static void export_vrml_module(MODEL_VRML &aModel, BOARD *aPcb, MODULE *aModule, std::ostream *aOutputFile)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
#define NULL
MODULES & Modules()
Definition: class_board.h:229
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static bool USE_RELPATH
Definition: export_vrml.cpp:68
#define OPEN_OSTREAM(var, name)
static wxString SUBDIR_3D
Definition: export_vrml.cpp:72
static void export_vrml_tracks(MODEL_VRML &aModel, BOARD *pcb)
static void export_vrml_board(MODEL_VRML &aModel, BOARD *aPcb)
static void export_vrml_drawings(MODEL_VRML &aModel, BOARD *pcb)
static void write_layers(MODEL_VRML &aModel, BOARD *aPcb, const char *aFileName, OSTREAM *aOutputFile)
static wxString PROJ_DIR
Definition: export_vrml.cpp:73
static void export_vrml_zones(MODEL_VRML &aModel, BOARD *aPcb)
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
#define _(s)
Definition: 3d_actions.cpp:33
static const int PRECISION
Definition: export_vrml.cpp:71
static bool USE_DEFS
Definition: export_vrml.cpp:67
#define CLOSE_STREAM(var)
BOARD * GetBoard() const

References _, BOARD_SCALE, cache, CLOSE_STREAM, compute_layer_Zs(), export_vrml_board(), export_vrml_drawings(), export_vrml_module(), export_vrml_tracks(), export_vrml_zones(), FROM_UTF8(), PCB_BASE_FRAME::GetBoard(), PROJECT::GetProjectPath(), MODEL_VRML::m_plainPCB, model_vrml, BOARD::Modules(), NULL, OPEN_OSTREAM, PRECISION, KIWAY_HOLDER::Prj(), PROJ_DIR, MODEL_VRML::SetOffset(), MODEL_VRML::SetScale(), SUBDIR_3D, TO_UTF8, USE_DEFS, USE_INLINES, USE_RELPATH, WORLD_SCALE, and write_layers().

Referenced by OnExportVRML().

◆ FetchNetlistFromSchematic()

bool PCB_EDIT_FRAME::FetchNetlistFromSchematic ( NETLIST aNetlist,
FETCH_NETLIST_MODE  aMode 
)

Definition at line 999 of file pcb_edit_frame.cpp.

1000 {
1001  if( Kiface().IsSingle() )
1002  {
1003  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
1004  "mode. In order to create or update PCBs from schematics, you "
1005  "must launch the KiCad project manager and create a project." ) );
1006  return false;
1007  }
1008 
1009  // Update PCB requires a netlist. Therefore the schematic editor must be running
1010  // If this is not the case, open the schematic editor
1011  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1012 
1013  if( !frame->IsShown() )
1014  {
1015  wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(), LegacySchematicFileExtension );
1016 
1017  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1018 
1019  // we show the schematic editor frame, because do not show is seen as
1020  // a not yet opened schematic by Kicad manager, which is not the case
1021  frame->Show( true );
1022 
1023  // bring ourselves back to the front
1024  Raise();
1025  }
1026 
1027  std::string payload;
1028 
1029  if( aMode == NO_ANNOTATION )
1030  payload = "no-annotate";
1031  else if( aMode == QUIET_ANNOTATION )
1032  payload = "quiet-annotate";
1033 
1034  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1035 
1036  try
1037  {
1038  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1039  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1040  netlistReader.LoadNetlist();
1041  }
1042  catch( const IO_ERROR& )
1043  {
1044  assert( false ); // should never happen
1045  return false;
1046  }
1047 
1048  return true;
1049 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:118
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
KICAD_NETLIST_READER read the new s-expression based KiCad netlist format.
Fetch a netlist from schematics.
Definition: mail_type.h:46
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:341
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
const std::string LegacySchematicFileExtension
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:427
#define _(s)
Definition: 3d_actions.cpp:33
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References _, DisplayError(), KIWAY::ExpressMail(), FRAME_SCH, Kiface(), Kiway, LegacySchematicFileExtension, KICAD_NETLIST_READER::LoadNetlist(), MAIL_SCH_GET_NETLIST, KIWAY_PLAYER::OpenProjectFiles(), KIWAY::Player(), and Prj().

Referenced by importFile(), DRC::RunTests(), and PCB_EDITOR_CONTROL::UpdatePCBFromSchematic().

◆ Files_io()

void PCB_EDIT_FRAME::Files_io ( wxCommandEvent &  event)

Function Files_io.

Parameters
eventis the command event handler. do nothing else than call Files_io_from_id with the wxCommandEvent id

Definition at line 211 of file pcbnew/files.cpp.

212 {
213  int id = event.GetId();
214  Files_io_from_id( id );
215 }
bool Files_io_from_id(int aId)
Function Files_io_from_id Read and write board files.

References Files_io_from_id().

◆ Files_io_from_id()

bool PCB_EDIT_FRAME::Files_io_from_id ( int  aId)

Function Files_io_from_id Read and write board files.

Parameters
aIdis an event ID ciming from file command events: ID_LOAD_FILE ID_MENU_READ_BOARD_BACKUP_FILE ID_MENU_RECOVER_BOARD_AUTOSAVE ID_NEW_BOARD ID_SAVE_BOARD ID_COPY_BOARD_AS ID_SAVE_BOARD_AS Files_io_from_id prepare parameters and calls the specialized function

Definition at line 218 of file pcbnew/files.cpp.

219 {
220  wxString msg;
221 
222  switch( id )
223  {
224  case ID_LOAD_FILE:
225  {
226  int open_ctl = 0;
227  wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
228 
229  return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
230  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
231  }
232 
234  {
235  int open_ctl = 1;
236  wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
237 
238  return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
239  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
240  }
241 
244  {
245  wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
246  wxFileName fn = currfn;
247 
249  {
250  wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
251  fn.SetName( rec_name );
252  }
253  else
254  {
255  wxString backup_ext = fn.GetExt() + GetBackupSuffix();
256  fn.SetExt( backup_ext );
257  }
258 
259  if( !fn.FileExists() )
260  {
261  msg.Printf( _( "Recovery file \"%s\" not found." ), fn.GetFullPath() );
262  DisplayInfoMessage( this, msg );
263  return false;
264  }
265 
266  msg.Printf( _( "OK to load recovery or backup file \"%s\"" ), fn.GetFullPath() );
267 
268  if( !IsOK( this, msg ) )
269  return false;
270 
271  GetScreen()->ClrModify(); // do not prompt the user for changes
272 
273  if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
274  {
275  // Re-set the name since name or extension was changed
276  GetBoard()->SetFileName( currfn.GetFullPath() );
277  UpdateTitle();
278  return true;
279  }
280  return false;
281  }
282 
283  case ID_NEW_BOARD:
284  {
285  if( IsContentModified() )
286  {
287  wxFileName fileName = GetBoard()->GetFileName();
288  wxString saveMsg =
289  _( "Current board will be closed, save changes to \"%s\" before continuing?" );
290 
291  if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
292  [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
293  return false;
294  }
295  else if( !GetBoard()->IsEmpty() )
296  {
297  if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
298  return false;
299  }
300 
301  if( !Clear_Pcb( false ) )
302  return false;
303 
304  wxFileName fn( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ),
306 
307  Prj().SetProjectFullName( fn.GetFullPath() );
308 
309  onBoardLoaded();
310 
311  OnModify();
312  return true;
313  }
314 
315  case ID_SAVE_BOARD:
316  if( !GetBoard()->GetFileName().IsEmpty() )
317  return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) );
318  // Fall through
319 
320  case ID_COPY_BOARD_AS:
321  case ID_SAVE_BOARD_AS:
322  {
323  wxString orig_name;
324  wxFileName::SplitPath( GetBoard()->GetFileName(),
325  nullptr, nullptr, &orig_name, nullptr );
326 
327  if( orig_name.IsEmpty() )
328  orig_name = _( "noname" );
329 
330  wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
331  wxFileName fn( pro_dir, orig_name, KiCadPcbFileExtension );
332  wxString filename = fn.GetFullPath();
333 
334  if( AskSaveBoardFileName( this, &filename ) )
335  {
336  if( id == ID_COPY_BOARD_AS )
337  return SavePcbCopy( filename );
338  else
339  return SavePcbFile( filename, NO_BACKUP_FILE );
340  }
341  return false;
342  }
343 
344  default:
345  wxLogDebug( wxT( "File_io Internal Error" ) );
346  return false;
347  }
348 }
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:201
const std::string ProjectFileExtension
bool SavePcbCopy(const wxString &aFileName)
Function SavePcbCopy writes the board data structures to a aFileName but unlike SavePcbFile,...
const std::string KiCadPcbFileExtension
#define NO_BACKUP_FILE
const wxString & GetFileName() const
Definition: class_board.h:218
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:413
bool IsContentModified() override
Get if the current board has been modified but not saved.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Function OpenProjectFiles (was LoadOnePcbFile) loads a KiCad board (.kicad_pcb) from aFileName.
static wxString GetBackupSuffix()
void onBoardLoaded()
Updates the state of the GUI after a new board is loaded or created.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
bool AskLoadBoardFileName(wxWindow *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly)
Function AskLoadBoardFileName puts up a wxFileDialog asking for a BOARD filename to open.
void SetFileName(const wxString &aFileName)
Definition: class_board.h:216
VTBL_ENTRY void SetProjectFullName(const wxString &aFullPathAndName)
Function SetProjectFullName sets the: 1) full directory, 2) basename, and 3) extension of the project...
Definition: project.cpp:64
static wxString GetAutoSaveFilePrefix()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
bool AskSaveBoardFileName(wxWindow *aParent, wxString *aFileName)
Function AskSaveBoardFileName puts up a wxFileDialog asking for a BOARD filename to save.
void ClrModify()
Definition: base_screen.h:225
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool Files_io_from_id(int aId)
Function Files_io_from_id Read and write board files.
BOARD * GetBoard() const
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
bool Clear_Pcb(bool aQuery, bool aFinal=false)
Function Clear_Pcb delete all and reinitialize the current board.
Definition: initpcb.cpp:39
bool SavePcbFile(const wxString &aFileName, bool aCreateBackupFile=CREATE_BACKUP_FILE)
Function SavePcbFile writes the board data structures to a aFileName Creates backup when requested an...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
bool IsEmpty() const
Definition: class_board.h:264

References _, PROJECT::AbsolutePath(), AskLoadBoardFileName(), AskSaveBoardFileName(), Clear_Pcb(), BASE_SCREEN::ClrModify(), DisplayInfoMessage(), Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), EDA_BASE_FRAME::GetBackupSuffix(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), PCB_BASE_FRAME::GetScreen(), HandleUnsavedChanges(), ID_COPY_BOARD_AS, ID_IMPORT_NON_KICAD_BOARD, ID_LOAD_FILE, ID_MENU_READ_BOARD_BACKUP_FILE, ID_MENU_RECOVER_BOARD_AUTOSAVE, ID_NEW_BOARD, ID_SAVE_BOARD, ID_SAVE_BOARD_AS, IsContentModified(), BOARD::IsEmpty(), IsOK(), KiCadPcbFileExtension, NO_BACKUP_FILE, onBoardLoaded(), OnModify(), OpenProjectFiles(), KIWAY_HOLDER::Prj(), ProjectFileExtension, SavePcbCopy(), SavePcbFile(), BOARD::SetFileName(), PROJECT::SetProjectFullName(), and UpdateTitle().

Referenced by Files_io(), PCB_EDITOR_CONTROL::New(), PCB_EDITOR_CONTROL::Open(), PCB_EDITOR_CONTROL::Save(), PCB_EDITOR_CONTROL::SaveAs(), and PCB_EDITOR_CONTROL::SaveCopyAs().

◆ findPythonConsole()

static wxWindow* PCB_EDIT_FRAME::findPythonConsole ( )
inlinestaticprotected
Returns
a pointer to the python console frame, or NULL if not exist

Definition at line 204 of file pcb_edit_frame.h.

205  {
206  return FindWindowByName( pythonConsoleNameId() );
207  }
static const wxChar * pythonConsoleNameId()
Has meaning only if KICAD_SCRIPTING_WXPYTHON option is not defined.

References pythonConsoleNameId().

Referenced by ReCreateMenuBar(), and SyncToolbars().

◆ fixEagleNets()

bool PCB_EDIT_FRAME::fixEagleNets ( const std::unordered_map< wxString, wxString > &  aRemap)
protected

Rematch orphaned zones and vias to schematic nets.

Definition at line 1012 of file pcbnew/files.cpp.

1013 {
1014  bool result = true;
1015  BOARD* board = GetBoard();
1016 
1017  // perform netlist matching to prevent orphaned zones.
1018  for( auto zone : board->Zones() )
1019  {
1020  auto it = aRemap.find( zone->GetNet()->GetNetname() );
1021 
1022  if( it != aRemap.end() )
1023  {
1024  NETINFO_ITEM* net = board->FindNet( it->second );
1025 
1026  if( !net )
1027  {
1028  wxFAIL;
1029  result = false;
1030  continue;
1031  }
1032 
1033  zone->SetNet( net );
1034  }
1035  }
1036 
1037 
1038  // perform netlist matching to prevent orphaned tracks/vias.
1039  for( auto track : board->Tracks() )
1040  {
1041  auto it = aRemap.find( track->GetNet()->GetNetname() );
1042 
1043  if( it != aRemap.end() )
1044  {
1045  NETINFO_ITEM* net = board->FindNet( it->second );
1046 
1047  if( !net )
1048  {
1049  wxFAIL;
1050  result = false;
1051  continue;
1052  }
1053 
1054  track->SetNet( net );
1055  }
1056  }
1057 
1058  return result;
1059 }
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
ZONE_CONTAINERS & Zones()
Definition: class_board.h:243
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
BOARD * GetBoard() const
TRACKS & Tracks()
Definition: class_board.h:220

References BOARD::FindNet(), PCB_BASE_FRAME::GetBoard(), BOARD::Tracks(), and BOARD::Zones().

Referenced by importFile().

◆ FocusOnItem()

void PCB_BASE_FRAME::FocusOnItem ( BOARD_ITEM aItem)
inherited

Definition at line 186 of file pcb_base_frame.cpp.

187 {
188  static KIID lastBrightenedItemID( niluuid );
189 
190  BOARD_ITEM* lastItem = GetBoard()->GetItem( lastBrightenedItemID );
191 
192  if( lastItem && lastItem != aItem )
193  {
194  lastItem->ClearBrightened();
195 
196  if( lastItem->Type() == PCB_MODULE_T )
197  {
198  static_cast<MODULE*>( lastItem )->RunOnChildren( [&] ( BOARD_ITEM* child )
199  {
200  child->ClearBrightened();
201  });
202  }
203 
204  GetCanvas()->GetView()->Update( lastItem );
205  lastBrightenedItemID = niluuid;
206  GetCanvas()->Refresh();
207  }
208 
209  if( aItem )
210  {
211  aItem->SetBrightened();
212 
213  if( aItem->Type() == PCB_MODULE_T )
214  {
215  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* child )
216  {
217  child->SetBrightened();
218  });
219  }
220 
221  GetCanvas()->GetView()->Update( aItem );
222  lastBrightenedItemID = aItem->m_Uuid;
223  FocusOnLocation( aItem->GetPosition() );
224  GetCanvas()->Refresh();
225  }
226 }
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetBrightened()
Definition: base_struct.h:233
BOARD_ITEM * GetItem(const KIID &aID)
void ClearBrightened()
Definition: base_struct.h:237
Definition: common.h:65
class MODULE, a footprint
Definition: typeinfo.h:89
KIID niluuid(0)
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual const wxPoint GetPosition() const =0
const KIID m_Uuid
Definition: base_struct.h:169
BOARD * GetBoard() const
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References EDA_ITEM::ClearBrightened(), EDA_DRAW_FRAME::FocusOnLocation(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetItem(), BOARD_ITEM::GetPosition(), PCB_DRAW_PANEL_GAL::GetView(), EDA_ITEM::m_Uuid, niluuid, PCB_MODULE_T, EDA_DRAW_PANEL_GAL::Refresh(), EDA_ITEM::SetBrightened(), EDA_ITEM::Type(), and KIGFX::PCB_VIEW::Update().

Referenced by SELECTION_TOOL::Main(), DIALOG_DRC::OnCancelClick(), DIALOG_DRC::OnDRCItemSelected(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem(), and DIALOG_DRC::~DIALOG_DRC().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const wxPoint aPos)
inherited

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

Parameters
aPosis the point to go to.

Definition at line 688 of file eda_draw_frame.cpp.

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

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

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

◆ GenD356File()

void PCB_EDIT_FRAME::GenD356File ( wxCommandEvent &  event)

Definition at line 365 of file export_d356.cpp.

366 {
367  wxFileName fn = GetBoard()->GetFileName();
368  wxString msg, ext, wildcard;
369 
370  ext = IpcD356FileExtension;
371  wildcard = IpcD356FileWildcard();
372  fn.SetExt( ext );
373 
374  wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
375 
376  wxFileDialog dlg( this, _( "Export D-356 Test File" ), pro_dir,
377  fn.GetFullName(), wildcard,
378  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
379 
380  if( dlg.ShowModal() == wxID_CANCEL )
381  return;
382 
383  IPC356D_WRITER writer( GetBoard(), this );
384 
385  writer.Write( dlg.GetPath() );
386 }
const wxString & GetFileName() const
Definition: class_board.h:218
Wrapper to expose an API for writing IPC-D356 files.
Definition: export_d356.h:53
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const std::string IpcD356FileExtension
wxString IpcD356FileWildcard()
#define _(s)
Definition: 3d_actions.cpp:33
BOARD * GetBoard() const

References _, PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), IpcD356FileExtension, IpcD356FileWildcard(), KIWAY_HOLDER::Prj(), and IPC356D_WRITER::Write().

Referenced by PCB_EDITOR_CONTROL::GenerateFabFiles().

◆ GenFootprintsReport()

void PCB_EDIT_FRAME::GenFootprintsReport ( wxCommandEvent &  event)

Function GenFootprintsReport Calls DoGenFootprintsReport to create a footprint reprot file See DoGenFootprintsReport for file format.

Definition at line 513 of file gen_footprints_placefile.cpp.

514 {
515  wxFileName fn;
516 
517  wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName()).GetPath();
518  wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
519 
520  if( dirDialog.ShowModal() == wxID_CANCEL )
521  return;
522 
523  fn = GetBoard()->GetFileName();
524  fn.SetPath( dirDialog.GetPath() );
525  fn.SetExt( wxT( "rpt" ) );
526 
527&#