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 UNITS_PROVIDER

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...
 
std::vector< BOARD_ITEM * > FindItemsFromSyncSelection (std::string syncStr)
 Used to find items by selection synchronization spec string. 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 ()
 
bool PropertiesShown ()
 
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)
 
EDA_ANGLE GetRotationAngle () const override
 Return the angle used for rotate operations. More...
 
COLOR4D GetGridColor () override
 
void SetGridColor (const COLOR4D &aColor) override
 
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 ()
 
void ToggleProperties ()
 
void ToggleSearch ()
 
int DoGenFootprintsPositionFile (const wxString &aFullFileName, bool aUnitsMM, bool aOnlySMD, bool aNoTHItems, bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX)
 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...
 
void OnRunTeardropTool (wxCommandEvent &event)
 run teardrop tool More...
 
void OnRemoveTeardropTool (wxCommandEvent &event)
 Remove all teardrops. 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, bool *aUpdated=nullptr)
 Replace aExisting footprint by aNew footprint using the Existing footprint settings (position, orientation, pad netnames ...). More...
 
bool FootprintMatchesLibrary ()
 
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 InstallNetlistFrame ()
 
bool FetchNetlistFromSchematic (NETLIST &aNetlist, const wxString &aAnnotateMessage)
 
int 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 SendSelectItemsToSch (const std::deque< EDA_ITEM * > &aItems, EDA_ITEM *aFocusItem, bool aForce)
 Send a message to the schematic editor to try to find schematic counterparts of specified PCB items and select them. More...
 
void SendCrossProbeItem (BOARD_ITEM *aSyncItem)
 Send a message to the schematic editor so that it may move its cursor to an item with the same reference as the aSyncItem and highlight it. 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 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 AppendCopyToUndoList (const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType) override
 As SaveCopyInUndoList, but appends the changes to the last undo item on the stack. 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)
 
void ShowBitmapPropertiesDialog (BOARD_ITEM *aBitmap)
 Set the angle used for rotate operations. More...
 
void ShowTextPropertiesDialog (BOARD_ITEM *aText)
 
int ShowTextBoxPropertiesDialog (BOARD_ITEM *aText)
 
void ShowGraphicItemPropertiesDialog (BOARD_ITEM *aItem)
 
COLOR_SETTINGSGetColorSettings (bool aForceRefresh=false) 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 ()
 
PROPERTIES_PANELGetPropertiesPanel ()
 
void UpdateProperties ()
 
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...
 
BOX2I 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 VECTOR2IGetGridOrigin () const override
 Return the absolute coordinates of the origin of the snap grid. More...
 
void SetGridOrigin (const VECTOR2I &aPoint) override
 
const VECTOR2IGetAuxOrigin () const
 
const VECTOR2I 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...
 
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)
 
void HideSolderMask ()
 
void ShowSolderMask ()
 
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 PCB_VIEWERS_SETTINGS_BASEGetViewerSettingsBase () 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...
 
EDA_SEARCH_DATAGetFindReplaceData ()
 
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...
 
VECTOR2I GetNearestGridPosition (const VECTOR2I &aPosition) const
 Return the nearest aGridSize location to aPosition. More...
 
VECTOR2I GetNearestHalfGridPosition (const VECTOR2I &aPosition) const
 Return the nearest aGridSize / 2 location to aPosition. More...
 
virtual COLOR4D GetDrawBgColor () const
 
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 wxchoice. More...
 
void OnUpdateSelectZoom (wxUpdateUIEvent &aEvent)
 Update the checked item in the zoom wxchoice. 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 VECTOR2I &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, const std::map< wxString, wxString > *aProperties, 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)
 
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)
 
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 TOOL_EVENT &aEvent)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const TOOL_EVENT &aEvent)
 Pops a tool from the stack. More...
 
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...
 
bool HasKiway () const
 Safety check before asking for the Kiway reference. 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...
 
EDA_UNITS GetUserUnits () const
 
void SetUserUnits (EDA_UNITS aUnits)
 
const EDA_IU_SCALEGetIuScale () const
 
wxString StringFromValue (double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aValue in internal units into a united string. More...
 
wxString StringFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=false)
 
wxString MessageTextFromValue (double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 A lower-precision version of StringFromValue(). More...
 
wxString MessageTextFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=true)
 
long long int ValueFromString (const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aTextValue in aUnits to internal units used by the frame. More...
 

Static Public Member Functions

static const wxString SearchPaneName ()
 
static 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...
 
static std::vector< ACTION_PLUGIN * > GetOrderedActionPlugins ()
 Return ordered list of plugins in sequence in which they should appear on toolbar or in settings. More...
 
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_show_properties
 
bool m_show_search
 
bool m_ZoneFillsDirty
 
bool m_probingSchToPcb
 

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)
 
void redrawNetnames (wxTimerEvent &aEvent)
 
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 saveCopyInUndoList (PICKED_ITEMS_LIST *commandToUndo, const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType)
 
void unitsChangeRefresh () override
 Called when when the units setting has changed to allow for any derived classes to handle refreshing and controls that have units based measurements in them. More...
 
void handleIconizeEvent (wxIconizeEvent &aEvent) override
 Handle a window iconize event. 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 onIconize (wxIconizeEvent &aEvent)
 
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 ()
 
virtual void OnDropFiles (wxDropFilesEvent &aEvent)
 Handles event fired when a file is dropped to the window. More...
 
virtual void DoWithAcceptedFiles ()
 Execute action on accepted dropped file. More...
 

Static Protected Member Functions

static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
 
bool m_undoRedoBlocked
 
PANEL_SELECTION_FILTERm_selectionFilterPanel
 
APPEARANCE_CONTROLSm_appearancePanel
 
PROPERTIES_PANELm_propertiesPanel
 
wxAuiNotebook * m_tabbedPanel
 Panel with Layers and Object Inspector tabs. More...
 
BOARDm_pcb
 
PCB_DISPLAY_OPTIONS m_displayOptions
 
PCB_ORIGIN_TRANSFORMS m_originTransforms
 
wxSocketServer * m_socketServer
 
std::vector< wxSocketBase * > m_sockets
 interprocess communication More...
 
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
 
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
 
std::unique_ptr< EDA_SEARCH_DATAm_findReplaceData
 
wxArrayString m_findStringHistoryList
 
wxArrayString m_replaceStringHistoryList
 
EDA_MSG_PANELm_messagePanel
 
int m_msgFrameHeight
 
COLOR_SETTINGSm_colorSettings
 
SEARCH_PANEm_searchPane
 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
 
std::vector< wxFileName > m_AcceptedFiles
 
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_supportsAutoSave
 
bool m_autoSaveState
 
wxTimer * m_autoSaveTimer
 
UNDO_REDO_CONTAINER m_undoList
 
UNDO_REDO_CONTAINER m_redoList
 
wxString m_mruPath
 
std::map< int, UIUpdateHandlerm_uiUpdateMap
 < Map containing the UI update handlers registered with wx for each action. More...
 
bool m_isClosing
 Set by NonUserClose() to indicate that the user did not request the current close. More...
 
bool m_isNonUserClose
 
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
 Associates files extensions with action to execute. More...
 
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 Member Functions

void windowClosing (wxCloseEvent &event)
 (with its unexpected name so it does not collide with the real OnWindowClose() function provided in derived classes) is called just before a window closing, and is used to call a derivation specific SaveSettings(). More...
 
void commonInit (FRAME_T aFrameType)
 Collect common initialization functions used in all CTORs. More...
 
wxWindow * findQuasiModalDialog ()
 

Private Attributes

TOOL_ACTIONm_exportNetlistAction
 The export board netlist tool action object. More...
 
DIALOG_FINDm_findDialog
 
BOX2D m_lastViewport
 Keep track of viewport so that track net labels can be adjusted when it changes. More...
 
wxTimer m_redrawNetnamesTimer
 
wxTimer * m_eventCounterTimer
 
NL_PCBNEW_PLUGINm_spaceMouse
 
BASE_SCREENm_currentScreen
 current used SCREEN More...
 
EDA_DRAW_PANEL_GALm_canvas
 This the frame's interface to setting GAL display options. More...
 
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
 
KIWAYm_kiway
 
HOLDER_TYPE m_type
 
const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_userUnits
 

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

112 {
113 UNDO_LIST,
115 };

Constructor & Destructor Documentation

◆ ~PCB_EDIT_FRAME()

PCB_EDIT_FRAME::~PCB_EDIT_FRAME ( )
virtual

Definition at line 454 of file pcb_edit_frame.cpp.

455{
456 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
457 {
458 // Stop the timer during destruction early to avoid potential event race conditions (that do happen on windows)
459 m_eventCounterTimer->Stop();
460 delete m_eventCounterTimer;
461 }
462
463 // Close modeless dialogs
464 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
465
466 if( open_dlg )
467 open_dlg->Close( true );
468
469 // Shutdown all running tools
470 if( m_toolManager )
472
473 if( GetBoard() )
475
477 delete m_appearancePanel;
479 delete m_propertiesPanel;
480}
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void RemoveAllListeners()
Remove all listeners.
Definition: board.cpp:1984
APPEARANCE_CONTROLS * m_appearancePanel
PANEL_SELECTION_FILTER * m_selectionFilterPanel
PROPERTIES_PANEL * m_propertiesPanel
BOARD * GetBoard() const
TOOL_ACTION * m_exportNetlistAction
The export board netlist tool action object.
wxTimer * m_eventCounterTimer
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41

References DIALOG_DRC_WINDOW_NAME, PCB_BASE_FRAME::GetBoard(), ADVANCED_CFG::GetCfg(), PCB_BASE_EDIT_FRAME::m_appearancePanel, m_eventCounterTimer, m_exportNetlistAction, PCB_BASE_EDIT_FRAME::m_propertiesPanel, PCB_BASE_EDIT_FRAME::m_selectionFilterPanel, TOOLS_HOLDER::m_toolManager, BOARD::RemoveAllListeners(), and TOOL_MANAGER::ShutdownAllTools().

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

Reimplemented from PCB_BASE_EDIT_FRAME.

Definition at line 1088 of file pcb_edit_frame.cpp.

1089{
1092 GetCanvas()->Refresh();
1093}
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...
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.

References PCB_BASE_EDIT_FRAME::ActivateGalCanvas(), PCB_BASE_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::Refresh(), and PCB_DRAW_PANEL_GAL::UpdateColors().

Referenced by RunActionPlugin().

◆ AddActionPluginTools()

void PCB_EDIT_FRAME::AddActionPluginTools ( )
protected

Append action plugin buttons to main toolbar.

Definition at line 401 of file pcbnew_action_plugins.cpp.

402{
403 bool need_separator = true;
404 const std::vector<ACTION_PLUGIN*>& orderedPlugins = GetOrderedActionPlugins();
405
406 for( ACTION_PLUGIN* ap : orderedPlugins )
407 {
408 if( GetActionPluginButtonVisible( ap->GetPluginPath(), ap->GetShowToolbarButton() ) )
409 {
410 if( need_separator )
411 {
413 need_separator = false;
414 }
415
416 // Add button
417 wxBitmap bitmap;
418
419 if ( ap->iconBitmap.IsOk() )
420 bitmap = KiScaledBitmap( ap->iconBitmap, this );
421 else
422 bitmap = KiScaledBitmap( BITMAPS::puzzle_piece, this );
423
424 wxAuiToolBarItem* button = m_mainToolBar->AddTool( wxID_ANY, wxEmptyString,
425 bitmap, ap->GetName() );
426
427 Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
428 wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginButton ) );
429
430 // Link action plugin to button
431 ACTION_PLUGINS::SetActionButton( ap, button->GetId() );
432 }
433 }
434}
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
@ puzzle_piece
static void SetActionButton(ACTION_PLUGIN *aAction, int idButton)
Associate a button id to an action plugin.
This is the parent class from where any action plugin class must derive.
Definition: action_plugin.h:39
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
ACTION_TOOLBAR * m_mainToolBar
static std::vector< ACTION_PLUGIN * > GetOrderedActionPlugins()
Return ordered list of plugins in sequence in which they should appear on toolbar or in settings.
void OnActionPluginButton(wxCommandEvent &aEvent)
Launched by the button when an action is called.
static 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...

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

