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 (bool aAskForSave) 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...
 
std::vector< PARAM_CFG * > & GetConfigurationSettings ()
 Function GetConfigurationSettings returns the Pcbnew applications settings list. More...
 
void LoadSettings (wxConfigBase *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (wxConfigBase *aCfg) override
 Saves common frame parameters to a configuration data file. More...
 
wxConfigBase * GetSettings ()
 
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 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 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...
 
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)
 
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
 
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...
 
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...
 
PCB_GENERAL_SETTINGSSettings ()
 
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
 
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...
 
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, bool aCenterView=false)
 Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor) at a given coordinate and reframes the drawing if the requested point is out of view or if center on location is requested. More...
 
double GetZoom ()
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Function CreateBasicMenu. More...
 
void PrintWorkSheet (wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString, COLOR4D aColor=COLOR4D::UNSPECIFIED)
 Prints the page layout with the frame and the basic inscriptions. More...
 
void DisplayToolMsg (const wxString &msg) override
 
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)
 
TOOL_MANAGERGetToolManager () const
 Return the MVC controller. More...
 
virtual void PushTool (const std::string &actionName)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const std::string &actionName)
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
bool GetDoImmediateActions () const
 Indicates that hotkeys should perform an immediate action even if another tool is currently active. More...
 
bool GetDragSelects () const
 Indicates that a drag should draw a selection rectangle, even when started over an item. More...
 
bool GetMoveWarpsCursor () const
 Indicates that a move operation should warp the mouse pointer to the origin of the move object. More...
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &event)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuOpen (wxMenuEvent &event)
 Workaround some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
virtual const SEARCH_STACKsys_search ()
 Return a SEARCH_STACK pertaining to entire program. More...
 
virtual wxString help_name ()
 
void OnKicadAbout (wxCommandEvent &event)
 
void OnPreferences (wxCommandEvent &event)
 
void PrintMsg (const wxString &text)
 
virtual wxConfigBase * config ()
 Returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
wxString ConfigBaseName ()
 
void ImportHotkeyConfigFromFile (std::map< std::string, TOOL_ACTION * > aActionMap, const wxString &aDefaultShortname)
 Prompt the user for a hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=NULL)
 Fetches the file name from the file history list. More...
 
void UpdateFileHistory (const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
 Update the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
void AddStandardHelpMenu (wxMenuBar *aMenuBar)
 Adds the standard KiCad help menu to the menubar. More...
 
bool IsWritable (const wxFileName &aFileName)
 Checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName)
 Check if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
const wxString & GetAboutTitle () const
 
void SetShutdownBlockReason (const wxString &reason)
 Sets the block reason why the window/application is preventing OS shutdown. More...
 
void RemoveShutdownBlockReason ()
 Removes any shutdown block reason set. More...
 
bool SupportsShutdownBlockReason ()
 Whether or not the window supports setting a shutdown block reason. More...
 
HOLDER_TYPE GetType ()
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

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
 

Static Public Attributes

static const wxChar AUTO_ZOOM_KEY [] = wxT( "AutoZoom" )
 

Key in KifaceSettings to store the canvas type.

More...
 
static const wxChar ZOOM_KEY [] = wxT( "Zoom" )
 

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...
 
virtual wxString GetCanvasTypeKey ()
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 Function language_change is an event handler called on a language menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 

Static Protected Member Functions

static 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_configParams
 
std::vector< PARAM_CFG * > m_projectFileParams
 
wxString m_lastPath [LAST_PATH_SIZE]
 
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
 
PCB_GENERAL_SETTINGS m_configSettings
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 prevents opening same file multiple times. More...
 
int m_LastGridSizeId
 
bool m_drawGrid
 
bool m_showPageLimits
 
COLOR4D m_gridColor
 
COLOR4D m_drawBgColor
 
double m_zoomLevelCoeff
 
int m_UndoRedoCountMax
 
bool m_PolarCoords
 
TOOL_DISPATCHERm_toolDispatcher
 
bool m_showBorderAndTitleBlock
 
long m_firstRunDialogSetting
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
ACTION_TOOLBARm_mainToolBar
 
ACTION_TOOLBARm_auxiliaryToolBar
 
ACTION_TOOLBARm_drawToolBar
 
ACTION_TOOLBARm_optionsToolBar
 
wxFindReplaceData * m_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_MsgFrameHeight
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
 The current canvas type. More...
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
FRAME_T m_Ident
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_AboutTitle
 
wxAuiManager m_auimgr
 
wxString m_configName
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
bool m_dragSelects
 
bool m_moveWarpsCursor
 
bool m_hasAutoSave
 
bool m_autoSaveState
 
int m_autoSaveInterval
 
wxTimer * m_autoSaveTimer
 
wxString m_perspective
 
wxString m_mruPath
 
EDA_UNITS m_userUnits
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private 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 893 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 340 of file pcb_edit_frame.cpp.

341 {
342  // Since the file menu contains file history menus, we must ensure that the menu
343  // destructor is called before the file history objects are deleted since their destructor
344  // unregisters the menu from the history.
345  wxMenu* fileMenu = GetMenuBar()->Remove( 0 );
346  delete fileMenu;
347 }

Member Function Documentation

◆ ActivateGalCanvas()

void PCB_EDIT_FRAME::ActivateGalCanvas ( )
overridevirtual

Reimplemented from PCB_BASE_EDIT_FRAME.

Definition at line 562 of file pcb_edit_frame.cpp.

563 {
566 
569  GetCanvas()->Refresh();
570 }
void ActivateGalCanvas() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
virtual void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings)
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: painter.h:67
PCB_GENERAL_SETTINGS & Settings()
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
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...
COLORS_DESIGN_SETTINGS & Colors()
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.

References PCB_BASE_EDIT_FRAME::ActivateGalCanvas(), COLORS_DESIGN_SETTINGS::GetLayerColor(), and LAYER_GRID.

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 498 of file footprint_libraries_utils.cpp.

