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.

1147 lines
36 KiB

17 years ago
16 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
19 years ago
19 years ago
19 years ago
19 years ago
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
18 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
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
16 years ago
19 years ago
19 years ago
19 years ago
19 years ago
17 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
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
  1. /**************************************/
  2. /* edit.cpp: edit PCB implementation. */
  3. /**************************************/
  4. #include "fctsys.h"
  5. #include "appl_wxstruct.h"
  6. #include "class_drawpanel.h"
  7. #include "confirm.h"
  8. #include "eda_doc.h"
  9. #include "gestfich.h"
  10. #include "pcbnew_id.h"
  11. #include "pcbnew.h"
  12. #include "wxPcbStruct.h"
  13. #include "class_board_design_settings.h"
  14. #include "autorout.h"
  15. #include "protos.h"
  16. #include "kicad_device_context.h"
  17. #include "dialog_global_edit_tracks_and_vias.h"
  18. // Uncomment following line to enable wxBell() command (which beeps speaker)
  19. // #include <wx/utils.h>
  20. static void Process_Move_Item( WinEDA_PcbFrame* frame,
  21. EDA_BaseStruct* DrawStruct, wxDC* DC );
  22. /* Handles the selection of command events. */
  23. void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
  24. {
  25. int id = event.GetId();
  26. wxPoint pos;
  27. int itmp;
  28. INSTALL_DC( dc, DrawPanel );
  29. BOARD_ITEM* DrawStruct = GetCurItem();
  30. DrawPanel->CursorOff( &dc );
  31. wxGetMousePosition( &pos.x, &pos.y );
  32. pos.y += 20;
  33. switch( id ) // Some (not all ) edit commands must be finished or aborted
  34. {
  35. case wxID_CUT:
  36. case wxID_COPY:
  37. case ID_ON_GRID_SELECT:
  38. case ID_ON_ZOOM_SELECT:
  39. case ID_PCB_USER_GRID_SETUP:
  40. case ID_TOOLBARH_PCB_SELECT_LAYER:
  41. case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
  42. case ID_POPUP_PCB_ROTATE_TEXTEPCB:
  43. case ID_POPUP_PCB_EDIT_TEXTEPCB:
  44. case ID_POPUP_PCB_EDIT_MIRE:
  45. case ID_POPUP_PCB_ROTATE_TEXTMODULE:
  46. case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
  47. case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
  48. case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
  49. case ID_POPUP_PCB_EDIT_MODULE:
  50. case ID_POPUP_PCB_EDIT_TEXTMODULE:
  51. case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
  52. case ID_POPUP_PCB_END_TRACK:
  53. case ID_POPUP_PCB_PLACE_VIA:
  54. case ID_POPUP_PCB_PLACE_MICROVIA:
  55. case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
  56. case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
  57. case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
  58. case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
  59. case ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER:
  60. case ID_POPUP_PCB_FILL_ALL_ZONES:
  61. case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES:
  62. case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE:
  63. case ID_POPUP_PCB_PLACE_ZONE_CORNER:
  64. case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
  65. case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
  66. case ID_POPUP_PCB_DELETE_ZONE:
  67. case ID_POPUP_PCB_MOVE_ZONE_CORNER:
  68. case ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT:
  69. case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
  70. case ID_POPUP_PCB_ADD_ZONE_CORNER:
  71. case ID_POPUP_PCB_DELETE_TRACKSEG:
  72. case ID_POPUP_PCB_DELETE_TRACK:
  73. case ID_POPUP_PCB_DELETE_TRACKNET:
  74. case ID_POPUP_PCB_FILL_ZONE:
  75. case ID_POPUP_PCB_SELECT_LAYER:
  76. case ID_POPUP_PCB_SELECT_CU_LAYER:
  77. case ID_POPUP_PCB_SELECT_LAYER_PAIR:
  78. case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
  79. case ID_POPUP_PCB_MOVE_TRACK_NODE:
  80. case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE:
  81. case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
  82. case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
  83. case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE:
  84. case ID_POPUP_PCB_BREAK_TRACK:
  85. case ID_POPUP_PCB_EDIT_NET:
  86. case ID_POPUP_PCB_EDIT_TRACK:
  87. case ID_POPUP_PCB_EDIT_TRACKSEG:
  88. case ID_POPUP_PCB_LOCK_ON_TRACKSEG:
  89. case ID_POPUP_PCB_LOCK_OFF_TRACKSEG:
  90. case ID_POPUP_PCB_LOCK_ON_TRACK:
  91. case ID_POPUP_PCB_LOCK_OFF_TRACK:
  92. case ID_POPUP_PCB_LOCK_ON_NET:
  93. case ID_POPUP_PCB_LOCK_OFF_NET:
  94. case ID_POPUP_DELETE_BLOCK:
  95. case ID_POPUP_PLACE_BLOCK:
  96. case ID_POPUP_ZOOM_BLOCK:
  97. case ID_POPUP_FLIP_BLOCK:
  98. case ID_POPUP_ROTATE_BLOCK:
  99. case ID_POPUP_COPY_BLOCK:
  100. case ID_POPUP_PCB_EDIT_DRAWING:
  101. case ID_POPUP_PCB_GETINFO_MARKER:
  102. break;
  103. case ID_POPUP_CANCEL_CURRENT_COMMAND:
  104. if( DrawPanel->ManageCurseur
  105. && DrawPanel->ForceCloseManageCurseur )
  106. {
  107. DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
  108. }
  109. /* Should not be executed, just in case */
  110. if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
  111. {
  112. GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
  113. GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
  114. GetScreen()->m_BlockLocate.ClearItemsList();
  115. }
  116. if( m_ID_current_state == 0 )
  117. SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
  118. else
  119. SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
  120. break;
  121. default: // Finish (abort) the command
  122. if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
  123. DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
  124. if( m_ID_current_state != id )
  125. {
  126. if( m_ID_last_state != m_ID_current_state )
  127. m_ID_last_state = m_ID_current_state;
  128. SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
  129. }
  130. break;
  131. }
  132. switch( id ) // Execute command
  133. {
  134. case 0:
  135. break;
  136. case ID_OPEN_MODULE_EDITOR:
  137. if( m_ModuleEditFrame == NULL )
  138. {
  139. m_ModuleEditFrame =
  140. new WinEDA_ModuleEditFrame( this,
  141. _( "Module Editor" ),
  142. wxPoint( -1, -1 ),
  143. wxSize( 600, 400 ) );
  144. m_ModuleEditFrame->Show( true );
  145. m_ModuleEditFrame->Zoom_Automatique( true );
  146. }
  147. else
  148. m_ModuleEditFrame->Iconize( false );
  149. break;
  150. case ID_PCB_GLOBAL_DELETE:
  151. InstallPcbGlobalDeleteFrame( pos );
  152. break;
  153. case ID_POPUP_PLACE_BLOCK:
  154. GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
  155. DrawPanel->m_AutoPAN_Request = false;
  156. HandleBlockPlace( &dc );
  157. break;
  158. case ID_POPUP_COPY_BLOCK:
  159. GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
  160. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  161. DrawPanel->m_AutoPAN_Request = false;
  162. HandleBlockPlace( &dc );
  163. break;
  164. case ID_POPUP_ZOOM_BLOCK:
  165. GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
  166. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  167. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  168. HandleBlockEnd( &dc );
  169. break;
  170. case ID_POPUP_DELETE_BLOCK:
  171. GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
  172. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  173. HandleBlockEnd( &dc );
  174. break;
  175. case ID_POPUP_ROTATE_BLOCK:
  176. GetScreen()->m_BlockLocate.m_Command = BLOCK_ROTATE;
  177. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  178. HandleBlockEnd( &dc );
  179. break;
  180. case ID_POPUP_FLIP_BLOCK:
  181. GetScreen()->m_BlockLocate.m_Command = BLOCK_FLIP;
  182. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  183. HandleBlockEnd( &dc );
  184. break;
  185. case ID_DRC_CONTROL:
  186. Install_Test_DRC_Frame( &dc );
  187. break;
  188. case ID_GET_NETLIST:
  189. InstallNetlistFrame( &dc, wxPoint( -1, -1 ) );
  190. break;
  191. case ID_GET_TOOLS:
  192. // InstalloolsFrame(this, wxPoint(-1,-1) );
  193. break;
  194. case ID_FIND_ITEMS:
  195. InstallFindFrame( pos, &dc );
  196. break;
  197. case ID_TRACK_BUTT:
  198. SetToolID( id, wxCURSOR_PENCIL, _( "Add Tracks" ) );
  199. if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
  200. {
  201. Compile_Ratsnest( &dc, true );
  202. }
  203. break;
  204. case ID_PCB_ZONES_BUTT:
  205. SetToolID( id, wxCURSOR_PENCIL, _( "Add Zones" ) );
  206. if( DisplayOpt.DisplayZonesMode != 0 )
  207. DisplayInfoMessage( this, _( "Warning: Display Zone is OFF!!!" ) );
  208. if( !g_HighLight_Status && (g_HighLight_NetCode > 0 ) )
  209. High_Light( &dc );
  210. break;
  211. case ID_PCB_MIRE_BUTT:
  212. SetToolID( id, wxCURSOR_PENCIL, _( "Add Layer Alignment Target" ) );
  213. break;
  214. case ID_PCB_PLACE_OFFSET_COORD_BUTT:
  215. SetToolID( id, wxCURSOR_PENCIL, _( "Adjust Zero" ) );
  216. break;
  217. case ID_PCB_ADD_LINE_BUTT:
  218. case ID_PCB_ARC_BUTT:
  219. case ID_PCB_CIRCLE_BUTT:
  220. SetToolID( id, wxCURSOR_PENCIL, _( "Add Graphic" ) );
  221. break;
  222. case ID_PCB_ADD_TEXT_BUTT:
  223. SetToolID( id, wxCURSOR_PENCIL, _( "Add Text" ) );
  224. break;
  225. case ID_COMPONENT_BUTT:
  226. SetToolID( id, wxCURSOR_HAND, _( "Add Modules" ) );
  227. break;
  228. case ID_PCB_DIMENSION_BUTT:
  229. SetToolID( id, wxCURSOR_PENCIL, _( "Add Dimension" ) );
  230. break;
  231. case ID_NO_SELECT_BUTT:
  232. SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
  233. break;
  234. case ID_PCB_HIGHLIGHT_BUTT:
  235. SetToolID( id, wxCURSOR_HAND, _( "Net Highlight" ) );
  236. break;
  237. case ID_PCB_SHOW_1_RATSNEST_BUTT:
  238. SetToolID( id, wxCURSOR_HAND, _( "Local Ratsnest" ) );
  239. if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
  240. Compile_Ratsnest( &dc, true );
  241. break;
  242. case ID_POPUP_CLOSE_CURRENT_TOOL:
  243. SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
  244. break;
  245. case ID_POPUP_CANCEL_CURRENT_COMMAND:
  246. break;
  247. case ID_POPUP_PCB_END_LINE:
  248. DrawPanel->MouseToCursorSchema();
  249. // EndSegment(&dc);
  250. break;
  251. case ID_POPUP_PCB_EDIT_TRACK:
  252. if( GetCurItem() == NULL )
  253. break;
  254. Edit_Track_Width( &dc, (TRACK*) GetCurItem() );
  255. DrawPanel->MouseToCursorSchema();
  256. OnModify();
  257. break;
  258. case ID_POPUP_PCB_EDIT_TRACKSEG:
  259. if( GetCurItem() == NULL )
  260. break;
  261. Edit_TrackSegm_Width( &dc, (TRACK*) GetCurItem() );
  262. DrawPanel->MouseToCursorSchema();
  263. OnModify();
  264. break;
  265. case ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE:
  266. if( GetCurItem() == NULL )
  267. break;
  268. {
  269. int type = GetCurItem()->Type();
  270. if( type == TYPE_TRACK || type == TYPE_VIA )
  271. {
  272. BOARD_CONNECTED_ITEM*item = (BOARD_CONNECTED_ITEM*) GetCurItem();
  273. DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, item->GetNet() );
  274. dlg.ShowModal();
  275. }
  276. }
  277. DrawPanel->MouseToCursorSchema();
  278. break;
  279. case ID_POPUP_PCB_END_TRACK:
  280. DrawPanel->MouseToCursorSchema();
  281. End_Route( (TRACK*) GetCurItem(), &dc );
  282. break;
  283. case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE:
  284. DrawPanel->MouseToCursorSchema();
  285. if( GetCurItem()->m_Flags & IS_DRAGGED )
  286. {
  287. PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc );
  288. }
  289. break;
  290. case ID_POPUP_PCB_PLACE_MICROVIA:
  291. if( !IsMicroViaAcceptable() )
  292. break;
  293. case ID_POPUP_PCB_PLACE_VIA:
  294. DrawPanel->MouseToCursorSchema();
  295. if( GetCurItem()->m_Flags & IS_DRAGGED )
  296. {
  297. PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc );
  298. }
  299. else
  300. {
  301. int v_type = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType;
  302. if( id == ID_POPUP_PCB_PLACE_MICROVIA )
  303. GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA; // place micro via and switch layer
  304. Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
  305. GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = v_type;
  306. if( DisplayOpt.ContrastModeDisplay )
  307. ( (PCB_SCREEN*) GetScreen() )->SetRefreshReq();
  308. }
  309. break;
  310. case ID_POPUP_PCB_DELETE_TRACKSEG:
  311. if( GetCurItem() == NULL )
  312. break;
  313. DrawPanel->MouseToCursorSchema();
  314. SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
  315. OnModify();
  316. break;
  317. case ID_POPUP_PCB_DELETE_TRACK:
  318. if( GetCurItem() == NULL )
  319. break;
  320. DrawPanel->MouseToCursorSchema();
  321. Delete_Track( &dc, (TRACK*) GetCurItem() );
  322. SetCurItem( NULL );
  323. OnModify();
  324. break;
  325. case ID_POPUP_PCB_DELETE_TRACKNET:
  326. DrawPanel->MouseToCursorSchema();
  327. Delete_net( &dc, (TRACK*) GetCurItem() );
  328. SetCurItem( NULL );
  329. OnModify();
  330. break;
  331. case ID_POPUP_PCB_LOCK_ON_TRACKSEG:
  332. Attribut_Segment( (TRACK*) GetCurItem(), &dc, true );
  333. break;
  334. case ID_POPUP_PCB_LOCK_OFF_TRACKSEG:
  335. Attribut_Segment( (TRACK*) GetCurItem(), &dc, false );
  336. break;
  337. case ID_POPUP_PCB_LOCK_ON_TRACK:
  338. Attribut_Track( (TRACK*) GetCurItem(), &dc, true );
  339. break;
  340. case ID_POPUP_PCB_LOCK_OFF_TRACK:
  341. Attribut_Track( (TRACK*) GetCurItem(), &dc, false );
  342. break;
  343. case ID_POPUP_PCB_LOCK_ON_NET:
  344. Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNet(), true );
  345. break;
  346. case ID_POPUP_PCB_LOCK_OFF_NET:
  347. Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNet(), false );
  348. break;
  349. case ID_POPUP_PCB_SETFLAGS_TRACK_MNU:
  350. break;
  351. case ID_POPUP_PCB_DELETE_ZONE:
  352. DrawPanel->MouseToCursorSchema();
  353. if( GetCurItem() == NULL )
  354. break;
  355. {
  356. SEGZONE* zsegm = (SEGZONE*) GetCurItem();
  357. int netcode = zsegm->GetNet();
  358. Delete_Zone_Fill( zsegm );
  359. SetCurItem( NULL );
  360. test_1_net_connexion( NULL, netcode );
  361. OnModify();
  362. GetBoard()->DisplayInfo( this );
  363. }
  364. break;
  365. case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
  366. Edit_Zone_Params( &dc, (ZONE_CONTAINER*) GetCurItem() );
  367. SetCurItem( NULL ); // Outlines can have changed
  368. break;
  369. case ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE:
  370. DrawPanel->MouseToCursorSchema();
  371. DrawPanel->m_AutoPAN_Request = true;
  372. Add_Similar_Zone( &dc, (ZONE_CONTAINER*) GetCurItem() );
  373. break;
  374. case ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE:
  375. DrawPanel->MouseToCursorSchema();
  376. DrawPanel->m_AutoPAN_Request = true;
  377. Add_Zone_Cutout( &dc, (ZONE_CONTAINER*) GetCurItem() );
  378. break;
  379. case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
  380. case ID_POPUP_PCB_DELETE_ZONE_CUTOUT:
  381. DrawPanel->MouseToCursorSchema();
  382. {
  383. int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNet();
  384. Delete_Zone_Contour( &dc, (ZONE_CONTAINER*) GetCurItem() );
  385. SetCurItem( NULL );
  386. test_1_net_connexion( NULL, netcode );
  387. GetBoard()->DisplayInfo( this );
  388. }
  389. break;
  390. case ID_POPUP_PCB_DELETE_ZONE_CORNER:
  391. Remove_Zone_Corner( &dc, (ZONE_CONTAINER*) GetCurItem() );
  392. SetCurItem( NULL );
  393. break;
  394. case ID_POPUP_PCB_MOVE_ZONE_CORNER:
  395. {
  396. DrawPanel->MouseToCursorSchema();
  397. ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
  398. DrawPanel->m_AutoPAN_Request = true;
  399. Start_Move_Zone_Corner( &dc,
  400. zone_cont,
  401. zone_cont->m_CornerSelection,
  402. false );
  403. break;
  404. }
  405. case ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT:
  406. {
  407. DrawPanel->MouseToCursorSchema();
  408. ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
  409. DrawPanel->m_AutoPAN_Request = true;
  410. Start_Move_Zone_Drag_Outline_Edge( &dc,
  411. zone_cont,
  412. zone_cont->m_CornerSelection );
  413. break;
  414. }
  415. case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
  416. {
  417. DrawPanel->MouseToCursorSchema();
  418. ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
  419. DrawPanel->m_AutoPAN_Request = true;
  420. Start_Move_Zone_Outlines( &dc, zone_cont );
  421. break;
  422. }
  423. case ID_POPUP_PCB_ADD_ZONE_CORNER:
  424. {
  425. DrawPanel->MouseToCursorSchema();
  426. ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
  427. wxPoint pos = GetScreen()->m_Curseur;
  428. /* add corner between zone_cont->m_CornerSelection
  429. * and zone_cont->m_CornerSelection+1
  430. * and start move the new corner
  431. */
  432. zone_cont->Draw( DrawPanel, &dc, GR_XOR );
  433. zone_cont->m_Poly->InsertCorner( zone_cont->m_CornerSelection,
  434. pos.x, pos.y );
  435. zone_cont->m_CornerSelection++;
  436. zone_cont->Draw( DrawPanel, &dc, GR_XOR );
  437. DrawPanel->m_AutoPAN_Request = true;
  438. Start_Move_Zone_Corner( &dc,
  439. zone_cont,
  440. zone_cont->m_CornerSelection,
  441. true );
  442. break;
  443. }
  444. case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
  445. case ID_POPUP_PCB_PLACE_ZONE_CORNER:
  446. {
  447. DrawPanel->MouseToCursorSchema();
  448. ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
  449. End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont );
  450. DrawPanel->m_AutoPAN_Request = false;
  451. break;
  452. }
  453. case ID_POPUP_PCB_FILL_ALL_ZONES:
  454. DrawPanel->MouseToCursorSchema();
  455. Fill_All_Zones();
  456. GetBoard()->DisplayInfo( this );
  457. break;
  458. case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE:
  459. if( ( GetCurItem() )->Type() == TYPE_ZONE_CONTAINER )
  460. {
  461. ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
  462. Delete_Zone_Fill( NULL, zone_container->m_TimeStamp );
  463. test_1_net_connexion( NULL, zone_container->GetNet() );
  464. OnModify();
  465. GetBoard()->DisplayInfo( this );
  466. DrawPanel->Refresh();
  467. }
  468. SetCurItem( NULL );
  469. break;
  470. case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
  471. GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
  472. for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
  473. {
  474. // Remove filled areas in zone
  475. ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
  476. zone_container->m_FilledPolysList.clear();;
  477. }
  478. SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
  479. test_connexions( NULL );
  480. Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links */
  481. OnModify();
  482. GetBoard()->DisplayInfo( this );
  483. DrawPanel->Refresh();
  484. break;
  485. case ID_POPUP_PCB_FILL_ZONE:
  486. DrawPanel->MouseToCursorSchema();
  487. Fill_Zone( (ZONE_CONTAINER*) GetCurItem() );
  488. test_1_net_connexion( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
  489. GetBoard()->DisplayInfo( this );
  490. DrawPanel->Refresh();
  491. break;
  492. case ID_PCB_DELETE_ITEM_BUTT:
  493. SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
  494. break;
  495. case ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST:
  496. Process_Move_Item( this, GetCurItem(), &dc );
  497. DrawPanel->m_AutoPAN_Request = true;
  498. break;
  499. case ID_POPUP_PCB_DRAG_MODULE_REQUEST:
  500. g_Drag_Pistes_On = true;
  501. case ID_POPUP_PCB_MOVE_MODULE_REQUEST:
  502. // If the current Item is a pad, text module ...: Get its parent
  503. if( GetCurItem()->Type() != TYPE_MODULE )
  504. SetCurItem( GetCurItem()->GetParent() );
  505. if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
  506. {
  507. g_Drag_Pistes_On = false;
  508. break;
  509. }
  510. DrawPanel->MouseToCursorSchema();
  511. StartMove_Module( (MODULE*) GetCurItem(), &dc );
  512. break;
  513. case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: /* get module by name and move it */
  514. SetCurItem( GetModuleByName() );
  515. if( GetCurItem() )
  516. {
  517. DrawPanel->MouseToCursorSchema();
  518. StartMove_Module( (MODULE*) GetCurItem(), &dc );
  519. }
  520. break;
  521. case ID_POPUP_PCB_DELETE_MODULE:
  522. DrawPanel->MouseToCursorSchema();
  523. // If the current Item is a pad, text module ...: Get its parent
  524. if( GetCurItem()->Type() != TYPE_MODULE )
  525. SetCurItem( GetCurItem()->GetParent() );
  526. if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
  527. break;
  528. if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) )
  529. {
  530. SetCurItem( NULL );
  531. }
  532. break;
  533. case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
  534. DrawPanel->MouseToCursorSchema();
  535. // If the current Item is a pad, text module ...: Get its parent
  536. if( GetCurItem()->Type() != TYPE_MODULE )
  537. SetCurItem( GetCurItem()->GetParent() );
  538. if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
  539. break;
  540. if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
  541. SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos);
  542. Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true );
  543. break;
  544. case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
  545. DrawPanel->MouseToCursorSchema();
  546. // If the current Item is a pad, text module ...: Get its parent
  547. if( GetCurItem()->Type() != TYPE_MODULE )
  548. SetCurItem( GetCurItem()->GetParent() );
  549. if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
  550. break;
  551. if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
  552. SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos);
  553. Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true );
  554. break;
  555. case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
  556. DrawPanel->MouseToCursorSchema();
  557. // If the current Item is a pad, text module ...: Get its parent
  558. if( GetCurItem()->Type() != TYPE_MODULE )
  559. SetCurItem( GetCurItem()->GetParent() );
  560. if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
  561. break;
  562. if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple flip, no other edition in progress */
  563. SaveCopyInUndoList(GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->m_Pos);
  564. Change_Side_Module( (MODULE*) GetCurItem(), &dc );
  565. break;
  566. case ID_POPUP_PCB_EDIT_MODULE:
  567. // If the current Item is a pad, text module ...: Get its parent
  568. if( GetCurItem()->Type() != TYPE_MODULE )
  569. SetCurItem( GetCurItem()->GetParent() );
  570. if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
  571. break;
  572. InstallModuleOptionsFrame( (MODULE*) GetCurItem(), &dc );
  573. DrawPanel->MouseToCursorSchema();
  574. break;
  575. case ID_POPUP_PCB_DRAG_PAD_REQUEST:
  576. g_Drag_Pistes_On = true;
  577. DrawPanel->MouseToCursorSchema();
  578. StartMovePad( (D_PAD*) GetCurItem(), &dc );
  579. break;
  580. case ID_POPUP_PCB_MOVE_PAD_REQUEST:
  581. g_Drag_Pistes_On = false;
  582. DrawPanel->MouseToCursorSchema();
  583. StartMovePad( (D_PAD*) GetCurItem(), &dc );
  584. break;
  585. case ID_POPUP_PCB_EDIT_PAD:
  586. InstallPadOptionsFrame( (D_PAD*) GetCurItem() );
  587. DrawPanel->MouseToCursorSchema();
  588. break;
  589. case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
  590. DrawPanel->MouseToCursorSchema();
  591. SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
  592. Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
  593. break;
  594. case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
  595. DrawPanel->MouseToCursorSchema();
  596. Global_Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
  597. break;
  598. case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
  599. DrawPanel->MouseToCursorSchema();
  600. Export_Pad_Settings( (D_PAD*) GetCurItem() );
  601. break;
  602. case ID_POPUP_PCB_DELETE_PAD:
  603. SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
  604. DeletePad( (D_PAD*) GetCurItem() );
  605. SetCurItem( NULL );
  606. DrawPanel->MouseToCursorSchema();
  607. break;
  608. case ID_POPUP_PCB_EDIT_TEXTMODULE:
  609. InstallTextModOptionsFrame( (TEXTE_MODULE*) GetCurItem(), &dc );
  610. DrawPanel->MouseToCursorSchema();
  611. break;
  612. case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
  613. DrawPanel->MouseToCursorSchema();
  614. StartMoveTexteModule( (TEXTE_MODULE*) GetCurItem(), &dc );
  615. break;
  616. case ID_POPUP_PCB_ROTATE_TEXTMODULE:
  617. RotateTextModule( (TEXTE_MODULE*) GetCurItem(),
  618. &dc );
  619. DrawPanel->MouseToCursorSchema();
  620. break;
  621. case ID_POPUP_PCB_DELETE_TEXTMODULE:
  622. DeleteTextModule( (TEXTE_MODULE*) GetCurItem() );
  623. SetCurItem( NULL );
  624. DrawPanel->MouseToCursorSchema();
  625. break;
  626. case ID_POPUP_PCB_SELECT_LAYER:
  627. itmp = SelectLayer( getActiveLayer(), -1, -1 );
  628. if( itmp >= 0 )
  629. setActiveLayer( itmp );
  630. DrawPanel->MouseToCursorSchema();
  631. break;
  632. case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
  633. SelectLayerPair();
  634. break;
  635. case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
  636. itmp = SelectLayer( getActiveLayer(), FIRST_NO_COPPER_LAYER, -1 );
  637. if( itmp >= 0 )
  638. setActiveLayer( itmp );
  639. DrawPanel->MouseToCursorSchema();
  640. break;
  641. case ID_POPUP_PCB_SELECT_CU_LAYER:
  642. itmp = SelectLayer( getActiveLayer(), -1, LAST_COPPER_LAYER );
  643. if( itmp >= 0 )
  644. setActiveLayer( itmp );
  645. break;
  646. case ID_POPUP_PCB_SELECT_LAYER_PAIR:
  647. SelectLayerPair();
  648. DrawPanel->MouseToCursorSchema();
  649. break;
  650. case ID_TOOLBARH_PCB_SELECT_LAYER:
  651. itmp = m_SelLayerBox->GetChoice();
  652. setActiveLayer( (size_t) m_SelLayerBox->wxItemContainer::GetClientData( itmp ) );
  653. if( DisplayOpt.ContrastModeDisplay )
  654. DrawPanel->Refresh( true );
  655. break;
  656. case ID_POPUP_PCB_EDIT_TEXTEPCB:
  657. InstallTextPCBOptionsFrame( (TEXTE_PCB*) GetCurItem(), &dc );
  658. DrawPanel->MouseToCursorSchema();
  659. break;
  660. case ID_POPUP_PCB_ROTATE_TEXTEPCB:
  661. Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
  662. DrawPanel->MouseToCursorSchema();
  663. break;
  664. case ID_POPUP_PCB_DELETE_TEXTEPCB:
  665. Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
  666. DrawPanel->MouseToCursorSchema();
  667. break;
  668. case ID_POPUP_PCB_MOVE_MIRE_REQUEST:
  669. StartMove_Mire( (MIREPCB*) GetCurItem(), &dc );
  670. DrawPanel->MouseToCursorSchema();
  671. break;
  672. case ID_POPUP_PCB_EDIT_MIRE:
  673. InstallMireOptionsFrame( (MIREPCB*) GetCurItem(), &dc, pos );
  674. DrawPanel->MouseToCursorSchema();
  675. break;
  676. case ID_POPUP_PCB_DELETE_MIRE:
  677. DrawPanel->MouseToCursorSchema();
  678. Delete_Mire( (MIREPCB*) GetCurItem(), &dc );
  679. SetCurItem( NULL );
  680. break;
  681. case ID_POPUP_PCB_DELETE_DIMENSION:
  682. DrawPanel->MouseToCursorSchema();
  683. Delete_Dimension( (DIMENSION*) GetCurItem(), &dc );
  684. SetCurItem( NULL );
  685. break;
  686. case ID_POPUP_PCB_EDIT_DIMENSION:
  687. Install_Edit_Dimension( (DIMENSION*) GetCurItem(), &dc, pos );
  688. DrawPanel->MouseToCursorSchema();
  689. break;
  690. case ID_POPUP_PCB_DELETE_DRAWING:
  691. Delete_Segment_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
  692. DrawPanel->MouseToCursorSchema();
  693. break;
  694. case ID_POPUP_PCB_DELETE_MARKER:
  695. RemoveStruct( GetCurItem(), &dc );
  696. DrawPanel->MouseToCursorSchema();
  697. break;
  698. case ID_POPUP_PCB_GETINFO_MARKER:
  699. if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER_PCB )
  700. ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
  701. DrawPanel->MouseToCursorSchema();
  702. break;
  703. case ID_POPUP_PCB_DELETE_DRAWING_LAYER:
  704. if( GetCurItem()->m_Flags != 0 )
  705. break;
  706. Delete_Drawings_All_Layer( GetCurItem()->GetLayer() );
  707. SetCurItem( NULL );
  708. DrawPanel->MouseToCursorSchema();
  709. DrawPanel->Refresh();
  710. break;
  711. case ID_POPUP_PCB_EDIT_DRAWING:
  712. InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) GetCurItem(), &dc );
  713. DrawPanel->MouseToCursorSchema();
  714. break;
  715. case ID_POPUP_PCB_MOVE_DRAWING_REQUEST:
  716. DrawPanel->MouseToCursorSchema();
  717. Start_Move_DrawItem( (DRAWSEGMENT*) GetCurItem(), &dc );
  718. break;
  719. case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
  720. DrawPanel->MouseToCursorSchema();
  721. if( GetCurItem() && (GetCurItem()->m_Flags & IS_NEW) )
  722. {
  723. End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
  724. SetCurItem( NULL );
  725. }
  726. break;
  727. case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
  728. DrawPanel->MouseToCursorSchema();
  729. if( GetCurItem() && (GetCurItem()->m_Flags & IS_NEW) )
  730. {
  731. if( End_Zone( &dc ) )
  732. SetCurItem( NULL );
  733. }
  734. DrawPanel->m_AutoPAN_Request = false;
  735. break;
  736. case ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER:
  737. DrawPanel->MouseToCursorSchema();
  738. if( GetCurItem() && (GetCurItem()->m_Flags & IS_NEW) )
  739. {
  740. if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
  741. SetCurItem( NULL );
  742. }
  743. break;
  744. case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
  745. DrawPanel->MouseToCursorSchema();
  746. Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(),
  747. &dc, id );
  748. break;
  749. case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
  750. case ID_POPUP_PCB_MOVE_TRACK_NODE:
  751. DrawPanel->MouseToCursorSchema();
  752. Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(),
  753. &dc, id );
  754. break;
  755. case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE:
  756. DrawPanel->MouseToCursorSchema();
  757. Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->GetCurItem(),
  758. &dc );
  759. break;
  760. case ID_POPUP_PCB_BREAK_TRACK:
  761. DrawPanel->MouseToCursorSchema();
  762. {
  763. TRACK* track = (TRACK*) GetScreen()->GetCurItem();
  764. wxPoint pos = GetScreen()->m_Curseur;
  765. track->Draw( DrawPanel, &dc, GR_XOR );
  766. PICKED_ITEMS_LIST itemsListPicker;
  767. TRACK* newtrack = CreateLockPoint( pos, track, NULL, &itemsListPicker);
  768. SaveCopyInUndoList(itemsListPicker,UR_UNSPECIFIED);
  769. track->Draw( DrawPanel, &dc, GR_XOR );
  770. newtrack->Draw( DrawPanel, &dc, GR_XOR );
  771. }
  772. break;
  773. case ID_MENU_PCB_CLEAN:
  774. Clean_Pcb( &dc );
  775. break;
  776. case ID_MENU_PCB_SWAP_LAYERS:
  777. Swap_Layers( event );
  778. break;
  779. case ID_PCB_USER_GRID_SETUP:
  780. InstallGridFrame( pos );
  781. break;
  782. case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC:
  783. {
  784. wxConfig* cfg = wxGetApp().m_EDA_CommonConfig;
  785. cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
  786. GetAssociatedDocument( this, g_DocModulesFileName, &wxGetApp().GetLibraryPathList() );
  787. }
  788. break;
  789. case ID_MENU_ARCHIVE_NEW_MODULES:
  790. Archive_Modules( wxEmptyString, true );
  791. break;
  792. case ID_MENU_ARCHIVE_ALL_MODULES:
  793. Archive_Modules( wxEmptyString, false );
  794. break;
  795. default:
  796. wxString msg;
  797. msg.Printf(
  798. wxT( "WinEDA_PcbFrame::Process_Special_Functions() id %d error" ),
  799. DrawStruct->Type() );
  800. DisplayError( this, msg );
  801. break;
  802. }
  803. SetToolbars();
  804. DrawPanel->CursorOn( &dc );
  805. DrawPanel->m_IgnoreMouseEvents = false;
  806. }
  807. static void Process_Move_Item( WinEDA_PcbFrame* frame,
  808. EDA_BaseStruct* DrawStruct, wxDC* DC )
  809. {
  810. if( DrawStruct == NULL )
  811. return;
  812. frame->DrawPanel->MouseToCursorSchema();
  813. switch( DrawStruct->Type() )
  814. {
  815. case TYPE_TEXTE:
  816. frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC );
  817. break;
  818. default:
  819. wxString msg;
  820. msg.Printf(
  821. wxT( "WinEDA_PcbFrame::Move_Item Error: Bad DrawType %d" ),
  822. DrawStruct->Type() );
  823. DisplayError( frame, msg );
  824. break;
  825. }
  826. }
  827. void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
  828. {
  829. if( Item == NULL )
  830. return;
  831. switch( Item->Type() )
  832. {
  833. case TYPE_MODULE:
  834. Delete_Module( (MODULE*) Item, DC, true );
  835. break;
  836. case TYPE_DIMENSION:
  837. Delete_Dimension( (DIMENSION*) Item, DC );
  838. break;
  839. case TYPE_MIRE:
  840. Delete_Mire( (MIREPCB*) Item, DC );
  841. break;
  842. case TYPE_DRAWSEGMENT:
  843. Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
  844. break;
  845. case TYPE_TEXTE:
  846. Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
  847. break;
  848. case TYPE_TRACK:
  849. Delete_Track( DC, (TRACK*) Item );
  850. break;
  851. case TYPE_VIA:
  852. Delete_Segment( DC, (TRACK*) Item );
  853. break;
  854. case TYPE_ZONE:
  855. Delete_Zone_Fill( (SEGZONE*) Item );
  856. break;
  857. case TYPE_ZONE_EDGE_CORNER:
  858. Remove_Zone_Corner( DC, (ZONE_CONTAINER*) Item );
  859. SetCurItem( NULL );
  860. break;
  861. case TYPE_ZONE_CONTAINER:
  862. {
  863. SetCurItem( NULL );
  864. int netcode = ( (ZONE_CONTAINER*) Item )->GetNet();
  865. Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
  866. test_1_net_connexion( NULL, netcode );
  867. GetBoard()->DisplayInfo( this );
  868. }
  869. break;
  870. case TYPE_MARKER_PCB:
  871. if( Item == GetCurItem() )
  872. SetCurItem( NULL );
  873. ( (MARKER_PCB*) Item )->Draw( DrawPanel, DC, GR_XOR );
  874. // delete the marker, and free memory. Don't use undo stack.
  875. GetBoard()->Delete( Item );
  876. break;
  877. case TYPE_PAD:
  878. case TYPE_TEXTE_MODULE:
  879. case TYPE_EDGE_MODULE:
  880. break;
  881. case TYPE_NOT_INIT:
  882. case TYPE_PCB:
  883. default:
  884. {
  885. wxString Line;
  886. Line.Printf( wxT( "Remove: item type %d unknown." ),
  887. Item->Type() );
  888. DisplayError( this, Line );
  889. }
  890. break;
  891. }
  892. }
  893. void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
  894. {
  895. int curLayer = getActiveLayer();
  896. // Check if the specified layer matches the present layer
  897. if( layer == curLayer )
  898. return;
  899. // Copper layers cannot be selected unconditionally; how many
  900. // of those layers are currently enabled needs to be checked.
  901. if( IsValidCopperLayerIndex( layer ) )
  902. {
  903. // If only one copper layer is enabled, the only such layer
  904. // that can be selected to is the "Back" layer (so the
  905. // selection of any other copper layer is disregarded).
  906. if( GetBoard()->GetCopperLayerCount() < 2 )
  907. {
  908. if( layer != LAYER_N_BACK )
  909. {
  910. // Uncomment following command (and line 17) to beep
  911. // the speaker. (Doing that would provide feedback to
  912. // the user that the (layer-switching) command has been
  913. // "acknowledged", but is unable to be acted upon.)
  914. // wxBell();
  915. return;
  916. }
  917. }
  918. // If more than one copper layer is enabled, the "Copper"
  919. // and "Component" layers can be selected, but the total
  920. // number of copper layers determines which internal
  921. // layers are also capable of being selected.
  922. else
  923. {
  924. if( ( layer != LAYER_N_BACK ) && ( layer != LAYER_N_FRONT )
  925. && ( layer >= GetBoard()->GetCopperLayerCount() - 1 ) )
  926. {
  927. // Uncomment following command (and line 17) to beep
  928. // the speaker. (Doing that would provide feedback to
  929. // the user that the (layer-switching) command has been
  930. // "acknowledged", but is unable to be acted upon.)
  931. // wxBell();
  932. return;
  933. }
  934. }
  935. EDA_BaseStruct* current = GetScreen()->GetCurItem();
  936. // See if we are drawing a segment; if so, add a via?
  937. if( m_ID_current_state == ID_TRACK_BUTT && current != NULL )
  938. {
  939. if( current->Type() == TYPE_TRACK && ( current->m_Flags & IS_NEW ) )
  940. {
  941. // Want to set the routing layers so that it switches properly -
  942. // see the implementation of Other_Layer_Route - the working
  943. // layer is used to 'start' the via and set the layer masks appropriately.
  944. GetScreen()->m_Route_Layer_TOP = curLayer;
  945. GetScreen()->m_Route_Layer_BOTTOM = layer;
  946. setActiveLayer( curLayer );
  947. if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
  948. {
  949. if( DisplayOpt.ContrastModeDisplay )
  950. GetScreen()->SetRefreshReq();
  951. }
  952. // if the via was allowed by DRC, then the layer swap has already
  953. // been done by Other_Layer_Route(). if via not allowed, then
  954. // return now so assignment to setActiveLayer() below doesn't happen.
  955. return;
  956. }
  957. }
  958. }
  959. // Is yet more checking required? E.g. when the layer to be selected
  960. // is a non-copper layer, or when switching between a copper layer
  961. // and a non-copper layer, or vice-versa?
  962. // ...
  963. setActiveLayer( layer );
  964. if( DisplayOpt.ContrastModeDisplay )
  965. GetScreen()->SetRefreshReq();
  966. }