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.

240 lines
11 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 changes" ) );
  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. KiScaledSeparator( m_mainToolBar, this );
  94. // Grid selection choice box.
  95. m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT,
  96. wxDefaultPosition, wxDefaultSize, 0, NULL );
  97. updateGridSelectBox();
  98. m_mainToolBar->AddControl( m_gridSelectBox );
  99. KiScaledSeparator( m_mainToolBar, this );
  100. // Zoom selection choice box.
  101. m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT,
  102. wxDefaultPosition, wxDefaultSize, 0, NULL );
  103. updateZoomSelectBox();
  104. m_mainToolBar->AddControl( m_zoomSelectBox );
  105. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  106. m_mainToolBar->Realize();
  107. }
  108. void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar()
  109. {
  110. if( m_drawToolBar )
  111. m_drawToolBar->Clear();
  112. else
  113. m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  114. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  115. // Set up toolbar
  116. m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
  117. wxEmptyString, wxITEM_CHECK );
  118. KiScaledSeparator( m_drawToolBar, this );
  119. m_drawToolBar->AddTool( ID_MODEDIT_PAD_TOOL, wxEmptyString, KiScaledBitmap( pad_xpm, this ),
  120. _( "Add pad" ), wxITEM_CHECK );
  121. KiScaledSeparator( m_drawToolBar, this );
  122. m_drawToolBar->AddTool( ID_MODEDIT_LINE_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_segments_xpm, this ),
  123. _( "Add graphic line" ), wxITEM_CHECK );
  124. m_drawToolBar->AddTool( ID_MODEDIT_CIRCLE_TOOL, wxEmptyString, KiScaledBitmap( add_circle_xpm, this ),
  125. _( "Add graphic circle" ), wxITEM_CHECK );
  126. m_drawToolBar->AddTool( ID_MODEDIT_ARC_TOOL, wxEmptyString, KiScaledBitmap( add_arc_xpm, this ),
  127. _( "Add graphic arc" ), wxITEM_CHECK );
  128. m_drawToolBar->AddTool( ID_MODEDIT_POLYGON_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_polygon_xpm, this ),
  129. _( "Add graphic polygon" ), wxITEM_CHECK );
  130. m_drawToolBar->AddTool( ID_MODEDIT_TEXT_TOOL, wxEmptyString, KiScaledBitmap( text_xpm, this ),
  131. _( "Add Text" ), wxITEM_CHECK );
  132. KiScaledSeparator( m_drawToolBar, this );
  133. m_drawToolBar->AddTool( ID_MODEDIT_ANCHOR_TOOL, wxEmptyString, KiScaledBitmap( anchor_xpm, this ),
  134. _( "Place footprint reference anchor" ),
  135. wxITEM_CHECK );
  136. KiScaledSeparator( m_drawToolBar, this );
  137. m_drawToolBar->AddTool( ID_MODEDIT_DELETE_TOOL, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
  138. _( "Delete item" ), wxITEM_CHECK );
  139. m_drawToolBar->AddTool( ID_MODEDIT_PLACE_GRID_COORD, wxEmptyString,
  140. KiScaledBitmap( grid_select_axis_xpm, this ),
  141. _( "Set grid origin" ),
  142. wxITEM_CHECK );
  143. m_drawToolBar->AddTool( ID_MODEDIT_MEASUREMENT_TOOL, wxEmptyString,
  144. KiScaledBitmap( measurement_xpm, this ),
  145. _( "Measure distance" ),
  146. wxITEM_CHECK );
  147. m_drawToolBar->Realize();
  148. }
  149. void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
  150. {
  151. if( m_optionsToolBar )
  152. m_optionsToolBar->Clear();
  153. else
  154. m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  155. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  156. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
  157. KiScaledBitmap( grid_xpm, this ),
  158. _( "Hide grid" ), wxITEM_CHECK );
  159. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
  160. KiScaledBitmap( polar_coord_xpm, this ),
  161. _( "Display Polar Coord ON" ), wxITEM_CHECK );
  162. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
  163. KiScaledBitmap( unit_inch_xpm, this ),
  164. _( "Set units to inches" ), wxITEM_CHECK );
  165. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
  166. KiScaledBitmap( unit_mm_xpm, this ),
  167. _( "Set units to millimeters" ), wxITEM_CHECK );
  168. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  169. KiScaledBitmap( cursor_shape_xpm, this ),
  170. _( "Change cursor shape" ), wxITEM_CHECK );
  171. KiScaledSeparator( m_optionsToolBar, this );
  172. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
  173. KiScaledBitmap( pad_sketch_xpm, this ),
  174. _( "Show Pads Sketch" ), wxITEM_CHECK );
  175. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, wxEmptyString,
  176. KiScaledBitmap( text_sketch_xpm, this ),
  177. _( "Show Texts Sketch" ), wxITEM_CHECK );
  178. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, wxEmptyString,
  179. KiScaledBitmap( show_mod_edge_xpm, this ),
  180. _( "Show Edges Sketch" ), wxITEM_CHECK );
  181. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, wxEmptyString,
  182. KiScaledBitmap( contrast_mode_xpm, this ),
  183. _( "Enable high contrast display mode" ),
  184. wxITEM_CHECK );
  185. m_optionsToolBar->Realize();
  186. }