499 {
500  wxFileName fn( aFilename );
501 
502  if( aFilename.IsEmpty() )
503  {
504  if( !LibraryFileBrowser( true, fn,
506  true ) )
507  {
508  return false;
509  }
510  }
511 
512  wxString libPath = fn.GetFullPath();
513  wxString libName = fn.GetName();
514 
515  if( libName.IsEmpty() )
516  return false;
517 
518  bool saveInGlobalTable = false;
519  bool saveInProjectTable = false;
520  wxArrayString libTableNames;
521 
522  libTableNames.Add( _( "Global" ) );
523  libTableNames.Add( _( "Project" ) );
524 
525  switch( SelectSingleOption( this, _( "Select Library Table" ),
526  _( "Choose the Library Table to add the library to:" ),
527  libTableNames ) )
528  {
529  case 0: saveInGlobalTable = true; break;
530  case 1: saveInProjectTable = true; break;
531  default: return false;
532  }
533 
534  wxString type = IO_MGR::ShowType( IO_MGR::GuessPluginTypeFromLibPath( libPath ) );
535 
536  // try to use path normalized to an environmental variable or project path
537  wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
538 
539  if( normalizedPath.IsEmpty() )
540  normalizedPath = libPath;
541 
542  try
543  {
544  if( saveInGlobalTable )
545  {
546  auto row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
547  GFootprintTable.InsertRow( row );
549  }
550  else if( saveInProjectTable )
551  {
552  auto row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
553  Prj().PcbFootprintLibs()->InsertRow( row );
554  Prj().PcbFootprintLibs()->Save( Prj().FootprintLibTblName() );
555  }
556  }
557  catch( const IO_ERROR& ioe )
558  {
559  DisplayError( this, ioe.What() );
560  return false;
561  }
562 
563  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
564 
565  if( editor )
566  {
567  LIB_ID libID( libName, wxEmptyString );
568  editor->SyncLibraryTree( true );
569  editor->FocusOnLibID( libID );
570  }
571 
572  auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
573 
574  if( viewer )
575  viewer->ReCreateLibraryList();
576 
577  return true;
578 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
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:98
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:400
wxString KiCadFootprintLibPathWildcard()
#define _(s)
Definition: 3d_actions.cpp:31
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:290
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:67
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 179 of file pcb_base_frame.cpp.

180 {
181  if( module )
182  {
183  GetBoard()->Add( module, ADD_MODE::APPEND );
184 
185  module->SetFlags( IS_NEW );
186 
187  module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
188 
189  module->SetTimeStamp( GetNewTimeStamp() );
190 
191  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
192  // built from a board)
193  if( module->IsFlipped() )
194  module->Flip( module->GetPosition(), m_configSettings.m_FlipLeftRight );
195 
196  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
197  // it might be stored in another orientation if the lib is an archive built from a board)
198  module->SetOrientation( 0 );
199  }
200 }
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.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:215
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
PCB_GENERAL_SETTINGS m_configSettings
void SetPosition(const wxPoint &aPos) override
void SetOrientation(double newangle)
BOARD * GetBoard() const
const wxPoint GetPosition() const override
Definition: class_module.h:210
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:212

References BOARD::Add(), APPEND, MODULE::Flip(), PCB_BASE_FRAME::GetBoard(), GetNewTimeStamp(), MODULE::GetPosition(), IS_NEW, MODULE::IsFlipped(), PCB_BASE_FRAME::m_configSettings, PCB_GENERAL_SETTINGS::m_FlipLeftRight, EDA_ITEM::SetFlags(), MODULE::SetOrientation(), MODULE::SetPosition(), and EDA_ITEM::SetTimeStamp().

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

413 {
414  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
415  ACTION_MENU* helpMenu = new ACTION_MENU( false );
416 
417  helpMenu->SetTool( commonControl );
418 
419  helpMenu->Add( ACTIONS::help );
420  helpMenu->Add( ACTIONS::gettingStarted );
421  helpMenu->Add( ACTIONS::listHotKeys );
422  helpMenu->Add( ACTIONS::getInvolved );
423 
424  helpMenu->AppendSeparator();
425  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
426 
427  aMenuBar->Append( helpMenu, _( "&Help" ) );
428 }
static TOOL_ACTION listHotKeys
Definition: actions.h:167
ACTION_MENU.
Definition: action_menu.h:43
const BITMAP_OPAQUE about_xpm[1]
Definition: about.cpp:84
COMMON_CONTROL.
#define _(s)
Definition: 3d_actions.cpp:31
static TOOL_ACTION help
Definition: actions.h:166
TOOL_MANAGER * m_toolManager
static TOOL_ACTION getInvolved
Definition: actions.h:168
static TOOL_ACTION gettingStarted
Definition: actions.h:165

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

Referenced by EDA_3D_VIEWER::CreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), 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 350 of file eda_draw_frame.cpp.

