You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

446 lines
15 KiB

17 years ago
17 years ago
5 years ago
17 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
14 years ago
17 years ago
17 years ago
17 years ago
17 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
14 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
16 years ago
17 years ago
5 years ago
17 years ago
2 years ago
17 years ago
2 years ago
2 years ago
17 years ago
2 years ago
17 years ago
17 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 2023 CERN
  7. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef PCB_BASE_FRAME_H
  27. #define PCB_BASE_FRAME_H
  28. #include <eda_units.h>
  29. #include <eda_draw_frame.h>
  30. #include <outline_mode.h>
  31. #include <lib_id.h>
  32. #include <pcb_display_options.h>
  33. #include <pcb_draw_panel_gal.h>
  34. #include <pcb_origin_transforms.h>
  35. #include <pcb_screen.h>
  36. #include <vector>
  37. #include <wx/datetime.h>
  38. #include <wx/timer.h>
  39. /* Forward declarations of classes. */
  40. class APP_SETTINGS_BASE;
  41. class BOARD;
  42. class BOARD_CONNECTED_ITEM;
  43. class COLOR_SETTINGS;
  44. class EDA_ITEM;
  45. class FOOTPRINT;
  46. class PAD;
  47. class EDA_3D_VIEWER_FRAME;
  48. class GENERAL_COLLECTOR;
  49. class GENERAL_COLLECTORS_GUIDE;
  50. class BOARD_DESIGN_SETTINGS;
  51. class LSET;
  52. class ZONE_SETTINGS;
  53. class PCB_PLOT_PARAMS;
  54. class FP_LIB_TABLE;
  55. class PCB_VIEWERS_SETTINGS_BASE;
  56. class PCBNEW_SETTINGS;
  57. class FOOTPRINT_EDITOR_SETTINGS;
  58. struct MAGNETIC_SETTINGS;
  59. class NL_PCBNEW_PLUGIN;
  60. class PROGRESS_REPORTER;
  61. #ifdef wxHAS_INOTIFY
  62. #define wxFileSystemWatcher wxInotifyFileSystemWatcher
  63. #elif defined( wxHAS_KQUEUE ) && defined( wxHAVE_FSEVENTS_FILE_NOTIFICATIONS )
  64. #define wxFileSystemWatcher wxFsEventsFileSystemWatcher
  65. #elif defined( wxHAS_KQUEUE )
  66. #define wxFileSystemWatcher wxKqueueFileSystemWatcher
  67. #elif defined( __WINDOWS__ )
  68. #define wxFileSystemWatcher wxMSWFileSystemWatcher
  69. #else
  70. #define wxFileSystemWatcher wxPollingFileSystemWatcher
  71. #endif
  72. class wxFileSystemWatcher;
  73. class wxFileSystemWatcherEvent;
  74. wxDECLARE_EVENT( EDA_EVT_BOARD_CHANGED, wxCommandEvent );
  75. /**
  76. * Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
  77. */
  78. class PCB_BASE_FRAME : public EDA_DRAW_FRAME
  79. {
  80. public:
  81. PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
  82. const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
  83. long aStyle, const wxString& aFrameName );
  84. ~PCB_BASE_FRAME();
  85. /**
  86. * @return a reference to the child 3D viewer frame, when exists, or NULL
  87. */
  88. EDA_3D_VIEWER_FRAME* Get3DViewerFrame();
  89. /**
  90. * Update the 3D view, if the viewer is opened by this frame.
  91. *
  92. * @param aMarkDirty alerts the 3D view that data is stale (it may not refresh instantly)
  93. * @param aRefresh will tell the 3D view to refresh immediately
  94. * @param aTitle is the new title of the 3D frame, or nullptr to do not change the frame title
  95. */
  96. virtual void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr );
  97. /**
  98. * Attempt to load \a aFootprintId from the footprint library table.
  99. *
  100. * @param aFootprintId is the #LIB_ID of component footprint to load.
  101. * @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the
  102. * libraries in table returned from #Prj().PcbFootprintLibs().
  103. */
  104. FOOTPRINT* LoadFootprint( const LIB_ID& aFootprintId );
  105. /**
  106. * Calculate the bounding box containing all board items (or board edge segments).
  107. *
  108. * @param aBoardEdgesOnly is true if we are interested in board edge segments only.
  109. * @return the board's bounding box.
  110. */
  111. BOX2I GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const;
  112. const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
  113. virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
  114. const PAGE_INFO& GetPageSettings() const override;
  115. const VECTOR2I GetPageSizeIU() const override;
  116. const VECTOR2I& GetGridOrigin() const override;
  117. void SetGridOrigin( const VECTOR2I& aPoint ) override;
  118. const VECTOR2I& GetAuxOrigin() const;
  119. const VECTOR2I GetUserOrigin() const;
  120. /**
  121. * Return a reference to the default #ORIGIN_TRANSFORMS object.
  122. */
  123. ORIGIN_TRANSFORMS& GetOriginTransforms() override;
  124. wxString MessageTextFromCoord( int aValue, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType ) const
  125. {
  126. return MessageTextFromValue( m_originTransforms.ToDisplay( aValue, aCoordType ) );
  127. }
  128. const TITLE_BLOCK& GetTitleBlock() const override;
  129. void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
  130. /**
  131. * Return the BOARD_DESIGN_SETTINGS for the open project.
  132. */
  133. virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
  134. /**
  135. * Helper to retrieve the current color settings.
  136. */
  137. virtual COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override
  138. {
  139. wxFAIL_MSG( wxT( "Color settings requested for a PCB_BASE_FRAME that does not "
  140. "override!" ) );
  141. return nullptr;
  142. }
  143. void SetDrawBgColor( const COLOR4D& aColor ) override;
  144. /**
  145. * Display options control the way tracks, vias, outlines and other things are shown
  146. * (for instance solid or sketch mode).
  147. */
  148. const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_displayOptions; }
  149. /**
  150. * Update the current display options.
  151. *
  152. * @param aOptions is the options struct to apply.
  153. * @param aRefresh will refresh the view after updating.
  154. */
  155. void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh = true );
  156. /**
  157. * Return the #PCB_PLOT_PARAMS for the BOARD owned by this frame.
  158. */
  159. virtual const PCB_PLOT_PARAMS& GetPlotSettings() const;
  160. virtual void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings );
  161. /**
  162. * Reload the footprint from the library.
  163. *
  164. * @param aFootprint is the footprint to reload.
  165. */
  166. virtual void ReloadFootprint( FOOTPRINT* aFootprint )
  167. {
  168. wxFAIL_MSG( wxT( "Attempted to reload a footprint for PCB_BASE_FRAME that does not "
  169. "override!" ) );
  170. }
  171. /**
  172. * Set the #m_Pcb member in such as way as to ensure deleting any previous #BOARD.
  173. */
  174. virtual void SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter = nullptr );
  175. BOARD* GetBoard() const
  176. {
  177. wxASSERT( m_pcb );
  178. return m_pcb;
  179. }
  180. /**
  181. * @return the primary data model.
  182. */
  183. virtual BOARD_ITEM_CONTAINER* GetModel() const = 0;
  184. EDA_ITEM* GetItem( const KIID& aId ) const override;
  185. void FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
  186. void FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
  187. void HideSolderMask();
  188. void ShowSolderMask();
  189. // General
  190. virtual void ShowChangedLanguage() override;
  191. virtual void UpdateStatusBar() override;
  192. PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
  193. /**
  194. * Show the 3D view frame.
  195. *
  196. * If it does not exist, it is created. If it exists, it is brought to the foreground.
  197. */
  198. EDA_3D_VIEWER_FRAME* CreateAndShow3D_Frame();
  199. /**
  200. * @return global configuration options.
  201. */
  202. GENERAL_COLLECTORS_GUIDE GetCollectorsGuide();
  203. /**
  204. * Put up a dialog and allows the user to pick a library, for unspecified use.
  205. *
  206. * @param aNicknameExisting is the current choice to highlight.
  207. * @return the library or wxEmptyString on abort.
  208. */
  209. wxString SelectLibrary( const wxString& aNicknameExisting );
  210. /**
  211. * Must be called after a change in order to set the "modify" flag and update other data
  212. * structures and GUI elements.
  213. */
  214. void OnModify() override;
  215. /**
  216. * Create a new footprint at position 0,0.
  217. *
  218. * The new footprint contains only 2 texts: a reference and a value:
  219. * Reference = REF**
  220. * Value = "VAL**" or Footprint name in lib
  221. *
  222. * @note They are dummy texts which will be replaced by the actual texts when the
  223. * footprint is placed on a board and a netlist is read.
  224. *
  225. * @param aFootprintName is the name of the new footprint in library.
  226. * @param aLibName optional, if specified is the library for the new footprint
  227. */
  228. FOOTPRINT* CreateNewFootprint( wxString aFootprintName, const wxString& aLibName );
  229. /**
  230. * Place \a aFootprint at the current cursor position and updates footprint coordinates
  231. * with the new position.
  232. *
  233. * @param aRecreateRatsnest A bool true redraws the footprint ratsnest.
  234. */
  235. void PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsnest = true );
  236. void ShowPadPropertiesDialog( PAD* aPad );
  237. /**
  238. * Open a dialog to select a footprint.
  239. *
  240. * @param aPreslect if valid, the #LIB_ID to select (otherwise the global history is used).
  241. */
  242. FOOTPRINT* SelectFootprintFromLibrary( LIB_ID aPreselect = LIB_ID() );
  243. /**
  244. * Add the given footprint to the board.
  245. *
  246. * @param aDC is the current Device Context, to draw the new footprint (can be NULL ).
  247. */
  248. virtual void AddFootprintToBoard( FOOTPRINT* aFootprint );
  249. /**
  250. * Create the entire board ratsnest.
  251. *
  252. * This must be called after a board change (changes for pads, footprints or a read
  253. * netlist ).
  254. *
  255. * @param aDisplayStatus if true, display the computation results.
  256. */
  257. void Compile_Ratsnest( bool aDisplayStatus );
  258. /**
  259. * Create a new entry in undo list of commands.
  260. *
  261. * @param aItemToCopy is the board item modified by the command to undo.
  262. * @param aTypeCommand is the command type (see enum #UNDO_REDO).
  263. */
  264. virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) {};
  265. /**
  266. * Create a new entry in undo list of commands.
  267. *
  268. * @param aItemsList is the list of items modified by the command to undo.
  269. * @param aTypeCommand is the command type (see enum #UNDO_REDO)
  270. */
  271. virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
  272. UNDO_REDO aTypeCommand ) {};
  273. /**
  274. * As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
  275. */
  276. virtual void AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList,
  277. UNDO_REDO aTypeCommand ) {};
  278. /**
  279. * Show the dialog box for a layer selection.
  280. *
  281. * @param aDefaultLayer is the default layer to select. Use UNDEFINED_LAYER if no selection
  282. * is desired.
  283. * @param aNotAllowedLayersMask is a layer mask for not allowed layers. Use 0 to show all
  284. * layers in use.
  285. * @param aDlgPosition is the position of dialog (default is centered).
  286. * @return the selected layer id.
  287. */
  288. PCB_LAYER_ID SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(),
  289. wxPoint aDlgPosition = wxDefaultPosition );
  290. /**
  291. * Change the active layer in the frame.
  292. *
  293. * @param aLayer New layer to make active.
  294. */
  295. virtual void SwitchLayer( PCB_LAYER_ID aLayer );
  296. virtual void SetActiveLayer( PCB_LAYER_ID aLayer ) { GetScreen()->m_Active_Layer = aLayer; }
  297. virtual PCB_LAYER_ID GetActiveLayer() const { return GetScreen()->m_Active_Layer; }
  298. SEVERITY GetSeverity( int aErrorCode ) const override;
  299. virtual void OnDisplayOptionsChanged() {}
  300. void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
  301. void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
  302. PCBNEW_SETTINGS* GetPcbNewSettings() const;
  303. FOOTPRINT_EDITOR_SETTINGS* GetFootprintEditorSettings() const;
  304. virtual PCB_VIEWERS_SETTINGS_BASE* GetViewerSettingsBase() const;
  305. virtual MAGNETIC_SETTINGS* GetMagneticItemsSettings();
  306. void CommonSettingsChanged( int aFlags ) override;
  307. PCB_DRAW_PANEL_GAL* GetCanvas() const override;
  308. virtual void ActivateGalCanvas() override;
  309. /**
  310. * Add \a aListener to post #EDA_EVT_BOARD_CHANGED command events to.
  311. *
  312. * @warning The caller is responsible for removing any listeners that are no long valid.
  313. *
  314. * @note This only gets called when the board editor is in stand alone mode. Changing
  315. * projects in the project manager closes the board editor when a new project is
  316. * loaded.
  317. */
  318. void AddBoardChangeListener( wxEvtHandler* aListener );
  319. /**
  320. * Remove \a aListener to from the board changed listener list.
  321. */
  322. void RemoveBoardChangeListener( wxEvtHandler* aListener );
  323. /**
  324. * Handler for FP change events. Responds to the filesystem watcher set in #setFPWatcher.
  325. */
  326. void OnFPChange( wxFileSystemWatcherEvent& aEvent );
  327. /**
  328. * Handler for the filesystem watcher debounce timer.
  329. */
  330. void OnFpChangeDebounceTimer( wxTimerEvent& aEvent );
  331. protected:
  332. bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
  333. void handleActivateEvent( wxActivateEvent& aEvent ) override;
  334. void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
  335. virtual void doReCreateMenuBar() override;
  336. /**
  337. * Attempt to load \a aFootprintId from the footprint library table.
  338. *
  339. * @param aFootprintId is the #LIB_ID of component footprint to load.
  340. * @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the
  341. * libraries in the table returned from #Prj().PcbFootprintLibs().
  342. * @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
  343. * occurs while reading footprint library files.
  344. */
  345. FOOTPRINT* loadFootprint( const LIB_ID& aFootprintId );
  346. virtual void unitsChangeRefresh() override;
  347. void rebuildConnectivity();
  348. /**
  349. * Create or removes a watcher on the specified footprint.
  350. *
  351. * @param aFootprint If nullptr, the watcher is removed. Otherwise, set a change watcher
  352. */
  353. void setFPWatcher( FOOTPRINT* aFootprint );
  354. protected:
  355. BOARD* m_pcb;
  356. PCB_DISPLAY_OPTIONS m_displayOptions;
  357. PCB_ORIGIN_TRANSFORMS m_originTransforms;
  358. private:
  359. std::unique_ptr<NL_PCBNEW_PLUGIN> m_spaceMouse;
  360. std::unique_ptr<wxFileSystemWatcher> m_watcher;
  361. wxFileName m_watcherFileName;
  362. wxDateTime m_watcherLastModified;
  363. wxTimer m_watcherDebounceTimer;
  364. std::vector<wxEvtHandler*> m_boardChangeListeners;
  365. };
  366. #endif // PCB_BASE_FRAME_H