227{
228 if( aFootprint )
229 {
230 GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
231
232 aFootprint->SetFlags( IS_NEW );
233 aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
234
235 // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
236 // built from a board)
237 if( aFootprint->IsFlipped() )
238 aFootprint->Flip( aFootprint->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
239
240 // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
241 // it might be stored in another orientation if the lib is an archive built from a board)
242 aFootprint->SetOrientation( ANGLE_0 );
243 }
244}
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:685
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1636
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:1766
bool IsFlipped() const
Definition: footprint.h:319
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1553
VECTOR2I GetPosition() const override
Definition: footprint.h:192
PCBNEW_SETTINGS * GetPcbNewSettings() const
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
#define IS_NEW
New item, just created.

References BOARD::Add(), ANGLE_0, APPEND, FOOTPRINT::Flip(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetPcbNewSettings(), FOOTPRINT::GetPosition(), IS_NEW, FOOTPRINT::IsFlipped(), 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 547 of file footprint_libraries_utils.cpp.

548{
549 if( aTable == nullptr )
550 aTable = selectLibTable();
551
552 if( aTable == nullptr )
553 return wxEmptyString;
554
555 bool isGlobal = ( aTable == &GFootprintTable );
556
557 wxFileName fn( aFilename );
558
559 if( aFilename.IsEmpty() )
560 {
562 KiCadFootprintLibPathExtension, true, isGlobal,
564 {
565 return false;
566 }
567 }
568
569 wxString libPath = fn.GetFullPath();
570 wxString libName = fn.GetName();
571
572 if( libName.IsEmpty() )
573 return false;
574
575 wxString type = IO_MGR::ShowType( IO_MGR::GuessPluginTypeFromLibPath( libPath ) );
576
577 // try to use path normalized to an environmental variable or project path
578 wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
579
580 try
581 {
582 FP_LIB_TABLE_ROW* row = new FP_LIB_TABLE_ROW( libName, normalizedPath, type, wxEmptyString );
583 aTable->InsertRow( row );
584
585 if( isGlobal )
587 else
588 Prj().PcbFootprintLibs()->Save( Prj().FootprintLibTblName() );
589 }
590 catch( const IO_ERROR& ioe )
591 {
592 DisplayError( this, ioe.What() );
593 return false;
594 }
595
597
598 if( editor )
599 {
600 LIB_ID libID( libName, wxEmptyString );
601 editor->SyncLibraryTree( true );
602 editor->FocusOnLibID( libID );
603 }
604
605 auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
606
607 if( viewer )
608 viewer->ReCreateLibraryList();
609
610 return true;
611}
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.
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
static wxString GetGlobalTableFileName()
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
static const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
Definition: io_mgr.cpp:77
static PCB_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath)
Return a plugin type given a footprint library's libPath.
Definition: io_mgr.cpp:124
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
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.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:318
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
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
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
const std::string KiCadFootprintLibPathExtension
wxString KiCadFootprintLibPathWildcard()
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

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_CONTROL::AddLibrary(), and 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 443 of file eda_base_frame.cpp.

444{
446 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
447
448 helpMenu->Add( ACTIONS::help );
449 helpMenu->Add( ACTIONS::gettingStarted );
450 helpMenu->Add( ACTIONS::listHotKeys );
451 helpMenu->Add( ACTIONS::getInvolved );
452 helpMenu->Add( ACTIONS::donate );
453 helpMenu->Add( ACTIONS::reportBug );
454
455 helpMenu->AppendSeparator();
456 helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
457
458 // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
459 aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
460}
static TOOL_ACTION reportBug
Cursor control event types.
Definition: actions.h:186
static TOOL_ACTION donate
Definition: actions.h:184
static TOOL_ACTION listHotKeys
Definition: actions.h:183
static TOOL_ACTION getInvolved
Definition: actions.h:185
static TOOL_ACTION gettingStarted
Definition: actions.h:181
static TOOL_ACTION help
Definition: actions.h:182
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
Handle actions that are shared between different applications.
#define _(s)

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(), CVPCB_MAINFRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_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 546 of file eda_draw_frame.cpp.

547{
549 CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
550
551 aMenu.AddSeparator( 1000 );
552
553 std::shared_ptr<ZOOM_MENU> zoomMenu = std::make_shared<ZOOM_MENU>( this );
554 zoomMenu->SetTool( commonTools );
555 aToolMenu.RegisterSubMenu( zoomMenu );
556
557 std::shared_ptr<GRID_MENU> gridMenu = std::make_shared<GRID_MENU>( this );
558 gridMenu->SetTool( commonTools );
559 aToolMenu.RegisterSubMenu( gridMenu );
560
561 aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
562 aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
563}
Handles action that are shared between different applications.
Definition: common_tools.h:38
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44

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

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

◆ AppendCopyToUndoList()

void PCB_BASE_EDIT_FRAME::AppendCopyToUndoList ( const PICKED_ITEMS_LIST aItemsList,
UNDO_REDO  aCommandType 
)
overridevirtualinherited

As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.

Implements PCB_BASE_FRAME.

Definition at line 319 of file undo_redo.cpp.

321{
322 PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList();
323
324 if( !commandToUndo )
325 commandToUndo = new PICKED_ITEMS_LIST();
326
327 saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
328}
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
void saveCopyInUndoList(PICKED_ITEMS_LIST *commandToUndo, const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType)
Definition: undo_redo.cpp:179
A holder to handle information on schematic or board items.

References EDA_BASE_FRAME::PopCommandFromUndoList(), and PCB_BASE_EDIT_FRAME::saveCopyInUndoList().

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

710{
711 if( m_messagePanel )
712 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
713}
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:93

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 379 of file pcbnew_action_plugins.cpp.

380{
381 if( !actionMenu ) // Should not occur.
382 return;
383
384 for( int ii = 0; ii < ACTION_PLUGINS::GetActionsCount(); ii++ )
385 {
386 wxMenuItem* item;
388 const wxBitmap& bitmap = ap->iconBitmap.IsOk() ? ap->iconBitmap :
390
391 item = AddMenuItem( actionMenu, wxID_ANY, ap->GetName(), ap->GetDescription(), bitmap );
392
393 Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
394 wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginMenu ) );
395
396 ACTION_PLUGINS::SetActionMenu( ii, item->GetId() );
397 }
398}
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
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
static int GetActionsCount()
static ACTION_PLUGIN * GetAction(const wxString &aName)
static void SetActionMenu(int aIndex, int idMenu)
Associate a menu id to an action plugin.
wxBitmap iconBitmap
virtual wxString GetDescription()=0
virtual wxString GetName()=0
void OnActionPluginMenu(wxCommandEvent &aEvent)
Launched by the menu when an action is called.

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

966{
967 // Shutdown blocks must be determined and vetoed as early as possible
968 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
969 && IsContentModified() )
970 {
971 return false;
972 }
973
974 if( Kiface().IsSingle() )
975 {
976 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
977
978 if( fpEditor && !fpEditor->Close() ) // Can close footprint editor?
979 return false;
980
981 auto* fpViewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
982
983 if( fpViewer && !fpViewer->Close() ) // Can close footprint viewer?
984 return false;
985
987
988 if( fpViewer && !fpViewer->Close() ) // Can close modal footprint viewer?
989 return false;
990 }
991 else
992 {
993 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
994
995 if( fpEditor && fpEditor->IsCurrentFPFromBoard() )
996 {
997 if( !fpEditor->CanCloseFPFromBoard( true ) )
998 return false;
999 }
1000 }
1001
1002 if( IsContentModified() )
1003 {
1004 wxFileName fileName = GetBoard()->GetFileName();
1005 wxString msg = _( "Save changes to '%s' before closing?" );
1006
1007 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1008 [&]() -> bool
1009 {
1010 return Files_io_from_id( ID_SAVE_BOARD );
1011 } ) )
1012 {
1013 return false;
1014 }
1015 }
1016
1017 // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
1018 // board.
1019 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
1020
1021 if( open_dlg )
1022 open_dlg->Close( true );
1023
1024 return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
1025}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
const wxString & GetFileName() const
Definition: board.h:302
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
bool IsContentModified() const override
Get if the current board has been modified but not saved.
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:240
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
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

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

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inherited

Definition at line 1303 of file eda_base_frame.cpp.

1304{
1305 SetUserUnits( aUnits );
1307
1308 wxCommandEvent e( UNITS_CHANGED );
1309 ProcessEventLocally( e );
1310}
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 UNITS_PROVIDER::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 1191 of file eda_base_frame.cpp.

1192{
1193 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1194
1195 wxFileName autoSaveFileName = aFileName;
1196
1197 // Check for auto save file.
1198 autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
1199
1200 wxLogTrace( traceAutoSave,
1201 wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
1202
1203 if( !autoSaveFileName.FileExists() )
1204 return;
1205
1206 wxString msg = wxString::Format( _(
1207 "Well this is potentially embarrassing!\n"
1208 "It appears that the last time you were editing the file\n"
1209 "%s\n"
1210 "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
1211 aFileName.GetFullName()
1212 );
1213
1214 int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1215 this );
1216
1217 // Make a backup of the current file, delete the file, and rename the auto save file to
1218 // the file name.
1219 if( response == wxYES )
1220 {
1221 if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
1222 {
1223 wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
1224 Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1225 }
1226 }
1227 else
1228 {
1229 wxLogTrace( traceAutoSave,
1230 wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
1231
1232 // Remove the auto save file when using the previous file as is.
1233 wxRemoveFile( autoSaveFileName.GetFullPath() );
1234 }
1235}
static wxString GetAutoSaveFilePrefix()
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.

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.

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
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() );
89
90 Zoom_Automatique( false );
91 }
92
93 return true;
94}
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:46
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
void SetFileName(const wxString &aFileName)
Definition: board.h:300
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:520
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:2002
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:532
void SetCopperLayerCount(int aCount)
Definition: board.cpp:494
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
void ReleaseFile()
Release the current file marked in use.
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:530
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...
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.
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 ReCreateAuxiliaryToolbar() override
void UpdateTitle()
Set the main window title bar text.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:342

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 doCloseWindow(), 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 948 of file eda_base_frame.cpp.

949{
950 if( !aFileHistory )
951 aFileHistory = m_fileHistory;
952
953 wxASSERT( aFileHistory );
954
955 aFileHistory->ClearFileHistory();
956
957 // Update the menubar to update the file history menu
958 if( GetMenuBar() )
959 {
961 GetMenuBar()->Refresh();
962 }
963}
FILE_HISTORY * m_fileHistory
virtual void ReCreateMenuBar()
Recreates the menu bar.
void ClearFileHistory()
Clear all entries from the file history.

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

Referenced by GERBVIEW_FRAME::OnClearDrlFileHistory(), SCH_EDIT_FRAME::OnClearFileHistory(), KICAD_MANAGER_FRAME::OnClearFileHistory(), PL_EDITOR_FRAME::OnClearFileHistory(), 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 579 of file undo_redo.cpp.

580{
581 if( aItemCount == 0 )
582 return;
583
584 UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
585 unsigned icnt = list.m_CommandsList.size();
586
587 if( aItemCount > 0 )
588 icnt = aItemCount;
589
590 for( unsigned ii = 0; ii < icnt; ii++ )
591 {
592 if( list.m_CommandsList.size() == 0 )
593 break;
594
595 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
596 list.m_CommandsList.erase( list.m_CommandsList.begin() );
597
598 curr_cmd->ClearListAndDeleteItems();
599 delete curr_cmd; // Delete command
600 }
601}
UNDO_REDO_CONTAINER m_undoList
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...
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList

References PICKED_ITEMS_LIST::ClearListAndDeleteItems(), UNDO_REDO_CONTAINER::m_CommandsList, EDA_BASE_FRAME::m_redoList, EDA_BASE_FRAME::m_undoList, and EDA_BASE_FRAME::UNDO_LIST.

Referenced by PCB_BASE_EDIT_FRAME::saveCopyInUndoList().

◆ ClearUndoRedoList()

◆ commonInit()

void EDA_BASE_FRAME::commonInit ( FRAME_T  aFrameType)
privateinherited

Collect common initialization functions used in all CTORs.

Definition at line 117 of file eda_base_frame.cpp.

118{
119 m_ident = aFrameType;
120 m_maximizeByDefault = false;
121 m_infoBar = nullptr;
122 m_settingsManager = nullptr;
123 m_fileHistory = nullptr;
124 m_supportsAutoSave = false;
125 m_autoSaveState = false;
127 m_isClosing = false;
128 m_isNonUserClose = false;
129 m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
131 m_frameSize = defaultSize( aFrameType );
132 m_displayIndex = -1;
133
134 m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
135
136 m_settingsManager = &Pgm().GetSettingsManager();
137
138 // Set a reasonable minimal size for the frame
139 SetSizeHints( minSize( aFrameType ).x, minSize( aFrameType ).y, -1, -1, -1, -1 );
140
141 // Store dimensions of the user area of the main window.
142 GetClientSize( &m_frameSize.x, &m_frameSize.y );
143
144 Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
145 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
146
147 // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
148 // to be called before any other hook for wxCloseEvent, which is necessary.
149 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
150
151 initExitKey();
152}
void windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
void initExitKey()
Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
WX_INFOBAR * m_infoBar
void onAutoSaveTimer(wxTimerEvent &aEvent)
Handle the auto save timer event.
wxTimer * m_autoSaveTimer
wxAuiManager m_auimgr
SETTINGS_MANAGER * m_settingsManager
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
wxString m_mruPath
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:139
static const wxSize minSize(FRAME_T aFrameType)
static const wxSize defaultSize(FRAME_T aFrameType)
#define DEFAULT_MAX_UNDO_ITEMS
@ ID_AUTO_SAVE_TIMER
Definition: id.h:79

References DEFAULT_MAX_UNDO_ITEMS, defaultSize(), PATHS::GetDefaultUserProjectsPath(), ID_AUTO_SAVE_TIMER, minSize(), EDA_BASE_FRAME::onAutoSaveTimer(), Pgm(), and EDA_BASE_FRAME::windowClosing().

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

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

