KiCad PCB EDA Suite
PCB_EDIT_FRAME Class Reference

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  UNDO_REDO_LIST { UNDO_LIST, REDO_LIST }
 Specifies whether we are interacting with the undo or redo stacks. More...
 
enum  HOLDER_TYPE { DIALOG, FRAME, PANEL }
 

Public Member Functions

virtual ~PCB_EDIT_FRAME ()
 
void LoadFootprints (NETLIST &aNetlist, REPORTER &aReporter)
 Load the footprints for each #SCH_COMPONENT in aNetlist from the list of libraries. More...
 
void OnQuit (wxCommandEvent &event)
 
bool IsContentModified () const override
 Get if the current board has been modified but not saved. 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 HardRedraw () override
 Rebuild the GAL and redraws the screen. 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). More...
 
void KiwayMailIn (KIWAY_EXPRESS &aEvent) override
 Receive KIWAY_EXPRESS messages from other players. More...
 
void ShowFindDialog ()
 Show the Find dialog. More...
 
void FindNext ()
 Find the next item using our existing search parameters. More...
 
void ToPlotter (int aID)
 Open a dialog frame to create plot and drill files relative to the current board. More...
 
void ExportSVG (wxCommandEvent &event)
 Show 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
 
void SetGridColor (const COLOR4D &aColor) override
 
void Process_Config (wxCommandEvent &event)
 
bool GetActionPluginButtonVisible (const wxString &aPluginPath, bool aPluginDefault)
 Return true if button visibility action plugin setting was set to true or it is unset and plugin defaults to true. More...
 
std::vector< ACTION_PLUGIN * > GetOrderedActionPlugins ()
 Return ordered list of plugins in sequence in which they should appear on toolbar or in settings. More...
 
void SaveProjectSettings () override
 Save 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 UpdateToolbarControlSizes () override
 Update the sizes of any controls in the toolbars of the frame. More...
 
void ReCreateLayerBox (bool aForceResizeToolbar=true)
 Recreate the layer box by clearing the old list and building a new one from the new layer names and colors. More...
 
void OnModify () override
 Must be called after a board change to set the modified flag. More...
 
void SetActiveLayer (PCB_LAYER_ID aLayer) override
 Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS. More...
 
void OnDisplayOptionsChanged () override
 
bool IsElementVisible (GAL_LAYER_ID aElement) const
 Test whether a given element category is visible. More...
 
void SetElementVisibility (GAL_LAYER_ID aElement, bool aNewState)
 Change the visibility of an element category. More...
 
void ActivateGalCanvas () override
 Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD. More...
 
void ShowBoardSetupDialog (const wxString &aInitialPage=wxEmptyString)
 
void PrepareLayerIndicator (bool aForceRebuild=false)
 
void ToggleLayersManager ()
 
int DoGenFootprintsPositionFile (const wxString &aFullFileName, bool aUnitsMM, bool aOnlySMD, bool aNoTHItems, bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin)
 Create an ASCII footprint position file. More...
 
void GenFootprintsReport (wxCommandEvent &event)
 Call DoGenFootprintsReport to create a footprint report file. More...
 
bool DoGenFootprintsReport (const wxString &aFullFilename, bool aUnitsMM)
 Create 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)
 Call Files_io_from_id with the wxCommandEvent id. More...
 
bool Files_io_from_id (int aId)
 Read and write board files according to aId. More...
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 Load a KiCad board (.kicad_pcb) from aFileName. More...
 
bool SavePcbFile (const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
 Write the board data structures to a aFileName. More...
 
bool SavePcbCopy (const wxString &aFileName, bool aCreateProject=false)
 Write the board data structures to aFileName. More...
 
bool Clear_Pcb (bool aQuery, bool aFinal=false)
 Delete all and reinitialize the current board. More...
 
void SetBoard (BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr) override
 Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD. More...
 
void SetBoard (BOARD *aBoard, bool aBuildConnectivity, PROGRESS_REPORTER *aReporter=nullptr)
 
BOARD_ITEM_CONTAINERGetModel () const override
 
void SetPageSettings (const PAGE_INFO &aPageSettings) override
 
void RecreateCmpFileFromBoard (wxCommandEvent &aEvent)
 Recreates a .cmp file from the current loaded board. More...
 
void ExportFootprintsToLibrary (bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=nullptr)
 Save footprints in a library: More...
 
void RecreateBOMFileFromBoard (wxCommandEvent &aEvent)
 Create a BOM file from the current loaded board. More...
 
void ExportToGenCAD (wxCommandEvent &event)
 Create a file in GenCAD 1.4 format from the current board. More...
 
void OnExportVRML (wxCommandEvent &event)
 Export the current BOARD to a VRML file. More...
 
bool ExportVRML_File (const wxString &aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles, bool aUseRelativePaths, const wxString &a3D_Subdir, double aXRef, double aYRef)
 Create the file(s) exporting current BOARD to a VRML file. More...
 
void OnExportIDF3 (wxCommandEvent &event)
 Export the current BOARD to a IDFv3 board and lib files. More...
 
void OnExportHyperlynx (wxCommandEvent &event)
 Export the current BOARD to a Hyperlynx HYP file. More...
 
bool Export_IDF3 (BOARD *aPcb, const wxString &aFullFileName, bool aUseThou, double aXRef, double aYRef)
 Create an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file. More...
 
void OnExportSTEP (wxCommandEvent &event)
 Export the current BOARD to a STEP assembly. More...
 
bool ExportSpecctraFile (const wxString &aFullFilename)
 Export the current BOARD to a specctra dsn file. More...
 
bool ImportSpecctraSession (const wxString &aFullFilename)
 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)
 Replace aExisting footprint by aNew footprint using the Existing footprint settings (position, orientation, pad netnames ...). More...
 
void OnEditItemRequest (BOARD_ITEM *aItem) override
 Install the corresponding dialog editor for the given item. More...
 
void SwitchLayer (PCB_LAYER_ID layer) override
 Change the active layer in the editor. More...
 
void SetTrackSegmentWidth (PCB_TRACK *aTrackItem, PICKED_ITEMS_LIST *aItemsListPicker, bool aUseNetclassValue)
 Modify one track segment width or one via diameter (using DRC control). More...
 
void Edit_Zone_Params (ZONE *zone_container)
 Edit params (layer, clearance, ...) for a zone outline. More...
 
void ShowTargetOptionsDialog (PCB_TARGET *aTarget)
 
void ShowDimensionPropertiesDialog (PCB_DIMENSION_BASE *aDimension)
 
void InstallNetlistFrame ()
 
bool FetchNetlistFromSchematic (NETLIST &aNetlist, const wxString &aAnnotateMessage)
 
bool TestStandalone (void)
 Test if standalone mode. More...
 
bool ReadNetlistFromFile (const wxString &aFilename, NETLIST &aNetlist, REPORTER &aReporter)
 Read 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)
 Send a message to the schematic editor so that it may move its cursor to a symbol with the same reference as the objectToSync. More...
 
void SendCrossProbeNetName (const wxString &aNetName)
 Send a net name to Eeschema for highlighting. More...
 
void ShowChangedLanguage () override
 Redraw the menus and what not in current language. More...
 
void UpdateTitle ()
 Set the main window title bar text. More...
 
void InstallPreferences (PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
 Allow 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 ThemeChanged () override
 Called when light/dark theme is changed. 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...
 
TOOL_ACTIONGetExportNetlistAction ()
 
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...
 
wxString CreateNewProjectLibrary (const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
 
bool AddLibrary (const wxString &aLibName=wxEmptyString, FP_LIB_TABLE *aTable=nullptr)
 Add an existing library to either the global or project library table. More...
 
void SaveCopyInUndoList (EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
 Create a new entry in undo list of commands. More...
 
void SaveCopyInUndoList (const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType) override
 Create a new entry in undo list of commands. More...
 
void RestoreCopyFromRedoList (wxCommandEvent &aEvent)
 Redo the last edit: More...
 
void RestoreCopyFromUndoList (wxCommandEvent &aEvent)
 Undo the last edit: More...
 
void RollbackFromUndo ()
 Perform an undo of the last edit without logging a corresponding redo. More...
 
void PutDataInPreviousState (PICKED_ITEMS_LIST *aList)
 Used in undo or redo command. More...
 
bool UndoRedoBlocked () const
 Check if the undo and redo operations are currently blocked. More...
 
void UndoRedoBlock (bool aBlock=true)
 Enable/disable undo and redo operations. More...
 
void SetGridVisibility (bool aVisible) override
 Override this function in the PCB_BASE_EDIT_FRAME to refill the layer widget. More...
 
void SetObjectVisible (GAL_LAYER_ID aLayer, bool aVisible=true)
 
int GetRotationAngle () const
 Return the angle used for rotate operations. More...
 
void SetRotationAngle (int aRotationAngle)
 Set the angle used for rotate operations. More...
 
void ShowTextPropertiesDialog (BOARD_ITEM *aText)
 
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
 Free the undo or redo list from List element. More...
 
wxString GetDesignRulesPath ()
 Return the absolute path to the design rules file for the currently-loaded board. More...
 
APPEARANCE_CONTROLSGetAppearancePanel ()
 
virtual void OnLayerAlphaChanged ()
 Notify the frame that the layer Alpha is being changed. More...
 
EDA_3D_VIEWER_FRAMEGet3DViewerFrame ()
 
virtual void Update3DView (bool aMarkDirty, bool aRefresh, 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 (const 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, bool aRefresh=true)
 Updates the current display options from the given options struct. More...
 
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) const override
 Fetch an item by KIID. More...
 
void FocusOnItem (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
 
void FocusOnItems (std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
 
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_VIEWER_FRAMECreateAndShow3D_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, bool aQuiet=false)
 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 SelectOneLayer (PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
 Show the dialog box for a 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...
 
bool LockFile (const wxString &aFileName)
 Mark a schematic file as being in use. More...
 
void ReleaseFile ()
 Release the current file marked in use. More...
 
void ScriptingConsoleEnableDisable ()
 Toggles the scripting console visibility. More...
 
bool IsScriptingConsoleVisible ()
 Gets the current visibility of the scripting console window. 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...
 
wxPoint GetNearestHalfGridPosition (const wxPoint &aPosition) const
 Return the nearest aGridSize / 2 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, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
 
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...
 
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) override
 Recalculate the size of toolbars and display panel when the frame size changes. More...
 
void OnMove (wxMoveEvent &aEvent) override
 
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 PrintDrawingSheet (const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
 Prints the drawing-sheet (frame and title block). More...
 
void DisplayToolMsg (const wxString &msg) override
 
void DisplayConstraintsMsg (const wxString &msg)
 
virtual void OnPageSettingsChange ()
 Called when modifying the page settings. More...
 
void DisplayUnitsMsg ()
 Display current unit pane in the status bar. More...
 
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)
 
void CreateServer (int service, bool local=true)
 
void OnSockRequest (wxSocketEvent &evt)
 
void OnSockRequestServer (wxSocketEvent &evt)
 
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 &aKeyEvent)
 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
 
FRAME_T GetFrameType () 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)
 Displays the preferences and settings of all opened editors paged dialog. More...
 
void PrintMsg (const wxString &text)
 
void CreateInfoBar ()
 
void FinishAUIInitialization ()
 
WX_INFOBARGetInfoBar ()
 
void ShowInfoBarError (const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
 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, bool aVerbose=true)
 Checks if aFileName can be written. More...
 
virtual 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)
 
virtual void HandleSystemColorChange ()
 Update the UI in response to a change in the system colors. More...
 
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
 Switch currently used canvas (Cairo / OpenGL). More...
 
void buildActionPluginMenus (ACTION_MENU *aActionMenu)
 Fill action menu with all registered action plugins. More...
 
void AddActionPluginTools ()
 Append action plugin buttons to main toolbar. More...
 
void RunActionPlugin (ACTION_PLUGIN *aActionPlugin)
 Execute action plugin's Run() method and updates undo buffer. More...
 
void OnActionPluginMenu (wxCommandEvent &aEvent)
 Launched by the menu when an action is called. More...
 
void OnActionPluginButton (wxCommandEvent &aEvent)
 Launched by the button when an action is called. More...
 
void onBoardLoaded ()
 Update the state of the GUI after a new board is loaded or created. More...
 
bool doAutoSave () override
 Perform auto save when the board has been modified and not saved within the auto save interval. More...
 
bool isAutoSaveRequired () const override
 Return 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)
 
FP_LIB_TABLEselectLibTable (bool aOptional=false)
 Prompts a user to select global or project library tables. More...
 
wxString createNewLibrary (const wxString &aLibName, const wxString &aProposedName, FP_LIB_TABLE *aTable)
 Create a new library in the given table (presumed to be either the global or project library table). More...
 
void handleActivateEvent (wxActivateEvent &aEvent) override
 Handle a window activation event. More...
 
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)
 
