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.

317 lines
11 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file cvpcb_mainframe.h
  26. */
  27. #ifndef _CVPCB_MAINFRAME_H_
  28. #define _CVPCB_MAINFRAME_H_
  29. #include <wx/listctrl.h>
  30. #include <wx/filename.h>
  31. #include <pcb_netlist.h>
  32. #include <footprint_info.h>
  33. #include <wxBasePcbFrame.h>
  34. #include <param_config.h>
  35. /* Forward declarations of all top-level window classes. */
  36. class wxAuiToolBar;
  37. class FOOTPRINTS_LISTBOX;
  38. class COMPONENTS_LISTBOX;
  39. class LIBRARY_LISTBOX;
  40. class DISPLAY_FOOTPRINTS_FRAME;
  41. class COMPONENT;
  42. class FP_LIB_TABLE;
  43. /**
  44. * The CvPcb application main window.
  45. */
  46. class CVPCB_MAINFRAME : public EDA_BASE_FRAME
  47. {
  48. wxArrayString m_footprintListEntries;
  49. #if defined( USE_FP_LIB_TABLE )
  50. /// The global footprint library table.
  51. FP_LIB_TABLE* m_globalFootprintTable;
  52. /// The project footprint library table. This is a combination of the project
  53. /// footprint library table and the global footprint table. This is the one to
  54. /// use when finding a #MODULE.
  55. FP_LIB_TABLE* m_footprintLibTable;
  56. #endif
  57. public:
  58. bool m_KeepCvpcbOpen;
  59. FOOTPRINTS_LISTBOX* m_FootprintList;
  60. LIBRARY_LISTBOX* m_LibraryList;
  61. COMPONENTS_LISTBOX* m_ListCmp;
  62. DISPLAY_FOOTPRINTS_FRAME* m_DisplayFootprintFrame;
  63. wxAuiToolBar* m_mainToolBar;
  64. wxFileName m_NetlistFileName;
  65. wxArrayString m_ModuleLibNames;
  66. wxArrayString m_AliasLibNames;
  67. wxString m_UserLibraryPath;
  68. wxString m_NetlistFileExtension;
  69. wxString m_DocModulesFileName;
  70. FOOTPRINT_LIST m_footprints;
  71. NETLIST m_netlist;
  72. protected:
  73. int m_undefinedComponentCnt;
  74. bool m_modified;
  75. bool m_isEESchemaNetlist;
  76. bool m_skipComponentSelect; // true to skip OnSelectComponent event
  77. // (in automatic selection/deletion of associations)
  78. PARAM_CFG_ARRAY m_projectFileParams;
  79. public:
  80. CVPCB_MAINFRAME( const wxString& title, long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
  81. ~CVPCB_MAINFRAME();
  82. /**
  83. * Function OnSelectComponent
  84. * Called when clicking on a component in component list window
  85. * * Updates the filtered footprint list, if the filtered list option is selected
  86. * * Updates the current selected footprint in footprint list
  87. * * Updates the footprint shown in footprint display window (if opened)
  88. */
  89. void OnSelectComponent( wxListEvent& event );
  90. /**
  91. * Function OnEditFootrprintLibraryTable
  92. * displays the footprint library table editing dialog and updates the global and local
  93. * footprint tables accordingly.
  94. */
  95. void OnEditFootrprintLibraryTable( wxCommandEvent& event );
  96. void OnQuit( wxCommandEvent& event );
  97. void OnCloseWindow( wxCloseEvent& Event );
  98. void OnSize( wxSizeEvent& SizeEvent );
  99. void ReCreateHToolbar();
  100. virtual void ReCreateMenuBar();
  101. void ChangeFocus( bool aMoveRight );
  102. /**
  103. * Function SetLanguage
  104. * is called on a language menu selection.
  105. */
  106. void SetLanguage( wxCommandEvent& event );
  107. void ToFirstNA( wxCommandEvent& event );
  108. void ToPreviousNA( wxCommandEvent& event );
  109. /**
  110. * Function DelAssociations
  111. * removes all component footprint associations already made
  112. */
  113. void DelAssociations( wxCommandEvent& event );
  114. void SaveProjectFile( wxCommandEvent& aEvent );
  115. void SaveQuitCvpcb( wxCommandEvent& event );
  116. /**
  117. * Function LoadNetList
  118. * reads a netlist selected by user when clicking on load netlist button or any entry
  119. * in the file history menu.
  120. */
  121. void LoadNetList( wxCommandEvent& event );
  122. void ConfigCvpcb( wxCommandEvent& event );
  123. /**
  124. * Function OnEditLibraryTable
  125. * envokes the footpirnt library table edit dialog.
  126. */
  127. #if defined( USE_FP_LIB_TABLE )
  128. void OnEditFootprintLibraryTable( wxCommandEvent& aEvent );
  129. #endif
  130. void OnKeepOpenOnSave( wxCommandEvent& event );
  131. void DisplayModule( wxCommandEvent& event );
  132. /**
  133. * Called by the automatic association button
  134. * Read *.equ files to try to find corresponding footprint
  135. * for each component that is not already linked to a footprint ( a "free"
  136. * component )
  137. * format of a line:
  138. * 'cmp_ref' 'footprint_name'
  139. */
  140. void AssocieModule( wxCommandEvent& event );
  141. void DisplayDocFile( wxCommandEvent& event );
  142. /**
  143. * Function OnSelectFilteringFootprint
  144. * is the command event handler for enabling and disabling footprint filtering.
  145. */
  146. void OnSelectFilteringFootprint( wxCommandEvent& event );
  147. void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event );
  148. /**
  149. * Function SetNewPkg
  150. * links the footprint to the current selected component
  151. * and selects the next component.
  152. * @param aFootprintName = the selected footprint
  153. */
  154. void SetNewPkg( const wxString& aFootprintName );
  155. void BuildCmpListBox();
  156. void BuildFOOTPRINTS_LISTBOX();
  157. void BuildLIBRARY_LISTBOX();
  158. /**
  159. * Create or Update the frame showing the current highlighted footprint
  160. * and (if showed) the 3D display frame
  161. */
  162. void CreateScreenCmp();
  163. /**
  164. * Function SaveCmpLinkFile
  165. * Saves the component - footprint link file (.cmp file) to \a aFullFileName.
  166. *
  167. * @param aFullFileName A reference wxString object containing the full
  168. * file name of the netlist or cmp file.
  169. * If aFullFileName is empty, a file name will be asked to the user
  170. * @return 0 if an error occurred saving the link file to \a aFullFileName.
  171. * -1 if canceled
  172. * 1 if OK
  173. */
  174. int SaveCmpLinkFile( const wxString& aFullFileName );
  175. /**
  176. * Function WriteComponentLinkFile
  177. * Writes the component footprint link file \a aFullFileName on disk.
  178. *
  179. * @param aFullFileName full filename of .cmp file to write.
  180. * @return true if OK, false if error.
  181. */
  182. bool WriteComponentLinkFile( const wxString& aFullFileName );
  183. /**
  184. * Function ReadNetList
  185. * reads the netlist (.net) file defined by #m_NetlistFileName.
  186. * and the corresponding cmp to footprint (.cmp) link file
  187. */
  188. bool ReadNetListAndLinkFiles();
  189. int ReadSchematicNetlist();
  190. /**
  191. * Function LoadProjectFile
  192. * reads the configuration parameter from the project (.pro) file \a aFileName
  193. */
  194. void LoadProjectFile( const wxString& aFileName );
  195. /**
  196. * Function LoadSettings
  197. * loads the CvPcb main frame specific configuration settings.
  198. *
  199. * Don't forget to call this base method from any derived classes or the
  200. * settings will not get loaded.
  201. */
  202. virtual void LoadSettings();
  203. /**
  204. * Function SaveSettings
  205. * save the CvPcb frame specific configuration settings.
  206. *
  207. * Don't forget to call this base method from any derived classes or the
  208. * settings will not get saved.
  209. */
  210. virtual void SaveSettings();
  211. /**
  212. * Function DisplayStatus
  213. * updates the information displayed on the status bar at bottom of the main frame.
  214. *
  215. * When the library or component list controls have the focus, the footprint assignment
  216. * status of the components is displayed in the first status bar pane and the list of
  217. * filters for the selected component is displayed in the second status bar pane. When
  218. * the footprint list control has the focus, the description of the selected footprint is
  219. * displayed in the first status bar pane and the key words for the selected footprint are
  220. * displayed in the second status bar pane. The third status bar pane always displays the
  221. * current footprint list filtering.
  222. */
  223. void DisplayStatus();
  224. /**
  225. * Function LoadFootprintFiles
  226. * reads the list of footprint (*.mod files) and generate the list of footprints.
  227. * for each module are stored
  228. * the module name
  229. * documentation string
  230. * associated keywords
  231. * m_ModuleLibNames is the list of library that must be read (loaded)
  232. * fills m_footprints
  233. * @return true if libraries are found, false otherwise.
  234. */
  235. bool LoadFootprintFiles();
  236. /**
  237. * Function GetProjectFileParameters
  238. * return project file parameter list for CvPcb.
  239. * <p>
  240. * Populate the project file parameter array specific to CvPcb if it hasn't
  241. * already been populated and return a reference to the array to the caller.
  242. * Creating the parameter list at run time has the advantage of being able
  243. * to define local variables. The old method of statically building the array
  244. * at compile time requiring global variable definitions.
  245. * </p>
  246. *
  247. * @return A reference to a PARAM_CFG_ARRAY contain the project settings for CvPcb.
  248. */
  249. PARAM_CFG_ARRAY& GetProjectFileParameters( void );
  250. /**
  251. * Function UpdateTitle
  252. * sets the main window title bar text.
  253. * <p>
  254. * If file name defined by CVPCB_MAINFRAME::m_NetlistFileName is not set, the title is
  255. * set to the application name appended with no file. Otherwise, the title is set to
  256. * the full path and file name and read only is appended to the title if the user does
  257. * not have write access to the file.
  258. */
  259. void UpdateTitle();
  260. /**
  261. * Function SendMessageToEESCHEMA
  262. * Send a remote command to Eeschema via a socket,
  263. * Commands are
  264. * $PART: "reference" put cursor on component anchor
  265. */
  266. void SendMessageToEESCHEMA();
  267. COMPONENT* GetSelectedComponent();
  268. DECLARE_EVENT_TABLE()
  269. };
  270. #endif //#ifndef _CVPCB_MAINFRAME_H_