351 {
352  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
353  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
354 
355  aMenu.AddSeparator( 1000 );
357  aMenu.AddItem( ACTIONS::zoomIn, SELECTION_CONDITIONS::ShowAlways, 1000 );
358  aMenu.AddItem( ACTIONS::zoomOut, SELECTION_CONDITIONS::ShowAlways, 1000 );
360 
361  aMenu.AddSeparator( 1000 );
362 
363  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
364  zoomMenu->SetTool( commonTools );
365  aToolMenu.AddSubMenu( zoomMenu );
366 
367  auto gridMenu = std::make_shared<GRID_MENU>( this );
368  gridMenu->SetTool( commonTools );
369  aToolMenu.AddSubMenu( gridMenu );
370 
371  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
372  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
373 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
COMMON_TOOLS.
Definition: common_tools.h:38
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION zoomCenter
Definition: actions.h:92
static TOOL_ACTION zoomIn
Definition: actions.h:88
static TOOL_ACTION zoomOut
Definition: actions.h:89
TOOL_MANAGER * m_toolManager

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

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

◆ AppendMsgPanel()

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

Append a message to the message panel.

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

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

Definition at line 559 of file eda_draw_frame.cpp.

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

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

Referenced by PCB_BASE_FRAME::Compile_Ratsnest(), LIB_EDIT_FRAME::DisplayCmpDoc(), GERBER_FILE_IMAGE::DisplayImageInfo(), SCH_EDIT_FRAME::EditSheet(), SCH_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::LoadSheetFromFile(), SCH_PRINTOUT::OnPrintPage(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::SaveEEFile(), LIB_EDIT_FRAME::saveLibrary(), SavePcbFile(), 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 630 of file footprint_libraries_utils.cpp.

632 {
633  if( GetBoard()->GetFirstModule() == NULL )
634  {
635  DisplayInfoMessage( this, _( "No footprints to archive!" ) );
636  return;
637  }
638 
639  wxString footprintName;
640 
641  if( !aStoreInNewLib )
642  {
643  // The footprints are saved in an existing .pretty library in the fp lib table
644  PROJECT& prj = Prj();
645  wxString last_nickname = prj.GetRString( PROJECT::PCB_LIB_NICKNAME );
646  wxString nickname = SelectLibrary( last_nickname );
647 
648  if( !nickname ) // Aborted
649  return;
650 
651  prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
652 
653  try
654  {
655  FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
656 
657  for( auto curr_fp : GetBoard()->Modules() )
658  {
659  if( !curr_fp->GetFPID().GetLibItemName().empty() ) // Can happen with old boards.
660  tbl->FootprintSave( nickname, curr_fp, false );
661  }
662  }
663  catch( const IO_ERROR& ioe )
664  {
665  DisplayError( this, ioe.What() );
666  }
667  }
668  else
669  {
670  // The footprints are saved in a new .pretty library.
671  // If this library already exists, all previous footprints will be deleted
672  wxString libPath = CreateNewLibrary( aLibName );
673 
674  if( libPath.IsEmpty() ) // Aborted
675  return;
676 
677 
678  if( aLibPath ) *aLibPath = libPath;
679 
681  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
682 
683  for( auto curr_fp : GetBoard()->Modules() )
684  {
685  try
686  {
687  if( !curr_fp->GetFPID().GetLibItemName().empty() ) // Can happen with old boards.
688  pi->FootprintSave( libPath, curr_fp );
689  }
690  catch( const IO_ERROR& ioe )
691  {
692  DisplayError( this, ioe.What() );
693  }
694  }
695  }
696 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
PROJECT holds project specific data.
Definition: project.h:58
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:171
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:400
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:186
#define _(s)
Definition: 3d_actions.cpp:31
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:264
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 221 of file eda_base_frame.h.

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

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

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

◆ CheckForAutoSaveFile()

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

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

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

Parameters
aFileNameA wxFileName object containing the file name to check.

Definition at line 735 of file eda_base_frame.cpp.

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

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

Referenced by 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:366
#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:213
void SetBoard(BOARD *aBoard) override
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
#define _(s)
Definition: 3d_actions.cpp:31
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:280
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().

◆ ClearMsgPanel()

◆ CommonSettingsChanged()

void PCB_EDIT_FRAME::CommonSettingsChanged ( bool  aEnvVarsChanged)
overridevirtual

Called after the preferences dialog is run.

Reimplemented from PCB_BASE_FRAME.

Definition at line 1172 of file pcb_edit_frame.cpp.

1173 {
1174  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1175 
1177 
1178  Layout();
1179  SendSizeEvent();
1180 }
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:300
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:31
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()

wxConfigBase * EDA_BASE_FRAME::config ( )
virtualinherited

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

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 584 of file eda_base_frame.cpp.

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

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

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

◆ ConfigBaseName()

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

Definition at line 345 of file eda_base_frame.h.

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

References EDA_BASE_FRAME::m_configName.

Referenced by DISPLAY_FOOTPRINTS_FRAME::LoadSettings(), FOOTPRINT_VIEWER_FRAME::LoadSettings(), EDA_BASE_FRAME::LoadSettings(), EDA_DRAW_FRAME::LoadSettings(), DISPLAY_FOOTPRINTS_FRAME::SaveSettings(), FOOTPRINT_VIEWER_FRAME::SaveSettings(), EDA_BASE_FRAME::SaveSettings(), EDA_DRAW_FRAME::SaveSettings(), and ACTION_MANAGER::UpdateHotKeys().

◆ 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->AddPrimitive( 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:236
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:219
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void SetY0(int y)
Definition: class_pad.h:296
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:31
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void AddPrimitive(const SHAPE_POLY_SET &aPoly, int aThickness)
Has meaning only for free shape pads.
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:429
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::AddPrimitive(), 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:236
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:31
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 367 of file pcb_base_frame.cpp.

368 {
369  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
370 
371  if( !draw3DFrame )
372  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
373 
374  // Raising the window does not show the window on Windows if iconized. This should work
375  // on any platform.
376  if( draw3DFrame->IsIconized() )
377  draw3DFrame->Iconize( false );
378 
379  draw3DFrame->Raise();
380  draw3DFrame->Show( true );
381 
382  // Raising the window does not set the focus on Linux. This should work on any platform.
383  if( wxWindow::FindFocus() != draw3DFrame )
384  draw3DFrame->SetFocus();
385 
386  return draw3DFrame;
387 }
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:31
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:56
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 652 of file pcbnew/files.cpp.

653 {
654  wxFileName fn = aFileName;
655  wxFileName backupFileName = aFileName;
656 
657  backupFileName.SetExt( fn.GetExt() + GetBackupSuffix() );
658 
659  // If an old backup file exists, delete it. If an old board file exists,
660  // rename it to the backup file name.
661  if( fn.FileExists() )
662  {
663  // Remove the old file xxx.000 if it exists.
664  if( backupFileName.FileExists() )
665  wxRemoveFile( backupFileName.GetFullPath() );
666 
667  // Rename the current file from <xxx>.kicad_pcb to <xxx>.kicad_pcb-bak
668  if( !wxRenameFile( fn.GetFullPath(), backupFileName.GetFullPath() ) )
669  {
670  wxString msg = wxString::Format( _(
671  "Warning: unable to create backup file \"%s\"" ),
672  GetChars( backupFileName.GetFullPath() )
673  );
674  DisplayError( NULL, msg );
675  }
676  }
677  else
678  {
679  backupFileName.Clear();
680  }
681 
682  return backupFileName.GetFullPath();
683 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
#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:31

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:441
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 406 of file footprint_libraries_utils.cpp.

407 {
408  // Kicad cannot write legacy format libraries, only .pretty new format
409  // because the legacy format cannot handle current features.
410  // The footprint library is actually a directory
411 
412  wxString initialPath = wxPathOnly( Prj().GetProjectFullName() );
413  wxFileName fn;
414  bool doAdd = false;
415 
416  if( aLibName.IsEmpty() )
417  {
418  fn = initialPath;
419 
420  if( !LibraryFileBrowser( false, fn,
422  {
423  return wxEmptyString;
424  }
425 
426  doAdd = true;
427  }
428  else
429  {
430  fn = aLibName;
431 
432  if( !fn.IsAbsolute() )
433  {
434  fn.SetName( aLibName );
435  fn.MakeAbsolute( initialPath );
436  }
437 
438  // Enforce the .pretty extension:
439  fn.SetExt( KiCadFootprintLibPathExtension );
440  }
441 
442  // We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries)
444  wxString libPath = fn.GetFullPath();
445 
446  try
447  {
448  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
449 
450  bool writable = false;
451  bool exists = false;
452 
453  try
454  {
455  writable = pi->IsFootprintLibWritable( libPath );
456  exists = true; // no exception was thrown, lib must exist.
457  }
458  catch( const IO_ERROR& )
459  { }
460 
461  if( exists )
462  {
463  if( !writable )
464  {
465  wxString msg = wxString::Format( FMT_LIB_READ_ONLY, libPath );
466  DisplayError( this, msg );
467  return wxEmptyString;
468  }
469  else
470  {
471  wxString msg = wxString::Format( _( "Library %s already exists." ), libPath );
472  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
473  dlg.SetOKLabel( _( "Overwrite" ) );
474  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
475 
476  if( dlg.ShowModal() == wxID_CANCEL )
477  return wxEmptyString;
478 
479  pi->FootprintLibDelete( libPath );
480  }
481  }
482 
483  pi->FootprintLibCreate( libPath );
484  }
485  catch( const IO_ERROR& ioe )
486  {
487  DisplayError( this, ioe.What() );
488  return wxEmptyString;
489  }
490 
491  if( doAdd )
492  AddLibrary( libPath );
493 
494  return libPath;
495 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
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:31
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 1025 of file footprint_libraries_utils.cpp.

1026 {
1027  // Creates a new footprint at position 0,0 which contains the minimal items:
1028  // the reference and the value.
1029  // Value : initialized to the footprint name.
1030  // put on fab layer (front side)
1031  // Reference : initialized to a default value (REF**).
1032  // put on silkscreen layer (front side)
1033 
1034  wxString moduleName = aModuleName;
1035 
1036  // Ask for the new module name
1037  if( moduleName.IsEmpty() )
1038  {
1039  WX_TEXT_ENTRY_DIALOG dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
1040  dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &moduleName ) );
1041 
1042  if( dlg.ShowModal() != wxID_OK )
1043  return NULL; //Aborted by user
1044  }
1045 
1046  moduleName.Trim( true );
1047  moduleName.Trim( false );
1048 
1049  if( moduleName.IsEmpty() )
1050  {
1052  return NULL;
1053  }
1054 
1055  // Creates the new module and add it to the head of the linked list of modules
1056  MODULE* module = new MODULE( GetBoard() );
1057 
1058  // Update parameters: timestamp ...
1059  module->SetLastEditTime();
1060 
1061  // Update its name in lib
1062  module->SetFPID( LIB_ID( wxEmptyString, moduleName ) );
1063 
1064  wxPoint default_pos;
1066 
1067  // Update reference:
1068  if( settings.m_RefDefaultText.IsEmpty() )
1069  module->SetReference( moduleName );
1070  else
1071  module->SetReference( settings.m_RefDefaultText );
1072 
1073  PCB_LAYER_ID layer = ToLAYER_ID( settings.m_RefDefaultlayer );
1074  module->Reference().SetThickness( settings.GetTextThickness( layer ) );
1075  module->Reference().SetTextSize( settings.GetTextSize( layer ) );
1076  module->Reference().SetItalic( settings.GetTextItalic( layer ) );
1077  module->Reference().SetKeepUpright( settings.GetTextUpright( layer ) );
1078  default_pos.y = GetDesignSettings().GetTextSize( layer ).y / 2;
1079  module->Reference().SetPosition( default_pos );
1080  module->Reference().SetLayer( layer );
1081  module->Reference().SetVisible( settings.m_RefDefaultVisibility );
1082 
1083  // Set the value field to a default value
1084  if( settings.m_ValueDefaultText.IsEmpty() )
1085  module->SetValue( moduleName );
1086  else
1087  module->SetValue( settings.m_ValueDefaultText );
1088 
1089  layer = ToLAYER_ID( settings.m_ValueDefaultlayer );
1090  module->Value().SetThickness( settings.GetTextThickness( layer ) );
1091  module->Value().SetTextSize( settings.GetTextSize( layer ) );
1092  module->Value().SetItalic( settings.GetTextItalic( layer ) );
1093  module->Value().SetKeepUpright( settings.GetTextUpright( layer ) );
1094  default_pos.y = -default_pos.y;
1095  module->Value().SetPosition( default_pos );
1096  module->Value().SetLayer( layer );
1097  module->Value().SetVisible( settings.m_ValueDefaultVisibility );
1098 
1099  SetMsgPanel( module );
1100  return module;
1101 }
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:264
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 267 of file eda_base_frame.cpp.

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

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

◆ 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 556 of file pcb_base_frame.cpp.

557 {
558  wxString line;
559  wxString gridformatter;
560 
561  switch( m_userUnits )
562  {
563  case EDA_UNITS::INCHES:
564  gridformatter = "grid X %.6f Y %.6f";
565  break;
566 
568  gridformatter = "grid X %.6f Y %.6f";
569  break;
570 
571  default:
572  gridformatter = "grid X %f Y %f";
573  break;
574  }
575 
576  BASE_SCREEN* screen = GetScreen();
577  wxArrayString gridsList;
578 
579  int icurr = screen->BuildGridsChoiceList( gridsList, m_userUnits != EDA_UNITS::INCHES );
580  GRID_TYPE& grid = screen->GetGrid( icurr );
581  double grid_x = To_User_Unit( m_userUnits, grid.m_Size.x );
582  double grid_y = To_User_Unit( m_userUnits, grid.m_Size.y );
583  line.Printf( gridformatter, grid_x, grid_y );
584 
585  SetStatusText( line, 4 );
586 }
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 376 of file eda_draw_frame.cpp.

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

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

◆ DisplayUnitsMsg()

void EDA_DRAW_FRAME::DisplayUnitsMsg ( )
inherited

Display current unit pane on the status bar.

Definition at line 413 of file eda_draw_frame.cpp.

414 {
415  wxString msg;
416 
417  switch( m_userUnits )
418  {
419  case EDA_UNITS::INCHES:
420  msg = _( "Inches" );
421  break;
423  msg = _( "mm" );
424  break;
425  default: msg = _( "Units" ); break;
426  }
427 
428  SetStatusText( msg, 5 );
429 }
#define _(s)
Definition: 3d_actions.cpp:31
EDA_UNITS m_userUnits

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

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

◆ doAutoSave()

bool 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 830 of file pcbnew/files.cpp.

831 {
832  wxFileName tmpFileName;
833 
834  if( GetBoard()->GetFileName().IsEmpty() )
835  {
836  tmpFileName = wxFileName( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ),
838  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
839  }
840  else
841  {
842  tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
843  }
844 
845  wxFileName autoSaveFileName = tmpFileName;
846 
847  // Auto save file name is the board file name prepended with autosaveFilePrefix string.
848  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() );
849 
850  if( !autoSaveFileName.IsOk() )
851  return false;
852 
853  // If the board file path is not writable, try writing to a platform specific temp file
854  // path. If that path isn't writabe, give up.
855  if( !autoSaveFileName.IsDirWritable() )
856  {
857  autoSaveFileName.SetPath( wxFileName::GetTempDir() );
858 
859  if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
860  return false;
861  }
862 
863  wxLogTrace( traceAutoSave, "Creating auto save file <" + autoSaveFileName.GetFullPath() + ">" );
864 
865  if( SavePcbFile( autoSaveFileName.GetFullPath(), NO_BACKUP_FILE ) )
866  {
867  GetScreen()->SetModify();
868  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
869  UpdateTitle();
870  m_autoSaveState = false;
871  return true;
872  }
873 
874  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
875 
876  return false;
877 }
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:386
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void SetFileName(const wxString &aFileName)
Definition: class_board.h:213
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 482 of file gen_footprints_placefile.cpp.

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

550 {
551  wxString msg;
552  FILE* rptfile;
553  wxPoint module_pos;
554 
555  rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
556 
557  if( rptfile == NULL )
558  return false;
559 
560  std::string data;
561  PLACE_FILE_EXPORTER exporter ( GetBoard(), aUnitsMM, false, true, true, false );
562  data = exporter.GenReportData();
563 
564  fputs( data.c_str(), rptfile );
565  fclose( rptfile );
566 
567  return true;
568 }
#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 573 of file pcb_edit_frame.cpp.

575 {
576  DIALOG_BOARD_SETUP dlg( this );
577 
578  if( !aInitialPage.IsEmpty() )
579  dlg.SetInitialPage( aInitialPage, aInitialParentPage );
580 
581  if( dlg.ShowModal() == wxID_OK )
582  {
583  SaveProjectSettings( false );
584 
587 
588  for( auto module : GetBoard()->Modules() )
589  GetCanvas()->GetView()->Update( module );
590 
591  GetCanvas()->Refresh();
592 
593  //this event causes the routing tool to reload its design rules information
595  toolEvent.SetHasPosition( false );
596  m_toolManager->ProcessEvent( toolEvent );
597 
598  OnModify();
599  }
600 }
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.
void SaveProjectSettings(bool aAskForSave) override
Function SaveProjectSettings saves changes to the project settings to the project (....
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 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(), TA_MODEL_CHANGE, TC_COMMAND, and UpdateUserInterface().

Referenced by 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 1011 of file pcb_edit_frame.cpp.

1012 {
1013  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1014  updater.SetLookupByTimestamp( aUseTimestamps );
1015  updater.SetDeleteUnusedComponents( false );
1016  updater.SetReplaceFootprints( true );
1017  updater.SetDeleteSinglePadNets( false );
1018  updater.SetWarnPadNoNetInNetlist( false );
1019  updater.UpdateNetlist( aNetlist );
1020 }
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:170
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:46
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:83
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:948
const ZONE_SETTINGS & GetZoneSettings() const
void SetNetCode(int aNetCode)
Definition: netinfo.h:227
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:300
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:225
#define _(s)
Definition: 3d_actions.cpp:31
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:913
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 245 of file eda_draw_frame.cpp.

246 {
247  if( m_messagePanel )
249 }
EDA_MSG_PANEL * m_messagePanel
void EraseMsgBox()
Definition: msgpanel.cpp:216

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

Referenced by GERBVIEW_CONTROL::UpdateMessagePanel().

◆ 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 424 of file dialog_exchange_footprints.cpp.

427 {
428  aDest->SetParent( GetBoard() );
429 
430  PlaceModule( aDest, false );
431 
432  // PlaceModule will move the module to the cursor position, which we don't want. Copy
433  // the original position across.
434  aDest->SetPosition( aSrc->GetPosition() );
435 
436  if( aDest->GetLayer() != aSrc->GetLayer() )
437  aDest->Flip( aDest->GetPosition(), m_configSettings.m_FlipLeftRight );
438 
439  if( aDest->GetOrientation() != aSrc->GetOrientation() )
440  aDest->Rotate( aDest->GetPosition(), aSrc->GetOrientation() );
441 
442  aDest->SetLocked( aSrc->IsLocked() );
443 
444  for( auto pad : aDest->Pads() )
445  {
446  D_PAD* oldPad = aSrc->FindPadByName( pad->GetName() );
447 
448  if( oldPad )
449  {
451  pad->SetNetCode( oldPad->GetNetCode() );
452  pad->SetPinFunction( oldPad->GetPinFunction() );
453  }
454  }
455 
456  // Copy reference
457  processTextItem( aSrc->Reference(), aDest->Reference(),
458  // never reset reference text
459  false,
460  resetTextLayers, resetTextEffects );
461 
462  // Copy value
463  processTextItem( aSrc->Value(), aDest->Value(),
464  // reset value text only when it is a proxy for the footprint ID
465  // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
466  aSrc->GetValue() == aSrc->GetFPID().GetLibItemName(),
467  resetTextLayers, resetTextEffects );
468 
469  // Copy fields in accordance with the reset* flags
470  for( auto item : aSrc->GraphicalItems() )
471  {
472  TEXTE_MODULE* srcItem = dyn_cast<TEXTE_MODULE*>( item );
473 
474  if( srcItem )
475  {
476  TEXTE_MODULE* destItem = getMatchingTextItem( srcItem, aDest );
477 
478  if( destItem )
479  processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects );
480  else if( !deleteExtraTexts )
481  aDest->Add( new TEXTE_MODULE( *srcItem ) );
482  }
483  }
484 
485  // Copy 3D model settings in accordance with the reset* flag
486  if( !reset3DModels )
487  aDest->Models() = aSrc->Models(); // Linked list of 3D models.
488 
489  // Updating other parameters
490  aDest->SetTimeStamp( aSrc->GetTimeStamp() );
491  aDest->SetPath( aSrc->GetPath() );
492  aDest->CalculateBoundingBox();
493 
494  aCommit.Remove( aSrc );
495  aCommit.Add( aDest );
496 
497  aDest->ClearFlags();
498 }
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.
const wxString & GetPath() const
Definition: class_module.h:228
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)
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:216
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.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:213
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
PCB_GENERAL_SETTINGS m_configSettings
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
TEXTE_MODULE * getMatchingTextItem(TEXTE_MODULE *aRefItem, MODULE *aModule)
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:256
void processTextItem(const TEXTE_MODULE &aSrc, TEXTE_MODULE &aDest, bool resetText, bool resetTextLayers, bool resetTextEffects)
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
void SetPath(const wxString &aPath)
Definition: class_module.h:229
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:212

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(), EDA_ITEM::GetTimeStamp(), MODULE::GetValue(), MODULE::GraphicalItems(), MODULE::IsLocked(), PCB_BASE_FRAME::m_configSettings, PCB_GENERAL_SETTINGS::m_FlipLeftRight, 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(), EDA_ITEM::SetTimeStamp(), 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 sheetStamp( FROM_UTF8( text ) );
149  SetStatusText( msg );
151  static_cast<void*>( &sheetStamp ) );
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  double ratio = std::max( fabs( bbSize.x / screenSize.x ),
214  fabs( bbSize.y / screenSize.y ) );
215 
216  // Try not to zoom on every cross-probe; it gets very noisy
217  if( ratio < 0.1 || ratio > 1.0 )
218  view->SetScale( view->GetScale() / ratio );
219 
220  view->SetCenter( bbox.Centre() );
221  }
222 
223  view->UpdateAllLayersColor();
224  // Ensure the display is refreshed, because in some installs the refresh is done only
225  // when the gal canvas has the focus, and that is not the case when crossprobing from
226  // Eeschema:
227  GetCanvas()->Refresh();
228 }
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:250
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:411
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:109
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:366
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:226
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:141
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:382
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:240
Vec Centre() const
Definition: box2.h:78
int GetNet() const
Function GetNet.
Definition: netinfo.h:225
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:160
#define _(s)
Definition: 3d_actions.cpp:31
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:217
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(), 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:90
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:530
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:215
#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:226
wxString GetBuildVersion()
Function GetBuildVersion Return the build 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:31
#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 81 of file specctra_export.cpp.

82 {
83  SPECCTRA_DB db;
84  bool ok = true;
85  wxString errorText;
86 
87  BASE_SCREEN* screen = GetScreen();
88  bool wasModified = screen->IsModify();
89 
90  db.SetPCB( SPECCTRA_DB::MakePCB() );
91 
92  LOCALE_IO toggle; // Switch the locale to standard C
93 
94  // DSN Images (=KiCad MODULES and pads) must be presented from the
95  // top view. So we temporarily flip any modules which are on the back
96  // side of the board to the front, and record this in the MODULE's flag field.
97  db.FlipMODULEs( GetBoard() );
98 
99  try
100  {
102  db.FromBOARD( GetBoard() );
103  db.ExportPCB( aFullFilename, true );
104 
105  // if an exception is thrown by FromBOARD or ExportPCB(), then
106  // ~SPECCTRA_DB() will close the file.
107  }
108  catch( const IO_ERROR& ioe )
109  {
110  ok = false;
111 
112  // copy the error string to safe place, ioe is in this scope only.
113  errorText = ioe.What();
114  }
115 
116  // done assuredly, even if an exception was thrown and caught.
117  db.RevertMODULEs( GetBoard() );
118 
119  // The two calls below to MODULE::Flip(), both set the
120  // modified flag, yet their actions cancel each other out, so it should
121  // be ok to clear the modify flag.
122  if( !wasModified )
123  screen->ClrModify();
124 
125  if( ok )
126  {
127  SetStatusText( wxString( _( "BOARD exported OK." ) ) );
128  }
129  else
130  {
131  DisplayErrorMessage( this,
132  _( "Unable to export, please fix and try again" ),
133  errorText );
134  }
135 
136  return ok;
137 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:249
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:90
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:31
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 817 of file pcb_edit_frame.cpp.

818 {
819  InvokeExportSVG( this, GetBoard() );
820 }
bool InvokeExportSVG(PCB_BASE_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 273 of file export_gencad.cpp.

274 {
275  // Build default output file name
276  wxString path = GetLastPath( LAST_PATH_GENCAD );
277 
278  if( path.IsEmpty() )
279  {
280  wxFileName brdFile = GetBoard()->GetFileName();
281  brdFile.SetExt( "cad" );
282  path = brdFile.GetFullPath();
283  }
284 
285  DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( this, path );
286 
287  if( optionsDialog.ShowModal() == wxID_CANCEL )
288  return;
289 
290  path = optionsDialog.GetFileName();
291  SetLastPath( LAST_PATH_GENCAD, path );
292  FILE* file = wxFopen( path, "wt" );
293 
294  if( !file )
295  {
296  DisplayError( this, wxString::Format( _( "Unable to create \"%s\"" ),
297  optionsDialog.GetFileName() ) );
298  return;
299  }
300 
301  // Get options
302  flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );
303  uniquePins = optionsDialog.GetOption( UNIQUE_PIN_NAMES );
304  individualShapes = optionsDialog.GetOption( INDIVIDUAL_SHAPES );
305  storeOriginCoords = optionsDialog.GetOption( STORE_ORIGIN_COORDS );
306 
307  // Switch the locale to standard C (needed to print floating point numbers)
308  LOCALE_IO toggle;
309 
310  // Update some board data, to ensure a reliable gencad export
312 
313  // Save the auxiliary origin for the rest of the module
314  GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().x : 0;
315  GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().y : 0;
316 
317  // No idea on *why* this should be needed... maybe to fix net names?
318  Compile_Ratsnest( true );
319 
320  /* Temporary modification of footprints that are flipped (i.e. on bottom
321  * layer) to convert them to non flipped footprints.
322  * This is necessary to easily export shapes to GenCAD,
323  * that are given as normal orientation (non flipped, rotation = 0))
324  * these changes will be undone later
325  */
326  BOARD* pcb = GetBoard();
327 
328  for( auto module : pcb->Modules() )
329  {
330  module->SetFlag( 0 );
331 
332  if( module->GetLayer() == B_Cu )
333  {
334  module->Flip( module->GetPosition(), Settings().m_FlipLeftRight );
335  module->SetFlag( 1 );
336  }
337  }
338 
339  /* Gencad has some mandatory and some optional sections: some importer
340  * need the padstack section (which is optional) anyway. Also the
341  * order of the section *is* important */
342 
343  CreateHeaderInfoData( file, this ); // Gencad header
344  CreateBoardSection( file, pcb ); // Board perimeter
345 
346  CreatePadsShapesSection( file, pcb ); // Pads and padstacks
347  CreateArtworksSection( file ); // Empty but mandatory
348 
349  /* Gencad splits a component info in shape, component and device.
350  * We don't do any sharing (it would be difficult since each module is
351  * customizable after placement) */
352  CreateShapesSection( file, pcb );
353  CreateComponentsSection( file, pcb );
354  CreateDevicesSection( file, pcb );
355 
356  // In a similar way the netlist is split in net, track and route
357  CreateSignalsSection( file, pcb );
358  CreateTracksInfoData( file, pcb );
359  CreateRoutesSection( file, pcb );
360 
361  fclose( file );
362 
363  // Undo the footprints modifications (flipped footprints)
364  for( auto module : pcb->Modules() )
365  {
366  if( module->GetFlag() )
367  {
368  module->Flip( module->GetPosition(), Settings().m_FlipLeftRight );
369  module->SetFlag( 0 );
370  }
371  }
372 
373  componentShapes.clear();
374  shapeNames.clear();
375 }
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:236
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:90
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:215
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:226
static void CreatePadsShapesSection(FILE *aFile, BOARD *aPcb)
PCB_GENERAL_SETTINGS & Settings()
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:160
static void CreateDevicesSection(FILE *aFile, BOARD *aPcb)
#define _(s)
Definition: 3d_actions.cpp:31
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, PCB_GENERAL_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:226
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:160
#define _(s)
Definition: 3d_actions.cpp:31
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 958 of file pcb_edit_frame.cpp.

959 {
960  if( Kiface().IsSingle() )
961  {
962  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
963  "mode. In order to create or update PCBs from schematics, you "
964  "must launch the KiCad project manager and create a project." ) );
965  return false;
966  }
967 
968  // Update PCB requires a netlist. Therefore the schematic editor must be running
969  // If this is not the case, open the schematic editor
970  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
971 
972  if( !frame->IsShown() )
973  {
974  wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(), SchematicFileExtension );
975 
976  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
977 
978  // we show the schematic editor frame, because do not show is seen as
979  // a not yet opened schematic by Kicad manager, which is not the case
980  frame->Show( true );
981 
982  // bring ourselves back to the front
983  Raise();
984  }
985 
986  std::string payload;
987 
988  if( aMode == NO_ANNOTATION )
989  payload = "no-annotate";
990  else if( aMode == QUIET_ANNOTATION )
991  payload = "quiet-annotate";
992 
993  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
994 
995  try
996  {
997  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
998  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
999  netlistReader.LoadNetlist();
1000  }
1001  catch( const IO_ERROR& )
1002  {
1003  assert( false ); // should never happen
1004  return false;
1005  }
1006 
1007  return true;
1008 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
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.
Definition: mail_type.h:45
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.
const std::string SchematicFileExtension
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
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:31
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, KICAD_NETLIST_READER::LoadNetlist(), MAIL_SCH_GET_NETLIST, KIWAY_PLAYER::OpenProjectFiles(), KIWAY::Player(), Prj(), and SchematicFileExtension.

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 206 of file pcbnew/files.cpp.

