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 TOOLS_HOLDER 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  UNDO_REDO_LIST { UNDO_LIST, REDO_LIST }
 Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if needed. More...
 
enum  HOLDER_TYPE { DIALOG, FRAME, PANEL }
 

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. More...
 
void PythonPluginsShowFolder ()
 Open the plugins folder in the default system file browser. More...
 
void PythonSyncEnvironmentVariables ()
 Synchronize the environment variables from KiCad's environment into the Python interpreter. More...
 
void PythonSyncProjectName ()
 Synchronize the project name from KiCad's environment into the Python interpreter. 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
 Receive 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 ()
 
void OnUpdateSelectViaSize (wxUpdateUIEvent &aEvent)
 
void OnUpdateSelectTrackWidth (wxUpdateUIEvent &aEvent)
 
void OnUpdateSelectAutoWidth (wxUpdateUIEvent &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)
 
void SaveProjectSettings () override
 Function SaveProjectSettings saves changes to the project settings to the project (.pro) file. More...
 
bool LoadProjectSettings ()
 Load the current project's file configuration settings which are pertinent to this PCB_EDIT_FRAME instance. More...
 
void LoadSettings (APP_SETTINGS_BASE *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (APP_SETTINGS_BASE *aCfg) override
 Save common frame parameters to a configuration data file. More...
 
wxString GetLastPath (LAST_PATH_TYPE aType)
 Get the last path for a particular type. More...
 
void SetLastPath (LAST_PATH_TYPE aType, const wxString &aLastPath)
 Set the path of the last file successfully read. More...
 
void RecordDRCExclusions ()
 Scan existing markers and record data from any that are Excluded. More...
 
void ResolveDRCExclusions ()
 Update markers to match recorded exclusions. More...
 
void Process_Special_Functions (wxCommandEvent &event)
 
void Tracks_and_Vias_Size_Event (wxCommandEvent &event)
 
void ReCreateHToolbar () override
 
void ReCreateAuxiliaryToolbar () override
 
void ReCreateVToolbar () override
 
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...
 
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 APPEARANCE_CONTROLS. More...
 
APPEARANCE_CONTROLSGetAppearancePanel ()
 
void OnUpdateLayerAlpha (wxUpdateUIEvent &aEvent) override
 Update the UI to reflect changes to the current layer's transparency. More...
 
void OnDisplayOptionsChanged () override
 
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 ActivateGalCanvas () override
 

More...
 
void ShowBoardSetupDialog (const wxString &aInitialPage=wxEmptyString)
 Function ShowBoardSetupDialog. More...
 
void PrepareLayerIndicator (bool aForceRebuild=false)
 
void ToggleLayersManager ()
 
int DoGenFootprintsPositionFile (const wxString &aFullFileName, bool aUnitsMM, bool aForceSmdItems, bool aTopSide, bool aBottomSide, bool aFormatCSV=false)
 Function DoGenFootprintsPositionFile Creates an ascii footprint position file. More...
 
void GenFootprintsReport (wxCommandEvent &event)
 Function GenFootprintsReport Calls DoGenFootprintsReport to create a footprint reprot file See DoGenFootprintsReport for file format. More...
 
bool DoGenFootprintsReport (const wxString &aFullFilename, bool aUnitsMM)
 Function DoGenFootprintsReport Creates an ascii footprint report file giving some infos on footprints and board outlines. More...
 
void GenD356File (wxCommandEvent &event)
 
void OnFileHistory (wxCommandEvent &event)
 
void OnClearFileHistory (wxCommandEvent &aEvent)
 
void Files_io (wxCommandEvent &event)
 Function Files_io. More...
 
bool Files_io_from_id (int aId)
 Function Files_io_from_id Read and write board files. More...
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 Function OpenProjectFiles (was LoadOnePcbFile) loads a KiCad board (.kicad_pcb) from aFileName. More...
 
bool SavePcbFile (const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
 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, bool aCreateProject=false)
 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 ExportFootprintsToLibrary (bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=NULL)
 Function ExportFootprintsToLibrary Save footprints 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 ShowFootprintPropertiesDialog (FOOTPRINT *aFootprint)
 
int ShowExchangeFootprintsDialog (FOOTPRINT *aFootprint, bool aUpdateMode, bool aSelectedMode)
 
void ExchangeFootprint (FOOTPRINT *aExisting, FOOTPRINT *aNew, BOARD_COMMIT &aCommit, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool resetFabricationAttrs=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
 
void 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 *zone_container)
 Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline. More...
 
void ShowTargetOptionsDialog (PCB_TARGET *aTarget)
 
void ShowDimensionPropertiesDialog (DIMENSION_BASE *aDimension)
 
void InstallNetlistFrame ()
 
bool FetchNetlistFromSchematic (NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
 
bool ReannotateSchematic (std::string &aNetlist)
 Sends a command to Eeschema to re-annotate the schematic. More...
 
bool TestStandalone (void)
 Test if standalone mode. More...
 
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 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...
 
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 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, bool aTextVarsChanged) override
 Called after the preferences dialog is run. More...
 
void ProjectChanged () override
 Notification event that the project has changed. More...
 
wxString GetCurrentFileName () const override
 Get the full filename + path of the currently opened file in the frame. More...
 
SELECTIONGetCurrentSelection () override
 Get the current selection from the canvas area. More...
 
bool TryBefore (wxEvent &aEvent) override
 
wxString CreateNewLibrary (const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
 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 (EDA_ITEM *aItemToCopy, UNDO_REDO 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 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...
 
void SetObjectVisible (GAL_LAYER_ID aLayer, bool aVisible=true)
 
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 ShowTextPropertiesDialog (BOARD_ITEM *aText)
 Routine for main window class to launch text properties dialog. More...
 
void ShowGraphicItemPropertiesDialog (BOARD_ITEM *aItem)
 
COLOR_SETTINGSGetColorSettings () const override
 Helper to retrieve the current color settings. More...
 
void ClearUndoORRedoList (UNDO_REDO_LIST whichList, int aItemCount=-1) override
 Function ClearUndoORRedoList free the undo or redo list from List element Wrappers are deleted. More...
 
wxString GetDesignRulesPath ()
 Returns the absolute path to the design rules file for the currently-loaded board. More...
 
EDA_3D_VIEWERGet3DViewerFrame ()
 
virtual void Update3DView (bool aReloadRequest, const wxString *aTitle=nullptr)
 Update the 3D view, if the viewer is opened by this frame. More...
 
FOOTPRINTLoadFootprint (const LIB_ID &aFootprintId)
 Attempt to load aFootprintId from the footprint library table. More...
 
EDA_RECT GetBoardBoundingBox (bool aBoardEdgesOnly=false) const
 Calculate the bounding box containing all board items (or board edge segments). More...
 
const BOX2I GetDocumentExtents (bool aIncludeAllVisible=true) const override
 Returns bbox of document with option to not include some items. More...
 
const PAGE_INFOGetPageSettings () const override
 
const wxSize GetPageSizeIU () const override
 Works off of GetPageSettings() to return the size of the paper page in the internal units of this particular view. More...
 
const wxPoint & GetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const wxPoint &aPoint) override
 
const wxPoint & GetAuxOrigin () const
 
const wxPoint GetUserOrigin () const
 
ORIGIN_TRANSFORMSGetOriginTransforms () override
 Return a reference to the default ORIGIN_TRANSFORMS object. More...
 
const TITLE_BLOCKGetTitleBlock () const override
 
void SetTitleBlock (const TITLE_BLOCK &aTitleBlock) override
 
virtual BOARD_DESIGN_SETTINGSGetDesignSettings () const
 Returns the BOARD_DESIGN_SETTINGS for the open project. More...
 
PCBNEW_SETTINGSSettings ()
 
void SetDrawBgColor (COLOR4D aColor) override
 
const PCB_DISPLAY_OPTIONSGetDisplayOptions () const
 Display options control 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
 Return the PCB_PLOT_PARAMS for the BOARD owned by this frame. More...
 
virtual void SetPlotSettings (const PCB_PLOT_PARAMS &aSettings)
 
BOARDGetBoard () const
 
EDA_ITEMGetItem (const KIID &aId) override
 Fetch an item by KIID. More...
 
void FocusOnItem (BOARD_ITEM *aItem)
 
virtual void UpdateStatusBar () override
 Update the status bar information. More...
 
PCB_SCREENGetScreen () const override
 Return a pointer to a BASE_SCREEN or one of its derivatives. More...
 
EDA_3D_VIEWERCreateAndShow3D_Frame ()
 Shows the 3D view frame. More...
 
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide ()
 
wxString SelectLibrary (const wxString &aNicknameExisting)
 Put up a dialog and allows the user to pick a library, for unspecified use. More...
 
FOOTPRINTGetFootprintFromBoardByReference ()
 
FOOTPRINTCreateNewFootprint (const wxString &aFootprintName)
 Creates a new footprint, at position 0,0. More...
 
void PlaceFootprint (FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
 Places aFootprint at the current cursor position and updates footprint coordinates with the new position. More...
 
void ShowPadPropertiesDialog (PAD *aPad)
 
FOOTPRINTSelectFootprintFromLibTree (LIB_ID aPreselect=LIB_ID())
 Open a dialog to select a footprint. More...
 
virtual void AddFootprintToBoard (FOOTPRINT *aFootprint)
 Add the given footprint to the board. More...
 
wxString SelectFootprintFromLibBrowser ()
 Launch the footprint viewer to select the name of a footprint to load. More...
 
void Compile_Ratsnest (bool aDisplayStatus)
 Create the entire board ratsnest. More...
 
PCB_LAYER_ID SelectLayer (PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
 Show the dialog box for layer selection. More...
 
virtual PCB_LAYER_ID GetActiveLayer () const
 
SEVERITY GetSeverity (int aErrorCode) const override
 
PCBNEW_SETTINGSGetPcbNewSettings () const
 
FOOTPRINT_EDITOR_SETTINGSGetFootprintEditorSettings () const
 
virtual MAGNETIC_SETTINGSGetMagneticItemsSettings ()
 
void DisplayGridMsg () override
 Display the current grid pane on the status bar. More...
 
PCB_DRAW_PANEL_GALGetCanvas () const override
 Return a pointer to GAL-based canvas of given EDA draw frame. More...
 
virtual void SetAutoZoom (bool aAutoZoom)
 Does nothing. More...
 
virtual bool GetAutoZoom ()
 Always returns false. More...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
wxFindReplaceData & GetFindReplaceData ()
 
wxArrayString & GetFindHistoryList ()
 
bool GetShowPolarCoords () const
 For those frames that support polar coordinates. More...
 
void SetShowPolarCoords (bool aShow)
 
void ToggleUserUnits () override
 
void GetUnitPair (EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
 Get the pair or units in current use. More...
 
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)
 
bool LibraryFileBrowser (bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
 
virtual wxString GetScreenDesc () const
 
void EraseMsgBox ()
 
bool IsGridVisible () const
 
void OnSelectGrid (wxCommandEvent &event)
 Command event handler for selecting grid sizes. More...
 
void OnGridSettings (wxCommandEvent &event)
 
void UpdateGridSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.). More...
 
void OnUpdateSelectGrid (wxUpdateUIEvent &aEvent)
 Update the checked item in the grid combobox. More...
 
void UpdateZoomSelectBox ()
 Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes, etc.) More...
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 Update the checked item in the zoom combobox. More...
 
const wxString GetZoomLevelIndicator () const
 Return a human readable value for display in dialogs. More...
 
virtual void OnSelectZoom (wxCommandEvent &event)
 Set the zoom factor when selected by the zoom list box in the main tool bar. More...
 
virtual void OnSize (wxSizeEvent &event)
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
virtual void HardRedraw ()
 Rebuild the GAL and redraws the screen. More...
 
virtual void Zoom_Automatique (bool aWarpPointer)
 Redraw the screen with best zoom level and the best centering that shows all the page or the board. More...
 
void FocusOnLocation (const wxPoint &aPos)
 Useful to focus on a particular location, in find functions. More...
 
void AddStandardSubMenus (TOOL_MENU &aMenu)
 Construct a "basic" menu for a tool, containing only items that apply to all tools (e.g. More...
 
void PrintWorkSheet (const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 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 in the status bar. More...
 
void CreateServer (int service, bool local=true)
 
void OnSockRequest (wxSocketEvent &evt)
 
void OnSockRequestServer (wxSocketEvent &evt)
 
void AppendMsgPanel (const wxString &aTextUpper, const wxString &aTextLower, int aPadding=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)
 
void SetMsgPanel (const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
 Helper function that erases the msg panel and then appends a single message. More...
 
virtual void UpdateMsgPanel ()
 Redraw the message panel. More...
 
virtual void PrintPage (const RENDER_SETTINGS *aSettings)
 Print the page pointed by current screen, set by the calling print function. More...
 
void SetCanvas (EDA_DRAW_PANEL_GAL *aPanel)
 
wxWindow * GetToolCanvas () const override
 Canvas access. More...
 
KIGFX::GAL_DISPLAY_OPTIONSGetGalDisplayOptions ()
 Return a reference to the gal rendering options used by GAL for rendering. More...
 
void RefreshCanvas () override
 
void RecreateToolbars ()
 Rebuild all toolbars, and update the checked state of check tools. More...
 
virtual void ParseArgs (wxCmdLineParser &aParser)
 Handle command-line arguments in a frame-specific way. More...
 
virtual bool ShowModal (wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
 Show 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 () const override
 Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame. More...
 
void SetModal (bool aIsModal)
 
bool IsDismissed ()
 
void DismissModal (bool aRetVal, const wxString &aResult=wxEmptyString)
 
EDA_UNITS GetUserUnits () const
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS aUnits)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
SETTINGS_MANAGERGetSettingsManager () const
 
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 OnMenuEvent (wxMenuEvent &event)
 The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
virtual void RegisterUIUpdateHandler (int aID, const ACTION_CONDITIONS &aConditions) override
 Register a UI update handler for the control with ID aID. More...
 
virtual void RegisterUIUpdateHandler (const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
 Register an action's update conditions with the UI layer to allow the UI to appropriately display the state of its controls. More...
 
virtual void UnregisterUIUpdateHandler (int aID) override
 Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler. More...
 
virtual void UnregisterUIUpdateHandler (const TOOL_ACTION &aAction)
 Unregister a UI handler for an action that was registered using RegisterUIUpdateHandler. More...
 
void OnMaximize (wxMaximizeEvent &aEvent)
 
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)
 
void CreateInfoBar ()
 
void FinishAUIInitialization ()
 
WX_INFOBARGetInfoBar ()
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left of the infobar, and an optional closebox to the right. More...
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton, std::function< void(void)> aCallback)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left of the infobar, and an optional closebox to the right. More...
 
void ShowInfoBarWarning (const wxString &aWarningMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left of the infobar. More...
 
void ShowInfoBarMsg (const wxString &aMsg, bool aShowCloseButton=false)
 Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of the infobar. More...
 
virtual APP_SETTINGS_BASEconfig () const
 Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
void LoadWindowState (const wxString &aFileName)
 
virtual void LoadWindowState (const WINDOW_STATE &aState)
 Load frame state info from a configuration file. More...
 
void LoadWindowSettings (const WINDOW_SETTINGS *aCfg)
 Load window settings from the given settings object. More...
 
void SaveWindowSettings (WINDOW_SETTINGS *aCfg)
 Save window settings to the given settings object. More...
 
virtual WINDOW_SETTINGSGetWindowSettings (APP_SETTINGS_BASE *aCfg)
 Return a pointer to the window settings for this frame. More...
 
wxString ConfigBaseName () override
 Get the configuration base name. More...
 
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=nullptr)
 Fetches the file name from the file history list. More...
 
void ClearFileHistory (FILE_HISTORY *aFileHistory=nullptr)
 Removes all files from the file history. More...
 
void UpdateFileHistory (const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
 Update the list of recently opened files. More...
 
FILE_HISTORYGetFileHistory ()
 Get the frame's main file history. 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
 
wxSize GetWindowSize ()
 Get the undecorated window size that can be used for restoring the window size. More...
 
virtual void ClearUndoRedoList ()
 Clear the undo and redo list using ClearUndoORRedoList() More...
 
virtual void PushCommandToUndoList (PICKED_ITEMS_LIST *aItem)
 Add a command to undo in the undo list. More...
 
virtual void PushCommandToRedoList (PICKED_ITEMS_LIST *aItem)
 Add a command to redo in the redo list. More...
 
virtual PICKED_ITEMS_LISTPopCommandFromUndoList ()
 Return the last command to undo and remove it from list, nothing is deleted. More...
 
virtual PICKED_ITEMS_LISTPopCommandFromRedoList ()
 Return the last command to undo and remove it from list, nothing is deleted. More...
 
virtual int GetUndoCommandCount () const
 
virtual int GetRedoCommandCount () const
 
int GetMaxUndoItems () const
 
bool NonUserClose (bool aForce)
 
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
 Indicate that hotkeys should perform an immediate action even if another tool is currently active. More...
 
MOUSE_DRAG_ACTION GetDragAction () const
 Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects. More...
 
bool GetMoveWarpsCursor () const
 Indicate that a move operation should warp the mouse pointer to the origin of the move object. More...
 
HOLDER_TYPE GetType () const
 
KIWAYKiway () const
 Return a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Return a reference to the PROJECT associated with this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 It is only used for debugging, since "this" is not a wxWindow*. More...
 

Static Public Member Functions

static void HandleUpdateUIEvent (wxUpdateUIEvent &aEvent, EDA_BASE_FRAME *aFrame, ACTION_CONDITIONS aCond)
 Handle events generated when the UI is trying to figure out the current state of the UI controls related to TOOL_ACTIONS (e.g. More...
 

Public Attributes

PCB_LAYER_BOX_SELECTORm_SelLayerBox
 
wxChoice * m_SelTrackWidthBox
 
wxChoice * m_SelViaSizeBox
 
bool m_show_layer_manager_tools
 
bool m_ZoneFillsDirty
 

Protected Member Functions

void setupTools ()
 
void setupUIConditions () override
 Setup the UI conditions for the various actions and their controls in this frame. More...
 
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...
 
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...
 
bool canCloseWindow (wxCloseEvent &aCloseEvent) override
 
void doCloseWindow () override
 
 PCB_EDIT_FRAME (KIWAY *aKiway, wxWindow *aParent)
 
void onSize (wxSizeEvent &aEvent)
 
int inferLegacyEdgeClearance (BOARD *aBoard)
 
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...
 
FOOTPRINTloadFootprint (const LIB_ID &aFootprintId)
 Attempts to load aFootprintId from the footprint library table. More...
 
virtual void SetScreen (BASE_SCREEN *aScreen)
 
void setupUnits (APP_SETTINGS_BASE *aCfg)
 
void resolveCanvasType ()
 Determines the Canvas type to load (with prompt if required) and initializes m_canvasType. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting ()
 Returns the canvas type stored in the application settings. More...
 
bool saveCanvasTypeSetting (EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
 Stores the canvas type in the application settings. More...
 
void initExitKey ()
 Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id. More...
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 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

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...
 
PANEL_SELECTION_FILTERm_selectionFilterPanel
 AUI panel for changing the selection tool filter controls. More...
 
APPEARANCE_CONTROLSm_appearancePanel
 AUI panel for controlling layer and object visibility and appearance. More...
 
BOARDm_pcb
 
PCB_DISPLAY_OPTIONS m_displayOptions
 
PCB_ORIGIN_TRANSFORMS m_originTransforms
 
PCBNEW_SETTINGSm_settings
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 
bool m_showPageLimits
 
COLOR4D m_gridColor
 
COLOR4D m_drawBgColor
 
int m_undoRedoCountMax
 
bool m_polarCoords
 
bool m_showBorderAndTitleBlock
 
long m_firstRunDialogSetting
 
wxChoice * m_gridSelectBox
 
wxChoice * m_zoomSelectBox
 
ACTION_TOOLBARm_mainToolBar
 
ACTION_TOOLBARm_auxiliaryToolBar
 
ACTION_TOOLBARm_drawToolBar
 
ACTION_TOOLBARm_optionsToolBar
 
wxFindReplaceData * m_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_msgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 The current canvas type. More...
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 < Points to nested event_loop. NULL means not modal and dismissed. More...
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
FRAME_T m_ident
 
wxPoint m_framePos
 
wxSize m_frameSize
 
bool m_maximizeByDefault
 
wxPoint m_normalFramePos
 
wxSize m_normalFrameSize
 
wxString m_aboutTitle
 
wxAuiManager m_auimgr
 
wxString m_perspective
 
WX_INFOBARm_infoBar
 
wxString m_configName
 
SETTINGS_MANAGERm_settingsManager
 
FILE_HISTORYm_fileHistory
 
bool m_hasAutoSave
 
bool m_autoSaveState
 
int m_autoSaveInterval
 
wxTimer * m_autoSaveTimer
 
UNDO_REDO_CONTAINER m_undoList
 
UNDO_REDO_CONTAINER m_redoList
 
wxString m_mruPath
 
EDA_UNITS m_userUnits
 Map containing the UI update handlers registered with wx for each action. More...
 
std::map< int, UIUpdateHandlerm_uiUpdateMap
 Set by the close window event handler after frames are asked if they can close. More...
 
bool m_isClosing
 Set by NonUserClose() to indicate that the user did not request the current close. More...
 
bool m_isNonUserClose
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
TOOL_DISPATCHERm_toolDispatcher
 
SELECTION m_dummySelection
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
MOUSE_DRAG_ACTION m_dragAction
 
bool m_moveWarpsCursor
 

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

Friends

struct PCB::IFACE
 
class APPEARANCE_CONTROLS
 

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 74 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 788 of file pcb_edit_frame.h.

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 

Definition at line 42 of file kiway_holder.h.

◆ UNDO_REDO_LIST

Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if needed.

Because picked items must be deleted only if they are not in use, this is a virtual pure function that must be created for SCH_SCREEN and PCB_SCREEN. Commands are deleted from the older to the last.

Parameters
aList= the UNDO_REDO_CONTAINER of commands.
aItemCountnumber of old commands to delete. -1 to remove all old commands this will empty the list of commands.
Enumerator
UNDO_LIST 
REDO_LIST 

Definition at line 519 of file eda_base_frame.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 367 of file pcb_edit_frame.cpp.

368 {
369  // Close modeless dialogs
370  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
371 
372  if( open_dlg )
373  open_dlg->Close( true );
374 
375  // Shutdown all running tools
376  if( m_toolManager )
378 
379  if( GetBoard() )
381 
382  delete m_selectionFilterPanel;
383  delete m_appearancePanel;
384 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
APPEARANCE_CONTROLS * m_appearancePanel
AUI panel for controlling layer and object visibility and appearance.
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1952
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
PANEL_SELECTION_FILTER * m_selectionFilterPanel
AUI panel for changing the selection tool filter controls.
BOARD * GetBoard() const

References DIALOG_DRC_WINDOW_NAME, GetBoard(), and BOARD::RemoveListener().

Member Function Documentation

◆ ActivateGalCanvas()

void PCB_EDIT_FRAME::ActivateGalCanvas ( )
overridevirtual

Reimplemented from PCB_BASE_EDIT_FRAME.

Definition at line 870 of file pcb_edit_frame.cpp.

871 {
873  GetCanvas()->UpdateColors();
874  GetCanvas()->Refresh();
875 }
void ActivateGalCanvas() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void UpdateColors()
Updates the color settings in the painter and GAL.

References PCB_BASE_EDIT_FRAME::ActivateGalCanvas().

Referenced by Refresh().

◆ AddFootprintToBoard()

void PCB_BASE_FRAME::AddFootprintToBoard ( FOOTPRINT aFootprint)
virtualinherited

Add the given footprint to the board.

Parameters
aDCis the current Device Context, to draw the new footprint (can be NULL ).

Reimplemented in FOOTPRINT_EDIT_FRAME.

Definition at line 157 of file pcb_base_frame.cpp.

158 {
159  if( aFootprint )
160  {
161  GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
162 
163  aFootprint->SetFlags(IS_NEW );
164  aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
165 
166  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
167  // built from a board)
168  if( aFootprint->IsFlipped() )
169  aFootprint->Flip( aFootprint->GetPosition(), m_settings->m_FlipLeftRight );
170 
171  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
172  // it might be stored in another orientation if the lib is an archive built from a board)
173  aFootprint->SetOrientation( 0 );
174  }
175 }
PCBNEW_SETTINGS * m_settings
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:201
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1462
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1297
bool IsFlipped() const
function IsFlipped
Definition: footprint.h:282
wxPoint GetPosition() const override
Definition: footprint.h:200
BOARD * GetBoard() const
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1362
#define IS_NEW
New item, just created.
Definition: eda_item.h:106

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

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard().

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

465 {
466  wxFileName fn( aFilename );
467 
468  if( aFilename.IsEmpty() )
469  {
470  if( !LibraryFileBrowser( true, fn,
472  true ) )
473  {
474  return false;
475  }
476  }
477 
478  wxString libPath = fn.GetFullPath();
479  wxString libName = fn.GetName();
480 
481  if( libName.IsEmpty() )
482  return false;
483 
484  bool saveInGlobalTable = false;
485  bool saveInProjectTable = false;
486 
487  if( Prj().IsNullProject() )
488  {
489  saveInGlobalTable = true;
490  }
491  else
492  {
493  wxArrayString libTableNames;
494 
495  libTableNames.Add( _( "Global" ) );
496  libTableNames.Add( _( "Project" ) );
497 
498  switch( SelectSingleOption( this, _( "Select Library Table" ),
499  _( "Choose the Library Table to add the library to:" ), libTableNames ) )
500  {
501  case 0: saveInGlobalTable = true; break;
502  case 1: saveInProjectTable = true; break;
503  default: return false;
504  }
505  }
506 
507  wxString type = IO_MGR::ShowType( IO_MGR::GuessPluginTypeFromLibPath( libPath ) );
508 
509  // try to use path normalized to an environmental variable or project path
510  wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
511 
512  if( normalizedPath.IsEmpty() )
513  normalizedPath = libPath;
514 
515  try
516  {
517  if( saveInGlobalTable )
518  {
519  auto row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
520  GFootprintTable.InsertRow( row );
522  }
523  else if( saveInProjectTable )
524  {
525  auto row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
526  Prj().PcbFootprintLibs()->InsertRow( row );
527  Prj().PcbFootprintLibs()->Save( Prj().FootprintLibTblName() );
528  }
529  }
530  catch( const IO_ERROR& ioe )
531  {
532  DisplayError( this, ioe.What() );
533  return false;
534  }
535 
536  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
537 
538  if( editor )
539  {
540  LIB_ID libID( libName, wxEmptyString );
541  editor->SyncLibraryTree( true );
542  editor->FocusOnLibID( libID );
543  }
544 
545  auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
546 
547  if( viewer )
548  viewer->ReCreateLibraryList();
549 
550  return true;
551 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
FP_LIB_TABLE GFootprintTable
!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.
Definition: cvpcb.cpp:120
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
Component library viewer main window.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
static const wxString ShowType(PCB_FILE_T aFileType)
Return 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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
static PCB_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath)
Return a plugin type given a footprint library's libPath.
Definition: io_mgr.cpp:124
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
wxString KiCadFootprintLibPathWildcard()
#define _(s)
Definition: 3d_actions.cpp:33
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
int SelectSingleOption(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
Displays a dialog with radioboxes asking the user to select an option.
Definition: confirm.cpp:307
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
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()

References _, DisplayError(), FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_VIEWER, FP_LIB_TABLE::GetGlobalTableFileName(), GFootprintTable, IO_MGR::GuessPluginTypeFromLibPath(), LIB_TABLE::InsertRow(), PROJECT::IsNullProject(), 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().

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 388 of file eda_base_frame.cpp.

389 {
390  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
391  ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
392 
393  helpMenu->Add( ACTIONS::help );
394  helpMenu->Add( ACTIONS::gettingStarted );
395  helpMenu->Add( ACTIONS::listHotKeys );
396  helpMenu->Add( ACTIONS::getInvolved );
397  helpMenu->Add( ACTIONS::reportBug );
398 
399  helpMenu->AppendSeparator();
400  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
401 
402  aMenuBar->Append( helpMenu, _( "&Help" ) );
403 }
static TOOL_ACTION listHotKeys
Definition: actions.h:182
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:45
static TOOL_ACTION reportBug
Definition: actions.h:184
const BITMAP_OPAQUE about_xpm[1]
Definition: about.cpp:40
Handle actions that are shared between different applications.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION help
Definition: actions.h:181
static TOOL_ACTION getInvolved
Definition: actions.h:183
static TOOL_ACTION gettingStarted
Definition: actions.h:180

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

Referenced by EDA_3D_VIEWER::CreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), and ReCreateMenuBar().

◆ AddStandardSubMenus()

void EDA_DRAW_FRAME::AddStandardSubMenus ( TOOL_MENU aMenu)
inherited

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

zoom and grid).

Definition at line 437 of file eda_draw_frame.cpp.

438 {
439  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
440  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
441 
442  aMenu.AddSeparator( 1000 );
443 
444  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
445  zoomMenu->SetTool( commonTools );
446  aToolMenu.AddSubMenu( zoomMenu );
447 
448  auto gridMenu = std::make_shared<GRID_MENU>( this );
449  gridMenu->SetTool( commonTools );
450  aToolMenu.AddSubMenu( gridMenu );
451 
452  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
453  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
454 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
Handles action that are shared between different applications.
Definition: common_tools.h:37
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157

References CONDITIONAL_MENU::AddSeparator(), TOOL_MENU::AddSubMenu(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::m_toolManager, and SELECTION_CONDITIONS::ShowAlways().

Referenced by ROUTER_TOOL::Init(), PICKER_TOOL::Init(), PL_EDIT_TOOL::Init(), PCB_VIEWER_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), and PCB_SELECTION_TOOL::Init().

◆ AppendMsgPanel()

void EDA_DRAW_FRAME::AppendMsgPanel ( const wxString &  aTextUpper,
const wxString &  aTextLower,
int  aPadding = 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
aTextUpperThe message upper text.
aTextLowerThe message lower text.
aPaddingNumber of spaces to pad between messages.

Definition at line 597 of file eda_draw_frame.cpp.

599 {
600  if( m_messagePanel )
601  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
602 }
EDA_MSG_PANEL * m_messagePanel
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Function AppendMessage appends a message to the message panel.
Definition: msgpanel.cpp:118

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

Referenced by GERBER_FILE_IMAGE::DisplayImageInfo(), SYMBOL_EDIT_FRAME::DisplaySymbolDatasheet(), and SYMBOL_VIEWER_FRAME::updatePreviewSymbol().

◆ canCloseWindow()

bool PCB_EDIT_FRAME::canCloseWindow ( wxCloseEvent &  aCloseEvent)
overrideprotectedvirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 778 of file pcb_edit_frame.cpp.

779 {
780  // Shutdown blocks must be determined and vetoed as early as possible
781  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
782  && IsContentModified() )
783  {
784  return false;
785  }
786 
787  if( IsContentModified() )
788  {
789  wxFileName fileName = GetBoard()->GetFileName();
790  wxString msg = _( "Save changes to \"%s\" before closing?" );
791 
792  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
793  [&]() -> bool
794  {
796  } ) )
797  {
798  return false;
799  }
800  }
801 
802  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
803  // board.
804  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
805 
806  if( open_dlg )
807  open_dlg->Close( true );
808 
809  return true;
810 }
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:208
const wxString & GetFileName() const
Definition: board.h:281
bool IsContentModified() override
Get if the current board has been modified but not saved.
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:40
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
bool Files_io_from_id(int aId)
Function Files_io_from_id Read and write board files.
BOARD * GetBoard() const

References _, DIALOG_DRC_WINDOW_NAME, Format(), GetBoard(), BOARD::GetFileName(), HandleUnsavedChanges(), ID_SAVE_BOARD, and KIPLATFORM::APP::SupportsShutdownBlockReason().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1025 of file eda_base_frame.cpp.

1026 {
1027  SetUserUnits( aUnits );
1029 
1030  wxCommandEvent e( UNITS_CHANGED );
1031  ProcessEventLocally( e );
1032 }
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::SwitchUnits(), 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 923 of file eda_base_frame.cpp.

924 {
925  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
926 
927  wxFileName autoSaveFileName = aFileName;
928 
929  // Check for auto save file.
930  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
931 
932  wxLogTrace( traceAutoSave,
933  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
934 
935  if( !autoSaveFileName.FileExists() )
936  return;
937 
938  wxString msg = wxString::Format( _(
939  "Well this is potentially embarrassing!\n"
940  "It appears that the last time you were editing the file\n"
941  "\"%s\"\n"
942  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
943  aFileName.GetFullName()
944  );
945 
946  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
947 
948  // Make a backup of the current file, delete the file, and rename the auto save file to
949  // the file name.
950  if( response == wxYES )
951  {
952  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
953  {
954  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
955  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
956  }
957  }
958  else
959  {
960  wxLogTrace( traceAutoSave,
961  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
962 
963  // Remove the auto save file when using the previous file as is.
964  wxRemoveFile( autoSaveFileName.GetFullPath() );
965  }
966 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static wxString GetAutoSaveFilePrefix()
#define _(s)
Definition: 3d_actions.cpp:33

References _, Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), 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 42 of file initpcb.cpp.

43 {
44  if( GetBoard() == NULL )
45  return false;
46 
47  if( aQuery && !GetBoard()->IsEmpty() )
48  {
49  if( !IsOK( this,
50  _( "Current Board will be lost and this operation cannot be undone. Continue?" ) ) )
51  return false;
52  }
53 
54  // Release the lock file, if exists
55  ReleaseFile();
56 
57  // Clear undo and redo lists because we want a full deletion
59  GetScreen()->ClrModify();
60 
61  if( !aFinal )
62  {
63  // delete the old BOARD and create a new BOARD so that the default
64  // layer names are put into the BOARD.
65  SetBoard( new BOARD() );
66 
67  // clear filename, to avoid overwriting an old file
68  GetBoard()->SetFileName( wxEmptyString );
69 
71 
73 
74  // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
75  GetBoard()->SetEnabledLayers( LSET().set() );
76 
77  // Default copper layers count set to 2: double layer board
79 
80  // Update display (some options depend on the board setup)
81  GetBoard()->SetVisibleLayers( LSET().set() );
85  UpdateTitle();
86 
87  Zoom_Automatique( false );
88  }
89 
90  return true;
91 }
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
APPEARANCE_CONTROLS * m_appearancePanel
AUI panel for controlling layer and object visibility and appearance.
void SetCopperLayerCount(int aCount)
Definition: board.cpp:441
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.
void OnBoardChanged()
Updates the panel contents from the application and board models
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:48
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()
Reset all high light data to the init state.
Definition: board.cpp:1976
#define NULL
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:473
void SetFileName(const wxString &aFileName)
Definition: board.h:279
void SetBoard(BOARD *aBoard) override
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:189
#define _(s)
Definition: 3d_actions.cpp:33
void ClrModify()
Definition: base_screen.h:60
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 IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:297
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
Definition: board.cpp:467
void ReCreateAuxiliaryToolbar() override

References _, EDA_BASE_FRAME::ClearUndoRedoList(), BASE_SCREEN::ClrModify(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetPageSizeIU(), PCB_BASE_FRAME::GetScreen(), BASE_SCREEN::InitDataPoints(), IsOK(), PCB_BASE_EDIT_FRAME::m_appearancePanel, NULL, APPEARANCE_CONTROLS::OnBoardChanged(), ReCreateAuxiliaryToolbar(), ReCreateLayerBox(), EDA_DRAW_FRAME::ReleaseFile(), BOARD::ResetNetHighLight(), SetBoard(), BOARD::SetCopperLayerCount(), BOARD::SetEnabledLayers(), BOARD::SetFileName(), BOARD::SetVisibleLayers(), UpdateTitle(), and EDA_DRAW_FRAME::Zoom_Automatique().

Referenced by Files_io_from_id(), and OpenProjectFiles().

◆ ClearFileHistory()

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

Removes all files from the file history.

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

Definition at line 820 of file eda_base_frame.cpp.

821 {
822  if( !aFileHistory )
823  aFileHistory = m_fileHistory;
824 
825  wxASSERT( aFileHistory );
826 
827  aFileHistory->ClearFileHistory();
828 
829  // Update the menubar to update the file history menu
830  if( GetMenuBar() )
831  {
832  ReCreateMenuBar();
833  GetMenuBar()->Refresh();
834  }
835 }
void ClearFileHistory()
Clear all entries from the file history.
FILE_HISTORY * m_fileHistory
virtual void ReCreateMenuBar()
Recreates the menu bar.

References FILE_HISTORY::ClearFileHistory(), EDA_BASE_FRAME::m_fileHistory, and EDA_BASE_FRAME::ReCreateMenuBar().

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

◆ ClearMsgPanel()

◆ ClearUndoORRedoList()

void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList ( UNDO_REDO_LIST  whichList,
int  aItemCount = -1 
)
overridevirtualinherited

Function ClearUndoORRedoList free the undo or redo list from List element Wrappers are deleted.

datas pointed by wrappers are deleted if not in use in schematic i.e. when they are copy of a schematic item or they are no more in use (DELETED)

Parameters
whichList= the UNDO_REDO_CONTAINER to clear
aItemCount= the count of items to remove. < 0 for all items items are removed from the beginning of the list. So this function can be called to remove old commands

Reimplemented from EDA_BASE_FRAME.

Definition at line 604 of file undo_redo.cpp.

605 {
606  if( aItemCount == 0 )
607  return;
608 
609  UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
610  unsigned icnt = list.m_CommandsList.size();
611 
612  if( aItemCount > 0 )
613  icnt = aItemCount;
614 
615  for( unsigned ii = 0; ii < icnt; ii++ )
616  {
617  if( list.m_CommandsList.size() == 0 )
618  break;
619 
620  PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
621  list.m_CommandsList.erase( list.m_CommandsList.begin() );
622 
623  curr_cmd->ClearListAndDeleteItems();
624  delete curr_cmd; // Delete command
625  }
626 }
UNDO_REDO_CONTAINER m_undoList
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
A holder to handle information on schematic or board items.
UNDO_REDO_CONTAINER m_redoList
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...

References PICKED_ITEMS_LIST::ClearListAndDeleteItems(), and UNDO_REDO_CONTAINER::m_CommandsList.

◆ ClearUndoRedoList()

◆ CommonSettingsChanged()

void PCB_EDIT_FRAME::CommonSettingsChanged ( bool  aEnvVarsChanged,
bool  aTextVarsChanged 
)
overridevirtual

Called after the preferences dialog is run.

Reimplemented from PCB_BASE_FRAME.

Definition at line 1636 of file pcb_edit_frame.cpp.

1637 {
1638  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1639 
1641 
1642  // Netclass definitions could have changed, either by us or by Eeschema
1643  DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1644  WX_INFOBAR* infobar = GetInfoBar();
1645 
1646  try
1647  {
1648  drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1649  infobar->Hide();
1650  }
1651  catch( PARSE_ERROR& pe )
1652  {
1653  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
1654  wxEmptyString );
1655 
1656  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1657  [&]( wxHyperlinkEvent& aEvent )
1658  {
1659  ShowBoardSetupDialog( _( "Custom Rules" ) );
1660  } ) );
1661 
1662  infobar->RemoveAllButtons();
1663  infobar->AddButton( button );
1664  infobar->AddCloseButton();
1665  infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR );
1666  }
1667 
1668  // Update the environment variables in the Python interpreter
1669  if( aEnvVarsChanged )
1671 
1672  Layout();
1673  SendSizeEvent();
1674 }
wxString GetDesignRulesPath()
Returns the absolute path to the design rules file for the currently-loaded board.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
Function ShowBoardSetupDialog.
void PythonSyncEnvironmentVariables()
Synchronize the environment variables from KiCad's environment into the Python interpreter.
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition: drc_tool.h:113
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
#define _(s)
Definition: 3d_actions.cpp:33
WX_INFOBAR * GetInfoBar()
APPEARANCE_CONTROLS * GetAppearancePanel()
void OnColorThemeChanged()
Updates the colors on all the widgets from the new chosen color theme

References _, PCB_BASE_FRAME::CommonSettingsChanged(), and DRC_TOOL::GetDRCEngine().

◆ Compile_Ratsnest()

void PCB_BASE_FRAME::Compile_Ratsnest ( bool  aDisplayStatus)
inherited

Create the entire board ratsnest.

Function Compile_Ratsnest Create the entire board ratsnest.

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

Parameters
aDCis the current device context (can be NULL).
aDisplayStatusif true, display the computation results.

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 41 of file ratsnest.cpp.

42 {
43  GetBoard()->GetConnectivity()->RecalculateRatsnest();
44 
45  if( aDisplayStatus )
46  {
47  SetMsgPanel( m_pcb );
48  }
49 }
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:397
BOARD * GetBoard() const

References PCB_BASE_FRAME::GetBoard(), BOARD::GetConnectivity(), PCB_BASE_FRAME::m_pcb, and EDA_DRAW_FRAME::SetMsgPanel().

Referenced by DIALOG_GLOBAL_DELETION::acceptPcbDelete(), DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), ExportToGenCAD(), DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked(), OpenProjectFiles(), PCB_CONTROL::Paste(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ config()

APP_SETTINGS_BASE * EDA_BASE_FRAME::config ( ) const
virtualinherited

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

Reimplemented in KICAD_MANAGER_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 661 of file eda_base_frame.cpp.

662 {
663  // KICAD_MANAGER_FRAME overrides this
664  return Kiface().KifaceSettings();
665 }
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:92
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.

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

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::ActivateGalCanvas(), BM2CMP_FRAME::BM2CMP_FRAME(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS(), FOOTPRINT_WIZARD_FRAME::doCloseWindow(), SIM_PLOT_FRAME::doCloseWindow(), SCH_BASE_FRAME::eeconfig(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), DISPLAY_FOOTPRINTS_FRAME::GetAutoZoom(), GRID_MENU::GRID_MENU(), COMMON_TOOLS::GridFast1(), COMMON_TOOLS::GridFast2(), EDA_DRAW_FRAME::IsGridVisible(), SCH_BASE_FRAME::libeditconfig(), EDA_DRAW_FRAME::OnUpdateSelectGrid(), EDA_DRAW_FRAME::OnUpdateSelectZoom(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), EDA_DRAW_FRAME::resolveCanvasType(), DISPLAY_FOOTPRINTS_FRAME::SetAutoZoom(), PCB_BASE_EDIT_FRAME::SetBoard(), EDA_DRAW_FRAME::SetGridVisibility(), PL_EDITOR_FRAME::setupTools(), SYMBOL_VIEWER_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), SYMBOL_EDIT_FRAME::setupTools(), CVPCB_MAINFRAME::setupTools(), SCH_EDIT_FRAME::setupTools(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), ZOOM_MENU::update(), GRID_MENU::update(), EDA_DRAW_FRAME::UpdateGridSelectBox(), EDA_DRAW_FRAME::UpdateZoomSelectBox(), EDA_BASE_FRAME::windowClosing(), ZOOM_MENU::ZOOM_MENU(), and BM2CMP_FRAME::~BM2CMP_FRAME().

◆ ConfigBaseName()

wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineoverridevirtualinherited

Get the configuration base name.

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 configuration can be used.

Returns
a base name prefix used in Load/Save settings to build the full name of keys used in configuration.

Reimplemented from TOOLS_HOLDER.

Definition at line 338 of file eda_base_frame.h.

339  {
340  wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
341  return baseCfgName;
342  }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

Referenced by EDA_BASE_FRAME::SaveWindowSettings().

◆ 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 brought to the foreground.

Definition at line 416 of file pcb_base_frame.cpp.

417 {
418  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
419 
420  if( !draw3DFrame )
421  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
422 
423  // Raising the window does not show the window on Windows if iconized. This should work
424  // on any platform.
425  if( draw3DFrame->IsIconized() )
426  draw3DFrame->Iconize( false );
427 
428  draw3DFrame->Raise();
429  draw3DFrame->Show( true );
430 
431  // Raising the window does not set the focus on Linux. This should work on any platform.
432  if( wxWindow::FindFocus() != draw3DFrame )
433  draw3DFrame->SetFocus();
434 
435  return draw3DFrame;
436 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
#define _(s)
Definition: 3d_actions.cpp:33
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:65
EDA_3D_VIEWER * Get3DViewerFrame()

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

Referenced by PCB_VIEWER_TOOLS::Show3DViewer().

◆ CreateInfoBar()

void EDA_BASE_FRAME::CreateInfoBar ( )
inherited

Definition at line 686 of file eda_base_frame.cpp.

687 {
688 #if defined( __WXOSX_MAC__ )
690 #else
691  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
692 
693  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
694 #endif
695 }
wxAuiManager m_auimgr
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
Specialization of the wxAuiPaneInfo class for KiCad panels.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
WX_INFOBAR * m_infoBar

References TOOLS_HOLDER::GetToolCanvas(), EDA_BASE_FRAME::m_auimgr, and EDA_BASE_FRAME::m_infoBar.

◆ CreateNewFootprint()

FOOTPRINT * PCB_BASE_FRAME::CreateNewFootprint ( const wxString &  aFootprintName)
inherited

Creates a new footprint, at position 0,0.

The new footprint 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 footprint is placed on a board and a netlist is read.
Parameters
aFootprintNameis the name of the new footprint in library.

Definition at line 1018 of file footprint_libraries_utils.cpp.

1019 {
1020  wxString footprintName = aFootprintName;
1021 
1022  // Ask for the new footprint name
1023  if( footprintName.IsEmpty() )
1024  {
1025  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
1026  footprintName );
1027  dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &footprintName ) );
1028 
1029  if( dlg.ShowModal() != wxID_OK )
1030  return nullptr; //Aborted by user
1031  }
1032 
1033  footprintName.Trim( true );
1034  footprintName.Trim( false );
1035 
1036  if( footprintName.IsEmpty() )
1037  {
1038  DisplayInfoMessage( this, _( "No footprint name defined." ) );
1039  return nullptr;
1040  }
1041 
1042  // Creates the new footprint and add it to the head of the linked list of footprints
1043  FOOTPRINT* footprint = new FOOTPRINT( GetBoard() );
1044 
1045  // Update parameters: timestamp ...
1046  footprint->SetLastEditTime();
1047 
1048  // Update its name in lib
1049  footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
1050 
1051  PCB_LAYER_ID txt_layer;
1052  wxPoint default_pos;
1054 
1055  footprint->Reference().SetText( settings.m_DefaultFPTextItems[0].m_Text );
1056  footprint->Reference().SetVisible( settings.m_DefaultFPTextItems[0].m_Visible );
1057  txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[0].m_Layer;
1058  footprint->Reference().SetLayer( txt_layer );
1059  default_pos.y -= settings.GetTextSize( txt_layer ).y / 2;
1060  footprint->Reference().SetPosition( default_pos );
1061  default_pos.y += settings.GetTextSize( txt_layer ).y;
1062 
1063  footprint->Value().SetText( settings.m_DefaultFPTextItems[1].m_Text );
1064  footprint->Value().SetVisible( settings.m_DefaultFPTextItems[1].m_Visible );
1065  txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[1].m_Layer;
1066  footprint->Value().SetLayer( txt_layer );
1067  default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
1068  footprint->Value().SetPosition( default_pos );
1069  default_pos.y += settings.GetTextSize( txt_layer ).y;
1070 
1071  for( size_t i = 2; i < settings.m_DefaultFPTextItems.size(); ++i )
1072  {
1073  FP_TEXT* textItem = new FP_TEXT( footprint );
1074  textItem->SetText( settings.m_DefaultFPTextItems[i].m_Text );
1075  textItem->SetVisible( settings.m_DefaultFPTextItems[i].m_Visible );
1076  txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[i].m_Layer;
1077  textItem->SetLayer( txt_layer );
1078  default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
1079  textItem->SetPosition( default_pos );
1080  default_pos.y += settings.GetTextSize( txt_layer ).y;
1081  footprint->GraphicalItems().push_back( textItem );
1082  }
1083 
1084  if( footprint->GetReference().IsEmpty() )
1085  footprint->SetReference( footprintName );
1086 
1087  if( footprint->GetValue().IsEmpty() )
1088  footprint->SetValue( footprintName );
1089 
1090  footprint->RunOnChildren(
1091  [&] ( BOARD_ITEM* aChild )
1092  {
1093  if( aChild->Type() == PCB_FP_TEXT_T )
1094  {
1095  FP_TEXT* textItem = static_cast<FP_TEXT*>( aChild );
1096  PCB_LAYER_ID layer = textItem->GetLayer();
1097 
1098  textItem->SetTextThickness( settings.GetTextThickness( layer ) );
1099  textItem->SetTextSize( settings.GetTextSize( layer ) );
1100  textItem->SetItalic( settings.GetTextItalic( layer ) );
1101  textItem->SetKeepUpright( settings.GetTextUpright( layer ) );
1102  }
1103  } );
1104 
1105  SetMsgPanel( footprint );
1106  return footprint;
1107 }
void SetReference(const wxString &aReference)
Function SetReference.
Definition: footprint.h:452
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
virtual void SetPosition(const wxPoint &aPos) override
Definition: fp_text.h:91
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
const wxString GetValue() const
Function GetValue.
Definition: footprint.h:467
void SetItalic(bool isItalic)
Definition: eda_text.h:186
A KICAD version of wxTextEntryDialog which supports the various improvments/work-arounds from DIALOG_...
void SetVisible(bool aVisible)
Definition: eda_text.h:192
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
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
Return the default text thickness from the layer class for the given layer.
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:482
bool GetTextUpright(PCB_LAYER_ID aLayer) const
This class provides a custom wxValidator object for limiting the allowable characters when defining f...
Definition: validators.h:63
FP_TEXT & Reference()
Definition: footprint.h:483
bool GetTextItalic(PCB_LAYER_ID aLayer) const
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
DRAWINGS & GraphicalItems()
Definition: footprint.h:185
const wxString GetReference() const
Function GetReference.
Definition: footprint.h:442
void SetValue(const wxString &aValue)
Function SetValue.
Definition: footprint.h:476
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:209
void SetKeepUpright(bool aKeepUpright)
Definition: fp_text.h:113
#define _(s)
Definition: 3d_actions.cpp:33
void SetLastEditTime(timestamp_t aTime)
Definition: footprint.h:346
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Function RunOnChildren.
Definition: footprint.cpp:1104
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:166
BOARD * GetBoard() const
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:281
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:161
Container for design settings for a BOARD object.

References _, DisplayInfoMessage(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetDesignSettings(), BOARD_ITEM::GetLayer(), FOOTPRINT::GetReference(), BOARD_DESIGN_SETTINGS::GetTextItalic(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), BOARD_DESIGN_SETTINGS::GetTextUpright(), FOOTPRINT::GetValue(), FOOTPRINT::GraphicalItems(), BOARD_DESIGN_SETTINGS::m_DefaultFPTextItems, PCB_FP_TEXT_T, FOOTPRINT::Reference(), FOOTPRINT::RunOnChildren(), FOOTPRINT::SetFPID(), EDA_TEXT::SetItalic(), FP_TEXT::SetKeepUpright(), FOOTPRINT::SetLastEditTime(), BOARD_ITEM::SetLayer(), EDA_DRAW_FRAME::SetMsgPanel(), FP_TEXT::SetPosition(), FOOTPRINT::SetReference(), EDA_TEXT::SetText(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), WX_TEXT_ENTRY_DIALOG::SetTextValidator(), FOOTPRINT::SetValue(), EDA_TEXT::SetVisible(), EDA_ITEM::Type(), and FOOTPRINT::Value().

Referenced by MICROWAVE_TOOL::createBaseFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), and FOOTPRINT_EDITOR_CONTROL::NewFootprint().

◆ CreateNewLibrary()

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

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.

Parameters
aProposedNameis the inital path and filename shown in the file chooser dialog
Returns
wxString - the newly created library path if library was successfully created, else wxEmptyString because user aborted or error.

Definition at line 371 of file footprint_libraries_utils.cpp.

373 {
374  // Kicad cannot write legacy format libraries, only .pretty new format
375  // because the legacy format cannot handle current features.
376  // The footprint library is actually a directory
377 
378  wxString initialPath = aProposedName.IsEmpty() ? Prj().GetProjectPath() : aProposedName;
379  wxFileName fn;
380  bool doAdd = false;
381 
382  if( aLibName.IsEmpty() )
383  {
384  fn = initialPath;
385 
386  if( !LibraryFileBrowser( false, fn,
388  {
389  return wxEmptyString;
390  }
391 
392  doAdd = true;
393  }
394  else
395  {
396  fn = aLibName;
397 
398  if( !fn.IsAbsolute() )
399  {
400  fn.SetName( aLibName );
401  fn.MakeAbsolute( initialPath );
402  }
403 
404  // Enforce the .pretty extension:
405  fn.SetExt( KiCadFootprintLibPathExtension );
406  }
407 
408  // We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries)
410  wxString libPath = fn.GetFullPath();
411 
412  try
413  {
414  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
415 
416  bool writable = false;
417  bool exists = false;
418 
419  try
420  {
421  writable = pi->IsFootprintLibWritable( libPath );
422  exists = true; // no exception was thrown, lib must exist.
423  }
424  catch( const IO_ERROR& )
425  { }
426 
427  if( exists )
428  {
429  if( !writable )
430  {
431  wxString msg = wxString::Format( _( "Library \"%s\" is read only." ), libPath );
432  ShowInfoBarError( msg );
433  return wxEmptyString;
434  }
435  else
436  {
437  wxString msg = wxString::Format( _( "Library %s already exists." ), libPath );
438  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
439  dlg.SetOKLabel( _( "Overwrite" ) );
440  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
441 
442  if( dlg.ShowModal() == wxID_CANCEL )
443  return wxEmptyString;
444 
445  pi->FootprintLibDelete( libPath );
446  }
447  }
448 
449  pi->FootprintLibCreate( libPath );
450  }
451  catch( const IO_ERROR& ioe )
452  {
453  DisplayError( this, ioe.What() );
454  return wxEmptyString;
455  }
456 
457  if( doAdd )
458  AddLibrary( libPath );
459 
460  return libPath;
461 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
virtual const wxString GetProjectPath() const
Return the full path of the project.
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:535
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
PROJECT & Prj() const
Return 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)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString KiCadFootprintLibPathWildcard()
#define _(s)
Definition: 3d_actions.cpp:33
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: io_mgr.cpp:58
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:52
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
const std::string KiCadFootprintLibPathExtension
S-expression Pcbnew file format.
Definition: io_mgr.h:55

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

Referenced by ExportFootprintsToLibrary().

◆ CreateServer()

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

Definition at line 48 of file eda_dde.cpp.

49 {
50  wxIPV4address addr;
51 
52  // Set the port number
53  addr.Service( service );
54 
55  // Listen on localhost only if requested
56  if( local )
57  addr.Hostname( HOSTNAME );
58 
59  delete m_socketServer;
60  m_socketServer = new wxSocketServer( addr );
61 
62  m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
63  m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
64  m_socketServer->Notify( true );
65 }
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 TOOLS_HOLDER::CurrentToolName ( ) const
inherited

Definition at line 99 of file tools_holder.cpp.

100 {
101  if( m_toolStack.empty() )
102  return ACTIONS::selectionTool.GetName();
103  else
104  return m_toolStack.back();
105 }
std::vector< std::string > m_toolStack
Definition: tools_holder.h:163
static TOOL_ACTION selectionTool
Definition: actions.h:156

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

Referenced by TOOL_MANAGER::processEvent().

◆ Destroy()

◆ DismissModal()

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

Definition at line 161 of file kiway_player.cpp.

162 {
163  m_modal_ret_val = aRetVal;
164  m_modal_string = aResult;
165 
166  if( m_modal_loop )
167  {
168  m_modal_loop->Exit();
169  m_modal_loop = 0; // this marks it as dismissed.
170  }
171 
172  Show( false );
173 }
bool m_modal_ret_val
Definition: kiway_player.h:198
wxString m_modal_string
Definition: kiway_player.h:197
WX_EVENT_LOOP * m_modal_loop
< Points to nested event_loop. NULL means not modal and dismissed.
Definition: kiway_player.h:195

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

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SYMBOL_VIEWER_FRAME::doCloseWindow(), FOOTPRINT_VIEWER_FRAME::doCloseWindow(), FOOTPRINT_WIZARD_FRAME::doCloseWindow(), FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint(), and SYMBOL_VIEWER_FRAME::FinishModal().

◆ DisplayGridMsg()

void PCB_BASE_FRAME::DisplayGridMsg ( )
overridevirtualinherited

Display the current grid pane on the status bar.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 510 of file pcb_base_frame.cpp.

511 {
512  wxString line;
513 
514  line.Printf( "grid X %s Y %s",
515  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
516  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
517 
518  SetStatusText( line, 4 );
519 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Definition: base_units.cpp:123
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.

References PCB_BASE_FRAME::GetCanvas(), EDA_BASE_FRAME::m_userUnits, and MessageTextFromValue().

Referenced by PCB_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from TOOLS_HOLDER.

Definition at line 466 of file eda_draw_frame.cpp.

467 {
468  SetStatusText( msg, 6 );
469 }

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

◆ DisplayUnitsMsg()

void EDA_DRAW_FRAME::DisplayUnitsMsg ( )
inherited

Display current unit pane in the status bar.

Definition at line 483 of file eda_draw_frame.cpp.

484 {
485  wxString msg;
486 
487  switch( m_userUnits )
488  {
489  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
490  case EDA_UNITS::MILS: msg = _( "mils" ); break;
491  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
492  default: msg = _( "Units" ); break;
493  }
494 
495  SetStatusText( msg, 5 );
496 }
#define _(s)
Definition: 3d_actions.cpp:33
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.

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

Referenced by EDA_DRAW_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 1028 of file pcbnew/files.cpp.

1029 {
1030  wxFileName tmpFileName;
1031 
1032  if( GetBoard()->GetFileName().IsEmpty() )
1033  {
1034  tmpFileName = wxFileName( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ),
1036  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1037  }
1038  else
1039  {
1040  tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
1041  }
1042 
1043  wxFileName autoSaveFileName = tmpFileName;
1044 
1045  // Auto save file name is the board file name prepended with autosaveFilePrefix string.
1046  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() );
1047 
1048  if( !autoSaveFileName.IsOk() )
1049  return false;
1050 
1051  // If the board file path is not writable, try writing to a platform specific temp file
1052  // path. If that path isn't writabe, give up.
1053  if( !autoSaveFileName.IsDirWritable() )
1054  {
1055  autoSaveFileName.SetPath( wxFileName::GetTempDir() );
1056 
1057  if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
1058  return false;
1059  }
1060 
1061  wxLogTrace( traceAutoSave, "Creating auto save file <" + autoSaveFileName.GetFullPath() + ">" );
1062 
1063  if( SavePcbFile( autoSaveFileName.GetFullPath(), false, false ) )
1064  {
1065  GetScreen()->SetModify();
1066  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1067  UpdateTitle();
1068  m_autoSaveState = false;
1069 
1070  if( !Kiface().IsSingle() &&
1071  GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
1072  {
1074  }
1075 
1076  return true;
1077  }
1078 
1079  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1080 
1081  return false;
1082 }
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
SETTINGS_MANAGER * GetSettingsManager() const
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const std::string KiCadPcbFileExtension
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetFileName(const wxString &aFileName)
Definition: board.h:279
static wxString GetAutoSaveFilePrefix()
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Function SavePcbFile writes the board data structures to a aFileName Creates backup when requested an...
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static REPORTER & GetInstance()
Definition: reporter.cpp:105
BOARD * GetBoard() const
void SetModify()
Definition: base_screen.h:59

References PROJECT::AbsolutePath(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), PCB_BASE_FRAME::GetBoard(), NULL_REPORTER::GetInstance(), PCB_BASE_FRAME::GetScreen(), EDA_BASE_FRAME::GetSettingsManager(), KiCadPcbFileExtension, Kiface(), EDA_BASE_FRAME::m_autoSaveState, KIWAY_HOLDER::Prj(), SavePcbFile(), BOARD::SetFileName(), BASE_SCREEN::SetModify(), traceAutoSave, SETTINGS_MANAGER::TriggerBackupIfNeeded(), and UpdateTitle().

Referenced by OnExportSTEP().

◆ doCloseWindow()

void PCB_EDIT_FRAME::doCloseWindow ( )
overrideprotectedvirtual

Reimplemented from PCB_BASE_EDIT_FRAME.

Definition at line 813 of file pcb_edit_frame.cpp.

814 {
815  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
816  // when closing this frame if a footprint was selected, and the footprint editor called
817  // to edit this footprint, and when closing pcbnew if this footprint is still selected
818  // See https://bugs.launchpad.net/kicad/+bug/1655858
819  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
820  // avoid the crash (JPC)
821  GetCanvas()->SetEvtHandlerEnabled( false );
822 
823  GetCanvas()->StopDrawing();
824 
825  // Delete the auto save file if it exists.
826  wxFileName fn = GetBoard()->GetFileName();
827 
828  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
829  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
830 
831  // When the auto save feature does not have write access to the board file path, it falls
832  // back to a platform specific user temporary file path.
833  if( !fn.IsOk() || !fn.IsDirWritable() )
834  fn.SetPath( wxFileName::GetTempDir() );
835 
836  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
837 
838  // Remove the auto save file on a normal close of Pcbnew.
839  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
840  {
841  wxString msg = wxString::Format( _( "The auto save file \"%s\" could not be removed!" ),
842  fn.GetFullPath() );
843  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
844  }
845 
846  // Make sure local settings are persisted
848 
849  // Do not show the layer manager during closing to avoid flicker
850  // on some platforms (Windows) that generate useless redraw of items in
851  // the Layer Manger
853  m_auimgr.GetPane( "LayersManager" ).Show( false );
854 
855  // Unlink the old project if needed
856  GetBoard()->ClearProject();
857 
858  // Delete board structs and undo/redo lists, to avoid crash on exit
859  // when deleting some structs (mainly in undo/redo lists) too late
860  Clear_Pcb( false, true );
861 
862  // do not show the window because ScreenPcb will be deleted and we do not
863  // want any paint event
864  Show( false );
865 
867 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxAuiManager m_auimgr
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
const wxString & GetFileName() const
Definition: board.h:281
void doCloseWindow() override
bool m_show_layer_manager_tools
void SaveProjectSettings() override
Function SaveProjectSettings saves changes to the project settings to the project (....
void ClearProject()
Definition: board.cpp:169
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static wxString GetAutoSaveFilePrefix()
#define _(s)
Definition: 3d_actions.cpp:33
BOARD * GetBoard() const
bool Clear_Pcb(bool aQuery, bool aFinal=false)
Function Clear_Pcb delete all and reinitialize the current board.
Definition: initpcb.cpp:42
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.

References _, BOARD::ClearProject(), PCB_BASE_EDIT_FRAME::doCloseWindow(), Format(), GetBoard(), BOARD::GetFileName(), Pgm(), and traceAutoSave.

◆ DoGenFootprintsPositionFile()

int PCB_EDIT_FRAME::DoGenFootprintsPositionFile ( const wxString &  aFullFileName,
bool  aUnitsMM,
bool  aForceSmdItems,
bool  aTopSide,
bool  aBottomSide,
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,
aBottomSidetrue 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 465 of file gen_footprints_placefile.cpp.

468 {
469  FILE * file = NULL;
470 
471  if( !aFullFileName.IsEmpty() )
472  {
473  file = wxFopen( aFullFileName, wxT( "wt" ) );
474 
475  if( file == NULL )
476  return -1;
477  }
478 
479  std::string data;
480  PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aForceSmdItems, aTopSide, aBottomSide,
481  aFormatCSV );
482  data = exporter.GenPositionData();
483 
484  // if aFullFileName is empty, the file is not created, only the
485  // count of footprints to place is returned
486  if( file )
487  {
488  // Creates a footprint position file
489  // aSide = 0 -> Back (bottom) side)
490  // aSide = 1 -> Front (top) side)
491  // aSide = 2 -> both sides
492  fputs( data.c_str(), file );
493  fclose( file );
494  }
495 
496  return exporter.GetFootprintCount();
497 }
#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 533 of file gen_footprints_placefile.cpp.

534 {
535  FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
536 
537  if( rptfile == NULL )
538  return false;
539 
540  std::string data;
541  PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, false, true, true, false );
542  data = exporter.GenReportData();
543 
544  fputs( data.c_str(), rptfile );
545  fclose( rptfile );
546 
547  return true;
548 }
#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().

◆ 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 1412 of file pcb_edit_frame.cpp.

1413 {
1414  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1415  updater.SetLookupByTimestamp( aUseTimestamps );
1416  updater.SetDeleteUnusedComponents( false );
1417  updater.SetReplaceFootprints( true );
1418  updater.SetDeleteSinglePadNets( false );
1419  updater.SetWarnPadNoNetInNetlist( false );
1420  updater.UpdateNetlist( aNetlist );
1421 }
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().

◆ Edit_Zone_Params()

void PCB_EDIT_FRAME::Edit_Zone_Params ( ZONE zone_container)

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

Definition at line 39 of file edit_zone_helpers.cpp.

40 {
41  int dialogResult;
42  ZONE_SETTINGS zoneInfo = GetZoneSettings();
43  PICKED_ITEMS_LIST pickedList; // zones for undo/redo command
44  PICKED_ITEMS_LIST deletedList; // zones that have been deleted when combined
45  BOARD_COMMIT commit( this );
46 
47  // Save initial zones configuration, for undo/redo, before adding new zone
48  // note the net name and the layer can be changed, so we must save all zones
49  deletedList.ClearListAndDeleteItems();
50  pickedList.ClearListAndDeleteItems();
51  SaveCopyOfZones( pickedList, GetBoard(), -1, UNDEFINED_LAYER );
52 
53  if( aZone->GetIsRuleArea() )
54  {
55  // edit a rule area on a copper layer
56  zoneInfo << *aZone;
57  dialogResult = InvokeRuleAreaEditor( this, &zoneInfo );
58  }
59  else if( IsCopperLayer( aZone->GetLayer() ) )
60  {
61  // edit a zone on a copper layer
62  zoneInfo << *aZone;
63  dialogResult = InvokeCopperZonesEditor( this, &zoneInfo );
64  }
65  else
66  {
67  zoneInfo << *aZone;
68  dialogResult = InvokeNonCopperZonesEditor( this, &zoneInfo );
69  }
70 
71  if( dialogResult == wxID_CANCEL )
72  {
73  deletedList.ClearListAndDeleteItems();
74  pickedList.ClearListAndDeleteItems();
75  return;
76  }
77 
78  SetZoneSettings( zoneInfo );
79  OnModify();
80 
81  if( dialogResult == ZONE_EXPORT_VALUES )
82  {
83  UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() );
84  commit.Stage( pickedList );
85  commit.Push( _( "Modify zone properties" ) );
86  pickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
87  return;
88  }
89 
90  wxBusyCursor dummy;
91 
92  // Undraw old zone outlines
93  for( ZONE* zone : GetBoard()->Zones() )
94  GetCanvas()->GetView()->Update( zone );
95 
96  zoneInfo.ExportSetting( *aZone );
97 
98  NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
99 
100  if( net ) // net == NULL should not occur
101  aZone->SetNetCode( net->GetNetCode() );
102 
103  // Combine zones if possible
104  GetBoard()->OnAreaPolygonModified( &deletedList, aZone );
105 
106  UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() );
107 
108  // refill zones with the new properties applied
109  std::vector<ZONE*> zones_to_refill;
110 
111  for( unsigned i = 0; i < pickedList.GetCount(); ++i )
112  {
113  ZONE* zone = dyn_cast<ZONE*>( pickedList.GetPickedItem( i ) );
114 
115  if( zone == nullptr )
116  {
117  wxASSERT_MSG( false, "Expected a zone after zone properties edit" );
118  continue;
119  }
120 
121  // aZone won't be filled if the layer set was modified, but it needs to be updated
122  if( zone->IsFilled() || zone == aZone )
123  zones_to_refill.push_back( zone );
124  }
125 
126  commit.Stage( pickedList );
127 
128  if( zones_to_refill.size() )
129  {
130  ZONE_FILLER filler( GetBoard(), &commit );
131  wxString title = wxString::Format( _( "Refill %d Zones" ), (int) zones_to_refill.size() );
132  filler.InstallNewProgressReporter( this, title, 4 );
133 
134  if( !filler.Fill( zones_to_refill ) )
135  {
136  commit.Revert();
137  return;
138  }
139  }
140 
141  commit.Push( _( "Modify zone properties" ) );
142  GetBoard()->GetConnectivity()->RecalculateRatsnest();
143 
144  pickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
145 }
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1261
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
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...
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.
bool IsFilled() const
Definition: zone.h:237
#define ZONE_EXPORT_VALUES
Definition: zones.h:37
unsigned GetCount() const
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
Definition: zone_settings.h:93
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:93
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
bool OnAreaPolygonModified(PICKED_ITEMS_LIST *aModifiedZonesList, ZONE *modified_area)
Process an area that has been modified, by normalizing its polygon and merging the intersecting polyg...
const ZONE_SETTINGS & GetZoneSettings() const
void SetNetCode(int aNetCode)
Definition: netinfo.h:132
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:397
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
A holder to handle information on schematic or board items.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
#define _(s)
Definition: 3d_actions.cpp:33
void ClearItemsList()
Delete only the list of pickers NOT the picked data itself.
bool IsCopperLayer(LAYER_NUM aLayerId)
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)
BOARD * GetBoard() const
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
int GetNetCode() const
Definition: netinfo.h:131

References _, PICKED_ITEMS_LIST::ClearItemsList(), PICKED_ITEMS_LIST::ClearListAndDeleteItems(), dummy(), ZONE_SETTINGS::ExportSetting(), ZONE_FILLER::Fill(), BOARD::FindNet(), Format(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), PICKED_ITEMS_LIST::GetCount(), ZONE::GetIsRuleArea(), ZONE::GetLayer(), NETINFO_ITEM::GetNetCode(), PICKED_ITEMS_LIST::GetPickedItem(), PCB_DRAW_PANEL_GAL::GetView(), PCB_BASE_FRAME::GetZoneSettings(), ZONE_FILLER::InstallNewProgressReporter(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), IsCopperLayer(), ZONE::IsFilled(), ZONE_SETTINGS::m_NetcodeSelection, BOARD::OnAreaPolygonModified(), OnModify(), BOARD_COMMIT::Push(), BOARD_COMMIT::Revert(), 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 229 of file eda_draw_frame.cpp.

230 {
231  if( m_messagePanel )
233 }
EDA_MSG_PANEL * m_messagePanel
void EraseMsgBox()
Definition: msgpanel.cpp:214

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

Referenced by GERBVIEW_CONTROL::UpdateMessagePanel().

◆ ExchangeFootprint()

void PCB_EDIT_FRAME::ExchangeFootprint ( FOOTPRINT aExisting,
FOOTPRINT aNew,
BOARD_COMMIT aCommit,
bool  deleteExtraTexts = true,
bool  resetTextLayers = true,
bool  resetTextEffects = true,
bool  resetFabricationAttrs = 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
aExisting= footprint to replace
aNew= footprint to put
aCommit= commit that should store the changes

Definition at line 479 of file dialog_exchange_footprints.cpp.

483 {
484  PCB_GROUP* parentGroup = aExisting->GetParentGroup();
485 
486  if( parentGroup )
487  {
488  parentGroup->RemoveItem( aExisting );
489  parentGroup->AddItem( aNew );
490  }
491 
492  aNew->SetParent( GetBoard() );
493 
494  PlaceFootprint( aNew, false );
495 
496  // PlaceModule will move the footprint to the cursor position, which we don't want. Copy
497  // the original position across.
498  aNew->SetPosition( aExisting->GetPosition() );
499 
500  if( aNew->GetLayer() != aExisting->GetLayer() )
501  aNew->Flip( aNew->GetPosition(), m_settings->m_FlipLeftRight );
502 
503  if( aNew->GetOrientation() != aExisting->GetOrientation() )
504  aNew->SetOrientation( aExisting->GetOrientation() );
505 
506  aNew->SetLocked( aExisting->IsLocked() );
507 
508  for( PAD* pad : aNew->Pads() )
509  {
510  PAD* oldPad = aExisting->FindPadByName( pad->GetName() );
511 
512  if( oldPad )
513  {
515  pad->SetNetCode( oldPad->GetNetCode() );
516  pad->SetPinFunction( oldPad->GetPinFunction() );
517  }
518  }
519 
520  // Copy reference
521  processTextItem( aExisting->Reference(), aNew->Reference(),
522  // never reset reference text
523  false,
524  resetTextLayers, resetTextEffects );
525 
526  // Copy value
527  processTextItem( aExisting->Value(), aNew->Value(),
528  // reset value text only when it is a proxy for the footprint ID
529  // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
530  aExisting->GetValue() == aExisting->GetFPID().GetLibItemName(),
531  resetTextLayers, resetTextEffects );
532 
533  // Copy fields in accordance with the reset* flags
534  for( BOARD_ITEM* item : aExisting->GraphicalItems() )
535  {
536  FP_TEXT* srcItem = dyn_cast<FP_TEXT*>( item );
537 
538  if( srcItem )
539  {
540  FP_TEXT* destItem = getMatchingTextItem( srcItem, aNew );
541 
542  if( destItem )
543  processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects );
544  else if( !deleteExtraTexts )
545  aNew->Add( new FP_TEXT( *srcItem ) );
546  }
547  }
548 
549  if( !resetFabricationAttrs )
550  aNew->SetAttributes( aExisting->GetAttributes() );
551 
552  // Copy 3D model settings in accordance with the reset* flag
553  if( !reset3DModels )
554  aNew->Models() = aExisting->Models(); // Linked list of 3D models.
555 
556  // Updating other parameters
557  const_cast<KIID&>( aNew->m_Uuid ) = aExisting->m_Uuid;
558  aNew->SetProperties( aExisting->GetProperties() );
559  aNew->SetPath( aExisting->GetPath() );
560  aNew->CalculateBoundingBox();
561 
562  aCommit.Remove( aExisting );
563  aCommit.Add( aNew );
564 
565  aNew->ClearFlags();
566 }
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:93
bool IsLocked() const override
Definition: footprint.h:298
bool AddItem(BOARD_ITEM *aItem)
Adds item to group.
Definition: pcb_group.cpp:38
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
int GetNetCode() const
Function GetNetCode.
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:196
const KIID_PATH & GetPath() const
Definition: footprint.h:217
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
const wxString GetValue() const
Function GetValue.
Definition: footprint.h:467
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:218
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:77
PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates)
Definition: pcb_group.h:50
double GetOrientation() const
Definition: footprint.h:204
bool GetLocalRatsnestVisible() const
void SetLocalRatsnestVisible(bool aVisible)
PCBNEW_SETTINGS * m_settings
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:164
void SetAttributes(int aAttributes)
Definition: footprint.h:250
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
PADS & Pads()
Definition: footprint.h:182
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:482
FP_TEXT & Reference()
Definition: footprint.h:483
FP_TEXT * getMatchingTextItem(FP_TEXT *aRefItem, FOOTPRINT *aFootprint)
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1462
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1297
DRAWINGS & GraphicalItems()
Definition: footprint.h:185
bool RemoveItem(BOARD_ITEM *aItem)
Removes item from group.
Definition: pcb_group.cpp:50
const LIB_ID & GetFPID() const
Definition: footprint.h:208
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:89
PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a PAD* with a matching name.
Definition: footprint.cpp:886
void processTextItem(const FP_TEXT &aSrc, FP_TEXT &aDest, bool resetText, bool resetTextLayers, bool resetTextEffects)
const KIID m_Uuid
Definition: eda_item.h:523
int GetAttributes() const
Definition: footprint.h:249
void SetLocked(bool isLocked) override
Function SetLocked sets the MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:308
wxPoint GetPosition() const override
Definition: footprint.h:200
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:202
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:489
BOARD * GetBoard() const
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Definition: footprint.cpp:445
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:490
Definition: pad.h:60
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1362
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
const wxString & GetPinFunction() const
Definition: pad.h:136
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
Definition: footprint.cpp:568

References COMMIT::Add(), FOOTPRINT::Add(), PCB_GROUP::AddItem(), FOOTPRINT::CalculateBoundingBox(), EDA_ITEM::ClearFlags(), FOOTPRINT::FindPadByName(), FOOTPRINT::Flip(), FOOTPRINT::GetAttributes(), PCB_BASE_FRAME::GetBoard(), FOOTPRINT::GetFPID(), BOARD_ITEM::GetLayer(), LIB_ID::GetLibItemName(), BOARD_CONNECTED_ITEM::GetLocalRatsnestVisible(), getMatchingTextItem(), BOARD_CONNECTED_ITEM::GetNetCode(), FOOTPRINT::GetOrientation(), BOARD_ITEM::GetParentGroup(), FOOTPRINT::GetPath(), PAD::GetPinFunction(), FOOTPRINT::GetPosition(), FOOTPRINT::GetProperties(), FOOTPRINT::GetValue(), FOOTPRINT::GraphicalItems(), FOOTPRINT::IsLocked(), PCBNEW_SETTINGS::m_FlipLeftRight, PCB_BASE_FRAME::m_settings, EDA_ITEM::m_Uuid, FOOTPRINT::Models(), FOOTPRINT::Pads(), PCB_BASE_FRAME::PlaceFootprint(), processTextItem(), FOOTPRINT::Reference(), COMMIT::Remove(), PCB_GROUP::RemoveItem(), FOOTPRINT::SetAttributes(), BOARD_CONNECTED_ITEM::SetLocalRatsnestVisible(), FOOTPRINT::SetLocked(), FOOTPRINT::SetOrientation(), EDA_ITEM::SetParent(), FOOTPRINT::SetPath(), FOOTPRINT::SetPosition(), FOOTPRINT::SetProperties(), and FOOTPRINT::Value().

Referenced by DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), 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 62 of file pcbnew/cross-probing.cpp.

63 {
64  char line[1024];
65  wxString msg;
66  wxString modName;
67  char* idcmd;
68  char* text;
69  int netcode = -1;
70  bool multiHighlight = false;
71  FOOTPRINT* footprint = nullptr;
72  PAD* pad = nullptr;
73  BOARD* pcb = GetBoard();
74 
75  CROSS_PROBING_SETTINGS& crossProbingSettings = GetPcbNewSettings()->m_CrossProbing;
76 
78  KIGFX::RENDER_SETTINGS* renderSettings = view->GetPainter()->GetSettings();
79 
80  strncpy( line, cmdline, sizeof(line) - 1 );
81  line[sizeof(line) - 1] = 0;
82 
83  idcmd = strtok( line, " \n\r" );
84  text = strtok( NULL, "\"\n\r" );
85 
86  if( idcmd == NULL )
87  return;
88 
89  if( strcmp( idcmd, "$NET:" ) == 0 )
90  {
91  if( !crossProbingSettings.auto_highlight )
92  return;
93 
94  wxString net_name = FROM_UTF8( text );
95 
96  NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
97 
98  if( netinfo )
99  {
100  netcode = netinfo->GetNetCode();
101 
102  MSG_PANEL_ITEMS items;
103  netinfo->GetMsgPanelInfo( this, items );
104  SetMsgPanel( items );
105  }
106  }
107  if( strcmp( idcmd, "$NETS:" ) == 0 )
108  {
109  if( !crossProbingSettings.auto_highlight )
110  return;
111 
112  wxStringTokenizer netsTok = wxStringTokenizer( FROM_UTF8( text ), "," );
113  bool first = true;
114 
115  while( netsTok.HasMoreTokens() )
116  {
117  NETINFO_ITEM* netinfo = pcb->FindNet( netsTok.GetNextToken() );
118 
119  if( netinfo )
120  {
121  if( first )
122  {
123  // TODO: Once buses are included in netlist, show bus name
124  MSG_PANEL_ITEMS items;
125  netinfo->GetMsgPanelInfo( this, items );
126  SetMsgPanel( items );
127  first = false;
128 
129  pcb->SetHighLightNet( netinfo->GetNetCode() );
130  renderSettings->SetHighlight( true, netinfo->GetNetCode() );
131  multiHighlight = true;
132  }
133  else
134  {
135  pcb->SetHighLightNet( netinfo->GetNetCode(), true );
136  renderSettings->SetHighlight( true, netinfo->GetNetCode(), true );
137  }
138  }
139  }
140 
141  netcode = -1;
142  }
143  else if( strcmp( idcmd, "$PIN:" ) == 0 )
144  {
145  wxString pinName = FROM_UTF8( text );
146 
147  text = strtok( NULL, " \n\r" );
148 
149  if( text && strcmp( text, "$PART:" ) == 0 )
150  text = strtok( NULL, "\"\n\r" );
151 
152  modName = FROM_UTF8( text );
153 
154  footprint = pcb->FindFootprintByReference( modName );
155 
156  if( footprint )
157  pad = footprint->FindPadByName( pinName );
158 
159  if( pad )
160  netcode = pad->GetNetCode();
161 
162  if( footprint == NULL )
163  msg.Printf( _( "%s not found" ), modName );
164  else if( pad == NULL )
165  msg.Printf( _( "%s pin %s not found" ), modName, pinName );
166  else
167  msg.Printf( _( "%s pin %s found" ), modName, pinName );
168 
169  SetStatusText( msg );
170  }
171  else if( strcmp( idcmd, "$PART:" ) == 0 )
172  {
173  pcb->ResetNetHighLight();
174 
175  modName = FROM_UTF8( text );
176 
177  footprint = pcb->FindFootprintByReference( modName );
178 
179  if( footprint )
180  msg.Printf( _( "%s found" ), modName );
181  else
182  msg.Printf( _( "%s not found" ), modName );
183 
184  SetStatusText( msg );
185  }
186  else if( strcmp( idcmd, "$SHEET:" ) == 0 )
187  {
188  msg.Printf( _( "Selecting all from sheet \"%s\"" ), FROM_UTF8( text ) );
189  wxString sheetUIID( FROM_UTF8( text ) );
190  SetStatusText( msg );
192  static_cast<void*>( &sheetUIID ) );
193  return;
194  }
195  else if( strcmp( idcmd, "$CLEAR" ) == 0 )
196  {
197  if( renderSettings->IsHighlightEnabled() )
198  {
199  renderSettings->SetHighlight( false );
200  view->UpdateAllLayersColor();
201  }
202 
203  if( pcb->IsHighLightNetON() )
204  {
205  pcb->ResetNetHighLight();
206  SetMsgPanel( pcb );
207  }
208 
209  GetCanvas()->Refresh();
210  return;
211  }
212 
213  BOX2I bbox = { { 0, 0 }, { 0, 0 } };
214 
215  if( footprint )
216  {
217  bbox = footprint->GetBoundingBox( false ); // No invisible text in bbox calc
218 
219  if( pad )
220  m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) pad );
221  else
222  m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) footprint );
223  }
224  else if( netcode > 0 || multiHighlight )
225  {
226  if( !multiHighlight )
227  {
228  renderSettings->SetHighlight( ( netcode >= 0 ), netcode );
229  pcb->SetHighLightNet( netcode );
230  }
231  else
232  {
233  // Just pick the first one for area calculation
234  netcode = *pcb->GetHighLightNetCodes().begin();
235  }
236 
237  pcb->HighLightON();
238 
239  auto merge_area =
240  [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
241  {
242  if( aItem->GetNetCode() == netcode )
243  {
244  if( bbox.GetWidth() == 0 )
245  bbox = aItem->GetBoundingBox();
246  else
247  bbox.Merge( aItem->GetBoundingBox() );
248  }
249  };
250 
251  if( crossProbingSettings.center_on_items )
252  {
253  for( ZONE* zone : pcb->Zones() )
254  merge_area( zone );
255 
256  for( TRACK* track : pcb->Tracks() )
257  merge_area( track );
258 
259  for( FOOTPRINT* fp : pcb->Footprints() )
260  {
261  for( PAD* p : fp->Pads() )
262  merge_area( p );
263  }
264  }
265  }
266  else
267  {
268  renderSettings->SetHighlight( false );
269  }
270 
271  if( crossProbingSettings.center_on_items && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
272  {
273 
274 //#define DEFAULT_PCBNEW_CODE // Un-comment for normal full zoom KiCad algorithm
275 #ifdef DEFAULT_PCBNEW_CODE
276  auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
277  auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false );
278 
279  // The "fabs" on x ensures the right answer when the view is flipped
280  screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
281  screenSize.y = std::max( 10.0, screenSize.y );
282  double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
283 
284  // Try not to zoom on every cross-probe; it gets very noisy
285  if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
286  view->SetScale( view->GetScale() / ratio );
287 #endif // DEFAULT_PCBNEW_CODE
288 
289 #ifndef DEFAULT_PCBNEW_CODE // Do the scaled zoom
290  auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
291  auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false );
292 
293  // This code tries to come up with a zoom factor that doesn't simply zoom in
294  // to the cross probed component, but instead shows a reasonable amount of the
295  // circuit around it to provide context. This reduces or eliminates the need
296  // to manually change the zoom because it's too close.
297 
298  // Using the default text height as a constant to compare against, use the
299  // height of the bounding box of visible items for a footprint to figure out
300  // if this is a big footprint (like a processor) or a small footprint (like a resistor).
301  // This ratio is not useful by itself as a scaling factor. It must be "bent" to
302  // provide good scaling at varying component sizes. Bigger components need less
303  // scaling than small ones.
304  double currTextHeight = Millimeter2iu( DEFAULT_TEXT_SIZE );
305 
306  double compRatio = bbSize.y / currTextHeight; // Ratio of component to text height
307  double compRatioBent = 1.0; // This will end up as the scaling factor we apply to "ratio"
308 
309  // This is similar to the original KiCad code that scaled the zoom to make sure components
310  // were visible on screen. It's simply a ratio of screen size to component size, and its
311  // job is to zoom in to make the component fullscreen. Earlier in the code the
312  // component BBox is given a 20% margin to add some breathing room. We compare
313  // the height of this enlarged component bbox to the default text height. If a component
314  // will end up with the sides clipped, we adjust later to make sure it fits on screen.
315  //
316  // The "fabs" on x ensures the right answer when the view is flipped
317  screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
318  screenSize.y = std::max( 10.0, screenSize.y );
319  double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
320  // Original KiCad code for how much to scale the zoom
321  double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ),
322  fabs( bbSize.y / screenSize.y ) );
323 
324  // LUT to scale zoom ratio to provide reasonable schematic context. Must work
325  // with footprints of varying sizes (e.g. 0402 package and 200 pin BGA).
326  // "first" is used as the input and "second" as the output
327  //
328  // "first" = compRatio (footprint height / default text height)
329  // "second" = Amount to scale ratio by
330  std::vector<std::pair<double, double>> lut{
331  { 1, 8 },
332  { 1.5, 5 },
333  { 3, 3 },
334  { 4.5, 2.5 },
335  { 8, 2.0 },
336  { 12, 1.7 },
337  { 16, 1.5 },
338  { 24, 1.3 },
339  { 32, 1.0 },
340  };
341 
342 
343  std::vector<std::pair<double, double>>::iterator it;
344 
345  compRatioBent = lut.back().second; // Large component default
346 
347  if( compRatio >= lut.front().first )
348  {
349  // Use LUT to do linear interpolation of "compRatio" within "first", then
350  // use that result to linearly interpolate "second" which gives the scaling
351  // factor needed.
352 
353  for( it = lut.begin(); it < lut.end() - 1; it++ )
354  {
355  if( it->first <= compRatio && next( it )->first >= compRatio )
356  {
357  double diffx = compRatio - it->first;
358  double diffn = next( it )->first - it->first;
359 
360  compRatioBent =
361  it->second + ( next( it )->second - it->second ) * diffx / diffn;
362  break; // We have our interpolated value
363  }
364  }
365  }
366  else
367  compRatioBent = lut.front().second; // Small component default
368 
369  // If the width of the part we're probing is bigger than what the screen width will be
370  // after the zoom, then punt and use the KiCad zoom algorithm since it guarantees the
371  // part's width will be encompassed within the screen. This will apply to parts that are
372  // much wider than they are tall.
373 
374  if( bbSize.x > screenSize.x * ratio * compRatioBent )
375  {
376  ratio = kicadRatio; // Use standard KiCad zoom algorithm for parts too wide to fit screen
377  compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
378  wxLogTrace( "CROSS_PROBE_SCALE",
379  "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
380  }
381 
382  // Now that "compRatioBent" holds our final scaling factor we apply it to the original
383  // fullscreen zoom ratio to arrive at the final ratio itself.
384  ratio *= compRatioBent;
385 
386  bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
387  // Try not to zoom on every cross-probe; it gets very noisy
388  if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
389  view->SetScale( view->GetScale() / ratio );
390 #endif // ifndef DEFAULT_PCBNEW_CODE
391 
392  view->SetCenter( bbox.Centre() );
393  }
394 
395  view->UpdateAllLayersColor();
396  // Ensure the display is refreshed, because in some installs the refresh is done only
397  // when the gal canvas has the focus, and that is not the case when crossprobing from
398  // Eeschema:
399  GetCanvas()->Refresh();
400 }
CITER next(CITER it)
Definition: ptree.cpp:126
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1261
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:284
int GetNetCode() const
Function GetNetCode.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
ZONES & Zones()
Definition: board.h:292
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:1998
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:456
static TOOL_ACTION highlightItem
Definition: pcb_actions.h:446
bool IsHighLightNetON() const
Definition: board.h:452
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)
Run the specified action.
Definition: tool_manager.h:141
bool IsHighlightEnabled() const
Return current highlight setting.
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
Cross-probing behavior.
Definition: app_settings.h:30
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:1976
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:585
#define NULL
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:197
FOOTPRINTS & Footprints()
Definition: board.h:286
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a PAD* with a matching name.
Definition: footprint.cpp:886
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:1985
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:386
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...
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:33
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:437
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:559
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:34
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:302
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
Vec Centre() const
Definition: box2.h:79
static TOOL_ACTION selectOnSheetFromEeschema
Selects all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:86
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:189
#define _(s)
Definition: 3d_actions.cpp:33
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:631
PCBNEW_SETTINGS * GetPcbNewSettings() const
coord_type GetHeight() const
Definition: box2.h:198
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
BOARD * GetBoard() const
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:159
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo returns the information about the NETINFO_ITEM in aList to display in the me...
Definition: pad.h:60
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:776
double GetScale() const
Definition: view.h:263
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:32
static constexpr int Millimeter2iu(double mm)
TRACKS & Tracks()
Definition: board.h:283
Definition: track.h:83
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:1282
int GetNetCode() const
Definition: netinfo.h:131