std::vector< wxWindow * > findDialogs ()
 
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 onActivate (wxActivateEvent &aEvent)
 
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...
 
void onSystemColorChange (wxSysColourChangedEvent &aEvent)
 
void initExitKey ()
 Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id. More...
 
void ensureWindowIsOnScreen ()
 

Static Protected Member Functions

static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
 
int m_rotationAngle
 
bool m_undoRedoBlocked
 
PANEL_SELECTION_FILTERm_selectionFilterPanel
 
APPEARANCE_CONTROLSm_appearancePanel
 
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
 
int m_displayIndex
 
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...
 

Private Attributes

TOOL_ACTIONm_exportNetlistAction
 The export board netlist tool action object. More...
 
DIALOG_FINDm_findDialog
 
wxTimer * m_eventCounterTimer
 

Friends

struct PCB::IFACE
 
class APPEARANCE_CONTROLS
 

Detailed Description

The main frame for Pcbnew.

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

Definition at line 70 of file pcb_edit_frame.h.

Member Enumeration Documentation

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 

Definition at line 39 of file kiway_holder.h.

◆ UNDO_REDO_LIST

Specifies whether we are interacting with the undo or redo stacks.

Enumerator
UNDO_LIST 
REDO_LIST 

Definition at line 109 of file eda_base_frame.h.

Constructor & Destructor Documentation

◆ ~PCB_EDIT_FRAME()

PCB_EDIT_FRAME::~PCB_EDIT_FRAME ( )
virtual

Definition at line 396 of file pcb_edit_frame.cpp.

397 {
398  if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
399  {
400  // Stop the timer during destruction early to avoid potential event race conditions (that do happen on windows)
401  m_eventCounterTimer->Stop();
402  delete m_eventCounterTimer;
403  }
404 
405  // Close modeless dialogs
406  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
407 
408  if( open_dlg )
409  open_dlg->Close( true );
410 
411  // Shutdown all running tools
412  if( m_toolManager )
414 
415  if( GetBoard() )
417 
418  delete m_selectionFilterPanel;
419  delete m_appearancePanel;
420  delete m_exportNetlistAction;
421 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
TOOL_ACTION * m_exportNetlistAction
The export board netlist tool action object.
APPEARANCE_CONTROLS * m_appearancePanel
wxTimer * m_eventCounterTimer
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1922
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
PANEL_SELECTION_FILTER * m_selectionFilterPanel
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BOARD * GetBoard() const

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

◆ PCB_EDIT_FRAME()

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

Member Function Documentation

◆ ActivateGalCanvas()

void PCB_EDIT_FRAME::ActivateGalCanvas ( )
overridevirtual

Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.

Parameters
aBoardis the BOARD to put into the frame.

Reimplemented from PCB_BASE_EDIT_FRAME.

Definition at line 961 of file pcb_edit_frame.cpp.

962 {
964  GetCanvas()->UpdateColors();
965  GetCanvas()->Refresh();
966 }
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void UpdateColors()
Update the color settings in the painter and GAL.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...

References PCB_BASE_EDIT_FRAME::ActivateGalCanvas().

Referenced by RunActionPlugin().

◆ AddActionPluginTools()

void PCB_EDIT_FRAME::AddActionPluginTools ( )
protected

Append action plugin buttons to main toolbar.

Definition at line 398 of file pcbnew_action_plugins.cpp.

399 {
400  bool need_separator = true;
401  const std::vector<ACTION_PLUGIN*>& orderedPlugins = GetOrderedActionPlugins();
402 
403  for( ACTION_PLUGIN* ap : orderedPlugins )
404  {
405  if( GetActionPluginButtonVisible( ap->GetPluginPath(), ap->GetShowToolbarButton() ) )
406  {
407  if( need_separator )
408  {
410  need_separator = false;
411  }
412 
413  // Add button
414  wxBitmap bitmap;
415 
416  if ( ap->iconBitmap.IsOk() )
417  bitmap = KiScaledBitmap( ap->iconBitmap, this );
418  else
419  bitmap = KiScaledBitmap( BITMAPS::puzzle_piece, this );
420 
421  wxAuiToolBarItem* button = m_mainToolBar->AddTool( wxID_ANY, wxEmptyString,
422  bitmap, ap->GetName() );
423 
424  Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
425  wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginButton ) );
426 
427  // Link action plugin to button
428  ACTION_PLUGINS::SetActionButton( ap, button->GetId() );
429  }
430  }
431 }
This is the parent class from where any action plugin class must derive.
Definition: action_plugin.h:38
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
ACTION_TOOLBAR * m_mainToolBar
bool GetActionPluginButtonVisible(const wxString &aPluginPath, bool aPluginDefault)
Return true if button visibility action plugin setting was set to true or it is unset and plugin defa...
std::vector< ACTION_PLUGIN * > GetOrderedActionPlugins()
Return ordered list of plugins in sequence in which they should appear on toolbar or in settings.
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:148
static void SetActionButton(ACTION_PLUGIN *aAction, int idButton)
Associate a button id to an action plugin.
void OnActionPluginButton(wxCommandEvent &aEvent)
Launched by the button when an action is called.

References ACTION_TOOLBAR::AddScaledSeparator(), GetActionPluginButtonVisible(), GetOrderedActionPlugins(), KiScaledBitmap(), EDA_DRAW_FRAME::m_mainToolBar, OnActionPluginButton(), puzzle_piece, and ACTION_PLUGINS::SetActionButton().

Referenced by ReCreateHToolbar().

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

178 {
179  if( aFootprint )
180  {
181  GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
182 
183  aFootprint->SetFlags( IS_NEW );
184  aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
185 
186  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
187  // built from a board)
188  if( aFootprint->IsFlipped() )
189  aFootprint->Flip( aFootprint->GetPosition(), m_settings->m_FlipLeftRight );
190 
191  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
192  // it might be stored in another orientation if the lib is an archive built from a board)
193  aFootprint->SetOrientation( 0 );
194  }
195 }
#define IS_NEW
New item, just created.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
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:608
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1681
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1491
bool IsFlipped() const
Definition: footprint.h:281
wxPoint GetPosition() const override
Definition: footprint.h:187
BOARD * GetBoard() const
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1562

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,
FP_LIB_TABLE aTable = nullptr 
)
inherited

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

547 {
548  if( aTable == nullptr )
549  aTable = selectLibTable();
550 
551  if( aTable == nullptr )
552  return wxEmptyString;
553 
554  bool isGlobal = ( aTable == &GFootprintTable );
555 
556  wxFileName fn( aFilename );
557 
558  if( aFilename.IsEmpty() )
559  {
561  KiCadFootprintLibPathExtension, true, isGlobal,
563  {
564  return false;
565  }
566  }
567 
568  wxString libPath = fn.GetFullPath();
569  wxString libName = fn.GetName();
570 
571  if( libName.IsEmpty() )
572  return false;
573 
574  wxString type = IO_MGR::ShowType( IO_MGR::GuessPluginTypeFromLibPath( libPath ) );
575 
576  // try to use path normalized to an environmental variable or project path
577  wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
578 
579  try
580  {
581  FP_LIB_TABLE_ROW* row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
582  aTable->InsertRow( row );
583 
584  if( isGlobal )
586  else
587  Prj().PcbFootprintLibs()->Save( Prj().FootprintLibTblName() );
588  }
589  catch( const IO_ERROR& ioe )
590  {
591  DisplayError( this, ioe.What() );
592  return false;
593  }
594 
596 
597  if( editor )
598  {
599  LIB_ID libID( libName, wxEmptyString );
600  editor->SyncLibraryTree( true );
601  editor->FocusOnLibID( libID );
602  }
603 
604  auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
605 
606  if( viewer )
607  viewer->ReCreateLibraryList();
608 
609  return true;
610 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
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.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
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:393
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:106
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:30
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
wxString KiCadFootprintLibPathWildcard()
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:108
FP_LIB_TABLE * selectLibTable(bool aOptional=false)
Prompts a user to select global or project library tables.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
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)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
static wxString GetGlobalTableFileName()

References DisplayError(), editor, FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_VIEWER, PATHS::GetDefaultUserFootprintsPath(), FP_LIB_TABLE::GetGlobalTableFileName(), GFootprintTable, IO_MGR::GuessPluginTypeFromLibPath(), LIB_TABLE::InsertRow(), KiCadFootprintLibPathExtension, KiCadFootprintLibPathWildcard(), KIWAY_HOLDER::Kiway(), EDA_DRAW_FRAME::LibraryFileBrowser(), NormalizePath(), PROJECT::PcbFootprintLibs(), Pgm(), KIWAY::Player(), KIWAY_HOLDER::Prj(), LIB_TABLE::Save(), PCB_BASE_EDIT_FRAME::selectLibTable(), 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 460 of file eda_base_frame.cpp.

461 {
462  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
463  ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
464 
465  helpMenu->Add( ACTIONS::help );
466  helpMenu->Add( ACTIONS::gettingStarted );
467  helpMenu->Add( ACTIONS::listHotKeys );
468  helpMenu->Add( ACTIONS::getInvolved );
469  helpMenu->Add( ACTIONS::donate );
470  helpMenu->Add( ACTIONS::reportBug );
471 
472  helpMenu->AppendSeparator();
473  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
474 
475  // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
476  aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
477 }
static TOOL_ACTION listHotKeys
Definition: actions.h:179
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
static TOOL_ACTION reportBug
Cursor control event types.
Definition: actions.h:182
static TOOL_ACTION donate
Definition: actions.h:180
#define _(s)
Handle actions that are shared between different applications.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION help
Definition: actions.h:178
static TOOL_ACTION getInvolved
Definition: actions.h:181
static TOOL_ACTION gettingStarted
Definition: actions.h:177

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

Referenced by EDA_3D_VIEWER_FRAME::CreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), SCH_EDIT_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 492 of file eda_draw_frame.cpp.

493 {
494  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
495  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
496 
497  aMenu.AddSeparator( 1000 );
498 
499  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
500  zoomMenu->SetTool( commonTools );
501  aToolMenu.AddSubMenu( zoomMenu );
502 
503  auto gridMenu = std::make_shared<GRID_MENU>( this );
504  gridMenu->SetTool( commonTools );
505  aToolMenu.AddSubMenu( gridMenu );
506 
507  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
508  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
509 }
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:158

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(), PL_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), PCB_SELECTION_TOOL::Init(), and PICKER_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 652 of file eda_draw_frame.cpp.

654 {
655  if( m_messagePanel )
656  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
657 }
EDA_MSG_PANEL * m_messagePanel
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:94

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

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

◆ buildActionPluginMenus()

void PCB_EDIT_FRAME::buildActionPluginMenus ( ACTION_MENU aActionMenu)
protected

Fill action menu with all registered action plugins.

Definition at line 376 of file pcbnew_action_plugins.cpp.

377 {
378  if( !actionMenu ) // Should not occur.
379  return;
380 
381  for( int ii = 0; ii < ACTION_PLUGINS::GetActionsCount(); ii++ )
382  {
383  wxMenuItem* item;
385  const wxBitmap& bitmap = ap->iconBitmap.IsOk() ? ap->iconBitmap :
387 
388  item = AddMenuItem( actionMenu, wxID_ANY, ap->GetName(), ap->GetDescription(), bitmap );
389 
390  Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
391  wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginMenu ) );
392 
393  ACTION_PLUGINS::SetActionMenu( ii, item->GetId() );
394  }
395 }
virtual wxString GetName()=0
This is the parent class from where any action plugin class must derive.
Definition: action_plugin.h:38
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Definition: bitmap.cpp:257
virtual wxString GetDescription()=0
wxBitmap iconBitmap
void OnActionPluginMenu(wxCommandEvent &aEvent)
Launched by the menu when an action is called.
static int GetActionsCount()
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
static ACTION_PLUGIN * GetAction(const wxString &aName)
static void SetActionMenu(int aIndex, int idMenu)
Associate a menu id to an action plugin.

References AddMenuItem(), ACTION_PLUGINS::GetAction(), ACTION_PLUGINS::GetActionsCount(), ACTION_PLUGIN::GetDescription(), ACTION_PLUGIN::GetName(), ACTION_PLUGIN::iconBitmap, KiBitmap(), OnActionPluginMenu(), puzzle_piece, and ACTION_PLUGINS::SetActionMenu().

Referenced by ReCreateMenuBar().

◆ canCloseWindow()

bool PCB_EDIT_FRAME::canCloseWindow ( wxCloseEvent &  aCloseEvent)
overrideprotectedvirtual

Reimplemented from PCB_BASE_FRAME.

Definition at line 841 of file pcb_edit_frame.cpp.

