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.

1157 lines
37 KiB

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