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.

263 lines
12 KiB

8 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software: you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation, either version 3 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * @file tool_footprint_editor.cpp
  24. * @brief Footprint editor tool bars
  25. */
  26. #include <fctsys.h>
  27. #include <pcbnew.h>
  28. #include <footprint_edit_frame.h>
  29. #include <dialog_helpers.h>
  30. #include <pcbnew_id.h>
  31. #include <hotkeys.h>
  32. #include <bitmaps.h>
  33. void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
  34. {
  35. if( m_mainToolBar )
  36. m_mainToolBar->Clear();
  37. else
  38. m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  39. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  40. wxString msg;
  41. // Set up toolbar
  42. m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString,
  43. KiScaledBitmap( new_footprint_xpm, this ),
  44. _( "New footprint" ) );
  45. #ifdef KICAD_SCRIPTING
  46. m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, wxEmptyString,
  47. KiScaledBitmap( module_wizard_xpm, this ),
  48. _( "New footprint using footprint wizard" ) );
  49. #endif
  50. m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
  51. KiScaledBitmap( save_xpm, this ),
  52. _( "Save footprint in existing library" ) );
  53. KiScaledSeparator( m_mainToolBar, this );
  54. m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString,
  55. KiScaledBitmap( print_button_xpm, this ),
  56. _( "Print footprint" ) );
  57. KiScaledSeparator( m_mainToolBar, this );
  58. m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ),
  59. _( "Undo last edit" ) );
  60. m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ),
  61. _( "Redo last undo command" ) );
  62. KiScaledSeparator( m_mainToolBar, this );
  63. msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_REDRAW, IS_COMMENT );
  64. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
  65. msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_IN, IS_COMMENT );
  66. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
  67. msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_OUT, IS_COMMENT );
  68. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
  69. msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_AUTO, IS_COMMENT );
  70. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
  71. m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
  72. _( "Zoom to selection" ), wxITEM_CHECK );
  73. KiScaledSeparator( m_mainToolBar, this );
  74. m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
  75. KiScaledBitmap( module_options_xpm, this ),
  76. _( "Footprint properties" ) );
  77. m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString,
  78. KiScaledBitmap( options_pad_xpm, this ),
  79. _( "Default pad properties" ) );
  80. KiScaledSeparator( m_mainToolBar, this );
  81. m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
  82. KiScaledBitmap( load_module_board_xpm, this ),
  83. _( "Load footprint from current board" ) );
  84. m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
  85. KiScaledBitmap( insert_module_board_xpm, this ),
  86. _( "Insert footprint into current board" ) );
  87. #if 0 // Currently there is no check footprint function defined, so do not show this tool
  88. KiScaledSeparator( m_mainToolBar, this );
  89. m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
  90. KiScaledBitmap( module_check_xpm, this ),
  91. _( "Check footprint" ) );
  92. #endif
  93. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  94. m_mainToolBar->Realize();
  95. }
  96. void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar()
  97. {
  98. if( m_drawToolBar )
  99. m_drawToolBar->Clear();
  100. else
  101. m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  102. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  103. // Set up toolbar
  104. m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
  105. wxEmptyString, wxITEM_CHECK );
  106. KiScaledSeparator( m_drawToolBar, this );
  107. m_drawToolBar->AddTool( ID_MODEDIT_PAD_TOOL, wxEmptyString, KiScaledBitmap( pad_xpm, this ),
  108. _( "Add pad" ), wxITEM_CHECK );
  109. KiScaledSeparator( m_drawToolBar, this );
  110. m_drawToolBar->AddTool( ID_MODEDIT_LINE_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_segments_xpm, this ),
  111. _( "Add graphic line" ), wxITEM_CHECK );
  112. m_drawToolBar->AddTool( ID_MODEDIT_CIRCLE_TOOL, wxEmptyString, KiScaledBitmap( add_circle_xpm, this ),
  113. _( "Add graphic circle" ), wxITEM_CHECK );
  114. m_drawToolBar->AddTool( ID_MODEDIT_ARC_TOOL, wxEmptyString, KiScaledBitmap( add_arc_xpm, this ),
  115. _( "Add graphic arc" ), wxITEM_CHECK );
  116. m_drawToolBar->AddTool( ID_MODEDIT_POLYGON_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_polygon_xpm, this ),
  117. _( "Add graphic polygon" ), wxITEM_CHECK );
  118. m_drawToolBar->AddTool( ID_MODEDIT_TEXT_TOOL, wxEmptyString, KiScaledBitmap( text_xpm, this ),
  119. _( "Add Text" ), wxITEM_CHECK );
  120. KiScaledSeparator( m_drawToolBar, this );
  121. m_drawToolBar->AddTool( ID_MODEDIT_ANCHOR_TOOL, wxEmptyString, KiScaledBitmap( anchor_xpm, this ),
  122. _( "Place footprint reference anchor" ),
  123. wxITEM_CHECK );
  124. KiScaledSeparator( m_drawToolBar, this );
  125. m_drawToolBar->AddTool( ID_MODEDIT_DELETE_TOOL, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
  126. _( "Delete item" ), wxITEM_CHECK );
  127. m_drawToolBar->AddTool( ID_MODEDIT_PLACE_GRID_COORD, wxEmptyString,
  128. KiScaledBitmap( grid_select_axis_xpm, this ),
  129. _( "Set grid origin" ),
  130. wxITEM_CHECK );
  131. m_drawToolBar->AddTool( ID_MODEDIT_MEASUREMENT_TOOL, wxEmptyString,
  132. KiScaledBitmap( measurement_xpm, this ),
  133. _( "Measure distance" ),
  134. wxITEM_CHECK );
  135. m_drawToolBar->Realize();
  136. }
  137. void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
  138. {
  139. if( m_optionsToolBar )
  140. m_optionsToolBar->Clear();
  141. else
  142. m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  143. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  144. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
  145. KiScaledBitmap( grid_xpm, this ),
  146. _( "Hide grid" ), wxITEM_CHECK );
  147. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
  148. KiScaledBitmap( polar_coord_xpm, this ),
  149. _( "Display Polar Coord ON" ), wxITEM_CHECK );
  150. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
  151. KiScaledBitmap( unit_inch_xpm, this ),
  152. _( "Set units to inches" ), wxITEM_CHECK );
  153. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
  154. KiScaledBitmap( unit_mm_xpm, this ),
  155. _( "Set units to millimeters" ), wxITEM_CHECK );
  156. #ifndef __APPLE__
  157. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  158. KiScaledBitmap( cursor_shape_xpm, this ),
  159. _( "Change cursor shape" ), wxITEM_CHECK );
  160. #else
  161. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  162. KiScaledBitmap( cursor_shape_xpm, this ),
  163. _( "Change cursor shape (not supported in Legacy Toolset)" ),
  164. wxITEM_CHECK );
  165. #endif
  166. KiScaledSeparator( m_optionsToolBar, this );
  167. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
  168. KiScaledBitmap( pad_sketch_xpm, this ),
  169. _( "Show Pads Sketch" ), wxITEM_CHECK );
  170. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, wxEmptyString,
  171. KiScaledBitmap( text_sketch_xpm, this ),
  172. _( "Show Texts Sketch" ), wxITEM_CHECK );
  173. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, wxEmptyString,
  174. KiScaledBitmap( show_mod_edge_xpm, this ),
  175. _( "Show Edges Sketch" ), wxITEM_CHECK );
  176. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, wxEmptyString,
  177. KiScaledBitmap( contrast_mode_xpm, this ),
  178. _( "Enable high contrast display mode" ),
  179. wxITEM_CHECK );
  180. m_optionsToolBar->Realize();
  181. }
  182. void FOOTPRINT_EDIT_FRAME::ReCreateAuxiliaryToolbar()
  183. {
  184. if( m_auxiliaryToolBar )
  185. m_auxiliaryToolBar->Clear();
  186. else
  187. m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  188. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  189. // Set up toolbar
  190. KiScaledSeparator( m_auxiliaryToolBar, this );
  191. // Grid selection choice box.
  192. m_gridSelectBox = new wxChoice( m_auxiliaryToolBar,
  193. ID_ON_GRID_SELECT,
  194. wxDefaultPosition, wxDefaultSize,
  195. 0, NULL );
  196. // Update tool bar to reflect setting.
  197. updateGridSelectBox();
  198. m_auxiliaryToolBar->AddControl( m_gridSelectBox );
  199. // Zoom selection choice box.
  200. KiScaledSeparator( m_auxiliaryToolBar, this );
  201. m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar,
  202. ID_ON_ZOOM_SELECT,
  203. wxDefaultPosition, wxDefaultSize,
  204. 0, NULL );
  205. updateZoomSelectBox();
  206. m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
  207. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  208. m_auxiliaryToolBar->Realize();
  209. }