842 {
843  // Shutdown blocks must be determined and vetoed as early as possible
844  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
845  && IsContentModified() )
846  {
847  return false;
848  }
849 
850  if( Kiface().IsSingle() )
851  {
852  auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
853 
854  if( fpEditor && !fpEditor->Close() ) // Can close footprint editor?
855  return false;
856 
857  auto* fpViewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
858 
859  if( fpViewer && !fpViewer->Close() ) // Can close footprint viewer?
860  return false;
861 
863 
864  if( fpViewer && !fpViewer->Close() ) // Can close modal footprint viewer?
865  return false;
866  }
867  else
868  {
869  auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
870 
871  if( fpEditor && fpEditor->IsCurrentFPFromBoard() )
872  {
873  if( !fpEditor->CanCloseFPFromBoard( true ) )
874  return false;
875  }
876  }
877 
878  if( IsContentModified() )
879  {
880  wxFileName fileName = GetBoard()->GetFileName();
881  wxString msg = _( "Save changes to '%s' before closing?" );
882 
883  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
884  [&]() -> bool
885  {
887  } ) )
888  {
889  return false;
890  }
891  }
892 
893  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
894  // board.
895  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
896 
897  if( open_dlg )
898  open_dlg->Close( true );
899 
900  return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
901 }
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:239
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
bool IsContentModified() const override
Get if the current board has been modified but not saved.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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:393
const wxString & GetFileName() const
Definition: board.h:229
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
#define _(s)
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
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
bool Files_io_from_id(int aId)
Read and write board files according to aId.
BOARD * GetBoard() const
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:104

References _, PCB_BASE_FRAME::canCloseWindow(), DIALOG_DRC_WINDOW_NAME, Format(), FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_VIEWER, FRAME_FOOTPRINT_VIEWER_MODAL, GetBoard(), BOARD::GetFileName(), HandleUnsavedChanges(), ID_SAVE_BOARD, KIFACE_BASE::IsSingle(), Kiface(), Kiway, KIWAY::Player(), and KIPLATFORM::APP::SupportsShutdownBlockReason().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1203 of file eda_base_frame.cpp.

1204 {
1205  SetUserUnits( aUnits );
1207 
1208  wxCommandEvent e( UNITS_CHANGED );
1209  ProcessEventLocally( e );
1210 }
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)
virtualinherited

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.

Reimplemented in SCH_EDIT_FRAME.

Definition at line 1091 of file eda_base_frame.cpp.

1092 {
1093  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1094 
1095  wxFileName autoSaveFileName = aFileName;
1096 
1097  // Check for auto save file.
1098  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
1099 
1100  wxLogTrace( traceAutoSave,
1101  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
1102 
1103  if( !autoSaveFileName.FileExists() )
1104  return;
1105 
1106  wxString msg = wxString::Format( _(
1107  "Well this is potentially embarrassing!\n"
1108  "It appears that the last time you were editing the file\n"
1109  "%s\n"
1110  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
1111  aFileName.GetFullName()
1112  );
1113 
1114  int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1115  this );
1116 
1117  // Make a backup of the current file, delete the file, and rename the auto save file to
1118  // the file name.
1119  if( response == wxYES )
1120  {
1121  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
1122  {
1123  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
1124  Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1125  }
1126  }
1127  else
1128  {
1129  wxLogTrace( traceAutoSave,
1130  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
1131 
1132  // Remove the auto save file when using the previous file as is.
1133  wxRemoveFile( autoSaveFileName.GetFullPath() );
1134  }
1135 }
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:106
#define _(s)
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()

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

Referenced by OpenProjectFiles().

◆ Clear_Pcb()

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

Delete all and reinitialize the current board.

Parameters
aQuerytrue to prompt user for confirmation, false to initialize silently.
aFinalif true, we are clearing the board to exit, so don't run more events.Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
aBoardis the BOARD to put into the frame.

Definition at line 43 of file initpcb.cpp.

44 {
45  if( GetBoard() == nullptr )
46  return false;
47 
48  if( aQuery && !GetBoard()->IsEmpty() )
49  {
50  if( !IsOK( this, _( "Current Board will be lost and this operation cannot be undone. "
51  "Continue?" ) ) )
52  {
53  return false;
54  }
55  }
56 
57  // Release the lock file, if exists
58  ReleaseFile();
59 
60  // Clear undo and redo lists because we want a full deletion
62  GetScreen()->SetContentModified( false );
63 
64  if( !aFinal )
65  {
66  // delete the old BOARD and create a new BOARD so that the default
67  // layer names are put into the BOARD.
68  SetBoard( new BOARD() );
69 
70  // clear filename, to avoid overwriting an old file
71  GetBoard()->SetFileName( wxEmptyString );
72 
74 
76 
77  // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
78  GetBoard()->SetEnabledLayers( LSET().set() );
79 
80  // Default copper layers count set to 2: double layer board
82 
83  // Update display (some options depend on the board setup)
84  GetBoard()->SetVisibleLayers( LSET().set() );
88  UpdateTitle();
89 
90  Zoom_Automatique( false );
91  }
92 
93  return true;
94 }
void UpdateTitle()
Set the main window title bar text.
APPEARANCE_CONTROLS * m_appearancePanel
void SetCopperLayerCount(int aCount)
Definition: board.cpp:461
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Recreate the layer box by clearing the old list and building a new one from the new layer names and c...
void ReleaseFile()
Release the current file marked in use.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:46
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.
Definition: layer_ids.h:516
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:1946
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:499
void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr) override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
#define _(s)
void SetFileName(const wxString &aFileName)
Definition: board.h:227
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
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:323
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.
Definition: board.cpp:487
void ReCreateAuxiliaryToolbar() override

References _, EDA_BASE_FRAME::ClearUndoRedoList(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetPageSizeIU(), PCB_BASE_FRAME::GetScreen(), BASE_SCREEN::InitDataPoints(), IsOK(), PCB_BASE_EDIT_FRAME::m_appearancePanel, APPEARANCE_CONTROLS::OnBoardChanged(), ReCreateAuxiliaryToolbar(), ReCreateLayerBox(), EDA_DRAW_FRAME::ReleaseFile(), BOARD::ResetNetHighLight(), SetBoard(), BASE_SCREEN::SetContentModified(), 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 976 of file eda_base_frame.cpp.

977 {
978  if( !aFileHistory )
979  aFileHistory = m_fileHistory;
980 
981  wxASSERT( aFileHistory );
982 
983  aFileHistory->ClearFileHistory();
984 
985  // Update the menubar to update the file history menu
986  if( GetMenuBar() )
987  {
988  ReCreateMenuBar();
989  GetMenuBar()->Refresh();
990  }
991 }
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

Free the undo or redo list from List element.

Wrappers are deleted. Data 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). Items are removed from the beginning of the list so this function can be called to remove old commands.

Parameters
whichListthe UNDO_REDO_CONTAINER to clear.
aItemCountthe count of items to remove. < 0 for all items.

Reimplemented from EDA_BASE_FRAME.

Definition at line 551 of file undo_redo.cpp.

552 {
553  if( aItemCount == 0 )
554  return;
555 
556  UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
557  unsigned icnt = list.m_CommandsList.size();
558 
559  if( aItemCount > 0 )
560  icnt = aItemCount;
561 
562  for( unsigned ii = 0; ii < icnt; ii++ )
563  {
564  if( list.m_CommandsList.size() == 0 )
565  break;
566 
567  PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
568  list.m_CommandsList.erase( list.m_CommandsList.begin() );
569 
570  curr_cmd->ClearListAndDeleteItems();
571  delete curr_cmd; // Delete command
572  }
573 }
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 1734 of file pcb_edit_frame.cpp.

1735 {
1736  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1737 
1739 
1740  // Netclass definitions could have changed, either by us or by Eeschema
1741  DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1742  WX_INFOBAR* infobar = GetInfoBar();
1743 
1744  try
1745  {
1746  drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1747 
1748  if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR )
1749  infobar->Dismiss();
1750  }
1751  catch( PARSE_ERROR& )
1752  {
1753  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
1754  wxEmptyString );
1755 
1756  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1757  [&]( wxHyperlinkEvent& aEvent )
1758  {
1759  ShowBoardSetupDialog( _( "Custom Rules" ) );
1760  } ) );
1761 
1762  infobar->RemoveAllButtons();
1763  infobar->AddButton( button );
1764  infobar->AddCloseButton();
1765  infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR,
1767  }
1768 
1769  // Update the environment variables in the Python interpreter
1770  if( aEnvVarsChanged )
1772 
1773  Layout();
1774  SendSizeEvent();
1775 }
wxString GetDesignRulesPath()
Return 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.
APPEARANCE_CONTROLS * GetAppearancePanel()
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
#define _(s)
void PythonSyncEnvironmentVariables()
Synchronize the environment variables from KiCad's environment into the Python interpreter.
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition: drc_tool.h:78
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
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:158
WX_INFOBAR * GetInfoBar()
void OnColorThemeChanged()
Update the widget when the active board layer is changed.

References _, PCB_BASE_FRAME::CommonSettingsChanged(), WX_INFOBAR::DRC_RULES_ERROR, 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 40 of file ratsnest.cpp.

41 {
42  GetBoard()->GetConnectivity()->RecalculateRatsnest();
43 
44  if( aDisplayStatus )
45  SetMsgPanel( m_pcb );
46 }
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:345
BOARD * GetBoard() const

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

Referenced by DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), DIALOG_GLOBAL_DELETION::DoGlobalDeletions(), ExportToGenCAD(), DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked(), 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 SYMBOL_EDIT_FRAME, KICAD_MANAGER_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 816 of file eda_base_frame.cpp.

817 {
818  // KICAD_MANAGER_FRAME overrides this
819  return Kiface().KifaceSettings();
820 }
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:92

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

Referenced by GERBVIEW_FRAME::ActivateGalCanvas(), PCB_BASE_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(), GRID_MENU::GRID_MENU(), COMMON_TOOLS::GridFast1(), COMMON_TOOLS::GridFast2(), EDA_DRAW_FRAME::IsGridVisible(), SCH_BASE_FRAME::libeditconfig(), EDA_DRAW_FRAME::OnUpdateSelectGrid(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), GERBVIEW_FRAME::Read_EXCELLON_File(), DIALOG_GRID_SETTINGS::RebuildGridSizes(), EDA_DRAW_FRAME::resolveCanvasType(), PCB_BASE_EDIT_FRAME::SetBoard(), EDA_DRAW_FRAME::SetGridVisibility(), PL_EDITOR_FRAME::setupTools(), SYMBOL_VIEWER_FRAME::setupTools(), CVPCB_MAINFRAME::setupTools(), GERBVIEW_FRAME::setupTools(), SCH_EDIT_FRAME::setupTools(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataToWindow(), ZOOM_MENU::update(), GRID_MENU::update(), EDA_DRAW_FRAME::UpdateGridSelectBox(), EDA_DRAW_FRAME::UpdateZoomSelectBox(), EDA_BASE_FRAME::windowClosing(), 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 358 of file eda_base_frame.h.

359  {
360  wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
361  return baseCfgName;
362  }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

Referenced by EDA_BASE_FRAME::SaveWindowSettings().

◆ CreateAndShow3D_Frame()

EDA_3D_VIEWER_FRAME * 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 603 of file pcb_base_frame.cpp.

604 {
605  EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
606 
607  if( !draw3DFrame )
608  draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
609 
610  // Raising the window does not show the window on Windows if iconized. This should work
611  // on any platform.
612  if( draw3DFrame->IsIconized() )
613  draw3DFrame->Iconize( false );
614 
615  draw3DFrame->Raise();
616  draw3DFrame->Show( true );
617 
618  // Raising the window does not set the focus on Linux. This should work on any platform.
619  if( wxWindow::FindFocus() != draw3DFrame )
620  draw3DFrame->SetFocus();
621 
622  // Allocate a slice of time to display the 3D frame
623  // a call to wxSafeYield() should be enough (and better), but on Linux we need
624  // to call wxYield()
625  // otherwise the activity messages are not displayed during the first board loading
626  wxYield();
627 
628  // Note, the caller is responsible to load/update the board 3D view.
629  // after frame creation the board is not automatically created.
630 
631  return draw3DFrame;
632 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
EDA_3D_VIEWER_FRAME * Get3DViewerFrame()
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
#define _(s)

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

842 {
843 #if defined( __WXOSX_MAC__ )
845 #else
846  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
847 
848  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxT( "InfoBar" ) ).Top().Layer(1) );
849 #endif
850 }
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:73
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,
bool  aQuiet = false 
)
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.
aQuietprevents user dialogs from being shown

Definition at line 1136 of file footprint_libraries_utils.cpp.