1903{
1904 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1905
1907
1908 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
1909 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
1910 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1911
1912 renderSettings->LoadDisplayOptions( GetDisplayOptions() );
1913
1914 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1915
1917
1918 // Netclass definitions could have changed, either by us or by Eeschema, so we need to
1919 // recompile the implicit rules
1920 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1921 WX_INFOBAR* infobar = GetInfoBar();
1922
1923 try
1924 {
1925 drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1926
1927 if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR )
1928 infobar->Dismiss();
1929 }
1930 catch( PARSE_ERROR& )
1931 {
1932 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
1933 wxEmptyString );
1934
1935 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1936 [&]( wxHyperlinkEvent& aEvent )
1937 {
1938 ShowBoardSetupDialog( _( "Custom Rules" ) );
1939 } ) );
1940
1941 infobar->RemoveAllButtons();
1942 infobar->AddButton( button );
1943 infobar->AddCloseButton();
1944 infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR,
1946 }
1947
1950
1951 // Update the environment variables in the Python interpreter
1952 if( aEnvVarsChanged )
1954
1955 Layout();
1956 SendSizeEvent();
1957}
void OnColorThemeChanged()
Update the widget when the active board layer is changed.
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition: drc_tool.h:78
WX_INFOBAR * GetInfoBar()
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void ForceRefresh()
Force a redraw.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:156
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:161
PCB specific render settings.
Definition: pcb_painter.h:71
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:617
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
APPEARANCE_CONTROLS * GetAppearancePanel()
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Change the visibility of an element category.
void PythonSyncEnvironmentVariables()
Synchronize the environment variables from KiCad's environment into the Python interpreter.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:75
@ LAYER_RATSNEST
Definition: layer_ids.h:204
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:119

References _, PCB_BASE_FRAME::CommonSettingsChanged(), WX_INFOBAR::DRC_RULES_ERROR, EDA_DRAW_PANEL_GAL::ForceRefresh(), PCB_BASE_EDIT_FRAME::GetAppearancePanel(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_EDIT_FRAME::GetDesignRulesPath(), PCB_BASE_FRAME::GetDisplayOptions(), DRC_TOOL::GetDRCEngine(), EDA_DRAW_FRAME::GetGalDisplayOptions(), EDA_BASE_FRAME::GetInfoBar(), KIGFX::VIEW::GetPainter(), PCB_BASE_FRAME::GetPcbNewSettings(), KIGFX::PCB_PAINTER::GetSettings(), TOOL_MANAGER::GetTool(), PCB_DRAW_PANEL_GAL::GetView(), LAYER_RATSNEST, KIGFX::PCB_RENDER_SETTINGS::LoadDisplayOptions(), TOOLS_HOLDER::m_toolManager, KIGFX::VIEW::MarkTargetDirty(), APPEARANCE_CONTROLS::OnColorThemeChanged(), PythonSyncEnvironmentVariables(), KIGFX::GAL_DISPLAY_OPTIONS::ReadWindowSettings(), SetElementVisibility(), ShowBoardSetupDialog(), and KIGFX::TARGET_NONCACHED.

◆ 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
aDisplayStatusif true, display the computation results.

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

Parameters
aDisplayStatus: if true, display the computation results

Definition at line 35 of file ratsnest.cpp.

36{
37 GetBoard()->GetConnectivity()->RecalculateRatsnest();
39
40 if( aDisplayStatus )
42}
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:239
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.

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

Referenced by DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), DIALOG_GLOBAL_DELETION::DoGlobalDeletions(), ExportToGenCAD(), OnNetlistChanged(), DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked(), PCB_BASE_FRAME::PlaceFootprint(), and PCB_BASE_EDIT_FRAME::PutDataInPreviousState().

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

789{
790 // KICAD_MANAGER_FRAME overrides this
791 return Kiface().KifaceSettings();
792}
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93

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(), SIM_PLOT_FRAME::doCloseWindow(), FOOTPRINT_WIZARD_FRAME::doCloseWindow(), SCH_BASE_FRAME::eeconfig(), GERBVIEW_FRAME::GERBVIEW_FRAME(), GetRotationAngle(), GRID_MENU::GRID_MENU(), COMMON_TOOLS::GridFast1(), COMMON_TOOLS::GridFast2(), GERBVIEW_FRAME::gvconfig(), EDA_DRAW_FRAME::IsGridVisible(), SCH_BASE_FRAME::libeditconfig(), EDA_DRAW_FRAME::OnUpdateSelectGrid(), EDA_DRAW_FRAME::OnUpdateSelectZoom(), 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(), CVPCB_MAINFRAME::setupTools(), SCH_EDIT_FRAME::setupTools(), SYMBOL_VIEWER_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), PL_EDITOR_FRAME::setupTools(), setupTools(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), GRID_MENU::update(), ZOOM_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 341 of file eda_base_frame.h.

342 {
343 wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
344 return baseCfgName;
345 }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

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

682{
683 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
684
685 if( !draw3DFrame )
686 draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
687
688 // Raising the window does not show the window on Windows if iconized. This should work
689 // on any platform.
690 if( draw3DFrame->IsIconized() )
691 draw3DFrame->Iconize( false );
692
693 draw3DFrame->Raise();
694 draw3DFrame->Show( true );
695
696 // Raising the window does not set the focus on Linux. This should work on any platform.
697 if( wxWindow::FindFocus() != draw3DFrame )
698 draw3DFrame->SetFocus();
699
700 // Allocate a slice of time to display the 3D frame
701 // a call to wxSafeYield() should be enough (and better), but on Linux we need
702 // to call wxYield()
703 // otherwise the activity messages are not displayed during the first board loading
704 wxYield();
705
706 // Note, the caller is responsible to load/update the board 3D view.
707 // after frame creation the board is not automatically created.
708
709 return draw3DFrame;
710}
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
EDA_3D_VIEWER_FRAME * Get3DViewerFrame()

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

Referenced by PCB_VIEWER_TOOLS::Show3DViewer().

◆ CreateInfoBar()

void EDA_BASE_FRAME::CreateInfoBar ( )
inherited

Definition at line 813 of file eda_base_frame.cpp.

814{
815#if defined( __WXOSX_MAC__ )
817#else
818 m_infoBar = new WX_INFOBAR( this, &m_auimgr );
819
820 m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
821#endif
822}
Specialization of the wxAuiPaneInfo class for KiCad panels.
virtual wxWindow * GetToolCanvas() const =0
Canvas access.

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

1232{
1233 wxString footprintName = aFootprintName;
1234
1235 // Static to store user preference for a session
1236 static int footprintType = 1;
1237 int footprintTranslated = FP_SMD;
1238
1239 // Ask for the new footprint name
1240 if( footprintName.IsEmpty() && !aQuiet )
1241 {
1242 WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
1243 footprintName, _( "Footprint type:" ),
1244 { _( "Through hole" ), _( "SMD" ), _( "Other" ) },
1245 footprintType );
1246 dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &footprintName ) );
1247
1248 if( dlg.ShowModal() != wxID_OK )
1249 return nullptr; //Aborted by user
1250
1251 footprintType = dlg.GetChoice();
1252
1253 switch( footprintType )
1254 {
1255 case 0: footprintTranslated = FP_THROUGH_HOLE; break;
1256 case 1: footprintTranslated = FP_SMD; break;
1257 default: footprintTranslated = 0; break;
1258 }
1259 }
1260
1261 footprintName.Trim( true );
1262 footprintName.Trim( false );
1263
1264 if( footprintName.IsEmpty() )
1265 {
1266 if( !aQuiet )
1267 DisplayInfoMessage( this, _( "No footprint name defined." ) );
1268
1269 return nullptr;
1270 }
1271
1272 // Creates the new footprint and add it to the head of the linked list of footprints
1273 FOOTPRINT* footprint = new FOOTPRINT( GetBoard() );
1274
1275 // Update its name in lib
1276 footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
1277
1278 footprint->SetAttributes( footprintTranslated );
1279
1280 PCB_LAYER_ID txt_layer;
1281 wxPoint default_pos;
1283
1284 footprint->Reference().SetText( settings.m_DefaultFPTextItems[0].m_Text );
1285 footprint->Reference().SetVisible( settings.m_DefaultFPTextItems[0].m_Visible );
1286 txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[0].m_Layer;
1287 footprint->Reference().SetLayer( txt_layer );
1288 default_pos.y -= settings.GetTextSize( txt_layer ).y / 2;
1289 footprint->Reference().SetPosition( default_pos );
1290 default_pos.y += settings.GetTextSize( txt_layer ).y;
1291
1292 footprint->Value().SetText( settings.m_DefaultFPTextItems[1].m_Text );
1293 footprint->Value().SetVisible( settings.m_DefaultFPTextItems[1].m_Visible );
1294 txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[1].m_Layer;
1295 footprint->Value().SetLayer( txt_layer );
1296 default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
1297 footprint->Value().SetPosition( default_pos );
1298 default_pos.y += settings.GetTextSize( txt_layer ).y;
1299
1300 for( size_t i = 2; i < settings.m_DefaultFPTextItems.size(); ++i )
1301 {
1302 FP_TEXT* textItem = new FP_TEXT( footprint );
1303 textItem->SetText( settings.m_DefaultFPTextItems[i].m_Text );
1304 textItem->SetVisible( settings.m_DefaultFPTextItems[i].m_Visible );
1305 txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[i].m_Layer;
1306 textItem->SetLayer( txt_layer );
1307 default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
1308 textItem->SetPosition( default_pos );
1309 default_pos.y += settings.GetTextSize( txt_layer ).y;
1310 footprint->GraphicalItems().push_back( textItem );
1311 }
1312
1313 if( footprint->GetReference().IsEmpty() )
1314 footprint->SetReference( footprintName );
1315
1316 if( footprint->GetValue().IsEmpty() )
1317 footprint->SetValue( footprintName );
1318
1319 footprint->RunOnChildren(
1320 [&] ( BOARD_ITEM* aChild )
1321 {
1322 if( aChild->Type() == PCB_FP_TEXT_T )
1323 {
1324 FP_TEXT* textItem = static_cast<FP_TEXT*>( aChild );
1325 PCB_LAYER_ID layer = textItem->GetLayer();
1326
1327 textItem->SetTextThickness( settings.GetTextThickness( layer ) );
1328 textItem->SetTextSize( settings.GetTextSize( layer ) );
1329 textItem->SetItalic( settings.GetTextItalic( layer ) );
1330 textItem->SetKeepUpright( settings.GetTextUpright( layer ) );
1331 }
1332 } );
1333
1334 SetMsgPanel( footprint );
1335 return footprint;
1336}
Container for design settings for a BOARD object.
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
bool GetTextUpright(PCB_LAYER_ID aLayer) const
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
bool GetTextItalic(PCB_LAYER_ID aLayer) const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:167
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:201
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:185
void SetKeepUpright(bool aKeepUpright)
Definition: eda_text.cpp:256
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
This class provides a custom wxValidator object for limiting the allowable characters when defining f...
Definition: validators.h:64
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:208
void SetAttributes(int aAttributes)
Definition: footprint.h:246
void SetReference(const wxString &aReference)
Definition: footprint.h:528
void SetValue(const wxString &aValue)
Definition: footprint.h:549
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:555
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:1356
const wxString & GetValue() const
Definition: footprint.h:541
const wxString & GetReference() const
Definition: footprint.h:519
DRAWINGS & GraphicalItems()
Definition: footprint.h:177
FP_TEXT & Reference()
Definition: footprint.h:556
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: fp_text.h:92
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
void SetTextValidator(wxTextValidatorStyle style)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:320
@ FP_SMD
Definition: footprint.h:68
@ FP_THROUGH_HOLE
Definition: footprint.h:67
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

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(), EDA_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,
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 402 of file footprint_libraries_utils.cpp.

405{
406 // Kicad cannot write legacy format libraries, only .pretty new format because the legacy
407 // format cannot handle current features.
408 // The footprint library is actually a directory.
409
410 if( aTable == nullptr )
411 return wxEmptyString;
412
413 wxString initialPath = aProposedName.IsEmpty() ? Prj().GetProjectPath() : aProposedName;
414 wxFileName fn;
415 bool doAdd = false;
416 bool isGlobal = ( aTable == &GFootprintTable );
417
418 if( aLibName.IsEmpty() )
419 {
420 fn = initialPath;
421
423 KiCadFootprintLibPathExtension, false, isGlobal,
425 {
426 return wxEmptyString;
427 }
428
429 doAdd = true;
430 }
431 else
432 {
433 fn = aLibName;
434
435 if( !fn.IsAbsolute() )
436 {
437 fn.SetName( aLibName );
438 fn.MakeAbsolute( initialPath );
439 }
440
441 // Enforce the .pretty extension:
443 }
444
445 // We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries)
447 wxString libPath = fn.GetFullPath();
448
449 try
450 {
451 PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
452
453 bool writable = false;
454 bool exists = false;
455
456 try
457 {
458 writable = pi->IsFootprintLibWritable( libPath );
459 exists = true; // no exception was thrown, lib must exist.
460 }
461 catch( const IO_ERROR& )
462 {
463 // best efforts....
464 }
465
466 if( exists )
467 {
468 if( !writable )
469 {
470 wxString msg = wxString::Format( _( "Library %s is read only." ), libPath );
471 ShowInfoBarError( msg );
472 return wxEmptyString;
473 }
474 else
475 {
476 wxString msg = wxString::Format( _( "Library %s already exists." ), libPath );
477 KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
478 dlg.SetOKLabel( _( "Overwrite" ) );
479 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
480
481 if( dlg.ShowModal() == wxID_CANCEL )
482 return wxEmptyString;
483
484 pi->FootprintLibDelete( libPath );
485 }
486 }
487
488 pi->FootprintLibCreate( libPath );
489 }
490 catch( const IO_ERROR& ioe )
491 {
492 DisplayError( this, ioe.What() );
493 return wxEmptyString;
494 }
495
496 if( doAdd )
497 AddLibrary( libPath, aTable );
498
499 return libPath;
500}
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...
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:54
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition: io_mgr.h:56
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
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:46
bool AddLibrary(const wxString &aLibName=wxEmptyString, FP_LIB_TABLE *aTable=nullptr)
Add an existing library to either the global or project library table.
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:564
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:125

References _, PCB_BASE_EDIT_FRAME::AddLibrary(), DisplayError(), KIDIALOG::DoNotShowCheckbox(), PLUGIN::FootprintLibCreate(), PLUGIN::FootprintLibDelete(), Format(), PATHS::GetDefaultUserFootprintsPath(), PROJECT::GetProjectPath(), GFootprintTable, PLUGIN::IsFootprintLibWritable(), 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().

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

395{
396 FP_LIB_TABLE* table = selectLibTable();
397
398 return createNewLibrary( aLibName, aProposedName, table );
399}
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(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().

◆ CreateNewProjectLibrary()

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

Definition at line 386 of file footprint_libraries_utils.cpp.

388{
389 return createNewLibrary( aLibName, aProposedName, Prj().PcbFootprintLibs() );
390}

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 if( m_socketServer )
55 {
56 // this helps prevent any events that could come in during deletion
57 m_socketServer->Notify( false );
58 delete m_socketServer;
59 }
60
61 m_socketServer = new wxSocketServer( addr );
62
63 m_socketServer->SetNotify( wxSOCKET_CONNECTION_FLAG );
64 m_socketServer->SetEventHandler( *this, ID_EDA_SOCKET_EVENT_SERV );
65 m_socketServer->Notify( true );
66}
wxSocketServer * m_socketServer
Definition: kiway_player.h:218
static const wxString HOSTNAME(wxT("localhost"))
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:163

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 110 of file tools_holder.cpp.

111{
112 if( m_toolStack.empty() )
114 else
115 return m_toolStack.back();
116}
static TOOL_ACTION selectionTool
Definition: actions.h:156
std::vector< std::string > m_toolStack
Definition: tools_holder.h:176
const std::string & GetName() const
Return name of the action.
Definition: tool_action.h:101

References TOOL_ACTION::GetName(), TOOLS_HOLDER::m_toolStack, and ACTIONS::selectionTool.

Referenced by TOOLS_HOLDER::ShowChangedLanguage().

◆ Destroy()

◆ DismissModal()

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

Definition at line 182 of file kiway_player.cpp.

183{
184 m_modal_ret_val = aRetVal;
185 m_modal_string = aResult;
186
187 if( m_modal_loop )
188 {
189 m_modal_loop->Exit();
190 m_modal_loop = nullptr; // this marks it as dismissed.
191 }
192
193 Show( false );
194}
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
bool m_modal_ret_val
Definition: kiway_player.h:216

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

573{
574 SetStatusText( msg, 7 );
575}

Referenced by EDIT_TOOL::doMoveSelection(), and 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 780 of file pcb_base_frame.cpp.

781{
782 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
783 wxString line;
784
785 line.Printf( wxT( "grid X %s Y %s" ),
786 MessageTextFromValue( gridSize.x, false ),
787 MessageTextFromValue( gridSize.y, false ) );
788
789 SetStatusText( line, 4 );
790}
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
const VECTOR2D & GetGridSize() const
Return the grid size.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().

References PCB_BASE_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetGAL(), KIGFX::GAL::GetGridSize(), UNITS_PROVIDER::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 566 of file eda_draw_frame.cpp.

567{
568 SetStatusText( msg, 6 );
569}

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

589{
590 wxString msg;
591
592 switch( GetUserUnits() )
593 {
594 case EDA_UNITS::INCHES: msg = _( "inches" ); break;
595 case EDA_UNITS::MILS: msg = _( "mils" ); break;
596 case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
597 default: msg = _( "Units" ); break;
598 }
599
600 SetStatusText( msg, 5 );
601}
EDA_UNITS GetUserUnits() const

References _, UNITS_PROVIDER::GetUserUnits(), INCHES, 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 1202 of file pcbnew/files.cpp.

1203{
1204 wxFileName tmpFileName;
1205
1206 // Don't run autosave if content has not been modified
1207 if( !IsContentModified() )
1208 return true;
1209
1210 wxString title = GetTitle(); // Save frame title, that can be modified by the save process
1211
1212 if( GetBoard()->GetFileName().IsEmpty() )
1213 {
1214 tmpFileName = wxFileName( PATHS::GetDefaultUserProjectsPath(), NAMELESS_PROJECT,
1216 GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1217 }
1218 else
1219 {
1220 tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
1221 }
1222
1223 wxFileName autoSaveFileName = tmpFileName;
1224
1225 // Auto save file name is the board file name prepended with autosaveFilePrefix string.
1226 autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() );
1227
1228 if( !autoSaveFileName.IsOk() )
1229 return false;
1230
1231 // If the board file path is not writable, try writing to a platform specific temp file
1232 // path. If that path isn't writable, give up.
1233 if( !autoSaveFileName.IsDirWritable() )
1234 {
1235 autoSaveFileName.SetPath( wxFileName::GetTempDir() );
1236
1237 if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
1238 return false;
1239 }
1240
1241 wxLogTrace( traceAutoSave,
1242 wxT( "Creating auto save file <" ) + autoSaveFileName.GetFullPath() + wxT( ">" ) );
1243
1244 if( SavePcbFile( autoSaveFileName.GetFullPath(), false, false ) )
1245 {
1247 GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1248 UpdateTitle();
1249 m_autoSaveState = false;
1250
1251 if( !Kiface().IsSingle() &&
1252 GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
1253 {
1255 }
1256
1257 SetTitle( title ); // Restore initial frame title
1258
1259 return true;
1260 }
1261
1262 GetBoard()->SetFileName( tmpFileName.GetFullPath() );
1263
1264 SetTitle( title ); // Restore initial frame title
1265
1266 return false;
1267}
SETTINGS_MANAGER * GetSettingsManager() const
static REPORTER & GetInstance()
Definition: reporter.cpp:117
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Write the board data structures to a aFileName.
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:304
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
const std::string KiCadPcbFileExtension
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41

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

1029{
1030 // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
1031 // when closing this frame if a footprint was selected, and the footprint editor called
1032 // to edit this footprint, and when closing pcbnew if this footprint is still selected
1033 // See https://bugs.launchpad.net/kicad/+bug/1655858
1034 // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
1035 // avoid the crash (JPC)
1036 GetCanvas()->SetEvtHandlerEnabled( false );
1037
1039
1040 // Delete the auto save file if it exists.
1041 wxFileName fn = GetBoard()->GetFileName();
1042
1043 // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
1044 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
1045
1046 // When the auto save feature does not have write access to the board file path, it falls
1047 // back to a platform specific user temporary file path.
1048 if( !fn.IsOk() || !fn.IsDirWritable() )
1049 fn.SetPath( wxFileName::GetTempDir() );
1050
1051 wxLogTrace( traceAutoSave, wxT( "Deleting auto save file <" ) + fn.GetFullPath() + wxT( ">" ) );
1052
1053 // Remove the auto save file on a normal close of Pcbnew.
1054 if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
1055 {
1056 wxString msg = wxString::Format( _( "The auto save file '%s' could not be removed!" ),
1057 fn.GetFullPath() );
1058 wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
1059 }
1060
1061 // Make sure local settings are persisted
1063
1064 // Do not show the layer manager during closing to avoid flicker
1065 // on some platforms (Windows) that generate useless redraw of items in
1066 // the Layer Manager
1068 {
1069 m_auimgr.GetPane( "LayersManager" ).Show( false );
1070 m_auimgr.GetPane( "TabbedPanel" ).Show( false );
1071 }
1072
1073 // Unlink the old project if needed
1075
1076 // Delete board structs and undo/redo lists, to avoid crash on exit
1077 // when deleting some structs (mainly in undo/redo lists) too late
1078 Clear_Pcb( false, true );
1079
1080 // do not show the window because ScreenPcb will be deleted and we do not
1081 // want any paint event
1082 Show( false );
1083
1085}
void ClearProject()
Definition: board.cpp:196
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void doCloseWindow() override
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
bool Clear_Pcb(bool aQuery, bool aFinal=false)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:43
bool m_show_layer_manager_tools

References _, Clear_Pcb(), BOARD::ClearProject(), PCB_BASE_EDIT_FRAME::doCloseWindow(), Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetFileName(), EDA_BASE_FRAME::m_auimgr, m_show_layer_manager_tools, Pgm(), SaveProjectSettings(), EDA_DRAW_PANEL_GAL::StopDrawing(), 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,
bool  aNegateBottomX 
)

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
aNegateBottomXtrue to negate X coordinates for bottom side of the placement file
Returns
the number of footprints found on aSide side or -1 if the file could not be created.

Definition at line 541 of file gen_footprints_placefile.cpp.

545{
546 FILE * file = nullptr;
547
548 if( !aFullFileName.IsEmpty() )
549 {
550 file = wxFopen( aFullFileName, wxT( "wt" ) );
551
552 if( file == nullptr )
553 return -1;
554 }
555
556 std::string data;
557 PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aOnlySMD, aNoTHItems, aTopSide, aBottomSide,
558 aFormatCSV, aUseAuxOrigin, aNegateBottomX );
559 data = exporter.GenPositionData();
560
561 // if aFullFileName is empty, the file is not created, only the
562 // count of footprints to place is returned
563 if( file )
564 {
565 // Creates a footprint position file
566 // aSide = 0 -> Back (bottom) side)
567 // aSide = 1 -> Front (top) side)
568 // aSide = 2 -> both sides
569 fputs( data.c_str(), file );
570 fclose( file );
571 }
572
573 return exporter.GetFootprintCount();
574}
The ASCII format of the kicad place file is:

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

611{
612 FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
613
614 if( rptfile == nullptr )
615 return false;
616
617 std::string data;
618 PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM,
619 false, false, // SMD aOnlySMD, aNoTHItems
620 true, true, // aTopSide, aBottomSide
621 false, true, false // aFormatCSV, aUseAuxOrigin, aNegateBottomX
622 );
623 data = exporter.GenReportData();
624
625 fputs( data.c_str(), rptfile );
626 fclose( rptfile );
627
628 return true;
629}

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

Referenced by GenFootprintsReport().

◆ DoWithAcceptedFiles()

void EDA_BASE_FRAME::DoWithAcceptedFiles ( )
protectedvirtualinherited

Execute action on accepted dropped file.

Called in OnDropFiles and should be populated with the action to execute in inherited classes.

Reimplemented in GERBVIEW_FRAME, KICAD_MANAGER_FRAME, and PL_EDITOR_FRAME.

Definition at line 1138 of file eda_base_frame.cpp.

1139{
1140 for( const wxFileName& file : m_AcceptedFiles )
1141 {
1142 wxString fn = file.GetFullPath();
1143 m_toolManager->RunAction( *m_acceptedExts.at( file.GetExt() ), true, &fn );
1144 }
1145}
std::vector< wxFileName > m_AcceptedFiles
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associates files extensions with action to execute.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142

References EDA_BASE_FRAME::m_acceptedExts, EDA_BASE_FRAME::m_AcceptedFiles, TOOLS_HOLDER::m_toolManager, and TOOL_MANAGER::RunAction().

Referenced by EDA_BASE_FRAME::OnDropFiles().

◆ Edit_Zone_Params()

void PCB_EDIT_FRAME::Edit_Zone_Params ( ZONE zone_container)

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

Definition at line 38 of file edit_zone_helpers.cpp.

39{
40 int dialogResult;
41 ZONE_SETTINGS zoneInfo = GetZoneSettings();
42 PICKED_ITEMS_LIST pickedList; // zones for undo/redo command
43 PICKED_ITEMS_LIST deletedList; // zones that have been deleted when combined
44 BOARD_COMMIT commit( this );
45
46 // Save initial zones configuration, for undo/redo, before adding new zone
47 // note the net name and the layer can be changed, so we must save all zones
48 deletedList.ClearListAndDeleteItems();
49 pickedList.ClearListAndDeleteItems();
50 SaveCopyOfZones( pickedList, GetBoard(), -1, UNDEFINED_LAYER );
51
52 if( aZone->GetIsRuleArea() )
53 {
54 // edit a rule area on a copper layer
55 zoneInfo << *aZone;
56 dialogResult = InvokeRuleAreaEditor( this, &zoneInfo );
57 }
58 else if( IsCopperLayer( aZone->GetFirstLayer() ) )
59 {
60 // edit a zone on a copper layer
61 zoneInfo << *aZone;
62 dialogResult = InvokeCopperZonesEditor( this, &zoneInfo );
63 }
64 else
65 {
66 zoneInfo << *aZone;
67 dialogResult = InvokeNonCopperZonesEditor( this, &zoneInfo );
68 }
69
70 if( dialogResult == wxID_CANCEL )
71 {
72 deletedList.ClearListAndDeleteItems();
73 pickedList.ClearListAndDeleteItems();
74 return;
75 }
76
77 SetZoneSettings( zoneInfo );
78 OnModify();
79
80 if( dialogResult == ZONE_EXPORT_VALUES )
81 {
82 UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() );
83 commit.Stage( pickedList );
84 commit.Push( _( "Modify zone properties" ) );
85 pickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
86 return;
87 }
88
89 wxBusyCursor dummy;
90
91 // Undraw old zone outlines
92 for( ZONE* zone : GetBoard()->Zones() )
93 GetCanvas()->GetView()->Update( zone );
94
95 zoneInfo.ExportSetting( *aZone );
96
97 NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
98
99 if( net ) // net == NULL should not occur
100 aZone->SetNetCode( net->GetNetCode() );
101
102 UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() );
103
104 commit.Stage( pickedList );
105
106 commit.Push( _( "Modify zone properties" ), SKIP_CONNECTIVITY );
108
109 pickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
110}
#define SKIP_CONNECTIVITY
Definition: board_commit.h:42
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1391
void BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:155
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
Handle the data for a net.
Definition: netinfo.h:66
void SetNetCode(int aNetCode)
Definition: netinfo.h:114
int GetNetCode() const
Definition: netinfo.h:113
const ZONE_SETTINGS & GetZoneSettings() const
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
void OnModify() override
Must be called after a board change to set the modified flag.
void ClearItemsList()
Delete only the list of pickers NOT the picked data itself.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
int m_NetcodeSelection
Definition: zone_settings.h:95
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:823
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
#define ZONE_EXPORT_VALUES
Definition: zones.h:44
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 SaveCopyOfZones(PICKED_ITEMS_LIST &aPickList, BOARD *aPcb, int aNetCode, int aLayer)
Function SaveCopyOfZones creates a copy of zones having a given netcode on a given layer,...

References _, BOARD::BuildConnectivity(), PICKED_ITEMS_LIST::ClearItemsList(), PICKED_ITEMS_LIST::ClearListAndDeleteItems(), dummy(), ZONE_SETTINGS::ExportSetting(), BOARD::FindNet(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), ZONE::GetFirstLayer(), ZONE::GetIsRuleArea(), NETINFO_ITEM::GetNetCode(), PCB_DRAW_PANEL_GAL::GetView(), PCB_BASE_FRAME::GetZoneSettings(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), IsCopperLayer(), ZONE_SETTINGS::m_NetcodeSelection, OnModify(), BOARD_COMMIT::Push(), SaveCopyOfZones(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_BASE_FRAME::SetZoneSettings(), SKIP_CONNECTIVITY, 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 640 of file eda_base_frame.cpp.

641{
642 wxDisplay display( wxDisplay::GetFromWindow( this ) );
643 wxRect clientSize = display.GetClientArea();
644 wxPoint pos = GetPosition();
645 wxSize size = GetWindowSize();
646
647 wxLogTrace( traceDisplayLocation,
648 "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d", clientSize.x, clientSize.y,
649 clientSize.width, clientSize.height );
650
651 if( pos.y < clientSize.y )
652 {
653 wxLogTrace( traceDisplayLocation,
654 "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d", pos.y,
655 clientSize.y );
656 pos.y = clientSize.y;
657 }
658
659 if( pos.x < clientSize.x )
660 {
661 wxLogTrace( traceDisplayLocation,
662 "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d", pos.x,
663 clientSize.x );
664 pos.x = clientSize.x;
665 }
666
667 if( pos.x + size.x - clientSize.x > clientSize.width )
668 {
669 int newWidth = clientSize.width - ( pos.x - clientSize.x );
670 wxLogTrace( traceDisplayLocation,
671 "ensureWindowIsOnScreen: effective width %d above available %d, setting to %d",
672 pos.x + size.x, clientSize.width, newWidth );
673 size.x = newWidth;
674 }
675
676 if( pos.y + size.y - clientSize.y > clientSize.height )
677 {
678 int newHeight = clientSize.height - ( pos.y - clientSize.y );
679 wxLogTrace( traceDisplayLocation,
680 "ensureWindowIsOnScreen: effective height %d above available %d, setting to %d",
681 pos.y + size.y, clientSize.height, newHeight );
682 size.y = newHeight;
683 }
684
685 wxLogTrace( traceDisplayLocation, "Updating window position (%d, %d) with size (%d, %d)",
686 pos.x, pos.y, size.x, size.y );
687
688 SetSize( pos.x, pos.y, size.x, size.y );
689}
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.

References EDA_BASE_FRAME::GetWindowSize(), and traceDisplayLocation.

Referenced by EDA_BASE_FRAME::OnSize().

◆ EraseMsgBox()

void EDA_DRAW_FRAME::EraseMsgBox ( )
inherited

◆ 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,
bool *  aUpdated = nullptr 
)

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

502{
503 PCB_GROUP* parentGroup = aExisting->GetParentGroup();
504 bool dummyBool = false;
505
506 if( !aUpdated )
507 aUpdated = &dummyBool;
508
509 if( parentGroup )
510 {
511 parentGroup->RemoveItem( aExisting );
512 parentGroup->AddItem( aNew );
513 }
514
515 aNew->SetParent( GetBoard() );
516
517 PlaceFootprint( aNew, false );
518
519 // PlaceFootprint will move the footprint to the cursor position, which we don't want. Copy
520 // the original position across.
521 aNew->SetPosition( aExisting->GetPosition() );
522
523 if( aNew->GetLayer() != aExisting->GetLayer() )
524 aNew->Flip( aNew->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
525
526 if( aNew->GetOrientation() != aExisting->GetOrientation() )
527 aNew->SetOrientation( aExisting->GetOrientation() );
528
529 aNew->SetLocked( aExisting->IsLocked() );
530
531 // Now transfer the net info from "old" pads to the new footprint
532 for( PAD* pad : aNew->Pads() )
533 {
534 PAD* pad_model = nullptr;
535
536 // Pads with no copper are never connected to a net
537 if( !pad->IsOnCopperLayer() )
538 {
539 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
540 continue;
541 }
542
543 // Pads with no numbers are never connected to a net
544 if( pad->GetNumber().IsEmpty() )
545 {
546 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
547 continue;
548 }
549
550 // Search for a similar pad on a copper layer, to reuse net info
551 PAD* last_pad = nullptr;
552
553 while( true )
554 {
555 pad_model = aExisting->FindPadByNumber( pad->GetNumber(), last_pad );
556
557 if( !pad_model )
558 break;
559
560 if( pad_model->IsOnCopperLayer() ) // a candidate is found
561 break;
562
563 last_pad = pad_model;
564 }
565
566 if( pad_model )
567 {
568 pad->SetLocalRatsnestVisible( pad_model->GetLocalRatsnestVisible() );
569 pad->SetPinFunction( pad_model->GetPinFunction() );
570 pad->SetPinType( pad_model->GetPinType() );
571 }
572
573 pad->SetNetCode( pad_model ? pad_model->GetNetCode() : NETINFO_LIST::UNCONNECTED );
574 }
575
576 // Copy reference
577 processTextItem( aExisting->Reference(), aNew->Reference(),
578 // never reset reference text
579 false,
580 resetTextLayers, resetTextEffects, aUpdated );
581
582 // Copy value
583 processTextItem( aExisting->Value(), aNew->Value(),
584 // reset value text only when it is a proxy for the footprint ID
585 // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
586 aExisting->GetValue() == aExisting->GetFPID().GetLibItemName(),
587 resetTextLayers, resetTextEffects, aUpdated );
588
589 // Copy fields in accordance with the reset* flags
590 for( BOARD_ITEM* item : aExisting->GraphicalItems() )
591 {
592 FP_TEXT* srcItem = dyn_cast<FP_TEXT*>( item );
593
594 if( srcItem )
595 {
596 FP_TEXT* destItem = getMatchingTextItem( srcItem, aNew );
597
598 if( destItem )
599 {
600 processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects,
601 aUpdated );
602 }
603 else if( !deleteExtraTexts )
604 {
605 aNew->Add( new FP_TEXT( *srcItem ) );
606 }
607 }
608 }
609
610 if( !resetFabricationAttrs )
611 aNew->SetAttributes( aExisting->GetAttributes() );
612
613 // Copy 3D model settings in accordance with the reset* flag
614 if( !reset3DModels )
615 aNew->Models() = aExisting->Models(); // Linked list of 3D models.
616
617 // Updating other parameters
618 const_cast<KIID&>( aNew->m_Uuid ) = aExisting->m_Uuid;
619 aNew->SetProperties( aExisting->GetProperties() );
620 aNew->SetPath( aExisting->GetPath() );
621
622 aCommit.Remove( aExisting );
623 aCommit.Add( aNew );
624
625 aNew->ClearFlags();
626}
bool GetLocalRatsnestVisible() const
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:62
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
const KIID m_Uuid
Definition: eda_item.h:492
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:345
EDA_ANGLE GetOrientation() const
Definition: footprint.h:195
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:220
int GetAttributes() const
Definition: footprint.h:245
PADS & Pads()
Definition: footprint.h:174
const LIB_ID & GetFPID() const
Definition: footprint.h:207
bool IsLocked() const override
Definition: footprint.h:335
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:549
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:188
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:563
const KIID_PATH & GetPath() const
Definition: footprint.h:219
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1151
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:562
Definition: kiid.h:47
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:373
Definition: pad.h:58
const wxString & GetPinType() const
Definition: pad.h:151
const wxString & GetPinFunction() const
Definition: pad.h:145
bool IsOnCopperLayer() const override
Definition: pad.h:236
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:51
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:39
FP_TEXT * getMatchingTextItem(FP_TEXT *aRefItem, FOOTPRINT *aFootprint)
void processTextItem(const FP_TEXT &aSrc, FP_TEXT &aDest, bool resetText, bool resetTextLayers, bool resetTextEffects, bool *aUpdated)

References FOOTPRINT::Add(), COMMIT::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(), PCB_BASE_FRAME::GetPcbNewSettings(), PAD::GetPinFunction(), PAD::GetPinType(), FOOTPRINT::GetPosition(), FOOTPRINT::GetProperties(), FOOTPRINT::GetValue(), FOOTPRINT::GraphicalItems(), FOOTPRINT::IsLocked(), PAD::IsOnCopperLayer(), 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 67 of file pcbnew/cross-probing.cpp.

68{
69 char line[1024];
70 wxString msg;
71 wxString modName;
72 char* idcmd;
73 char* text;
74 int netcode = -1;
75 bool multiHighlight = false;
76 FOOTPRINT* footprint = nullptr;
77 PAD* pad = nullptr;
78 BOARD* pcb = GetBoard();
79
81
83 KIGFX::RENDER_SETTINGS* renderSettings = view->GetPainter()->GetSettings();
84
85 strncpy( line, cmdline, sizeof(line) - 1 );
86 line[sizeof(line) - 1] = 0;
87
88 idcmd = strtok( line, " \n\r" );
89 text = strtok( nullptr, "\"\n\r" );
90
91 if( idcmd == nullptr )
92 return;
93
94 if( strcmp( idcmd, "$NET:" ) == 0 )
95 {
96 if( !crossProbingSettings.auto_highlight )
97 return;
98
99 wxString net_name = FROM_UTF8( text );
100
101 NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
102
103 if( netinfo )
104 {
105 netcode = netinfo->GetNetCode();
106
107 std::vector<MSG_PANEL_ITEM> items;
108 netinfo->GetMsgPanelInfo( this, items );
109 SetMsgPanel( items );
110 }
111 }
112
113 if( strcmp( idcmd, "$NETS:" ) == 0 )
114 {
115 if( !crossProbingSettings.auto_highlight )
116 return;
117
118 wxStringTokenizer netsTok = wxStringTokenizer( FROM_UTF8( text ), wxT( "," ) );
119 bool first = true;
120
121 while( netsTok.HasMoreTokens() )
122 {
123 NETINFO_ITEM* netinfo = pcb->FindNet( netsTok.GetNextToken() );
124
125 if( netinfo )
126 {
127 if( first )
128 {
129 // TODO: Once buses are included in netlist, show bus name
130 std::vector<MSG_PANEL_ITEM> items;
131 netinfo->GetMsgPanelInfo( this, items );
132 SetMsgPanel( items );
133 first = false;
134
135 pcb->SetHighLightNet( netinfo->GetNetCode() );
136 renderSettings->SetHighlight( true, netinfo->GetNetCode() );
137 multiHighlight = true;
138 }
139 else
140 {
141 pcb->SetHighLightNet( netinfo->GetNetCode(), true );
142 renderSettings->SetHighlight( true, netinfo->GetNetCode(), true );
143 }
144 }
145 }
146
147 netcode = -1;
148 }
149 else if( strcmp( idcmd, "$CLEAR" ) == 0 )
150 {
151 if( renderSettings->IsHighlightEnabled() )
152 {
153 renderSettings->SetHighlight( false );
154 view->UpdateAllLayersColor();
155 }
156
157 if( pcb->IsHighLightNetON() )
158 {
159 pcb->ResetNetHighLight();
160 SetMsgPanel( pcb );
161 }
162
163 GetCanvas()->Refresh();
164 return;
165 }
166
167 BOX2I bbox;
168
169 if( footprint )
170 {
171 bbox = footprint->GetBoundingBox( true, false ); // No invisible text in bbox calc
172
173 if( pad )
175 else
176 m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) footprint );
177 }
178 else if( netcode > 0 || multiHighlight )
179 {
180 if( !multiHighlight )
181 {
182 renderSettings->SetHighlight( ( netcode >= 0 ), netcode );
183 pcb->SetHighLightNet( netcode );
184 }
185 else
186 {
187 // Just pick the first one for area calculation
188 netcode = *pcb->GetHighLightNetCodes().begin();
189 }
190
191 pcb->HighLightON();
192
193 auto merge_area =
194 [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
195 {
196 if( aItem->GetNetCode() == netcode )
197 bbox.Merge( aItem->GetBoundingBox() );
198 };
199
200 if( crossProbingSettings.center_on_items )
201 {
202 for( ZONE* zone : pcb->Zones() )
203 merge_area( zone );
204
205 for( PCB_TRACK* track : pcb->Tracks() )
206 merge_area( track );
207
208 for( FOOTPRINT* fp : pcb->Footprints() )
209 {
210 for( PAD* p : fp->Pads() )
211 merge_area( p );
212 }
213 }
214 }
215 else
216 {
217 renderSettings->SetHighlight( false );
218 }
219
220 if( crossProbingSettings.center_on_items && bbox.GetWidth() != 0 && bbox.GetHeight() != 0 )
221 {
222 if( crossProbingSettings.zoom_to_fit )
223 GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
224
225 FocusOnLocation( bbox.Centre() );
226 }
227
228 view->UpdateAllLayersColor();
229
230 // Ensure the display is refreshed, because in some installs the refresh is done only
231 // when the gal canvas has the focus, and that is not the case when crossprobing from
232 // Eeschema:
233 GetCanvas()->Refresh();
234}
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:170
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:472
ZONES & Zones()
Definition: board.h:313
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:2011
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
bool IsHighLightNetON() const
Definition: board.h:488
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:2024
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Vec Centre() const
Definition: box2.h:70
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:782
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsHighlightEnabled() const
Return current highlight setting.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:758
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.
static TOOL_ACTION highlightItem
Definition: pcb_actions.h:493
The selection tool: currently supports:
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:285
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
Cross-probing behavior.
Definition: app_settings.h:31
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:34
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:33
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:35

References CROSS_PROBING_SETTINGS::auto_highlight, CROSS_PROBING_SETTINGS::center_on_items, BOX2< Vec >::Centre(), BOARD::FindNet(), 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::PAINTER::GetSettings(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::GetView(), BOX2< Vec >::GetWidth(), PCB_ACTIONS::highlightItem, BOARD::HighLightON(), KIGFX::RENDER_SETTINGS::IsHighlightEnabled(), BOARD::IsHighLightNetON(), APP_SETTINGS_BASE::m_CrossProbing, TOOLS_HOLDER::m_toolManager, BOX2< Vec >::Merge(), pad, EDA_DRAW_PANEL_GAL::Refresh(), BOARD::ResetNetHighLight(), TOOL_MANAGER::RunAction(), KIGFX::RENDER_SETTINGS::SetHighlight(), BOARD::SetHighLightNet(), EDA_DRAW_FRAME::SetMsgPanel(), text, BOARD::Tracks(), KIGFX::VIEW::UpdateAllLayersColor(), 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 595 of file export_idf.cpp.

597{
598 IDF3_BOARD idfBoard( IDF3::CAD_ELEC );
599
600 // Switch the locale to standard C (needed to print floating point numbers)
601 LOCALE_IO toggle;
602
603 resolver = Prj().Get3DCacheManager()->GetResolver();
604
605 bool ok = true;
606 double scale = pcbIUScale.MM_PER_IU; // we must scale internal units to mm for IDF
607 IDF3::IDF_UNIT idfUnit;
608
609 if( aUseThou )
610 {
611 idfUnit = IDF3::UNIT_THOU;
612 idfBoard.SetUserPrecision( 1 );
613 }
614 else
615 {
616 idfUnit = IDF3::UNIT_MM;
617 idfBoard.SetUserPrecision( 5 );
618 }
619
620 wxFileName brdName = aPcb->GetFileName();
621
622 idfBoard.SetUserScale( scale );
623 idfBoard.SetBoardThickness( aPcb->GetDesignSettings().GetBoardThickness() * scale );
624 idfBoard.SetBoardName( TO_UTF8( brdName.GetFullName() ) );
625 idfBoard.SetBoardVersion( 0 );
626 idfBoard.SetLibraryVersion( 0 );
627
628 std::ostringstream ostr;
629 ostr << "KiCad " << TO_UTF8( GetBuildVersion() );
630 idfBoard.SetIDFSource( ostr.str() );
631
632 try
633 {
634 // set up the board reference point
635 idfBoard.SetUserOffset( -aXRef, aYRef );
636
637 // Export the board outline
638 idf_export_outline( aPcb, idfBoard );
639
640 // Output the drill holes and footprint (library) data.
641 for( FOOTPRINT* footprint : aPcb->Footprints() )
642 idf_export_footprint( aPcb, footprint, idfBoard );
643
644 if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) )
645 {
646 wxString msg;
647 msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( idfBoard.GetError().c_str() );
648 wxMessageBox( msg );
649
650 ok = false;
651 }
652 }
653 catch( const IO_ERROR& ioe )
654 {
655 wxString msg;
656 msg << _( "IDF Export Failed:\n" ) << ioe.What();
657 wxMessageBox( msg );
658
659 ok = false;
660 }
661 catch( const std::exception& e )
662 {
663 wxString msg;
664 msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
665 wxMessageBox( msg );
666 ok = false;
667 }
668
669 return ok;
670}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
wxString GetBuildVersion()
Get the full KiCad version string.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:617
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
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:59
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:274
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:52
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const int scale
const double MM_PER_IU
Definition: base_units.h:79
#define UNIT_MM
Definition: units_scales.h:34

References _, BOARD::Footprints(), FROM_UTF8(), BOARD_DESIGN_SETTINGS::GetBoardThickness(), GetBuildVersion(), BOARD::GetDesignSettings(), BOARD::GetFileName(), idf_export_footprint(), idf_export_outline(), EDA_IU_SCALE::MM_PER_IU, pcbIUScale, 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 667 of file footprint_libraries_utils.cpp.

669{
670 if( GetBoard()->GetFirstFootprint() == nullptr )
671 {
672 DisplayInfoMessage( this, _( "No footprints to export!" ) );
673 return;
674 }
675
676 wxString footprintName;
677
678 auto resetReference =
679 []( FOOTPRINT* aFootprint )
680 {
681 aFootprint->SetReference( "REF**" );
682 };
683
684 if( !aStoreInNewLib )
685 {
686 // The footprints are saved in an existing .pretty library in the fp lib table
687 PROJECT& prj = Prj();
688 wxString last_nickname = prj.GetRString( PROJECT::PCB_LIB_NICKNAME );
689 wxString nickname = SelectLibrary( last_nickname );
690
691 if( !nickname ) // Aborted
692 return;
693
694 bool map = IsOK( this, wxString::Format( _( "Update footprints on board to refer to %s?" ),
695 nickname ) );
696
697 prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
698
699 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
700 {
701 try
702 {
703 FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
704
705 if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
706 {
707 FOOTPRINT* fpCopy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
708
709 resetReference( fpCopy );
710 tbl->FootprintSave( nickname, fpCopy, true );
711
712 delete fpCopy;
713 }
714 }
715 catch( const IO_ERROR& ioe )
716 {
717 DisplayError( this, ioe.What() );
718 }
719
720 if( map )
721 {
722 LIB_ID id = footprint->GetFPID();
723 id.SetLibNickname( nickname );
724 footprint->SetFPID( id );
725 }
726 }
727 }
728 else
729 {
730 // The footprints are saved in a new .pretty library.
731 // If this library already exists, all previous footprints will be deleted
732 wxString libPath = CreateNewLibrary( aLibName );
733
734 if( libPath.IsEmpty() ) // Aborted
735 return;
736
737 if( aLibPath )
738 *aLibPath = libPath;
739
740 wxString libNickname;
741 bool map = IsOK( this, _( "Update footprints on board to refer to new library?" ) );
742
743 if( map )
744 {
745 const LIB_TABLE_ROW* row = Prj().PcbFootprintLibs()->FindRowByURI( libPath );
746
747 if( row )
748 libNickname = row->GetNickName();
749 }
750
752 PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
753
754 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
755 {
756 try
757 {
758 if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
759 {
760 FOOTPRINT* fpCopy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
761
762 resetReference( fpCopy );
763 pi->FootprintSave( libPath, fpCopy );
764
765 delete fpCopy;
766 }
767 }
768 catch( const IO_ERROR& ioe )
769 {
770 DisplayError( this, ioe.What() );
771 }
772
773 if( map )
774 {
775 LIB_ID id = footprint->GetFPID();
776 id.SetLibNickname( libNickname );
777 footprint->SetFPID( id );
778 }
779 }
780 }
781}
SAVE_T FootprintSave(const wxString &aNickname, const FOOTPRINT *aFootprint, bool aOverwrite=true)
Write aFootprint to an existing library given by aNickname.
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString & GetNickName() const
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...
wxString SelectLibrary(const wxString &aNicknameExisting)
Put up a dialog and allows the user to pick a library, for unspecified use.
Container for project specific data.
Definition: project.h:63
@ PCB_LIB_NICKNAME
Definition: project.h:172
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:253
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:264

References _, PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DisplayError(), DisplayInfoMessage(), LIB_TABLE::FindRowByURI(), PLUGIN::FootprintSave(), 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 81 of file specctra_export.cpp.

82{
83 BASE_SCREEN* screen = GetScreen();
84 bool wasModified = screen->IsContentModified();
85 wxString errorText;
86 bool ok = true;
87
88 try
89 {
90 ExportBoardToSpecctraFile( GetBoard(), aFullFilename );
91 }
92 catch( const IO_ERROR& ioe )
93 {
94 ok = false;
95
96 // copy the error string to safe place, ioe is in this scope only.
97 errorText = ioe.What();
98 }
99
100 // The two calls to FOOTPRINT::Flip() in ExportBoardToSpecctraFile both set the modified flag,
101 // yet their actions cancel each other out, so it should be ok to clear the flag.
102 if( !wasModified )
103 screen->SetContentModified( false );
104
105 if( ok )
106 SetStatusText( wxString( _( "BOARD exported OK." ) ) );
107 else
108 DisplayErrorMessage( this, _( "Unable to export, please fix and try again" ), errorText );
109
110 return ok;
111}
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
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:299
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.

References _, DisplayErrorMessage(), ExportBoardToSpecctraFile(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetScreen(), 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 1444 of file pcb_edit_frame.cpp.

1445{
1446 InvokeExportSVG( this, GetBoard() );
1447}
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.

References PCB_BASE_FRAME::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
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}
const VECTOR2I & GetAuxOrigin()
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1166
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
Definition: ratsnest.cpp:35
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
static std::map< int, wxString > shapeNames
static void CreateTracksInfoData(FILE *aFile, BOARD *aPcb)
static bool uniquePins
static bool flipBottomPads
static void CreatePadsShapesSection(FILE *aFile, BOARD *aPcb)
static bool storeOriginCoords
static void CreateRoutesSection(FILE *aFile, BOARD *aPcb)
static bool CreateHeaderInfoData(FILE *aFile, PCB_EDIT_FRAME *frame)
static int GencadOffsetX
static std::map< FOOTPRINT *, int > componentShapes
static bool individualShapes
static void CreateBoardSection(FILE *aFile, BOARD *aPcb)
static int GencadOffsetY
static void CreateShapesSection(FILE *aFile, BOARD *aPcb)
static void CreateDevicesSection(FILE *aFile, BOARD *aPcb)
static void CreateComponentsSection(FILE *aFile, BOARD *aPcb)
static void CreateArtworksSection(FILE *aFile)
static void CreateSignalsSection(FILE *aFile, BOARD *aPcb)
@ B_Cu
Definition: layer_ids.h:95
@ LAST_PATH_GENCAD
Definition: project_file.h:53

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(), BOARD::GetFileName(), DIALOG_GENCAD_EXPORT_OPTIONS::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, USE_AUX_ORIGIN, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ 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 1301 of file exporter_vrml.cpp.