207 {
208  int id = event.GetId();
209  Files_io_from_id( id );
210 }
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 213 of file pcbnew/files.cpp.

214 {
215  wxString msg;
216 
217  switch( id )
218  {
219  case ID_LOAD_FILE:
220  {
221  int open_ctl = 0;
222  wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
223 
224  return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
225  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
226  }
227 
229  {
230  int open_ctl = 1;
231  wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
232 
233  return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
234  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
235  }
236 
239  {
240  wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
241  wxFileName fn = currfn;
242 
244  {
245  wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
246  fn.SetName( rec_name );
247  }
248  else
249  {
250  wxString backup_ext = fn.GetExt() + GetBackupSuffix();
251  fn.SetExt( backup_ext );
252  }
253 
254  if( !fn.FileExists() )
255  {
256  msg.Printf( _( "Recovery file \"%s\" not found." ), fn.GetFullPath() );
257  DisplayInfoMessage( this, msg );
258  return false;
259  }
260 
261  msg.Printf( _( "OK to load recovery or backup file \"%s\"" ), fn.GetFullPath() );
262 
263  if( !IsOK( this, msg ) )
264  return false;
265 
266  GetScreen()->ClrModify(); // do not prompt the user for changes
267 
268  if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
269  {
270  // Re-set the name since name or extension was changed
271  GetBoard()->SetFileName( currfn.GetFullPath() );
272  UpdateTitle();
273  return true;
274  }
275  return false;
276  }
277 
278  case ID_NEW_BOARD:
279  {
280  if( IsContentModified() )
281  {
282  wxFileName fileName = GetBoard()->GetFileName();
283  wxString saveMsg =
284  _( "Current board will be closed, save changes to \"%s\" before continuing?" );
285 
286  if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
287  [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
288  return false;
289  }
290  else if( !GetBoard()->IsEmpty() )
291  {
292  if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
293  return false;
294  }
295 
296  if( !Clear_Pcb( false ) )
297  return false;
298 
299  wxFileName fn( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ),
301 
302  Prj().SetProjectFullName( fn.GetFullPath() );
303 
304  onBoardLoaded();
305 
306  OnModify();
307  return true;
308  }
309 
310  case ID_SAVE_BOARD:
311  if( !GetBoard()->GetFileName().IsEmpty() )
312  return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) );
313  // Fall through
314 
315  case ID_COPY_BOARD_AS:
316  case ID_SAVE_BOARD_AS:
317  {
318  wxString orig_name;
319  wxFileName::SplitPath( GetBoard()->GetFileName(),
320  nullptr, nullptr, &orig_name, nullptr );
321 
322  if( orig_name.IsEmpty() )
323  orig_name = _( "noname" );
324 
325  wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
326  wxFileName fn( pro_dir, orig_name, KiCadPcbFileExtension );
327  wxString filename = fn.GetFullPath();
328 
329  if( AskSaveBoardFileName( this, &filename ) )
330  {
331  if( id == ID_COPY_BOARD_AS )
332  return SavePcbCopy( filename );
333  else
334  return SavePcbFile( filename, NO_BACKUP_FILE );
335  }
336  return false;
337  }
338 
339  default:
340  wxLogDebug( wxT( "File_io Internal Error" ) );
341  return false;
342  }
343 }
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:215
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:386
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:213
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:31
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:264
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:280
bool IsEmpty() const
Definition: class_board.h:256

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 1008 of file pcbnew/files.cpp.