1137 {
1138  wxString footprintName = aFootprintName;
1139 
1140  // Static to store user preference for a session
1141  static int footprintType = 1;
1142  int footprintTranslated = FP_SMD;
1143 
1144  // Ask for the new footprint name
1145  if( footprintName.IsEmpty() && !aQuiet )
1146  {
1147  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
1148  footprintName, _( "Footprint type:" ),
1149  { _( "Through hole" ), _( "SMD" ), _( "Other" ) },
1150  footprintType );
1151  dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &footprintName ) );
1152 
1153  if( dlg.ShowModal() != wxID_OK )
1154  return nullptr; //Aborted by user
1155 
1156  footprintType = dlg.GetChoice();
1157 
1158  switch( footprintType )
1159  {
1160  case 0:
1161  footprintTranslated = FP_THROUGH_HOLE;
1162  break;
1163  case 1:
1164  footprintTranslated = FP_SMD;
1165  break;
1166  default:
1167  footprintTranslated = 0;
1168  }
1169  }
1170 
1171  footprintName.Trim( true );
1172  footprintName.Trim( false );
1173 
1174  if( footprintName.IsEmpty() )
1175  {
1176  if( !aQuiet )
1177  DisplayInfoMessage( this, _( "No footprint name defined." ) );
1178 
1179  return nullptr;
1180  }
1181 
1182  // Creates the new footprint and add it to the head of the linked list of footprints
1183  FOOTPRINT* footprint = new FOOTPRINT( GetBoard() );
1184 
1185  // Update its name in lib
1186  footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
1187 
1188  footprint->SetAttributes( footprintTranslated );
1189 
1190  PCB_LAYER_ID txt_layer;
1191  wxPoint default_pos;
1193 
1194  footprint->Reference().SetText( settings.m_DefaultFPTextItems[0].m_Text );
1195  footprint->Reference().SetVisible( settings.m_DefaultFPTextItems[0].m_Visible );
1196  txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[0].m_Layer;
1197  footprint->Reference().SetLayer( txt_layer );
1198  default_pos.y -= settings.GetTextSize( txt_layer ).y / 2;
1199  footprint->Reference().SetPosition( default_pos );
1200  default_pos.y += settings.GetTextSize( txt_layer ).y;
1201 
1202  footprint->Value().SetText( settings.m_DefaultFPTextItems[1].m_Text );
1203  footprint->Value().SetVisible( settings.m_DefaultFPTextItems[1].m_Visible );
1204  txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[1].m_Layer;
1205  footprint->Value().SetLayer( txt_layer );
1206  default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
1207  footprint->Value().SetPosition( default_pos );
1208  default_pos.y += settings.GetTextSize( txt_layer ).y;
1209 
1210  for( size_t i = 2; i < settings.m_DefaultFPTextItems.size(); ++i )
1211  {
1212  FP_TEXT* textItem = new FP_TEXT( footprint );
1213  textItem->SetText( settings.m_DefaultFPTextItems[i].m_Text );
1214  textItem->SetVisible( settings.m_DefaultFPTextItems[i].m_Visible );
1215  txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[i].m_Layer;
1216  textItem->SetLayer( txt_layer );
1217  default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
1218  textItem->SetPosition( default_pos );
1219  default_pos.y += settings.GetTextSize( txt_layer ).y;
1220  footprint->GraphicalItems().push_back( textItem );
1221  }
1222 
1223  if( footprint->GetReference().IsEmpty() )
1224  footprint->SetReference( footprintName );
1225 
1226  if( footprint->GetValue().IsEmpty() )
1227  footprint->SetValue( footprintName );
1228 
1229  footprint->RunOnChildren(
1230  [&] ( BOARD_ITEM* aChild )
1231  {
1232  if( aChild->Type() == PCB_FP_TEXT_T )
1233  {
1234  FP_TEXT* textItem = static_cast<FP_TEXT*>( aChild );
1235  PCB_LAYER_ID layer = textItem->GetLayer();
1236 
1237  textItem->SetTextThickness( settings.GetTextThickness( layer ) );
1238  textItem->SetTextSize( settings.GetTextSize( layer ) );
1239  textItem->SetItalic( settings.GetTextItalic( layer ) );
1240  textItem->SetKeepUpright( settings.GetTextUpright( layer ) );
1241  }
1242  } );
1243 
1244  SetMsgPanel( footprint );
1245  return footprint;
1246 }
void SetReference(const wxString &aReference)
Definition: footprint.h:475
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:93
const wxString & GetValue() const
Definition: footprint.h:488
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetItalic(bool isItalic)
Definition: eda_text.h:200
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
void SetTextValidator(wxTextValidatorStyle style)
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
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.
void SetAttributes(int aAttributes)
Definition: footprint.h:240
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:502
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:503
bool GetTextItalic(PCB_LAYER_ID aLayer) const
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
const wxString & GetReference() const
Definition: footprint.h:466
#define _(s)
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
void SetValue(const wxString &aValue)
Definition: footprint.h:496
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:196
void SetKeepUpright(bool aKeepUpright)
Definition: fp_text.h:115
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1299
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
BOARD * GetBoard() const
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
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:112
Container for design settings for a BOARD object.

References _, DisplayInfoMessage(), FP_SMD, FP_THROUGH_HOLE, 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::SetAttributes(), FOOTPRINT::SetFPID(), EDA_TEXT::SetItalic(), FP_TEXT::SetKeepUpright(), 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 initial path and filename shown in the file chooser dialog.
Returns
The newly created library path if library was successfully created, else wxEmptyString because user aborted or error.

Definition at line 392 of file footprint_libraries_utils.cpp.

394 {
395  FP_LIB_TABLE* table = selectLibTable();
396 
397  return createNewLibrary( aLibName, aProposedName, table );
398 }
FP_LIB_TABLE * selectLibTable(bool aOptional=false)
Prompts a user to select global or project library tables.
wxString createNewLibrary(const wxString &aLibName, const wxString &aProposedName, FP_LIB_TABLE *aTable)
Create a new library in the given table (presumed to be either the global or project library table).

References PCB_BASE_EDIT_FRAME::createNewLibrary(), and PCB_BASE_EDIT_FRAME::selectLibTable().

Referenced by ExportFootprintsToLibrary().

◆ createNewLibrary()

wxString PCB_BASE_EDIT_FRAME::createNewLibrary ( const wxString &  aLibName,
const wxString &  aProposedName,
FP_LIB_TABLE aTable 
)
protectedinherited

Create a new library in the given table (presumed to be either the global or project library table).

Definition at line 401 of file footprint_libraries_utils.cpp.

