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
......
This diff is collapsed.
...@@ -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;
......
...@@ -104,7 +104,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -104,7 +104,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
copySelectedFieldToPanel(); copySelectedFieldToPanel();
wxToolTip::Enable( true ); wxToolTip::Enable( true );
if( GetSizer() ) if( GetSizer() )
{ {
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
...@@ -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;
} }
......
This diff is collapsed.
...@@ -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
...@@ -172,20 +176,21 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) ...@@ -172,20 +176,21 @@ 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:
delete item; 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 @@ ...@@ -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,10 +76,10 @@ public: ...@@ -60,10 +76,10 @@ 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;
m_Link = NULL; m_Link = NULL;
} }
}; };
...@@ -76,28 +92,28 @@ public: ...@@ -76,28 +92,28 @@ 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;
public: public:
PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST();
~PICKED_ITEMS_LIST(); ~PICKED_ITEMS_LIST();
void PushItem( ITEM_PICKER& aItem ); void PushItem( ITEM_PICKER& aItem );
ITEM_PICKER PopItem(); ITEM_PICKER PopItem();
/** Function ClearItemsList /** Function ClearItemsList
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself * delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
*/ */
void ClearItemsList(); void ClearItemsList();
/** Function ClearListAndDeleteItems /** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item * delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
*/ */
void ClearListAndDeleteItems(); void ClearListAndDeleteItems();
unsigned GetCount() const unsigned GetCount() const
{ {
...@@ -105,21 +121,21 @@ public: ...@@ -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* 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