References _, CROSS_PROBING_SETTINGS::auto_highlight, CROSS_PROBING_SETTINGS::center_on_items, BOX2< Vec >::Centre(), DEFAULT_TEXT_SIZE, BOARD::FindFootprintByReference(), BOARD::FindNet(), FOOTPRINT::FindPadByName(), BOARD::Footprints(), FROM_UTF8(), PCB_BASE_FRAME::GetBoard(), FOOTPRINT::GetBoundingBox(), PCB_BASE_FRAME::GetCanvas(), BOX2< Vec >::GetHeight(), BOARD::GetHighLightNetCodes(), NETINFO_ITEM::GetMsgPanelInfo(), BOARD_CONNECTED_ITEM::GetNetCode(), NETINFO_ITEM::GetNetCode(), KIGFX::VIEW::GetPainter(), PCB_BASE_FRAME::GetPcbNewSettings(), KIGFX::VIEW::GetScale(), KIGFX::PAINTER::GetSettings(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::GetView(), BOX2< Vec >::GetWidth(), PCB_ACTIONS::highlightItem, BOARD::HighLightON(), BOX2< Vec >::Inflate(), KIGFX::RENDER_SETTINGS::IsHighlightEnabled(), BOARD::IsHighLightNetON(), APP_SETTINGS_BASE::m_CrossProbing, TOOLS_HOLDER::m_toolManager, BOX2< Vec >::Merge(), Millimeter2iu(), next(), NULL, EDA_DRAW_PANEL_GAL::Refresh(), BOARD::ResetNetHighLight(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectOnSheetFromEeschema, KIGFX::VIEW::SetCenter(), KIGFX::RENDER_SETTINGS::SetHighlight(), BOARD::SetHighLightNet(), EDA_DRAW_FRAME::SetMsgPanel(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), BOARD::Tracks(), KIGFX::VIEW::UpdateAllLayersColor(), VECTOR2< T >::x, BOARD::Zones(), and CROSS_PROBING_SETTINGS::zoom_to_fit.

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 587 of file pcbnew/exporters/export_idf.cpp.

589 {
590  IDF3_BOARD idfBoard( IDF3::CAD_ELEC );
591 
592  // Switch the locale to standard C (needed to print floating point numbers)
593  LOCALE_IO toggle;
594 
595  resolver = Prj().Get3DCacheManager()->GetResolver();
596 
597  bool ok = true;
598  double scale = MM_PER_IU; // we must scale internal units to mm for IDF
599  IDF3::IDF_UNIT idfUnit;
600 
601  if( aUseThou )
602  {
603  idfUnit = IDF3::UNIT_THOU;
604  idfBoard.SetUserPrecision( 1 );
605  }
606  else
607  {
608  idfUnit = IDF3::UNIT_MM;
609  idfBoard.SetUserPrecision( 5 );
610  }
611 
612  wxFileName brdName = aPcb->GetFileName();
613 
614  idfBoard.SetUserScale( scale );
615  idfBoard.SetBoardThickness( aPcb->GetDesignSettings().GetBoardThickness() * scale );
616  idfBoard.SetBoardName( TO_UTF8( brdName.GetFullName() ) );
617  idfBoard.SetBoardVersion( 0 );
618  idfBoard.SetLibraryVersion( 0 );
619 
620  std::ostringstream ostr;
621  ostr << "KiCad " << TO_UTF8( GetBuildVersion() );
622  idfBoard.SetIDFSource( ostr.str() );
623 
624  try
625  {
626  // set up the board reference point
627  idfBoard.SetUserOffset( -aXRef, aYRef );
628 
629  // Export the board outline
630  idf_export_outline( aPcb, idfBoard );
631 
632  // Output the drill holes and footprint (library) data.
633  for( FOOTPRINT* footprint : aPcb->Footprints() )
634  idf_export_footprint( aPcb, footprint, idfBoard );
635 
636  if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) )
637  {
638  wxString msg;
639  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( idfBoard.GetError().c_str() );
640  wxMessageBox( msg );
641 
642  ok = false;
643  }
644  }
645  catch( const IO_ERROR& ioe )
646  {
647  wxString msg;
648  msg << _( "IDF Export Failed:\n" ) << ioe.What();
649  wxMessageBox( msg );
650 
651  ok = false;
652  }
653  catch( const std::exception& e )
654  {
655  wxString msg;
656  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
657  wxMessageBox( msg );
658  ok = false;
659  }
660 
661  return ok;
662 }
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574
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: board.h:281
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
wxString GetBuildVersion()
Get the full KiCad version string.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
FOOTPRINTS & Footprints()
Definition: board.h:286
static void idf_export_footprint(BOARD *aPcb, FOOTPRINT *aFootprint, IDF3_BOARD &aIDFBoard)
Function idf_export_footprint retrieves information from all board footprints, adds drill holes to th...
const int scale
#define _(s)
Definition: 3d_actions.cpp:33
#define UNIT_MM
Definition: units_scales.h:31
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

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

Referenced by OnExportIDF3().

◆ ExportFootprintsToLibrary()

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

Function ExportFootprintsToLibrary Save footprints in a library:

Parameters
aStoreInNewLibtrue : save footprints 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 footprints 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 607 of file footprint_libraries_utils.cpp.

609 {
610  if( GetBoard()->GetFirstFootprint() == nullptr )
611  {
612  DisplayInfoMessage( this, _( "No footprints to export!" ) );
613  return;
614  }
615 
616  wxString footprintName;
617 
618  auto resetReference =
619  []( FOOTPRINT* aFootprint )
620  {
621  aFootprint->SetReference( "REF**" );
622  };
623 
624  if( !aStoreInNewLib )
625  {
626  // The footprints are saved in an existing .pretty library in the fp lib table
627  PROJECT& prj = Prj();
628  wxString last_nickname = prj.GetRString( PROJECT::PCB_LIB_NICKNAME );
629  wxString nickname = SelectLibrary( last_nickname );
630 
631  if( !nickname ) // Aborted
632  return;
633 
634  prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
635 
636  for( FOOTPRINT* footprint : GetBoard()->Footprints() )
637  {
638  try
639  {
640  FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
641 
642  if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
643  {
644  FOOTPRINT* fpCopy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
645 
646  resetReference( fpCopy );
647  tbl->FootprintSave( nickname, fpCopy, true );
648 
649  delete fpCopy;
650  }
651  }
652  catch( const IO_ERROR& ioe )
653  {
654  DisplayError( this, ioe.What() );
655  }
656  }
657  }
658  else
659  {
660  // The footprints are saved in a new .pretty library.
661  // If this library already exists, all previous footprints will be deleted
662  wxString libPath = CreateNewLibrary( aLibName );
663 
664  if( libPath.IsEmpty() ) // Aborted
665  return;
666 
667  if( aLibPath )
668  *aLibPath = libPath;
669 
671  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
672 
673  for( FOOTPRINT* footprint : GetBoard()->Footprints() )
674  {
675  try
676  {
677  if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
678  {
679  FOOTPRINT* fpCopy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
680 
681  resetReference( fpCopy );
682  pi->FootprintSave( libPath, fpCopy );
683 
684  delete fpCopy;
685  }
686  }
687  catch( const IO_ERROR& ioe )
688  {
689  DisplayError( this, ioe.What() );
690  }
691  }
692  }
693 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
Container for project specific data.
Definition: project.h:62
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:535
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString CreateNewLibrary(const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
If a library name is given, creates a new footprint library in the project folder with the given name...
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
#define _(s)
Definition: 3d_actions.cpp:33
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: io_mgr.cpp:58
SAVE_T FootprintSave(const wxString &aNickname, const FOOTPRINT *aFootprint, bool aOverwrite=true)
Write aFootprint to an existing library given by aNickname.
wxString SelectLibrary(const wxString &aNicknameExisting)
Put up a dialog and allows the user to pick a library, for unspecified use.
BOARD * GetBoard() const
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:52
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:281
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
S-expression Pcbnew file format.
Definition: io_mgr.h:55

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

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

◆ ExportSpecctraFile()

bool PCB_EDIT_FRAME::ExportSpecctraFile ( const wxString &  aFullFilename)

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

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

Returns
true if OK

Definition at line 82 of file specctra_export.cpp.

83 {
84  SPECCTRA_DB db;
85  bool ok = true;
86  wxString errorText;
87 
88  BASE_SCREEN* screen = GetScreen();
89  bool wasModified = screen->IsModify();
90 
91  db.SetPCB( SPECCTRA_DB::MakePCB() );
92 
93  LOCALE_IO toggle; // Switch the locale to standard C
94 
95  // DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the top view. So we
96  // temporarily flip any footprints which are on the back side of the board to the front,
97  // and record this in the FOOTPRINT's flag field.
98  db.FlipFOOTPRINTs( GetBoard());
99 
100  try
101  {
103  db.FromBOARD( GetBoard() );
104  db.ExportPCB( aFullFilename, true );
105 
106  // if an exception is thrown by FromBOARD or ExportPCB(), then
107  // ~SPECCTRA_DB() will close the file.
108  }
109  catch( const IO_ERROR& ioe )
110  {
111  ok = false;
112 
113  // copy the error string to safe place, ioe is in this scope only.
114  errorText = ioe.What();
115  }
116 
117  // done assuredly, even if an exception was thrown and caught.
118  db.RevertFOOTPRINTs( GetBoard());
119 
120  // The two calls below to FOOTPRINT::Flip(), both set the
121  // modified flag, yet their actions cancel each other out, so it should
122  // be ok to clear the modify flag.
123  if( !wasModified )
124  screen->ClrModify();
125 
126  if( ok )
127  {
128  SetStatusText( wxString( _( "BOARD exported OK." ) ) );
129  }
130  else
131  {
132  DisplayErrorMessage( this,
133  _( "Unable to export, please fix and try again" ),
134  errorText );
135  }
136 
137  return ok;
138 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:266
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void SetPCB(PCB *aPcb)
Function SetPCB deletes any existing PCB and replaces it with the given one.
Definition: specctra.h:3877
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1406
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
void RevertFOOTPRINTs(BOARD *aBoard)
Function RevertFOOTPRINTs flips the footprints which were on the back side of the board back to the b...
bool IsModify() const
Definition: base_screen.h:63
SPECCTRA_DB holds a DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3605
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:3442
#define _(s)
Definition: 3d_actions.cpp:33
void ClrModify()
Definition: base_screen.h:60
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void FlipFOOTPRINTs(BOARD *aBoard)
Function FlipFOOTPRINTs flips the footprints which are on the back side of the board to the front.

References _, BASE_SCREEN::ClrModify(), DisplayErrorMessage(), DSN::SPECCTRA_DB::ExportPCB(), DSN::SPECCTRA_DB::FlipFOOTPRINTs(), DSN::SPECCTRA_DB::FromBOARD(), GetBoard(), BASE_SCREEN::IsModify(), DSN::SPECCTRA_DB::MakePCB(), DSN::SPECCTRA_DB::RevertFOOTPRINTs(), 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 1190 of file pcb_edit_frame.cpp.

1191 {
1192  InvokeExportSVG( this, GetBoard() );
1193 }
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.
BOARD * GetBoard() const

References GetBoard(), and InvokeExportSVG().

◆ ExportToGenCAD()

void PCB_EDIT_FRAME::ExportToGenCAD ( wxCommandEvent &  event)

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

Definition at line 223 of file export_gencad.cpp.

224 {
225  // Build default output file name
226  wxString path = GetLastPath( LAST_PATH_GENCAD );
227 
228  if( path.IsEmpty() )
229  {
230  wxFileName brdFile = GetBoard()->GetFileName();
231  brdFile.SetExt( "cad" );
232  path = brdFile.GetFullPath();
233  }
234 
235  DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( this, path );
236 
237  if( optionsDialog.ShowModal() == wxID_CANCEL )
238  return;
239 
240  path = optionsDialog.GetFileName();
241  SetLastPath( LAST_PATH_GENCAD, path );
242  FILE* file = wxFopen( path, "wt" );
243 
244  if( !file )
245  {
246  DisplayError( this, wxString::Format( _( "Unable to create \"%s\"" ),
247  optionsDialog.GetFileName() ) );
248  return;
249  }
250 
251  // Get options
252  flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );
253  uniquePins = optionsDialog.GetOption( UNIQUE_PIN_NAMES );
254  individualShapes = optionsDialog.GetOption( INDIVIDUAL_SHAPES );
255  storeOriginCoords = optionsDialog.GetOption( STORE_ORIGIN_COORDS );
256 
257  // Switch the locale to standard C (needed to print floating point numbers)
258  LOCALE_IO toggle;
259 
260  // Update some board data, to ensure a reliable gencad export
262 
263  // Save the auxiliary origin for the rest of the footprint
264  wxPoint auxOrigin = m_pcb->GetDesignSettings().m_AuxOrigin;
265  GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0;
266  GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0;
267 
268  // No idea on *why* this should be needed... maybe to fix net names?
269  Compile_Ratsnest( true );
270 
271  /* Temporary modification of footprints that are flipped (i.e. on bottom
272  * layer) to convert them to non flipped footprints.
273  * This is necessary to easily export shapes to GenCAD,
274  * that are given as normal orientation (non flipped, rotation = 0))
275  * these changes will be undone later
276  */
277  BOARD* pcb = GetBoard();
278 
279  for( FOOTPRINT* footprint : pcb->Footprints() )
280  {
281  footprint->SetFlag( 0 );
282 
283  if( footprint->GetLayer() == B_Cu )
284  {
285  footprint->Flip( footprint->GetPosition(), Settings().m_FlipLeftRight );
286  footprint->SetFlag( 1 );
287  }
288  }
289 
290  /* Gencad has some mandatory and some optional sections: some importer
291  * need the padstack section (which is optional) anyway. Also the
292  * order of the section *is* important */
293 
294  CreateHeaderInfoData( file, this ); // Gencad header
295  CreateBoardSection( file, pcb ); // Board perimeter
296 
297  CreatePadsShapesSection( file, pcb ); // Pads and padstacks
298  CreateArtworksSection( file ); // Empty but mandatory
299 
300  /* Gencad splits a component info in shape, component and device.
301  * We don't do any sharing (it would be difficult since each module is
302  * customizable after placement) */
303  CreateShapesSection( file, pcb );
304  CreateComponentsSection( file, pcb );
305  CreateDevicesSection( file, pcb );
306 
307  // In a similar way the netlist is split in net, track and route
308  CreateSignalsSection( file, pcb );
309  CreateTracksInfoData( file, pcb );
310  CreateRoutesSection( file, pcb );
311 
312  fclose( file );
313 
314  // Undo the footprints modifications (flipped footprints)
315  for( FOOTPRINT* footprint : pcb->Footprints() )
316  {
317  if( footprint->GetFlag() )
318  {
319  footprint->Flip( footprint->GetPosition(), Settings().m_FlipLeftRight );
320  footprint->SetFlag( 0 );
321  }
322  }
323 
324  componentShapes.clear();
325  shapeNames.clear();
326 }
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:253
static void CreateShapesSection(FILE *aFile, BOARD *aPcb)
static std::map< FOOTPRINT *, int > componentShapes
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
Definition: ratsnest.cpp:41
static void CreateRoutesSection(FILE *aFile, BOARD *aPcb)
static void CreateSignalsSection(FILE *aFile, BOARD *aPcb)
static bool uniquePins
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574
static int GencadOffsetY
static bool flipBottomPads
const wxString & GetFileName() const
Definition: board.h:281
static void CreateTracksInfoData(FILE *aFile, BOARD *aPcb)
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
static void CreateArtworksSection(FILE *aFile)
static void CreateComponentsSection(FILE *aFile, BOARD *aPcb)
static bool individualShapes
static void CreatePadsShapesSection(FILE *aFile, BOARD *aPcb)
FOOTPRINTS & Footprints()
Definition: board.h:286
static bool storeOriginCoords
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static bool CreateHeaderInfoData(FILE *aFile, PCB_EDIT_FRAME *frame)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:189
static void CreateDevicesSection(FILE *aFile, BOARD *aPcb)
#define _(s)
Definition: 3d_actions.cpp:33
PCBNEW_SETTINGS & Settings()
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1022
static int GencadOffsetX
BOARD * GetBoard() const
static std::map< int, wxString > shapeNames
wxPoint m_AuxOrigin
origin for plot exports
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, BOARD::Footprints(), Format(), GencadOffsetX, GencadOffsetY, PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), DIALOG_GENCAD_EXPORT_OPTIONS::GetFileName(), BOARD::GetFileName(), GetLastPath(), DIALOG_GENCAD_EXPORT_OPTIONS::GetOption(), INDIVIDUAL_SHAPES, individualShapes, LAST_PATH_GENCAD, BOARD_DESIGN_SETTINGS::m_AuxOrigin, PCBNEW_SETTINGS::m_FlipLeftRight, PCB_BASE_FRAME::m_pcb, SetLastPath(), PCB_BASE_FRAME::Settings(), shapeNames, STORE_ORIGIN_COORDS, storeOriginCoords, UNIQUE_PIN_NAMES, uniquePins, and USE_AUX_ORIGIN.

◆ 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 1615 of file export_vrml.cpp.

1619 {
1620  BOARD* pcb = GetBoard();
1621  bool ok = true;
1622  BOARD_COMMIT commit( this ); // We may need to modify the board (for instance to
1623  // fill zones), so make sure we can revert.
1624 
1625  USE_INLINES = aExport3DFiles;
1626  USE_DEFS = true;
1627  USE_RELPATH = aUseRelativePaths;
1628 
1629  cache = Prj().Get3DCacheManager();
1630  PROJ_DIR = Prj().GetProjectPath();
1631  SUBDIR_3D = a3D_Subdir;
1632  MODEL_VRML model3d;
1633  model_vrml = &model3d;
1634  model3d.SetScale( aMMtoWRMLunit );
1635 
1636  if( USE_INLINES )
1637  {
1638  BOARD_SCALE = MM_PER_IU / 2.54;
1639  model3d.SetOffset( -aXRef / 2.54, aYRef / 2.54 );
1640  }
1641  else
1642  {
1643  BOARD_SCALE = MM_PER_IU;
1644  model3d.SetOffset( -aXRef, aYRef );
1645  }
1646 
1647  // plain PCB or else PCB with copper and silkscreen
1648  model3d.m_plainPCB = aUsePlainPCB;
1649 
1650  try
1651  {
1652  // Preliminary computation: the z value for each layer
1653  compute_layer_Zs( model3d, pcb );
1654 
1655  // board edges and cutouts
1656  export_vrml_board( model3d, pcb );
1657 
1658  // Drawing and text on the board
1659  if( !aUsePlainPCB )
1660  export_vrml_drawings( model3d, pcb );
1661 
1662  // Export vias and trackage
1663  export_vrml_tracks( model3d, pcb );
1664 
1665  // Export zone fills
1666  if( !aUsePlainPCB )
1667  export_vrml_zones( model3d, pcb, &commit );
1668 
1669  if( USE_INLINES )
1670  {
1671  // check if the 3D Subdir exists - create if not
1672  wxFileName subdir( SUBDIR_3D, "" );
1673 
1674  if( ! subdir.DirExists() )
1675  {
1676  if( !wxDir::Make( subdir.GetFullPath() ) )
1677  throw( std::runtime_error( "Could not create 3D model subdirectory" ) );
1678  }
1679 
1680  OPEN_OSTREAM( output_file, TO_UTF8( aFullFileName ) );
1681 
1682  if( output_file.fail() )
1683  {
1684  std::ostringstream ostr;
1685  ostr << "Could not open file '" << TO_UTF8( aFullFileName ) << "'";
1686  throw( std::runtime_error( ostr.str().c_str() ) );
1687  }
1688 
1689  output_file.imbue( std::locale( "C" ) );
1690 
1691  // Begin with the usual VRML boilerplate
1692  wxString fn = aFullFileName;
1693  fn.Replace( "\\" , "/" );
1694  output_file << "#VRML V2.0 utf8\n";
1695  output_file << "WorldInfo {\n";
1696  output_file << " title \"" << TO_UTF8( fn ) << " - Generated by Pcbnew\"\n";
1697  output_file << "}\n";
1698  output_file << "Transform {\n";
1699  output_file << " scale " << std::setprecision( PRECISION );
1700  output_file << WORLD_SCALE << " ";
1701  output_file << WORLD_SCALE << " ";
1702  output_file << WORLD_SCALE << "\n";
1703  output_file << " children [\n";
1704 
1705  // Export footprints
1706  for( FOOTPRINT* footprint : pcb->Footprints() )
1707  export_vrml_footprint( model3d, pcb, footprint, &output_file );
1708 
1709  // write out the board and all layers
1710  write_layers( model3d, pcb, TO_UTF8( aFullFileName ), &output_file );
1711 
1712  // Close the outer 'transform' node
1713  output_file << "]\n}\n";
1714 
1715  CLOSE_STREAM( output_file );
1716  }
1717  else
1718  {
1719  // Export footprints
1720  for( FOOTPRINT* footprint : pcb->Footprints() )
1721  export_vrml_footprint( model3d, pcb, footprint, NULL );
1722 
1723  // write out the board and all layers
1724  write_layers( model3d, pcb, TO_UTF8( aFullFileName ), NULL );
1725  }
1726  }
1727  catch( const std::exception& e )
1728  {
1729  wxString msg;
1730  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
1731  wxMessageBox( msg );
1732 
1733  ok = false;
1734  }
1735 
1736  commit.Revert();
1737  return ok;
1738 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
static S3D_CACHE * cache
Definition: export_vrml.cpp:62
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
static double WORLD_SCALE
Definition: export_vrml.cpp:66
static bool USE_INLINES
Definition: export_vrml.cpp:63
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)
virtual const wxString GetProjectPath() const
Return the full path of the project.
static void export_vrml_zones(MODEL_VRML &aModel, BOARD *aPcb, COMMIT *aCommit)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
#define NULL
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
FOOTPRINTS & Footprints()
Definition: board.h:286
static bool USE_RELPATH
Definition: export_vrml.cpp:65
#define OPEN_OSTREAM(var, name)
static wxString SUBDIR_3D
Definition: export_vrml.cpp:69
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 export_vrml_footprint(MODEL_VRML &aModel, BOARD *aPcb, FOOTPRINT *aFootprint, std::ostream *aOutputFile)
static void write_layers(MODEL_VRML &aModel, BOARD *aPcb, const char *aFileName, OSTREAM *aOutputFile)
static wxString PROJ_DIR
Definition: export_vrml.cpp:70
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:189
#define _(s)
Definition: 3d_actions.cpp:33
static const int PRECISION
Definition: export_vrml.cpp:68
static bool USE_DEFS
Definition: export_vrml.cpp:64
#define CLOSE_STREAM(var)
BOARD * GetBoard() const

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

Referenced by ExportVRML(), and OnExportVRML().

◆ FetchNetlistFromSchematic()

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

Definition at line 1376 of file pcb_edit_frame.cpp.

1377 {
1378  if( !TestStandalone() )
1379  {
1380  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
1381  "mode. In order to create or update PCBs from schematics, you "
1382  "must launch the KiCad project manager and create a project." ) );
1383  return false; //Not in standalone mode
1384  }
1385 
1386  Raise(); //Show
1387  std::string payload;
1388 
1389  if( aMode == NO_ANNOTATION )
1390  payload = "no-annotate";
1391  else if( aMode == QUIET_ANNOTATION )
1392  payload = "quiet-annotate";
1393 
1394  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1395 
1396  try
1397  {
1398  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1399  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1400  netlistReader.LoadNetlist();
1401  }
1402  catch( const IO_ERROR& )
1403  {
1404  assert( false ); // should never happen
1405  return false;
1406  }
1407 
1408  return true;
1409 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
KIWAY & Kiway() const
Return 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.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:439
bool TestStandalone(void)
Test if standalone mode.
#define _(s)
Definition: 3d_actions.cpp:33
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:237
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

References _, DisplayError(), KIWAY::ExpressMail(), FRAME_SCH, Kiway, KICAD_NETLIST_READER::LoadNetlist(), and MAIL_SCH_GET_NETLIST.

Referenced by KiwayMailIn(), DRC_TOOL::RunTests(), and BOARD_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 284 of file pcbnew/files.cpp.

285 {
286  int id = event.GetId();
287  Files_io_from_id( id );
288 }
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_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 291 of file pcbnew/files.cpp.

292 {
293  wxString msg;
294 
295  switch( id )
296  {
297  case ID_LOAD_FILE:
298  {
299  int open_ctl = 0;
300  wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
301 
302  return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
303  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
304  }
305 
307  {
308  int open_ctl = 1;
309  wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
310 
311  return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
312  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
313  }
314 
316  {
317  wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
318  wxFileName fn = currfn;
319 
320  wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
321  fn.SetName( rec_name );
322 
323  if( !fn.FileExists() )
324  {
325  msg.Printf( _( "Recovery file \"%s\" not found." ), fn.GetFullPath() );
326  DisplayInfoMessage( this, msg );
327  return false;
328  }
329 
330  msg.Printf( _( "OK to load recovery file \"%s\"" ), fn.GetFullPath() );
331 
332  if( !IsOK( this, msg ) )
333  return false;
334 
335  GetScreen()->ClrModify(); // do not prompt the user for changes
336 
337  if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
338  {
339  // Re-set the name since name or extension was changed
340  GetBoard()->SetFileName( currfn.GetFullPath() );
341  UpdateTitle();
342  return true;
343  }
344  return false;
345  }
346 
347  case ID_NEW_BOARD:
348  {
349  if( IsContentModified() )
350  {
351  wxFileName fileName = GetBoard()->GetFileName();
352  wxString saveMsg =
353  _( "Current board will be closed, save changes to \"%s\" before continuing?" );
354 
355  if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
356  [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
357  return false;
358  }
359  else if( !GetBoard()->IsEmpty() )
360  {
361  if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
362  return false;
363  }
364 
366 
367  GetBoard()->ClearProject();
368 
370 
371  mgr->SaveProject( mgr->Prj().GetProjectFullName() );
372  mgr->UnloadProject( &mgr->Prj() );
373 
374  if( !Clear_Pcb( false ) )
375  return false;
376 
377  onBoardLoaded();
378 
380 
381  OnModify();
382  return true;
383  }
384 
385  case ID_SAVE_BOARD:
386  if( !GetBoard()->GetFileName().IsEmpty() )
387  return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) );
388 
390 
391  case ID_COPY_BOARD_AS:
392  case ID_SAVE_BOARD_AS:
393  {
394  bool addToHistory = false;
395  wxString orig_name;
396  wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name,
397  nullptr );
398 
399  if( orig_name.IsEmpty() )
400  {
401  addToHistory = true;
402  orig_name = _( "noname" );
403  }
404 
405  wxFileName savePath( Prj().GetProjectFullName() );
406 
407  if( !savePath.IsOk() || !savePath.IsDirWritable() )
408  {
409  savePath = GetMruPath();
410 
411  if( !savePath.IsOk() || !savePath.IsDirWritable() )
412  savePath = wxStandardPaths::Get().GetDocumentsDir();
413  }
414 
415  wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
416  wxString filename = fn.GetFullPath();
417 
418  bool createProject = false;
419 
420  if( AskSaveBoardFileName( this, &filename, &createProject ) )
421  {
422  if( id == ID_COPY_BOARD_AS )
423  return SavePcbCopy( filename, createProject );
424  else
425  return SavePcbFile( filename, addToHistory, createProject );
426  }
427  return false;
428  }
429 
430  default:
431  return false;
432  }
433 }
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:208
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
SETTINGS_MANAGER * GetSettingsManager() const
bool LoadProjectSettings()
Load the current project's file configuration settings which are pertinent to this PCB_EDIT_FRAME ins...
bool SavePcbCopy(const wxString &aFileName, bool aCreateProject=false)
Function SavePcbCopy writes the board data structures to a aFileName but unlike SavePcbFile,...
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
const std::string KiCadPcbFileExtension
const wxString & GetFileName() const
Definition: board.h:281
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
wxString GetMruPath() const
bool AskSaveBoardFileName(PCB_EDIT_FRAME *aParent, wxString *aFileName, bool *aCreateProject)
Puts up a wxFileDialog asking for a BOARD filename to save.
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.
void onBoardLoaded()
Updates the state of the GUI after a new board is loaded or created.
PROJECT & Prj() const
Return 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 SaveProjectSettings() override
Function SaveProjectSettings saves changes to the project settings to the project (....
void SetFileName(const wxString &aFileName)
Definition: board.h:279
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
void ClearProject()
Definition: board.cpp:169
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static wxString GetAutoSaveFilePrefix()
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Function SavePcbFile writes the board data structures to a aFileName Creates backup when requested an...
#define _(s)
Definition: 3d_actions.cpp:33
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
bool SaveProject(const wxString &aFullPath=wxEmptyString)
Saves a loaded project.
void ClrModify()
Definition: base_screen.h:60
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:281
bool Clear_Pcb(bool aQuery, bool aFinal=false)
Function Clear_Pcb delete all and reinitialize the current board.
Definition: initpcb.cpp:42
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:297
bool IsEmpty() const
Definition: board.h:334

References _, PROJECT::AbsolutePath(), AskLoadBoardFileName(), AskSaveBoardFileName(), Clear_Pcb(), BOARD::ClearProject(), BASE_SCREEN::ClrModify(), DisplayInfoMessage(), Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), EDA_BASE_FRAME::GetMruPath(), PROJECT::GetProjectFullName(), PCB_BASE_FRAME::GetScreen(), EDA_BASE_FRAME::GetSettingsManager(), HandleUnsavedChanges(), ID_COPY_BOARD_AS, ID_IMPORT_NON_KICAD_BOARD, ID_LOAD_FILE, ID_MENU_RECOVER_BOARD_AUTOSAVE, ID_NEW_BOARD, ID_SAVE_BOARD, ID_SAVE_BOARD_AS, IsContentModified(), BOARD::IsEmpty(), IsOK(), KI_FALLTHROUGH, KiCadPcbFileExtension, LoadProjectSettings(), onBoardLoaded(), OnModify(), OpenProjectFiles(), KIWAY_HOLDER::Prj(), SETTINGS_MANAGER::Prj(), SavePcbCopy(), SavePcbFile(), SETTINGS_MANAGER::SaveProject(), SaveProjectSettings(), BOARD::SetFileName(), SETTINGS_MANAGER::UnloadProject(), and UpdateTitle().