404 {
405  // Kicad cannot write legacy format libraries, only .pretty new format because the legacy
406  // format cannot handle current features.
407  // The footprint library is actually a directory.
408 
409  if( aTable == nullptr )
410  return wxEmptyString;
411 
412  wxString initialPath = aProposedName.IsEmpty() ? Prj().GetProjectPath() : aProposedName;
413  wxFileName fn;
414  bool doAdd = false;
415  bool isGlobal = ( aTable == &GFootprintTable );
416 
417  if( aLibName.IsEmpty() )
418  {
419  fn = initialPath;
420 
422  KiCadFootprintLibPathExtension, false, isGlobal,
424  {
425  return wxEmptyString;
426  }
427 
428  doAdd = true;
429  }
430  else
431  {
432  fn = aLibName;
433 
434  if( !fn.IsAbsolute() )
435  {
436  fn.SetName( aLibName );
437  fn.MakeAbsolute( initialPath );
438  }
439 
440  // Enforce the .pretty extension:
441  fn.SetExt( KiCadFootprintLibPathExtension );
442  }
443 
444  // We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries)
446  wxString libPath = fn.GetFullPath();
447 
448  try
449  {
450  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
451 
452  bool writable = false;
453  bool exists = false;
454 
455  try
456  {
457  writable = pi->IsFootprintLibWritable( libPath );
458  exists = true; // no exception was thrown, lib must exist.
459  }
460  catch( const IO_ERROR& )
461  {
462  // best efforts....
463  }
464 
465  if( exists )
466  {
467  if( !writable )
468  {
469  wxString msg = wxString::Format( _( "Library %s is read only." ), libPath );
470  ShowInfoBarError( msg );
471  return wxEmptyString;
472  }
473  else
474  {
475  wxString msg = wxString::Format( _( "Library %s already exists." ), libPath );
476  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
477  dlg.SetOKLabel( _( "Overwrite" ) );
478  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
479 
480  if( dlg.ShowModal() == wxID_CANCEL )
481  return wxEmptyString;
482 
483  pi->FootprintLibDelete( libPath );
484  }
485  }
486 
487  pi->FootprintLibCreate( libPath );
488  }
489  catch( const IO_ERROR& ioe )
490  {
491  DisplayError( this, ioe.What() );
492  return wxEmptyString;
493  }
494 
495  if( doAdd )
496  AddLibrary( libPath, aTable );
497 
498  return libPath;
499 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:555
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
#define _(s)
bool AddLibrary(const wxString &aLibName=wxEmptyString, FP_LIB_TABLE *aTable=nullptr)
Add an existing library to either the global or project library table.
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()
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:108
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
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:53
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:56

References _, PCB_BASE_EDIT_FRAME::AddLibrary(), DisplayError(), KIDIALOG::DoNotShowCheckbox(), Format(), PATHS::GetDefaultUserFootprintsPath(), PROJECT::GetProjectPath(), GFootprintTable, 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 PCB_BASE_EDIT_FRAME::CreateNewLibrary(), and PCB_BASE_EDIT_FRAME::CreateNewProjectLibrary().

◆ CreateNewProjectLibrary()

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

Definition at line 385 of file footprint_libraries_utils.cpp.

387 {
388  return createNewLibrary( aLibName, aProposedName, Prj().PcbFootprintLibs() );
389 }
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString createNewLibrary(const wxString &aLibName, const wxString &aProposedName, FP_LIB_TABLE *aTable)
Create a new library in the given table (presumed to be either the global or project library table).

References PCB_BASE_EDIT_FRAME::createNewLibrary(), and KIWAY_HOLDER::Prj().

Referenced by OpenProjectFiles().

◆ CreateServer()

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

Definition at line 43 of file eda_dde.cpp.

44 {
45  wxIPV4address addr;
46 
47  // Set the port number
48  addr.Service( service );
49 
50  // Listen on localhost only if requested
51  if( local )
52  addr.Hostname( HOSTNAME );
53 
54  delete m_socketServer;
55  m_socketServer = new wxSocketServer( addr );
56 
57  m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
58  m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
59  m_socketServer->Notify( true );
60 }
static const wxString HOSTNAME(wxT("localhost"))
wxSocketServer * m_socketServer
Definition: kiway_player.h:218

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

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

◆ CurrentToolName()

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

Definition at line 100 of file tools_holder.cpp.

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

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

Referenced by TOOL_MANAGER::processEvent(), and TOOLS_HOLDER::ShowChangedLanguage().

◆ Destroy()

◆ DismissModal()

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

Definition at line 166 of file kiway_player.cpp.

167 {
168  m_modal_ret_val = aRetVal;
169  m_modal_string = aResult;
170 
171  if( m_modal_loop )
172  {
173  m_modal_loop->Exit();
174  m_modal_loop = nullptr; // this marks it as dismissed.
175  }
176 
177  Show( false );
178 }
bool m_modal_ret_val
Definition: kiway_player.h:216
wxString m_modal_string
Definition: kiway_player.h:215
WX_EVENT_LOOP * m_modal_loop
< Points to nested event_loop. NULL means not modal and dismissed.
Definition: kiway_player.h:213

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

◆ DisplayConstraintsMsg()

void EDA_DRAW_FRAME::DisplayConstraintsMsg ( const wxString &  msg)
inherited

Definition at line 518 of file eda_draw_frame.cpp.

519 {
520  SetStatusText( msg, 7 );
521 }

Referenced by DRAWING_TOOL::updateStatusBar().

◆ DisplayGridMsg()

void PCB_BASE_FRAME::DisplayGridMsg ( )
overridevirtualinherited

Display the current grid pane on the status bar.

Reimplemented from EDA_DRAW_FRAME.

Definition at line 702 of file pcb_base_frame.cpp.

703 {
704  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
705  wxString line;
706 
707  line.Printf( wxT( "grid X %s Y %s" ),
708  MessageTextFromValue( m_userUnits, gridSize.x, false ),
709  MessageTextFromValue( m_userUnits, gridSize.y, false ) );
710 
711  SetStatusText( line, 4 );
712 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
const VECTOR2D & GetGridSize() const
Return the grid size.
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.

References PCB_BASE_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetGAL(), KIGFX::GAL::GetGridSize(), EDA_BASE_FRAME::m_userUnits, MessageTextFromValue(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_BASE_FRAME::UpdateStatusBar().

◆ DisplayToolMsg()

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

Reimplemented from TOOLS_HOLDER.

Definition at line 512 of file eda_draw_frame.cpp.

513 {
514  SetStatusText( msg, 6 );
515 }

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 536 of file eda_draw_frame.cpp.

537 {
538  wxString msg;
539 
540  switch( m_userUnits )
541  {
542  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
543  case EDA_UNITS::MILS: msg = _( "mils" ); break;
544  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
545  default: msg = _( "Units" ); break;
546  }
547 
548  SetStatusText( msg, 5 );
549 }
#define _(s)
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

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

1162 {
1163  wxFileName tmpFileName;
1164 
1165  // Don't run autosave if content has not been modified
1166  if( !IsContentModified() )
1167  return true;
1168 
1169  wxString title = GetTitle(); // Save frame title, that can be modified by the save process
1170 
1171  if( GetBoard()->GetFileName().IsEmpty() )
1172  {
1173  tmpFileName = wxFileName( PATHS::GetDefaultUserProjectsPath(), NAMELESS_PROJECT,
1175  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1176  }
1177  else
1178  {
1179  tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
1180  }
1181 
1182  wxFileName autoSaveFileName = tmpFileName;
1183 
1184  // Auto save file name is the board file name prepended with autosaveFilePrefix string.
1185  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() );
1186 
1187  if( !autoSaveFileName.IsOk() )
1188  return false;
1189 
1190  // If the board file path is not writable, try writing to a platform specific temp file
1191  // path. If that path isn't writable, give up.
1192  if( !autoSaveFileName.IsDirWritable() )
1193  {
1194  autoSaveFileName.SetPath( wxFileName::GetTempDir() );
1195 
1196  if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
1197  return false;
1198  }
1199 
1200  wxLogTrace( traceAutoSave,
1201  wxT( "Creating auto save file <" ) + autoSaveFileName.GetFullPath() + wxT( ">" ) );
1202 
1203  if( SavePcbFile( autoSaveFileName.GetFullPath(), false, false ) )
1204  {
1206  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1207  UpdateTitle();
1208  m_autoSaveState = false;
1209 
1210  if( !Kiface().IsSingle() &&
1211  GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
1212  {
1214  }
1215 
1216  SetTitle( title ); // Restore initial frame title
1217 
1218  return true;
1219  }
1220 
1221  GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1222 
1223  SetTitle( title ); // Restore initial frame title
1224 
1225  return false;
1226 }
void UpdateTitle()
Set the main window title bar text.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
SETTINGS_MANAGER * GetSettingsManager() const
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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.
Definition: project.cpp:269
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.
void SetFileName(const wxString &aFileName)
Definition: board.h:227
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
static wxString GetAutoSaveFilePrefix()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:139
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Write the board data structures to a aFileName.
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static REPORTER & GetInstance()
Definition: reporter.cpp:117
BOARD * GetBoard() const

References PROJECT::AbsolutePath(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), PCB_BASE_FRAME::GetBoard(), PATHS::GetDefaultUserProjectsPath(), NULL_REPORTER::GetInstance(), PCB_BASE_FRAME::GetScreen(), EDA_BASE_FRAME::GetSettingsManager(), IsContentModified(), KiCadPcbFileExtension, Kiface(), EDA_BASE_FRAME::m_autoSaveState, NAMELESS_PROJECT, KIWAY_HOLDER::Prj(), SavePcbFile(), BASE_SCREEN::SetContentModified(), BOARD::SetFileName(), 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 904 of file pcb_edit_frame.cpp.

905 {
906  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
907  // when closing this frame if a footprint was selected, and the footprint editor called
908  // to edit this footprint, and when closing pcbnew if this footprint is still selected
909  // See https://bugs.launchpad.net/kicad/+bug/1655858
910  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
911  // avoid the crash (JPC)
912  GetCanvas()->SetEvtHandlerEnabled( false );
913 
914  GetCanvas()->StopDrawing();
915 
916  // Delete the auto save file if it exists.
917  wxFileName fn = GetBoard()->GetFileName();
918 
919  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
920  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
921 
922  // When the auto save feature does not have write access to the board file path, it falls
923  // back to a platform specific user temporary file path.
924  if( !fn.IsOk() || !fn.IsDirWritable() )
925  fn.SetPath( wxFileName::GetTempDir() );
926 
927  wxLogTrace( traceAutoSave, wxT( "Deleting auto save file <" ) + fn.GetFullPath() + wxT( ">" ) );
928 
929  // Remove the auto save file on a normal close of Pcbnew.
930  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
931  {
932  wxString msg = wxString::Format( _( "The auto save file '%s' could not be removed!" ),
933  fn.GetFullPath() );
934  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
935  }
936 
937  // Make sure local settings are persisted
939 
940  // Do not show the layer manager during closing to avoid flicker
941  // on some platforms (Windows) that generate useless redraw of items in
942  // the Layer Manager
944  m_auimgr.GetPane( "LayersManager" ).Show( false );
945 
946  // Unlink the old project if needed
947  GetBoard()->ClearProject();
948 
949  // Delete board structs and undo/redo lists, to avoid crash on exit
950  // when deleting some structs (mainly in undo/redo lists) too late
951  Clear_Pcb( false, true );
952 
953  // do not show the window because ScreenPcb will be deleted and we do not
954  // want any paint event
955  Show( false );
956 
958 }
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:106
const wxString & GetFileName() const
Definition: board.h:229
void doCloseWindow() override
bool m_show_layer_manager_tools
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
#define _(s)
void ClearProject()
Definition: board.cpp:173
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()
BOARD * GetBoard() const
bool Clear_Pcb(bool aQuery, bool aFinal=false)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:43
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  aOnlySMD,
bool  aNoTHItems,
bool  aTopSide,
bool  aBottomSide,
bool  aFormatCSV,
bool  aUseAuxOrigin 
)

Create an ASCII footprint position file.

Parameters
aFullFileNamethe full file name of the file to create.
aUnitsMMfalse to use inches, true to use mm in coordinates.
aOnlySMDtrue to force only footprints flagged smd to be in the list
aNoTHItemstrue to include only footprints with no TH pads no matter the footprint flag
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.
aFormatCSVtrue to use a comma separated file (CSV) format; default = false
aUseAuxOrigintrue to use auxiliary axis as an origin for the position data
Returns
the number of footprints found on aSide side or -1 if the file could not be created.

Definition at line 526 of file gen_footprints_placefile.cpp.

530 {
531  FILE * file = nullptr;
532 
533  if( !aFullFileName.IsEmpty() )
534  {
535  file = wxFopen( aFullFileName, wxT( "wt" ) );
536 
537  if( file == nullptr )
538  return -1;
539  }
540 
541  std::string data;
542  PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aOnlySMD, aNoTHItems, aTopSide, aBottomSide,
543  aFormatCSV, aUseAuxOrigin );
544  data = exporter.GenPositionData();
545 
546  // if aFullFileName is empty, the file is not created, only the
547  // count of footprints to place is returned
548  if( file )
549  {
550  // Creates a footprint position file
551  // aSide = 0 -> Back (bottom) side)
552  // aSide = 1 -> Front (top) side)
553  // aSide = 2 -> both sides
554  fputs( data.c_str(), file );
555  fclose( file );
556  }
557 
558  return exporter.GetFootprintCount();
559 }
The ASCII format of the kicad place file is:
BOARD * GetBoard() const

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

Referenced by DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles().

◆ DoGenFootprintsReport()

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

Create an ASCII footprint report file giving some infos on footprints and board outlines.

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

Definition at line 595 of file gen_footprints_placefile.cpp.

596 {
597  FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
598 
599  if( rptfile == nullptr )
600  return false;
601 
602  std::string data;
603  PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, false, false, true, true, false, true );
604  data = exporter.GenReportData();
605 
606  fputs( data.c_str(), rptfile );
607  fclose( rptfile );
608 
609  return true;
610 }
The ASCII format of the kicad place file is:
BOARD * GetBoard() const

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

Referenced by GenFootprintsReport().

◆ Edit_Zone_Params()

void PCB_EDIT_FRAME::Edit_Zone_Params ( ZONE zone_container)

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

Definition at line 40 of file edit_zone_helpers.cpp.

41 {
42  int dialogResult;
43  ZONE_SETTINGS zoneInfo = GetZoneSettings();
44  PICKED_ITEMS_LIST pickedList; // zones for undo/redo command
45  PICKED_ITEMS_LIST deletedList; // zones that have been deleted when combined
46  BOARD_COMMIT commit( this );
47 
48  // Save initial zones configuration, for undo/redo, before adding new zone
49  // note the net name and the layer can be changed, so we must save all zones
50  deletedList.ClearListAndDeleteItems();
51  pickedList.ClearListAndDeleteItems();
52  SaveCopyOfZones( pickedList, GetBoard(), -1, UNDEFINED_LAYER );
53 
54  if( aZone->GetIsRuleArea() )
55  {
56  // edit a rule area on a copper layer
57  zoneInfo << *aZone;
58  dialogResult = InvokeRuleAreaEditor( this, &zoneInfo );
59  }
60  else if( IsCopperLayer( aZone->GetLayer() ) )
61  {
62  // edit a zone on a copper layer
63  zoneInfo << *aZone;
64  dialogResult = InvokeCopperZonesEditor( this, &zoneInfo );
65  }
66  else
67  {
68  zoneInfo << *aZone;
69  dialogResult = InvokeNonCopperZonesEditor( this, &zoneInfo );
70  }
71 
72  if( dialogResult == wxID_CANCEL )
73  {
74  deletedList.ClearListAndDeleteItems();
75  pickedList.ClearListAndDeleteItems();
76  return;
77  }
78 
79  SetZoneSettings( zoneInfo );
80  OnModify();
81 
82  if( dialogResult == ZONE_EXPORT_VALUES )
83  {
84  UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() );
85  commit.Stage( pickedList );
86  commit.Push( _( "Modify zone properties" ) );
87  pickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
88  return;
89  }
90 
91  wxBusyCursor dummy;
92 
93  // Undraw old zone outlines
94  for( ZONE* zone : GetBoard()->Zones() )
95  GetCanvas()->GetView()->Update( zone );
96 
97  zoneInfo.ExportSetting( *aZone );
98 
99  NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
100 
101  if( net ) // net == NULL should not occur
102  aZone->SetNetCode( net->GetNetCode() );
103 
104  UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() );
105 
106  // refill zones with the new properties applied
107  std::vector<ZONE*> zones_to_refill;
108 
109  for( unsigned i = 0; i < pickedList.GetCount(); ++i )
110  {
111  ZONE* zone = dyn_cast<ZONE*>( pickedList.GetPickedItem( i ) );
112 
113  if( zone == nullptr )
114  {
115  wxASSERT_MSG( false, wxT( "Expected a zone after zone properties edit" ) );
116  continue;
117  }
118 
119  // aZone won't be filled if the layer set was modified, but it needs to be updated
120  if( zone->IsFilled() || zone == aZone )
121  zones_to_refill.push_back( zone );
122  }
123 
124  commit.Stage( pickedList );
125 
126  // Only auto-refill zones here if in user preferences
127  if( Settings().m_AutoRefillZones && zones_to_refill.size() )
128  {
129  ZONE_FILLER filler( GetBoard(), &commit );
130  wxString title = wxString::Format( _( "Refill %d Zones" ), (int) zones_to_refill.size() );
131 
132  std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
133  reporter = std::make_unique<WX_PROGRESS_REPORTER>( this, title, 4 );
134  filler.SetProgressReporter( reporter.get() );
135 
136  filler.Fill( zones_to_refill );
137  }
138 
139  commit.Push( _( "Modify zone properties" ) );
140 
141  if( Settings().m_AutoRefillZones && zones_to_refill.size() )
142  GetBoard()->GetConnectivity()->Build( GetBoard() );
143 
144  GetBoard()->GetConnectivity()->RecalculateRatsnest();
145 
146  pickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
147 }
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1328
void OnModify() override
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:234
#define ZONE_EXPORT_VALUES
Definition: zones.h:37
unsigned GetCount() const
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
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:92
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
const ZONE_SETTINGS & GetZoneSettings() const
void SetNetCode(int aNetCode)
Definition: netinfo.h:121
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
#define _(s)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
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.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:808
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
Handle the data for a net.
Definition: netinfo.h:66
PCBNEW_SETTINGS & Settings()
void ClearItemsList()
Delete only the list of pickers NOT the picked data itself.
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:120

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(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), IsCopperLayer(), ZONE::IsFilled(), ZONE_SETTINGS::m_NetcodeSelection, OnModify(), BOARD_COMMIT::Push(), SaveCopyOfZones(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE_FILLER::SetProgressReporter(), PCB_BASE_FRAME::Settings(), PCB_BASE_FRAME::SetZoneSettings(), BOARD_COMMIT::Stage(), UNDEFINED_LAYER, KIGFX::PCB_VIEW::Update(), UpdateCopyOfZonesList(), and ZONE_EXPORT_VALUES.

Referenced by OnEditItemRequest().

◆ ensureWindowIsOnScreen()

void EDA_BASE_FRAME::ensureWindowIsOnScreen ( )
protectedinherited

Definition at line 657 of file eda_base_frame.cpp.

658 {
659  wxDisplay display( wxDisplay::GetFromWindow( this ) );
660  wxRect clientSize = display.GetClientArea();
661  wxPoint pos = GetPosition();
662  wxSize size = GetWindowSize();
663 
664  wxLogTrace( traceDisplayLocation,
665  wxT( "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d" ), clientSize.x, clientSize.y,
666  clientSize.width, clientSize.height );
667 
668  if( pos.y < clientSize.y )
669  {
670  wxLogTrace( traceDisplayLocation,
671  wxT( "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d" ), pos.y,
672  clientSize.y );
673  pos.y = clientSize.y;
674  }
675 
676  if( pos.x < clientSize.x )
677  {
678  wxLogTrace( traceDisplayLocation,
679  wxT( "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d" ), pos.x,
680  clientSize.x );
681  pos.x = clientSize.x;
682  }
683 
684  if( pos.x + size.x - clientSize.x > clientSize.width )
685  {
686  int newWidth = clientSize.width - ( pos.x - clientSize.x );
687  wxLogTrace( traceDisplayLocation,
688  wxT( "ensureWindowIsOnScreen: effective width %d above available %d, setting to %d" ),
689  pos.x + size.x, clientSize.width, newWidth );
690  size.x = newWidth;
691  }
692 
693  if( pos.y + size.y - clientSize.y > clientSize.height )
694  {
695  int newHeight = clientSize.height - ( pos.y - clientSize.y );
696  wxLogTrace( traceDisplayLocation,
697  wxT( "ensureWindowIsOnScreen: effective height %d above available %d, setting to %d" ),
698  pos.y + size.y, clientSize.height, newHeight );
699  size.y = newHeight;
700  }
701 
702  wxLogTrace( traceDisplayLocation, wxT( "Updating window position (%d, %d) with size (%d, %d)" ),
703  pos.x, pos.y, size.x, size.y );
704 
705  SetSize( pos.x, pos.y, size.x, size.y );
706 }
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.

References EDA_BASE_FRAME::GetWindowSize(), and traceDisplayLocation.

Referenced by EDA_BASE_FRAME::OnSize().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

Definition at line 305 of file eda_draw_frame.cpp.

306 {
307  if( m_messagePanel )
309 }
EDA_MSG_PANEL * m_messagePanel
void EraseMsgBox()
Definition: msgpanel.cpp:198

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 
)

