Commit 08ef7417 authored by jean-pierre charras's avatar jean-pierre charras

Undo redo change and code cleanup.

parent 8e846082
...@@ -33,11 +33,10 @@ ...@@ -33,11 +33,10 @@
ITEM_PICKER::ITEM_PICKER( EDA_ITEM* aItem, UNDO_REDO_T aUndoRedoStatus ) ITEM_PICKER::ITEM_PICKER( EDA_ITEM* aItem, UNDO_REDO_T aUndoRedoStatus )
{ {
m_UndoRedoStatus = aUndoRedoStatus; m_undoRedoStatus = aUndoRedoStatus;
m_PickedItem = aItem; SetItem( aItem );
m_PickedItemType = TYPE_NOT_INIT; m_pickerFlags = 0;
m_PickerFlags = 0; m_link = NULL;
m_Link = NULL;
} }
...@@ -75,7 +74,7 @@ bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const ...@@ -75,7 +74,7 @@ bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
{ {
for( size_t i = 0; i < m_ItemsList.size(); i++ ) for( size_t i = 0; i < m_ItemsList.size(); i++ )
{ {
if( m_ItemsList[ i ].m_PickedItem == aItem ) if( m_ItemsList[ i ].GetItem() == aItem )
return true; return true;
} }
...@@ -97,9 +96,9 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -97,9 +96,9 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
while( GetCount() > 0 ) while( GetCount() > 0 )
{ {
ITEM_PICKER wrapper = PopItem(); ITEM_PICKER wrapper = PopItem();
if( wrapper.m_PickedItem == NULL ) // No more item in list. if( wrapper.GetItem() == NULL ) // No more item in list.
break; break;
switch( wrapper.m_UndoRedoStatus ) switch( wrapper.GetStatus() )
{ {
case UR_UNSPECIFIED: case UR_UNSPECIFIED:
if( show_error_message ) if( show_error_message )
...@@ -112,7 +111,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -112,7 +111,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
{ {
// Specific to eeschema: a linked list of wires is stored. The wrapper picks only // Specific to eeschema: a linked list of wires is stored. The wrapper picks only
// the first item (head of list), and is owner of all picked items. // the first item (head of list), and is owner of all picked items.
EDA_ITEM* item = wrapper.m_PickedItem; EDA_ITEM* item = wrapper.GetItem();
while( item ) while( item )
{ {
...@@ -135,7 +134,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -135,7 +134,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
case UR_CHANGED: case UR_CHANGED:
case UR_EXCHANGE_T: case UR_EXCHANGE_T:
delete wrapper.m_Link; // the picker is owner of this item delete wrapper.GetLink(); // the picker is owner of this item
break; break;
case UR_DELETED: // the picker is owner of this item case UR_DELETED: // the picker is owner of this item
...@@ -146,12 +145,12 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -146,12 +145,12 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
* copy of the current module when changed), * copy of the current module when changed),
* and the picker is owner of this item * and the picker is owner of this item
*/ */
delete wrapper.m_PickedItem; delete wrapper.GetItem();
break; break;
default: default:
wxFAIL_MSG( wxString::Format( wxT( "Cannot clear unknown undo/redo command %d" ), wxFAIL_MSG( wxString::Format( wxT( "Cannot clear unknown undo/redo command %d" ),
wrapper.m_UndoRedoStatus ) ); wrapper.GetStatus() ) );
break; break;
} }
} }
...@@ -172,7 +171,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) ...@@ -172,7 +171,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].m_PickedItem; return m_ItemsList[aIdx].GetItem();
else else
return NULL; return NULL;
} }
...@@ -181,7 +180,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) ...@@ -181,7 +180,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].m_Link; return m_ItemsList[aIdx].GetLink();
else else
return NULL; return NULL;
} }
...@@ -190,7 +189,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) ...@@ -190,7 +189,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].m_UndoRedoStatus; return m_ItemsList[aIdx].GetStatus();
else else
return UR_UNSPECIFIED; return UR_UNSPECIFIED;
} }
...@@ -199,7 +198,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) ...@@ -199,7 +198,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].m_PickerFlags; return m_ItemsList[aIdx].GetFlags();
else else
return 0; return 0;
} }
...@@ -209,7 +208,7 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx ) ...@@ -209,7 +208,7 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
m_ItemsList[aIdx].m_PickedItem = aItem; m_ItemsList[aIdx].SetItem( aItem );
return true; return true;
} }
else else
...@@ -221,7 +220,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx ) ...@@ -221,7 +220,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
m_ItemsList[aIdx].m_Link = aLink; m_ItemsList[aIdx].SetLink( aLink );
return true; return true;
} }
else else
...@@ -233,8 +232,8 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UNDO_REDO_T aStatus, uns ...@@ -233,8 +232,8 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UNDO_REDO_T aStatus, uns
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
m_ItemsList[aIdx].m_PickedItem = aItem; m_ItemsList[aIdx].SetItem( aItem );
m_ItemsList[aIdx].m_UndoRedoStatus = aStatus; m_ItemsList[aIdx].SetStatus( aStatus );
return true; return true;
} }
else else
...@@ -246,7 +245,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO_T aStatus, unsigned aIdx ...@@ -246,7 +245,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO_T aStatus, unsigned aIdx
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
m_ItemsList[aIdx].m_UndoRedoStatus = aStatus; m_ItemsList[aIdx].SetStatus( aStatus );
return true; return true;
} }
else else
...@@ -258,7 +257,7 @@ bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx ) ...@@ -258,7 +257,7 @@ bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
m_ItemsList[aIdx].m_PickerFlags = aFlags; m_ItemsList[aIdx].SetFlags( aFlags );
return true; return true;
} }
else else
......
...@@ -263,12 +263,12 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) ...@@ -263,12 +263,12 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
} }
// Prepare undo command for delete old text // Prepare undo command for delete old text
picker.m_UndoRedoStatus = UR_DELETED; picker.SetStatus( UR_DELETED );
picker.SetLink( NULL ); picker.SetLink( NULL );
pickList.PushItem( picker ); pickList.PushItem( picker );
// Prepare undo command for new text // Prepare undo command for new text
picker.m_UndoRedoStatus = UR_NEW; picker.SetStatus( UR_NEW );
picker.SetItem(newtext); picker.SetItem(newtext);
pickList.PushItem( picker ); pickList.PushItem( picker );
......
...@@ -48,7 +48,7 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) ...@@ -48,7 +48,7 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
lastcmd = GetScreen()->PopCommandFromRedoList(); lastcmd = GetScreen()->PopCommandFromRedoList();
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
m_component = (LIB_COMPONENT*) wrapper.m_PickedItem; m_component = (LIB_COMPONENT*) wrapper.GetItem();
if( m_component == NULL ) if( m_component == NULL )
return; return;
...@@ -84,7 +84,7 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) ...@@ -84,7 +84,7 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
lastcmd = GetScreen()->PopCommandFromUndoList(); lastcmd = GetScreen()->PopCommandFromUndoList();
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
m_component = (LIB_COMPONENT*) wrapper.m_PickedItem; m_component = (LIB_COMPONENT*) wrapper.GetItem();
if( m_component == NULL ) if( m_component == NULL )
return; return;
......
...@@ -872,7 +872,6 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position ) ...@@ -872,7 +872,6 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = GetDrawItems(); item != NULL; item = item->Next() )
{ {
picker.SetItem( item ); picker.SetItem( item );
picker.SetItemType( item->Type() );
if( !item->IsConnectable() || !item->IsConnected( position ) if( !item->IsConnectable() || !item->IsConnected( position )
|| (item->GetFlags() & SKIP_STRUCT) ) || (item->GetFlags() & SKIP_STRUCT) )
...@@ -901,7 +900,7 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position ) ...@@ -901,7 +900,7 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
if( addinlist ) if( addinlist )
{ {
picker.m_PickerFlags = item->GetFlags(); picker.SetFlags( item->GetFlags() );
m_BlockLocate.m_ItemsSelection.PushItem( picker ); m_BlockLocate.m_ItemsSelection.PushItem( picker );
} }
} }
...@@ -922,7 +921,6 @@ int SCH_SCREEN::UpdatePickList() ...@@ -922,7 +921,6 @@ int SCH_SCREEN::UpdatePickList()
if( item->HitTest( area ) ) if( item->HitTest( area ) )
{ {
picker.SetItem( item ); picker.SetItem( item );
picker.SetItemType( item->Type() );
m_BlockLocate.PushItem( picker ); m_BlockLocate.PushItem( picker );
} }
} }
......
...@@ -121,25 +121,19 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem, ...@@ -121,25 +121,19 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
if( aItem == NULL && ( aCommandType != UR_WIRE_IMAGE ) ) if( aItem == NULL && ( aCommandType != UR_WIRE_IMAGE ) )
return; return;
SCH_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
ITEM_PICKER itemWrapper( aItem, aCommandType ); ITEM_PICKER itemWrapper( aItem, aCommandType );
if( aItem ) if( aItem )
{ itemWrapper.SetFlags( aItem->GetFlags() );
itemWrapper.m_PickedItemType = aItem->Type();
itemWrapper.m_PickerFlags = aItem->GetFlags();
}
switch( aCommandType ) switch( aCommandType )
{ {
case UR_CHANGED: /* Create a copy of item */ case UR_CHANGED: /* Create a copy of item */
CopyOfItem = DuplicateStruct( aItem, true ); itemWrapper.SetLink( DuplicateStruct( aItem, true ) );
itemWrapper.m_Link = CopyOfItem; commandToUndo->PushItem( itemWrapper );
if( CopyOfItem )
commandToUndo->PushItem( itemWrapper );
break; break;
case UR_NEW: case UR_NEW:
......
...@@ -80,18 +80,16 @@ enum UNDO_REDO_T { ...@@ -80,18 +80,16 @@ enum UNDO_REDO_T {
class ITEM_PICKER class ITEM_PICKER
{ {
friend class PICKED_ITEMS_LIST; private:
int m_pickerFlags; /* a copy of m_Flags member. useful in mode/drag
public: * undo/redo commands */
UNDO_REDO_T m_UndoRedoStatus; /* type of operation to undo/redo for this item */ UNDO_REDO_T m_undoRedoStatus; /* type of operation to undo/redo for this item */
EDA_ITEM* m_PickedItem; /* Pointer on the schematic or board item that is concerned EDA_ITEM* m_pickedItem; /* Pointer on the schematic or board item that is concerned
* (picked), or in undo redo commands, the copy of an * (picked), or in undo redo commands, the copy of an
* edited item. */ * edited item. */
KICAD_T m_PickedItemType; /* type of schematic or board item that is concerned */ KICAD_T m_pickedItemType; /* type of schematic or board item that is concerned */
int m_PickerFlags; /* a copy of m_Flags member. useful in mode/drag EDA_ITEM* m_link; /* Pointer on an other item. Used in undo redo command
* undo/redo commands */
EDA_ITEM* m_Link; /* Pointer on an other item. Used in undo redo command
* used when a duplicate exists i.e. when an item is * used when a duplicate exists i.e. when an item is
* modified, and the copy of initial item exists (the * modified, and the copy of initial item exists (the
* duplicate) m_Item points the duplicate (i.e the old * duplicate) m_Item points the duplicate (i.e the old
...@@ -101,19 +99,27 @@ public: ...@@ -101,19 +99,27 @@ public:
public: public:
ITEM_PICKER( EDA_ITEM* aItem = NULL, UNDO_REDO_T aUndoRedoStatus = UR_UNSPECIFIED ); ITEM_PICKER( EDA_ITEM* aItem = NULL, UNDO_REDO_T aUndoRedoStatus = UR_UNSPECIFIED );
EDA_ITEM* GetItem() const { return m_PickedItem; } EDA_ITEM* GetItem() const { return m_pickedItem; }
void SetItem( EDA_ITEM* aItem )
{
m_pickedItem = aItem;
m_pickedItemType = aItem ? aItem->Type() : TYPE_NOT_INIT;
}
KICAD_T GetItemType() const { return m_pickedItemType; }
void SetItem( EDA_ITEM* aItem ) { m_PickedItem = aItem; } void SetStatus( UNDO_REDO_T aStatus ) { m_undoRedoStatus = aStatus; }
KICAD_T GetItemType() const { return m_PickedItemType; } UNDO_REDO_T GetStatus() { return m_undoRedoStatus; }
void SetStatus( UNDO_REDO_T aStatus ) { m_UndoRedoStatus = aStatus; } void SetFlags( int aFlags ) { m_pickerFlags = aFlags; }
void SetItemType( KICAD_T aType ) { m_PickedItemType = aType; } int GetFlags() { return m_pickerFlags; }
void SetLink( EDA_ITEM* aItem ) { m_Link = aItem; } void SetLink( EDA_ITEM* aItem ) { m_link = aItem; }
EDA_ITEM* GetLink() const { return m_Link; } EDA_ITEM* GetLink() const { return m_link; }
}; };
......
...@@ -264,8 +264,8 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) ...@@ -264,8 +264,8 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
} }
// Undo: add copy of old Module to undo // Undo: add copy of old Module to undo
picker.m_Link = Module->Clone(); picker.SetItem( Module );
picker.m_PickedItemType = Module->Type(); picker.SetLink( Module->Clone() );
if( current.x > (Xsize_allowed + start.x) ) if( current.x > (Xsize_allowed + start.x) )
{ {
...@@ -282,7 +282,6 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) ...@@ -282,7 +282,6 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
PlaceModule( Module, NULL, true ); PlaceModule( Module, NULL, true );
// Undo: add new Module to undo // Undo: add new Module to undo
picker.m_PickedItem = Module;
newList.PushItem( picker ); newList.PushItem( picker );
current.x += Module->m_BoundaryBox.GetWidth() + pas_grille; current.x += Module->m_BoundaryBox.GetWidth() + pas_grille;
......
...@@ -181,8 +181,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -181,8 +181,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if( ThisModule == Module ) if( ThisModule == Module )
{ {
// Module will be placed, add to undo. // Module will be placed, add to undo.
picker.m_PickedItem = ThisModule; picker.SetItem( ThisModule );
picker.m_PickedItemType = ThisModule->Type();
newList.PushItem( picker ); newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
...@@ -199,8 +198,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -199,8 +198,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if( !bbbox.Contains( Module->m_Pos ) ) if( !bbbox.Contains( Module->m_Pos ) )
{ {
// Module will be placed, add to undo. // Module will be placed, add to undo.
picker.m_PickedItem = Module; picker.SetItem( Module );
picker.m_PickedItemType = Module->Type();
newList.PushItem( picker ); newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
...@@ -215,8 +213,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -215,8 +213,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
break; break;
// Module will be placed, add to undo. // Module will be placed, add to undo.
picker.m_PickedItem = Module; picker.SetItem( Module );
picker.m_PickedItemType = Module->Type();
newList.PushItem( picker ); newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
...@@ -232,8 +229,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -232,8 +229,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if( !(Module->m_ModuleStatus & MODULE_is_PLACED) ) if( !(Module->m_ModuleStatus & MODULE_is_PLACED) )
{ {
// Module will be placed, add to undo. // Module will be placed, add to undo.
picker.m_PickedItem = Module; picker.SetItem( Module );
picker.m_PickedItemType = Module->Type();
newList.PushItem( picker ); newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
......
...@@ -398,8 +398,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() ...@@ -398,8 +398,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
{ {
if( blockIncludeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) ) if( blockIncludeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) )
{ {
picker.m_PickedItem = module; picker.SetItem ( module );
picker.m_PickedItemType = module->Type();
itemsList->PushItem( picker ); itemsList->PushItem( picker );
} }
} }
...@@ -416,8 +415,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() ...@@ -416,8 +415,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
if( blockIncludeItemsOnInvisibleLayers if( blockIncludeItemsOnInvisibleLayers
|| m_Pcb->IsLayerVisible( pt_segm->GetLayer() ) ) || m_Pcb->IsLayerVisible( pt_segm->GetLayer() ) )
{ {
picker.m_PickedItem = pt_segm; picker.SetItem ( pt_segm );
picker.m_PickedItemType = pt_segm->Type();
itemsList->PushItem( picker ); itemsList->PushItem( picker );
} }
} }
...@@ -486,8 +484,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() ...@@ -486,8 +484,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
if( select_me ) if( select_me )
{ {
picker.m_PickedItem = PtStruct; picker.SetItem ( PtStruct );
picker.m_PickedItemType = PtStruct->Type();
itemsList->PushItem( picker ); itemsList->PushItem( picker );
} }
} }
...@@ -505,8 +502,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() ...@@ -505,8 +502,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|| m_Pcb->IsLayerVisible( area->GetLayer() ) ) || m_Pcb->IsLayerVisible( area->GetLayer() ) )
{ {
BOARD_ITEM* zone_c = (BOARD_ITEM*) area; BOARD_ITEM* zone_c = (BOARD_ITEM*) area;
picker.m_PickedItem = zone_c; picker.SetItem ( zone_c );
picker.m_PickedItemType = zone_c->Type();
itemsList->PushItem( picker ); itemsList->PushItem( picker );
} }
} }
...@@ -854,8 +850,7 @@ void PCB_EDIT_FRAME::Block_Duplicate() ...@@ -854,8 +850,7 @@ void PCB_EDIT_FRAME::Block_Duplicate()
if( newitem ) if( newitem )
{ {
newitem->Move( MoveVector ); newitem->Move( MoveVector );
picker.m_PickedItem = newitem; picker.SetItem ( newitem );
picker.m_PickedItemType = newitem->Type();
newList.PushItem( picker ); newList.PushItem( picker );
} }
} }
......
...@@ -312,17 +312,13 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, ...@@ -312,17 +312,13 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
ITEM_PICKER itemWrapper( aItem, aCommandType ); ITEM_PICKER itemWrapper( aItem, aCommandType );
itemWrapper.m_PickedItemType = aItem->Type();
switch( aCommandType ) switch( aCommandType )
{ {
case UR_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: // Create a copy of item
if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done if( itemWrapper.GetLink() == NULL ) // When not null, the copy is already done
itemWrapper.m_Link = aItem->Clone();; itemWrapper.SetLink( aItem->Clone() );
commandToUndo->PushItem( itemWrapper );
if( itemWrapper.m_Link )
commandToUndo->PushItem( itemWrapper );
break; break;
case UR_NEW: case UR_NEW:
...@@ -466,10 +462,10 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -466,10 +462,10 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
* - if a call to SaveCopyInUndoList was forgotten in Pcbnew * - if a call to SaveCopyInUndoList was forgotten in Pcbnew
* - in zones outlines, when a change in one zone merges this zone with an other * - in zones outlines, when a change in one zone merges this zone with an other
* This test avoids a Pcbnew crash * This test avoids a Pcbnew crash
* the test is made only to avoid crashes, so it is not needed for deleted or new items * Obviouly, this test is not made for deleted items
*/ */
UNDO_REDO_T status = aList->GetPickedItemStatus( ii ); UNDO_REDO_T status = aList->GetPickedItemStatus( ii );
if( status != UR_DELETED && status != UR_NEW ) if( status != UR_DELETED )
{ {
if( build_item_list ) if( build_item_list )
// Build list of existing items, for integrity test // Build list of existing items, for integrity test
......
...@@ -177,8 +177,7 @@ void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack ) ...@@ -177,8 +177,7 @@ void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack )
// redraw the area where the track was // redraw the area where the track was
m_canvas->RefreshDrawingRect( segm->GetBoundingBox() ); m_canvas->RefreshDrawingRect( segm->GetBoundingBox() );
picker.m_PickedItem = segm; picker.SetItem( segm );
picker.m_PickedItemType = segm->Type();
itemsList.PushItem( picker ); itemsList.PushItem( picker );
} }
...@@ -223,8 +222,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) ...@@ -223,8 +222,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
// redraw the area where the track was // redraw the area where the track was
m_canvas->RefreshDrawingRect( tracksegment->GetBoundingBox() ); m_canvas->RefreshDrawingRect( tracksegment->GetBoundingBox() );
picker.m_PickedItem = tracksegment; picker.SetItem( tracksegment );
picker.m_PickedItemType = tracksegment->Type();
itemsList.PushItem( picker ); itemsList.PushItem( picker );
} }
......
...@@ -88,7 +88,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -88,7 +88,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
while( pcb->GetAreaCount() ) while( pcb->GetAreaCount() )
{ {
item = pcb->GetArea( 0 ); item = pcb->GetArea( 0 );
itemPicker.m_PickedItem = item; itemPicker.SetItem( item );
pickersList.PushItem( itemPicker ); pickersList.PushItem( itemPicker );
pcb->Remove( item ); pcb->Remove( item );
} }
...@@ -118,7 +118,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -118,7 +118,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
if( removeme ) if( removeme )
{ {
itemPicker.m_PickedItem = item; itemPicker.SetItem( item );
pickersList.PushItem( itemPicker ); pickersList.PushItem( itemPicker );
item->UnLink(); item->UnLink();
} }
...@@ -131,7 +131,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -131,7 +131,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
for( item = pcb->m_Modules; item; item = nextitem ) for( item = pcb->m_Modules; item; item = nextitem )
{ {
nextitem = item->Next(); nextitem = item->Next();
itemPicker.m_PickedItem = item; itemPicker.SetItem( item );
pickersList.PushItem( itemPicker ); pickersList.PushItem( itemPicker );
item->UnLink(); item->UnLink();
} }
...@@ -165,7 +165,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -165,7 +165,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
if( (track->ReturnMaskLayer() & layers_filter) == 0 ) if( (track->ReturnMaskLayer() & layers_filter) == 0 )
continue; continue;
itemPicker.m_PickedItem = track; itemPicker.SetItem( track );
pickersList.PushItem( itemPicker ); pickersList.PushItem( itemPicker );
track->UnLink(); track->UnLink();
gen_rastnest = true; gen_rastnest = true;
......
...@@ -100,7 +100,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, ...@@ -100,7 +100,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
{ {
aTrackItem->m_Width = initial_width; aTrackItem->m_Width = initial_width;
ITEM_PICKER picker( aTrackItem, UR_CHANGED ); ITEM_PICKER picker( aTrackItem, UR_CHANGED );
picker.m_Link = aTrackItem->Clone(); picker.SetLink( aTrackItem->Clone() );
aItemsListPicker->PushItem( picker ); aItemsListPicker->PushItem( picker );
aTrackItem->m_Width = new_width; aTrackItem->m_Width = new_width;
......
...@@ -173,7 +173,7 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( int aLayer ) ...@@ -173,7 +173,7 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( int aLayer )
if( item->GetLayer() == aLayer ) if( item->GetLayer() == aLayer )
{ {
item->UnLink(); item->UnLink();
picker.m_PickedItem = item; picker.SetItem( item );
pickList.PushItem( picker ); pickList.PushItem( picker );
} }
......
...@@ -366,14 +366,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) ...@@ -366,14 +366,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
PICKED_ITEMS_LIST undoItemList; PICKED_ITEMS_LIST undoItemList;
unsigned int ii; unsigned int ii;
itemWrapper.m_PickedItemType = PCB_MODULE_T;
module = GetBoard()->m_Modules; module = GetBoard()->m_Modules;
// Prepare undo list // Prepare undo list
while( module ) while( module )
{ {
itemWrapper.m_PickedItem = module; itemWrapper.SetItem( module );
switch( aType ) switch( aType )
{ {
...@@ -388,7 +386,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) ...@@ -388,7 +386,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
case TEXT_is_VALUE: case TEXT_is_VALUE:
item = module->m_Value; item = module->m_Value;
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
undoItemList.PushItem( itemWrapper ); undoItemList.PushItem( itemWrapper );
break; break;
......
...@@ -265,7 +265,6 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad, ...@@ -265,7 +265,6 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
if( saveMe ) if( saveMe )
{ {
ITEM_PICKER itemWrapper( Module, UR_CHANGED ); ITEM_PICKER itemWrapper( Module, UR_CHANGED );
itemWrapper.m_PickedItemType = Module->Type();
itemsList.PushItem( itemWrapper ); itemsList.PushItem( itemWrapper );
} }
} }
......
...@@ -63,7 +63,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) ...@@ -63,7 +63,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
// Retrieve last module state from undo list // Retrieve last module state from undo list
lastcmd = GetScreen()->PopCommandFromRedoList(); lastcmd = GetScreen()->PopCommandFromRedoList();
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
module = (MODULE *)wrapper.m_PickedItem; module = (MODULE *)wrapper.GetItem();
delete lastcmd; delete lastcmd;
if( module ) if( module )
...@@ -91,7 +91,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) ...@@ -91,7 +91,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
// Retrieve last module state from undo list // Retrieve last module state from undo list
lastcmd = GetScreen()->PopCommandFromUndoList(); lastcmd = GetScreen()->PopCommandFromUndoList();
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
module = (MODULE *)wrapper.m_PickedItem; module = (MODULE *)wrapper.GetItem();
delete lastcmd; delete lastcmd;
if( module ) if( module )
......
...@@ -121,9 +121,9 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC ) ...@@ -121,9 +121,9 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{ {
TRACK* segm = g_DragSegmentList[ii].m_Segm; TRACK* segm = g_DragSegmentList[ii].m_Segm;
itemWrapper.m_PickedItem = segm; itemWrapper.SetItem( segm );
itemWrapper.m_Link = segm->Clone(); itemWrapper.SetLink( segm->Clone() );
itemWrapper.m_Link->SetState( IN_EDIT, OFF ); itemWrapper.GetLink()->SetState( IN_EDIT, OFF );
s_PickedList.PushItem( itemWrapper ); s_PickedList.PushItem( itemWrapper );
} }
} }
...@@ -376,7 +376,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat ...@@ -376,7 +376,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat
else if( aModule->IsMoving() ) else if( aModule->IsMoving() )
{ {
ITEM_PICKER picker( aModule, UR_CHANGED ); ITEM_PICKER picker( aModule, UR_CHANGED );
picker.m_Link = s_ModuleInitialCopy; picker.SetLink( s_ModuleInitialCopy );
s_PickedList.PushItem( picker ); s_PickedList.PushItem( picker );
s_ModuleInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy. s_ModuleInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy.
} }
......
...@@ -320,7 +320,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -320,7 +320,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
if( g_DragSegmentList[ii].m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad_OldPos; Track->m_End = Pad_OldPos;
picker.m_PickedItem = Track; picker.SetItem( Track );
pickList.PushItem( picker ); pickList.PushItem( picker );
} }
...@@ -333,7 +333,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -333,7 +333,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
SaveCopyInUndoList( Module, UR_CHANGED ); SaveCopyInUndoList( Module, UR_CHANGED );
else else
{ {
picker.m_PickedItem = Module; picker.SetItem( Module );
pickList.PushItem( picker ); pickList.PushItem( picker );
SaveCopyInUndoList( pickList, UR_CHANGED ); SaveCopyInUndoList( pickList, UR_CHANGED );
} }
......
...@@ -758,16 +758,16 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC ...@@ -758,16 +758,16 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC
// Prepare the Undo command // Prepare the Undo command
ITEM_PICKER picker( aTrack, UR_CHANGED ); ITEM_PICKER picker( aTrack, UR_CHANGED );
picker.m_Link = aTrack->Clone(); picker.SetLink( aTrack->Clone() );
s_ItemsListPicker.PushItem( picker ); s_ItemsListPicker.PushItem( picker );
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{ {
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
picker.m_PickedItem = draggedtrack; picker.SetItem( draggedtrack );
picker.m_Link = draggedtrack->Clone(); picker.SetLink( draggedtrack->Clone() );
s_ItemsListPicker.PushItem( picker ); s_ItemsListPicker.PushItem( picker );
draggedtrack = (TRACK*) picker.m_Link; draggedtrack = (TRACK*) picker.GetLink();
draggedtrack->SetStatus( 0 ); draggedtrack->SetStatus( 0 );
draggedtrack->ClearFlags(); draggedtrack->ClearFlags();
} }
...@@ -979,10 +979,10 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -979,10 +979,10 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{ {
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
picker.m_PickedItem = draggedtrack; picker.SetItem( draggedtrack);
picker.m_Link = draggedtrack->Clone(); picker.SetLink ( draggedtrack->Clone() );
s_ItemsListPicker.PushItem( picker ); s_ItemsListPicker.PushItem( picker );
draggedtrack = (TRACK*) picker.m_Link; draggedtrack = (TRACK*) picker.GetLink();
draggedtrack->SetStatus( 0 ); draggedtrack->SetStatus( 0 );
draggedtrack->ClearFlags(); draggedtrack->ClearFlags();
} }
......
...@@ -549,11 +549,12 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -549,11 +549,12 @@ void DIALOG_PLOT::applyPlotSettings()
{ {
msg = ReturnStringFromValue( g_UserUnit, m_PSWidthAdjust, PCB_INTERNAL_UNIT ); msg = ReturnStringFromValue( g_UserUnit, m_PSWidthAdjust, PCB_INTERNAL_UNIT );
m_PSFineAdjustWidthOpt->SetValue( msg ); m_PSFineAdjustWidthOpt->SetValue( msg );
msg.Printf( _( "Width correction constrained!\nThe reasonable width correction value must be in a range of [%+f; %+f]" ), msg.Printf( _( "Width correction constrained!\n"
"The reasonable width correction value must be in a range of\n"
" [%+f; %+f] (%s) for current design rules!\n" ),
To_User_Unit( g_UserUnit, m_WidthAdjustMinValue, PCB_INTERNAL_UNIT ), To_User_Unit( g_UserUnit, m_WidthAdjustMinValue, PCB_INTERNAL_UNIT ),
To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue, PCB_INTERNAL_UNIT ) ); To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue, PCB_INTERNAL_UNIT ),
msg += ( g_UserUnit == INCHES )? _(" (\")") : _(" (mm)"); ( g_UserUnit == INCHES )? wxT("\"") : wxT("mm") );
msg += _( " for current design rules!\n" );
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
} }
......
...@@ -137,9 +137,8 @@ int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, in ...@@ -137,9 +137,8 @@ int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, in
ZONE_CONTAINER* zoneDup = new ZONE_CONTAINER( *zone ); ZONE_CONTAINER* zoneDup = new ZONE_CONTAINER( *zone );
zoneDup->SetParent( aPcb ); zoneDup->SetParent( aPcb );
ITEM_PICKER picker( zone, UR_CHANGED ); ITEM_PICKER picker( zone, UR_CHANGED );
picker.m_Link = zoneDup; picker.SetLink( zoneDup );
picker.m_PickedItemType = zone->Type();
aPickList.PushItem( picker ); aPickList.PushItem( picker );
copyCount++; copyCount++;
} }
......
...@@ -44,7 +44,6 @@ ZONE_CONTAINER* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, ...@@ -44,7 +44,6 @@ ZONE_CONTAINER* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
if( aNewZonesList ) if( aNewZonesList )
{ {
ITEM_PICKER picker( new_area, UR_NEW ); ITEM_PICKER picker( new_area, UR_NEW );
picker.m_PickedItemType = new_area->Type();
aNewZonesList->PushItem( picker ); aNewZonesList->PushItem( picker );
} }
return new_area; return new_area;
...@@ -66,7 +65,6 @@ void BOARD::RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to ...@@ -66,7 +65,6 @@ void BOARD::RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to
if( aDeletedList ) if( aDeletedList )
{ {
ITEM_PICKER picker( area_to_remove, UR_DELETED ); ITEM_PICKER picker( area_to_remove, UR_DELETED );
picker.m_PickedItemType = area_to_remove->Type();
aDeletedList->PushItem( picker ); aDeletedList->PushItem( picker );
Remove( area_to_remove ); // remove from zone list, but does not delete it Remove( area_to_remove ); // remove from zone list, but does not delete it
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment