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.

659 lines
27 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
16 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.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-2012 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file tool_pcb.cpp
  28. * @brief PCB editor tool bars
  29. */
  30. #include <fctsys.h>
  31. #include <help_common_strings.h>
  32. #include <dialog_helpers.h>
  33. #include <class_layer_box_selector.h>
  34. #include <colors_selection.h>
  35. #include <wxPcbStruct.h>
  36. #include <class_board.h>
  37. #include <pcbnew.h>
  38. #include <pcbnew_id.h>
  39. #include <hotkeys.h>
  40. #include <class_pcb_layer_box_selector.h>
  41. #include <wx/wupdlock.h>
  42. #ifdef __UNIX__
  43. #define LISTBOX_WIDTH 150
  44. #else
  45. #define LISTBOX_WIDTH 130
  46. #endif
  47. #define SEL_LAYER_HELP _( \
  48. "Show active layer selections\nand select layer pair for route and place via" )
  49. /* Data to build the layer pair indicator button */
  50. static wxBitmap* LayerPairBitmap = NULL;
  51. static const char s_BitmapLayerIcon[24][24] = {
  52. // 0 = draw pixel with active layer color
  53. // 1 = draw pixel with top layer color (top/bottom layer used inautoroute and place via)
  54. // 2 = draw pixel with bottom layer color
  55. // 3 = draw pixel with via color
  56. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
  57. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
  58. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
  59. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
  60. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
  61. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
  62. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
  63. { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0 },
  64. { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
  65. { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
  66. { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
  67. { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 },
  68. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  69. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  70. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  71. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  72. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  73. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  74. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  75. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  76. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  77. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  78. };
  79. /* Draw the icon for the "Select layer pair" bitmap tool
  80. */
  81. void PCB_EDIT_FRAME::PrepareLayerIndicator()
  82. {
  83. int ii, jj;
  84. int active_layer_color, Route_Layer_TOP_color,
  85. Route_Layer_BOTTOM_color, via_color;
  86. bool change = false;
  87. bool first_call = LayerPairBitmap == NULL;
  88. static int previous_active_layer_color, previous_Route_Layer_TOP_color,
  89. previous_Route_Layer_BOTTOM_color, previous_via_color;
  90. /* get colors, and redraw bitmap button only on changes */
  91. active_layer_color = GetBoard()->GetLayerColor(getActiveLayer());
  92. if( previous_active_layer_color != active_layer_color )
  93. {
  94. previous_active_layer_color = active_layer_color;
  95. change = true;
  96. }
  97. Route_Layer_TOP_color =
  98. g_ColorsSettings.GetLayerColor( ( ( PCB_SCREEN* ) GetScreen() )->m_Route_Layer_TOP );
  99. if( previous_Route_Layer_TOP_color != Route_Layer_TOP_color )
  100. {
  101. previous_Route_Layer_TOP_color = Route_Layer_TOP_color;
  102. change = true;
  103. }
  104. Route_Layer_BOTTOM_color =
  105. g_ColorsSettings.GetLayerColor( ( (PCB_SCREEN*) GetScreen() )->m_Route_Layer_BOTTOM );
  106. if( previous_Route_Layer_BOTTOM_color != Route_Layer_BOTTOM_color )
  107. {
  108. previous_Route_Layer_BOTTOM_color = Route_Layer_BOTTOM_color;
  109. change = true;
  110. }
  111. int via_type = GetDesignSettings().m_CurrentViaType;
  112. via_color = GetBoard()->GetVisibleElementColor(VIAS_VISIBLE+via_type);
  113. if( previous_via_color != via_color )
  114. {
  115. previous_via_color = via_color;
  116. change = true;
  117. }
  118. if( !change && (LayerPairBitmap != NULL) )
  119. return;
  120. /* Create the bitmap and its Memory DC, if not already made */
  121. if( LayerPairBitmap == NULL )
  122. {
  123. LayerPairBitmap = new wxBitmap( 24, 24 );
  124. }
  125. /* Draw the icon, with colors according to the active layer and layer
  126. * pairs for via command (change layer)
  127. */
  128. wxMemoryDC iconDC;
  129. iconDC.SelectObject( *LayerPairBitmap );
  130. wxPen pen;
  131. int buttonColor = -1;
  132. for( ii = 0; ii < 24; ii++ )
  133. {
  134. for( jj = 0; jj < 24; jj++ )
  135. {
  136. if( s_BitmapLayerIcon[ii][jj] != buttonColor )
  137. {
  138. switch( s_BitmapLayerIcon[ii][jj] )
  139. {
  140. default:
  141. case 0:
  142. pen.SetColour( MakeColour( active_layer_color ) );
  143. break;
  144. case 1:
  145. pen.SetColour( MakeColour( Route_Layer_TOP_color) );
  146. break;
  147. case 2:
  148. pen.SetColour( MakeColour( Route_Layer_BOTTOM_color ) );
  149. break;
  150. case 3:
  151. pen.SetColour( MakeColour( via_color ) );
  152. break;
  153. }
  154. buttonColor = s_BitmapLayerIcon[ii][jj];
  155. iconDC.SetPen( pen );
  156. }
  157. iconDC.DrawPoint( jj, ii );
  158. }
  159. }
  160. /* Deselect the Tool Bitmap from DC,
  161. * in order to delete the MemoryDC safely without deleting the bitmap */
  162. iconDC.SelectObject( wxNullBitmap );
  163. if( m_mainToolBar && ! first_call )
  164. {
  165. m_mainToolBar->SetToolBitmap( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, *LayerPairBitmap );
  166. m_mainToolBar->Refresh();
  167. }
  168. }
  169. /* Creates or updates the main horizontal toolbar for the board editor
  170. */
  171. void PCB_EDIT_FRAME::ReCreateHToolbar()
  172. {
  173. wxString msg;
  174. if( m_mainToolBar )
  175. return;
  176. wxWindowUpdateLocker dummy( this );
  177. m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  178. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
  179. // Set up toolbar
  180. m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_pcb_xpm ),
  181. _( "New board" ) );
  182. m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
  183. _( "Open existing board" ) );
  184. m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
  185. _( "Save board" ) );
  186. m_mainToolBar->AddSeparator();
  187. m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
  188. _( "Page settings for paper size and texts" ) );
  189. m_mainToolBar->AddSeparator();
  190. m_mainToolBar->AddTool( ID_OPEN_MODULE_EDITOR, wxEmptyString,
  191. KiBitmap( module_edit_xpm ),
  192. _( "Open module editor" ) );
  193. m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString,
  194. KiBitmap( modview_icon_xpm ),
  195. _( "Open module viewer" ) );
  196. m_mainToolBar->AddSeparator();
  197. msg = AddHotkeyName( HELP_UNDO, g_Board_Editor_Hokeys_Descr, HK_UNDO, IS_COMMENT );
  198. m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), HELP_UNDO );
  199. msg = AddHotkeyName( HELP_REDO, g_Board_Editor_Hokeys_Descr, HK_REDO, IS_COMMENT );
  200. m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), HELP_REDO );
  201. m_mainToolBar->AddSeparator();
  202. m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
  203. _( "Print board" ) );
  204. m_mainToolBar->AddTool( ID_GEN_PLOT, wxEmptyString, KiBitmap( plot_xpm ),
  205. _( "Plot (HPGL, PostScript, or GERBER format)" ) );
  206. m_mainToolBar->AddSeparator();
  207. msg = AddHotkeyName( HELP_ZOOM_IN, g_Board_Editor_Hokeys_Descr, HK_ZOOM_IN, IS_COMMENT );
  208. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
  209. msg = AddHotkeyName( HELP_ZOOM_OUT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_OUT, IS_COMMENT );
  210. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
  211. msg = AddHotkeyName( HELP_ZOOM_REDRAW, g_Board_Editor_Hokeys_Descr, HK_ZOOM_REDRAW,
  212. IS_COMMENT );
  213. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
  214. msg = AddHotkeyName( HELP_ZOOM_FIT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_AUTO, IS_COMMENT );
  215. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
  216. m_mainToolBar->AddSeparator();
  217. msg = AddHotkeyName( HELP_FIND, g_Board_Editor_Hokeys_Descr, HK_FIND_ITEM, IS_COMMENT );
  218. m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
  219. m_mainToolBar->AddSeparator();
  220. m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
  221. _( "Read netlist" ) );
  222. m_mainToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, KiBitmap( erc_xpm ),
  223. _( "Perform design rules check" ) );
  224. m_mainToolBar->AddSeparator();
  225. if( m_SelLayerBox == NULL )
  226. m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_PCB_SELECT_LAYER );
  227. ReCreateLayerBox( m_mainToolBar );
  228. m_mainToolBar->AddControl( m_SelLayerBox );
  229. PrepareLayerIndicator(); // Initialize the bitmap with current
  230. // active layer colors for the next tool
  231. m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
  232. *LayerPairBitmap, SEL_LAYER_HELP );
  233. m_mainToolBar->AddSeparator();
  234. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString, KiBitmap( mode_module_xpm ),
  235. _( "Mode footprint: manual and automatic move and place modules" ),
  236. wxITEM_CHECK );
  237. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString, KiBitmap( mode_track_xpm ),
  238. _( "Mode track: autorouting" ), wxITEM_CHECK );
  239. // Fast call to FreeROUTE Web Bases router
  240. m_mainToolBar->AddSeparator();
  241. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, wxEmptyString,
  242. KiBitmap( web_support_xpm ),
  243. _( "Fast access to the Web Based FreeROUTE advanced router" ) );
  244. m_mainToolBar->AddSeparator();
  245. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  246. m_mainToolBar->Realize();
  247. }
  248. void PCB_EDIT_FRAME::ReCreateOptToolbar()
  249. {
  250. if( m_optionsToolBar )
  251. return;
  252. wxWindowUpdateLocker dummy( this );
  253. m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  254. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
  255. m_optionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, KiBitmap( drc_off_xpm ),
  256. _( "Enable design rule checking" ), wxITEM_CHECK );
  257. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
  258. _( "Hide grid" ), wxITEM_CHECK );
  259. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
  260. KiBitmap( polar_coord_xpm ),
  261. _( "Display polar coordinates" ), wxITEM_CHECK );
  262. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
  263. KiBitmap( unit_inch_xpm ),
  264. _( "Units in inches" ), wxITEM_CHECK );
  265. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
  266. KiBitmap( unit_mm_xpm ),
  267. _( "Units in millimeters" ), wxITEM_CHECK );
  268. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  269. KiBitmap( cursor_shape_xpm ),
  270. _( "Change cursor shape" ), wxITEM_CHECK );
  271. m_optionsToolBar->AddSeparator();
  272. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
  273. KiBitmap( general_ratsnest_xpm ),
  274. _( "Show board ratsnest" ), wxITEM_CHECK );
  275. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, wxEmptyString,
  276. KiBitmap( local_ratsnest_xpm ),
  277. _( "Show module ratsnest when moving" ),
  278. wxITEM_CHECK );
  279. m_optionsToolBar->AddSeparator();
  280. m_optionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
  281. KiBitmap( auto_delete_track_xpm ),
  282. _( "Enable automatic track deletion" ),
  283. wxITEM_CHECK );
  284. m_optionsToolBar->AddSeparator();
  285. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, KiBitmap( show_zone_xpm ),
  286. _( "Show filled areas in zones" ), wxITEM_CHECK );
  287. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString,
  288. KiBitmap( show_zone_disable_xpm ),
  289. _( "Do not show filled areas in zones" ) , wxITEM_CHECK );
  290. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY, wxEmptyString,
  291. KiBitmap( show_zone_outline_only_xpm ),
  292. _( "Show outlines of filled areas only in zones" ), wxITEM_CHECK );
  293. m_optionsToolBar->AddSeparator();
  294. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
  295. KiBitmap( pad_sketch_xpm ),
  296. _( "Show pads in outline mode" ), wxITEM_CHECK );
  297. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
  298. KiBitmap( via_sketch_xpm ),
  299. _( "Show vias in outline mode" ), wxITEM_CHECK );
  300. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
  301. KiBitmap( showtrack_xpm ),
  302. _( "Show tracks in outline mode" ),
  303. wxITEM_CHECK );
  304. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, wxEmptyString,
  305. KiBitmap( palette_xpm ),
  306. _( "Enable high contrast display mode" ),
  307. wxITEM_CHECK );
  308. // Tools to show/hide toolbars:
  309. m_optionsToolBar->AddSeparator();
  310. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
  311. wxEmptyString,
  312. KiBitmap( layers_manager_xpm ),
  313. HELP_SHOW_HIDE_LAYERMANAGER,
  314. wxITEM_CHECK );
  315. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
  316. wxEmptyString,
  317. KiBitmap( mw_toolbar_xpm ),
  318. _( "Show/hide the toolbar for microwaves tools\n This is a experimental feature (under development)" ),
  319. wxITEM_CHECK );
  320. m_optionsToolBar->AddSeparator();
  321. m_optionsToolBar->Realize();
  322. }
  323. /* Create the main vertical right toolbar, showing usual tools
  324. */
  325. void PCB_EDIT_FRAME::ReCreateVToolbar()
  326. {
  327. if( m_drawToolBar )
  328. return;
  329. wxWindowUpdateLocker dummy( this );
  330. m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  331. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
  332. // Set up toolbar
  333. m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
  334. wxEmptyString, wxITEM_CHECK );
  335. m_drawToolBar->AddSeparator();
  336. m_drawToolBar->AddTool( ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, KiBitmap( net_highlight_xpm ),
  337. _( "Highlight net" ), wxITEM_CHECK );
  338. m_drawToolBar->AddTool( ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString,
  339. KiBitmap( tool_ratsnest_xpm ),
  340. _( "Display local ratsnest" ), wxITEM_CHECK );
  341. m_drawToolBar->AddSeparator();
  342. m_drawToolBar->AddTool( ID_PCB_MODULE_BUTT, wxEmptyString, KiBitmap( module_xpm ),
  343. _( "Add modules" ), wxITEM_CHECK );
  344. m_drawToolBar->AddTool( ID_TRACK_BUTT, wxEmptyString, KiBitmap( add_tracks_xpm ),
  345. _( "Add tracks and vias" ), wxITEM_CHECK );
  346. m_drawToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, KiBitmap( add_zone_xpm ),
  347. _( "Add filled zones" ), wxITEM_CHECK );
  348. m_drawToolBar->AddSeparator();
  349. m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_dashed_line_xpm ),
  350. _( "Add graphic line or polygon" ), wxITEM_CHECK );
  351. m_drawToolBar->AddTool( ID_PCB_CIRCLE_BUTT, wxEmptyString, KiBitmap( add_circle_xpm ),
  352. _( "Add graphic circle" ), wxITEM_CHECK );
  353. m_drawToolBar->AddTool( ID_PCB_ARC_BUTT, wxEmptyString, KiBitmap( add_arc_xpm ),
  354. _( "Add graphic arc" ), wxITEM_CHECK );
  355. m_drawToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, KiBitmap( add_text_xpm ),
  356. _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
  357. m_drawToolBar->AddSeparator();
  358. m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
  359. _( "Add dimension" ), wxITEM_CHECK );
  360. m_drawToolBar->AddTool( ID_PCB_MIRE_BUTT, wxEmptyString, KiBitmap( add_mires_xpm ),
  361. _( "Add layer alignment target" ), wxITEM_CHECK );
  362. m_drawToolBar->AddSeparator();
  363. m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
  364. _( "Delete items" ), wxITEM_CHECK );
  365. m_drawToolBar->AddSeparator();
  366. m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
  367. KiBitmap( pcb_offset_xpm ),
  368. _( "Place the origin point for drill and place files" ),
  369. wxITEM_CHECK );
  370. m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
  371. KiBitmap( grid_select_axis_xpm ),
  372. _( "Set the origin point for the grid" ),
  373. wxITEM_CHECK );
  374. m_drawToolBar->Realize();
  375. }
  376. /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
  377. */
  378. void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
  379. {
  380. if( m_microWaveToolBar )
  381. return;
  382. wxWindowUpdateLocker dummy(this);
  383. m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
  384. wxDefaultSize,
  385. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
  386. // Set up toolbar
  387. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
  388. KiBitmap( mw_add_line_xpm ),
  389. _( "Create line of specified length for microwave applications" ) );
  390. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
  391. KiBitmap( mw_add_gap_xpm ),
  392. _( "Create gap of specified length for microwave applications" ) );
  393. m_microWaveToolBar->AddSeparator();
  394. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
  395. KiBitmap( mw_add_stub_xpm ),
  396. _( "Create stub of specified length for microwave applications" ) );
  397. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
  398. KiBitmap( mw_add_stub_arc_xpm ),
  399. _( "Create stub (arc) of specified length for microwave applications" ) );
  400. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, wxEmptyString,
  401. KiBitmap( mw_add_shape_xpm ),
  402. _( "Create a polynomial shape for microwave applications" ) );
  403. m_microWaveToolBar->Realize();
  404. }
  405. /* Creates auxiliary horizontal toolbar
  406. * displays:
  407. * existing track width choice
  408. * selection for auto track width
  409. * existing via size choice
  410. * Current strategy (to choose the track and via sizes)
  411. * grid size choice
  412. * zoom level choice
  413. */
  414. void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
  415. {
  416. wxString msg;
  417. wxWindowUpdateLocker dummy( this );
  418. if( m_auxiliaryToolBar )
  419. return;
  420. m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  421. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
  422. /* Set up toolbar items */
  423. // Creates box to display and choose tracks widths:
  424. m_SelTrackWidthBox = new wxComboBox( m_auxiliaryToolBar,
  425. ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
  426. wxEmptyString,
  427. wxPoint( -1, -1 ),
  428. wxSize( LISTBOX_WIDTH, -1 ),
  429. 0, NULL, wxCB_READONLY );
  430. m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
  431. m_auxiliaryToolBar->AddSeparator();
  432. // Creates box to display and choose vias diameters:
  433. m_SelViaSizeBox = new wxComboBox( m_auxiliaryToolBar,
  434. ID_AUX_TOOLBAR_PCB_VIA_SIZE,
  435. wxEmptyString,
  436. wxPoint( -1, -1 ),
  437. wxSize( (LISTBOX_WIDTH*12)/10, -1 ),
  438. 0, NULL, wxCB_READONLY );
  439. m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
  440. m_auxiliaryToolBar->AddSeparator();
  441. // Creates box to display and choose strategy to handle tracks an vias sizes:
  442. m_auxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
  443. wxEmptyString,
  444. KiBitmap( auto_track_width_xpm ),
  445. _( "Auto track width: when starting on \
  446. an existing track use its width\notherwise, use current width setting" ),
  447. wxITEM_CHECK );
  448. // Add the box to display and select the current grid size:
  449. m_auxiliaryToolBar->AddSeparator();
  450. m_gridSelectBox = new wxComboBox( m_auxiliaryToolBar,
  451. ID_ON_GRID_SELECT,
  452. wxEmptyString,
  453. wxPoint( -1, -1 ),
  454. wxSize( LISTBOX_WIDTH, -1 ),
  455. 0, NULL, wxCB_READONLY );
  456. m_auxiliaryToolBar->AddControl( m_gridSelectBox );
  457. // Add the box to display and select the current Zoom
  458. m_auxiliaryToolBar->AddSeparator();
  459. m_zoomSelectBox = new wxComboBox( m_auxiliaryToolBar,
  460. ID_ON_ZOOM_SELECT,
  461. wxEmptyString,
  462. wxPoint( -1, -1 ),
  463. wxSize( LISTBOX_WIDTH, -1 ),
  464. 0, NULL, wxCB_READONLY );
  465. m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
  466. updateZoomSelectBox();
  467. updateGridSelectBox();
  468. updateTraceWidthSelectBox();
  469. updateViaSizeSelectBox();
  470. // after adding the buttons to the toolbar, must call Realize()
  471. m_auxiliaryToolBar->Realize();
  472. m_auxiliaryToolBar->AddSeparator();
  473. }
  474. void PCB_EDIT_FRAME::updateTraceWidthSelectBox()
  475. {
  476. if( m_SelTrackWidthBox == NULL )
  477. return;
  478. wxString msg;
  479. m_SelTrackWidthBox->Clear();
  480. for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthList.size(); ii++ )
  481. {
  482. msg = _( "Track " ) + CoordinateToString( GetBoard()->m_TrackWidthList[ii], true );
  483. if( ii == 0 )
  484. msg << _( " *" );
  485. m_SelTrackWidthBox->Append( msg );
  486. }
  487. if( GetBoard()->m_TrackWidthSelector >= GetBoard()->m_TrackWidthList.size() )
  488. GetBoard()->m_TrackWidthSelector = 0;
  489. m_SelTrackWidthBox->SetSelection( GetBoard()->m_TrackWidthSelector );
  490. }
  491. void PCB_EDIT_FRAME::updateViaSizeSelectBox()
  492. {
  493. if( m_SelViaSizeBox == NULL )
  494. return;
  495. wxString msg;
  496. m_SelViaSizeBox->Clear();
  497. for( unsigned ii = 0; ii < GetBoard()->m_ViasDimensionsList.size(); ii++ )
  498. {
  499. msg = _( "Via " );
  500. msg << CoordinateToString( GetBoard()->m_ViasDimensionsList[ii].m_Diameter, true );
  501. if( GetBoard()->m_ViasDimensionsList[ii].m_Drill )
  502. msg << wxT("/ ")
  503. << CoordinateToString( GetBoard()->m_ViasDimensionsList[ii].m_Drill, true );
  504. if( ii == 0 )
  505. msg << _( " *" );
  506. m_SelViaSizeBox->Append( msg );
  507. }
  508. if( GetBoard()->m_ViaSizeSelector >= GetBoard()->m_ViasDimensionsList.size() )
  509. GetBoard()->m_ViaSizeSelector = 0;
  510. m_SelViaSizeBox->SetSelection( GetBoard()->m_ViaSizeSelector );
  511. }
  512. PCB_LAYER_BOX_SELECTOR* PCB_EDIT_FRAME::ReCreateLayerBox( wxAuiToolBar* parent )
  513. {
  514. if( m_SelLayerBox == NULL )
  515. return NULL;
  516. m_SelLayerBox->m_hotkeys = g_Board_Editor_Hokeys_Descr;
  517. m_SelLayerBox->Resync();
  518. m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
  519. return m_SelLayerBox;
  520. }