Replace aExisting footprint by aNew footprint using the Existing footprint settings (position, orientation, pad netnames ...).

The aExisting footprint is deleted or put in undo list.

Parameters
aExistingfootprint to replace.
aNewfootprint to put.
aCommitcommit that should store the changes.

Definition at line 486 of file dialog_exchange_footprints.cpp.

490 {
491  PCB_GROUP* parentGroup = aExisting->GetParentGroup();
492 
493  if( parentGroup )
494  {
495  parentGroup->RemoveItem( aExisting );
496  parentGroup->AddItem( aNew );
497  }
498 
499  aNew->SetParent( GetBoard() );
500 
501  PlaceFootprint( aNew, false );
502 
503  // PlaceFootprint will move the footprint to the cursor position, which we don't want. Copy
504  // the original position across.
505  aNew->SetPosition( aExisting->GetPosition() );
506 
507  if( aNew->GetLayer() != aExisting->GetLayer() )
508  aNew->Flip( aNew->GetPosition(), m_settings->m_FlipLeftRight );
509 
510  if( aNew->GetOrientation() != aExisting->GetOrientation() )
511  aNew->SetOrientation( aExisting->GetOrientation() );
512 
513  aNew->SetLocked( aExisting->IsLocked() );
514 
515  // Now transfer the net info from "old" pads to the new footprint
516  for( PAD* pad : aNew->Pads() )
517  {
518  PAD* pad_model = nullptr;
519 
520  // Pads with no copper are never connected to a net
521  if( !pad->IsOnCopperLayer() )
522  {
523  pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
524  continue;
525  }
526 
527  // Pads with no numbers are never connected to a net
528  if( pad->GetNumber().IsEmpty() )
529  {
530  pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
531  continue;
532  }
533 
534  // Search for a similar pad on a copper layer, to reuse net info
535  PAD* last_pad = nullptr;
536 
537  while( true )
538  {
539  pad_model = aExisting->FindPadByNumber( pad->GetNumber(), last_pad );
540 
541  if( !pad_model )
542  break;
543 
544  if( pad_model->IsOnCopperLayer() ) // a candidate is found
545  break;
546 
547  last_pad = pad_model;
548  }
549 
550  if( pad_model )
551  {
552  pad->SetLocalRatsnestVisible( pad_model->GetLocalRatsnestVisible() );
553  pad->SetPinFunction( pad_model->GetPinFunction() );
554  pad->SetPinType( pad_model->GetPinType() );
555  }
556 
557  pad->SetNetCode( pad_model ? pad_model->GetNetCode() : NETINFO_LIST::UNCONNECTED );
558  }
559 
560  // Copy reference
561  processTextItem( aExisting->Reference(), aNew->Reference(),
562  // never reset reference text
563  false,
564  resetTextLayers, resetTextEffects );
565 
566  // Copy value
567  processTextItem( aExisting->Value(), aNew->Value(),
568  // reset value text only when it is a proxy for the footprint ID
569  // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
570  aExisting->GetValue() == aExisting->GetFPID().GetLibItemName(),
571  resetTextLayers, resetTextEffects );
572 
573  // Copy fields in accordance with the reset* flags
574  for( BOARD_ITEM* item : aExisting->GraphicalItems() )
575  {
576  FP_TEXT* srcItem = dyn_cast<FP_TEXT*>( item );
577 
578  if( srcItem )
579  {
580  FP_TEXT* destItem = getMatchingTextItem( srcItem, aNew );
581 
582  if( destItem )
583  processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects );
584  else if( !deleteExtraTexts )
585  aNew->Add( new FP_TEXT( *srcItem ) );
586  }
587  }
588 
589  if( !resetFabricationAttrs )
590  aNew->SetAttributes( aExisting->GetAttributes() );
591 
592  // Copy 3D model settings in accordance with the reset* flag
593  if( !reset3DModels )
594  aNew->Models() = aExisting->Models(); // Linked list of 3D models.
595 
596  // Updating other parameters
597  const_cast<KIID&>( aNew->m_Uuid ) = aExisting->m_Uuid;
598  aNew->SetProperties( aExisting->GetProperties() );
599  aNew->SetPath( aExisting->GetPath() );
600 
601  aCommit.Remove( aExisting );
602  aCommit.Add( aNew );
603 
604  aNew->ClearFlags();
605 }
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:60
bool IsLocked() const override
Definition: footprint.h:297
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:39
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:183
const wxString & GetValue() const
Definition: footprint.h:488
const KIID_PATH & GetPath() const
Definition: footprint.h:207
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:208
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
double GetOrientation() const
Definition: footprint.h:191
bool GetLocalRatsnestVisible() const
PCBNEW_SETTINGS * m_settings
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
void SetAttributes(int aAttributes)
Definition: footprint.h:240
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:169
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:502
FP_TEXT & Reference()
Definition: footprint.h:503
FP_TEXT * getMatchingTextItem(FP_TEXT *aRefItem, FOOTPRINT *aFootprint)
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1681
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1491
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1075
const wxString & GetPinType() const
Definition: pad.h:146
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:51
const LIB_ID & GetFPID() const
Definition: footprint.h:195
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90
bool IsOnCopperLayer() const override
Definition: pad.h:218
void processTextItem(const FP_TEXT &aSrc, FP_TEXT &aDest, bool resetText, bool resetTextLayers, bool resetTextEffects)
const KIID m_Uuid
Definition: eda_item.h:474
int GetAttributes() const
Definition: footprint.h:239
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:307
wxPoint GetPosition() const override
Definition: footprint.h:187
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:509
BOARD * GetBoard() const
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:510
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1562
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
const wxString & GetPinFunction() const
Definition: pad.h:140
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:372

References COMMIT::Add(), FOOTPRINT::Add(), PCB_GROUP::AddItem(), EDA_ITEM::ClearFlags(), FOOTPRINT::FindPadByNumber(), 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(), PAD::GetPinType(), FOOTPRINT::GetPosition(), FOOTPRINT::GetProperties(), FOOTPRINT::GetValue(), FOOTPRINT::GraphicalItems(), FOOTPRINT::IsLocked(), PAD::IsOnCopperLayer(), PCBNEW_SETTINGS::m_FlipLeftRight, PCB_BASE_FRAME::m_settings, EDA_ITEM::m_Uuid, FOOTPRINT::Models(), pad, FOOTPRINT::Pads(), PCB_BASE_FRAME::PlaceFootprint(), processTextItem(), FOOTPRINT::Reference(), COMMIT::Remove(), PCB_GROUP::RemoveItem(), FOOTPRINT::SetAttributes(), FOOTPRINT::SetLocked(), FOOTPRINT::SetOrientation(), EDA_ITEM::SetParent(), FOOTPRINT::SetPath(), FOOTPRINT::SetPosition(), FOOTPRINT::SetProperties(), NETINFO_LIST::UNCONNECTED, and FOOTPRINT::Value().

Referenced by DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), BOARD_NETLIST_UPDATER::replaceFootprint(), 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
cmdlineis the received command from socket.

Reimplemented from KIWAY_PLAYER.

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

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

References _, CROSS_PROBING_SETTINGS::auto_highlight, CROSS_PROBING_SETTINGS::center_on_items, BOX2< Vec >::Centre(), DEFAULT_TEXT_SIZE, BOARD::FindFootprintByReference(), BOARD::FindNet(), FOOTPRINT::FindPadByNumber(), EDA_DRAW_FRAME::FocusOnLocation(), BOARD::Footprints(), FROM_UTF8(), PCB_BASE_FRAME::GetBoard(), FOOTPRINT::GetBoundingBox(), PCB_BASE_FRAME::GetCanvas(), BOX2< Vec >::GetHeight(), BOARD::GetHighLightNetCodes(), NETINFO_ITEM::GetMsgPanelInfo(), 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(), pad, EDA_DRAW_PANEL_GAL::Refresh(), BOARD::ResetNetHighLight(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectOnSheetFromEeschema, KIGFX::RENDER_SETTINGS::SetHighlight(), BOARD::SetHighLightNet(), EDA_DRAW_FRAME::SetMsgPanel(), KIGFX::VIEW::SetScale(), text, 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 
)

Create an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file.

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

Parameters
aPcba pointer to the board to be exported to IDF.
aFullFileNamethe full filename of the export file.
aUseThouset to true if the desired IDF unit is thou (mil).
aXRefthe board Reference Point in mm, X value.
aYRefthe board Reference Point in mm, Y value.
Returns
true if OK.

Definition at line 588 of file export_idf.cpp.

590 {
591  IDF3_BOARD idfBoard( IDF3::CAD_ELEC );
592 
593  // Switch the locale to standard C (needed to print floating point numbers)
594  LOCALE_IO toggle;
595 
596  resolver = Prj().Get3DCacheManager()->GetResolver();
597 
598  bool ok = true;
599  double scale = MM_PER_IU; // we must scale internal units to mm for IDF
600  IDF3::IDF_UNIT idfUnit;
601 
602  if( aUseThou )
603  {
604  idfUnit = IDF3::UNIT_THOU;
605  idfBoard.SetUserPrecision( 1 );
606  }
607  else
608  {
609  idfUnit = IDF3::UNIT_MM;
610  idfBoard.SetUserPrecision( 5 );
611  }
612 
613  wxFileName brdName = aPcb->GetFileName();
614 
615  idfBoard.SetUserScale( scale );
616  idfBoard.SetBoardThickness( aPcb->GetDesignSettings().GetBoardThickness() * scale );
617  idfBoard.SetBoardName( TO_UTF8( brdName.GetFullName() ) );
618  idfBoard.SetBoardVersion( 0 );
619  idfBoard.SetLibraryVersion( 0 );
620 
621  std::ostringstream ostr;
622  ostr << "KiCad " << TO_UTF8( GetBuildVersion() );
623  idfBoard.SetIDFSource( ostr.str() );
624 
625  try
626  {
627  // set up the board reference point
628  idfBoard.SetUserOffset( -aXRef, aYRef );
629 
630  // Export the board outline
631  idf_export_outline( aPcb, idfBoard );
632 
633  // Output the drill holes and footprint (library) data.
634  for( FOOTPRINT* footprint : aPcb->Footprints() )
635  idf_export_footprint( aPcb, footprint, idfBoard );
636 
637  if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) )
638  {
639  wxString msg;
640  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( idfBoard.GetError().c_str() );
641  wxMessageBox( msg );
642 
643  ok = false;
644  }
645  }
646  catch( const IO_ERROR& ioe )
647  {
648  wxString msg;
649  msg << _( "IDF Export Failed:\n" ) << ioe.What();
650  wxMessageBox( msg );
651 
652  ok = false;
653  }
654  catch( const std::exception& e )
655  {
656  wxString msg;
657  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
658  wxMessageBox( msg );
659  ok = false;
660  }
661 
662  return ok;
663 }
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
static void idf_export_outline(BOARD *aPcb, IDF3_BOARD &aIDFBoard)
Retrieve line segment information from the edge layer and compiles the data into a form which can be ...
Definition: export_idf.cpp:64
const wxString & GetFileName() const
Definition: board.h:229
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
#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:30
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:234
#define _(s)
static void idf_export_footprint(BOARD *aPcb, FOOTPRINT *aFootprint, IDF3_BOARD &aIDFBoard)
Retrieve information from all board footprints, adds drill holes to the DRILLED_HOLES or BOARD_OUTLIN...
Definition: export_idf.cpp:279
const int scale
#define UNIT_MM
Definition: units_scales.h:31
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:57
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 = nullptr 
)