1305{
1306 bool success;
1307 wxString msgs;
1308 EXPORTER_VRML model3d( GetBoard() );
1309
1310 success = model3d.ExportVRML_File( &Prj(), &msgs, aFullFileName, aMMtoWRMLunit,
1311 aExport3DFiles, aUseRelativePaths,
1312 a3D_Subdir, aXRef, aYRef );
1313
1314 if( !msgs.IsEmpty() )
1315 wxMessageBox( msgs );
1316
1317 return success;
1318}
Wrapper to expose an API for writing VRML files, without exposing all the many structures used in the...
Definition: export_vrml.h:33

References EXPORTER_VRML::ExportVRML_File(), PCB_BASE_FRAME::GetBoard(), and KIWAY_HOLDER::Prj().

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

1670{
1671 if( TestStandalone() == 0 )
1672 {
1673 DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
1674 "stand-alone mode. In order to create or update PCBs from "
1675 "schematics, you must launch the KiCad project manager and "
1676 "create a project." ) );
1677 return false; // Not in standalone mode
1678 }
1679
1680 if( TestStandalone() < 0 ) // Problem with Eeschema or the schematic
1681 return false;
1682
1683 Raise(); // Show
1684
1685 std::string payload( aAnnotateMessage );
1686
1687 Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1688
1689 if( payload == aAnnotateMessage )
1690 {
1691 Raise();
1692 DisplayErrorMessage( this, aAnnotateMessage );
1693 return false;
1694 }
1695
1696 try
1697 {
1698 auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1699 KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1700 netlistReader.LoadNetlist();
1701 }
1702 catch( const IO_ERROR& e )
1703 {
1704 Raise();
1705
1706 // Do not translate extra_info strings. These are for developers
1707 wxString extra_info = e.Problem() + wxT( " : " ) + e.What() + wxT( " at " ) + e.Where();
1708
1709 DisplayErrorMessage( this, _( "Received an error while reading netlist. Please "
1710 "report this issue to the KiCad team using the menu "
1711 "Help->Report Bug."), extra_info );
1712 return false;
1713 }
1714
1715 return true;
1716}
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
Read the new s-expression based KiCad netlist format.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:488
int TestStandalone(void)
Test if standalone mode.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:241
@ FRAME_SCH
Definition: frame_type.h:34
@ MAIL_SCH_GET_NETLIST
Definition: mail_type.h:49

References _, DisplayErrorMessage(), KIWAY::ExpressMail(), FRAME_SCH, KIWAY_HOLDER::Kiway(), KICAD_NETLIST_READER::LoadNetlist(), MAIL_SCH_GET_NETLIST, IO_ERROR::Problem(), TestStandalone(), 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 296 of file pcbnew/files.cpp.

297{
298 int id = event.GetId();
299 Files_io_from_id( id );
300}
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 303 of file pcbnew/files.cpp.

304{
305 wxString msg;
306
307 switch( id )
308 {
309 case ID_LOAD_FILE:
310 {
311 int open_ctl = 0;
312 wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
313
314 return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
315 && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
316 }
317
319 {
320 int open_ctl = 1;
321 wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
322
323 return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
324 && OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
325 }
326
328 {
329 wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
330 wxFileName fn = currfn;
331
332 wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
333 fn.SetName( rec_name );
334
335 if( !fn.FileExists() )
336 {
337 msg.Printf( _( "Recovery file '%s' not found." ), fn.GetFullPath() );
338 DisplayInfoMessage( this, msg );
339 return false;
340 }
341
342 msg.Printf( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() );
343
344 if( !IsOK( this, msg ) )
345 return false;
346
347 GetScreen()->SetContentModified( false ); // do not prompt the user for changes
348
349 if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
350 {
351 // Re-set the name since name or extension was changed
352 GetBoard()->SetFileName( currfn.GetFullPath() );
353 UpdateTitle();
354 return true;
355 }
356
357 return false;
358 }
359
360 case ID_REVERT_BOARD:
361 {
362 wxFileName fn = Prj().AbsolutePath( GetBoard()->GetFileName() );
363
364 msg.Printf( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() );
365
366 if( !IsOK( this, msg ) )
367 return false;
368
369 GetScreen()->SetContentModified( false ); // do not prompt the user for changes
370
371 ReleaseFile();
372
373 return OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
374 }
375
376 case ID_NEW_BOARD:
377 {
378 if( IsContentModified() )
379 {
380 wxFileName fileName = GetBoard()->GetFileName();
381 wxString saveMsg = _( "Current board will be closed, save changes to '%s' before "
382 "continuing?" );
383
384 if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
385 [&]()->bool
386 {
387 return Files_io_from_id( ID_SAVE_BOARD );
388 } ) )
389 {
390 return false;
391 }
392 }
393 else if( !GetBoard()->IsEmpty() )
394 {
395 if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
396 return false;
397 }
398
400
402
404
405 mgr->SaveProject( mgr->Prj().GetProjectFullName() );
406 mgr->UnloadProject( &mgr->Prj() );
407
408 if( !Clear_Pcb( false ) )
409 return false;
410
412
414
415 OnModify();
416 return true;
417 }
418
419 case ID_SAVE_BOARD:
420 if( !GetBoard()->GetFileName().IsEmpty() )
421 return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) );
422
424
425 case ID_COPY_BOARD_AS:
426 case ID_SAVE_BOARD_AS:
427 {
428 bool addToHistory = ( id == ID_SAVE_BOARD_AS );
429 wxString orig_name;
430
431 wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name, nullptr );
432
433 if( orig_name.IsEmpty() )
434 orig_name = NAMELESS_PROJECT;
435
436 wxFileName savePath( Prj().GetProjectFullName() );
437
438 if( !savePath.IsOk() || !savePath.IsDirWritable() )
439 {
440 savePath = GetMruPath();
441
442 if( !savePath.IsOk() || !savePath.IsDirWritable() )
444 }
445
446 wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
447 wxString filename = fn.GetFullPath();
448 bool createProject = false;
449
450 if( AskSaveBoardFileName( this, &filename, &createProject ) )
451 {
452 if( id == ID_COPY_BOARD_AS )
453 return SavePcbCopy( filename, createProject );
454 else
455 return SavePcbFile( filename, addToHistory, createProject );
456 }
457
458 return false;
459 }
460
461 default:
462 return false;
463 }
464}
wxString GetMruPath() const
bool SavePcbCopy(const wxString &aFileName, bool aCreateProject=false)
Write the board data structures to aFileName.
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.
bool LoadProjectSettings()
Load the current project's file configuration settings which are pertinent to this PCB_EDIT_FRAME ins...
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:119
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Saves a loaded project.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
@ ID_NEW_BOARD
Definition: id.h:76
@ ID_SAVE_BOARD
Definition: id.h:77
@ ID_LOAD_FILE
Definition: id.h:75
@ ID_SAVE_BOARD_AS
Definition: id.h:78
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
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.
@ ID_IMPORT_NON_KICAD_BOARD
Definition: pcbnew_id.h:19
@ ID_REVERT_BOARD
Definition: pcbnew_id.h:18
@ ID_MENU_RECOVER_BOARD_AUTOSAVE
Definition: pcbnew_id.h:81
@ ID_COPY_BOARD_AS
Definition: pcbnew_id.h:17

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_REVERT_BOARD, ID_SAVE_BOARD, ID_SAVE_BOARD_AS, IsContentModified(), IsOK(), KI_FALLTHROUGH, KiCadPcbFileExtension, LoadProjectSettings(), NAMELESS_PROJECT, onBoardLoaded(), OnModify(), OpenProjectFiles(), KIWAY_HOLDER::Prj(), SETTINGS_MANAGER::Prj(), EDA_DRAW_FRAME::ReleaseFile(), 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::Revert(), BOARD_EDITOR_CONTROL::Save(), BOARD_EDITOR_CONTROL::SaveAs(), and BOARD_EDITOR_CONTROL::SaveCopy().

◆ findDialogs()

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

Definition at line 898 of file eda_draw_frame.cpp.

899{
900 std::vector<wxWindow*> dialogs;
901
902 for( wxWindow* window : GetChildren() )
903 {
904 if( dynamic_cast<DIALOG_SHIM*>( window ) )
905 dialogs.push_back( window );
906 }
907
908 return dialogs;
909}
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83

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

◆ FindItemsFromSyncSelection()

std::vector< BOARD_ITEM * > PCB_EDIT_FRAME::FindItemsFromSyncSelection ( std::string  syncStr)

Used to find items by selection synchronization spec string.

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

432{
433 wxArrayString syncArray = wxStringTokenize( syncStr, "," );
434
435 std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
436
437 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
438 {
439 if( footprint == nullptr )
440 continue;
441
442 wxString fpSheetPath = footprint->GetPath().AsString().BeforeLast( '/' );
443 wxString fpUUID = footprint->m_Uuid.AsString();
444
445 if( fpSheetPath.IsEmpty() )
446 fpSheetPath += '/';
447
448 if( fpUUID.empty() )
449 continue;
450
451 wxString fpRefEscaped = EscapeString( footprint->GetReference(), CTX_IPC );
452
453 for( unsigned index = 0; index < syncArray.size(); ++index )
454 {
455 wxString syncEntry = syncArray[index];
456
457 if( syncEntry.empty() )
458 continue;
459
460 wxString syncData = syncEntry.substr( 1 );
461
462 switch( syncEntry.GetChar( 0 ).GetValue() )
463 {
464 case 'S': // Select sheet with subsheets: S<Sheet path>
465 if( fpSheetPath.StartsWith( syncData ) )
466 {
467 orderPairs.emplace_back( index, footprint );
468 }
469 break;
470 case 'F': // Select footprint: F<Reference>
471 if( syncData == fpRefEscaped )
472 {
473 orderPairs.emplace_back( index, footprint );
474 }
475 break;
476 case 'P': // Select pad: P<Footprint reference>/<Pad number>
477 {
478 if( syncData.StartsWith( fpRefEscaped ) )
479 {
480 wxString selectPadNumberEscaped =
481 syncData.substr( fpRefEscaped.size() + 1 ); // Skips the slash
482
483 wxString selectPadNumber = UnescapeString( selectPadNumberEscaped );
484
485 for( PAD* pad : footprint->Pads() )
486 {
487 if( selectPadNumber == pad->GetNumber() )
488 {
489 orderPairs.emplace_back( index, pad );
490 }
491 }
492 }
493 break;
494 }
495 default: break;
496 }
497 }
498 }
499
500 std::sort(
501 orderPairs.begin(), orderPairs.end(),
502 []( const std::pair<int, BOARD_ITEM*>& a, const std::pair<int, BOARD_ITEM*>& b ) -> bool
503 {
504 return a.first < b.first;
505 } );
506
507 std::vector<BOARD_ITEM*> items;
508 items.reserve( orderPairs.size() );
509
510 for( const std::pair<int, BOARD_ITEM*>& pair : orderPairs )
511 items.push_back( pair.second );
512
513 return items;
514}
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_IPC
Definition: string_utils.h:56

References CTX_IPC, EscapeString(), PCB_BASE_FRAME::GetBoard(), pad, and UnescapeString().

Referenced by KiwayMailIn().

◆ FindNext()

void PCB_EDIT_FRAME::FindNext ( )

Find the next item using our existing search parameters.

Definition at line 1577 of file pcb_edit_frame.cpp.

1578{
1579 if( !m_findDialog )
1581
1583}
void FindNext()
Finds the next item.
Definition: dialog_find.h:71
DIALOG_FIND * m_findDialog
void ShowFindDialog()
Show the Find dialog.

References DIALOG_FIND::FindNext(), m_findDialog, and ShowFindDialog().

Referenced by BOARD_EDITOR_CONTROL::FindNext().

◆ findQuasiModalDialog()

wxWindow * EDA_BASE_FRAME::findQuasiModalDialog ( )
privateinherited

Definition at line 168 of file eda_base_frame.cpp.

169{
170 for( wxWindow* iter : GetChildren() )
171 {
172 DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
173
174 if( dlg && dlg->IsQuasiModal() )
175 return dlg;
176 }
177
178 // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
179 // so we have to look for it separately.
180 if( m_ident == FRAME_SCH )
181 {
182 wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
183
184 if( cvpcb )
185 return cvpcb;
186 }
187
188 return nullptr;
189}
bool IsQuasiModal() const
Definition: dialog_shim.h:106

References FRAME_SCH, DIALOG_SHIM::IsQuasiModal(), and EDA_BASE_FRAME::m_ident.

Referenced by EDA_BASE_FRAME::ProcessEvent(), and EDA_BASE_FRAME::windowClosing().

◆ FinishAUIInitialization()

void EDA_BASE_FRAME::FinishAUIInitialization ( )
inherited

Definition at line 825 of file eda_base_frame.cpp.

826{
827#if defined( __WXOSX_MAC__ )
828 m_auimgr.Update();
829#else
830 // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
831 // hiding it.
832 m_auimgr.Update();
833
834 // We don't want the infobar displayed right away
835 m_auimgr.GetPane( "InfoBar" ).Hide();
836 m_auimgr.Update();
837#endif
838}

