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.

680 lines
25 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * @file toolbars_gerber.cpp
  23. * @brief Build tool bars
  24. */
  25. #include <fctsys.h>
  26. #include <common.h>
  27. #include <gerbview.h>
  28. #include <gerbview_frame.h>
  29. #include <bitmaps.h>
  30. #include <gerbview_id.h>
  31. #include <hotkeys.h>
  32. #include <gerber_file_image.h>
  33. #include <gerber_file_image_list.h>
  34. #include <gbr_layer_box_selector.h>
  35. #include <DCodeSelectionbox.h>
  36. #include <dialog_helpers.h>
  37. #include <bitmaps.h>
  38. #include <kicad_string.h>
  39. #include <wx/wupdlock.h>
  40. void GERBVIEW_FRAME::ReCreateHToolbar( void )
  41. {
  42. wxString msg;
  43. if( m_mainToolBar )
  44. m_mainToolBar->Clear();
  45. else
  46. m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  47. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  48. // Set up toolbar
  49. m_mainToolBar->AddTool( ID_GERBVIEW_ERASE_ALL, wxEmptyString,
  50. KiScaledBitmap( delete_gerber_xpm, this ),
  51. _( "Clear all layers" ) );
  52. m_mainToolBar->AddTool( ID_GERBVIEW_RELOAD_ALL, wxEmptyString,
  53. KiScaledBitmap( reload2_xpm, this ),
  54. _( "Reload all layers" ) );
  55. m_mainToolBar->AddTool( wxID_FILE, wxEmptyString, KiScaledBitmap( load_gerber_xpm, this ),
  56. _( "Open Gerber file(s) on the current layer. Previous data will be deleted" ) );
  57. m_mainToolBar->AddTool( ID_GERBVIEW_LOAD_DRILL_FILE, wxEmptyString,
  58. KiScaledBitmap( gerbview_drill_file_xpm, this ),
  59. _( "Open Excellon drill file(s) on the current layer. Previous data will be deleted" ) );
  60. KiScaledSeparator( m_mainToolBar, this );
  61. m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiScaledBitmap( print_button_xpm, this ),
  62. _( "Print layers" ) );
  63. KiScaledSeparator( m_mainToolBar, this );
  64. msg = AddHotkeyName( _( "Redraw view" ), GerbviewHotkeysDescr, HK_ZOOM_REDRAW, IS_COMMENT );
  65. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
  66. msg = AddHotkeyName( _( "Zoom in" ), GerbviewHotkeysDescr, HK_ZOOM_IN, IS_COMMENT );
  67. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
  68. msg = AddHotkeyName( _( "Zoom out" ), GerbviewHotkeysDescr, HK_ZOOM_OUT, IS_COMMENT );
  69. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
  70. msg = AddHotkeyName( _( "Zoom to fit" ), GerbviewHotkeysDescr, HK_ZOOM_AUTO, IS_COMMENT );
  71. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
  72. KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
  73. m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
  74. _( "Zoom to selection" ), wxITEM_CHECK );
  75. KiScaledSeparator( m_mainToolBar, this );
  76. m_SelLayerBox = new GBR_LAYER_BOX_SELECTOR( m_mainToolBar,
  77. ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
  78. wxDefaultPosition, wxDefaultSize, 0, NULL );
  79. m_SelLayerBox->Resync();
  80. m_mainToolBar->AddControl( m_SelLayerBox );
  81. m_TextInfo = new wxTextCtrl( m_mainToolBar, wxID_ANY, wxEmptyString, wxDefaultPosition,
  82. wxDefaultSize, wxTE_READONLY );
  83. m_mainToolBar->AddControl( m_TextInfo );
  84. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  85. m_mainToolBar->Realize();
  86. }
  87. void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
  88. {
  89. wxWindowUpdateLocker dummy( this );
  90. wxStaticText* text;
  91. if( !m_auxiliaryToolBar )
  92. m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition,
  93. wxDefaultSize,
  94. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  95. // Creates box to display and choose components:
  96. if( !m_SelComponentBox )
  97. {
  98. m_SelComponentBox = new wxChoice( m_auxiliaryToolBar,
  99. ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
  100. m_SelComponentBox->SetToolTip( _("Highlight items belonging to this component") );
  101. text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Cmp: ") );
  102. m_auxiliaryToolBar->AddControl( text );
  103. m_auxiliaryToolBar->AddControl( m_SelComponentBox );
  104. m_auxiliaryToolBar->AddSpacer( 5 );
  105. }
  106. // Creates choice box to display net names and highlight selected:
  107. if( !m_SelNetnameBox )
  108. {
  109. m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar,
  110. ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE );
  111. m_SelNetnameBox->SetToolTip( _("Highlight items belonging to this net") );
  112. text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Net:" ) );
  113. m_auxiliaryToolBar->AddControl( text );
  114. m_auxiliaryToolBar->AddControl( m_SelNetnameBox );
  115. m_auxiliaryToolBar->AddSpacer( 5 );
  116. }
  117. // Creates choice box to display aperture attributes and highlight selected:
  118. if( !m_SelAperAttributesBox )
  119. {
  120. m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar,
  121. ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
  122. m_SelAperAttributesBox->SetToolTip( _("Highlight items with this aperture attribute") );
  123. text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Attr:" ) );
  124. m_auxiliaryToolBar->AddControl( text );
  125. m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox );
  126. m_auxiliaryToolBar->AddSpacer( 5 );
  127. }
  128. if( !m_DCodeSelector )
  129. {
  130. m_DCodeSelector = new DCODE_SELECTION_BOX( m_auxiliaryToolBar,
  131. ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE,
  132. wxDefaultPosition, wxSize( 150, -1 ) );
  133. text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "DCode:" ) );
  134. m_auxiliaryToolBar->AddControl( text );
  135. m_auxiliaryToolBar->AddControl( m_DCodeSelector );
  136. }
  137. if( !m_gridSelectBox )
  138. {
  139. KiScaledSeparator( m_auxiliaryToolBar, this );
  140. m_gridSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_GRID_SELECT,
  141. wxDefaultPosition, wxDefaultSize, 0, nullptr );
  142. m_auxiliaryToolBar->AddControl( m_gridSelectBox );
  143. }
  144. if( !m_zoomSelectBox )
  145. {
  146. KiScaledSeparator( m_auxiliaryToolBar, this );
  147. m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_ZOOM_SELECT,
  148. wxDefaultPosition, wxDefaultSize, 0, nullptr );
  149. m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
  150. }
  151. updateComponentListSelectBox();
  152. updateNetnameListSelectBox();
  153. updateAperAttributesSelectBox();
  154. updateDCodeSelectBox();
  155. updateGridSelectBox();
  156. updateZoomSelectBox();
  157. // combobox sizes can have changed: apply new best sizes
  158. auto item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
  159. item->SetMinSize( m_SelComponentBox->GetBestSize() );
  160. item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE );
  161. item->SetMinSize( m_SelNetnameBox->GetBestSize() );
  162. item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
  163. item->SetMinSize( m_SelAperAttributesBox->GetBestSize() );
  164. item = m_auxiliaryToolBar->FindTool( ID_ON_GRID_SELECT );
  165. item->SetMinSize( m_gridSelectBox->GetBestSize() );
  166. item = m_auxiliaryToolBar->FindTool( ID_ON_ZOOM_SELECT );
  167. item->SetMinSize( m_zoomSelectBox->GetBestSize() );
  168. // after adding the buttons to the toolbar, must call Realize()
  169. m_auxiliaryToolBar->Realize();
  170. }
  171. void GERBVIEW_FRAME::ReCreateVToolbar( void )
  172. {
  173. if( m_drawToolBar )
  174. return;
  175. m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  176. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  177. // Set up toolbar
  178. m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, _( "Select item" ),
  179. KiScaledBitmap( cursor_xpm, this ) );
  180. KiScaledSeparator( m_mainToolBar, this );
  181. m_drawToolBar->Realize();
  182. }
  183. void GERBVIEW_FRAME::ReCreateOptToolbar( void )
  184. {
  185. if( m_optionsToolBar )
  186. m_optionsToolBar->Clear();
  187. else
  188. m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  189. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  190. // TODO: these can be moved to the 'proper' vertical toolbar if and when there are
  191. // actual tools to put there. That, or I'll get around to implementing configurable
  192. // toolbars.
  193. m_optionsToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString,
  194. KiScaledBitmap( cursor_xpm, this ),
  195. wxEmptyString, wxITEM_CHECK );
  196. if( IsGalCanvasActive() )
  197. {
  198. m_optionsToolBar->AddTool( ID_TB_MEASUREMENT_TOOL, wxEmptyString,
  199. KiScaledBitmap( measurement_xpm, this ),
  200. _( "Measure distance between two points" ),
  201. wxITEM_CHECK );
  202. }
  203. KiScaledSeparator( m_mainToolBar, this );
  204. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
  205. KiScaledBitmap( grid_xpm, this ),
  206. _( "Turn grid off" ), wxITEM_CHECK );
  207. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
  208. KiScaledBitmap( polar_coord_xpm, this ),
  209. _( "Turn polar coordinates on" ), wxITEM_CHECK );
  210. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
  211. KiScaledBitmap( unit_inch_xpm, this ),
  212. _( "Set units to inches" ), wxITEM_CHECK );
  213. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
  214. KiScaledBitmap( unit_mm_xpm, this ),
  215. _( "Set units to millimeters" ), wxITEM_CHECK );
  216. #ifndef __APPLE__
  217. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  218. KiScaledBitmap( cursor_shape_xpm, this ),
  219. _( "Change cursor shape" ), wxITEM_CHECK );
  220. #else
  221. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
  222. KiScaledBitmap( cursor_shape_xpm, this ),
  223. _( "Change cursor shape (not supported in Legacy Toolset)" ),
  224. wxITEM_CHECK );
  225. #endif
  226. KiScaledSeparator( m_mainToolBar, this );
  227. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, wxEmptyString,
  228. KiScaledBitmap( pad_sketch_xpm, this ),
  229. _( "Show flashed items in outline mode" ), wxITEM_CHECK );
  230. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_LINES_SKETCH, wxEmptyString,
  231. KiScaledBitmap( showtrack_xpm, this ),
  232. _( "Show lines in outline mode" ), wxITEM_CHECK );
  233. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, wxEmptyString,
  234. KiScaledBitmap( opt_show_polygon_xpm, this ),
  235. _( "Show polygons in outline mode" ),
  236. wxITEM_CHECK );
  237. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, wxEmptyString,
  238. KiScaledBitmap( gerbview_show_negative_objects_xpm, this ),
  239. _( "Show negatives objects in ghost color" ),
  240. wxITEM_CHECK );
  241. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_DCODES, wxEmptyString,
  242. KiScaledBitmap( show_dcodenumber_xpm, this ),
  243. _( "Show dcode number" ), wxITEM_CHECK );
  244. // tools to select draw mode in GerbView, unused in GAL
  245. if( !IsGalCanvasActive() )
  246. {
  247. KiScaledSeparator( m_mainToolBar, this );
  248. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GBR_MODE_0, wxEmptyString,
  249. KiScaledBitmap( gbr_select_mode0_xpm, this ),
  250. _( "Show layers in raw mode\n"
  251. "(could have problems with negative items when more than one gerber file is shown)" ),
  252. wxITEM_RADIO );
  253. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GBR_MODE_1, wxEmptyString,
  254. KiScaledBitmap( gbr_select_mode1_xpm, this ),
  255. _( "Show layers in stacked mode\n"
  256. "(show negative items without artifacts)" ),
  257. wxITEM_RADIO );
  258. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GBR_MODE_2, wxEmptyString,
  259. KiScaledBitmap( gbr_select_mode2_xpm, this ),
  260. _( "Show layers in transparency mode\n"
  261. "(show negative items without artifacts)" ),
  262. wxITEM_RADIO );
  263. }
  264. else
  265. {
  266. m_optionsToolBar->AddTool( ID_TB_OPTIONS_DIFF_MODE, wxEmptyString,
  267. KiScaledBitmap( gbr_select_mode2_xpm, this ),
  268. _( "Show layers in diff (compare) mode" ),
  269. wxITEM_CHECK );
  270. m_optionsToolBar->AddTool( ID_TB_OPTIONS_HIGH_CONTRAST_MODE, wxEmptyString,
  271. KiScaledBitmap( contrast_mode_xpm, this ),
  272. _( "Enable high contrast display mode" ),
  273. wxITEM_CHECK );
  274. }
  275. // Tools to show/hide toolbars:
  276. KiScaledSeparator( m_mainToolBar, this );
  277. m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
  278. wxEmptyString,
  279. KiScaledBitmap( layers_manager_xpm, this ),
  280. _( "Show/hide the layers manager toolbar" ),
  281. wxITEM_CHECK );
  282. m_optionsToolBar->Realize();
  283. }
  284. #define NO_SELECTION_STRING _("<No selection>")
  285. void GERBVIEW_FRAME::updateDCodeSelectBox()
  286. {
  287. m_DCodeSelector->Clear();
  288. // Add an empty string to deselect net highlight
  289. m_DCodeSelector->Append( NO_SELECTION_STRING );
  290. int layer = GetActiveLayer();
  291. GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
  292. if( !gerber || gerber->GetDcodesCount() == 0 )
  293. {
  294. if( m_DCodeSelector->GetSelection() != 0 )
  295. m_DCodeSelector->SetSelection( 0 );
  296. return;
  297. }
  298. // Build the aperture list of the current layer, and add it to the combo box:
  299. wxArrayString dcode_list;
  300. wxString msg;
  301. const char* units = GetUserUnits() == INCHES ? "mils" : "mm";
  302. double scale = GetUserUnits() == INCHES ? IU_PER_MILS : IU_PER_MM;
  303. for( int ii = 0; ii < TOOLS_MAX_COUNT; ii++ )
  304. {
  305. D_CODE* dcode = gerber->GetDCODE( ii + FIRST_DCODE );
  306. if( dcode == NULL )
  307. continue;
  308. if( !dcode->m_InUse && !dcode->m_Defined )
  309. continue;
  310. msg.Printf( "tool %d [%.3fx%.3f %s] %s",
  311. dcode->m_Num_Dcode,
  312. dcode->m_Size.y / scale, dcode->m_Size.x / scale,
  313. units,
  314. D_CODE::ShowApertureType( dcode->m_Shape )
  315. );
  316. if( !dcode->m_AperFunction.IsEmpty() )
  317. msg << ", " << dcode->m_AperFunction;
  318. dcode_list.Add( msg );
  319. }
  320. m_DCodeSelector->AppendDCodeList( dcode_list );
  321. if( dcode_list.size() > 1 )
  322. {
  323. wxSize size = m_DCodeSelector->GetBestSize();
  324. size.x = std::max( size.x, 100 );
  325. m_DCodeSelector->SetMinSize( size );
  326. m_auimgr.Update();
  327. }
  328. }
  329. void GERBVIEW_FRAME::updateComponentListSelectBox()
  330. {
  331. m_SelComponentBox->Clear();
  332. // Build the full list of component names from the partial lists stored in each file image
  333. std::map<wxString, int> full_list;
  334. for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
  335. {
  336. GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
  337. if( gerber == NULL ) // Graphic layer not yet used
  338. continue;
  339. full_list.insert( gerber->m_ComponentsList.begin(), gerber->m_ComponentsList.end() );
  340. }
  341. // Add an empty string to deselect net highlight
  342. m_SelComponentBox->Append( NO_SELECTION_STRING );
  343. // Now copy the list to the choice box
  344. for( auto ii = full_list.begin(); ii != full_list.end(); ++ii )
  345. {
  346. m_SelComponentBox->Append( ii->first );
  347. }
  348. m_SelComponentBox->SetSelection( 0 );
  349. }
  350. void GERBVIEW_FRAME::updateNetnameListSelectBox()
  351. {
  352. m_SelNetnameBox->Clear();
  353. // Build the full list of netnames from the partial lists stored in each file image
  354. std::map<wxString, int> full_list;
  355. for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
  356. {
  357. GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
  358. if( gerber == NULL ) // Graphic layer not yet used
  359. continue;
  360. full_list.insert( gerber->m_NetnamesList.begin(), gerber->m_NetnamesList.end() );
  361. }
  362. // Add an empty string to deselect net highlight
  363. m_SelNetnameBox->Append( NO_SELECTION_STRING );
  364. // Now copy the list to the choice box
  365. for( auto ii = full_list.begin(); ii != full_list.end(); ++ii )
  366. {
  367. m_SelNetnameBox->Append( UnescapeString( ii->first ) );
  368. }
  369. m_SelNetnameBox->SetSelection( 0 );
  370. }
  371. void GERBVIEW_FRAME::updateAperAttributesSelectBox()
  372. {
  373. m_SelAperAttributesBox->Clear();
  374. // Build the full list of netnames from the partial lists stored in each file image
  375. std::map<wxString, int> full_list;
  376. for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
  377. {
  378. GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
  379. if( gerber == NULL ) // Graphic layer not yet used
  380. continue;
  381. if( gerber->GetDcodesCount() == 0 )
  382. continue;
  383. for( int ii = 0; ii < TOOLS_MAX_COUNT; ii++ )
  384. {
  385. D_CODE* aperture = gerber->GetDCODE( ii + FIRST_DCODE );
  386. if( aperture == NULL )
  387. continue;
  388. if( !aperture->m_InUse && !aperture->m_Defined )
  389. continue;
  390. if( !aperture->m_AperFunction.IsEmpty() )
  391. full_list.insert( std::make_pair( aperture->m_AperFunction, 0 ) );
  392. }
  393. }
  394. // Add an empty string to deselect net highlight
  395. m_SelAperAttributesBox->Append( NO_SELECTION_STRING );
  396. // Now copy the list to the choice box
  397. for( auto ii = full_list.begin(); ii != full_list.end(); ++ii )
  398. {
  399. m_SelAperAttributesBox->Append( ii->first );
  400. }
  401. m_SelAperAttributesBox->SetSelection( 0 );
  402. }
  403. void GERBVIEW_FRAME::OnUpdateDrawMode( wxUpdateUIEvent& aEvent )
  404. {
  405. switch( aEvent.GetId() )
  406. {
  407. case ID_TB_OPTIONS_SHOW_GBR_MODE_0:
  408. aEvent.Check( GetDisplayMode() == 0 );
  409. break;
  410. case ID_TB_OPTIONS_SHOW_GBR_MODE_1:
  411. aEvent.Check( GetDisplayMode() == 1 );
  412. break;
  413. case ID_TB_OPTIONS_SHOW_GBR_MODE_2:
  414. aEvent.Check( GetDisplayMode() == 2 );
  415. break;
  416. default:
  417. break;
  418. }
  419. }
  420. void GERBVIEW_FRAME::OnToggleCoordType( wxCommandEvent& aEvent )
  421. {
  422. m_DisplayOptions.m_DisplayPolarCood = !m_DisplayOptions.m_DisplayPolarCood;
  423. UpdateStatusBar();
  424. }
  425. void GERBVIEW_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
  426. {
  427. aEvent.Check( m_DisplayOptions.m_DisplayPolarCood );
  428. if( m_optionsToolBar )
  429. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
  430. m_DisplayOptions.m_DisplayPolarCood ?
  431. _( "Turn on rectangular coordinates" ) :
  432. _( "Turn on polar coordinates" ) );
  433. }
  434. void GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent )
  435. {
  436. aEvent.Check( !m_DisplayOptions.m_DisplayFlashedItemsFill );
  437. if( m_optionsToolBar )
  438. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
  439. m_DisplayOptions.m_DisplayFlashedItemsFill ?
  440. _( "Show flashed items in outline mode" ) :
  441. _( "Show flashed items in fill mode" ) );
  442. }
  443. void GERBVIEW_FRAME::OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent )
  444. {
  445. aEvent.Check( !m_DisplayOptions.m_DisplayLinesFill );
  446. if( m_optionsToolBar )
  447. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_LINES_SKETCH,
  448. m_DisplayOptions.m_DisplayFlashedItemsFill ?
  449. _( "Show lines in outline mode" ) :
  450. _( "Show lines in fill mode" ) );
  451. }
  452. void GERBVIEW_FRAME::OnUpdatePolygonDrawMode( wxUpdateUIEvent& aEvent )
  453. {
  454. aEvent.Check( !m_DisplayOptions.m_DisplayPolygonsFill );
  455. if( m_optionsToolBar )
  456. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
  457. m_DisplayOptions.m_DisplayFlashedItemsFill ?
  458. _( "Show polygons in outline mode" ) :
  459. _( "Show polygons in fill mode" ) );
  460. }
  461. void GERBVIEW_FRAME::OnUpdateShowDCodes( wxUpdateUIEvent& aEvent )
  462. {
  463. aEvent.Check( IsElementVisible( LAYER_DCODES ) );
  464. if( m_optionsToolBar )
  465. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_DCODES,
  466. IsElementVisible( LAYER_DCODES ) ?
  467. _( "Hide DCodes" ) : _( "Show DCodes" ) );
  468. }
  469. void GERBVIEW_FRAME::OnUpdateShowNegativeItems( wxUpdateUIEvent& aEvent )
  470. {
  471. aEvent.Check( IsElementVisible( LAYER_NEGATIVE_OBJECTS ) );
  472. if( m_optionsToolBar )
  473. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS,
  474. IsElementVisible( LAYER_NEGATIVE_OBJECTS ) ?
  475. _( "Show negative objects in normal color" ) :
  476. _( "Show negative objects in ghost color" ) );
  477. }
  478. void GERBVIEW_FRAME::OnUpdateDiffMode( wxUpdateUIEvent& aEvent )
  479. {
  480. aEvent.Check( m_DisplayOptions.m_DiffMode );
  481. if( m_optionsToolBar )
  482. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DIFF_MODE,
  483. m_DisplayOptions.m_DiffMode ?
  484. _( "Show layers in normal mode" ) :
  485. _( "Show layers in differential mode" ) );
  486. }
  487. void GERBVIEW_FRAME::OnUpdateHighContrastMode( wxUpdateUIEvent& aEvent )
  488. {
  489. aEvent.Check( m_DisplayOptions.m_HighContrastMode );
  490. if( m_optionsToolBar )
  491. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIGH_CONTRAST_MODE,
  492. m_DisplayOptions.m_HighContrastMode ?
  493. _( "Disable high contrast mode" ) :
  494. _( "Enable high contrast mode" ) );
  495. }
  496. void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
  497. {
  498. aEvent.Check( m_show_layer_manager_tools );
  499. if( m_optionsToolBar )
  500. {
  501. if( m_show_layer_manager_tools )
  502. m_optionsToolBar->SetToolShortHelp( aEvent.GetId(), _( "Hide layers manager" ) );
  503. else
  504. m_optionsToolBar->SetToolShortHelp( aEvent.GetId(), _( "Show layers manager" ) );
  505. }
  506. }
  507. void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
  508. {
  509. if( !m_DCodeSelector )
  510. return;
  511. int layer = GetActiveLayer();
  512. GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
  513. int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;
  514. aEvent.Enable( gerber != NULL );
  515. if( m_DCodeSelector->GetSelectedDCodeId() != selected )
  516. {
  517. m_DCodeSelector->SetDCodeSelection( selected );
  518. // Be sure the selection can be made. If no, set to
  519. // a correct value
  520. if( gerber )
  521. gerber->m_Selected_Tool = m_DCodeSelector->GetSelectedDCodeId();
  522. }
  523. }
  524. void GERBVIEW_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
  525. {
  526. if( m_SelLayerBox->GetSelection() != GetActiveLayer() )
  527. {
  528. m_SelLayerBox->SetSelection( GetActiveLayer() );
  529. }
  530. }