1009 {
1010  bool result = true;
1011  BOARD* board = GetBoard();
1012 
1013  // perform netlist matching to prevent orphaned zones.
1014  for( auto zone : board->Zones() )
1015  {
1016  auto it = aRemap.find( zone->GetNet()->GetNetname() );
1017 
1018  if( it != aRemap.end() )
1019  {
1020  NETINFO_ITEM* net = board->FindNet( it->second );
1021 
1022  if( !net )
1023  {
1024  wxFAIL;
1025  result = false;
1026  continue;
1027  }
1028 
1029  zone->SetNet( net );
1030  }
1031  }
1032 
1033 
1034  // perform netlist matching to prevent orphaned tracks/vias.
1035  for( auto track : board->Tracks() )
1036  {
1037  auto it = aRemap.find( track->GetNet()->GetNetname() );
1038 
1039  if( it != aRemap.end() )
1040  {
1041  NETINFO_ITEM* net = board->FindNet( it->second );
1042 
1043  if( !net )
1044  {
1045  wxFAIL;
1046  result = false;
1047  continue;
1048  }
1049 
1050  track->SetNet( net );
1051  }
1052  }
1053 
1054  return result;
1055 }
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:240
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
BOARD * GetBoard() const
TRACKS & Tracks()
Definition: class_board.h:217

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

