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.

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