Save footprints in a library:

Parameters
aStoreInNewLibtrue to save footprints in a existing library. Existing footprints will be kept or updated. This library should be in fp lib table, and is type is .pretty. False to save footprints in a new library. If 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 666 of file footprint_libraries_utils.cpp.

668 {
669  if( GetBoard()->GetFirstFootprint() == nullptr )
670  {
671  DisplayInfoMessage( this, _( "No footprints to export!" ) );
672  return;
673  }
674 
675  wxString footprintName;
676 
677  auto resetReference =
678  []( FOOTPRINT* aFootprint )
679  {
680  aFootprint->SetReference( "REF**" );
681  };
682 
683  if( !aStoreInNewLib )
684  {
685  // The footprints are saved in an existing .pretty library in the fp lib table
686  PROJECT& prj = Prj();
687  wxString last_nickname = prj.GetRString( PROJECT::PCB_LIB_NICKNAME );
688  wxString nickname = SelectLibrary( last_nickname );
689 
690  if( !nickname ) // Aborted
691  return;
692 
693  bool map = IsOK( this, wxString::Format( _( "Update footprints on board to refer to %s?" ),
694  nickname ) );
695 
696  prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
697 
698  for( FOOTPRINT* footprint : GetBoard()->Footprints() )
699  {
700  try
701  {
702  FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
703 
704  if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
705  {
706  FOOTPRINT* fpCopy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
707 
708  resetReference( fpCopy );
709  tbl->FootprintSave( nickname, fpCopy, true );
710 
711  delete fpCopy;
712  }
713  }
714  catch( const IO_ERROR& ioe )
715  {
716  DisplayError( this, ioe.What() );
717  }
718 
719  if( map )
720  {
721  LIB_ID id = footprint->GetFPID();
722  id.SetLibNickname( nickname );
723  footprint->SetFPID( id );
724  }
725  }
726  }
727  else
728  {
729  // The footprints are saved in a new .pretty library.
730  // If this library already exists, all previous footprints will be deleted
731  wxString libPath = CreateNewLibrary( aLibName );
732 
733  if( libPath.IsEmpty() ) // Aborted
734  return;
735 
736  if( aLibPath )
737  *aLibPath = libPath;
738 
739  wxString libNickname;
740  bool map = IsOK( this, _( "Update footprints on board to refer to new library?" ) );
741 
742  if( map )
743  {
744  const LIB_TABLE_ROW* row = Prj().PcbFootprintLibs()->FindRowByURI( libPath );
745 
746  if( row )
747  libNickname = row->GetNickName();
748  }
749 
751  PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
752 
753  for( FOOTPRINT* footprint : GetBoard()->Footprints() )
754  {
755  try
756  {
757  if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
758  {
759  FOOTPRINT* fpCopy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
760 
761  resetReference( fpCopy );
762  pi->FootprintSave( libPath, fpCopy );
763 
764  delete fpCopy;
765  }
766  }
767  catch( const IO_ERROR& ioe )
768  {
769  DisplayError( this, ioe.What() );
770  }
771 
772  if( map )
773  {
774  LIB_ID id = footprint->GetFPID();
775  id.SetLibNickname( libNickname );
776  footprint->SetFPID( id );
777  }
778  }
779  }
780 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
Container for project specific data.
Definition: project.h:62
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:555
const wxString & GetNickName() const
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
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...
#define _(s)
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...
Definition: project.cpp:212
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:97
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
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:227
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:53
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:323
S-expression Pcbnew file format.
Definition: io_mgr.h:56

References _, PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DisplayError(), DisplayInfoMessage(), LIB_TABLE::FindRowByURI(), FP_LIB_TABLE::FootprintSave(), Format(), PCB_BASE_FRAME::GetBoard(), LIB_TABLE_ROW::GetNickName(), PROJECT::GetRString(), IsOK(), IO_MGR::KICAD_SEXP, PROJECT::PCB_LIB_NICKNAME, PROJECT::PcbFootprintLibs(), IO_MGR::PluginFind(), KIWAY_HOLDER::Prj(), PCB_BASE_FRAME::SelectLibrary(), LIB_ID::SetLibNickname(), PROJECT::SetRString(), and IO_ERROR::What().

Referenced by ExportFootprintsToLibrary(), and Process_Special_Functions().

◆ ExportSpecctraFile()

bool PCB_EDIT_FRAME::ExportSpecctraFile ( const wxString &  aFullFilename)

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 86 of file specctra_export.cpp.

87 {
88  BASE_SCREEN* screen = GetScreen();
89  bool wasModified = screen->IsContentModified();
90  wxString errorText;
91  bool ok = true;
92 
93  try
94  {
95  ExportBoardToSpecctraFile( GetBoard(), aFullFilename );
96  }
97  catch( const IO_ERROR& ioe )
98  {
99  ok = false;
100 
101  // copy the error string to safe place, ioe is in this scope only.
102  errorText = ioe.What();
103  }
104 
105  // The two calls to FOOTPRINT::Flip() in ExportBoardToSpecctraFile both set the
106  // modified flag, yet their actions cancel each other out, so it should
107  // be ok to clear the modify flag.
108  if( !wasModified )
109  screen->SetContentModified( false );
110 
111  if( ok )
112  {
113  SetStatusText( wxString( _( "BOARD exported OK." ) ) );
114  }
115  else
116  {
117  DisplayErrorMessage( this, _( "Unable to export, please fix and try again" ), errorText );
118  }
119 
120  return ok;
121 }
bool IsContentModified() const
Definition: base_screen.h:60
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
#define _(s)
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
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

References _, DisplayErrorMessage(), ExportBoardToSpecctraFile(), GetBoard(), BASE_SCREEN::IsContentModified(), BASE_SCREEN::SetContentModified(), and IO_ERROR::What().

Referenced by ExportSpecctraDSN().

◆ ExportSVG()

void PCB_EDIT_FRAME::ExportSVG ( wxCommandEvent &  event)

Show the Export to SVG file dialog.

Definition at line 1316 of file pcb_edit_frame.cpp.

1317 {
1318  InvokeExportSVG( this, GetBoard() );
1319 }
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)

Create a file in GenCAD 1.4 format from the current board.

Definition at line 234 of file export_gencad.cpp.

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

References _, B_Cu, PCB_BASE_FRAME::Compile_Ratsnest(), componentShapes, BOARD::ComputeBoundingBox(), CreateArtworksSection(), CreateBoardSection(), CreateComponentsSection(), CreateDevicesSection(), CreateHeaderInfoData(), CreatePadsShapesSection(), CreateRoutesSection(), CreateShapesSection(), CreateSignalsSection(), CreateTracksInfoData(), DisplayError(), FLIP_BOTTOM_PADS, flipBottomPads, BOARD::Footprints(), Format(), GencadOffsetX, GencadOffsetY, BOARD_DESIGN_SETTINGS::GetAuxOrigin(), 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, PCB_BASE_FRAME::m_pcb, path, SetLastPath(), 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,
const wxString &  a3D_Subdir,
double  aXRef,
double  aYRef 
)

Create 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
aFullFileNamethe full filename of the file to create
aMMtoWRMLunitthe VRML scaling factor: 1.0 to export in mm. 0.001 for meters
aExport3DFilestrue 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.
a3D_Subdirsub directory where 3D shapes files are copied. This is only used when aExport3DFiles == true.
aXRefX value of PCB (0,0) reference point.
aYRefY value of PCB (0,0) reference point.
Returns
true if Ok.

Definition at line 1153 of file exporter_vrml.cpp.

1157 {
1158  bool success = true;
1159  EXPORTER_PCB_VRML model3d( GetBoard() );
1160 
1161  model_vrml = &model3d;
1162  model3d.SetScale( aMMtoWRMLunit );
1163  model3d.m_UseInlineModelsInBrdfile = aExport3DFiles;
1164  model3d.m_Subdir3DFpModels = a3D_Subdir;
1165  model3d.m_UseRelPathIn3DModelFilename = aUseRelativePaths;
1166  model3d.m_Cache3Dmodels = Prj().Get3DCacheManager();
1167 
1168  if( model3d.m_UseInlineModelsInBrdfile )
1169  {
1170  model3d.m_BoardToVrmlScale = MM_PER_IU / 2.54;
1171  model3d.SetOffset( -aXRef / 2.54, aYRef / 2.54 );
1172  }
1173  else
1174  {
1175  model3d.m_BoardToVrmlScale = MM_PER_IU;
1176  model3d.SetOffset( -aXRef, aYRef );
1177  }
1178 
1179  try
1180  {
1181  // Preliminary computation: the z value for each layer
1182  model3d.ComputeLayer3D_Zpos();
1183 
1184  // board edges and cutouts
1185  model3d.ExportVrmlBoard();
1186 
1187  // Draw solder mask layer (negative layer)
1188  model3d.ExportVrmlSolderMask();
1189 #if 1
1190  model3d.ExportVrmlViaHoles();
1191  model3d.ExportStandardLayers();
1192 #else
1193  // Drawing and text on the board
1194  model3d.ExportVrmlDrawings();
1195 
1196  // Export vias and trackage
1197  model3d.ExportVrmlTracks();
1198 
1199  // Export zone fills
1200  model3d.ExportVrmlZones();
1201 #endif
1202  if( model3d.m_UseInlineModelsInBrdfile )
1203  {
1204  // Copy fp 3D models in a folder, and link these files in
1205  // the board .vrml file
1206  model3d.ExportFp3DModelsAsLinkedFile( aFullFileName );
1207  }
1208  else
1209  {
1210  // merge footprints in the .vrml board file
1211  for( FOOTPRINT* footprint : GetBoard()->Footprints() )
1212  model3d.ExportVrmlFootprint( footprint, nullptr );
1213 
1214  // write out the board and all layers
1215  model3d.writeLayers( TO_UTF8( aFullFileName ), nullptr );
1216  }
1217  }
1218  catch( const std::exception& e )
1219  {
1220  wxString msg;
1221  msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
1222  wxMessageBox( msg );
1223 
1224  success = false;
1225  }
1226 
1227  return success;
1228 }
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
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
#define _(s)
static EXPORTER_PCB_VRML * model_vrml
bool SetScale(double aWorldScale)
BOARD * GetBoard() const

References _, EXPORTER_PCB_VRML::ComputeLayer3D_Zpos(), EXPORTER_PCB_VRML::ExportFp3DModelsAsLinkedFile(), EXPORTER_PCB_VRML::ExportStandardLayers(), EXPORTER_PCB_VRML::ExportVrmlBoard(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), EXPORTER_PCB_VRML::ExportVrmlSolderMask(), EXPORTER_PCB_VRML::ExportVrmlViaHoles(), FROM_UTF8(), PCB_BASE_FRAME::GetBoard(), EXPORTER_PCB_VRML::m_BoardToVrmlScale, EXPORTER_PCB_VRML::m_Cache3Dmodels, EXPORTER_PCB_VRML::m_Subdir3DFpModels, EXPORTER_PCB_VRML::m_UseInlineModelsInBrdfile, EXPORTER_PCB_VRML::m_UseRelPathIn3DModelFilename, model_vrml, KIWAY_HOLDER::Prj(), EXPORTER_PCB_VRML::SetOffset(), EXPORTER_PCB_VRML::SetScale(), TO_UTF8, and EXPORTER_PCB_VRML::writeLayers().

Referenced by ExportVRML(), and OnExportVRML().

◆ FetchNetlistFromSchematic()

bool PCB_EDIT_FRAME::FetchNetlistFromSchematic ( NETLIST aNetlist,
const wxString &  aAnnotateMessage 
)
Parameters
aNetlista NETLIST owned by the caller. This function fills it in.
aAnnotateMessagea message to be shown if annotation must be performed. If empty, annotation will be skipped.
Returns
true if a netlist was fetched.