Referenced by importFile().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const wxPoint aPos,
bool  aCenterView = false 
)
inherited

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

Parameters
aPosis the point to go to.
aCenterViewis true if the new cursor position should be centered on canvas.

Definition at line 732 of file eda_draw_frame.cpp.

733 {
734  if( aCenterView )
735  {
736  wxWindow* dialog = findDialog( GetChildren() );
737 
738  // If a dialog partly obscures the window, then center on the uncovered area.
739  if( dialog )
740  {
741  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
742  dialog->GetSize() );
743  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
744  }
745  else
746  GetCanvas()->GetView()->SetCenter( aPos );
747  }
748 
750 }
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:604
wxWindow * findDialog(wxWindowList &aList)
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.

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

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

◆ GenD356File()

void PCB_EDIT_FRAME::GenD356File ( wxCommandEvent &  event)

Definition at line 352 of file export_d356.cpp.

353 {
354  wxFileName fn = GetBoard()->GetFileName();
355  wxString msg, ext, wildcard;
356  FILE* file;
357 
358  ext = IpcD356FileExtension;
359  wildcard = IpcD356FileWildcard();
360  fn.SetExt( ext );
361 
362  wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
363 
364  wxFileDialog dlg( this, _( "Export D-356 Test File" ), pro_dir,
365  fn.GetFullName(), wildcard,
366  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
367 
368  if( dlg.ShowModal() == wxID_CANCEL )
369  return;
370 
371  if( ( file = wxFopen( dlg.GetPath(), wxT( "wt" ) ) ) == NULL )
372  {
373  msg = _( "Unable to create " ) + dlg.GetPath();
374  DisplayError( this, msg ); return;
375  }
376 
377  LOCALE_IO toggle; // Switch the locale to standard C
378 
379  // This will contain everything needed for the 356 file
380  std::vector <D356_RECORD> d356_records;
381  BOARD* pcb = GetBoard();
382 
383  build_via_testpoints( pcb, d356_records );
384 
385  build_pad_testpoints( pcb, d356_records );
386 
387  // Code 00 AFAIK is ASCII, CUST 0 is decimils/degrees
388  // CUST 1 would be metric but gerbtool simply ignores it!
389  fprintf( file, "P CODE 00\n" );
390  fprintf( file, "P UNITS CUST 0\n" );
391  fprintf( file, "P arrayDim N\n" );
392  write_D356_records( d356_records, file );
393  fprintf( file, "999\n" );
394 
395  fclose( file );
396 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:90
static void build_pad_testpoints(BOARD *aPcb, std::vector< D356_RECORD > &aRecords)
const wxString & GetFileName() const
Definition: class_board.h:215
static void write_D356_records(std::vector< D356_RECORD > &aRecords, FILE *fout)
#define NULL
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static void build_via_testpoints(BOARD *aPcb, std::vector< D356_RECORD > &aRecords)
const std::string IpcD356FileExtension
wxString IpcD356FileWildcard()
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
#define _(s)
Definition: 3d_actions.cpp:31
BOARD * GetBoard() const

References _, build_pad_testpoints(), build_via_testpoints(), DisplayError(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), IpcD356FileExtension, IpcD356FileWildcard(), NULL, KIWAY_HOLDER::Prj(), and write_D356_records().

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 516 of file gen_footprints_placefile.cpp.

517 {
518  wxFileName fn;
519 
520  wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName()).GetPath();
521  wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
522 
523  if( dirDialog.ShowModal() == wxID_CANCEL )
524  return;
525 
526  fn = GetBoard()->GetFileName();
527  fn.SetPath( dirDialog.GetPath() );
528  fn.SetExt( wxT( "rpt" ) );
529 
530  bool unitMM = GetUserUnits() != EDA_UNITS::INCHES;
531  bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM );
532 
533  wxString msg;
534  if( success )
535  {
536  msg.Printf( _( "Footprint report file created:\n\"%s\"" ), fn.GetFullPath() );
537  wxMessageBox( msg, _( "Footprint Report" ), wxICON_INFORMATION );
538  }
539 
540  else
541  {
542  msg.Printf( _( "Unable to create \"%s\"" ), fn.GetFullPath() );
543  DisplayError( this, msg );
544  }
545 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
const wxString & GetFileName() const
Definition: class_board.h:215
bool DoGenFootprintsReport(const wxString &aFullFilename, bool aUnitsMM)
Function DoGenFootprintsReport Creates an ascii footprint report file giving some infos on footprints...
#define _(s)
Definition: 3d_actions.cpp:31
BOARD * GetBoard() const
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, DisplayError(), DoGenFootprintsReport(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), EDA_BASE_FRAME::GetUserUnits(), and INCHES.

Referenced by PCB_EDITOR_CONTROL::GenerateFabFiles().

◆ Get3DViewerFrame()

EDA_3D_VIEWER * PCB_BASE_FRAME::Get3DViewerFrame ( )
inherited
Returns
a reference to the child 3D viewer frame, when exists, or NULL

Definition at line 112 of file pcb_base_frame.cpp.

113 {
114  return dynamic_cast<EDA_3D_VIEWER*>( FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) ) );
115 }
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
Definition: eda_3d_viewer.h:50

