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.

219 lines
7.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2004-2012 KiCad Developers, see change_log.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 modview_frame.h
  26. */
  27. #ifndef MODVIEWFRM_H_
  28. #define MODVIEWFRM_H_
  29. #include <wx/gdicmn.h>
  30. class wxSashLayoutWindow;
  31. class wxListBox;
  32. class wxSemaphore;
  33. class FP_LIB_TABLE;
  34. /**
  35. * Component library viewer main window.
  36. */
  37. class FOOTPRINT_VIEWER_FRAME : public PCB_BASE_FRAME
  38. {
  39. private:
  40. // List of libraries (for selection )
  41. wxSashLayoutWindow* m_LibListWindow;
  42. wxListBox* m_LibList; // The list of libs names
  43. wxSize m_LibListSize; // size of the window
  44. // List of components in the selected library
  45. wxSashLayoutWindow* m_FootprintListWindow;
  46. wxListBox* m_FootprintList; // The list of footprint names
  47. wxSize m_FootprintListSize; // size of the window
  48. // Flags
  49. wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog
  50. wxString m_configPath; // subpath for configuration
  51. protected:
  52. static wxString m_libraryName; // Current selected library
  53. static wxString m_footprintName; // Current selected footprint
  54. static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
  55. // the selected footprint is here
  56. public:
  57. FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, FP_LIB_TABLE* aTable,
  58. wxSemaphore* aSemaphore = NULL,
  59. long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
  60. ~FOOTPRINT_VIEWER_FRAME();
  61. /**
  62. * Function GetFootprintViewerFrameName (static)
  63. * @return the frame name used when creating the frame
  64. * used to get a reference to this frame, if exists
  65. */
  66. static const wxChar* GetFootprintViewerFrameName();
  67. /**
  68. * Function GetActiveFootprintViewer (static)
  69. * @return a reference to the current opened Footprint viewer
  70. * or NULL if no Footprint viewer currently opened
  71. */
  72. static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer();
  73. wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
  74. const wxString GetSelectedLibraryFullName( void );
  75. /**
  76. * Function GetSelectedLibrary
  77. * @return the selected library name from the #FP_LIB_TABLE.
  78. */
  79. const wxString& GetSelectedLibrary() { return m_libraryName; }
  80. virtual EDA_COLOR_T GetGridColor( void ) const;
  81. private:
  82. void OnSize( wxSizeEvent& event );
  83. /**
  84. * Function OnSashDrag
  85. * resizes the child windows when dragging a sash window border.
  86. */
  87. void OnSashDrag( wxSashEvent& event );
  88. /**
  89. * Function ReCreateLibraryList
  90. *
  91. * Creates or recreates the list of current loaded libraries.
  92. * This list is sorted, with the library cache always at end of the list
  93. */
  94. void ReCreateLibraryList();
  95. void ReCreateFootprintList();
  96. void Process_Special_Functions( wxCommandEvent& event );
  97. void DisplayLibInfos();
  98. /**
  99. * Function RedrawActiveWindow
  100. * Display the current selected component.
  101. * If the component is an alias, the ROOT component is displayed
  102. */
  103. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  104. void OnCloseWindow( wxCloseEvent& Event );
  105. void ReCreateHToolbar();
  106. void ReCreateVToolbar();
  107. void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
  108. void ClickOnLibList( wxCommandEvent& event );
  109. void ClickOnFootprintList( wxCommandEvent& event );
  110. void DClickOnFootprintList( wxCommandEvent& event );
  111. void OnSetRelativeOffset( wxCommandEvent& event );
  112. void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
  113. /**
  114. * Function LoadSettings
  115. * loads the library viewer frame specific configuration settings.
  116. *
  117. * Don't forget to call this base method from any derived classes or the
  118. * settings will not get loaded.
  119. */
  120. void LoadSettings();
  121. /**
  122. * Function SaveSettings
  123. * save library viewer frame specific configuration settings.
  124. *
  125. * Don't forget to call this base method from any derived classes or the
  126. * settings will not get saved.
  127. */
  128. void SaveSettings();
  129. wxString& GetFootprintName( void ) const { return m_footprintName; }
  130. /**
  131. * Function OnActivate
  132. * is called when the frame frame is activate to reload the libraries and component lists
  133. * that can be changed by the schematic editor or the library editor.
  134. */
  135. virtual void OnActivate( wxActivateEvent& event );
  136. void SelectCurrentLibrary( wxCommandEvent& event );
  137. /**
  138. * Function SelectCurrentFootprint
  139. * Selects the current footprint name and display it
  140. */
  141. void SelectCurrentFootprint( wxCommandEvent& event );
  142. /**
  143. * Function ExportSelectedFootprint
  144. * exports the current footprint name and close the library browser.
  145. */
  146. void ExportSelectedFootprint( wxCommandEvent& event );
  147. /**
  148. * Function SelectAndViewFootprint
  149. * Select and load the next or the previous footprint
  150. * if no current footprint, Rebuild the list of footprints available in a given footprint
  151. * library
  152. * @param aMode = NEXT_PART or PREVIOUS_PART
  153. */
  154. void SelectAndViewFootprint( int aMode );
  155. bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
  156. /**
  157. * Function Show3D_Frame (virtual)
  158. * displays 3D view of the footprint (module) being edited.
  159. */
  160. void Show3D_Frame( wxCommandEvent& event );
  161. /**
  162. * Function Update3D_Frame
  163. * must be called after a footprint selection
  164. * Updates the 3D view and 3D frame title.
  165. * @param aForceReloadFootprint = true to reload data (default)
  166. * = false to update title only -(after creating the 3D viewer)
  167. */
  168. void Update3D_Frame( bool aForceReloadFootprint = true );
  169. /*
  170. * Virtual functions, not used here, but needed by PCB_BASE_FRAME
  171. * (virtual pure functions )
  172. */
  173. void OnLeftDClick(wxDC*, const wxPoint&) {}
  174. void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {}
  175. void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {}
  176. DECLARE_EVENT_TABLE()
  177. };
  178. #endif // MODVIEWFRM_H_