Commit 83be1f8a authored by charras's avatar charras

Rework on undo/redo and block functions: more efficient code to undo/redo...

Rework on undo/redo and block functions: more efficient code to undo/redo block move and mirror operations
parent daceb2e0
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
PICKED_ITEMS_LIST::PICKED_ITEMS_LIST() PICKED_ITEMS_LIST::PICKED_ITEMS_LIST()
{ {
m_UndoRedoType = 0; m_Status = UR_UNSPECIFIED;
}; };
PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST() PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()
...@@ -102,12 +102,12 @@ EDA_BaseStruct* PICKED_ITEMS_LIST::GetImage( unsigned int aIdx ) ...@@ -102,12 +102,12 @@ EDA_BaseStruct* PICKED_ITEMS_LIST::GetImage( unsigned int aIdx )
} }
int PICKED_ITEMS_LIST::GetItemStatus( unsigned int aIdx ) UndoRedoOpType PICKED_ITEMS_LIST::GetItemStatus( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].m_UndoRedoStatus; return m_ItemsList[aIdx].m_UndoRedoStatus;
else else
return 0; return UR_UNSPECIFIED;
} }
...@@ -135,7 +135,7 @@ bool PICKED_ITEMS_LIST::SetLink( EDA_BaseStruct* aItem, unsigned aIdx ) ...@@ -135,7 +135,7 @@ bool PICKED_ITEMS_LIST::SetLink( EDA_BaseStruct* aItem, unsigned aIdx )
} }
bool PICKED_ITEMS_LIST::SetItem( EDA_BaseStruct* aItem, int aStatus, unsigned aIdx ) bool PICKED_ITEMS_LIST::SetItem( EDA_BaseStruct* aItem, UndoRedoOpType aStatus, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
...@@ -148,7 +148,7 @@ bool PICKED_ITEMS_LIST::SetItem( EDA_BaseStruct* aItem, int aStatus, unsigned aI ...@@ -148,7 +148,7 @@ bool PICKED_ITEMS_LIST::SetItem( EDA_BaseStruct* aItem, int aStatus, unsigned aI
} }
bool PICKED_ITEMS_LIST::SetItemStatus( int aStatus, unsigned aIdx ) bool PICKED_ITEMS_LIST::SetItemStatus( UndoRedoOpType aStatus, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
......
...@@ -45,7 +45,7 @@ void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -45,7 +45,7 @@ void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop! if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop!
screen->AddToDrawList( this ); screen->AddToDrawList( this );
g_ItemToRepeat = this; g_ItemToRepeat = this;
frame->SaveCopyInUndoList( this, IS_NEW ); frame->SaveCopyInUndoList( this, UR_NEW );
} }
m_Flags = 0; m_Flags = 0;
......
...@@ -73,6 +73,7 @@ set(EESCHEMA_SRCS ...@@ -73,6 +73,7 @@ set(EESCHEMA_SRCS
erc.cpp erc.cpp
files-io.cpp files-io.cpp
find.cpp find.cpp
geometric_transforms.cpp
getpart.cpp getpart.cpp
hierarch.cpp hierarch.cpp
hotkeys.cpp hotkeys.cpp
......
...@@ -14,20 +14,23 @@ ...@@ -14,20 +14,23 @@
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h"
/* Variables Locales */ /* Variables Locales */
// Imported functions:
void MoveItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center );
/* Fonctions exportees */ /* Fonctions exportees */
void DeleteItemsInList( WinEDA_DrawPanel* panel, void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList ); PICKED_ITEMS_LIST& aItemsList );
/* Fonctions Locales */ /* Fonctions Locales */
static void PlaceItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList ); static void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
static void MoveListOfItems( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
static void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList );
static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
...@@ -37,9 +40,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, ...@@ -37,9 +40,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
bool erase ); bool erase );
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ); static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
static void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
static void MirrorOneStruct( SCH_ITEM* DrawStruct,
wxPoint& Center );
/*************************************************************************/ /*************************************************************************/
int WinEDA_SchematicFrame::ReturnBlockCommand( int key ) int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
...@@ -138,9 +138,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -138,9 +138,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
SaveCopyInUndoList( block->m_ItemsSelection, IS_CHANGED ); SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector );
MoveListOfItems( GetScreen(), block->m_ItemsSelection ); MoveItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
block->ClearItemsList(); block->ClearItemsList();
break; break;
...@@ -149,10 +149,10 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -149,10 +149,10 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
CopyItemsInList( GetScreen(), block->m_ItemsSelection ); DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
SaveCopyInUndoList( block->m_ItemsSelection, SaveCopyInUndoList( block->m_ItemsSelection,
(block->m_Command == BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW ); (block->m_Command == BLOCK_PRESELECT_MOVE) ? UR_CHANGED : UR_NEW );
block->ClearItemsList(); block->ClearItemsList();
break; break;
...@@ -285,11 +285,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -285,11 +285,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->GetCount() ) if( block->GetCount() )
{ {
wxPoint oldpos = GetScreen()->m_Curseur; wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
SaveStructListForPaste( block->m_ItemsSelection ); SaveStructListForPaste( block->m_ItemsSelection );
PlaceItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection ); MoveItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection, move_vector);
GetScreen()->m_Curseur = oldpos;
ii = -1; ii = -1;
} }
block->ClearItemsList(); block->ClearItemsList();
...@@ -409,11 +407,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -409,11 +407,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() ) if( block->GetCount() )
{ {
wxPoint oldpos = GetScreen()->m_Curseur; wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
SaveStructListForPaste( block->m_ItemsSelection ); SaveStructListForPaste( block->m_ItemsSelection );
PlaceItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection ); MoveItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection, move_vector );
GetScreen()->m_Curseur = oldpos;
ii = -1; ii = -1;
} }
break; break;
...@@ -435,13 +431,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -435,13 +431,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() ) if( block->GetCount() )
{ {
SaveCopyInUndoList( block->m_ItemsSelection, IS_CHANGED );
ii = -1; ii = -1;
/* Compute the mirror centre and put it on grid */ /* Compute the mirror centre and put it on grid */
wxPoint Center = block->Centre(); wxPoint mirrorPoint = block->Centre();
PutOnGrid( &Center ); PutOnGrid( &mirrorPoint );
MirrorListOfItems( block->m_ItemsSelection, Center ); SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint );
MirrorListOfItems( block->m_ItemsSelection, mirrorPoint );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
...@@ -487,9 +482,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -487,9 +482,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii ); schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii );
DrawStructsInGhost( panel, DC, schitem, DrawStructsInGhost( panel, DC, schitem, block->m_MoveVector );
block->m_MoveVector.x,
block->m_MoveVector.y );
} }
} }
...@@ -502,202 +495,14 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -502,202 +495,14 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii ); schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii );
DrawStructsInGhost( panel, DC, schitem, DrawStructsInGhost( panel, DC, schitem, block->m_MoveVector );
block->m_MoveVector.x,
block->m_MoveVector.y );
} }
} }
/*****************************************************************************
* Routine to move objects to a new position. *
*****************************************************************************/
void MoveListOfItems( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList )
{
PlaceItemsInList( aScreen, aItemsList ); /* Place it in its new position. */
}
static void MirrorYPoint( wxPoint& point, wxPoint& Center )
{
point.x -= Center.x;
NEGATE( point.x );
point.x += Center.x;
}
/**************************************************************/
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
/**************************************************************/
/* Given a structure rotate it to 90 degrees refer to the Center point.
*/
{
int dx;
DrawPolylineStruct* DrawPoly;
DrawJunctionStruct* DrawConnect;
EDA_DrawLineStruct* DrawSegment;
DrawBusEntryStruct* DrawRaccord;
SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
MARKER_SCH* DrawMarker;
DrawNoConnectStruct* DrawNoConnect;
SCH_TEXT* DrawText;
wxPoint px;
WinEDA_SchematicFrame* frame;
if( !DrawStruct )
return;
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
switch( DrawStruct->Type() )
{
case TYPE_NOT_INIT:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
DrawPoly = (DrawPolylineStruct*) DrawStruct;
for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
{
wxPoint point;
point = DrawPoly->m_PolyPoints[ii];
MirrorYPoint( point, Center );
DrawPoly->m_PolyPoints[ii] = point;
}
break;
case DRAW_SEGMENT_STRUCT_TYPE:
DrawSegment = (EDA_DrawLineStruct*) DrawStruct;
if( (DrawSegment->m_Flags & STARTPOINT) == 0 )
{
MirrorYPoint( DrawSegment->m_Start, Center );
}
if( (DrawSegment->m_Flags & ENDPOINT) == 0 )
{
MirrorYPoint( DrawSegment->m_End, Center );
}
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
MirrorYPoint( DrawRaccord->m_Pos, Center );
NEGATE( DrawRaccord->m_Size.x );
break;
case DRAW_JUNCTION_STRUCT_TYPE:
DrawConnect = (DrawJunctionStruct*) DrawStruct;
MirrorYPoint( DrawConnect->m_Pos, Center );
break;
case DRAW_MARKER_STRUCT_TYPE:
DrawMarker = (MARKER_SCH*) DrawStruct;
MirrorYPoint( DrawMarker->m_Pos, Center );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
DrawNoConnect = (DrawNoConnectStruct*) DrawStruct;
MirrorYPoint( DrawNoConnect->m_Pos, Center );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
// Text is not really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half horizontal len
DrawText = (SCH_TEXT*) DrawStruct;
px = DrawText->m_Pos;
if( DrawText->m_Orient == 0 ) /* horizontal text */
dx = DrawText->LenSize( DrawText->m_Text ) / 2;
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
dx = -DrawText->LenSize( DrawText->m_Text ) / 2;
else
dx = 0;
px.x += dx;
MirrorYPoint( px, Center );
px.x -= dx;
frame->PutOnGrid( &px );
DrawText->m_Pos.x = px.x;
break;
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
// Text is not really mirrored: Orientation is changed
DrawText = (SCH_LABEL*) DrawStruct;
if( DrawText->m_Orient == 0 ) /* horizontal text */
DrawText->m_Orient = 2;
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
DrawText->m_Orient = 0;
px = DrawText->m_Pos;
MirrorYPoint( px, Center );
frame->PutOnGrid( &px );
DrawText->m_Pos.x = px.x;
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
dx = DrawLibItem->m_Pos.x;
frame->CmpRotationMiroir( DrawLibItem, NULL, CMP_MIROIR_Y );
MirrorYPoint( DrawLibItem->m_Pos, Center );
dx -= DrawLibItem->m_Pos.x;
for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
/* move the fields to the new position because the component itself has moved */
DrawLibItem->GetField( ii )->m_Pos.x -= dx;
}
break;
case DRAW_SHEET_STRUCT_TYPE:
DrawSheet = (DrawSheetStruct*) DrawStruct;
MirrorYPoint( DrawSheet->m_Pos, Center );
DrawSheet->m_Pos.x -= DrawSheet->m_Size.x;
DrawSheetLabel = DrawSheet->m_Label;
while( DrawSheetLabel != NULL )
{
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1;
DrawSheetLabel =
(Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Next();
}
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
break;
default:
break;
}
}
/*****************************************************************************
* Routine to Mirror objects. *
*****************************************************************************/
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
MirrorOneStruct( item, Center ); // Place it in its new position.
item->m_Flags = 0;
}
}
/*****************************************************************************/ /*****************************************************************************/
void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList ) void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector )
/*****************************************************************************/ /*****************************************************************************/
/* Routine to copy a new entity of an object for each object in list and reposition it. /* Routine to copy a new entity of an object for each object in list and reposition it.
...@@ -713,7 +518,7 @@ void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList ) ...@@ -713,7 +518,7 @@ void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList )
{ {
newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetItemData( ii ) ); newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetItemData( ii ) );
aItemsList.SetItem( newitem, ii ); aItemsList.SetItem( newitem, ii );
aItemsList.SetItemStatus( IS_NEW, ii ); aItemsList.SetItemStatus( UR_NEW, ii );
{ {
switch( newitem->Type() ) switch( newitem->Type() )
{ {
...@@ -751,7 +556,7 @@ void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList ) ...@@ -751,7 +556,7 @@ void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList )
} }
} }
PlaceItemsInList( screen, aItemsList ); MoveItemsInList( screen, aItemsList, aMoveVector );
} }
...@@ -775,7 +580,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -775,7 +580,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
* accessible par la liste globale directement */ * accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct
*) DrawStruct )->GetParent(), *) DrawStruct )->GetParent(),
IS_CHANGED ); UR_CHANGED );
frame->DeleteSheetLabel( DC ? true : false, frame->DeleteSheetLabel( DC ? true : false,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct ); (Hierarchical_PIN_Sheet_Struct*) DrawStruct );
return; return;
...@@ -791,7 +596,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -791,7 +596,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
DrawStruct->SetNext( 0 ); DrawStruct->SetNext( 0 );
DrawStruct->SetBack( 0 ); // Only one struct -> no link DrawStruct->SetBack( 0 ); // Only one struct -> no link
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); frame->SaveCopyInUndoList( DrawStruct, UR_DELETED );
} }
} }
...@@ -836,10 +641,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -836,10 +641,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
} }
PICKED_ITEMS_LIST picklist; PICKED_ITEMS_LIST picklist;
picklist.m_UndoRedoType = IS_NEW;
// Creates data, and push it as new data in undo item list buffer // Creates data, and push it as new data in undo item list buffer
ITEM_PICKER picker( NULL, IS_NEW ); ITEM_PICKER picker( NULL, UR_NEW );
for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ ) for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ )
{ {
Struct = DuplicateStruct( (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetItemData( ii ) ); Struct = DuplicateStruct( (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetItemData( ii ) );
...@@ -858,9 +662,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -858,9 +662,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
GetScreen()->EEDrawList = Struct; GetScreen()->EEDrawList = Struct;
} }
SaveCopyInUndoList( picklist, IS_NEW ); SaveCopyInUndoList( picklist, UR_NEW );
PlaceItemsInList( GetScreen(), picklist ); MoveItemsInList( GetScreen(), picklist, GetScreen()->m_BlockLocate.m_MoveVector );
/* clear .m_Flags member for all items */ /* clear .m_Flags member for all items */
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() ) for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
...@@ -887,7 +691,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ) ...@@ -887,7 +691,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii ); SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
itemWrapper.m_Item = item; itemWrapper.m_Item = item;
itemWrapper.m_UndoRedoStatus = IS_DELETED; itemWrapper.m_UndoRedoStatus = UR_DELETED;
if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ) if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{ {
/* this item is depending on a sheet, and is not in global list */ /* this item is depending on a sheet, and is not in global list */
...@@ -897,7 +701,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ) ...@@ -897,7 +701,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
Hierarchical_PIN_Sheet_Struct* pinlabel = (Hierarchical_PIN_Sheet_Struct*) item; Hierarchical_PIN_Sheet_Struct* pinlabel = (Hierarchical_PIN_Sheet_Struct*) item;
frame->DeleteSheetLabel( false, pinlabel->m_Parent ); frame->DeleteSheetLabel( false, pinlabel->m_Parent );
itemWrapper.m_Item = pinlabel->m_Parent; itemWrapper.m_Item = pinlabel->m_Parent;
itemWrapper.m_UndoRedoStatus = IS_CHANGED; itemWrapper.m_UndoRedoStatus = UR_CHANGED;
itemsList.PushItem( itemWrapper ); itemsList.PushItem( itemWrapper );
#endif #endif
} }
...@@ -912,138 +716,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ) ...@@ -912,138 +716,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
} }
} }
frame->SaveCopyInUndoList( itemsList, IS_DELETED ); frame->SaveCopyInUndoList( itemsList, UR_DELETED );
}
/*****************************************************************************
* Routine to place a given object. *
*****************************************************************************/
void PlaceItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList )
{
wxPoint move_vector;
move_vector = aScreen->m_Curseur - aScreen->m_BlockLocate.m_BlockLastCursorPosition;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
MoveOneStruct( item, move_vector );
}
}
/**************************************************************************/
void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
/*************************************************************************/
/* Given a structure move it by Dx, Dy.
*/
{
DrawPolylineStruct* DrawPoly;
DrawJunctionStruct* DrawConnect;
EDA_DrawLineStruct* DrawSegment;
DrawBusEntryStruct* DrawRaccord;
SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
MARKER_SCH* DrawMarker;
DrawNoConnectStruct* DrawNoConnect;
if( !DrawStruct )
return;
switch( DrawStruct->Type() )
{
case TYPE_NOT_INIT:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
DrawPoly = (DrawPolylineStruct*) DrawStruct;
for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
{
DrawPoly->m_PolyPoints[ii] += move_vector;
}
break;
case DRAW_SEGMENT_STRUCT_TYPE:
DrawSegment = (EDA_DrawLineStruct*) DrawStruct;
if( (DrawSegment->m_Flags & STARTPOINT) == 0 )
{
DrawSegment->m_Start += move_vector;
}
if( (DrawSegment->m_Flags & ENDPOINT) == 0 )
{
DrawSegment->m_End += move_vector;
}
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
DrawRaccord->m_Pos += move_vector;
break;
case DRAW_JUNCTION_STRUCT_TYPE:
DrawConnect = (DrawJunctionStruct*) DrawStruct;
DrawConnect->m_Pos += move_vector;
break;
case DRAW_MARKER_STRUCT_TYPE:
DrawMarker = (MARKER_SCH*) DrawStruct;
DrawMarker->m_Pos += move_vector;
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
DrawNoConnect = (DrawNoConnectStruct*) DrawStruct;
DrawNoConnect->m_Pos += move_vector;
break;
case TYPE_SCH_TEXT:
#define DrawText ( (SCH_TEXT*) DrawStruct )
DrawText->m_Pos += move_vector;
break;
case TYPE_SCH_LABEL:
#define DrawLabel ( (SCH_LABEL*) DrawStruct )
DrawLabel->m_Pos += move_vector;
break;
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
#define DrawGHLabel ( (SCH_LABEL*) DrawStruct )
DrawGHLabel->m_Pos += move_vector;
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
DrawLibItem->m_Pos += move_vector;
for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
DrawLibItem->GetField( ii )->m_Pos += move_vector;
}
break;
case DRAW_SHEET_STRUCT_TYPE:
DrawSheet = (DrawSheetStruct*) DrawStruct;
DrawSheet->m_Pos += move_vector;
DrawSheetLabel = DrawSheet->m_Label;
while( DrawSheetLabel != NULL )
{
DrawSheetLabel->m_Pos += move_vector;
DrawSheetLabel = DrawSheetLabel->Next();
}
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
DrawSheetLabel->m_Pos += move_vector;
break;
default:
break;
}
} }
...@@ -1113,9 +786,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) ...@@ -1113,9 +786,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy(); NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy();
break; break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCREEN_STRUCT_TYPE:
default: default:
{ {
wxString msg; wxString msg;
......
...@@ -357,7 +357,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) ...@@ -357,7 +357,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
DrawPanel->CursorOn( DC ); // Display schematic cursor DrawPanel->CursorOn( DC ); // Display schematic cursor
SaveCopyInUndoList( s_OldWiresList, IS_WIRE_IMAGE ); SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE );
s_OldWiresList = NULL; s_OldWiresList = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -548,7 +548,7 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( ...@@ -548,7 +548,7 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
GetScreen()->EEDrawList = NewJunction; GetScreen()->EEDrawList = NewJunction;
GetScreen()->SetModify(); GetScreen()->SetModify();
if( PutInUndoList ) if( PutInUndoList )
SaveCopyInUndoList( NewJunction, IS_NEW ); SaveCopyInUndoList( NewJunction, UR_NEW );
return NewJunction; return NewJunction;
} }
...@@ -572,7 +572,7 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC ) ...@@ -572,7 +572,7 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
NewNoConnect->SetNext( GetScreen()->EEDrawList ); NewNoConnect->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = NewNoConnect; GetScreen()->EEDrawList = NewNoConnect;
GetScreen()->SetModify(); GetScreen()->SetModify();
SaveCopyInUndoList( NewNoConnect, IS_NEW ); SaveCopyInUndoList( NewNoConnect, UR_NEW );
return NewNoConnect; return NewNoConnect;
} }
...@@ -734,7 +734,7 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -734,7 +734,7 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
GetScreen()->EEDrawList = g_ItemToRepeat; GetScreen()->EEDrawList = g_ItemToRepeat;
TestDanglingEnds( GetScreen()->EEDrawList, NULL ); TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( g_ItemToRepeat, IS_NEW ); SaveCopyInUndoList( g_ItemToRepeat, UR_NEW );
g_ItemToRepeat->m_Flags = 0; g_ItemToRepeat->m_Flags = 0;
// GetScreen()->Curseur = new_pos; // GetScreen()->Curseur = new_pos;
......
...@@ -145,7 +145,7 @@ void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC, ...@@ -145,7 +145,7 @@ void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
/* Put old item in undo list if it is not currently in edit */ /* Put old item in undo list if it is not currently in edit */
if( BusEntry->m_Flags == 0 ) if( BusEntry->m_Flags == 0 )
SaveCopyInUndoList( BusEntry, IS_CHANGED ); SaveCopyInUndoList( BusEntry, UR_CHANGED );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode ); RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
......
...@@ -416,7 +416,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -416,7 +416,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == component->Type()) ) if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == component->Type()) )
{ {
component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
frame->SaveCopyInUndoList( component, IS_CHANGED ); frame->SaveCopyInUndoList( component, UR_CHANGED );
component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
} }
......
...@@ -454,7 +454,7 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -454,7 +454,7 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
SwapData( (SCH_TEXT*) g_ItemToUndoCopy ); SwapData( (SCH_TEXT*) g_ItemToUndoCopy );
/* save in undo list */ /* save in undo list */
frame->SaveCopyInUndoList( this, IS_CHANGED ); frame->SaveCopyInUndoList( this, UR_CHANGED );
/* restore new values */ /* restore new values */
SwapData( (SCH_TEXT*) g_ItemToUndoCopy ); SwapData( (SCH_TEXT*) g_ItemToUndoCopy );
......
...@@ -155,7 +155,7 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint, ...@@ -155,7 +155,7 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint,
/* Ici il faut couper le segment en 2 */ /* Ici il faut couper le segment en 2 */
if( aPicklist ) // First: put copy of the old segment in undo list if( aPicklist ) // First: put copy of the old segment in undo list
{ {
ITEM_PICKER picker((SCH_ITEM*) segment->GenCopy(), IS_CHANGED); ITEM_PICKER picker((SCH_ITEM*) segment->GenCopy(), UR_CHANGED);
picker.m_Link = segment; picker.m_Link = segment;
aPicklist->PushItem(picker); aPicklist->PushItem(picker);
} }
...@@ -167,7 +167,7 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint, ...@@ -167,7 +167,7 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint,
DrawList = NewSegment; DrawList = NewSegment;
if( aPicklist ) if( aPicklist )
{ {
ITEM_PICKER picker(NewSegment, IS_NEW); ITEM_PICKER picker(NewSegment, UR_NEW);
aPicklist->PushItem(picker); aPicklist->PushItem(picker);
} }
} }
......
...@@ -615,7 +615,7 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -615,7 +615,7 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
/* save in undo list */ /* save in undo list */
frame->SaveCopyInUndoList( this, IS_CHANGED ); frame->SaveCopyInUndoList( this, UR_CHANGED );
/* restore new values */ /* restore new values */
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
......
...@@ -138,7 +138,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection ) ...@@ -138,7 +138,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
/* Locate all the wires, bus or junction under the mouse cursor, and put them in a list /* Locate all the wires, bus or junction under the mouse cursor, and put them in a list
* of items to delete * of items to delete
*/ */
ITEM_PICKER picker(NULL, IS_DELETED); ITEM_PICKER picker(NULL, UR_DELETED);
SCH_SCREEN* screen = (SCH_SCREEN*) GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) GetScreen();
SCH_ITEM* savedEEDrawList = screen->EEDrawList; // Save the list entry point of this screen SCH_ITEM* savedEEDrawList = screen->EEDrawList; // Save the list entry point of this screen
DelStruct = GetScreen()->EEDrawList; DelStruct = GetScreen()->EEDrawList;
......
...@@ -243,7 +243,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event ...@@ -243,7 +243,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
/* save old cmp in undo list if not already in edit, or moving ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( m_Cmp->m_Flags == 0 ) if( m_Cmp->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED ); m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
// change all field positions from relative to absolute // change all field positions from relative to absolute
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
......
...@@ -128,7 +128,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -128,7 +128,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
/* save old cmp in undo list if not already in edit, or moving ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( Field->m_Flags == 0 ) if( Field->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
wxString newtext = Field->m_Text; wxString newtext = Field->m_Text;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
...@@ -270,7 +270,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -270,7 +270,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
/* save old cmp in undo list if not already in edit, or moving ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( Field->m_Flags == 0 ) if( Field->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
Field->m_AddExtraText = flag; Field->m_AddExtraText = flag;
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode ); Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
...@@ -310,7 +310,7 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -310,7 +310,7 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
{ {
/* save old cmp in undo list if not already in edit, or moving ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->SetRef(GetSheet(), ref); Cmp->SetRef(GetSheet(), ref);
Cmp->GetField( REFERENCE )->m_AddExtraText = flag; Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
...@@ -349,7 +349,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -349,7 +349,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
{ {
/* save old cmp in undo list if not already in edit, or moving ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
TextField->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode ); TextField->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
TextField->m_Text = message; TextField->m_Text = message;
...@@ -388,7 +388,7 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -388,7 +388,7 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
// save old cmp in undo list if not already in edit, or moving ... // save old cmp in undo list if not already in edit, or moving ...
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode ); Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
// move the field if it was new. // move the field if it was new.
......
...@@ -39,7 +39,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) ...@@ -39,7 +39,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
/* save old text in undo list if not already in edit */ /* save old text in undo list if not already in edit */
if( m_CurrentText->m_Flags == 0 ) if( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_CurrentText, IS_CHANGED ); m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
text = m_TextLabel->GetValue(); text = m_TextLabel->GetValue();
if( !text.IsEmpty() ) if( !text.IsEmpty() )
...@@ -162,7 +162,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -162,7 +162,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
/* save old text in undo list if is not already in edit */ /* save old text in undo list if is not already in edit */
if( TextStruct->m_Flags == 0 ) if( TextStruct->m_Flags == 0 )
SaveCopyInUndoList( TextStruct, IS_CHANGED ); SaveCopyInUndoList( TextStruct, UR_CHANGED );
/* Effacement du texte en cours */ /* Effacement du texte en cours */
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
...@@ -432,7 +432,7 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, ...@@ -432,7 +432,7 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
*/ */
if( (flags & IS_NEW) == 0 ) if( (flags & IS_NEW) == 0 )
{ {
SaveCopyInUndoList( newtext, IS_NEW ); SaveCopyInUndoList( newtext, UR_NEW );
} }
else else
{ {
......
...@@ -164,25 +164,23 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -164,25 +164,23 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
* de structures. * de structures.
* Utilisee dans les deplacements de blocs * Utilisee dans les deplacements de blocs
*/ */
void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset )
SCH_ITEM* DrawStruct, int dx, int dy )
{ {
int DrawMode = g_XorMode; int DrawMode = g_XorMode;
int width = g_DrawDefaultLineThickness; int width = g_DrawDefaultLineThickness;
GRSetDrawMode( aDC, DrawMode );
GRSetDrawMode( DC, DrawMode ); switch( aItem->Type() )
switch( DrawStruct->Type() )
{ {
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
{ {
DrawPolylineStruct* Struct = (DrawPolylineStruct*) DrawStruct; DrawPolylineStruct* Struct = (DrawPolylineStruct*) aItem;
GRMoveTo( Struct->m_PolyPoints[0].x + dx, GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
Struct->m_PolyPoints[0].y + dy ); Struct->m_PolyPoints[0].y + aOffset.y );
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ ) for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
GRLineTo( &panel->m_ClipBox, DC, Struct->m_PolyPoints[ii].x + dx, GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_PolyPoints[ii].x + aOffset.x,
Struct->m_PolyPoints[ii].y + dy, width, g_GhostColor ); Struct->m_PolyPoints[ii].y + aOffset.y, width, g_GhostColor );
break; break;
} }
...@@ -190,10 +188,10 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -190,10 +188,10 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
{ {
EDA_DrawLineStruct* Struct; EDA_DrawLineStruct* Struct;
Struct = (EDA_DrawLineStruct*) DrawStruct; Struct = (EDA_DrawLineStruct*) aItem;
if( (Struct->m_Flags & STARTPOINT) == 0 ) if( (Struct->m_Flags & STARTPOINT) == 0 )
{ {
GRMoveTo( Struct->m_Start.x + dx, Struct->m_Start.y + dy ); GRMoveTo( Struct->m_Start.x + aOffset.x, Struct->m_Start.y + aOffset.y );
} }
else else
{ {
...@@ -201,12 +199,12 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -201,12 +199,12 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
} }
if( (Struct->m_Flags & ENDPOINT) == 0 ) if( (Struct->m_Flags & ENDPOINT) == 0 )
{ {
GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x + dx, GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x + aOffset.x,
Struct->m_End.y + dy, width, g_GhostColor ); Struct->m_End.y + aOffset.y, width, g_GhostColor );
} }
else else
{ {
GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x, GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x,
Struct->m_End.y, width, g_GhostColor ); Struct->m_End.y, width, g_GhostColor );
} }
break; break;
...@@ -214,27 +212,27 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -214,27 +212,27 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
{ {
DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) DrawStruct; DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) aItem;
int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy; wxPoint start = Struct->m_Pos + aOffset;
GRMoveTo( xx, yy ); GRMoveTo( start.x, start.y );
GRLineTo( &panel->m_ClipBox, DC, Struct->m_Size.x + xx, GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x,
Struct->m_Size.y + yy, width, g_GhostColor ); Struct->m_Size.y + start.y, width, g_GhostColor );
break; break;
} }
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
{ {
DrawJunctionStruct* Struct; DrawJunctionStruct* Struct;
Struct = (DrawJunctionStruct*) DrawStruct; Struct = (DrawJunctionStruct*) aItem;
Struct->Draw( panel, DC, wxPoint(0,0), DrawMode, g_GhostColor ); Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break; break;
} }
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
{ {
SCH_TEXT* Struct; SCH_TEXT* Struct;
Struct = (SCH_TEXT*) DrawStruct; Struct = (SCH_TEXT*) aItem;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor ); Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break; break;
} }
...@@ -243,16 +241,16 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -243,16 +241,16 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
{ {
SCH_LABEL* Struct; SCH_LABEL* Struct;
Struct = (SCH_LABEL*) DrawStruct; Struct = (SCH_LABEL*) aItem;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor ); Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break; break;
} }
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
{ {
DrawNoConnectStruct* Struct; DrawNoConnectStruct* Struct;
Struct = (DrawNoConnectStruct*) DrawStruct; Struct = (DrawNoConnectStruct*) aItem;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor ); Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break; break;
} }
...@@ -260,23 +258,23 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -260,23 +258,23 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
EDA_LibComponentStruct* LibEntry; EDA_LibComponentStruct* LibEntry;
SCH_COMPONENT* Struct; SCH_COMPONENT* Struct;
Struct = (SCH_COMPONENT*) DrawStruct; Struct = (SCH_COMPONENT*) aItem;
LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString, LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT ); FIND_ROOT );
if( LibEntry == NULL ) if( LibEntry == NULL )
break; break;
DrawingLibInGhost( panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx, DrawingLibInGhost( aPanel, aDC, LibEntry, Struct, Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + dy, Struct->m_Multi, Struct->m_Pos.y + aOffset.y, Struct->m_Multi,
Struct->m_Convert, g_GhostColor, FALSE ); Struct->m_Convert, g_GhostColor, FALSE );
break; break;
} }
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{ {
DrawSheetStruct* Struct = (DrawSheetStruct*) DrawStruct; DrawSheetStruct* Struct = (DrawSheetStruct*) aItem;
GRRect( &panel->m_ClipBox, DC, Struct->m_Pos.x + dx, GRRect( &aPanel->m_ClipBox, aDC, Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + dy, Struct->m_Pos.x + Struct->m_Size.x + dx, Struct->m_Pos.y + aOffset.y, Struct->m_Pos.x + Struct->m_Size.x + aOffset.x,
Struct->m_Pos.y + Struct->m_Size.y + dy, width, g_GhostColor ); Struct->m_Pos.y + Struct->m_Size.y + aOffset.y, width, g_GhostColor );
break; break;
} }
......
/****************************************************/
/* BLOCK.CPP */
/* Gestion des Operations sur Blocks et Effacements */
/****************************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h"
/* Variables Locales */
/* Fonctions exportees */
void MoveItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& aMirrorPoint );
/*
* Small function to mirror (relative to a vertiacl axis at aMirrorPoint.x position)
* a given point
*/
static void MirrorYPoint( wxPoint& point, wxPoint& aMirrorPoint )
{
point.x -= aMirrorPoint.x;
NEGATE( point.x );
point.x += aMirrorPoint.x;
}
/**************************************************************/
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& aMirrorPoint )
/**************************************************************/
/* Given a structure rotate it to 90 degrees refer to the aMirrorPoint point.
*/
{
int dx;
DrawPolylineStruct* DrawPoly;
DrawJunctionStruct* DrawConnect;
EDA_DrawLineStruct* DrawSegment;
DrawBusEntryStruct* DrawRaccord;
SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
MARKER_SCH* DrawMarker;
DrawNoConnectStruct* DrawNoConnect;
SCH_TEXT* DrawText;
wxPoint px;
if( !DrawStruct )
return;
switch( DrawStruct->Type() )
{
case TYPE_NOT_INIT:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
DrawPoly = (DrawPolylineStruct*) DrawStruct;
for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
{
wxPoint point;
point = DrawPoly->m_PolyPoints[ii];
MirrorYPoint( point, aMirrorPoint );
DrawPoly->m_PolyPoints[ii] = point;
}
break;
case DRAW_SEGMENT_STRUCT_TYPE:
DrawSegment = (EDA_DrawLineStruct*) DrawStruct;
if( (DrawSegment->m_Flags & STARTPOINT) == 0 )
{
MirrorYPoint( DrawSegment->m_Start, aMirrorPoint );
}
if( (DrawSegment->m_Flags & ENDPOINT) == 0 )
{
MirrorYPoint( DrawSegment->m_End, aMirrorPoint );
}
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
MirrorYPoint( DrawRaccord->m_Pos, aMirrorPoint );
NEGATE( DrawRaccord->m_Size.x );
break;
case DRAW_JUNCTION_STRUCT_TYPE:
DrawConnect = (DrawJunctionStruct*) DrawStruct;
MirrorYPoint( DrawConnect->m_Pos, aMirrorPoint );
break;
case DRAW_MARKER_STRUCT_TYPE:
DrawMarker = (MARKER_SCH*) DrawStruct;
MirrorYPoint( DrawMarker->m_Pos, aMirrorPoint );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
DrawNoConnect = (DrawNoConnectStruct*) DrawStruct;
MirrorYPoint( DrawNoConnect->m_Pos, aMirrorPoint );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
// Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half horizontal len
DrawText = (SCH_TEXT*) DrawStruct;
px = DrawText->m_Pos;
if( DrawText->m_Orient == 0 ) /* horizontal text */
dx = DrawText->LenSize( DrawText->m_Text ) / 2;
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
dx = -DrawText->LenSize( DrawText->m_Text ) / 2;
else
dx = 0;
px.x += dx;
MirrorYPoint( px, aMirrorPoint );
px.x -= dx;
DrawText->m_Pos.x = px.x;
break;
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
// Text is not really mirrored: Orientation is changed
DrawText = (SCH_LABEL*) DrawStruct;
if( DrawText->m_Orient == 0 ) /* horizontal text */
DrawText->m_Orient = 2;
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
DrawText->m_Orient = 0;
px = DrawText->m_Pos;
MirrorYPoint( px, aMirrorPoint );
DrawText->m_Pos.x = px.x;
break;
case TYPE_SCH_COMPONENT:
{
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
dx = DrawLibItem->m_Pos.x;
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->CmpRotationMiroir( DrawLibItem, NULL, CMP_MIROIR_Y );
MirrorYPoint( DrawLibItem->m_Pos, aMirrorPoint );
dx -= DrawLibItem->m_Pos.x;
for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
/* move the fields to the new position because the component itself has moved */
DrawLibItem->GetField( ii )->m_Pos.x -= dx;
}
}
break;
case DRAW_SHEET_STRUCT_TYPE:
DrawSheet = (DrawSheetStruct*) DrawStruct;
MirrorYPoint( DrawSheet->m_Pos, aMirrorPoint );
DrawSheet->m_Pos.x -= DrawSheet->m_Size.x;
DrawSheetLabel = DrawSheet->m_Label;
while( DrawSheetLabel != NULL )
{
MirrorYPoint( DrawSheetLabel->m_Pos, aMirrorPoint );
DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1;
DrawSheetLabel =
(Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Next();
}
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
MirrorYPoint( DrawSheetLabel->m_Pos, aMirrorPoint );
break;
default:
break;
}
}
/*****************************************************************************
* Routine to Mirror objects. *
*****************************************************************************/
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
MirrorOneStruct( item, aMirrorPoint ); // Place it in its new position.
item->m_Flags = 0;
}
}
/*****************************************************************************
* Routine to place a given object. *
*****************************************************************************/
void MoveItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
MoveOneStruct( item, aMoveVector );
}
}
/**************************************************************************/
void MoveOneStruct( SCH_ITEM* aItem, const wxPoint& aMoveVector )
/*************************************************************************/
/* Given a structure move it by aMoveVector.
*/
{
DrawPolylineStruct* DrawPoly;
DrawJunctionStruct* DrawConnect;
EDA_DrawLineStruct* DrawSegment;
DrawBusEntryStruct* DrawRaccord;
SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
MARKER_SCH* DrawMarker;
DrawNoConnectStruct* DrawNoConnect;
if( !aItem )
return;
switch( aItem->Type() )
{
case TYPE_NOT_INIT:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
DrawPoly = (DrawPolylineStruct*) aItem;
for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
{
DrawPoly->m_PolyPoints[ii] += aMoveVector;
}
break;
case DRAW_SEGMENT_STRUCT_TYPE:
DrawSegment = (EDA_DrawLineStruct*) aItem;
if( (DrawSegment->m_Flags & STARTPOINT) == 0 )
{
DrawSegment->m_Start += aMoveVector;
}
if( (DrawSegment->m_Flags & ENDPOINT) == 0 )
{
DrawSegment->m_End += aMoveVector;
}
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
DrawRaccord = (DrawBusEntryStruct*) aItem;
DrawRaccord->m_Pos += aMoveVector;
break;
case DRAW_JUNCTION_STRUCT_TYPE:
DrawConnect = (DrawJunctionStruct*) aItem;
DrawConnect->m_Pos += aMoveVector;
break;
case DRAW_MARKER_STRUCT_TYPE:
DrawMarker = (MARKER_SCH*) aItem;
DrawMarker->m_Pos += aMoveVector;
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
DrawNoConnect = (DrawNoConnectStruct*) aItem;
DrawNoConnect->m_Pos += aMoveVector;
break;
case TYPE_SCH_TEXT:
#define DrawText ( (SCH_TEXT*) aItem )
DrawText->m_Pos += aMoveVector;
break;
case TYPE_SCH_LABEL:
#define DrawLabel ( (SCH_LABEL*) aItem )
DrawLabel->m_Pos += aMoveVector;
break;
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
#define DrawGHLabel ( (SCH_LABEL*) aItem )
DrawGHLabel->m_Pos += aMoveVector;
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) aItem;
DrawLibItem->m_Pos += aMoveVector;
for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
DrawLibItem->GetField( ii )->m_Pos += aMoveVector;
}
break;
case DRAW_SHEET_STRUCT_TYPE:
DrawSheet = (DrawSheetStruct*) aItem;
DrawSheet->m_Pos += aMoveVector;
DrawSheetLabel = DrawSheet->m_Label;
while( DrawSheetLabel != NULL )
{
DrawSheetLabel->m_Pos += aMoveVector;
DrawSheetLabel = DrawSheetLabel->Next();
}
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) aItem;
DrawSheetLabel->m_Pos += aMoveVector;
break;
default:
break;
}
}
...@@ -231,7 +231,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -231,7 +231,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
curr_field->m_Name = ( ii < FIELD1 ) ? ReturnDefaultFieldName( ii ) : EntryField->m_Name; curr_field->m_Name = ( ii < FIELD1 ) ? ReturnDefaultFieldName( ii ) : EntryField->m_Name;
} }
DrawStructsInGhost( DrawPanel, DC, Component, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) );
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
Component->DisplayInfo( this ); Component->DisplayInfo( this );
...@@ -255,14 +255,14 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -255,14 +255,14 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* Effacement du composant */ /* Effacement du composant */
if( erase ) if( erase )
{ {
DrawStructsInGhost( panel, DC, Component, 0, 0 ); DrawStructsInGhost( panel, DC, Component, wxPoint(0,0) );
} }
move_vector.x = screen->m_Curseur.x - Component->m_Pos.x; move_vector.x = screen->m_Curseur.x - Component->m_Pos.x;
move_vector.y = screen->m_Curseur.y - Component->m_Pos.y; move_vector.y = screen->m_Curseur.y - Component->m_Pos.y;
MoveOneStruct( Component, move_vector ); MoveOneStruct( Component, move_vector );
DrawStructsInGhost( panel, DC, Component, 0, 0 ); DrawStructsInGhost( panel, DC, Component, wxPoint(0,0) );
} }
...@@ -283,7 +283,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir( ...@@ -283,7 +283,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir(
{ {
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
if( DrawComponent->m_Flags ) if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else else
{ {
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() ); DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() );
...@@ -296,7 +296,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir( ...@@ -296,7 +296,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir(
if( DC ) if( DC )
{ {
if( DrawComponent->m_Flags ) if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ), 0 ),
...@@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent, ...@@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
/* Efface le trace precedent */ /* Efface le trace precedent */
if( DrawComponent->m_Flags ) if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
...@@ -388,10 +388,9 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent, ...@@ -388,10 +388,9 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
/* Redessine le composant dans la nouvelle position */ /* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags ) if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -421,7 +420,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent, ...@@ -421,7 +420,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
/* Efface le trace precedent */ /* Efface le trace precedent */
if( DrawComponent->m_Flags ) if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
...@@ -431,10 +430,9 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent, ...@@ -431,10 +430,9 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
/* Redessine le composant dans la nouvelle position */ /* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags & IS_MOVED ) if( DrawComponent->m_Flags & IS_MOVED )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -508,7 +506,7 @@ void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component, ...@@ -508,7 +506,7 @@ void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component,
Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only
DrawPanel->PostDirtyRect( Component->GetBoundingBox() ); DrawPanel->PostDirtyRect( Component->GetBoundingBox() );
DrawStructsInGhost( DrawPanel, DC, Component, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) );
#else #else
......
...@@ -331,7 +331,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -331,7 +331,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
if( DrawStruct->m_Flags == 0 ) if( DrawStruct->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
...@@ -345,7 +345,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -345,7 +345,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
if( DrawStruct->m_Flags == 0 ) if( DrawStruct->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
ChangeTextOrient( (SCH_TEXT*) DrawStruct, DC ); ChangeTextOrient( (SCH_TEXT*) DrawStruct, DC );
...@@ -364,7 +364,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -364,7 +364,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{ {
if( DrawStruct->m_Flags == 0 ) if( DrawStruct->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_Y ); CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_Y );
...@@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{ {
if( DrawStruct->m_Flags == 0 ) if( DrawStruct->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_X ); CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_X );
...@@ -392,7 +392,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -392,7 +392,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{ {
if( DrawStruct->m_Flags == 0 ) if( DrawStruct->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_NORMAL ); CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_NORMAL );
......
...@@ -166,8 +166,7 @@ Hierarchical_PIN_Sheet_Struct * LocateAnyPinSheet(const wxPoint & RefPos, ...@@ -166,8 +166,7 @@ Hierarchical_PIN_Sheet_Struct * LocateAnyPinSheet(const wxPoint & RefPos,
void DrawDanglingSymbol(WinEDA_DrawPanel * panel,wxDC * DC, void DrawDanglingSymbol(WinEDA_DrawPanel * panel,wxDC * DC,
const wxPoint & pos, int Color); const wxPoint & pos, int Color);
void DrawStructsInGhost(WinEDA_DrawPanel * panel, wxDC * DC, void DrawStructsInGhost(WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset );
SCH_ITEM * DrawStruct, int dx, int dy );
void SetHighLightStruct(SCH_ITEM *HighLight); void SetHighLightStruct(SCH_ITEM *HighLight);
void RedrawActiveWindow(WinEDA_DrawPanel * panel, wxDC * DC); void RedrawActiveWindow(WinEDA_DrawPanel * panel, wxDC * DC);
void RedrawStructList(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *Structs, int DrawMode, void RedrawStructList(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *Structs, int DrawMode,
......
...@@ -341,7 +341,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -341,7 +341,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
PICKED_ITEMS_LIST picklistForUndo; PICKED_ITEMS_LIST picklistForUndo;
BreakSegment( screen, screen->m_Curseur, &picklistForUndo ); BreakSegment( screen, screen->m_Curseur, &picklistForUndo );
if( picklistForUndo.GetCount() ) if( picklistForUndo.GetCount() )
SaveCopyInUndoList( picklistForUndo, IS_NEW | IS_CHANGED ); SaveCopyInUndoList( picklistForUndo, UR_UNSPECIFIED );
TestDanglingEnds( screen->EEDrawList, &dc ); TestDanglingEnds( screen->EEDrawList, &dc );
} }
break; break;
...@@ -485,7 +485,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -485,7 +485,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( screen->GetCurItem()->m_Flags == 0 ) if( screen->GetCurItem()->m_Flags == 0 )
SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(), IS_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(), UR_CHANGED );
CmpRotationMiroir( CmpRotationMiroir(
(SCH_COMPONENT*) screen->GetCurItem(), (SCH_COMPONENT*) screen->GetCurItem(),
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
// Imported functions
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& aMirrorPoint );
/* Functions to undo and redo edit commands. /* Functions to undo and redo edit commands.
* commmands to undo are stored in CurrentScreen->m_UndoList * commmands to undo are stored in CurrentScreen->m_UndoList
* commmands to redo are stored in CurrentScreen->m_RedoList * commmands to redo are stored in CurrentScreen->m_RedoList
...@@ -173,19 +177,20 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) ...@@ -173,19 +177,20 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
/***********************************************************************/ /***********************************************************************/
void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy, void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
int aCommandType ) UndoRedoOpType aCommandType,
const wxPoint& aTransformPoint )
/***********************************************************************/ /***********************************************************************/
/** function SaveCopyInUndoList /** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list. * Create a copy of the current schematic item, and put it in the undo list.
* *
* flag_type_command = * flag_type_command =
* IS_CHANGED * UR_CHANGED
* IS_NEW * UR_NEW
* IS_DELETED * UR_DELETED
* IS_WIRE_IMAGE * UR_WIRE_IMAGE
* *
* If it is a delete command, items are put on list with the .Flags member set to IS_DELETED. * If it is a delete command, items are put on list with the .Flags member set to UR_DELETED.
* When it will be really deleted, the EEDrawList and the subhierarchy will be deleted. * When it will be really deleted, the EEDrawList and the subhierarchy will be deleted.
* If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted. * If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted.
* *
...@@ -193,28 +198,29 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy, ...@@ -193,28 +198,29 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
* Edit wires and busses is a bit complex. * Edit wires and busses is a bit complex.
* because when a new wire is added, modifications in wire list * because when a new wire is added, modifications in wire list
* (wire concatenation) there are modified items, deleted items and new items * (wire concatenation) there are modified items, deleted items and new items
* so flag_type_command is IS_WIRE_IMAGE: the struct ItemToCopy is a list of wires * so flag_type_command is UR_WIRE_IMAGE: the struct ItemToCopy is a list of wires
* saved in Undo List (for Undo or Redo commands, saved wires will be exchanged with current wire list * saved in Undo List (for Undo or Redo commands, saved wires will be exchanged with current wire list
*/ */
{ {
SCH_ITEM* CopyOfItem; 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_UndoRedoType = aCommandType;
ITEM_PICKER itemWrapper( aItemToCopy, aCommandType ); ITEM_PICKER itemWrapper( aItemToCopy, aCommandType );
switch( aCommandType ) switch( aCommandType )
{ {
case IS_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( aItemToCopy ); CopyOfItem = DuplicateStruct( aItemToCopy );
itemWrapper.m_Item = CopyOfItem; itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = aItemToCopy; itemWrapper.m_Link = aItemToCopy;
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
case IS_NEW: case UR_NEW:
case IS_WIRE_IMAGE: case UR_WIRE_IMAGE:
case IS_DELETED: case UR_DELETED:
case UR_MOVED:
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
...@@ -237,21 +243,23 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy, ...@@ -237,21 +243,23 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
/** function SaveCopyInUndoList /** function SaveCopyInUndoList
* @param aItemsList = a PICKED_ITEMS_LIST of items to save * @param aItemsList = a PICKED_ITEMS_LIST of items to save
* @param aTypeCommand = type of comand ( IS_CHANGED, IS_NEW, IS_DELETED ... * @param aTypeCommand = type of comand ( UR_CHANGED, UR_NEW, UR_DELETED ...
*/ */
void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, int aTypeCommand ) void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint )
{ {
SCH_ITEM* CopyOfItem; 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_UndoRedoType = aTypeCommand;
ITEM_PICKER itemWrapper; ITEM_PICKER itemWrapper;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* ItemToCopy = (SCH_ITEM*) aItemsList.GetItemData( ii ); SCH_ITEM* ItemToCopy = (SCH_ITEM*) aItemsList.GetItemData( ii );
int command = aItemsList.GetItemStatus( ii ); UndoRedoOpType command = aItemsList.GetItemStatus( ii );
if( command == 0 ) if( command == UR_UNSPECIFIED )
{ {
command = aTypeCommand; command = aTypeCommand;
} }
...@@ -259,20 +267,21 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, i ...@@ -259,20 +267,21 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, i
itemWrapper.m_UndoRedoStatus = command; itemWrapper.m_UndoRedoStatus = command;
switch( command ) switch( command )
{ {
case IS_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( ItemToCopy ); CopyOfItem = DuplicateStruct( ItemToCopy );
itemWrapper.m_Item = CopyOfItem; itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = ItemToCopy; itemWrapper.m_Link = ItemToCopy;
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
case IS_NEW: case UR_MOVED:
case IS_NEW | IS_CHANGED: // when more than one item, some are new, some are changed case UR_MIRRORED_Y:
case UR_NEW:
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
case IS_DELETED: case UR_DELETED:
ItemToCopy->m_Flags = IS_DELETED; ItemToCopy->m_Flags = UR_DELETED;
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
...@@ -344,26 +353,38 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -344,26 +353,38 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link; SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link;
switch( itemWrapper.m_UndoRedoStatus ) switch( itemWrapper.m_UndoRedoStatus )
{ {
case IS_CHANGED: /* Exchange old and new data for each item */ case UR_CHANGED: /* Exchange old and new data for each item */
SwapData( item, image ); SwapData( item, image );
break; break;
case IS_NEW: /* new items are deleted */ case UR_NEW: /* new items are deleted */
aList->m_UndoRedoType = IS_DELETED; aList->SetItemStatus( UR_DELETED, ii );
aList->SetItemStatus( IS_DELETED, ii );
GetScreen()->RemoveFromDrawList( item ); GetScreen()->RemoveFromDrawList( item );
item->m_Flags = IS_DELETED; item->m_Flags = UR_DELETED;
break; break;
case IS_DELETED: /* deleted items are put in EEdrawList, as new items */ case UR_DELETED: /* deleted items are put in EEdrawList, as new items */
aList->m_UndoRedoType = IS_NEW; aList->SetItemStatus( UR_NEW, ii );
aList->SetItemStatus( IS_NEW, ii );
item->SetNext( GetScreen()->EEDrawList ); item->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = item; GetScreen()->EEDrawList = item;
item->m_Flags = 0; item->m_Flags = 0;
break; break;
case IS_WIRE_IMAGE: case UR_MOVED:
{
wxPoint moveVector = - aList->m_TransformPoint;
MoveOneStruct( item, moveVector );
}
break;
case UR_MIRRORED_Y:
{
wxPoint mirrorPoint = aList->m_TransformPoint;
MirrorOneStruct( item, mirrorPoint );
}
break;
case UR_WIRE_IMAGE:
/* Exchange the current wires and the old wires */ /* Exchange the current wires and the old wires */
alt_item = GetScreen()->ExtractWires( false ); alt_item = GetScreen()->ExtractWires( false );
aList->SetItem( alt_item, ii ); aList->SetItem( alt_item, ii );
...@@ -422,14 +443,14 @@ bool WinEDA_SchematicFrame::GetSchematicFromUndoList() ...@@ -422,14 +443,14 @@ bool WinEDA_SchematicFrame::GetSchematicFromUndoList()
} }
/*********************************************************/ /***********************************************************************************/
void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ) void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
/*********************************************************/ /**********************************************************************************/
/** Function ClearUndoORRedoList /** Function ClearUndoORRedoList
* free the undo or redo list from List element * free the undo or redo list from List element
* Wrappers are deleted. * Wrappers are deleted.
* datas pointed by wrappers are deleted if not flagged IS_NEW * datas pointed by wrappers are deleted if not flagged UR_NEW
* because they are copy of used data or they are not in use (DELETED) * because they are copy of used data or they are not in use (DELETED)
* @param aList = the UNDO_REDO_CONTAINER to clear * @param aList = the UNDO_REDO_CONTAINER to clear
* @param aItemCount = the count of items to remove. < 0 for all items * @param aItemCount = the count of items to remove. < 0 for all items
...@@ -437,8 +458,6 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -437,8 +458,6 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
* So this function can be called to remove old commands * So this function can be called to remove old commands
*/ */
{ {
int CmdType;
if( aItemCount == 0 ) if( aItemCount == 0 )
return; return;
...@@ -451,30 +470,36 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -451,30 +470,36 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
break; break;
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0]; PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
aList.m_CommandsList.erase( aList.m_CommandsList.begin() ); aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
CmdType = curr_cmd->m_UndoRedoType;
// Delete items is they are not flagged IS_NEW // Delete items is they are not flagged UR_NEW, or if this is a block operation
while( 1 ) while( 1 )
{ {
ITEM_PICKER wrapper = curr_cmd->PopItem(); ITEM_PICKER wrapper = curr_cmd->PopItem();
EDA_BaseStruct* item = wrapper.m_Item; EDA_BaseStruct* item = wrapper.m_Item;
if( item == NULL ) // No more item in list. if( item == NULL ) // No more item in list.
break; break;
if( wrapper.m_UndoRedoStatus == IS_WIRE_IMAGE ) switch( wrapper.m_UndoRedoStatus )
{ {
case UR_WIRE_IMAGE:
while( item ) while( item )
{ {
EDA_BaseStruct* nextitem = item->Next(); EDA_BaseStruct* nextitem = item->Next();
delete item; delete item;
item = nextitem; item = nextitem;
} }
}
else break;
{
if( (wrapper.m_UndoRedoStatus & IS_NEW) == 0 ) case UR_MOVED:
{ case UR_MIRRORED_X:
case UR_MIRRORED_Y:
case UR_ROTATED:
case UR_NEW: // Do nothing, items are in use
break;
default:
delete item; delete item;
} break;
} }
} }
......
...@@ -45,10 +45,26 @@ ...@@ -45,10 +45,26 @@
* and they are undo/redo by the same command * and they are undo/redo by the same command
*/ */
/* Type of undo/redo operations
* each type must be redo/undoed by a specfic operation
*/
enum UndoRedoOpType {
UR_UNSPECIFIED = 0, // illegal
UR_CHANGED, // params of items have a value changed: undo is made by exchange values with a copy of these values
UR_NEW, // new item, undo by changing in deleted
UR_DELETED, // deleted item, undo by changing in deleted
UR_MOVED, // moved item, undo by move it
UR_MIRRORED_X, // mirrored item, undo by mirror X
UR_MIRRORED_Y, // mirrored item, undo by mirror Y
UR_ROTATED, // Rotated item, undo by rotating it
UR_FLIPPED, // flipped (board items only), undo by flipping it
UR_WIRE_IMAGE // Specific to eeschema: handle wires changes
};
class ITEM_PICKER class ITEM_PICKER
{ {
public: public:
int m_UndoRedoStatus; // type of operation to undo/redo for this item UndoRedoOpType m_UndoRedoStatus; /* type of operation to undo/redo for this item */
EDA_BaseStruct* m_Item; /* Pointer on the schematic or board item that is concerned, EDA_BaseStruct* m_Item; /* Pointer on the schematic or board item that is concerned,
* or in undo redo commands, the copy of an edited item. * or in undo redo commands, the copy of an edited item.
*/ */
...@@ -60,7 +76,7 @@ public: ...@@ -60,7 +76,7 @@ public:
*/ */
public: public:
ITEM_PICKER( EDA_BaseStruct* aItem = NULL, int aUndoRedoStatus = 0 ) ITEM_PICKER( EDA_BaseStruct* aItem = NULL, UndoRedoOpType aUndoRedoStatus = UR_UNSPECIFIED )
{ {
m_UndoRedoStatus = aUndoRedoStatus; m_UndoRedoStatus = aUndoRedoStatus;
m_Item = aItem; m_Item = aItem;
...@@ -76,10 +92,10 @@ public: ...@@ -76,10 +92,10 @@ public:
class PICKED_ITEMS_LIST class PICKED_ITEMS_LIST
{ {
public: public:
int m_UndoRedoType; // type of operation to undo/redo UndoRedoOpType m_Status; /* info about operation to undo/redo for this item. can be UR_UNSPECIFIED */
// UNSPECIFIED (0), IS_NEW, IS_DELETED, IS_CHANGED wxPoint m_TransformPoint; /* used to undo redo command by the same command:
wxPoint m_TransformPoint; // used to undo redo command by the same command: * we usually need to know the rotate point or the move vector
// we usually need to know the rotate point or the move vector */
private: private:
std::vector <ITEM_PICKER> m_ItemsList; std::vector <ITEM_PICKER> m_ItemsList;
...@@ -108,18 +124,18 @@ public: ...@@ -108,18 +124,18 @@ public:
ITEM_PICKER GetItemWrapper( unsigned int aIdx ); ITEM_PICKER GetItemWrapper( unsigned int aIdx );
EDA_BaseStruct* GetItemData( unsigned int aIdx ); EDA_BaseStruct* GetItemData( unsigned int aIdx );
EDA_BaseStruct* GetImage( unsigned int aIdx ); EDA_BaseStruct* GetImage( unsigned int aIdx );
int GetItemStatus( unsigned int aIdx ); UndoRedoOpType GetItemStatus( unsigned int aIdx );
bool SetItem( EDA_BaseStruct* aItem, unsigned aIdx ); bool SetItem( EDA_BaseStruct* aItem, unsigned aIdx );
bool SetItem( EDA_BaseStruct* aItem, int aStatus, unsigned aIdx ); bool SetItem( EDA_BaseStruct* aItem, UndoRedoOpType aStatus, unsigned aIdx );
bool SetLink( EDA_BaseStruct* aItem, unsigned aIdx ); bool SetLink( EDA_BaseStruct* aItem, unsigned aIdx );
bool SetItemStatus( int aStatus, unsigned aIdx ); bool SetItemStatus( UndoRedoOpType aStatus, unsigned aIdx );
bool RemoveItem( unsigned aIdx ); bool RemoveItem( unsigned aIdx );
/** Function CopyList /** Function CopyList
* copy all data from aSource * copy all data from aSource
* Items picked are not copied. just pointer on them are copied * Items picked are not copied. just pointer on them are copied
*/ */
void CopyList(const PICKED_ITEMS_LIST & aSource); void CopyList( const PICKED_ITEMS_LIST& aSource );
}; };
/** /**
......
...@@ -339,8 +339,6 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, ...@@ -339,8 +339,6 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr,
int Internal_Unit ); int Internal_Unit );
/* return a String List from a string, whith a specific splitter*/ /* return a String List from a string, whith a specific splitter*/
//WX_DECLARE_LIST( wxString, StringList );
//WX_DEFINE_LIST( StringList );
wxArrayString* wxStringSplit(wxString txt, wxChar splitter); wxArrayString* wxStringSplit(wxString txt, wxChar splitter);
/** /**
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "wxstruct.h" #include "wxstruct.h"
#include "param_config.h" #include "param_config.h"
#include "class_undoredo_container.h"
class WinEDA_LibeditFrame; class WinEDA_LibeditFrame;
...@@ -33,7 +34,7 @@ class LibDrawField; ...@@ -33,7 +34,7 @@ class LibDrawField;
class SCH_CMP_FIELD; class SCH_CMP_FIELD;
class LibDrawPin; class LibDrawPin;
class DrawJunctionStruct; class DrawJunctionStruct;
class PICKED_ITEMS_LIST;
/*******************************/ /*******************************/
/* class WinEDA_SchematicFrame */ /* class WinEDA_SchematicFrame */
...@@ -368,8 +369,26 @@ private: ...@@ -368,8 +369,26 @@ private:
/* Undo - redo */ /* Undo - redo */
public: public:
void SaveCopyInUndoList( SCH_ITEM* ItemToCopy, int aTypeCommand );
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, int aTypeCommand ); /** Function SaveCopyInUndoList.
* Creates a new entry in undo list of commands.
* add a picker to handle aItemToCopy
* @param aItemToCopy = the schematic item modified by the command to undo
* @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for commands like move
*/
void SaveCopyInUndoList( SCH_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) );
/** Function SaveCopyInUndoList (overloaded).
* Creates a new entry in undo list of commands.
* add a list of pickers to handle a list of items
* @param aItemsList = the list of items modified by the command to undo
* @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for commands like move
*/
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) );
private: private:
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList ); void PutDataInPreviousState( PICKED_ITEMS_LIST* aList );
......
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