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 @@
PICKED_ITEMS_LIST::PICKED_ITEMS_LIST()
{
m_UndoRedoType = 0;
m_Status = UR_UNSPECIFIED;
};
PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()
......@@ -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() )
return m_ItemsList[aIdx].m_UndoRedoStatus;
else
return 0;
return UR_UNSPECIFIED;
}
......@@ -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() )
{
......@@ -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() )
{
......
......@@ -45,7 +45,7 @@ void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop!
screen->AddToDrawList( this );
g_ItemToRepeat = this;
frame->SaveCopyInUndoList( this, IS_NEW );
frame->SaveCopyInUndoList( this, UR_NEW );
}
m_Flags = 0;
......
......@@ -73,6 +73,7 @@ set(EESCHEMA_SRCS
erc.cpp
files-io.cpp
find.cpp
geometric_transforms.cpp
getpart.cpp
hierarch.cpp
hotkeys.cpp
......
......@@ -14,20 +14,23 @@
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "class_marker_sch.h"
#include "protos.h"
/* 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 */
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
/* Fonctions Locales */
static void PlaceItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
static void MoveListOfItems( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
static void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList );
static void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
......@@ -37,9 +40,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
bool erase );
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 )
......@@ -138,9 +138,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur )
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();
break;
......@@ -149,10 +149,10 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
CopyItemsInList( GetScreen(), block->m_ItemsSelection );
DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
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();
break;
......@@ -285,11 +285,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
wxPoint oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection );
PlaceItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection );
GetScreen()->m_Curseur = oldpos;
MoveItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection, move_vector);
ii = -1;
}
block->ClearItemsList();
......@@ -409,11 +407,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
wxPoint oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection );
PlaceItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection );
GetScreen()->m_Curseur = oldpos;
MoveItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection, move_vector );
ii = -1;
}
break;
......@@ -435,13 +431,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
SaveCopyInUndoList( block->m_ItemsSelection, IS_CHANGED );
ii = -1;
/* Compute the mirror centre and put it on grid */
wxPoint Center = block->Centre();
PutOnGrid( &Center );
MirrorListOfItems( block->m_ItemsSelection, Center );
wxPoint mirrorPoint = block->Centre();
PutOnGrid( &mirrorPoint );
SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint );
MirrorListOfItems( block->m_ItemsSelection, mirrorPoint );
GetScreen()->SetModify();
}
TestDanglingEnds( GetScreen()->EEDrawList, DC );
......@@ -487,9 +482,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{
schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii );
DrawStructsInGhost( panel, DC, schitem,
block->m_MoveVector.x,
block->m_MoveVector.y );
DrawStructsInGhost( panel, DC, schitem, block->m_MoveVector );
}
}
......@@ -502,202 +495,14 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{
schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii );
DrawStructsInGhost( panel, DC, schitem,
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;
DrawStructsInGhost( panel, DC, schitem, block->m_MoveVector );
}
}
/*****************************************************************************
* 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.
......@@ -713,7 +518,7 @@ void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList )
{
newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetItemData( ii ) );
aItemsList.SetItem( newitem, ii );
aItemsList.SetItemStatus( IS_NEW, ii );
aItemsList.SetItemStatus( UR_NEW, ii );
{
switch( newitem->Type() )
{
......@@ -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 )
* accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct
*) DrawStruct )->GetParent(),
IS_CHANGED );
UR_CHANGED );
frame->DeleteSheetLabel( DC ? true : false,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct );
return;
......@@ -791,7 +596,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
DrawStruct->SetNext( 0 );
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 )
}
PICKED_ITEMS_LIST picklist;
picklist.m_UndoRedoType = IS_NEW;
// 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++ )
{
Struct = DuplicateStruct( (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetItemData( ii ) );
......@@ -858,9 +662,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
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 */
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
......@@ -887,7 +691,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
itemWrapper.m_Item = item;
itemWrapper.m_UndoRedoStatus = IS_DELETED;
itemWrapper.m_UndoRedoStatus = UR_DELETED;
if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
/* 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 )
Hierarchical_PIN_Sheet_Struct* pinlabel = (Hierarchical_PIN_Sheet_Struct*) item;
frame->DeleteSheetLabel( false, pinlabel->m_Parent );
itemWrapper.m_Item = pinlabel->m_Parent;
itemWrapper.m_UndoRedoStatus = IS_CHANGED;
itemWrapper.m_UndoRedoStatus = UR_CHANGED;
itemsList.PushItem( itemWrapper );
#endif
}
......@@ -912,138 +716,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
}
}
frame->SaveCopyInUndoList( itemsList, IS_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;
}
frame->SaveCopyInUndoList( itemsList, UR_DELETED );
}
......@@ -1113,9 +786,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy();
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCREEN_STRUCT_TYPE:
default:
{
wxString msg;
......
......@@ -357,7 +357,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
DrawPanel->CursorOn( DC ); // Display schematic cursor
SaveCopyInUndoList( s_OldWiresList, IS_WIRE_IMAGE );
SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE );
s_OldWiresList = NULL;
GetScreen()->SetModify();
......@@ -548,7 +548,7 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
GetScreen()->EEDrawList = NewJunction;
GetScreen()->SetModify();
if( PutInUndoList )
SaveCopyInUndoList( NewJunction, IS_NEW );
SaveCopyInUndoList( NewJunction, UR_NEW );
return NewJunction;
}
......@@ -572,7 +572,7 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
NewNoConnect->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = NewNoConnect;
GetScreen()->SetModify();
SaveCopyInUndoList( NewNoConnect, IS_NEW );
SaveCopyInUndoList( NewNoConnect, UR_NEW );
return NewNoConnect;
}
......@@ -734,7 +734,7 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
GetScreen()->EEDrawList = g_ItemToRepeat;
TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( g_ItemToRepeat, IS_NEW );
SaveCopyInUndoList( g_ItemToRepeat, UR_NEW );
g_ItemToRepeat->m_Flags = 0;
// GetScreen()->Curseur = new_pos;
......
......@@ -145,7 +145,7 @@ void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
/* Put old item in undo list if it is not currently in edit */
if( BusEntry->m_Flags == 0 )
SaveCopyInUndoList( BusEntry, IS_CHANGED );
SaveCopyInUndoList( BusEntry, UR_CHANGED );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
......
......@@ -416,7 +416,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == component->Type()) )
{
component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
frame->SaveCopyInUndoList( component, IS_CHANGED );
frame->SaveCopyInUndoList( component, UR_CHANGED );
component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
}
......
......@@ -454,7 +454,7 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
SwapData( (SCH_TEXT*) g_ItemToUndoCopy );
/* save in undo list */
frame->SaveCopyInUndoList( this, IS_CHANGED );
frame->SaveCopyInUndoList( this, UR_CHANGED );
/* restore new values */
SwapData( (SCH_TEXT*) g_ItemToUndoCopy );
......
......@@ -155,7 +155,7 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint,
/* Ici il faut couper le segment en 2 */
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;
aPicklist->PushItem(picker);
}
......@@ -167,7 +167,7 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint,
DrawList = NewSegment;
if( aPicklist )
{
ITEM_PICKER picker(NewSegment, IS_NEW);
ITEM_PICKER picker(NewSegment, UR_NEW);
aPicklist->PushItem(picker);
}
}
......
......@@ -615,7 +615,7 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
/* save in undo list */
frame->SaveCopyInUndoList( this, IS_CHANGED );
frame->SaveCopyInUndoList( this, UR_CHANGED );
/* restore new values */
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
......
......@@ -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
* of items to delete
*/
ITEM_PICKER picker(NULL, IS_DELETED);
ITEM_PICKER picker(NULL, UR_DELETED);
SCH_SCREEN* screen = (SCH_SCREEN*) GetScreen();
SCH_ITEM* savedEEDrawList = screen->EEDrawList; // Save the list entry point of this screen
DelStruct = GetScreen()->EEDrawList;
......
......@@ -104,7 +104,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
copySelectedFieldToPanel();
wxToolTip::Enable( true );
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
......@@ -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 ... */
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
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
......
......@@ -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 ... */
if( Field->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED );
SaveCopyInUndoList( Cmp, UR_CHANGED );
wxString newtext = Field->m_Text;
DrawPanel->m_IgnoreMouseEvents = TRUE;
......@@ -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 ... */
if( Field->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED );
SaveCopyInUndoList( Cmp, UR_CHANGED );
Field->m_AddExtraText = flag;
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
......@@ -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 ... */
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED );
SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->SetRef(GetSheet(), ref);
Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
......@@ -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 ... */
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED );
SaveCopyInUndoList( Cmp, UR_CHANGED );
TextField->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
TextField->m_Text = message;
......@@ -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 ...
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED );
SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
// move the field if it was new.
......
......@@ -39,7 +39,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
/* save old text in undo list if not already in edit */
if( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_CurrentText, IS_CHANGED );
m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
text = m_TextLabel->GetValue();
if( !text.IsEmpty() )
......@@ -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 */
if( TextStruct->m_Flags == 0 )
SaveCopyInUndoList( TextStruct, IS_CHANGED );
SaveCopyInUndoList( TextStruct, UR_CHANGED );
/* Effacement du texte en cours */
DrawPanel->CursorOff( DC );
......@@ -432,7 +432,7 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
*/
if( (flags & IS_NEW) == 0 )
{
SaveCopyInUndoList( newtext, IS_NEW );
SaveCopyInUndoList( newtext, UR_NEW );
}
else
{
......
......@@ -164,25 +164,23 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
* de structures.
* Utilisee dans les deplacements de blocs
*/
void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* DrawStruct, int dx, int dy )
void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset )
{
int DrawMode = g_XorMode;
int width = g_DrawDefaultLineThickness;
GRSetDrawMode( aDC, DrawMode );
GRSetDrawMode( DC, DrawMode );
switch( DrawStruct->Type() )
switch( aItem->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
{
DrawPolylineStruct* Struct = (DrawPolylineStruct*) DrawStruct;
GRMoveTo( Struct->m_PolyPoints[0].x + dx,
Struct->m_PolyPoints[0].y + dy );
DrawPolylineStruct* Struct = (DrawPolylineStruct*) aItem;
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
Struct->m_PolyPoints[0].y + aOffset.y );
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
GRLineTo( &panel->m_ClipBox, DC, Struct->m_PolyPoints[ii].x + dx,
Struct->m_PolyPoints[ii].y + dy, width, g_GhostColor );
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_PolyPoints[ii].x + aOffset.x,
Struct->m_PolyPoints[ii].y + aOffset.y, width, g_GhostColor );
break;
}
......@@ -190,10 +188,10 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
case DRAW_SEGMENT_STRUCT_TYPE:
{
EDA_DrawLineStruct* Struct;
Struct = (EDA_DrawLineStruct*) DrawStruct;
Struct = (EDA_DrawLineStruct*) aItem;
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
{
......@@ -201,12 +199,12 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
}
if( (Struct->m_Flags & ENDPOINT) == 0 )
{
GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x + dx,
Struct->m_End.y + dy, width, g_GhostColor );
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x + aOffset.x,
Struct->m_End.y + aOffset.y, width, g_GhostColor );
}
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 );
}
break;
......@@ -214,27 +212,27 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
case DRAW_BUSENTRY_STRUCT_TYPE:
{
DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) DrawStruct;
int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy;
GRMoveTo( xx, yy );
GRLineTo( &panel->m_ClipBox, DC, Struct->m_Size.x + xx,
Struct->m_Size.y + yy, width, g_GhostColor );
DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) aItem;
wxPoint start = Struct->m_Pos + aOffset;
GRMoveTo( start.x, start.y );
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x,
Struct->m_Size.y + start.y, width, g_GhostColor );
break;
}
case DRAW_JUNCTION_STRUCT_TYPE:
{
DrawJunctionStruct* Struct;
Struct = (DrawJunctionStruct*) DrawStruct;
Struct->Draw( panel, DC, wxPoint(0,0), DrawMode, g_GhostColor );
Struct = (DrawJunctionStruct*) aItem;
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break;
}
case TYPE_SCH_TEXT:
{
SCH_TEXT* Struct;
Struct = (SCH_TEXT*) DrawStruct;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor );
Struct = (SCH_TEXT*) aItem;
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break;
}
......@@ -243,16 +241,16 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
case TYPE_SCH_HIERLABEL:
{
SCH_LABEL* Struct;
Struct = (SCH_LABEL*) DrawStruct;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor );
Struct = (SCH_LABEL*) aItem;
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break;
}
case DRAW_NOCONNECT_STRUCT_TYPE:
{
DrawNoConnectStruct* Struct;
Struct = (DrawNoConnectStruct*) DrawStruct;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor );
Struct = (DrawNoConnectStruct*) aItem;
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
break;
}
......@@ -260,23 +258,23 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
{
EDA_LibComponentStruct* LibEntry;
SCH_COMPONENT* Struct;
Struct = (SCH_COMPONENT*) DrawStruct;
Struct = (SCH_COMPONENT*) aItem;
LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT );
if( LibEntry == NULL )
break;
DrawingLibInGhost( panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx,
Struct->m_Pos.y + dy, Struct->m_Multi,
DrawingLibInGhost( aPanel, aDC, LibEntry, Struct, Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + aOffset.y, Struct->m_Multi,
Struct->m_Convert, g_GhostColor, FALSE );
break;
}
case DRAW_SHEET_STRUCT_TYPE:
{
DrawSheetStruct* Struct = (DrawSheetStruct*) DrawStruct;
GRRect( &panel->m_ClipBox, DC, Struct->m_Pos.x + dx,
Struct->m_Pos.y + dy, Struct->m_Pos.x + Struct->m_Size.x + dx,
Struct->m_Pos.y + Struct->m_Size.y + dy, width, g_GhostColor );
DrawSheetStruct* Struct = (DrawSheetStruct*) aItem;
GRRect( &aPanel->m_ClipBox, aDC, Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + aOffset.y, Struct->m_Pos.x + Struct->m_Size.x + aOffset.x,
Struct->m_Pos.y + Struct->m_Size.y + aOffset.y, width, g_GhostColor );
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,
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();
Component->DisplayInfo( this );
......@@ -255,14 +255,14 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* Effacement du composant */
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.y = screen->m_Curseur.y - Component->m_Pos.y;
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(
{
DrawPanel->CursorOff( DC );
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else
{
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() );
......@@ -296,7 +296,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir(
if( DC )
{
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ),
......@@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
/* Efface le trace precedent */
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
......@@ -388,10 +388,9 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
/* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ), GR_DEFAULT_DRAWMODE );
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds( GetScreen()->EEDrawList, DC );
GetScreen()->SetModify();
......@@ -421,7 +420,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
/* Efface le trace precedent */
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
......@@ -431,10 +430,9 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
/* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags & IS_MOVED )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ), GR_DEFAULT_DRAWMODE );
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds( GetScreen()->EEDrawList, DC );
GetScreen()->SetModify();
......@@ -508,7 +506,7 @@ void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component,
Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only
DrawPanel->PostDirtyRect( Component->GetBoundingBox() );
DrawStructsInGhost( DrawPanel, DC, Component, 0, 0 );
DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) );
#else
......
......@@ -331,7 +331,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
case TYPE_SCH_COMPONENT:
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE;
}
......@@ -345,7 +345,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
case TYPE_SCH_HIERLABEL:
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE;
}
ChangeTextOrient( (SCH_TEXT*) DrawStruct, DC );
......@@ -364,7 +364,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_Y );
......@@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_X );
......@@ -392,7 +392,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_NORMAL );
......
......@@ -166,8 +166,7 @@ Hierarchical_PIN_Sheet_Struct * LocateAnyPinSheet(const wxPoint & RefPos,
void DrawDanglingSymbol(WinEDA_DrawPanel * panel,wxDC * DC,
const wxPoint & pos, int Color);
void DrawStructsInGhost(WinEDA_DrawPanel * panel, wxDC * DC,
SCH_ITEM * DrawStruct, int dx, int dy );
void DrawStructsInGhost(WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset );
void SetHighLightStruct(SCH_ITEM *HighLight);
void RedrawActiveWindow(WinEDA_DrawPanel * panel, wxDC * DC);
void RedrawStructList(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *Structs, int DrawMode,
......
......@@ -341,7 +341,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
PICKED_ITEMS_LIST picklistForUndo;
BreakSegment( screen, screen->m_Curseur, &picklistForUndo );
if( picklistForUndo.GetCount() )
SaveCopyInUndoList( picklistForUndo, IS_NEW | IS_CHANGED );
SaveCopyInUndoList( picklistForUndo, UR_UNSPECIFIED );
TestDanglingEnds( screen->EEDrawList, &dc );
}
break;
......@@ -485,7 +485,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema();
if( screen->GetCurItem()->m_Flags == 0 )
SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(), IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(), UR_CHANGED );
CmpRotationMiroir(
(SCH_COMPONENT*) screen->GetCurItem(),
......
......@@ -12,6 +12,10 @@
#include "protos.h"
#include "class_marker_sch.h"
// Imported functions
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& aMirrorPoint );
/* Functions to undo and redo edit commands.
* commmands to undo are stored in CurrentScreen->m_UndoList
* commmands to redo are stored in CurrentScreen->m_RedoList
......@@ -172,20 +176,21 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
/***********************************************************************/
void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
int aCommandType )
void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
UndoRedoOpType aCommandType,
const wxPoint& aTransformPoint )
/***********************************************************************/
/** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list.
*
* flag_type_command =
* IS_CHANGED
* IS_NEW
* IS_DELETED
* IS_WIRE_IMAGE
* UR_CHANGED
* UR_NEW
* UR_DELETED
* 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.
* 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,
* Edit wires and busses is a bit complex.
* because when a new wire is added, modifications in wire list
* (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
*/
{
SCH_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
commandToUndo->m_UndoRedoType = aCommandType;
ITEM_PICKER itemWrapper( aItemToCopy, aCommandType );
switch( aCommandType )
{
case IS_CHANGED: /* Create a copy of schematic */
case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( aItemToCopy );
itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = aItemToCopy;
commandToUndo->PushItem( itemWrapper );
break;
case IS_NEW:
case IS_WIRE_IMAGE:
case IS_DELETED:
case UR_NEW:
case UR_WIRE_IMAGE:
case UR_DELETED:
case UR_MOVED:
commandToUndo->PushItem( itemWrapper );
break;
......@@ -237,21 +243,23 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
/** function SaveCopyInUndoList
* @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;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
commandToUndo->m_UndoRedoType = aTypeCommand;
ITEM_PICKER itemWrapper;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* ItemToCopy = (SCH_ITEM*) aItemsList.GetItemData( ii );
int command = aItemsList.GetItemStatus( ii );
if( command == 0 )
SCH_ITEM* ItemToCopy = (SCH_ITEM*) aItemsList.GetItemData( ii );
UndoRedoOpType command = aItemsList.GetItemStatus( ii );
if( command == UR_UNSPECIFIED )
{
command = aTypeCommand;
}
......@@ -259,20 +267,21 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, i
itemWrapper.m_UndoRedoStatus = command;
switch( command )
{
case IS_CHANGED: /* Create a copy of schematic */
case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( ItemToCopy );
itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = ItemToCopy;
commandToUndo->PushItem( itemWrapper );
break;
case IS_NEW:
case IS_NEW | IS_CHANGED: // when more than one item, some are new, some are changed
case UR_MOVED:
case UR_MIRRORED_Y:
case UR_NEW:
commandToUndo->PushItem( itemWrapper );
break;
case IS_DELETED:
ItemToCopy->m_Flags = IS_DELETED;
case UR_DELETED:
ItemToCopy->m_Flags = UR_DELETED;
commandToUndo->PushItem( itemWrapper );
break;
......@@ -344,26 +353,38 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link;
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 );
break;
case IS_NEW: /* new items are deleted */
aList->m_UndoRedoType = IS_DELETED;
aList->SetItemStatus( IS_DELETED, ii );
case UR_NEW: /* new items are deleted */
aList->SetItemStatus( UR_DELETED, ii );
GetScreen()->RemoveFromDrawList( item );
item->m_Flags = IS_DELETED;
item->m_Flags = UR_DELETED;
break;
case IS_DELETED: /* deleted items are put in EEdrawList, as new items */
aList->m_UndoRedoType = IS_NEW;
aList->SetItemStatus( IS_NEW, ii );
case UR_DELETED: /* deleted items are put in EEdrawList, as new items */
aList->SetItemStatus( UR_NEW, ii );
item->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = item;
item->m_Flags = 0;
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 */
alt_item = GetScreen()->ExtractWires( false );
aList->SetItem( alt_item, ii );
......@@ -422,14 +443,14 @@ bool WinEDA_SchematicFrame::GetSchematicFromUndoList()
}
/*********************************************************/
/***********************************************************************************/
void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
/*********************************************************/
/**********************************************************************************/
/** Function ClearUndoORRedoList
* free the undo or redo list from List element
* 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)
* @param aList = the UNDO_REDO_CONTAINER to clear
* @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
* So this function can be called to remove old commands
*/
{
int CmdType;
if( aItemCount == 0 )
return;
......@@ -451,30 +470,36 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
break;
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
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 )
{
ITEM_PICKER wrapper = curr_cmd->PopItem();
EDA_BaseStruct* item = wrapper.m_Item;
if( item == NULL ) // No more item in list.
break;
if( wrapper.m_UndoRedoStatus == IS_WIRE_IMAGE )
switch( wrapper.m_UndoRedoStatus )
{
case UR_WIRE_IMAGE:
while( item )
{
EDA_BaseStruct* nextitem = item->Next();
delete item;
item = nextitem;
}
}
else
{
if( (wrapper.m_UndoRedoStatus & IS_NEW) == 0 )
{
delete item;
}
break;
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;
break;
}
}
......
......@@ -45,10 +45,26 @@
* 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
{
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,
* or in undo redo commands, the copy of an edited item.
*/
......@@ -60,10 +76,10 @@ 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_Item = aItem;
m_Item = aItem;
m_Link = NULL;
}
};
......@@ -76,28 +92,28 @@ public:
class PICKED_ITEMS_LIST
{
public:
int m_UndoRedoType; // type of operation to undo/redo
// UNSPECIFIED (0), IS_NEW, IS_DELETED, IS_CHANGED
wxPoint m_TransformPoint; // used to undo redo command by the same command:
// we usually need to know the rotate point or the move vector
UndoRedoOpType m_Status; /* info about operation to undo/redo for this item. can be UR_UNSPECIFIED */
wxPoint m_TransformPoint; /* used to undo redo command by the same command:
* we usually need to know the rotate point or the move vector
*/
private:
std::vector <ITEM_PICKER> m_ItemsList;
public:
PICKED_ITEMS_LIST();
~PICKED_ITEMS_LIST();
void PushItem( ITEM_PICKER& aItem );
void PushItem( ITEM_PICKER& aItem );
ITEM_PICKER PopItem();
/** Function ClearItemsList
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
*/
void ClearItemsList();
void ClearItemsList();
/** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
*/
void ClearListAndDeleteItems();
void ClearListAndDeleteItems();
unsigned GetCount() const
{
......@@ -105,21 +121,21 @@ public:
}
ITEM_PICKER GetItemWrapper( unsigned int aIdx );
ITEM_PICKER GetItemWrapper( unsigned int aIdx );
EDA_BaseStruct* GetItemData( 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, int aStatus, unsigned aIdx );
bool SetItem( EDA_BaseStruct* aItem, UndoRedoOpType aStatus, 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 );
/** Function CopyList
* copy all data from aSource
* 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,
int Internal_Unit );
/* 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);
/**
......
......@@ -8,6 +8,7 @@
#include "wxstruct.h"
#include "param_config.h"
#include "class_undoredo_container.h"
class WinEDA_LibeditFrame;
......@@ -33,7 +34,7 @@ class LibDrawField;
class SCH_CMP_FIELD;
class LibDrawPin;
class DrawJunctionStruct;
class PICKED_ITEMS_LIST;
/*******************************/
/* class WinEDA_SchematicFrame */
......@@ -368,8 +369,26 @@ private:
/* Undo - redo */
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:
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