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.

686 lines
28 KiB

19 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
16 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 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. #define BM_LAYERICON_SIZE 24
  52. static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE] =
  53. {
  54. // 0 = draw pixel with active layer color
  55. // 1 = draw pixel with top layer color (top/bottom layer used inautoroute and place via)
  56. // 2 = draw pixel with bottom layer color
  57. // 3 = draw pixel with via color
  58. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
  59. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
  60. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
  61. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
  62. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
  63. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
  64. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
  65. { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0 },
  66. { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
  67. { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
  68. { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
  69. { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 },
  70. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  71. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 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. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  79. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  80. };
  81. /* Draw the icon for the "Select layer pair" bitmap tool
  82. */
  83. void PCB_EDIT_FRAME::PrepareLayerIndicator()
  84. {
  85. int ii, jj;
  86. EDA_COLOR_T active_layer_color, Route_Layer_TOP_color,
  87. Route_Layer_BOTTOM_color, via_color;
  88. bool change = false;
  89. bool first_call = LayerPairBitmap == NULL;
  90. static int previous_active_layer_color, previous_Route_Layer_TOP_color,
  91. previous_Route_Layer_BOTTOM_color, previous_via_color;
  92. /* get colors, and redraw bitmap button only on changes */
  93. active_layer_color = GetBoard()->GetLayerColor(GetActiveLayer());
  94. if( previous_active_layer_color != active_layer_color )
  95. {
  96. previous_active_layer_color = active_layer_color;
  97. change = true;
  98. }
  99. Route_Layer_TOP_color =
  100. g_ColorsSettings.GetLayerColor( ( ( PCB_SCREEN* ) GetScreen() )->m_Route_Layer_TOP );
  101. if( previous_Route_Layer_TOP_color != Route_Layer_TOP_color )
  102. {
  103. previous_Route_Layer_TOP_color = Route_Layer_TOP_color;
  104. change = true;
  105. }
  106. Route_Layer_BOTTOM_color =
  107. g_ColorsSettings.GetLayerColor( ( (PCB_SCREEN*) GetScreen() )->m_Route_Layer_BOTTOM );
  108. if( previous_Route_Layer_BOTTOM_color != Route_Layer_BOTTOM_color )
  109. {
  110. previous_Route_Layer_BOTTOM_color = Route_Layer_BOTTOM_color;
  111. change = true;
  112. }
  113. int via_type = GetDesignSettings().m_CurrentViaType;
  114. via_color = GetBoard()->GetVisibleElementColor(VIAS_VISIBLE+via_type);
  115. if( previous_via_color != via_color )
  116. {
  117. previous_via_color = via_color;
  118. change = true;
  119. }
  120. if( !change && (LayerPairBitmap != NULL) )
  121. return;
  122. /* Create the bitmap and its Memory DC, if not already made */
  123. if( LayerPairBitmap == NULL )
  124. {
  125. LayerPairBitmap = new wxBitmap( 24, 24 );
  126. }
  127. /* Draw the icon, with colors according to the active layer and layer
  128. * pairs for via command (change layer)
  129. */
  130. wxMemoryDC iconDC;
  131. iconDC.SelectObject( *LayerPairBitmap );
  132. wxPen pen;
  133. int buttonColor = -1;
  134. for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
  135. {
  136. for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
  137. {
  138. if( s_BitmapLayerIcon[ii][jj] != buttonColor )
  139. {
  140. switch( s_BitmapLayerIcon[ii][jj] )
  141. {
  142. default:
  143. case 0:
  144. pen.SetColour( MakeColour( active_layer_color ) );
  145. break;
  146. case 1:
  147. pen.SetColour( MakeColour( Route_Layer_TOP_color) );
  148. break;
  149. case 2:
  150. pen.SetColour( MakeColour( Route_Layer_BOTTOM_color ) );
  151. break;
  152. case 3:
  153. pen.SetColour( MakeColour( via_color ) );
  154. break;
  155. }
  156. buttonColor = s_BitmapLayerIcon[ii][jj];
  157. iconDC.SetPen( pen );
  158. }
  159. iconDC.DrawPoint( jj, ii );
  160. }
  161. }
  162. /* Deselect the Tool Bitmap from DC,
  163. * in order to delete the MemoryDC safely without deleting the bitmap */
  164. iconDC.SelectObject( wxNullBitmap );
  165. if( m_mainToolBar && ! first_call )
  166. {
  167. m_mainToolBar->SetToolBitmap( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, *LayerPairBitmap );
  168. m_mainToolBar->Refresh();
  169. }
  170. }
  171. /* Creates or updates the main horizontal toolbar for the board editor
  172. */
  173. void PCB_EDIT_FRAME::ReCreateHToolbar()
  174. {
  175. wxString msg;
  176. if( m_mainToolBar )
  177. return;
  178. wxWindowUpdateLocker dummy( this );
  179. m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  180. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
  181. // Set up toolbar
  182. m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_pcb_xpm ),
  183. _( "New board" ) );
  184. m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
  185. _( "Open existing board" ) );
  186. m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
  187. _( "Save board" ) );
  188. m_mainToolBar->AddSeparator();
  189. m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
  190. _( "Page settings for paper size and texts" ) );
  191. m_mainToolBar->AddSeparator();
  192. m_mainToolBar->AddTool( ID_OPEN_MODULE_EDITOR, wxEmptyString,
  193. KiBitmap( module_editor_xpm ),
  194. _( "Open module editor" ) );
  195. m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString,
  196. KiBitmap( modview_icon_xpm ),
  197. _( "Open module viewer" ) );
  198. m_mainToolBar->AddSeparator();
  199. msg = AddHotkeyName( HELP_UNDO, g_Board_Editor_Hokeys_Descr, HK_UNDO, IS_COMMENT );
  200. m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), HELP_UNDO );
  201. msg = AddHotkeyName( HELP_REDO, g_Board_Editor_Hokeys_Descr, HK_REDO, IS_COMMENT );
  202. m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), HELP_REDO );
  203. m_mainToolBar->AddSeparator();
  204. m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
  205. _( "Print board" ) );
  206. m_mainToolBar->AddTool( ID_GEN_PLOT, wxEmptyString, KiBitmap( plot_xpm ),
  207. _( "Plot (HPGL, PostScript, or GERBER format)" ) );
  208. m_mainToolBar->AddSeparator();
  209. msg = AddHotkeyName( HELP_ZOOM_IN, g_Board_Editor_Hokeys_Descr, HK_ZOOM_IN, IS_COMMENT );
  210. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
  211. msg = AddHotkeyName( HELP_ZOOM_OUT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_OUT, IS_COMMENT );
  212. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
  213. msg = AddHotkeyName( HELP_ZOOM_REDRAW, g_Board_Editor_Hokeys_Descr, HK_ZOOM_REDRAW,
  214. IS_COMMENT );
  215. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
  216. msg = AddHotkeyName( HELP_ZOOM_FIT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_AUTO, IS_COMMENT );
  217. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
  218. m_mainToolBar->AddSeparator();
  219. msg = AddHotkeyName( HELP_FIND, g_Board_Editor_Hokeys_Descr, HK_FIND_ITEM, IS_COMMENT );
  220. m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
  221. m_mainToolBar->AddSeparator();
  222. m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
  223. _( "Read netlist" ) );
  224. m_mainToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, KiBitmap( erc_xpm ),
  225. _( "Perform design rules check" ) );
  226. m_mainToolBar->AddSeparator();
  227. if( m_SelLayerBox == NULL )
  228. {
  229. m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_PCB_SELECT_LAYER );
  230. m_SelLayerBox->SetBoardFrame( this );
  231. }
  232. ReCreateLayerBox( false );
  233. m_mainToolBar->AddControl( m_SelLayerBox );
  234. PrepareLayerIndicator(); // Initialize the bitmap with current
  235. // active layer colors for the next tool
  236. m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
  237. *LayerPairBitmap, SEL_LAYER_HELP );
  238. m_mainToolBar->AddSeparator();
  239. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString, KiBitmap( mode_module_xpm ),
  240. _( "Mode footprint: manual and automatic move and place modules" ),
  241. wxITEM_CHECK );
  242. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString, KiBitmap( mode_track_xpm ),
  243. _( "Mode track: autorouting" ), wxITEM_CHECK );
  244. // Fast call to FreeROUTE Web Bases router
  245. m_mainToolBar->AddSeparator();
  246. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, wxEmptyString,
  247. KiBitmap( web_support_xpm ),
  248. _( "Fast access to the Web Based FreeROUTE advanced router" ) );
  249. m_mainToolBar->AddSeparator();
  250. // Access to the scripting console
  251. #ifdef KICAD_SCRIPTING_WXPYTHON
  252. m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
  253. KiBitmap( py_script_xpm ),
  254. _( "Show/Hide the Scripting console" ) );
  255. m_mainToolBar->AddSeparator();
  256. #endif
  257. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  258. m_mainToolBar->Realize();
  259. }
  260. void PCB_EDIT_FRAME::ReCreateOptToolbar()
  261. {
  262. if( m_optionsToolBar )
  263. return;
  264. wxWindowUpdateLocker dummy( this );
  265. m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  266. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
  267. m_optionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, KiBitmap( drc_off_xpm ),
  268. _( "Enable design rule checking" ), wxITEM_CHECK );
  269. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
  270. _( "Hide grid" ), wxITEM_CHECK );
  271. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
  272. KiBitmap( polar_coord_xpm ),
  273. _( "Display polar coordinates" ), wxITEM_CHECK );
  274. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
  275. KiBitmap( unit_inch_xpm ),
  276. _( "Units in inches" ), wxITEM_CHECK );
  277. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
  278. KiBitmap( unit_mm_xpm ),
  279. _( "Units in millimeters" ), wxITEM_CHECK );
  280. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  281. KiBitmap( cursor_shape_xpm ),
  282. _( "Change cursor shape" ), wxITEM_CHECK );
  283. m_optionsToolBar->AddSeparator();
  284. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
  285. KiBitmap( general_ratsnest_xpm ),
  286. _( "Show board ratsnest" ), wxITEM_CHECK );
  287. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, wxEmptyString,
  288. KiBitmap( local_ratsnest_xpm ),
  289. _( "Show module ratsnest when moving" ),
  290. wxITEM_CHECK );
  291. m_optionsToolBar->AddSeparator();
  292. m_optionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
  293. KiBitmap( auto_delete_track_xpm ),
  294. _( "Enable automatic track deletion" ),
  295. wxITEM_CHECK );
  296. m_optionsToolBar->AddSeparator();
  297. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, KiBitmap( show_zone_xpm ),
  298. _( "Show filled areas in zones" ), wxITEM_CHECK );
  299. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString,
  300. KiBitmap( show_zone_disable_xpm ),
  301. _( "Do not show filled areas in zones" ) , wxITEM_CHECK );
  302. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY, wxEmptyString,
  303. KiBitmap( show_zone_outline_only_xpm ),
  304. _( "Show outlines of filled areas only in zones" ), wxITEM_CHECK );
  305. m_optionsToolBar->AddSeparator();
  306. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
  307. KiBitmap( pad_sketch_xpm ),
  308. _( "Show pads in outline mode" ), wxITEM_CHECK );
  309. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
  310. KiBitmap( via_sketch_xpm ),
  311. _( "Show vias in outline mode" ), wxITEM_CHECK );
  312. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
  313. KiBitmap( showtrack_xpm ),
  314. _( "Show tracks in outline mode" ),
  315. wxITEM_CHECK );
  316. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, wxEmptyString,
  317. KiBitmap( palette_xpm ),
  318. _( "Enable high contrast display mode" ),
  319. wxITEM_CHECK );
  320. // Tools to show/hide toolbars:
  321. m_optionsToolBar->AddSeparator();
  322. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
  323. wxEmptyString,
  324. KiBitmap( layers_manager_xpm ),
  325. HELP_SHOW_HIDE_LAYERMANAGER,
  326. wxITEM_CHECK );
  327. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
  328. wxEmptyString,
  329. KiBitmap( mw_toolbar_xpm ),
  330. HELP_SHOW_HIDE_MICROWAVE_TOOLS,
  331. wxITEM_CHECK );
  332. m_optionsToolBar->AddSeparator();
  333. m_optionsToolBar->Realize();
  334. }
  335. /* Create the main vertical right toolbar, showing usual tools
  336. */
  337. void PCB_EDIT_FRAME::ReCreateVToolbar()
  338. {
  339. if( m_drawToolBar )
  340. return;
  341. wxWindowUpdateLocker dummy( this );
  342. m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  343. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
  344. // Set up toolbar
  345. m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
  346. wxEmptyString, wxITEM_CHECK );
  347. m_drawToolBar->AddSeparator();
  348. m_drawToolBar->AddTool( ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, KiBitmap( net_highlight_xpm ),
  349. _( "Highlight net" ), wxITEM_CHECK );
  350. m_drawToolBar->AddTool( ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString,
  351. KiBitmap( tool_ratsnest_xpm ),
  352. _( "Display local ratsnest" ), wxITEM_CHECK );
  353. m_drawToolBar->AddSeparator();
  354. m_drawToolBar->AddTool( ID_PCB_MODULE_BUTT, wxEmptyString, KiBitmap( module_xpm ),
  355. _( "Add modules" ), wxITEM_CHECK );
  356. m_drawToolBar->AddTool( ID_TRACK_BUTT, wxEmptyString, KiBitmap( add_tracks_xpm ),
  357. _( "Add tracks and vias" ), wxITEM_CHECK );
  358. m_drawToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, KiBitmap( add_zone_xpm ),
  359. _( "Add filled zones" ), wxITEM_CHECK );
  360. m_drawToolBar->AddTool( ID_PCB_KEEPOUT_AREA_BUTT, wxEmptyString,
  361. KiBitmap( add_keepout_area_xpm ),
  362. _( "Add keepout areas" ), wxITEM_CHECK );
  363. m_drawToolBar->AddSeparator();
  364. m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_dashed_line_xpm ),
  365. _( "Add graphic line or polygon" ), wxITEM_CHECK );
  366. m_drawToolBar->AddTool( ID_PCB_CIRCLE_BUTT, wxEmptyString, KiBitmap( add_circle_xpm ),
  367. _( "Add graphic circle" ), wxITEM_CHECK );
  368. m_drawToolBar->AddTool( ID_PCB_ARC_BUTT, wxEmptyString, KiBitmap( add_arc_xpm ),
  369. _( "Add graphic arc" ), wxITEM_CHECK );
  370. m_drawToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, KiBitmap( add_text_xpm ),
  371. _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
  372. m_drawToolBar->AddSeparator();
  373. m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
  374. _( "Add dimension" ), wxITEM_CHECK );
  375. m_drawToolBar->AddTool( ID_PCB_MIRE_BUTT, wxEmptyString, KiBitmap( add_mires_xpm ),
  376. _( "Add layer alignment target" ), wxITEM_CHECK );
  377. m_drawToolBar->AddSeparator();
  378. m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
  379. _( "Delete items" ), wxITEM_CHECK );
  380. m_drawToolBar->AddSeparator();
  381. m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
  382. KiBitmap( pcb_offset_xpm ),
  383. _( "Place the origin point for drill and place files" ),
  384. wxITEM_CHECK );
  385. m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
  386. KiBitmap( grid_select_axis_xpm ),
  387. _( "Set the origin point for the grid" ),
  388. wxITEM_CHECK );
  389. m_drawToolBar->Realize();
  390. }
  391. /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
  392. */
  393. void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
  394. {
  395. if( m_microWaveToolBar )
  396. return;
  397. wxWindowUpdateLocker dummy(this);
  398. m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
  399. wxDefaultSize,
  400. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
  401. // Set up toolbar
  402. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
  403. KiBitmap( mw_add_line_xpm ),
  404. _( "Create line of specified length for microwave applications" ),
  405. wxITEM_CHECK );
  406. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
  407. KiBitmap( mw_add_gap_xpm ),
  408. _( "Create gap of specified length for microwave applications" ),
  409. wxITEM_CHECK );
  410. m_microWaveToolBar->AddSeparator();
  411. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
  412. KiBitmap( mw_add_stub_xpm ),
  413. _( "Create stub of specified length for microwave applications" ),
  414. wxITEM_CHECK );
  415. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
  416. KiBitmap( mw_add_stub_arc_xpm ),
  417. _( "Create stub (arc) of specified length for microwave applications" ),
  418. wxITEM_CHECK );
  419. m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, wxEmptyString,
  420. KiBitmap( mw_add_shape_xpm ),
  421. _( "Create a polynomial shape for microwave applications" ),
  422. wxITEM_CHECK );
  423. m_microWaveToolBar->Realize();
  424. }
  425. /* Creates auxiliary horizontal toolbar
  426. * displays:
  427. * existing track width choice
  428. * selection for auto track width
  429. * existing via size choice
  430. * Current strategy (to choose the track and via sizes)
  431. * grid size choice
  432. * zoom level choice
  433. */
  434. void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
  435. {
  436. wxString msg;
  437. wxWindowUpdateLocker dummy( this );
  438. if( m_auxiliaryToolBar )
  439. return;
  440. m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  441. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
  442. /* Set up toolbar items */
  443. // Creates box to display and choose tracks widths:
  444. m_SelTrackWidthBox = new wxComboBox( m_auxiliaryToolBar,
  445. ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
  446. wxEmptyString,
  447. wxPoint( -1, -1 ),
  448. wxSize( LISTBOX_WIDTH, -1 ),
  449. 0, NULL, wxCB_READONLY );
  450. m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
  451. m_auxiliaryToolBar->AddSeparator();
  452. // Creates box to display and choose vias diameters:
  453. m_SelViaSizeBox = new wxComboBox( m_auxiliaryToolBar,
  454. ID_AUX_TOOLBAR_PCB_VIA_SIZE,
  455. wxEmptyString,
  456. wxPoint( -1, -1 ),
  457. wxSize( (LISTBOX_WIDTH*12)/10, -1 ),
  458. 0, NULL, wxCB_READONLY );
  459. m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
  460. m_auxiliaryToolBar->AddSeparator();
  461. // Creates box to display and choose strategy to handle tracks an vias sizes:
  462. m_auxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
  463. wxEmptyString,
  464. KiBitmap( auto_track_width_xpm ),
  465. _( "Auto track width: when starting on \
  466. an existing track use its width\notherwise, use current width setting" ),
  467. wxITEM_CHECK );
  468. // Add the box to display and select the current grid size:
  469. m_auxiliaryToolBar->AddSeparator();
  470. m_gridSelectBox = new wxComboBox( m_auxiliaryToolBar,
  471. ID_ON_GRID_SELECT,
  472. wxEmptyString,
  473. wxPoint( -1, -1 ),
  474. wxSize( LISTBOX_WIDTH, -1 ),
  475. 0, NULL, wxCB_READONLY );
  476. m_auxiliaryToolBar->AddControl( m_gridSelectBox );
  477. // Add the box to display and select the current Zoom
  478. m_auxiliaryToolBar->AddSeparator();
  479. m_zoomSelectBox = new wxComboBox( m_auxiliaryToolBar,
  480. ID_ON_ZOOM_SELECT,
  481. wxEmptyString,
  482. wxPoint( -1, -1 ),
  483. wxSize( LISTBOX_WIDTH, -1 ),
  484. 0, NULL, wxCB_READONLY );
  485. m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
  486. updateZoomSelectBox();
  487. updateGridSelectBox();
  488. updateTraceWidthSelectBox();
  489. updateViaSizeSelectBox();
  490. // after adding the buttons to the toolbar, must call Realize()
  491. m_auxiliaryToolBar->Realize();
  492. m_auxiliaryToolBar->AddSeparator();
  493. }
  494. void PCB_EDIT_FRAME::updateTraceWidthSelectBox()
  495. {
  496. if( m_SelTrackWidthBox == NULL )
  497. return;
  498. wxString msg;
  499. m_SelTrackWidthBox->Clear();
  500. for( unsigned ii = 0; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
  501. {
  502. msg = _( "Track " ) + CoordinateToString( GetDesignSettings().m_TrackWidthList[ii], true );
  503. if( ii == 0 )
  504. msg << _( " *" );
  505. m_SelTrackWidthBox->Append( msg );
  506. }
  507. if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
  508. GetDesignSettings().SetTrackWidthIndex( 0 );
  509. m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
  510. }
  511. void PCB_EDIT_FRAME::updateViaSizeSelectBox()
  512. {
  513. if( m_SelViaSizeBox == NULL )
  514. return;
  515. wxString msg;
  516. m_SelViaSizeBox->Clear();
  517. for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
  518. {
  519. msg = _( "Via " );
  520. msg << CoordinateToString( GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter, true );
  521. if( GetDesignSettings().m_ViasDimensionsList[ii].m_Drill )
  522. msg << wxT("/ ")
  523. << CoordinateToString( GetDesignSettings().m_ViasDimensionsList[ii].m_Drill, true );
  524. if( ii == 0 )
  525. msg << _( " *" );
  526. m_SelViaSizeBox->Append( msg );
  527. }
  528. if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
  529. GetDesignSettings().SetViaSizeIndex( 0 );
  530. m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
  531. }
  532. void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
  533. {
  534. if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
  535. return;
  536. m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
  537. m_SelLayerBox->m_hotkeys = g_Board_Editor_Hokeys_Descr;
  538. m_SelLayerBox->Resync();
  539. if( aForceResizeToolbar )
  540. {
  541. // the layer box can have its size changed
  542. // Update the aui manager, to take in account the new size
  543. m_auimgr.Update();
  544. }
  545. }