Referenced by Files_io(), BOARD_EDITOR_CONTROL::New(), BOARD_EDITOR_CONTROL::Open(), BOARD_EDITOR_CONTROL::Save(), BOARD_EDITOR_CONTROL::SaveAs(), and BOARD_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 179 of file pcb_edit_frame.h.

180  {
181  return FindWindowByName( pythonConsoleNameId() );
182  }
static const wxChar * pythonConsoleNameId()
Has meaning only if KICAD_SCRIPTING_WXPYTHON option is not defined.

References pythonConsoleNameId().

Referenced by setupUIConditions().

◆ FinishAUIInitialization()

void EDA_BASE_FRAME::FinishAUIInitialization ( )
inherited

Definition at line 698 of file eda_base_frame.cpp.

699 {
700 #if defined( __WXOSX_MAC__ )
701  m_auimgr.Update();
702 #else
703  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
704  // hidding it.
705  m_auimgr.Update();
706 
707  // We don't want the infobar displayed right away
708  m_auimgr.GetPane( "InfoBar" ).Hide();
709  m_auimgr.Update();
710 #endif
711 }
wxAuiManager m_auimgr

References EDA_BASE_FRAME::m_auimgr.

◆ FocusOnItem()

void PCB_BASE_FRAME::FocusOnItem ( BOARD_ITEM aItem)
inherited
Todo:
The Boost entropy exception does not exist prior to 1.67. Once the minimum Boost version is raise to 1.67 or greater, this version check can be removed.

