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.

1009 lines
40 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
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
  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 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2007-2013 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2013 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 pcbnew/onrightclick.cpp
  28. * @brief Right mouse button functions.
  29. */
  30. #include <fctsys.h>
  31. #include <class_drawpanel.h>
  32. #include <macros.h>
  33. #include <base_units.h>
  34. #include <class_board.h>
  35. #include <class_module.h>
  36. #include <class_track.h>
  37. #include <class_pcb_text.h>
  38. #include <class_zone.h>
  39. #include <pcbnew.h>
  40. #include <wxPcbStruct.h>
  41. #include <pcbnew_id.h>
  42. #include <hotkeys.h>
  43. #include <collectors.h>
  44. #include <menus_helpers.h>
  45. static wxMenu* Append_Track_Width_List( BOARD* aBoard );
  46. bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
  47. {
  48. wxString msg;
  49. STATUS_FLAGS flags = 0;
  50. bool trackFound = false; // Flag set to true,
  51. // if a track is being the cursor, to avoid
  52. // to display menus relative to tracks twice
  53. bool blockActive = !GetScreen()->m_BlockLocate.IsIdle();
  54. wxClientDC dc( m_canvas );
  55. BOARD_ITEM* item = GetCurItem();
  56. m_canvas->SetCanStartBlock( -1 ); // Avoid to start a block command when clicking on menu
  57. // If a command or a block is in progress:
  58. // Put the Cancel command (if needed) and the End command
  59. if( blockActive )
  60. {
  61. createPopUpBlockMenu( aPopMenu );
  62. aPopMenu->AppendSeparator();
  63. return true;
  64. }
  65. m_canvas->CrossHairOff( &dc );
  66. if( GetToolId() != ID_NO_TOOL_SELECTED )
  67. {
  68. if( item && item->GetFlags() )
  69. {
  70. AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ),
  71. KiBitmap( cancel_xpm ) );
  72. }
  73. else
  74. {
  75. AddMenuItem( aPopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
  76. _( "End Tool" ), KiBitmap( cursor_xpm ) );
  77. }
  78. aPopMenu->AppendSeparator();
  79. }
  80. else
  81. {
  82. if( item && item->GetFlags() )
  83. {
  84. AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
  85. _( "Cancel" ), KiBitmap( cancel_xpm ) );
  86. aPopMenu->AppendSeparator();
  87. }
  88. }
  89. // Select a proper item
  90. wxPoint cursorPos = GetCrossHairPosition();
  91. wxPoint selectPos = m_Collector->GetRefPos();
  92. selectPos = GetNearestGridPosition( selectPos );
  93. /* We can reselect another item only if there are no item being edited
  94. * because ALL moving functions use GetCurItem(), therefore GetCurItem()
  95. * must return the same item during moving. We know an item is moving
  96. * if( item && (item->m_Flags != 0)) is true and after calling
  97. * PcbGeneralLocateAndDisplay(), GetCurItem() is any arbitrary BOARD_ITEM,
  98. * not the current item being edited. In such case we cannot call
  99. * PcbGeneralLocateAndDisplay().
  100. */
  101. if( !item || (item->GetFlags() == 0) )
  102. {
  103. // show the "item selector" menu if no item selected or
  104. // if there is a selected item but the mouse has moved
  105. // (therefore a new item is perhaps under the cursor)
  106. if( !item || cursorPos != selectPos )
  107. {
  108. m_canvas->SetAbortRequest( false );
  109. item = PcbGeneralLocateAndDisplay();
  110. if( m_canvas->GetAbortRequest() )
  111. {
  112. m_canvas->CrossHairOn( &dc );
  113. return false;
  114. }
  115. }
  116. }
  117. item = GetCurItem();
  118. if( item )
  119. flags = item->GetFlags();
  120. else
  121. flags = 0;
  122. // Add the context menu, which depends on the picked item:
  123. if( item )
  124. {
  125. switch( item->Type() )
  126. {
  127. case PCB_MODULE_T:
  128. createPopUpMenuForFootprints( (MODULE*) item, aPopMenu );
  129. if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_MODULE ) )
  130. {
  131. aPopMenu->AppendSeparator();
  132. if( !( (MODULE*) item )->IsLocked() )
  133. {
  134. msg = AddHotkeyName( _("Lock Module" ), g_Board_Editor_Hokeys_Descr,
  135. HK_LOCK_UNLOCK_FOOTPRINT );
  136. AddMenuItem( aPopMenu, ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, msg,
  137. KiBitmap( locked_xpm ) );
  138. }
  139. else
  140. {
  141. msg = AddHotkeyName( _( "Unlock Module" ), g_Board_Editor_Hokeys_Descr,
  142. HK_LOCK_UNLOCK_FOOTPRINT );
  143. AddMenuItem( aPopMenu, ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, msg,
  144. KiBitmap( unlocked_xpm ) );
  145. }
  146. if( !flags )
  147. aPopMenu->Append( ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE,
  148. _( "Automatically Place Module" ) );
  149. }
  150. if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_TRACKS ) )
  151. {
  152. if( !flags )
  153. aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE,
  154. _( "Automatically Route Module" ) );
  155. }
  156. break;
  157. case PCB_PAD_T:
  158. createPopUpMenuForFpPads( (D_PAD*) item, aPopMenu );
  159. break;
  160. case PCB_MODULE_TEXT_T:
  161. createPopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu );
  162. break;
  163. case PCB_LINE_T: // Some graphic items on technical layers
  164. if( (flags & IS_NEW) )
  165. {
  166. AddMenuItem( aPopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING,
  167. _( "End Drawing" ), KiBitmap( checked_ok_xpm ) );
  168. }
  169. if( !flags )
  170. {
  171. msg = AddHotkeyName( _( "Move Drawing" ), g_Board_Editor_Hokeys_Descr,
  172. HK_MOVE_ITEM );
  173. AddMenuItem( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
  174. msg, KiBitmap( move_xpm ) );
  175. AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ),
  176. KiBitmap( edit_xpm ) );
  177. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING,
  178. _( "Delete Drawing" ), KiBitmap( delete_xpm ) );
  179. if( !IsCopperLayer( item->GetLayer() ) )
  180. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING_LAYER,
  181. _( "Delete All Drawings on Layer" ), KiBitmap( delete_xpm ) );
  182. }
  183. break;
  184. case PCB_ZONE_T: // Item used to fill a zone
  185. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_ZONE,
  186. _( "Delete Zone Filling" ), KiBitmap( delete_xpm ) );
  187. break;
  188. case PCB_ZONE_AREA_T: // Item used to handle a zone area (outlines, holes ...)
  189. if( flags & IS_NEW )
  190. {
  191. AddMenuItem( aPopMenu, ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE,
  192. _( "Close Zone Outline" ), KiBitmap( checked_ok_xpm ) );
  193. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER,
  194. _( "Delete Last Corner" ), KiBitmap( delete_xpm ) );
  195. }
  196. else
  197. {
  198. createPopUpMenuForZones( (ZONE_CONTAINER*) item, aPopMenu );
  199. }
  200. break;
  201. case PCB_TEXT_T:
  202. createPopUpMenuForTexts( (TEXTE_PCB*) item, aPopMenu );
  203. break;
  204. case PCB_TRACE_T:
  205. case PCB_VIA_T:
  206. trackFound = true;
  207. createPopupMenuForTracks( (TRACK*) item, aPopMenu );
  208. break;
  209. case PCB_MARKER_T:
  210. createPopUpMenuForMarkers( (MARKER_PCB*) item, aPopMenu );
  211. break;
  212. case PCB_DIMENSION_T:
  213. if( !flags )
  214. {
  215. msg = AddHotkeyName( _( "Edit Dimension" ), g_Board_Editor_Hokeys_Descr,
  216. HK_EDIT_ITEM );
  217. AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_DIMENSION, msg, KiBitmap( edit_xpm ) );
  218. msg = AddHotkeyName( _( "Move Dimension Text" ), g_Board_Editor_Hokeys_Descr,
  219. HK_MOVE_ITEM );
  220. AddMenuItem( aPopMenu, ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST,
  221. msg, KiBitmap( move_text_xpm ) );
  222. msg = AddHotkeyName( _( "Delete Dimension" ), g_Board_Editor_Hokeys_Descr,
  223. HK_DELETE );
  224. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_DIMENSION,
  225. msg, KiBitmap( delete_xpm ) );
  226. }
  227. break;
  228. case PCB_TARGET_T:
  229. if( !flags )
  230. {
  231. msg = AddHotkeyName( _( "Move Target" ), g_Board_Editor_Hokeys_Descr,
  232. HK_MOVE_ITEM );
  233. AddMenuItem( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, msg, KiBitmap( move_xpm ) );
  234. msg = AddHotkeyName( _( "Edit Target" ), g_Board_Editor_Hokeys_Descr,
  235. HK_EDIT_ITEM );
  236. AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_MIRE, msg, KiBitmap( edit_xpm ) );
  237. msg = AddHotkeyName( _( "Delete Target" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
  238. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_MIRE,
  239. msg, KiBitmap( delete_xpm ) );
  240. }
  241. break;
  242. case PCB_MODULE_EDGE_T:
  243. case SCREEN_T:
  244. case TYPE_NOT_INIT:
  245. case PCB_T:
  246. msg.Printf( wxT( "PCB_EDIT_FRAME::OnRightClick() Error: unexpected DrawType %d" ),
  247. item->Type() );
  248. wxMessageBox( msg );
  249. SetCurItem( NULL );
  250. break;
  251. default:
  252. msg.Printf( wxT( "PCB_EDIT_FRAME::OnRightClick() Error: unknown DrawType %d" ),
  253. item->Type() );
  254. wxMessageBox( msg );
  255. // Attempt to clear error (but should no occurs )
  256. if( item->Type() >= MAX_STRUCT_TYPE_ID )
  257. SetCurItem( NULL );
  258. break;
  259. }
  260. aPopMenu->AppendSeparator();
  261. }
  262. if( !flags )
  263. {
  264. msg = AddHotkeyName( _( "Get and Move Footprint" ),
  265. g_Board_Editor_Hokeys_Descr, HK_GET_AND_MOVE_FOOTPRINT );
  266. AddMenuItem( aPopMenu, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST,
  267. msg, KiBitmap( move_module_xpm ) );
  268. }
  269. // Display context sensitive commands:
  270. switch( GetToolId() )
  271. {
  272. case ID_PCB_ZONES_BUTT:
  273. if( GetBoard()->m_ZoneDescriptorList.size() > 0 )
  274. {
  275. aPopMenu->AppendSeparator();
  276. AddMenuItem( aPopMenu, ID_POPUP_PCB_FILL_ALL_ZONES,
  277. _( "Fill or Refill All Zones" ), KiBitmap( fill_zone_xpm ) );
  278. AddMenuItem( aPopMenu, ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES,
  279. _( "Remove Filled Areas in All Zones" ), KiBitmap( zone_unfill_xpm ) );
  280. aPopMenu->AppendSeparator();
  281. }
  282. AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_LAYER,
  283. _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
  284. aPopMenu->AppendSeparator();
  285. break;
  286. case ID_PCB_KEEPOUT_AREA_BUTT:
  287. AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_LAYER,
  288. _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
  289. aPopMenu->AppendSeparator();
  290. break;
  291. case ID_TRACK_BUTT:
  292. if ( ! trackFound ) // This menu is already added when a track is located
  293. {
  294. aPopMenu->AppendSeparator();
  295. msg = AddHotkeyName( _( "Begin Track" ),
  296. g_Board_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK );
  297. AddMenuItem( aPopMenu, ID_POPUP_PCB_BEGIN_TRACK,
  298. msg, KiBitmap( add_tracks_xpm ) );
  299. AddMenuItem( aPopMenu, Append_Track_Width_List( GetBoard() ),
  300. ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ),
  301. KiBitmap( width_track_xpm ) );
  302. AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_CU_LAYER,
  303. _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
  304. AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_LAYER_PAIR,
  305. _( "Select Layer Pair for Vias" ), KiBitmap( select_layer_pair_xpm ) );
  306. aPopMenu->AppendSeparator();
  307. }
  308. break;
  309. case ID_PCB_CIRCLE_BUTT:
  310. case ID_PCB_ARC_BUTT:
  311. case ID_PCB_ADD_TEXT_BUTT:
  312. case ID_PCB_ADD_LINE_BUTT:
  313. case ID_PCB_DIMENSION_BUTT:
  314. AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_NO_CU_LAYER,
  315. _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
  316. aPopMenu->AppendSeparator();
  317. break;
  318. case ID_PCB_MODULE_BUTT:
  319. if( !flags )
  320. {
  321. AddMenuItem( aPopMenu, ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC,
  322. _( "Footprint Documentation" ), KiBitmap( book_xpm ) );
  323. aPopMenu->AppendSeparator();
  324. }
  325. break;
  326. case ID_NO_TOOL_SELECTED:
  327. if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_MODULE ) )
  328. {
  329. wxMenu* commands = new wxMenu;
  330. AddMenuItem( aPopMenu, commands, ID_POPUP_PCB_AUTOPLACE_COMMANDS,
  331. _( "Global Spread and Place" ), KiBitmap( move_xpm ) );
  332. AddMenuItem( commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES,
  333. _( "Unlock All Footprints" ), KiBitmap( unlocked_xpm ) );
  334. AddMenuItem( commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES,
  335. _( "Lock All Footprints" ), KiBitmap( locked_xpm ) );
  336. commands->AppendSeparator();
  337. AddMenuItem( commands, ID_POPUP_PCB_SPREAD_ALL_MODULES,
  338. _( "Spread out All Footprints" ), KiBitmap( move_xpm ) );
  339. commands->Append( ID_POPUP_PCB_SPREAD_NEW_MODULES,
  340. _( "Spread out Footprints not Already on Board" ) );
  341. commands->AppendSeparator();
  342. commands->Append( ID_POPUP_PCB_AUTOPLACE_ALL_MODULES,
  343. _( "Automatically Place All Footprints" ) );
  344. commands->Append( ID_POPUP_PCB_AUTOPLACE_NEW_MODULES,
  345. _( "Automatically Place New Footprints" ) );
  346. commands->Append( ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE,
  347. _( "Automatically Place Next Footprints" ) );
  348. commands->AppendSeparator();
  349. AddMenuItem( commands, ID_POPUP_PCB_REORIENT_ALL_MODULES,
  350. _( "Orient All Footprints" ), KiBitmap( rotate_module_pos_xpm ) );
  351. aPopMenu->AppendSeparator();
  352. }
  353. if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_TRACKS ) )
  354. {
  355. wxMenu* commands = new wxMenu;
  356. aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_COMMANDS, _( "Autoroute" ), commands );
  357. AddMenuItem( commands, ID_POPUP_PCB_SELECT_LAYER_PAIR,
  358. _( "Select Layer Pair" ), KiBitmap( select_layer_pair_xpm ) );
  359. commands->AppendSeparator();
  360. commands->Append( ID_POPUP_PCB_AUTOROUTE_ALL_MODULES,
  361. _( "Automatically Route All Modules" ) );
  362. commands->AppendSeparator();
  363. commands->Append( ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED, _( "Reset Unrouted" ) );
  364. aPopMenu->AppendSeparator();
  365. }
  366. if( !trackFound )
  367. {
  368. msg = AddHotkeyName( _( "Begin Track" ), g_Board_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK );
  369. AddMenuItem( aPopMenu, ID_POPUP_PCB_BEGIN_TRACK, msg, KiBitmap( add_tracks_xpm ) );
  370. AddMenuItem( aPopMenu, Append_Track_Width_List( GetBoard() ),
  371. ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ),
  372. KiBitmap( width_track_xpm ) );
  373. AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_LAYER,
  374. _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
  375. aPopMenu->AppendSeparator();
  376. }
  377. break;
  378. }
  379. m_canvas->CrossHairOn( &dc );
  380. return true;
  381. }
  382. /* Create Pop sub menu for block commands
  383. */
  384. void PCB_EDIT_FRAME::createPopUpBlockMenu( wxMenu* menu )
  385. {
  386. AddMenuItem( menu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ),
  387. KiBitmap( cancel_xpm ) );
  388. AddMenuItem( menu, ID_POPUP_ZOOM_BLOCK, _( "Zoom Block" ), KiBitmap( zoom_area_xpm ) );
  389. menu->AppendSeparator();
  390. AddMenuItem( menu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), KiBitmap( checked_ok_xpm ) );
  391. AddMenuItem( menu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), KiBitmap( copyblock_xpm ) );
  392. AddMenuItem( menu, ID_POPUP_FLIP_BLOCK, _( "Flip Block" ), KiBitmap( invert_module_xpm ) );
  393. AddMenuItem( menu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block" ), KiBitmap( rotate_ccw_xpm ) );
  394. AddMenuItem( menu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), KiBitmap( delete_xpm ) );
  395. }
  396. /* Create command lines for a popup menu, for track and via editing
  397. * also update Netclass selection
  398. */
  399. void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
  400. {
  401. wxPoint cursorPosition = GetCrossHairPosition();
  402. wxString msg;
  403. GetBoard()->SetCurrentNetClass( Track->GetNetClassName() );
  404. updateTraceWidthSelectBox();
  405. updateViaSizeSelectBox();
  406. int flags = Track->GetFlags();
  407. if( flags == 0 )
  408. {
  409. msg = AddHotkeyName( _( "Begin Track" ),
  410. g_Board_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK );
  411. AddMenuItem( PopMenu, ID_POPUP_PCB_BEGIN_TRACK,
  412. msg, KiBitmap( add_tracks_xpm ) );
  413. if( Track->Type() == PCB_VIA_T )
  414. {
  415. msg = AddHotkeyName( _( "Drag Via" ), g_Board_Editor_Hokeys_Descr,
  416. HK_DRAG_ITEM );
  417. AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, msg,
  418. KiBitmap( move_xpm ) );
  419. }
  420. else
  421. {
  422. if( Track->IsPointOnEnds( cursorPosition, -1 ) != 0 )
  423. {
  424. msg = AddHotkeyName( _( "Move Node" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
  425. AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE,
  426. msg, KiBitmap( move_xpm ) );
  427. }
  428. else
  429. {
  430. msg = AddHotkeyName( _( "Drag Segments, Keep Slope" ), g_Board_Editor_Hokeys_Descr,
  431. HK_DRAG_TRACK_KEEP_SLOPE );
  432. AddMenuItem( PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE,
  433. msg, KiBitmap( drag_segment_withslope_xpm ) );
  434. msg = AddHotkeyName( _( "Drag Segment" ), g_Board_Editor_Hokeys_Descr,
  435. HK_DRAG_ITEM );
  436. AddMenuItem( PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT,
  437. msg, KiBitmap( drag_track_segment_xpm ) );
  438. AddMenuItem( PopMenu, ID_POPUP_PCB_BREAK_TRACK,
  439. _( "Break Track" ), KiBitmap( break_line_xpm ) );
  440. }
  441. }
  442. AddMenuItem( PopMenu, ID_POPUP_PCB_SELECT_CU_LAYER,
  443. _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
  444. }
  445. else if( flags & IS_DRAGGED ) // Drag via or node in progress
  446. {
  447. AddMenuItem( PopMenu, ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE,
  448. _( "Place Node" ), KiBitmap( checked_ok_xpm ) );
  449. return;
  450. }
  451. else // Edition in progress
  452. {
  453. if( flags & IS_NEW )
  454. {
  455. msg = AddHotkeyName( _( "End Track" ), g_Board_Editor_Hokeys_Descr, HK_END_TRACK );
  456. AddMenuItem( PopMenu, ID_POPUP_PCB_END_TRACK, msg, KiBitmap( checked_ok_xpm ) );
  457. }
  458. msg = AddHotkeyName( _( "Place Through Via" ), g_Board_Editor_Hokeys_Descr, HK_ADD_THROUGH_VIA );
  459. AddMenuItem( PopMenu, ID_POPUP_PCB_PLACE_THROUGH_VIA, msg, KiBitmap( via_xpm ) );
  460. msg = AddHotkeyName( _( "Select Layer and Place Through Via" ),
  461. g_Board_Editor_Hokeys_Descr, HK_SEL_LAYER_AND_ADD_THROUGH_VIA );
  462. AddMenuItem( PopMenu, ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA,
  463. msg, KiBitmap( select_w_layer_xpm ) );
  464. if( GetBoard()->GetDesignSettings().m_BlindBuriedViaAllowed )
  465. {
  466. msg = AddHotkeyName( _( "Place Blind/Buried Via" ),
  467. g_Board_Editor_Hokeys_Descr, HK_ADD_BLIND_BURIED_VIA );
  468. AddMenuItem( PopMenu, ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA, msg, KiBitmap( via_xpm ) );
  469. msg = AddHotkeyName( _( "Select Layer and Place Blind/Buried Via" ),
  470. g_Board_Editor_Hokeys_Descr, HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA );
  471. AddMenuItem( PopMenu, ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA,
  472. msg, KiBitmap( select_w_layer_xpm ) );
  473. }
  474. msg = AddHotkeyName( _( "Switch Track Posture" ), g_Board_Editor_Hokeys_Descr,
  475. HK_SWITCH_TRACK_POSTURE );
  476. AddMenuItem( PopMenu, ID_POPUP_PCB_SWITCH_TRACK_POSTURE, msg,
  477. KiBitmap( change_entry_orient_xpm ) );
  478. // See if we can place a Micro Via (4 or more layers, and start from an external layer):
  479. if( IsMicroViaAcceptable() )
  480. {
  481. msg = AddHotkeyName( _( "Place Micro Via" ), g_Board_Editor_Hokeys_Descr,
  482. HK_ADD_MICROVIA );
  483. PopMenu->Append( ID_POPUP_PCB_PLACE_MICROVIA, msg );
  484. }
  485. }
  486. // track Width control :
  487. if( !flags )
  488. {
  489. if( Track->Type() == PCB_VIA_T )
  490. {
  491. msg = AddHotkeyName( _( "Change Via Size and Drill" ), g_Board_Editor_Hokeys_Descr,
  492. HK_EDIT_ITEM );
  493. AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_TRACKSEG, msg, KiBitmap( width_segment_xpm ) );
  494. }
  495. else
  496. {
  497. msg = AddHotkeyName( _( "Change Segment Width" ), g_Board_Editor_Hokeys_Descr,
  498. HK_EDIT_ITEM );
  499. AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_TRACKSEG, msg, KiBitmap( width_segment_xpm ) );
  500. AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_TRACK,
  501. _( "Change Track Width" ), KiBitmap( width_track_xpm ) );
  502. }
  503. }
  504. // Allows switching to an other track/via size when routing
  505. AddMenuItem( PopMenu, Append_Track_Width_List( GetBoard() ), ID_POPUP_PCB_SELECT_WIDTH,
  506. _( "Select Track Width" ), KiBitmap( width_track_xpm ) );
  507. // Delete control:
  508. PopMenu->AppendSeparator();
  509. wxMenu* trackdel_mnu = new wxMenu;
  510. AddMenuItem( PopMenu, trackdel_mnu, ID_POPUP_PCB_DELETE_TRACK_MNU, _( "Delete" ),
  511. KiBitmap( delete_xpm ) );
  512. msg = AddHotkeyName( Track->Type()==PCB_VIA_T ?
  513. _( "Delete Via" ) : _( "Delete Segment" ),
  514. g_Board_Editor_Hokeys_Descr, HK_BACK_SPACE );
  515. AddMenuItem( trackdel_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, msg, KiBitmap( delete_line_xpm ) );
  516. if( !flags )
  517. {
  518. msg = AddHotkeyName( _( "Delete Track" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
  519. AddMenuItem( trackdel_mnu, ID_POPUP_PCB_DELETE_TRACK, msg, KiBitmap( delete_track_xpm ) );
  520. AddMenuItem( trackdel_mnu, ID_POPUP_PCB_DELETE_TRACKNET, _( "Delete Net" ),
  521. KiBitmap( delete_net_xpm ) );
  522. }
  523. // Add global edition command
  524. if( !flags )
  525. {
  526. PopMenu->AppendSeparator();
  527. AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE,
  528. _( "Edit All Tracks and Vias" ), KiBitmap( width_track_via_xpm ) );
  529. }
  530. // Add lock/unlock flags menu:
  531. wxMenu* trackflg_mnu = new wxMenu;
  532. AddMenuItem( PopMenu, trackflg_mnu, ID_POPUP_PCB_SETFLAGS_TRACK_MNU, _( "Set Flags" ),
  533. KiBitmap( flag_xpm ) );
  534. trackflg_mnu->Append( ID_POPUP_PCB_LOCK_ON_TRACKSEG, _( "Locked: Yes" ), wxEmptyString, true );
  535. trackflg_mnu->Append( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, _( "Locked: No" ), wxEmptyString, true );
  536. if( Track->GetState( TRACK_LOCKED ) )
  537. trackflg_mnu->Check( ID_POPUP_PCB_LOCK_ON_TRACKSEG, true );
  538. else
  539. trackflg_mnu->Check( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, true );
  540. if( !flags )
  541. {
  542. trackflg_mnu->Append( ID_POPUP_PCB_LOCK_ON_TRACK, _( "Track Locked: Yes" ) );
  543. trackflg_mnu->Append( ID_POPUP_PCB_LOCK_OFF_TRACK, _( "Track Locked: No" ) );
  544. trackflg_mnu->AppendSeparator();
  545. trackflg_mnu->Append( ID_POPUP_PCB_LOCK_ON_NET, _( "Net Locked: Yes" ) );
  546. trackflg_mnu->Append( ID_POPUP_PCB_LOCK_OFF_NET, _( "Net Locked: No" ) );
  547. }
  548. }
  549. /* Create the wxMenuitem list for zone outlines editing and zone filling
  550. */
  551. void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu )
  552. {
  553. wxString msg;
  554. if( edge_zone->GetFlags() == IS_DRAGGED )
  555. {
  556. AddMenuItem( aPopMenu, ID_POPUP_PCB_PLACE_DRAGGED_ZONE_OUTLINE_SEGMENT,
  557. _( "Place Edge Outline" ), KiBitmap( checked_ok_xpm ) );
  558. }
  559. else if( edge_zone->GetFlags() )
  560. {
  561. if( (edge_zone->GetFlags() & IN_EDIT ) )
  562. AddMenuItem( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_CORNER,
  563. _( "Place Corner" ), KiBitmap( checked_ok_xpm ) );
  564. else
  565. AddMenuItem( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_OUTLINES,
  566. _( "Place Zone" ), KiBitmap( checked_ok_xpm ) );
  567. }
  568. else
  569. {
  570. wxMenu* zones_menu = new wxMenu();
  571. AddMenuItem( aPopMenu, zones_menu, -1,
  572. edge_zone->GetIsKeepout() ? _("Keepout Area") : _( "Zones" ),
  573. KiBitmap( add_zone_xpm ) );
  574. if( edge_zone->HitTestForCorner( RefPos( true ) ) )
  575. {
  576. AddMenuItem( zones_menu, ID_POPUP_PCB_MOVE_ZONE_CORNER,
  577. _( "Move Corner" ), KiBitmap( move_xpm ) );
  578. AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CORNER,
  579. _( "Delete Corner" ), KiBitmap( delete_xpm ) );
  580. }
  581. else if( edge_zone->HitTestForEdge( RefPos( true ) ) )
  582. {
  583. AddMenuItem( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER,
  584. _( "Create Corner" ), KiBitmap( add_corner_xpm ) );
  585. msg = AddHotkeyName( _( "Drag Outline Segment" ), g_Board_Editor_Hokeys_Descr,
  586. HK_DRAG_ITEM );
  587. AddMenuItem( zones_menu, ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT,
  588. msg, KiBitmap( drag_outline_segment_xpm ) );
  589. }
  590. zones_menu->AppendSeparator();
  591. AddMenuItem( zones_menu, ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
  592. _( "Add Similar Zone" ), KiBitmap( add_zone_xpm ) );
  593. AddMenuItem( zones_menu, ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
  594. _( "Add Cutout Area" ), KiBitmap( add_zone_cutout_xpm ) );
  595. AddMenuItem( zones_menu, ID_POPUP_PCB_ZONE_DUPLICATE,
  596. _( "Duplicate Zone" ), KiBitmap( zone_duplicate_xpm ) );
  597. zones_menu->AppendSeparator();
  598. if( ! edge_zone->GetIsKeepout() )
  599. AddMenuItem( zones_menu, ID_POPUP_PCB_FILL_ZONE, _( "Fill Zone" ),
  600. KiBitmap( fill_zone_xpm ) );
  601. if( edge_zone->GetFilledPolysList().GetCornersCount() > 0 )
  602. {
  603. AddMenuItem( zones_menu, ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE,
  604. _( "Remove Filled Areas in Zone" ), KiBitmap( zone_unfill_xpm ) );
  605. }
  606. msg = AddHotkeyName( _( "Move Zone" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
  607. AddMenuItem( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES, msg, KiBitmap( move_xpm ) );
  608. msg = AddHotkeyName( _( "Edit Zone Properties" ), g_Board_Editor_Hokeys_Descr,
  609. HK_EDIT_ITEM );
  610. AddMenuItem( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
  611. msg, KiBitmap( edit_xpm ) );
  612. zones_menu->AppendSeparator();
  613. if( edge_zone->GetSelectedCorner() >= 0 &&
  614. edge_zone->Outline()->IsCutoutContour( edge_zone->GetSelectedCorner() ) )
  615. AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
  616. _( "Delete Cutout" ), KiBitmap( delete_xpm ) );
  617. AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
  618. _( "Delete Zone Outline" ), KiBitmap( delete_xpm ) );
  619. }
  620. }
  621. /* Create the wxMenuitem list for footprint editing
  622. */
  623. void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu )
  624. {
  625. wxMenu* sub_menu_footprint;
  626. int flags = aModule->GetFlags();
  627. wxString msg;
  628. sub_menu_footprint = new wxMenu;
  629. msg = aModule->GetSelectMenuText();
  630. AddMenuItem( menu, sub_menu_footprint, -1, msg, KiBitmap( module_xpm ) );
  631. if( !flags )
  632. {
  633. msg = AddHotkeyName( _( "Move" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
  634. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST,
  635. msg, KiBitmap( move_module_xpm ) );
  636. msg = AddHotkeyName( _( "Drag" ), g_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM );
  637. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST,
  638. msg, KiBitmap( drag_module_xpm ) );
  639. }
  640. msg = AddHotkeyName( _( "Rotate +" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
  641. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE,
  642. msg, KiBitmap( rotate_module_pos_xpm ) );
  643. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE,
  644. _( "Rotate -" ), KiBitmap( rotate_module_neg_xpm ) );
  645. msg = AddHotkeyName( _( "Flip" ), g_Board_Editor_Hokeys_Descr, HK_FLIP_ITEM );
  646. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE,
  647. msg, KiBitmap( invert_module_xpm ) );
  648. if( !flags )
  649. {
  650. msg = AddHotkeyName( _( "Edit Parameters" ),
  651. g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
  652. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE_PRMS, msg,
  653. KiBitmap( edit_module_xpm ) );
  654. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT,
  655. _( "Edit with Module Editor" ),
  656. KiBitmap( module_editor_xpm ) );
  657. sub_menu_footprint->AppendSeparator();
  658. msg = AddHotkeyName( _( "Delete Module" ),
  659. g_Board_Editor_Hokeys_Descr, HK_DELETE );
  660. AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE,
  661. msg, KiBitmap( delete_module_xpm ) );
  662. }
  663. }
  664. /* Create the wxMenuitem list for editing texts on footprints
  665. */
  666. void PCB_EDIT_FRAME::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* menu )
  667. {
  668. wxMenu* sub_menu_Fp_text;
  669. int flags = FpText->GetFlags();
  670. wxString msg = FpText->GetSelectMenuText();
  671. sub_menu_Fp_text = new wxMenu;
  672. AddMenuItem( menu, sub_menu_Fp_text, -1, msg, KiBitmap( footprint_text_xpm ) );
  673. if( !flags )
  674. {
  675. msg = AddHotkeyName( _( "Move" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
  676. AddMenuItem( sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST,
  677. msg, KiBitmap( move_field_xpm ) );
  678. }
  679. msg = AddHotkeyName( _( "Rotate" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
  680. AddMenuItem( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE,
  681. msg, KiBitmap( rotate_field_xpm ) );
  682. if( !flags )
  683. {
  684. msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
  685. AddMenuItem( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE,
  686. msg, KiBitmap( edit_text_xpm ) );
  687. AddMenuItem( sub_menu_Fp_text, ID_POPUP_PCB_RESET_TEXT_SIZE,
  688. _( "Reset Size" ), KiBitmap( reset_text_xpm ) );
  689. }
  690. // Graphic texts can be deleted only if are not currently edited.
  691. if( !flags && FpText->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
  692. {
  693. AddMenuItem( sub_menu_Fp_text, ID_POPUP_PCB_DELETE_TEXTMODULE,
  694. _( "Delete" ), KiBitmap( delete_xpm ) );
  695. }
  696. if( !flags )
  697. {
  698. MODULE* module = (MODULE*) FpText->GetParent();
  699. if( module )
  700. {
  701. menu->AppendSeparator();
  702. createPopUpMenuForFootprints( module, menu );
  703. }
  704. }
  705. }
  706. /* Create pop menu for pads
  707. * also update Netclass selection
  708. */
  709. void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
  710. {
  711. wxMenu* sub_menu_Pad;
  712. int flags = Pad->GetFlags();
  713. if( flags ) // Currently in edit, no others commands possible
  714. return;
  715. if( GetBoard()->GetCurrentNetClassName() != Pad->GetNetClassName() )
  716. {
  717. GetBoard()->SetCurrentNetClass( Pad->GetNetClassName() );
  718. updateTraceWidthSelectBox();
  719. updateViaSizeSelectBox();
  720. }
  721. wxString msg = Pad->GetSelectMenuText();
  722. sub_menu_Pad = new wxMenu;
  723. AddMenuItem( menu, sub_menu_Pad, -1, msg, KiBitmap( pad_xpm ) );
  724. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, _( "Move" ),
  725. KiBitmap( move_pad_xpm ) );
  726. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, _( "Drag" ),
  727. KiBitmap( drag_pad_xpm ) );
  728. msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
  729. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, msg, KiBitmap( options_pad_xpm ) );
  730. sub_menu_Pad->AppendSeparator();
  731. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_IMPORT_PAD_SETTINGS,
  732. _( "Copy Current Settings to this Pad" ),
  733. wxEmptyString,
  734. KiBitmap( options_new_pad_xpm ) );
  735. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_EXPORT_PAD_SETTINGS,
  736. _( "Copy this Pad Settings to Current Settings" ),
  737. wxEmptyString,
  738. KiBitmap( export_options_pad_xpm ) );
  739. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS,
  740. _( "Edit All Pads" ),
  741. _( "Copy this pad's settings to all pads in this footprint (or similar footprints)" ),
  742. KiBitmap( global_options_pad_xpm ) );
  743. sub_menu_Pad->AppendSeparator();
  744. AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_DELETE_PAD, _( "Delete" ), KiBitmap( delete_pad_xpm ) );
  745. if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_TRACKS ) )
  746. {
  747. menu->Append( ID_POPUP_PCB_AUTOROUTE_PAD, _( "Automatically Route Pad" ) );
  748. menu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _( "Automatically Route Net" ) );
  749. }
  750. MODULE* module = (MODULE*) Pad->GetParent();
  751. if( module )
  752. {
  753. menu->AppendSeparator();
  754. createPopUpMenuForFootprints( module, menu );
  755. }
  756. }
  757. // Create pop menu for pcb texts
  758. void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
  759. {
  760. wxMenu* sub_menu_Text;
  761. int flags = Text->GetFlags();
  762. wxString msg = Text->GetSelectMenuText();
  763. sub_menu_Text = new wxMenu;
  764. AddMenuItem( menu, sub_menu_Text, -1, msg, KiBitmap( add_text_xpm ) );
  765. if( !flags )
  766. {
  767. msg = AddHotkeyName( _( "Move" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
  768. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST,
  769. msg, KiBitmap( move_text_xpm ) );
  770. msg = AddHotkeyName( _( "Copy" ), g_Board_Editor_Hokeys_Descr, HK_COPY_ITEM );
  771. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_COPY_TEXTEPCB,
  772. msg, KiBitmap( copyblock_xpm ) );
  773. }
  774. msg = AddHotkeyName( _( "Rotate" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
  775. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB, msg, KiBitmap( rotate_ccw_xpm ) );
  776. msg = AddHotkeyName( _( "Flip" ), g_Board_Editor_Hokeys_Descr, HK_FLIP_ITEM );
  777. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_FLIP_TEXTEPCB, msg, KiBitmap( invert_module_xpm ) );
  778. msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
  779. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB, msg, KiBitmap( edit_text_xpm ) );
  780. if( !flags )
  781. {
  782. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_RESET_TEXT_SIZE,
  783. _( "Reset Size" ), KiBitmap( reset_text_xpm ) );
  784. sub_menu_Text->AppendSeparator();
  785. msg = AddHotkeyName( _( "Delete" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
  786. AddMenuItem( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, msg, KiBitmap( delete_text_xpm ) );
  787. }
  788. }
  789. void PCB_EDIT_FRAME::createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu )
  790. {
  791. AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ),
  792. KiBitmap( delete_xpm ) );
  793. AddMenuItem( aPopMenu, ID_POPUP_PCB_GETINFO_MARKER, _( "Marker Error Info" ),
  794. KiBitmap( info_xpm ) );
  795. }
  796. /**
  797. * Function Append_Track_Width_List
  798. * creates a wxMenu * which shows the last used track widths and via diameters
  799. * @return a pointer to the menu
  800. */
  801. static wxMenu* Append_Track_Width_List( BOARD* aBoard )
  802. {
  803. wxString msg;
  804. wxMenu* trackwidth_menu;
  805. wxString value;
  806. trackwidth_menu = new wxMenu;
  807. trackwidth_menu->Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Auto Width" ),
  808. _( "Use the track width when starting on a track, otherwise the current track width" ),
  809. true );
  810. if( aBoard->GetDesignSettings().m_UseConnectedTrackWidth )
  811. trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, true );
  812. if( aBoard->GetViaSizeIndex() != 0
  813. || aBoard->GetTrackWidthIndex() != 0
  814. || aBoard->GetDesignSettings().m_UseConnectedTrackWidth )
  815. trackwidth_menu->Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES,
  816. _( "Use Netclass Values" ),
  817. _( "Use track and via sizes from their Netclass values" ),
  818. true );
  819. for( unsigned ii = 0; ii < aBoard->m_TrackWidthList.size(); ii++ )
  820. {
  821. value = ReturnStringFromValue( g_UserUnit, aBoard->m_TrackWidthList[ii], true );
  822. msg.Printf( _( "Track %s" ), GetChars( value ) );
  823. if( ii == 0 )
  824. msg << _( " uses NetClass" );
  825. trackwidth_menu->Append( ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, true );
  826. }
  827. trackwidth_menu->AppendSeparator();
  828. for( unsigned ii = 0; ii < aBoard->m_ViasDimensionsList.size(); ii++ )
  829. {
  830. value = ReturnStringFromValue( g_UserUnit, aBoard->m_ViasDimensionsList[ii].m_Diameter,
  831. true );
  832. wxString drill = ReturnStringFromValue( g_UserUnit,
  833. aBoard->m_ViasDimensionsList[ii].m_Drill,
  834. true );
  835. if( aBoard->m_ViasDimensionsList[ii].m_Drill <= 0 )
  836. {
  837. msg.Printf( _( "Via %s" ), GetChars( value ) );
  838. }
  839. else
  840. {
  841. msg.Printf( _( "Via %s, drill %s" ), GetChars( value ), GetChars( drill ) );
  842. }
  843. if( ii == 0 )
  844. msg << _( " uses NetClass" );
  845. trackwidth_menu->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, true );
  846. }
  847. return trackwidth_menu;
  848. }