References EDA_BASE_FRAME::m_auimgr.

◆ FocusOnItem()

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

265{
266 static std::vector<KIID> lastBrightenedItemIDs;
267
268 BOARD_ITEM* lastItem = nullptr;
269
270 for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
271 {
274 #if BOOST_VERSION >= 106700
275 try
276 {
277 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
278 }
279 catch( const boost::uuids::entropy_error& )
280 {
281 wxLogError( wxT( "A Boost UUID entropy exception was thrown in %s:%s." ),
282 __FILE__, __FUNCTION__ );
283 }
284 #else
285 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
286 #endif
287
288 if( lastItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
289 {
290 lastItem->ClearBrightened();
291
292 if( lastItem->Type() == PCB_FOOTPRINT_T )
293 {
294 static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
295 [&]( BOARD_ITEM* child )
296 {
297 child->ClearBrightened();
298 } );
299 }
300 else if( lastItem->Type() == PCB_GROUP_T )
301 {
302 static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
303 [&]( BOARD_ITEM* child )
304 {
305 child->ClearBrightened();
306 } );
307 }
308
309 GetCanvas()->GetView()->Update( lastItem );
310 lastBrightenedItemID = niluuid;
311 GetCanvas()->Refresh();
312 }
313 }
314
315 lastBrightenedItemIDs.clear();
316
317 if( aItems.empty() )
318 return;
319
320 VECTOR2I focusPt;
321 KIGFX::VIEW* view = GetCanvas()->GetView();
322 SHAPE_POLY_SET viewportPoly( view->GetViewport() );
323
324 for( wxWindow* dialog : findDialogs() )
325 {
326 wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
327 SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( dialogPos, true ),
328 view->ToWorld( dialog->GetSize(), false ) ) );
329
330 try
331 {
332 viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
333 }
334 catch( const ClipperLib::clipperException& exc )
335 {
336 // This may be overkill and could be an assertion but we are more likely to
337 // find any clipper errors this way.
338 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
339 }
340 }
341
342 SHAPE_POLY_SET itemPoly, clippedPoly;
343
344 for( BOARD_ITEM* item : aItems )
345 {
346 if( item && item != DELETED_BOARD_ITEM::GetInstance() )
347 {
348 item->SetBrightened();
349
350 if( item->Type() == PCB_FOOTPRINT_T )
351 {
352 static_cast<FOOTPRINT*>( item )->RunOnChildren(
353 [&]( BOARD_ITEM* child )
354 {
355 child->SetBrightened();
356 });
357 }
358 else if( item->Type() == PCB_GROUP_T )
359 {
360 static_cast<PCB_GROUP*>( item )->RunOnChildren(
361 [&]( BOARD_ITEM* child )
362 {
363 child->SetBrightened();
364 });
365 }
366
367 GetCanvas()->GetView()->Update( item );
368 lastBrightenedItemIDs.push_back( item->m_Uuid );
369
370 // Focus on the object's location. Prefer a visible part of the object to its anchor
371 // in order to keep from scrolling around.
372
373 focusPt = item->GetPosition();
374
375 if( aLayer == UNDEFINED_LAYER )
376 aLayer = item->GetLayerSet().Seq()[0];
377
378 switch( item->Type() )
379 {
380 case PCB_FOOTPRINT_T:
381 try
382 {
383 itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
384 }
385 catch( const ClipperLib::clipperException& exc )
386 {
387 // This may be overkill and could be an assertion but we are more likely to
388 // find any clipper errors this way.
389 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
390 }
391
392 break;
393
394 case PCB_PAD_T:
395 case PCB_MARKER_T:
396 case PCB_VIA_T:
397 FocusOnLocation( item->GetFocusPosition() );
398 GetCanvas()->Refresh();
399 return;
400
401 case PCB_SHAPE_T:
402 case PCB_TEXT_T:
403 case PCB_TEXTBOX_T:
404 case PCB_FP_TEXT_T:
405 case PCB_FP_TEXTBOX_T:
406 case PCB_FP_SHAPE_T:
407 case PCB_FP_ZONE_T:
408 case PCB_TRACE_T:
409 case PCB_ARC_T:
411 case PCB_DIM_LEADER_T:
412 case PCB_DIM_CENTER_T:
413 case PCB_DIM_RADIAL_T:
420 item->TransformShapeWithClearanceToPolygon( itemPoly, aLayer, 0,
422 break;
423
424 case PCB_ZONE_T:
425 {
426 ZONE* zone = static_cast<ZONE*>( item );
427 #if 0
428 // Using the filled area shapes to find a Focus point can give good results, but
429 // unfortunately the calculations are highly time consuming, even for not very
430 // large areas (can be easily a few minutes for large areas).
431 // so we used only the zone outline that usually do not have too many vertices.
432 zone->TransformShapeWithClearanceToPolygon( itemPoly, aLayer, 0,
433 pcbIUScale.FromMillimeter( 0.1 ), ERROR_INSIDE );
434
435 if( itemPoly.IsEmpty() )
436 itemPoly = *zone->Outline();
437 #else
438 // much faster calculation time when using only the zone outlines
439 itemPoly = *zone->Outline();
440 #endif
441
442 break;
443 }
444
445 default:
446 {
447 BOX2I item_bbox = item->GetBoundingBox();
448 itemPoly.NewOutline();
449 itemPoly.Append( item_bbox.GetOrigin() );
450 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
451 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
452 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
453 item_bbox.GetHeight() ) );
454 break;
455 }
456 }
457
458 try
459 {
460 clippedPoly.BooleanIntersection( itemPoly, viewportPoly, SHAPE_POLY_SET::PM_FAST );
461 }
462 catch( const ClipperLib::clipperException& exc )
463 {
464 // This may be overkill and could be an assertion but we are more likely to
465 // find any clipper errors this way.
466 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
467 }
468
469 if( !clippedPoly.IsEmpty() )
470 itemPoly = clippedPoly;
471 }
472 }
473
474 /*
475 * Perform a step-wise deflate to find the visual-center-of-mass
476 */
477
478 BOX2I bbox = itemPoly.BBox();
479 int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
480
481 while( !itemPoly.IsEmpty() )
482 {
483 focusPt = itemPoly.BBox().Centre();
484
485 try
486 {
488 }
489 catch( const ClipperLib::clipperException& exc )
490 {
491 // This may be overkill and could be an assertion but we are more likely to
492 // find any clipper errors this way.
493 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
494 }
495 }
496
497 FocusOnLocation( focusPt );
498
499 GetCanvas()->Refresh();
500}
BOX2< VECTOR2D > BOX2D
Definition: box2.h:848
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:932
const Vec & GetOrigin() const
Definition: box2.h:183
static DELETED_BOARD_ITEM * GetInstance()
Definition: board_item.h:356
std::vector< wxWindow * > findDialogs()
void ClearBrightened()
Definition: eda_item.h:122
void SetBrightened()
Definition: eda_item.h:119
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:508
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:445
Represent a set of closed polygons.
@ CHAMFER_ACUTE_CORNERS
Acute angles are chamfered.
bool IsEmpty() const
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union between a and b, store the result in it self For aFastMode meaning,...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the zone shape to a closed polygon Used in filling zones calculations Circles and arcs are ap...
Definition: zone.cpp:1238
SHAPE_POLY_SET * Outline()
Definition: zone.h:305
@ ERROR_INSIDE
KIID niluuid(0)
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BBox(), SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::BooleanSubtract(), BOX2< Vec >::Centre(), SHAPE_POLY_SET::CHAMFER_ACUTE_CORNERS, EDA_ITEM::ClearBrightened(), SHAPE_POLY_SET::Deflate(), ERROR_INSIDE, EDA_DRAW_FRAME::findDialogs(), EDA_DRAW_FRAME::FocusOnLocation(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOX2< Vec >::GetHeight(), DELETED_BOARD_ITEM::GetInstance(), BOARD::GetItem(), BOX2< Vec >::GetOrigin(), PCB_DRAW_PANEL_GAL::GetView(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), SHAPE_POLY_SET::IsEmpty(), EDA_IU_SCALE::mmToIU(), SHAPE_POLY_SET::NewOutline(), niluuid, ZONE::Outline(), PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FOOTPRINT_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, pcbIUScale, SHAPE_POLY_SET::PM_FAST, EDA_DRAW_PANEL_GAL::Refresh(), EDA_ITEM::SetBrightened(), KIGFX::VIEW::ToWorld(), ZONE::TransformShapeWithClearanceToPolygon(), EDA_ITEM::Type(), UNDEFINED_LAYER, and KIGFX::PCB_VIEW::Update().

Referenced by PCB_BASE_FRAME::FocusOnItem(), and DIALOG_DRC::OnDRCItemSelected().

◆ FocusOnLocation()

void EDA_DRAW_FRAME::FocusOnLocation ( const VECTOR2I aPos)
inherited

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

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

Parameters
aPosis the point to go to.

Definition at line 912 of file eda_draw_frame.cpp.

913{
914 bool centerView = false;
916
917 // Center if we're off the current view, or within 10% of its edge
918 r.Inflate( - (int) r.GetWidth() / 10 );
919
920 if( !r.Contains( aPos ) )
921 centerView = true;
922
923 std::vector<BOX2D> dialogScreenRects;
924
925 for( wxWindow* dialog : findDialogs() )
926 {
927 dialogScreenRects.emplace_back( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
928 dialog->GetSize() );
929 }
930
931 // Center if we're behind an obscuring dialog, or within 10% of its edge
932 for( BOX2D rect : dialogScreenRects )
933 {
934 rect.Inflate( rect.GetWidth() / 10 );
935
936 if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
937 centerView = true;
938 }
939
940 if( centerView )
941 {
942 try
943 {
944 GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
945 }
946 catch( const ClipperLib::clipperException& exc )
947 {
948 wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
949 exc.what() );
950 }
951 }
952
954}
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:574
E_SERIE r
Definition: eserie.cpp:41

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

Referenced by PCB_SELECTION_TOOL::doSyncSelection(), ExecuteRemoteCommand(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindNext(), SCH_EDIT_FRAME::FocusOnItem(), PCB_BASE_FRAME::FocusOnItems(), DIALOG_DRC::OnDRCItemSelected(), and EE_SELECTION_TOOL::SyncSelection().

◆ FootprintMatchesLibrary()

bool PCB_EDIT_FRAME::FootprintMatchesLibrary ( )

◆ GenD356File()

void PCB_EDIT_FRAME::GenD356File ( wxCommandEvent &  event)

Definition at line 370 of file export_d356.cpp.

371{
372 wxFileName fn = GetBoard()->GetFileName();
373 wxString ext, wildcard;
374
376 wildcard = IpcD356FileWildcard();
377 fn.SetExt( ext );
378
379 wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
380
381 wxFileDialog dlg( this, _( "Export D-356 Test File" ), pro_dir,
382 fn.GetFullName(), wildcard,
383 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
384
385 if( dlg.ShowModal() == wxID_CANCEL )
386 return;
387
388 IPC356D_WRITER writer( GetBoard(), this );
389
390 writer.Write( dlg.GetPath() );
391}
Wrapper to expose an API for writing IPC-D356 files.
Definition: export_d356.h:54
const std::string IpcD356FileExtension
wxString IpcD356FileWildcard()

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

Referenced by BOARD_EDITOR_CONTROL::GenerateFabFiles().

◆ GenFootprintsReport()

void PCB_EDIT_FRAME::GenFootprintsReport ( wxCommandEvent &  event)

Call DoGenFootprintsReport to create a footprint report file.

Definition at line 577 of file gen_footprints_placefile.cpp.

578{
579 wxFileName fn;
580
581 wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName() ).GetPath();
582 wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
583
584 if( dirDialog.ShowModal() == wxID_CANCEL )
585 return;
586
587 fn = GetBoard()->GetFileName();
588 fn.SetPath( dirDialog.GetPath() );
589 fn.SetExt( wxT( "rpt" ) );
590
591 bool unitMM = GetUserUnits() == EDA_UNITS::MILLIMETRES;
592 bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM );
593
594 wxString msg;
595
596 if( success )
597 {
598 msg.Printf( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() );
599 wxMessageBox( msg, _( "Footprint Report" ), wxICON_INFORMATION );
600 }
601
602 else
603 {
604 msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
605 DisplayError( this, msg );
606 }
607}
bool DoGenFootprintsReport(const wxString &aFullFilename, bool aUnitsMM)
Create an ASCII footprint report file giving some infos on footprints and board outlines.

References _, DisplayError(), DoGenFootprintsReport(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), UNITS_PROVIDER::GetUserUnits(), and MILLIMETRES.

Referenced by BOARD_EDITOR_CONTROL::GenerateFabFiles().

◆ Get3DViewerFrame()

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

Definition at line 137 of file pcb_base_frame.cpp.

138{
139 wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
140 return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
141}
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)

References QUALIFIED_VIEWER3D_FRAMENAME.

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

◆ GetAboutTitle()

const wxString & EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

Definit