Definition at line 184 of file pcb_base_frame.cpp.

185 {
186  static KIID lastBrightenedItemID( niluuid );
187 
188  BOARD_ITEM* lastItem = nullptr;
189 
192 #if BOOST_VERSION >= 106700
193  try
194  {
195  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
196  }
197  catch( const boost::uuids::entropy_error& e )
198  {
199  wxLogError( "A Boost UUID entropy exception was thrown in %s:%s.", __FILE__, __FUNCTION__ );
200  }
201 #else
202  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
203 #endif
204 
205  if( lastItem && lastItem != aItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
206  {
207  lastItem->ClearBrightened();
208 
209  if( lastItem->Type() == PCB_FOOTPRINT_T )
210  {
211  static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
212  [&]( BOARD_ITEM* child )
213  {
214  child->ClearBrightened();
215  } );
216  }
217  else if( lastItem->Type() == PCB_GROUP_T )
218  {
219  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
220  [&]( BOARD_ITEM* child )
221  {
222  child->ClearBrightened();
223  } );
224  }
225 
226  GetCanvas()->GetView()->Update( lastItem );
227  lastBrightenedItemID = niluuid;
228  GetCanvas()->Refresh();
229  }
230 
231  if( aItem )
232  {
233  aItem->SetBrightened();
234 
235  if( aItem->Type() == PCB_FOOTPRINT_T )
236  {
237  static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
238  [&]( BOARD_ITEM* child )
239  {
240  child->SetBrightened();
241  });
242  }
243  else if( aItem->Type() == PCB_GROUP_T )
244  {
245  static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
246  [&]( BOARD_ITEM* child )
247  {
248  child->SetBrightened();
249  });
250  }
251 
252  GetCanvas()->GetView()->Update( aItem );
253  lastBrightenedItemID = aItem->m_Uuid;
254  FocusOnLocation( aItem->GetFocusPosition() );
255  GetCanvas()->Refresh();
256  }
257 }
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:785
KIID niluuid(0)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual const wxPoint GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:307
void SetBrightened()
Definition: eda_item.h:178
void ClearBrightened()
Definition: eda_item.h:181
Definition: kiid.h:44
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:93
static DELETED_BOARD_ITEM * GetInstance()
Definition: board_item.h:398
virtual KIGFX::PCB_VIEW * GetView() const override
Return 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...
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
const KIID m_Uuid
Definition: eda_item.h:523
BOARD * GetBoard() const
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:161

