kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #07271
[PATCH] - PCBNEW - Undo for autoplacer
Hello,
I have added an undo functionality to PCBNEW when the autoplacer is used
either on a single (Auto place module) or multiple components (Auto place
all modules, Auto place new modules, Auto place next module).
Basically, an PICKED_ITEMS_LIST is populated through an ITEM_PICKER with
only the items that are marked with MODULE_to_PLACE by the autoplacer.
The list is then given to SaveCopyInUndoList to be added to the undo list.
I will probably try to do the same for the autorouter and the move all/move
new modules.
--
Guillaume Simard
=== modified file 'pcbnew/autoplac.cpp'
--- pcbnew/autoplac.cpp 2011-12-06 08:35:13 +0000
+++ pcbnew/autoplac.cpp 2011-12-12 02:19:47 +0000
@@ -109,6 +109,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;
@@ -175,8 +180,15 @@
{
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;
case PLACE_OUT_OF_BOARD:
@@ -186,7 +198,14 @@
break;
if( !bbbox.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;
@@ -196,6 +215,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;
@@ -207,7 +231,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;
}
@@ -224,6 +255,10 @@
}
}
+ // Undo: commit
+ if( newList.GetCount() )
+ SaveCopyInUndoList( newList, UR_CHANGED );
+
activ = 0;
Pas = 100.0;
Follow ups