Eeschema: fixed: bad undo/redo for Drag commands
This commit is contained in:
parent
ab74cfeda8
commit
b6e8c338c5
|
@ -36,6 +36,7 @@ ITEM_PICKER::ITEM_PICKER( EDA_BaseStruct* aItem, UndoRedoOpType aUndoRedoStatus
|
||||||
m_UndoRedoStatus = aUndoRedoStatus;
|
m_UndoRedoStatus = aUndoRedoStatus;
|
||||||
m_PickedItem = aItem;
|
m_PickedItem = aItem;
|
||||||
m_PickedItemType = TYPE_NOT_INIT;
|
m_PickedItemType = TYPE_NOT_INIT;
|
||||||
|
m_PickerFlags = 0;
|
||||||
m_Link = NULL;
|
m_Link = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,6 +217,18 @@ UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
|
||||||
return UR_UNSPECIFIED;
|
return UR_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** function GetPickerFlags
|
||||||
|
* return the value of the picker flag
|
||||||
|
* @param aIdx = index of the picker in the picked list
|
||||||
|
* @return the value stored in the picker, if the picker exists, or 0 if does not exist
|
||||||
|
*/
|
||||||
|
int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
|
||||||
|
{
|
||||||
|
if( aIdx < m_ItemsList.size() )
|
||||||
|
return m_ItemsList[aIdx].m_PickerFlags;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** function SetPickedItem
|
/** function SetPickedItem
|
||||||
* @param aItem = a pointer to the item to pick
|
* @param aItem = a pointer to the item to pick
|
||||||
|
@ -289,6 +302,22 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aI
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/** function SetPickerFlags
|
||||||
|
* Set the flags of the picker (usually to the picked item m_Flags value)
|
||||||
|
* @param aFlags = the value to save in picker
|
||||||
|
* @param aIdx = index of the picker in the picked list
|
||||||
|
* @return true if the picker exists, or false if does not exist
|
||||||
|
*/
|
||||||
|
bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx )
|
||||||
|
{
|
||||||
|
if( aIdx < m_ItemsList.size() )
|
||||||
|
{
|
||||||
|
m_ItemsList[aIdx].m_PickerFlags = aFlags;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** function RemovePicker
|
/** function RemovePicker
|
||||||
|
|
|
@ -241,7 +241,6 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
|
||||||
|
|
||||||
case BLOCK_DRAG: /* Drag */
|
case BLOCK_DRAG: /* Drag */
|
||||||
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
|
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
|
||||||
|
|
||||||
case BLOCK_MOVE: /* Move */
|
case BLOCK_MOVE: /* Move */
|
||||||
case BLOCK_COPY: /* Copy */
|
case BLOCK_COPY: /* Copy */
|
||||||
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
|
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
|
||||||
|
@ -584,8 +583,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
|
||||||
{
|
{
|
||||||
SCH_ITEM* Struct;
|
SCH_ITEM* Struct;
|
||||||
EDA_DrawLineStruct* SegmStruct;
|
EDA_DrawLineStruct* SegmStruct;
|
||||||
int ox, oy, fx, fy;
|
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
|
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
|
||||||
|
|
||||||
if( pickedlist->GetCount() == 0 )
|
if( pickedlist->GetCount() == 0 )
|
||||||
|
@ -609,7 +607,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
||||||
Struct->m_Flags = SELECTED;
|
Struct->m_Flags = SELECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,16 +615,6 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
|
||||||
if( screen->m_BlockLocate.m_Command != BLOCK_DRAG )
|
if( screen->m_BlockLocate.m_Command != BLOCK_DRAG )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ox = screen->m_BlockLocate.GetX();
|
|
||||||
oy = screen->m_BlockLocate.GetY();
|
|
||||||
fx = screen->m_BlockLocate.GetRight();
|
|
||||||
fy = screen->m_BlockLocate.GetBottom();
|
|
||||||
|
|
||||||
if( fx < ox )
|
|
||||||
EXCHG( fx, ox );
|
|
||||||
if( fy < oy )
|
|
||||||
EXCHG( fy, oy );
|
|
||||||
|
|
||||||
|
|
||||||
/* Suppression du deplacement des extremites de segments hors cadre
|
/* Suppression du deplacement des extremites de segments hors cadre
|
||||||
* de selection */
|
* de selection */
|
||||||
|
@ -636,13 +624,15 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
|
||||||
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
||||||
{
|
{
|
||||||
SegmStruct = (EDA_DrawLineStruct*) Struct;
|
SegmStruct = (EDA_DrawLineStruct*) Struct;
|
||||||
if( (SegmStruct->m_Start.x < ox) || (SegmStruct->m_Start.x > fx)
|
if( ! screen->m_BlockLocate.Inside(SegmStruct->m_Start) )
|
||||||
|| (SegmStruct->m_Start.y < oy) || (SegmStruct->m_Start.y > fy) )
|
|
||||||
SegmStruct->m_Flags |= STARTPOINT;
|
SegmStruct->m_Flags |= STARTPOINT;
|
||||||
|
|
||||||
if( (SegmStruct->m_End.x < ox) || (SegmStruct->m_End.x > fx)
|
if( ! screen->m_BlockLocate.Inside(SegmStruct->m_End) )
|
||||||
|| (SegmStruct->m_End.y < oy) || (SegmStruct->m_End.y > fy) )
|
|
||||||
SegmStruct->m_Flags |= ENDPOINT;
|
SegmStruct->m_Flags |= ENDPOINT;
|
||||||
|
|
||||||
|
// Save m_Flags for Undo/redo drag operations:
|
||||||
|
pickedlist->SetPickerFlags(SegmStruct->m_Flags, ii);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +650,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
|
||||||
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
|
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
|
||||||
while( DrawItem )
|
while( DrawItem )
|
||||||
{
|
{
|
||||||
if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) )
|
if( ! screen->m_BlockLocate.Inside(pos) )
|
||||||
{
|
{
|
||||||
// This pin is outside area,
|
// This pin is outside area,
|
||||||
// but because it it the pin of a selected component
|
// but because it it the pin of a selected component
|
||||||
|
@ -724,6 +714,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
|
||||||
|
|
||||||
if( STRUCT->m_End == position )
|
if( STRUCT->m_End == position )
|
||||||
STRUCT->m_Flags &= ~ENDPOINT;
|
STRUCT->m_Flags &= ~ENDPOINT;
|
||||||
|
|
||||||
|
// Save m_Flags for Undo/redo drag operations:
|
||||||
|
pickedlist->SetPickerFlags(STRUCT->m_Flags, ii);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -768,12 +761,16 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
|
||||||
{
|
{
|
||||||
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
||||||
Struct->m_Flags &= ~STARTPOINT;
|
Struct->m_Flags &= ~STARTPOINT;
|
||||||
|
// Save m_Flags for Undo/redo drag operations:
|
||||||
|
picker.m_PickerFlags= Struct->m_Flags;
|
||||||
pickedlist->PushItem( picker );
|
pickedlist->PushItem( picker );
|
||||||
}
|
}
|
||||||
else if( STRUCT->m_End == position )
|
else if( STRUCT->m_End == position )
|
||||||
{
|
{
|
||||||
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
||||||
Struct->m_Flags &= ~ENDPOINT;
|
Struct->m_Flags &= ~ENDPOINT;
|
||||||
|
// Save m_Flags for Undo/redo drag operations:
|
||||||
|
picker.m_PickerFlags= Struct->m_Flags;
|
||||||
pickedlist->PushItem( picker );
|
pickedlist->PushItem( picker );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -223,7 +223,10 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
|
||||||
|
|
||||||
ITEM_PICKER itemWrapper( aItem, aCommandType );
|
ITEM_PICKER itemWrapper( aItem, aCommandType );
|
||||||
if( aItem )
|
if( aItem )
|
||||||
|
{
|
||||||
itemWrapper.m_PickedItemType = aItem->Type();
|
itemWrapper.m_PickedItemType = aItem->Type();
|
||||||
|
itemWrapper.m_PickerFlags = aItem->m_Flags;
|
||||||
|
}
|
||||||
|
|
||||||
switch( aCommandType )
|
switch( aCommandType )
|
||||||
{
|
{
|
||||||
|
@ -368,7 +371,9 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bo
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UR_MOVED:
|
case UR_MOVED:
|
||||||
|
item->m_Flags = aList->GetPickerFlags(ii);
|
||||||
item->Move( aRedoCommand ? aList->m_TransformPoint : - aList->m_TransformPoint );
|
item->Move( aRedoCommand ? aList->m_TransformPoint : - aList->m_TransformPoint );
|
||||||
|
item->m_Flags = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UR_MIRRORED_Y:
|
case UR_MIRRORED_Y:
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
*/
|
*/
|
||||||
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. usefull in mode/drag undo/redo commands */
|
||||||
EDA_BaseStruct* m_Link; /* Pointer on an other item. Used in undo redo command
|
EDA_BaseStruct* m_Link; /* Pointer on an other item. Used in undo redo command
|
||||||
* used when a duplicate exists i.e. when an item is modified,
|
* used when a duplicate exists i.e. when an item is modified,
|
||||||
* and the copy of initial item exists (the duplicate)
|
* and the copy of initial item exists (the duplicate)
|
||||||
|
@ -174,6 +175,13 @@ public:
|
||||||
*/
|
*/
|
||||||
UndoRedoOpType GetPickedItemStatus( unsigned int aIdx );
|
UndoRedoOpType GetPickedItemStatus( unsigned int aIdx );
|
||||||
|
|
||||||
|
/** function GetPickerFlags
|
||||||
|
* return the value of the picker flag
|
||||||
|
* @param aIdx = index of the picker in the picked list
|
||||||
|
* @return the value stored in the picker, if the picker exists, or 0 if does not exist
|
||||||
|
*/
|
||||||
|
int GetPickerFlags( unsigned aIdx );
|
||||||
|
|
||||||
/** function SetPickedItem
|
/** function SetPickedItem
|
||||||
* @param aItem = a pointer to the item to pick
|
* @param aItem = a pointer to the item to pick
|
||||||
* @param aIdx = index of the picker in the picked list
|
* @param aIdx = index of the picker in the picked list
|
||||||
|
@ -198,13 +206,21 @@ public:
|
||||||
bool SetPickedItemLink( EDA_BaseStruct* aLink, unsigned aIdx );
|
bool SetPickedItemLink( EDA_BaseStruct* aLink, unsigned aIdx );
|
||||||
|
|
||||||
/** function SetPickedItemStatus
|
/** function SetPickedItemStatus
|
||||||
* Set the the type of undo/redo operation for a given picked item
|
* Set the type of undo/redo operation for a given picked item
|
||||||
* @param aStatus = the type of undo/redo operation associated to the picked item
|
* @param aStatus = the type of undo/redo operation associated to the picked item
|
||||||
* @param aIdx = index of the picker in the picked list
|
* @param aIdx = index of the picker in the picked list
|
||||||
* @return true if the picker exists, or false if does not exist
|
* @return true if the picker exists, or false if does not exist
|
||||||
*/
|
*/
|
||||||
bool SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx );
|
bool SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx );
|
||||||
|
|
||||||
|
/** function SetPickerFlags
|
||||||
|
* Set the flags of the picker (usually to the picked item m_Flags value)
|
||||||
|
* @param aFlags = the value to save in picker
|
||||||
|
* @param aIdx = index of the picker in the picked list
|
||||||
|
* @return true if the picker exists, or false if does not exist
|
||||||
|
*/
|
||||||
|
bool SetPickerFlags( int aFlags, unsigned aIdx );
|
||||||
|
|
||||||
/** function RemovePicker
|
/** function RemovePicker
|
||||||
* remove one entry (one picker) from the list of picked items
|
* remove one entry (one picker) from the list of picked items
|
||||||
* @param aIdx = index of the picker in the picked list
|
* @param aIdx = index of the picker in the picked list
|
||||||
|
|
Loading…
Reference in New Issue