References EDA_ITEM::ClearBrightened(), EDA_DRAW_FRAME::FocusOnLocation(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), EDA_ITEM::GetFocusPosition(), DELETED_BOARD_ITEM::GetInstance(), BOARD::GetItem(), PCB_DRAW_PANEL_GAL::GetView(), EDA_ITEM::m_Uuid, niluuid, PCB_FOOTPRINT_T, PCB_GROUP_T, EDA_DRAW_PANEL_GAL::Refresh(), EDA_ITEM::SetBrightened(), EDA_ITEM::Type(), and KIGFX::PCB_VIEW::Update().

Referenced by PCB_SELECTION_TOOL::Main(), DIALOG_FOOTPRINT_CHECKER::OnCancelClick(), DIALOG_DRC::OnCancelClick(), DIALOG_DRC::OnDRCItemSelected(), DIALOG_GROUP_PROPERTIES::OnMemberSelected(), DIALOG_GROUP_PROPERTIES::OnRemoveMember(), DIALOG_FOOTPRINT_CHECKER::OnSelectItem(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem(), DIALOG_CLEANUP_GRAPHICS::OnSelectItem(), DIALOG_DRC::~DIALOG_DRC(), and DIALOG_GROUP_PROPERTIES::~DIALOG_GROUP_PROPERTIES().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const wxPoint &  aPos)
inherited