References QUALIFIED_VIEWER3D_FRAMENAME.

Referenced by PCB_BASE_FRAME::CommonSettingsChanged(), PCB_BASE_FRAME::CreateAndShow3D_Frame(), OpenProjectFiles(), PCB_BASE_FRAME::Update3DView(), and FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME().

◆ GetAboutTitle()

const wxString& EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

Definition at line 475 of file eda_base_frame.h.

475 { return m_AboutTitle; }
wxString m_AboutTitle

References EDA_BASE_FRAME::m_AboutTitle.

Referenced by DIALOG_ABOUT::DIALOG_ABOUT().

◆ GetActiveLayer()

◆ GetAutoSaveFilePrefix()

static wxString EDA_BASE_FRAME::GetAutoSaveFilePrefix ( )
inlinestaticprotectedinherited
Returns
the string to prepend to a file name for automatic save.

Definition at line 167 of file eda_base_frame.h.

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

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), SCH_EDIT_FRAME::doAutoSave(), doAutoSave(), Files_io_from_id(), SCH_EDIT_FRAME::OnCloseWindow(), OnExportSTEP(), SCH_EDIT_FRAME::SaveEEFile(), and SavePcbFile().

◆ GetAutoSaveInterval()

int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 290 of file eda_base_frame.h.

290 { return m_autoSaveInterval; }

References EDA_BASE_FRAME::m_autoSaveInterval.

◆ GetAuxOrigin()

const wxPoint & PCB_BASE_FRAME::GetAuxOrigin ( ) const
overridevirtualinherited

Return the origin of the axis used for plotting and various exports.

Implements EDA_DRAW_FRAME.

Definition at line 231 of file pcb_base_frame.cpp.

232 {
233  wxASSERT( m_Pcb );
234  return m_Pcb->GetAuxOrigin();
235 }
const wxPoint & GetAuxOrigin() const
Definition: class_board.h:353

References BOARD::GetAuxOrigin(), and PCB_BASE_FRAME::m_Pcb.

Referenced by ExportToGenCAD(), EDIT_TOOL::MoveExact(), and DIALOG_GENDRILL::UpdateDrillParams().

◆ GetBackupSuffix()

static wxString EDA_BASE_FRAME::GetBackupSuffix ( )
inlinestaticprotectedinherited
Returns
the suffix to be appended to the file extension on backup

Definition at line 159 of file eda_base_frame.h.

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

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), createBackupFile(), Files_io_from_id(), and SCH_EDIT_FRAME::SaveEEFile().

◆ GetBoard()