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.

669 lines
22 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2016 CERN
  7. * Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
  8. * @author Maciej Suminski <maciej.suminski@cern.ch>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, you may find one here:
  22. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  23. * or you may search the http://www.gnu.org website for the version 2 license,
  24. * or you may write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  26. */
  27. #include <functional>
  28. using namespace std::placeholders;
  29. #include <macros.h>
  30. #include <pcb_edit_frame.h>
  31. #include <pcb_track.h>
  32. #include <pcb_group.h>
  33. #include <pcb_generator.h>
  34. #include <pcb_target.h>
  35. #include <footprint.h>
  36. #include <pad.h>
  37. #include <origin_viewitem.h>
  38. #include <connectivity/connectivity_data.h>
  39. #include <tool/tool_manager.h>
  40. #include <tool/actions.h>
  41. #include <tools/pcb_selection_tool.h>
  42. #include <tools/pcb_control.h>
  43. #include <tools/board_editor_control.h>
  44. #include <board_commit.h>
  45. #include <drawing_sheet/ds_proxy_undo_item.h>
  46. #include <wx/msgdlg.h>
  47. /* Functions to undo and redo edit commands.
  48. * commands to undo are stored in CurrentScreen->m_UndoList
  49. * commands to redo are stored in CurrentScreen->m_RedoList
  50. *
  51. * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
  52. * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
  53. * that store the list of schematic items that are concerned by the command to undo or redo
  54. * and is created for each command to undo (handle also a command to redo).
  55. * each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or
  56. * modified),
  57. * and has a pointer to a copy of this item, when this item has been modified
  58. * (the old values of parameters are therefore saved)
  59. *
  60. * there are 3 cases:
  61. * - delete item(s) command
  62. * - change item(s) command
  63. * - add item(s) command
  64. *
  65. * Undo command
  66. * - delete item(s) command:
  67. * => deleted items are moved in undo list
  68. *
  69. * - change item(s) command
  70. * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
  71. * the .m_Link member of each wrapper points the modified item.
  72. * the .m_Item member of each wrapper points the old copy of this item.
  73. *
  74. * - add item(s) command
  75. * =>A list of item(s) is made. The .m_Item member of each wrapper points the new item.
  76. *
  77. * Redo command
  78. * - delete item(s) old command:
  79. * => deleted items are moved in EEDrawList list, and in
  80. *
  81. * - change item(s) command
  82. * => the copy of item(s) is moved in Undo list
  83. *
  84. * - add item(s) command
  85. * => The list of item(s) is used to create a deleted list in undo list(same as a delete
  86. * command)
  87. *
  88. * Some block operations that change items can be undone without memorize items, just the
  89. * coordinates of the transform:
  90. * move list of items (undo/redo is made by moving with the opposite move vector)
  91. * mirror (Y) and flip list of items (undo/redo is made by mirror or flip items)
  92. * so they are handled specifically.
  93. *
  94. */
  95. void PCB_BASE_EDIT_FRAME::saveCopyInUndoList( PICKED_ITEMS_LIST* commandToUndo,
  96. const PICKED_ITEMS_LIST& aItemsList,
  97. UNDO_REDO aCommandType )
  98. {
  99. int preExisting = commandToUndo->GetCount();
  100. for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
  101. commandToUndo->PushItem( aItemsList.GetItemWrapper(ii) );
  102. for( unsigned ii = preExisting; ii < commandToUndo->GetCount(); ii++ )
  103. {
  104. EDA_ITEM* item = commandToUndo->GetPickedItem( ii );
  105. UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
  106. if( command == UNDO_REDO::UNSPECIFIED )
  107. {
  108. command = aCommandType;
  109. commandToUndo->SetPickedItemStatus( command, ii );
  110. }
  111. wxASSERT( item );
  112. switch( command )
  113. {
  114. case UNDO_REDO::CHANGED:
  115. case UNDO_REDO::DRILLORIGIN:
  116. case UNDO_REDO::GRIDORIGIN:
  117. // If we don't yet have a copy in the link, set one up
  118. if( !commandToUndo->GetPickedItemLink( ii ) )
  119. commandToUndo->SetPickedItemLink( BOARD_COMMIT::MakeImage( item ), ii );
  120. break;
  121. case UNDO_REDO::NEWITEM:
  122. case UNDO_REDO::DELETED:
  123. case UNDO_REDO::PAGESETTINGS:
  124. case UNDO_REDO::REGROUP:
  125. case UNDO_REDO::UNGROUP:
  126. break;
  127. default:
  128. wxFAIL_MSG( wxString::Format( wxT( "Unrecognized undo command: %X" ), command ) );
  129. break;
  130. }
  131. }
  132. if( commandToUndo->GetCount() )
  133. {
  134. /* Save the copy in undo list */
  135. PushCommandToUndoList( commandToUndo );
  136. /* Clear redo list, because after a new command one cannot redo a command */
  137. ClearUndoORRedoList( REDO_LIST );
  138. }
  139. else
  140. {
  141. // Should not occur
  142. wxASSERT( false );
  143. delete commandToUndo;
  144. }
  145. }
  146. void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aCommandType )
  147. {
  148. PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
  149. PICKED_ITEMS_LIST itemsList;
  150. itemsList.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) );
  151. saveCopyInUndoList( commandToUndo, itemsList, aCommandType );
  152. }
  153. void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
  154. UNDO_REDO aCommandType )
  155. {
  156. PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
  157. commandToUndo->SetDescription( aItemsList.GetDescription() );
  158. saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
  159. }
  160. void PCB_BASE_EDIT_FRAME::AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList,
  161. UNDO_REDO aCommandType )
  162. {
  163. PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList();
  164. if( !commandToUndo )
  165. {
  166. commandToUndo = new PICKED_ITEMS_LIST();
  167. commandToUndo->SetDescription( aItemsList.GetDescription() );
  168. }
  169. saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
  170. }
  171. void PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent )
  172. {
  173. if( UndoRedoBlocked() )
  174. return;
  175. if( GetUndoCommandCount() <= 0 )
  176. return;
  177. // Inform tools that undo command was issued
  178. m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } );
  179. // Get the old list
  180. PICKED_ITEMS_LIST* list = PopCommandFromUndoList();
  181. // Undo the command
  182. PutDataInPreviousState( list );
  183. // Put the old list in RedoList
  184. list->ReversePickersListOrder();
  185. PushCommandToRedoList( list );
  186. OnModify();
  187. m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_POST, AS_GLOBAL } );
  188. m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
  189. GetCanvas()->Refresh();
  190. }
  191. void PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent )
  192. {
  193. if( UndoRedoBlocked() )
  194. return;
  195. if( GetRedoCommandCount() == 0 )
  196. return;
  197. // Inform tools that redo command was issued
  198. m_toolManager->ProcessEvent( EVENTS::UndoRedoPreEvent );
  199. // Get the old list
  200. PICKED_ITEMS_LIST* list = PopCommandFromRedoList();
  201. // Redo the command
  202. PutDataInPreviousState( list );
  203. // Put the old list in UndoList
  204. list->ReversePickersListOrder();
  205. PushCommandToUndoList( list );
  206. OnModify();
  207. m_toolManager->ProcessEvent( EVENTS::UndoRedoPostEvent );
  208. m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
  209. GetCanvas()->Refresh();
  210. }
  211. void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
  212. {
  213. bool not_found = false;
  214. bool reBuild_ratsnest = false;
  215. bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
  216. bool solder_mask_dirty = false;
  217. auto view = GetCanvas()->GetView();
  218. auto connectivity = GetBoard()->GetConnectivity();
  219. GetBoard()->IncrementTimeStamp(); // clear caches
  220. // Enum to track the modification type of items. Used to enable bulk BOARD_LISTENER
  221. // callbacks at the end of the undo / redo operation
  222. enum ITEM_CHANGE_TYPE
  223. {
  224. ADDED,
  225. DELETED,
  226. CHANGED
  227. };
  228. std::unordered_map<EDA_ITEM*, ITEM_CHANGE_TYPE> item_changes;
  229. auto update_item_change_state = [&]( EDA_ITEM* item, ITEM_CHANGE_TYPE change_type )
  230. {
  231. auto item_itr = item_changes.find( item );
  232. if( item_itr == item_changes.end() )
  233. {
  234. // First time we've seen this item - tag the current change type
  235. item_changes.insert( { item, change_type } );
  236. return;
  237. }
  238. // Update the item state based on the current and next change type
  239. switch( item_itr->second )
  240. {
  241. case ITEM_CHANGE_TYPE::ADDED:
  242. {
  243. if( change_type == ITEM_CHANGE_TYPE::DELETED )
  244. {
  245. // The item was previously added, now deleted - as far as bulk callbacks
  246. // are concerned, the item has never existed
  247. item_changes.erase( item_itr );
  248. }
  249. else if( change_type == ITEM_CHANGE_TYPE::ADDED )
  250. {
  251. // Error condition - added an already added item
  252. wxASSERT_MSG( false, wxT( "UndoRedo: should not add already added item" ) );
  253. }
  254. // For all other cases, the item remains as ADDED as seen by the bulk callbacks
  255. break;
  256. }
  257. case ITEM_CHANGE_TYPE::DELETED:
  258. {
  259. // This is an error condition - item has already been deleted so should not
  260. // be operated on further
  261. wxASSERT_MSG( false, wxT( "UndoRedo: should not alter already deleted item" ) );
  262. break;
  263. }
  264. case ITEM_CHANGE_TYPE::CHANGED:
  265. {
  266. if( change_type == ITEM_CHANGE_TYPE::DELETED )
  267. {
  268. item_itr->second = ITEM_CHANGE_TYPE::DELETED;
  269. }
  270. else if( change_type == ITEM_CHANGE_TYPE::ADDED )
  271. {
  272. // This is an error condition - item has already been changed so should not
  273. // be added
  274. wxASSERT_MSG( false,
  275. wxT( "UndoRedo: should not add already changed item" ) );
  276. }
  277. // Otherwise, item remains CHANGED
  278. break;
  279. }
  280. }
  281. };
  282. // Undo in the reverse order of list creation: (this can allow stacked changes
  283. // like the same item can be changes and deleted in the same complex command
  284. // Restore changes in reverse order
  285. for( int ii = (int) aList->GetCount() - 1; ii >= 0 ; ii-- )
  286. {
  287. EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
  288. /* Test for existence of item on board.
  289. * It could be deleted, and no more on board:
  290. * - if a call to SaveCopyInUndoList was forgotten in Pcbnew
  291. * - in zones outlines, when a change in one zone merges this zone with an other
  292. * This test avoids a Pcbnew crash
  293. * Obviously, this test is not made for deleted items
  294. */
  295. UNDO_REDO status = aList->GetPickedItemStatus( ii );
  296. if( status != UNDO_REDO::DELETED
  297. && status != UNDO_REDO::REGROUP
  298. && status != UNDO_REDO::UNGROUP
  299. && status != UNDO_REDO::DRILLORIGIN // origin markers never on board
  300. && status != UNDO_REDO::GRIDORIGIN // origin markers never on board
  301. && status != UNDO_REDO::PAGESETTINGS ) // nor are page settings proxy items
  302. {
  303. if( GetBoard()->GetItem( eda_item->m_Uuid ) == DELETED_BOARD_ITEM::GetInstance() )
  304. {
  305. // Checking if it ever happens
  306. wxASSERT_MSG( false, wxT( "Item in the undo buffer does not exist" ) );
  307. // Remove this non existent item
  308. aList->RemovePicker( ii );
  309. not_found = true;
  310. if( aList->GetCount() == 0 )
  311. break;
  312. continue;
  313. }
  314. }
  315. // see if we must rebuild ratsnets and pointers lists
  316. switch( eda_item->Type() )
  317. {
  318. case PCB_FOOTPRINT_T:
  319. deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
  320. KI_FALLTHROUGH;
  321. case PCB_ZONE_T:
  322. case PCB_TRACE_T:
  323. case PCB_ARC_T:
  324. case PCB_VIA_T:
  325. case PCB_PAD_T:
  326. reBuild_ratsnest = true;
  327. break;
  328. case PCB_NETINFO_T:
  329. reBuild_ratsnest = true;
  330. deep_reBuild_ratsnest = true;
  331. break;
  332. default:
  333. break;
  334. }
  335. switch( eda_item->Type() )
  336. {
  337. case PCB_FOOTPRINT_T:
  338. solder_mask_dirty = true;
  339. break;
  340. case PCB_VIA_T:
  341. solder_mask_dirty = true;
  342. break;
  343. case PCB_ZONE_T:
  344. case PCB_TRACE_T:
  345. case PCB_ARC_T:
  346. case PCB_PAD_T:
  347. case PCB_SHAPE_T:
  348. {
  349. LSET layers = static_cast<BOARD_ITEM*>( eda_item )->GetLayerSet();
  350. if( layers.test( F_Mask ) || layers.test( B_Mask ) )
  351. solder_mask_dirty = true;
  352. break;
  353. }
  354. default:
  355. break;
  356. }
  357. switch( aList->GetPickedItemStatus( ii ) )
  358. {
  359. case UNDO_REDO::CHANGED: /* Exchange old and new data for each item */
  360. {
  361. BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
  362. BOARD_ITEM_CONTAINER* parent = GetBoard();
  363. PCB_GROUP* parentGroup = item->GetParentGroup();
  364. if( item->GetParentFootprint() )
  365. {
  366. // We need the current item and it's parent, which may be different from what
  367. // was stored if we're multiple frames up the undo stack.
  368. item = GetBoard()->GetItem( item->m_Uuid );
  369. parent = item->GetParentFootprint();
  370. }
  371. BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
  372. view->Remove( item );
  373. if( parentGroup )
  374. parentGroup->RemoveItem( item );
  375. parent->Remove( item );
  376. item->SwapItemData( image );
  377. item->ClearFlags( UR_TRANSIENT );
  378. image->SetFlags( UR_TRANSIENT );
  379. if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( item ) )
  380. {
  381. group->RunOnChildren( [&]( BOARD_ITEM* child )
  382. {
  383. child->SetParentGroup( group );
  384. } );
  385. }
  386. view->Add( item );
  387. view->Hide( item, false );
  388. parent->Add( item );
  389. if( parentGroup )
  390. parentGroup->AddItem( item );
  391. update_item_change_state( item, ITEM_CHANGE_TYPE::CHANGED );
  392. break;
  393. }
  394. case UNDO_REDO::NEWITEM: /* new items are deleted */
  395. aList->SetPickedItemStatus( UNDO_REDO::DELETED, ii );
  396. GetModel()->Remove( (BOARD_ITEM*) eda_item, REMOVE_MODE::BULK );
  397. update_item_change_state( eda_item, ITEM_CHANGE_TYPE::DELETED );
  398. if( eda_item->Type() != PCB_NETINFO_T )
  399. view->Remove( eda_item );
  400. eda_item->SetFlags( UR_TRANSIENT );
  401. break;
  402. case UNDO_REDO::DELETED: /* deleted items are put in List, as new items */
  403. aList->SetPickedItemStatus( UNDO_REDO::NEWITEM, ii );
  404. eda_item->ClearFlags( UR_TRANSIENT );
  405. GetModel()->Add( (BOARD_ITEM*) eda_item, ADD_MODE::BULK_APPEND );
  406. update_item_change_state( eda_item, ITEM_CHANGE_TYPE::ADDED );
  407. if( eda_item->Type() != PCB_NETINFO_T )
  408. view->Add( eda_item );
  409. break;
  410. case UNDO_REDO::REGROUP: /* grouped items are ungrouped */
  411. aList->SetPickedItemStatus( UNDO_REDO::UNGROUP, ii );
  412. if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( eda_item ) )
  413. {
  414. if( PCB_GROUP* group = boardItem->GetParentGroup() )
  415. {
  416. aList->SetPickedItemGroupId( group->m_Uuid, ii );
  417. group->RemoveItem( boardItem );
  418. }
  419. }
  420. break;
  421. case UNDO_REDO::UNGROUP: /* ungrouped items are re-added to their previuos groups */
  422. aList->SetPickedItemStatus( UNDO_REDO::REGROUP, ii );
  423. if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( eda_item ) )
  424. {
  425. PCB_GROUP* group = dynamic_cast<PCB_GROUP*>(
  426. GetBoard()->GetItem( aList->GetPickedItemGroupId( ii ) ) );
  427. if( group )
  428. group->AddItem( boardItem );
  429. }
  430. break;
  431. case UNDO_REDO::DRILLORIGIN:
  432. case UNDO_REDO::GRIDORIGIN:
  433. {
  434. // Warning: DRILLORIGIN and GRIDORIGIN undo/redo command create EDA_ITEMs
  435. // that cannot be casted to BOARD_ITEMs
  436. EDA_ITEM* image = aList->GetPickedItemLink( ii );
  437. VECTOR2D origin = image->GetPosition();
  438. image->SetPosition( eda_item->GetPosition() );
  439. if( aList->GetPickedItemStatus( ii ) == UNDO_REDO::DRILLORIGIN )
  440. BOARD_EDITOR_CONTROL::DoSetDrillOrigin( view, this, eda_item, origin );
  441. else
  442. PCB_CONTROL::DoSetGridOrigin( view, this, eda_item, origin );
  443. break;
  444. }
  445. case UNDO_REDO::PAGESETTINGS:
  446. {
  447. // swap current settings with stored settings
  448. DS_PROXY_UNDO_ITEM alt_item( this );
  449. DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
  450. item->Restore( this );
  451. *item = std::move( alt_item );
  452. break;
  453. }
  454. default:
  455. wxFAIL_MSG( wxString::Format( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
  456. aList->GetPickedItemStatus( ii ) ) );
  457. break;
  458. }
  459. }
  460. if( not_found )
  461. wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) );
  462. if( IsType( FRAME_PCB_EDITOR ) )
  463. {
  464. if( reBuild_ratsnest || deep_reBuild_ratsnest )
  465. {
  466. // Connectivity may have changed; rebuild internal caches to remove stale items
  467. GetBoard()->BuildConnectivity();
  468. Compile_Ratsnest( false );
  469. }
  470. if( solder_mask_dirty )
  471. HideSolderMask();
  472. }
  473. PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
  474. selTool->RebuildSelection();
  475. GetBoard()->SanitizeNetcodes();
  476. // Invoke bulk BOARD_LISTENER callbacks
  477. std::vector<BOARD_ITEM*> added_items, deleted_items, changed_items;
  478. for( auto& item_itr : item_changes )
  479. {
  480. switch( item_itr.second )
  481. {
  482. case ITEM_CHANGE_TYPE::ADDED:
  483. {
  484. added_items.push_back( static_cast<BOARD_ITEM*>( item_itr.first ) );
  485. break;
  486. }
  487. case ITEM_CHANGE_TYPE::DELETED:
  488. {
  489. deleted_items.push_back( static_cast<BOARD_ITEM*>( item_itr.first ) );
  490. break;
  491. }
  492. case ITEM_CHANGE_TYPE::CHANGED:
  493. {
  494. changed_items.push_back( static_cast<BOARD_ITEM*>( item_itr.first ) );
  495. break;
  496. }
  497. }
  498. }
  499. if( added_items.size() > 0 || deleted_items.size() > 0 || changed_items.size() > 0 )
  500. GetBoard()->OnItemsCompositeUpdate( added_items, deleted_items, changed_items );
  501. }
  502. void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
  503. {
  504. if( aItemCount == 0 )
  505. return;
  506. UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
  507. if( aItemCount < 0 )
  508. {
  509. list.ClearCommandList();
  510. }
  511. else
  512. {
  513. for( int ii = 0; ii < aItemCount; ii++ )
  514. {
  515. if( list.m_CommandsList.size() == 0 )
  516. break;
  517. PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
  518. list.m_CommandsList.erase( list.m_CommandsList.begin() );
  519. ClearListAndDeleteItems( curr_cmd );
  520. delete curr_cmd; // Delete command
  521. }
  522. }
  523. }
  524. void PCB_BASE_EDIT_FRAME::ClearListAndDeleteItems( PICKED_ITEMS_LIST* aList )
  525. {
  526. aList->ClearListAndDeleteItems(
  527. []( EDA_ITEM* item )
  528. {
  529. wxASSERT_MSG( item->HasFlag( UR_TRANSIENT ),
  530. "Item on undo/redo list not owned by undo/redo!" );
  531. if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
  532. boardItem->SetParentGroup( nullptr );
  533. delete item;
  534. } );
  535. }
  536. void PCB_BASE_EDIT_FRAME::RollbackFromUndo()
  537. {
  538. PICKED_ITEMS_LIST* undo = PopCommandFromUndoList();
  539. PutDataInPreviousState( undo );
  540. ClearListAndDeleteItems( undo );
  541. delete undo;
  542. GetCanvas()->Refresh();
  543. }