Definition at line 1507 of file pcb_edit_frame.cpp.

1509 {
1510  if( !TestStandalone() )
1511  {
1512  DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
1513  "stand-alone mode. In order to create or update PCBs from "
1514  "schematics, you must launch the KiCad project manager and "
1515  "create a project." ) );
1516  return false; // Not in standalone mode
1517  }
1518 
1519  Raise(); // Show
1520 
1521  std::string payload( aAnnotateMessage );
1522 
1523  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1524 
1525  if( payload == aAnnotateMessage )
1526  {
1527  Raise();
1528  DisplayErrorMessage( this, aAnnotateMessage );
1529  return false;
1530  }
1531 
1532  try
1533  {
1534  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1535  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1536  netlistReader.LoadNetlist();
1537  }
1538  catch( const IO_ERROR& e )
1539  {
1540  Raise();
1541 
1542  // Do not translate extra_info strings. These are for developers
1543  wxString extra_info = e.Problem() + wxT( " : " ) + e.What() + wxT( " at " ) + e.Where();
1544 
1545  DisplayErrorMessage( this, _( "Received an error while reading netlist. Please "
1546  "report this issue to the KiCad team using the menu "
1547  "Help->Report Bug."), extra_info );
1548  return false;
1549  }
1550 
1551  return true;
1552 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
Read the new s-expression based KiCad netlist format.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:487
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
virtual const wxString Where() const
where did the Problem() occur?
Definition: exceptions.cpp:40
bool TestStandalone(void)
Test if standalone mode.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
#define _(s)
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

References _, DisplayErrorMessage(), KIWAY::ExpressMail(), FRAME_SCH, Kiway, KICAD_NETLIST_READER::LoadNetlist(), MAIL_SCH_GET_NETLIST, IO_ERROR::Problem(), IO_ERROR::What(), and IO_ERROR::Where().

Referenced by KiwayMailIn(), DRC_TOOL::RunTests(), and BOARD_EDITOR_CONTROL::UpdatePCBFromSchematic().

◆ Files_io()

void PCB_EDIT_FRAME::Files_io ( wxCommandEvent &  event)

Call Files_io_from_id with the wxCommandEvent id.

Parameters
eventis the command event handler.

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

307 {
308  int id = event.GetId();
309  Files_io_from_id( id );
310 }
bool Files_io_from_id(int aId)
Read and write board files according to aId.

References Files_io_from_id().

◆ Files_io_from_id()

bool PCB_EDIT_FRAME::Files_io_from_id ( int  aId)

Read and write board files according to aId.

Valid event IDs are:

  • ID_LOAD_FILE
  • ID_MENU_RECOVER_BOARD_AUTOSAVE
  • ID_NEW_BOARD
  • ID_SAVE_BOARD
  • ID_COPY_BOARD_AS
  • ID_SAVE_BOARD_AS
Parameters
aIdis an event ID coming from file command events:

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

314 {
315  wxString msg;
316 
317  switch( id )
318  {
319  case ID_LOAD_FILE:
320  {
321  int open_ctl = 0;
322  wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
323 
324  return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
325  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
326  }
327 
329  {
330  int open_ctl = 1;
331  wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
332 
333  return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
334  && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
335  }
336 
338  {
339  wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
340  wxFileName fn = currfn;
341 
342  wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
343  fn.SetName( rec_name );
344 
345  if( !fn.FileExists() )
346  {
347  msg.Printf( _( "Recovery file '%s' not found." ), fn.GetFullPath() );
348  DisplayInfoMessage( this, msg );
349  return false;
350  }
351 
352  msg.Printf( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() );
353 
354  if( !IsOK( this, msg ) )
355  return false;
356 
357  GetScreen()->SetContentModified( false ); // do not prompt the user for changes
358 
359  if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
360  {
361  // Re-set the name since name or extension was changed
362  GetBoard()->SetFileName( currfn.GetFullPath() );
363  UpdateTitle();
364  return true;
365  }
366 
367  return false;
368  }
369 
370  case ID_NEW_BOARD:
371  {
372  if( IsContentModified() )
373  {
374  wxFileName fileName = GetBoard()->GetFileName();
375  wxString saveMsg = _( "Current board will be closed, save changes to '%s' before "
376  "continuing?" );
377 
378  if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
379  [&]()->bool
380  {
382  } ) )
383  {
384  return false;
385  }
386  }
387  else if( !GetBoard()->IsEmpty() )
388  {
389  if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
390  return false;
391  }
392 
394 
395  GetBoard()->ClearProject();
396 
398 
399  mgr->SaveProject( mgr->Prj().GetProjectFullName() );
400  mgr->UnloadProject( &mgr->Prj() );
401 
402  if( !Clear_Pcb( false ) )
403  return false;
404 
406 
407  onBoardLoaded();
408 
409  OnModify();
410  return true;
411  }
412 
413  case ID_SAVE_BOARD:
414  if( !GetBoard()->GetFileName().IsEmpty() )
415  return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) );
416 
418 
419  case ID_COPY_BOARD_AS:
420  case ID_SAVE_BOARD_AS:
421  {
422  bool addToHistory = ( id == ID_SAVE_BOARD_AS );
423  wxString orig_name;
424 
425  wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name, nullptr );
426 
427  if( orig_name.IsEmpty() )
428  orig_name = NAMELESS_PROJECT;
429 
430  wxFileName savePath( Prj().GetProjectFullName() );
431 
432  if( !savePath.IsOk() || !savePath.IsDirWritable() )
433  {
434  savePath = GetMruPath();
435 
436  if( !savePath.IsOk() || !savePath.IsDirWritable() )
438  }
439 
440  wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
441  wxString filename = fn.GetFullPath();
442  bool createProject = false;
443 
444  if( AskSaveBoardFileName( this, &filename, &createProject ) )
445  {
446  if( id == ID_COPY_BOARD_AS )
447  return SavePcbCopy( filename, createProject );
448  else
449  return SavePcbFile( filename, addToHistory, createProject );
450  }
451 
452  return false;
453  }
454 
455  default:
456  return false;
457  }
458 }
void UpdateTitle()
Set the main window title bar text.
void OnModify() override
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:239
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
SETTINGS_MANAGER * GetSettingsManager() const
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Saves a loaded project.
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)
Write the board data structures to aFileName.
#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:229
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.
Definition: project.cpp:269
wxString GetMruPath() const
bool AskSaveBoardFileName(PCB_EDIT_FRAME *aParent, wxString *aFileName, bool *aCreateProject)
Put up a wxFileDialog asking for a BOARD filename to save.
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly)
Show a wxFileDialog asking for a BOARD filename to open.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Load a KiCad board (.kicad_pcb) from aFileName.
void onBoardLoaded()
Update 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.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
#define _(s)
void SetFileName(const wxString &aFileName)
Definition: board.h:227
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:116
void ClearProject()
Definition: board.cpp:173
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
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
static wxString GetAutoSaveFilePrefix()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:139
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Write the board data structures to a aFileName.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool Files_io_from_id(int aId)
Read and write board files according to aId.
BOARD * GetBoard() const
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
bool Clear_Pcb(bool aQuery, bool aFinal=false)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:43
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:323
bool IsEmpty() const
Definition: board.h:282

References _, PROJECT::AbsolutePath(), AskLoadBoardFileName(), AskSaveBoardFileName(), Clear_Pcb(), BOARD::ClearProject(), DisplayInfoMessage(), Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), PCB_BASE_FRAME::GetBoard(), PATHS::GetDefaultUserProjectsPath(), 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(), NAMELESS_PROJECT, onBoardLoaded(), OnModify(), OpenProjectFiles(), KIWAY_HOLDER::Prj(), SETTINGS_MANAGER::Prj(), SavePcbCopy(), SavePcbFile(), SETTINGS_MANAGER::SaveProject(), SaveProjectSettings(), BASE_SCREEN::SetContentModified(), 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().

◆ findDialogs()

std::vector< wxWindow * > EDA_DRAW_FRAME::findDialogs ( )
protectedinherited

Definition at line 842 of file eda_draw_frame.cpp.

843 {
844  std::vector<wxWindow*> dialogs;
845 
846  for( wxWindow* window : GetChildren() )
847  {
848  if( dynamic_cast<DIALOG_SHIM*>( window ) )
849  dialogs.push_back( window );
850  }
851 
852  return dialogs;
853 }

Referenced by PCB_BASE_FRAME::FocusOnItems(), and EDA_DRAW_FRAME::FocusOnLocation().

◆ FindNext()

void PCB_EDIT_FRAME::FindNext ( )

Find the next item using our existing search parameters.

Definition at line 1417 of file pcb_edit_frame.cpp.

1418 {
1419  if( !m_findDialog )
1420  {
1421  m_findDialog = new DIALOG_FIND( this );
1424  }
1425 
1427 }
void FindItem(BOARD_ITEM *aItem)
Handle finding an item.
void SetCallback(std::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition: dialog_find.h:61
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
DIALOG_FIND * m_findDialog
The selection tool: currently supports:
void FindNext()
Finds the next item.
Definition: dialog_find.h:69

References PCB_SELECTION_TOOL::FindItem().

Referenced by BOARD_EDITOR_CONTROL::FindNext().

◆ FinishAUIInitialization()

void EDA_BASE_FRAME::FinishAUIInitialization ( )
inherited

Definition at line 853 of file eda_base_frame.cpp.

854 {
855 #if defined( __WXOSX_MAC__ )
856  m_auimgr.Update();
857 #else
858  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
859  // hiding it.
860  m_auimgr.Update();
861 
862  // We don't want the infobar displayed right away
863  m_auimgr.GetPane( wxT( "InfoBar" ) ).Hide();
864  m_auimgr.Update();
865 #endif
866 }
wxAuiManager m_auimgr

References EDA_BASE_FRAME::m_auimgr.

◆ FocusOnItem()

void PCB_BASE_FRAME::FocusOnItem ( BOARD_ITEM aItem,
PCB_LAYER_ID  aLayer = UNDEFINED_LAYER 
)
inherited

◆ FocusOnItems()

void PCB_BASE_FRAME::FocusOnItems ( std::vector< BOARD_ITEM * >  aItems,
PCB_LAYER_ID  aLayer = UNDEFINED_LAYER 
)
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 215 of file pcb_base_frame.cpp.

216 {
217  static std::vector<KIID> lastBrightenedItemIDs;
218 
219  BOARD_ITEM* lastItem = nullptr;
220 
221  for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
222  {
225  #if BOOST_VERSION >= 106700
226  try
227  {
228  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
229  }
230  catch( const boost::uuids::entropy_error& )
231  {
232  wxLogError( wxT( "A Boost UUID entropy exception was thrown in %s:%s." ),
233  __FILE__, __FUNCTION__ );
234  }
235  #else
236  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
237  #endif
238 
239  if( lastItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
240  {
241  lastItem->ClearBrightened();
242 
243  if( lastItem->Type() == PCB_FOOTPRINT_T )
244  {
245  static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
246  [&]( BOARD_ITEM* child )
247  {
248  child->ClearBrightened();
249  } );
250  }
251  else if( lastItem->Type() == PCB_GROUP_T )
252  {
253  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
254  [&]( BOARD_ITEM* child )
255  {
256  child->ClearBrightened();
257  } );
258  }
259 
260  GetCanvas()->GetView()->Update( lastItem );
261  lastBrightenedItemID = niluuid;
262  GetCanvas()->Refresh();
263  }
264  }
265 
266  lastBrightenedItemIDs.clear();
267 
268  if( aItems.empty() )
269  return;
270 
271  wxPoint focusPt;
272  KIGFX::VIEW* view = GetCanvas()->GetView();
273  SHAPE_POLY_SET viewportPoly( view->GetViewport() );
274 
275  for( wxWindow* dialog : findDialogs() )
276  {
277  wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
278  SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( dialogPos, true ),
279  view->ToWorld( dialog->GetSize(), false ) ) );
280 
281  try
282  {
283  viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
284  }
285  catch( const ClipperLib::clipperException& exc )
286  {
287  // This may be overkill and could be an assertion but we are more likely to
288  // find any clipper errors this way.
289  wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
290  }
291  }
292 
293  SHAPE_POLY_SET itemPoly, clippedPoly;
294 
295  for( BOARD_ITEM* item : aItems )
296  {
297  if( item && item != DELETED_BOARD_ITEM::GetInstance() )
298  {
299  item->SetBrightened();
300 
301  if( item->Type() == PCB_FOOTPRINT_T )
302  {
303  static_cast<FOOTPRINT*>( item )->RunOnChildren(
304  [&]( BOARD_ITEM* child )
305  {
306  child->SetBrightened();