kicad/kicad-2012.01.19-undo-redo-auto.rev3297.patch

177 lines
5.2 KiB
Diff

diff -ru kicad-2012.01.19-2.rev3256/pcbnew/automove.cpp kicad-2012.01.19-3.rev3256/pcbnew/automove.cpp
--- kicad-2012.01.19-2.rev3256/pcbnew/automove.cpp 2012-01-22 17:23:38.000000000 +0100
+++ kicad-2012.01.19-3.rev3256/pcbnew/automove.cpp 2012-01-27 15:38:42.000000000 +0100
@@ -17,7 +17,8 @@
#include "pcbnew_id.h"
#include "class_board.h"
#include "class_module.h"
-
+
+extern BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem );
typedef enum {
FIXE_MODULE,
@@ -185,6 +186,11 @@
bool edgesExists;
double surface;
+ // Undo: init list
+ PICKED_ITEMS_LIST newList;
+ newList.m_Status = UR_CHANGED;
+ ITEM_PICKER picker( NULL, UR_CHANGED );
+
if( GetBoard()->m_Modules == NULL )
{
DisplayError( this, _( "No modules found!" ) );
@@ -262,6 +268,10 @@
continue;
}
+ // Undo: add copy of old Module to undo
+ picker.m_Link = DuplicateStruct( Module );
+ picker.m_PickedItemType = Module->Type();
+
if( current.x > (Xsize_allowed + start.x) )
{
current.x = start.x;
@@ -276,9 +286,17 @@
PlaceModule( Module, NULL, true );
+ // Undo: add new Module to undo
+ picker.m_PickedItem = Module;
+ newList.PushItem( picker );
+
current.x += Module->m_BoundaryBox.GetWidth() + pas_grille;
}
+ // Undo: commit
+ if( newList.GetCount() )
+ SaveCopyInUndoList( newList, UR_CHANGED );
+
DrawPanel->Refresh();
}
diff -ru kicad-2012.01.19-2.rev3256/pcbnew/autoplac.cpp kicad-2012.01.19-3.rev3256/pcbnew/autoplac.cpp
--- kicad-2012.01.19-2.rev3256/pcbnew/autoplac.cpp 2012-01-22 17:23:38.000000000 +0100
+++ kicad-2012.01.19-3.rev3256/pcbnew/autoplac.cpp 2012-01-27 15:49:37.000000000 +0100
@@ -106,6 +106,11 @@
float Pas;
int lay_tmp_TOP, lay_tmp_BOTTOM;
+ // Undo: init list
+ PICKED_ITEMS_LIST newList;
+ newList.m_Status = UR_CHANGED;
+ ITEM_PICKER picker( NULL, UR_CHANGED );
+
if( GetBoard()->m_Modules == NULL )
return;
@@ -172,7 +177,14 @@
{
case PLACE_1_MODULE:
if( ThisModule == Module )
+ {
+ // Module will be placed, add to undo.
+ picker.m_PickedItem = ThisModule;
+ picker.m_PickedItemType = ThisModule->Type();
+ newList.PushItem( picker );
+
Module->m_ModuleStatus |= MODULE_to_PLACE;
+ }
break;
@@ -183,7 +195,14 @@
break;
if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
+ {
+ // Module will be placed, add to undo.
+ picker.m_PickedItem = Module;
+ picker.m_PickedItemType = Module->Type();
+ newList.PushItem( picker );
+
Module->m_ModuleStatus |= MODULE_to_PLACE;
+ }
break;
@@ -193,6 +212,11 @@
if( Module->m_ModuleStatus & MODULE_is_LOCKED )
break;
+ // Module will be placed, add to undo.
+ picker.m_PickedItem = Module;
+ picker.m_PickedItemType = Module->Type();
+ newList.PushItem( picker );
+
Module->m_ModuleStatus |= MODULE_to_PLACE;
break;
@@ -204,7 +228,14 @@
}
if( !(Module->m_ModuleStatus & MODULE_is_PLACED) )
+ {
+ // Module will be placed, add to undo.
+ picker.m_PickedItem = Module;
+ picker.m_PickedItemType = Module->Type();
+ newList.PushItem( picker );
+
Module->m_ModuleStatus |= MODULE_to_PLACE;
+ }
break;
}
@@ -221,6 +252,10 @@
}
}
+ // Undo: commit
+ if( newList.GetCount() )
+ SaveCopyInUndoList( newList, UR_CHANGED );
+
activ = 0;
Pas = 100.0;
diff -ru kicad-2012.01.19-2.rev3256/pcbnew/solve.cpp kicad-2012.01.19-3.rev3256/pcbnew/solve.cpp
--- kicad-2012.01.19-2.rev3256/pcbnew/solve.cpp 2012-01-22 17:23:38.000000000 +0100
+++ kicad-2012.01.19-3.rev3256/pcbnew/solve.cpp 2012-01-27 16:08:23.000000000 +0100
@@ -79,6 +79,7 @@
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 +273,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 +379,9 @@
DrawPanel->m_AbortEnable = false;
+ SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
+ s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
+
return SUCCESS;
}
@@ -1324,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 );
}