← Back to team overview

kicad-developers team mailing list archive

[PATCH] - PCBNEW - undo for autorouter

 

Hello,

In this series of patches regarding Bug #577618 "Impossible to undo
track and module mode actions in PCBnew", here is what should be the
last one.

This one adds undo functionality to the autorouter.

For this fix, I have followed the undo mechanism from file
"editrack.pcb" and have done quite the same in "solve.cpp".

With these 3 patches taken together, that bug should be closed
whenever my proposed fixes are verified and hopefully confirmed to be
well behaved.

Good night,
Guillaume
=== modified file 'pcbnew/solve.cpp'
--- pcbnew/solve.cpp	2011-12-10 05:33:24 +0000
+++ pcbnew/solve.cpp	2011-12-13 05:09:35 +0000
@@ -79,6 +79,8 @@
 static int            Ncurrent;     /* measures of progress */
 static int            s_Clearance;  // Clearance value used in autorouter
 
+static PICKED_ITEMS_LIST s_ItemsListPicker;
+
 
 #define NOSUCCESS       0
 #define STOP_FROM_ESC   -1
@@ -272,6 +274,9 @@
 
     Ncurrent = 0;
 
+    // Prepare the undo command info
+    s_ItemsListPicker.ClearListAndDeleteItems();  // Should not be necessary, but...
+
     /* go until no more work to do */
     GetWork( &row_source, &col_source, &current_net_code,
              &row_target, &col_target, &pt_cur_ch ); // First net to route.
@@ -375,6 +380,9 @@
 
     DrawPanel->m_AbortEnable = false;
 
+    SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
+    s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
+
     return SUCCESS;
 }
 
@@ -1323,6 +1331,8 @@
 
     while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
     {
+        ITEM_PICKER picker( track, UR_NEW );
+        s_ItemsListPicker.PushItem( picker );
         pcbframe->GetBoard()->m_Track.Insert( track, insertBeforeMe );
     }