Useful to focus on a particular location, in find functions.

Move the graphic cursor (crosshair cursor) at a given coordinate and reframes the drawing if the requested point is out of view or if center on location is requested.

Parameters
aPosis the point to go to.

Definition at line 785 of file eda_draw_frame.cpp.

786 {
787  bool centerView = false;
788  BOX2D r = GetCanvas()->GetView()->GetViewport();
789 
790  // Center if we're off the current view, or within 10% of its edge
791  r.Inflate( - (int) r.GetWidth() / 10 );
792 
793  if( !r.Contains( aPos ) )
794  centerView = true;
795 
796  // Center if we're behind an obscuring dialog, or within 10% of its edge
797  wxWindow* dialog = findDialog( GetChildren() );
798 
799  if( dialog )
800  {
801  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
802  dialog->GetSize() );
803  dialogRect.Inflate( dialogRect.GetWidth() / 10 );
804 
805  if( dialogRect.Contains( (wxPoint) GetCanvas()->GetView()->ToScreen( aPos ) ) )
806  centerView = true;
807  }
808 
809  if( centerView )
810  {
811  // If a dialog partly obscures the window, then center on the uncovered area.
812  if( dialog )
813  {
814  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
815  dialog->GetSize() );
816  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
817  }
818  else
819  GetCanvas()->GetView()->SetCenter( aPos );
820  }
821 
823 }
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:519
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return 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)
Set the center point of the VIEW (i.e.
Definition: view.cpp:585
coord_type GetWidth() const
Definition: box2.h:197
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:151
wxWindow * findDialog(wxWindowList &aList)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:302

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

Referenced by PCB_SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindNext(), PCB_BASE_FRAME::FocusOnItem(), SCH_EDIT_FRAME::FocusOnItem(), and DIALOG_FIND::search().

◆ GenD356File()

void PCB_EDIT_FRAME::GenD356File ( wxCommandEvent &  event)

Definition at line 362 of file export_d356.cpp.

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

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

Referenced by BOARD_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 500 of file gen_footprints_placefile.cpp.

501 {
502  wxFileName fn;
503 
504  wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName() ).GetPath();
505  wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
506 
507  if( dirDialog.ShowModal() == wxID_CANCEL )
508  return;
509 
510  fn = GetBoard()->GetFileName();
511  fn.SetPath( dirDialog.GetPath() );
512  fn.SetExt( wxT( "rpt" ) );
513 
514  bool unitMM = GetUserUnits() == EDA_UNITS::MILLIMETRES;
515  bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM );
516 
517  wxString msg;
518  if( success )
519  {
520  msg.Printf( _( "Footprint report file created:\n\"%s\"" ), fn.GetFullPath() );
521  wxMessageBox( msg, _( "Footprint Report" ), wxICON_INFORMATION );
522  }
523 
524  else
525  {
526  msg.Printf( _( "Unable to create \"%s\"" ), fn.GetFullPath() );
527  DisplayError( this, msg );
528  }
529 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
const wxString & GetFileName() const
Definition: board.h:281
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:33
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 MILLIMETRES.

Referenced by BOARD_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 85 of file pcb_base_frame.cpp.

86 {
87  return dynamic_cast<EDA_3D_VIEWER*>( FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) ) );
88 }
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
Definition: eda_3d_viewer.h:51

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 488 of file eda_base_frame.h.

488 { return m_aboutTitle; }
wxString m_aboutTitle

References EDA_BASE_FRAME::m_aboutTitle.

Referenced by DIALOG_ABOUT::DIALOG_ABOUT(), and COMMON_CONTROL::ReportBug().

◆ GetActiveLayer()