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.

707 lines
27 KiB

17 years ago
17 years ago
17 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 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
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
17 years ago
17 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 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
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
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
17 years ago
17 years ago
17 years ago
17 years ago
16 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
17 years ago
17 years ago
17 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 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) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file wxBasePcbFrame.h
  27. * @brief Classes used in Pcbnew, CvPcb and GerbView.
  28. */
  29. #ifndef WX_BASE_PCB_FRAME_H_
  30. #define WX_BASE_PCB_FRAME_H_
  31. #include <vector>
  32. #include <boost/interprocess/exceptions.hpp>
  33. #include <draw_frame.h>
  34. #include <base_struct.h>
  35. #include <eda_text.h> // EDA_DRAW_MODE_T
  36. #include <richio.h>
  37. #include <class_pcb_screen.h>
  38. #include <pcbstruct.h>
  39. #include <class_draw_panel_gal.h>
  40. /* Forward declarations of classes. */
  41. class BOARD;
  42. class BOARD_CONNECTED_ITEM;
  43. class MODULE;
  44. class TRACK;
  45. class D_PAD;
  46. class TEXTE_MODULE;
  47. class EDA_3D_VIEWER;
  48. class GENERAL_COLLECTOR;
  49. class GENERAL_COLLECTORS_GUIDE;
  50. class BOARD_DESIGN_SETTINGS;
  51. class ZONE_SETTINGS;
  52. class PCB_PLOT_PARAMS;
  53. class FP_LIB_TABLE;
  54. class FPID;
  55. /**
  56. * class PCB_BASE_FRAME
  57. * basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
  58. */
  59. class PCB_BASE_FRAME : public EDA_DRAW_FRAME
  60. {
  61. public:
  62. DISPLAY_OPTIONS m_DisplayOptions;
  63. EDA_UNITS_T m_UserGridUnit;
  64. wxRealPoint m_UserGridSize;
  65. int m_FastGrid1; // 1st fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox)
  66. int m_FastGrid2; // 2nd fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox)
  67. protected:
  68. BOARD* m_Pcb;
  69. GENERAL_COLLECTOR* m_Collector;
  70. /// Auxiliary tool bar typically shown below the main tool bar at the top of the
  71. /// main window.
  72. wxAuiToolBar* m_auxiliaryToolBar;
  73. void updateGridSelectBox();
  74. void updateZoomSelectBox();
  75. virtual void unitsChangeRefresh();
  76. /**
  77. * Function loadFootprint
  78. * attempts to load \a aFootprintId from the footprint library table.
  79. *
  80. * @param aFootprintId is the #FPID of component footprint to load.
  81. * @return the #MODULE if found or NULL if \a aFootprintId not found in any of the
  82. * libraries in the table returned from #Prj().PcbFootprintLibs().
  83. * @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
  84. * occurs while reading footprint library files.
  85. */
  86. MODULE* loadFootprint( const FPID& aFootprintId )
  87. throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
  88. public:
  89. PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
  90. const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
  91. long aStyle, const wxString& aFrameName );
  92. ~PCB_BASE_FRAME();
  93. /**
  94. * @return a reference to the 3D viewer frame, when exists, or NULL
  95. */
  96. EDA_3D_VIEWER* Get3DViewerFrame();
  97. /**
  98. * Function LoadFootprint
  99. * attempts to load \a aFootprintId from the footprint library table.
  100. *
  101. * @param aFootprintId is the #FPID of component footprint to load.
  102. * @return the #MODULE if found or NULL if \a aFootprintId not found in any of the
  103. * libraries in table returned from #Prj().PcbFootprintLibs().
  104. */
  105. MODULE* LoadFootprint( const FPID& aFootprintId );
  106. /**
  107. * Function GetBoardBoundingBox
  108. * calculates the bounding box containing all board items (or board edge segments).
  109. * @param aBoardEdgesOnly is true if we are interested in board edge segments only.
  110. * @return EDA_RECT - the board's bounding box
  111. */
  112. EDA_RECT GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const;
  113. virtual void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload
  114. const PAGE_INFO& GetPageSettings() const; // overload
  115. const wxSize GetPageSizeIU() const; // overload
  116. const wxPoint& GetAuxOrigin() const; // overload
  117. void SetAuxOrigin( const wxPoint& aPoint ); // overload
  118. const wxPoint& GetGridOrigin() const; // overload
  119. void SetGridOrigin( const wxPoint& aPoint ); // overload
  120. const TITLE_BLOCK& GetTitleBlock() const; // overload
  121. void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload
  122. /**
  123. * Function GetDesignSettings
  124. * returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
  125. * Overloaded in FOOTPRINT_EDIT_FRAME.
  126. */
  127. virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
  128. virtual void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings );
  129. /**
  130. * Function GetDisplayOptions
  131. * returns the display options current in use
  132. * Display options are relative to the way tracks, vias, outlines
  133. * and other things are shown (for instance solid or sketch mode)
  134. * Must be overloaded in frames which have display options
  135. * (board editor and footprint editor)
  136. */
  137. void* GetDisplayOptions() { return &m_DisplayOptions; }
  138. const ZONE_SETTINGS& GetZoneSettings() const;
  139. void SetZoneSettings( const ZONE_SETTINGS& aSettings );
  140. /**
  141. * Function GetPlotSettings
  142. * returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
  143. * Overloaded in FOOTPRINT_EDIT_FRAME.
  144. */
  145. virtual const PCB_PLOT_PARAMS& GetPlotSettings() const;
  146. virtual void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings );
  147. /**
  148. * Function SetBoard
  149. * sets the m_Pcb member in such as way as to ensure deleting any previous
  150. * BOARD.
  151. * @param aBoard The BOARD to put into the frame.
  152. */
  153. virtual void SetBoard( BOARD* aBoard );
  154. BOARD* GetBoard() const
  155. {
  156. wxASSERT( m_Pcb );
  157. return m_Pcb;
  158. }
  159. // General
  160. virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
  161. virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }
  162. virtual void ReCreateHToolbar() = 0;
  163. virtual void ReCreateVToolbar() = 0;
  164. virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0;
  165. virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) = 0;
  166. virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0;
  167. virtual void ReCreateMenuBar();
  168. virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg );
  169. virtual void UpdateStatusBar();
  170. PCB_SCREEN* GetScreen() const { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
  171. /**
  172. * Function BestZoom
  173. * @return the "best" zoom to show the entire board or footprint on the screen.
  174. */
  175. virtual double BestZoom();
  176. /**
  177. * Function GetZoomLevelIndicator
  178. * returns a human readable value which can be displayed as zoom
  179. * level indicator in dialogs.
  180. * Virtual from the base class
  181. */
  182. const wxString GetZoomLevelIndicator() const;
  183. virtual void Show3D_Frame( wxCommandEvent& event );
  184. // Read/write functions:
  185. EDA_ITEM* ReadDrawSegmentDescr( LINE_READER* aReader );
  186. int ReadListeSegmentDescr( LINE_READER* aReader,
  187. TRACK* PtSegm,
  188. int StructType,
  189. int NumSegm );
  190. int ReadSetup( LINE_READER* aReader );
  191. int ReadGeneralDescrPcb( LINE_READER* aReader );
  192. /**
  193. * Function PcbGeneralLocateAndDisplay
  194. * searches for an item under the mouse cursor.
  195. * Items are searched first on the current working layer.
  196. * If nothing found, an item will be searched without layer restriction.
  197. * If more than one item is found meeting the current working layer
  198. * criterion, then a popup menu is shown which allows the user to pick
  199. * which item he/she is interested in. Once an item is chosen, then it
  200. * is make the "current item" and the status window is updated to reflect
  201. * this.
  202. *
  203. * @param aHotKeyCode The hotkey which relates to the caller and determines
  204. * the type of search to be performed. If zero, then
  205. * the mouse tools will be tested instead.
  206. */
  207. BOARD_ITEM* PcbGeneralLocateAndDisplay( int aHotKeyCode = 0 );
  208. void ProcessItemSelection( wxCommandEvent& event );
  209. /**
  210. * Function SetCurItem
  211. * sets the currently selected item and displays it in the MsgPanel.
  212. * If the given item is NULL then the MsgPanel is erased and there is no
  213. * currently selected item. This function is intended to make the process
  214. * of "selecting" an item more formal, and to indivisibly tie the operation
  215. * of selecting an item to displaying it using BOARD_ITEM::Display_Infos().
  216. * @param aItem The BOARD_ITEM to make the selected item or NULL if none.
  217. * @param aDisplayInfo = true to display item info, false if not (default = true)
  218. */
  219. void SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo = true );
  220. BOARD_ITEM* GetCurItem();
  221. ///> @copydoc EDA_DRAW_FRAME::UpdateMsgPanel()
  222. void UpdateMsgPanel();
  223. /**
  224. * Function GetCollectorsGuide
  225. * @return GENERAL_COLLECTORS_GUIDE - that considers the global
  226. *configuration options.
  227. */
  228. GENERAL_COLLECTORS_GUIDE GetCollectorsGuide();
  229. /**
  230. * Function CursorGoto
  231. * positions the cursor at a given coordinate and reframes the drawing if the
  232. * requested point is out of view.
  233. * @param aPos is the point to go to.
  234. * @param aWarp is true if the pointer should be warped to the new position.
  235. */
  236. void CursorGoto( const wxPoint& aPos, bool aWarp = true );
  237. /**
  238. * Function SelectLibrary
  239. * puts up a dialog and allows the user to pick a library, for unspecified use.
  240. *
  241. * @param aNicknameExisting is the current choice to highlight
  242. * @return wxString - the library or wxEmptyString on abort.
  243. */
  244. wxString SelectLibrary( const wxString& aNicknameExisting );
  245. /**
  246. * Function GetFootprintFromBoardByReference
  247. * @return a reference to the footprint found by its refence
  248. * on the curent board. the reference is entered by the user from
  249. * a dialog (by awxTextCtlr, or a list of available references)
  250. */
  251. MODULE* GetFootprintFromBoardByReference();
  252. /**
  253. * Function OnModify
  254. * Virtual
  255. * Must be called after a change
  256. * in order to set the "modify" flag of the current screen
  257. * and update the date in frame reference
  258. * do not forget to call this basic OnModify function to update info
  259. * in derived OnModify functions
  260. */
  261. virtual void OnModify();
  262. // Modules (footprints)
  263. /**
  264. * Function CreateNewModule
  265. * Creates a new module or footprint, at position 0,0
  266. * The new module contains only 2 texts: a reference and a value:
  267. * Reference = REF**
  268. * Value = "VAL**" or Footprint name in lib
  269. * Note: they are dummy texts, which will be replaced by the actual texts
  270. * when the fooprint is placed on a board and a netlist is read
  271. * @param aModuleName = name of the new footprint in library
  272. * @return a reference to the new module
  273. */
  274. MODULE* CreateNewModule( const wxString& aModuleName );
  275. void Edit_Module( MODULE* module, wxDC* DC );
  276. void Rotate_Module( wxDC* DC, MODULE* module, double angle, bool incremental );
  277. /**
  278. * Function PlaceModule
  279. * places \a aModule at the current cursor position and updates module coordinates
  280. * with the new position.
  281. *
  282. * @param aModule A MODULE object point of the module to be placed.
  283. * @param aDC A wxDC object point of the device context to draw \a aModule on
  284. * or NULL if no display screen need updated.
  285. * @param aDoNotRecreateRatsnest A bool true redraws the module rats nest.
  286. */
  287. void PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreateRatsnest = false );
  288. // module texts
  289. void RotateTextModule( TEXTE_MODULE* Text, wxDC* DC );
  290. void DeleteTextModule( TEXTE_MODULE* Text );
  291. void PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC );
  292. void StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC );
  293. /**
  294. * Function ResetTextSize
  295. * resets given field text size and width to current settings in
  296. * Preferences->Dimensions->Texts and Drawings.
  297. * @param aItem is the item to be reset, either TEXTE_PCB or TEXTE_MODULE.
  298. * @param aDC is the drawing context.
  299. */
  300. void ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC );
  301. /**
  302. * Function ResetModuleTextSizes
  303. * resets text size and width of all module text fields of given field
  304. * type to current settings in Preferences->Dimensions->Texts and Drawings.
  305. * @param aFilter is a filter: footprint names must match this filter.
  306. * an empty filter, or "*" do not filter anything.
  307. * @param aRef = true to modify the reference of footprints.
  308. * @param aValue = true to modify the value of footprints.
  309. * @param aOthers = true to modify the other fields of footprints.
  310. */
  311. void ResetModuleTextSizes( const wxString & aFilter, bool aRef,
  312. bool aValue, bool aOthers );
  313. void InstallPadOptionsFrame( D_PAD* pad );
  314. void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC );
  315. void AddPad( MODULE* Module, bool draw );
  316. /**
  317. * Function DeletePad
  318. * Delete the pad aPad.
  319. * Refresh the modified screen area
  320. * Refresh modified parameters of the parent module (bounding box, last date)
  321. * @param aPad = the pad to delete
  322. * @param aQuery = true to prompt for confirmation, false to delete silently
  323. */
  324. void DeletePad( D_PAD* aPad, bool aQuery = true );
  325. /**
  326. * Function StartMovePad
  327. * Initialize a drag or move pad command
  328. * @param aPad = the pad to move or drag
  329. * @param aDC = the current device context
  330. * @param aDragConnectedTracks = true to drag connected tracks,
  331. * false to just move the pad
  332. */
  333. void StartMovePad( D_PAD* aPad, wxDC* aDC, bool aDragConnectedTracks );
  334. void RotatePad( D_PAD* Pad, wxDC* DC );
  335. void PlacePad( D_PAD* Pad, wxDC* DC );
  336. void Export_Pad_Settings( D_PAD* aPad );
  337. void Import_Pad_Settings( D_PAD* aPad, bool aDraw );
  338. /**
  339. * Function GlobalChange_PadSettings
  340. * Function to change pad caracteristics for the given footprint
  341. * or all footprints which look like the given footprint
  342. * @param aPad is the pattern. The given footprint is the parent of this pad
  343. * @param aSameFootprints: if true, make changes on all identical footprints
  344. * @param aPadShapeFilter: if true, make changes only on pads having the same shape as aPad
  345. * @param aPadOrientFilter: if true, make changes only on pads having the same orientation as aPad
  346. * @param aPadLayerFilter: if true, make changes only on pads having the same layers as aPad
  347. * @param aRedraw: if true: redraws the footprint
  348. * @param aSaveForUndo: if true: create an entry in the Undo/Redo list
  349. * (usually: true in Schematic editor, false in Module editor)
  350. */
  351. void GlobalChange_PadSettings( D_PAD* aPad,
  352. bool aSameFootprints,
  353. bool aPadShapeFilter,
  354. bool aPadOrientFilter,
  355. bool aPadLayerFilter,
  356. bool aRedraw,
  357. bool aSaveForUndo );
  358. /**
  359. * Function SelectFootprint
  360. * displays a list of modules found in all libraries or a given library
  361. *
  362. * @param aWindow = the current window ( parent window )
  363. *
  364. * @param aLibraryName = library to list (if aLibraryFullFilename is empty, then list all modules).
  365. * This is a nickname for the FP_LIB_TABLE build.
  366. *
  367. * @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not used )
  368. *
  369. * @param aKeyWord = keyword list, to display a filtered list of module
  370. * having one (or more) of these keywords in their
  371. * keyword list ( aKeyWord = wxEmptyString if not used )
  372. *
  373. * @param aTable is the #FP_LIB_TABLE to search.
  374. *
  375. * @return wxEmptyString if abort or fails, or the selected module name if Ok
  376. */
  377. wxString SelectFootprint( EDA_DRAW_FRAME* aWindow,
  378. const wxString& aLibraryName,
  379. const wxString& aMask,
  380. const wxString& aKeyWord,
  381. FP_LIB_TABLE* aTable );
  382. /**
  383. * Function LoadModuleFromLibrary
  384. * opens a dialog to select a footprint, and loads it into current board.
  385. *
  386. * @param aLibrary = the library name to use, or empty string to search
  387. * in all loaded libraries
  388. * @param aTable is the #FP_LIB_TABLE containing the avaiable footprint libraries.
  389. * @param aUseFootprintViewer = true to show the option
  390. * allowing the footprint selection by the footprint viewer
  391. * @param aDC (can be NULL ) = the current Device Context, to draw the new footprint
  392. */
  393. MODULE* LoadModuleFromLibrary( const wxString& aLibrary,
  394. FP_LIB_TABLE* aTable,
  395. bool aUseFootprintViewer = true,
  396. wxDC* aDC = NULL );
  397. /**
  398. * Function SelectFootprintFromLibBrowser
  399. * launches the footprint viewer to select the name of a footprint to load.
  400. *
  401. * @return the selected footprint name or an empty string if no selection was made.
  402. */
  403. wxString SelectFootprintFromLibBrowser();
  404. // ratsnest functions
  405. /**
  406. * Function Compile_Ratsnest
  407. * Create the entire board ratsnest.
  408. * Must be called after a board change (changes for
  409. * pads, footprints or a read netlist ).
  410. * @param aDC = the current device context (can be NULL)
  411. * @param aDisplayStatus : if true, display the computation results
  412. */
  413. void Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus );
  414. /**
  415. * Function build_ratsnest_module
  416. * Build a ratsnest relative to one footprint. This is a simplified computation
  417. * used only in move footprint. It is not optimal, but it is fast and sufficient
  418. * to help a footprint placement
  419. * It shows the connections from a pad to the nearest connected pad
  420. * @param aModule = module to consider.
  421. */
  422. void build_ratsnest_module( MODULE* aModule );
  423. /**
  424. * Function TraceModuleRatsNest
  425. * display the rats nest of a moving footprint, computed by
  426. * build_ratsnest_module()
  427. */
  428. void TraceModuleRatsNest( wxDC* aDC );
  429. /**
  430. * Function Build_Board_Ratsnest.
  431. * Calculates the full ratsnest depending only on pads.
  432. */
  433. void Build_Board_Ratsnest();
  434. /**
  435. * function Displays the general ratsnest
  436. * Only ratsnest with the status bit CH_VISIBLE is set are displayed
  437. * @param aDC = the current device context (can be NULL)
  438. * @param aNetcode if > 0, Display only the ratsnest relative to the
  439. * corresponding net_code
  440. */
  441. void DrawGeneralRatsnest( wxDC* aDC, int aNetcode = 0 );
  442. /**
  443. * Function TraceAirWiresToTargets
  444. * This functions shows airwires to nearest connecting points (pads)
  445. * from the current new track end during track creation
  446. * Uses data prepared by BuildAirWiresTargetsList()
  447. * @param aDC = the current device context
  448. */
  449. void TraceAirWiresToTargets( wxDC* aDC );
  450. /**
  451. * Function BuildAirWiresTargetsList
  452. * Build a list of candidates that can be a coonection point
  453. * when a track is started.
  454. * This functions prepares data to show airwires to nearest connecting points (pads)
  455. * from the current new track to candidates during track creation
  456. * @param aItemRef = the item connected to the starting point of the new track (track or pad)
  457. * @param aPosition = the position of the new track end (usually the mouse cursor on grid)
  458. * @param aInit = true to build full candidate list or false to update data
  459. * When aInit = false, aItemRef is not used (can be NULL)
  460. */
  461. void BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef,
  462. const wxPoint& aPosition, bool aInit );
  463. /**
  464. * Function TestForActiveLinksInRatsnest
  465. * Explores the full rats nest list (which must exist) to determine
  466. * the ACTIVE links in the full rats nest list
  467. * When tracks exist between pads, a link can connect 2 pads already connected by a track
  468. * and the link is said inactive.
  469. * When a link connects 2 pads not already connected by a track, the link is said active.
  470. * @param aNetCode = net code to test. If 0, test all nets
  471. */
  472. void TestForActiveLinksInRatsnest( int aNetCode );
  473. /**
  474. * Function TestConnections
  475. * tests the connections relative to all nets.
  476. * <p>
  477. * This function update the status of the ratsnest ( flag CH_ACTIF = 0 if a connection
  478. * is found, = 1 else) track segments are assumed to be sorted by net codes.
  479. * This is the case because when a new track is added, it is inserted in the linked list
  480. * according to its net code. and when nets are changed (when a new netlist is read)
  481. * tracks are sorted before using this function.
  482. * </p>
  483. */
  484. void TestConnections();
  485. /**
  486. * Function TestNetConnection
  487. * tests the connections relative to \a aNetCode. Track segments are assumed to be
  488. * sorted by net codes.
  489. * @param aDC Current Device Context
  490. * @param aNetCode The net code to test
  491. */
  492. void TestNetConnection( wxDC* aDC, int aNetCode );
  493. /**
  494. * Function RecalculateAllTracksNetcode
  495. * search connections between tracks and pads and propagate pad net codes to the track
  496. * segments.
  497. */
  498. void RecalculateAllTracksNetcode();
  499. /* Functions relative to Undo/redo commands:
  500. */
  501. /**
  502. * Function SaveCopyInUndoList (virtual pure)
  503. * Creates a new entry in undo list of commands.
  504. * add a picker to handle aItemToCopy
  505. * @param aItemToCopy = the board item modified by the command to undo
  506. * @param aTypeCommand = command type (see enum UNDO_REDO_T)
  507. * @param aTransformPoint = the reference point of the transformation, for
  508. * commands like move
  509. */
  510. virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
  511. UNDO_REDO_T aTypeCommand,
  512. const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
  513. /**
  514. * Function SaveCopyInUndoList (virtual pure, overloaded).
  515. * Creates a new entry in undo list of commands.
  516. * add a list of pickers to handle a list of items
  517. * @param aItemsList = the list of items modified by the command to undo
  518. * @param aTypeCommand = command type (see enum UNDO_REDO_T)
  519. * @param aTransformPoint = the reference point of the transformation,
  520. * for commands like move
  521. */
  522. virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
  523. UNDO_REDO_T aTypeCommand,
  524. const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
  525. /** Install the dialog box for layer selection
  526. * @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer)
  527. * @param aNotAllowedLayersMask = a layer mask for not allowed layers
  528. * (= 0 to show all layers in use)
  529. * @param aDlgPosition = position of dialog ( defualt = centered)
  530. * @return the selected layer id
  531. */
  532. LAYER_ID SelectLayer( LAYER_ID aDefaultLayer,
  533. LSET aNotAllowedLayersMask = LSET(),
  534. wxPoint aDlgPosition = wxDefaultPosition );
  535. /* Display a list of two copper layers to choose a pair of copper layers
  536. * the layer pair is used to fast switch between copper layers when placing vias
  537. */
  538. void SelectCopperLayerPair();
  539. virtual void SwitchLayer( wxDC* DC, LAYER_ID layer );
  540. /**
  541. * Function SetActiveLayer
  542. * will change the currently active layer to \a aLayer.
  543. */
  544. virtual void SetActiveLayer( LAYER_ID aLayer )
  545. {
  546. GetScreen()->m_Active_Layer = aLayer;
  547. }
  548. /**
  549. * Function GetActiveLayer
  550. * returns the active layer
  551. */
  552. virtual LAYER_ID GetActiveLayer() const
  553. {
  554. return GetScreen()->m_Active_Layer;
  555. }
  556. void LoadSettings( wxConfigBase* aCfg ); // override virtual
  557. void SaveSettings( wxConfigBase* aCfg ); // override virtual
  558. bool InvokeDialogGrid();
  559. void OnTogglePolarCoords( wxCommandEvent& aEvent );
  560. void OnTogglePadDrawMode( wxCommandEvent& aEvent );
  561. // User interface update event handlers.
  562. void OnUpdateCoordType( wxUpdateUIEvent& aEvent );
  563. void OnUpdatePadDrawMode( wxUpdateUIEvent& aEvent );
  564. void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
  565. void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
  566. /**
  567. * Function SetFastGrid1()
  568. *
  569. * Switches grid settings to the 1st "fast" setting predefined by user.
  570. */
  571. void SetFastGrid1();
  572. /**
  573. * Function SetFastGrid2()
  574. *
  575. * Switches grid settings to the 1st "fast" setting predefined by user.
  576. */
  577. void SetFastGrid2();
  578. /**
  579. * Virtual function SetNextGrid()
  580. * changes the grid size settings to the next one available.
  581. */
  582. void SetNextGrid();
  583. /**
  584. * Virtual function SetPrevGrid()
  585. * changes the grid size settings to the previous one available.
  586. */
  587. void SetPrevGrid();
  588. void ClearSelection();
  589. ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
  590. virtual void UseGalCanvas( bool aEnable );
  591. /**
  592. * Function SwitchCanvas
  593. * switches currently used canvas (default / Cairo / OpenGL).
  594. */
  595. void SwitchCanvas( wxCommandEvent& aEvent );
  596. /**
  597. * Function LoadCanvasTypeSetting()
  598. * Returns the canvas type stored in the application settings.
  599. */
  600. EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting() const;
  601. /**
  602. * Function SaveCanvasTypeSetting()
  603. * Stores the canvas type in the application settings.
  604. */
  605. bool SaveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
  606. ///> Key in KifaceSettings to store the canvas type.
  607. static const wxChar CANVAS_TYPE_KEY[];
  608. DECLARE_EVENT_TABLE()
  609. };
  610. #endif // WX_BASE_PCB_FRAME_H_