Commit 304525db authored by charras's avatar charras

undo/redo rework: fixed some problems ans crashes (not all) in libedit and modedit

parent 8d5a6531
...@@ -219,7 +219,6 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -219,7 +219,6 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START; maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START;
maxZoomIds = ( (size_t) maxZoomIds < GetScreen()->m_ZoomList.GetCount() ) ? maxZoomIds = ( (size_t) maxZoomIds < GetScreen()->m_ZoomList.GetCount() ) ?
maxZoomIds : GetScreen()->m_ZoomList.GetCount(); maxZoomIds : GetScreen()->m_ZoomList.GetCount();
wxLogDebug( _T( "%d zoom IDs used." ), maxZoomIds );
/* Populate zoom submenu. */ /* Populate zoom submenu. */
for( i = 0; i < (size_t) maxZoomIds; i++ ) for( i = 0; i < (size_t) maxZoomIds; i++ )
......
...@@ -229,6 +229,19 @@ public: ...@@ -229,6 +229,19 @@ public:
{ {
} }
/** 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
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) )
{
// currently: do nothing in cvpcb.
}
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -26,7 +26,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, ...@@ -26,7 +26,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy ); CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy );
lastcmd = new PICKED_ITEMS_LIST(); lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(CopyItem); ITEM_PICKER wrapper(CopyItem, UR_LIBEDIT);
lastcmd->PushItem(wrapper); lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
/* Clear current flags (which can be temporary set by a current edit command) */ /* Clear current flags (which can be temporary set by a current edit command) */
...@@ -34,17 +34,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, ...@@ -34,17 +34,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
item->m_Flags = 0; item->m_Flags = 0;
/* Clear redo list, because after new save there is no redo to do */ /* Clear redo list, because after new save there is no redo to do */
while( (lastcmd = GetScreen()->PopCommandFromRedoList( ) ) != NULL ) GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
{
while ( 1 )
{
wrapper = lastcmd->PopItem();
if ( wrapper.m_PickedItem == NULL )
break; // All items are removed
delete wrapper.m_PickedItem;
}
delete lastcmd;
}
} }
...@@ -62,7 +52,7 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event) ...@@ -62,7 +52,7 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(CurrentLibEntry); ITEM_PICKER wrapper(CurrentLibEntry, UR_LIBEDIT);
lastcmd->PushItem(wrapper); lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
...@@ -95,7 +85,7 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event) ...@@ -95,7 +85,7 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(CurrentLibEntry); ITEM_PICKER wrapper(CurrentLibEntry, UR_LIBEDIT);
lastcmd->PushItem(wrapper); lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToRedoList( lastcmd ); GetScreen()->PushCommandToRedoList( lastcmd );
......
...@@ -509,6 +509,10 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -509,6 +509,10 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
case UR_NEW: // Do nothing, items are in use case UR_NEW: // Do nothing, items are in use
break; break;
case UR_LIBEDIT: // Libedit save always a copy of the current item
delete item; // So, the picker is always owner of the picked item
break;
case UR_DELETED: case UR_DELETED:
delete item; // Delete the picked item, because it was deleted from schematic delete item; // Delete the picked item, because it was deleted from schematic
break; break;
......
...@@ -175,6 +175,18 @@ public: ...@@ -175,6 +175,18 @@ public:
const wxPoint& aTransformPoint = wxPoint(0,0) ) 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
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) )
{
// currently: do nothing in gerbview.
}
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
......
...@@ -60,7 +60,9 @@ enum UndoRedoOpType { ...@@ -60,7 +60,9 @@ enum UndoRedoOpType {
UR_MIRRORED_Y, // mirrored item, undo by mirror Y UR_MIRRORED_Y, // mirrored item, undo by mirror Y
UR_ROTATED, // Rotated item, undo by rotating it UR_ROTATED, // Rotated item, undo by rotating it
UR_FLIPPED, // flipped (board items only), undo by flipping it UR_FLIPPED, // flipped (board items only), undo by flipping it
UR_WIRE_IMAGE // Specific to eeschema: handle wires changes UR_WIRE_IMAGE, // Specific to eeschema: handle wires changes
UR_MODEDIT, // Specific to the module editor (modedit creates a full copy of the current module when changed)
UR_LIBEDIT // Specific to the component editor (libedit creates a full copy of the current component when changed)
}; };
class ITEM_PICKER class ITEM_PICKER
......
...@@ -310,6 +310,16 @@ public: ...@@ -310,6 +310,16 @@ public:
virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand, virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) ) = 0; const wxPoint& aTransformPoint = wxPoint(0,0) ) = 0;
/** Function SaveCopyInUndoList (virtual pure, 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
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) ) = 0;
// layerhandling: // layerhandling:
// (See pcbnew/sel_layer.cpp for description of why null_layer parameter is provided) // (See pcbnew/sel_layer.cpp for description of why null_layer parameter is provided)
......
...@@ -143,7 +143,7 @@ public: ...@@ -143,7 +143,7 @@ public:
* @param aTypeCommand = command type (see enum UndoRedoOpType) * @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for commands like move * @param aTransformPoint = the reference point of the transformation, for commands like move
*/ */
void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand, virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) ); const wxPoint& aTransformPoint = wxPoint(0,0) );
/** Function SaveCopyInUndoList (overloaded). /** Function SaveCopyInUndoList (overloaded).
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
* @param aTypeCommand = command type (see enum UndoRedoOpType) * @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for commands like move * @param aTransformPoint = the reference point of the transformation, for commands like move
*/ */
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand, virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) ); const wxPoint& aTransformPoint = wxPoint(0,0) );
/** Function PutDataInPreviousState() /** Function PutDataInPreviousState()
...@@ -650,9 +650,26 @@ public: ...@@ -650,9 +650,26 @@ public:
/* Undo and redo functions */ /* Undo and redo functions */
public: public:
virtual void SaveCopyInUndoList( BOARD_ITEM* ItemToCopy, /** Function SaveCopyInUndoList.
UndoRedoOpType aTypeCommand = UR_UNSPECIFIED, * Creates a new entry in undo list of commands.
* add a picker to handle aItemToCopy
* @param aItem = the board 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
*/
virtual void SaveCopyInUndoList( BOARD_ITEM* aItem, 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
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) ); const wxPoint& aTransformPoint = wxPoint(0,0) );
private: private:
void GetComponentFromUndoList(wxCommandEvent& event); void GetComponentFromUndoList(wxCommandEvent& event);
void GetComponentFromRedoList(wxCommandEvent& event); void GetComponentFromRedoList(wxCommandEvent& event);
......
...@@ -152,7 +152,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -152,7 +152,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
DeleteMarkedItems( Currentmodule ); DeleteMarkedItems( Currentmodule );
break; break;
...@@ -163,7 +163,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -163,7 +163,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_ROTATE: case BLOCK_ROTATE:
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
...@@ -173,7 +173,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -173,7 +173,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_INVERT: /* mirror */ case BLOCK_INVERT: /* mirror */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
...@@ -240,14 +240,14 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -240,14 +240,14 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
MoveMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector ); MoveMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
CopyMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector ); CopyMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector );
break; break;
...@@ -258,12 +258,12 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -258,12 +258,12 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
case BLOCK_INVERT: /* Mirror by popup menu, from block move */ case BLOCK_INVERT: /* Mirror by popup menu, from block move */
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule, UR_CHANGED );
RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
......
This diff is collapsed.
...@@ -102,7 +102,8 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -102,7 +102,8 @@ void MODULE::Copy( MODULE* aModule )
m_Reference->Copy( aModule->m_Reference ); m_Reference->Copy( aModule->m_Reference );
m_Value->Copy( aModule->m_Value ); m_Value->Copy( aModule->m_Value );
/* Copie des structures auxiliaires: Pads */ /* Copy auxiliary data: Pads */
m_Pads.DeleteAll();
for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() )
{ {
D_PAD* newpad = new D_PAD( this ); D_PAD* newpad = new D_PAD( this );
...@@ -111,7 +112,8 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -111,7 +112,8 @@ void MODULE::Copy( MODULE* aModule )
m_Pads.PushBack( newpad ); m_Pads.PushBack( newpad );
} }
/* Copy des structures auxiliaires: Drawings */ /* Copy auxiliary data: Drawings */
m_Drawings.DeleteAll();
for( BOARD_ITEM* item = aModule->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aModule->m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
...@@ -131,11 +133,13 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -131,11 +133,13 @@ void MODULE::Copy( MODULE* aModule )
break; break;
default: default:
wxMessageBox( wxT( "Internal Err: CopyModule: type indefini" ) ); wxMessageBox( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
break; break;
} }
} }
/* Copy auxiliary data: 3D_Drawings info */
m_3D_Drawings.DeleteAll();
for( S3D_MASTER* item = aModule->m_3D_Drawings; item; item = item->Next() ) for( S3D_MASTER* item = aModule->m_3D_Drawings; item; item = item->Next() )
{ {
if ( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes. if ( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes.
......
...@@ -191,8 +191,7 @@ void D_PAD::Copy( D_PAD* source ) ...@@ -191,8 +191,7 @@ void D_PAD::Copy( D_PAD* source )
m_Offset = source->m_Offset; // Offset de la forme m_Offset = source->m_Offset; // Offset de la forme
m_Size = source->m_Size; // Dimension ( pour orient 0 ) m_Size = source->m_Size; // Dimension ( pour orient 0 )
m_DeltaSize = source->m_DeltaSize; // delta sur formes rectangle -> trapezes m_DeltaSize = source->m_DeltaSize; // delta sur formes rectangle -> trapezes
m_Pos0 = source->m_Pos0; // Coord relatives a l'ancre du pad en m_Pos0 = source->m_Pos0; /* Coord relatives a l'ancre du pad en orientation 0 */
// orientation 0
m_Rayon = source->m_Rayon; // rayon du cercle exinscrit du pad m_Rayon = source->m_Rayon; // rayon du cercle exinscrit du pad
m_PadShape = source->m_PadShape; // forme CERCLE, PAD_RECT PAD_OVAL PAD_TRAPEZOID ou libre m_PadShape = source->m_PadShape; // forme CERCLE, PAD_RECT PAD_OVAL PAD_TRAPEZOID ou libre
m_Attribut = source->m_Attribut; // NORMAL, PAD_SMD, PAD_CONN, Bit 7 = STACK m_Attribut = source->m_Attribut; // NORMAL, PAD_SMD, PAD_CONN, Bit 7 = STACK
......
...@@ -60,15 +60,11 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -60,15 +60,11 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
{ {
if( Edge == NULL ) if( Edge == NULL )
return; return;
Edge->m_Start.x -= MoveVector.x; Edge->m_Start -= MoveVector;
Edge->m_Start.y -= MoveVector.y; Edge->m_End -= MoveVector;
Edge->m_End.x -= MoveVector.x;
Edge->m_End.y -= MoveVector.y;
Edge->m_Start0.x -= MoveVector.x; Edge->m_Start0 -= MoveVector;
Edge->m_Start0.y -= MoveVector.y; Edge->m_End0 -= MoveVector;
Edge->m_End0.x -= MoveVector.x;
Edge->m_End0.y -= MoveVector.y;
Edge->Draw( DrawPanel, DC, GR_OR ); Edge->Draw( DrawPanel, DC, GR_OR );
Edge->m_Flags = 0; Edge->m_Flags = 0;
...@@ -131,10 +127,8 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -131,10 +127,8 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Edge->m_End = screen->m_Curseur; Edge->m_End = screen->m_Curseur;
/* Mise a jour des coord relatives */ /* Mise a jour des coord relatives */
Edge->m_End0.x = Edge->m_End.x - Module->m_Pos.x; Edge->m_End0 = Edge->m_End - Module->m_Pos;
Edge->m_End0.y = Edge->m_End.y - Module->m_Pos.y; RotatePoint( &Edge->m_End0, -Module->m_Orient );
RotatePoint( (int*) &Edge->m_End0.x,
(int*) &Edge->m_End0.y, -Module->m_Orient );
Edge->Draw( panel, DC, GR_XOR ); Edge->Draw( panel, DC, GR_XOR );
...@@ -155,7 +149,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge ) ...@@ -155,7 +149,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
SaveCopyInUndoList( Module ); SaveCopyInUndoList( Module, UR_MODEDIT );
if( Edge == NULL ) if( Edge == NULL )
{ {
...@@ -205,7 +199,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge ) ...@@ -205,7 +199,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
return; return;
} }
SaveCopyInUndoList( Module ); SaveCopyInUndoList( Module, UR_MODEDIT );
if( Edge == NULL ) if( Edge == NULL )
{ {
...@@ -341,7 +335,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -341,7 +335,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
if( Edge == NULL ) /* Start a new edge item */ if( Edge == NULL ) /* Start a new edge item */
{ {
SaveCopyInUndoList( module ); SaveCopyInUndoList( module, UR_MODEDIT );
Edge = new EDGE_MODULE( module ); Edge = new EDGE_MODULE( module );
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
...@@ -372,11 +366,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -372,11 +366,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge->m_End = Edge->m_Start; Edge->m_End = Edge->m_Start;
/* Initialise the relative coordinates */ /* Initialise the relative coordinates */
Edge->m_Start0.x = Edge->m_Start.x - module->m_Pos.x; Edge->m_Start0 = Edge->m_Start - module->m_Pos;
Edge->m_Start0.y = Edge->m_Start.y - module->m_Pos.y;
RotatePoint( (int*) &Edge->m_Start0.x, RotatePoint( &Edge->m_Start0, -module->m_Orient );
(int*) &Edge->m_Start0.y, -module->m_Orient );
Edge->m_End0 = Edge->m_Start0; Edge->m_End0 = Edge->m_Start0;
module->Set_Rectangle_Encadrement(); module->Set_Rectangle_Encadrement();
...@@ -401,9 +393,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -401,9 +393,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
// insert _after_ Edge, which is the same as inserting _before_ Edge->Next() // insert _after_ Edge, which is the same as inserting _before_ Edge->Next()
module->m_Drawings.Insert( newedge, Edge->Next() ); module->m_Drawings.Insert( newedge, Edge->Next() );
Edge->m_Flags = 0; Edge->m_Flags = 0;
Edge = newedge;
Edge = newedge; // point now new item
Edge->m_Flags = IS_NEW; Edge->m_Flags = IS_NEW;
Edge->m_Width = ModuleSegmentWidth; Edge->m_Width = ModuleSegmentWidth;
...@@ -411,11 +403,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -411,11 +403,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge->m_End = Edge->m_Start; Edge->m_End = Edge->m_Start;
/* Mise a jour des coord relatives */ /* Mise a jour des coord relatives */
Edge->m_Start0.x = Edge->m_Start.x - module->m_Pos.x; Edge->m_Start0 = Edge->m_Start - module->m_Pos;
Edge->m_Start0.y = Edge->m_Start.y - module->m_Pos.y;
RotatePoint( (int*) &Edge->m_Start0.x, RotatePoint( &Edge->m_Start0, -module->m_Orient );
(int*) &Edge->m_Start0.y, -module->m_Orient );
Edge->m_End0 = Edge->m_Start0; Edge->m_End0 = Edge->m_Start0;
...@@ -425,7 +415,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -425,7 +415,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
} }
} }
else else
DisplayError( this, wxT( "Begin_Edge() error" ) ); wxMessageBox( wxT( "Begin_Edge() error" ) );
} }
return Edge; return Edge;
} }
...@@ -439,16 +429,13 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -439,16 +429,13 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
/* If last segment length is 0: deletion */
if( Edge ) if( Edge )
{ {
if( (Edge->m_Start.x == Edge->m_End.x) Edge->m_Flags = 0;
&& (Edge->m_Start.y == Edge->m_End.y) ) /* If last segment length is 0: remove it */
{ if( Edge->m_Start == Edge->m_End )
Edge ->DeleteStructure(); Edge ->DeleteStructure();
}
} }
Edge->m_Flags = 0;
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
GetScreen()->SetModify(); GetScreen()->SetModify();
......
...@@ -821,6 +821,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -821,6 +821,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
Import_Pad_Settings( (D_PAD*) GetCurItem(), true ); Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
break; break;
...@@ -835,6 +836,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -835,6 +836,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_DELETE_PAD: case ID_POPUP_PCB_DELETE_PAD:
SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
DeletePad( (D_PAD*) GetCurItem() ); DeletePad( (D_PAD*) GetCurItem() );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
......
...@@ -110,7 +110,6 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod ) ...@@ -110,7 +110,6 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
} }
pt_mod->Set_Rectangle_Encadrement(); pt_mod->Set_Rectangle_Encadrement();
DrawPanel->Refresh();
} }
......
...@@ -475,20 +475,20 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -475,20 +475,20 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_DELETE_PAD: case ID_POPUP_PCB_DELETE_PAD:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
DeletePad( (D_PAD*) GetScreen()->GetCurItem() ); DeletePad( (D_PAD*) GetScreen()->GetCurItem() );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true ); Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true );
break; break;
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Global_Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true ); Global_Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
...@@ -526,7 +526,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -526,7 +526,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_DELETE_TEXTMODULE: case ID_POPUP_PCB_DELETE_TEXTMODULE:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem() ); DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem() );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
...@@ -586,7 +586,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -586,7 +586,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_DELETE_EDGE: case ID_POPUP_PCB_DELETE_EDGE:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
RemoveStruct( GetScreen()->GetCurItem() ); RemoveStruct( GetScreen()->GetCurItem() );
SetCurItem( NULL ); SetCurItem( NULL );
...@@ -597,7 +597,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -597,7 +597,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_MODULE_SCALE: case ID_MODEDIT_MODULE_SCALE:
case ID_MODEDIT_MODULE_SCALEX: case ID_MODEDIT_MODULE_SCALEX:
case ID_MODEDIT_MODULE_SCALEY: case ID_MODEDIT_MODULE_SCALEY:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Transform( (MODULE*) GetScreen()->GetCurItem(), id ); Transform( (MODULE*) GetScreen()->GetCurItem(), id );
redraw = true; redraw = true;
break; break;
......
...@@ -31,12 +31,12 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -31,12 +31,12 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC ); PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC );
break; break;
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Place_EdgeMod( (EDGE_MODULE*) DrawStruct, DC ); Place_EdgeMod( (EDGE_MODULE*) DrawStruct, DC );
break; break;
...@@ -118,7 +118,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -118,7 +118,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = ModeditLocateAndDisplay(); DrawStruct = ModeditLocateAndDisplay();
if( DrawStruct && (DrawStruct->m_Flags == 0) ) if( DrawStruct && (DrawStruct->m_Flags == 0) )
{ {
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
RemoveStruct( DrawStruct ); RemoveStruct( DrawStruct );
SetCurItem( DrawStruct = NULL ); SetCurItem( DrawStruct = NULL );
} }
...@@ -126,26 +126,30 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -126,26 +126,30 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_MODEDIT_PLACE_ANCHOR: case ID_MODEDIT_PLACE_ANCHOR:
SaveCopyInUndoList( GetBoard()->m_Modules ); {
Place_Ancre( GetBoard()->m_Modules ); MODULE * module = GetBoard()->m_Modules;
GetBoard()->m_Modules->m_Flags = 0; module->m_Flags = 0;
SaveCopyInUndoList( module, UR_MODEDIT );
Place_Ancre( module ); // set the new relatives internal coordinates of items
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
Recadre_Trace( TRUE ); Recadre_Trace( TRUE );
Place_Module( GetBoard()->m_Modules, DC ); // Replace the module in position 0, to recalculate absolutes coordinates of items
RedrawActiveWindow( DC, TRUE ); module->SetPosition( wxPoint(0,0) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->Refresh();
}
break; break;
case ID_TEXT_COMMENT_BUTT: case ID_TEXT_COMMENT_BUTT:
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
CreateTextModule( GetBoard()->m_Modules, DC ); CreateTextModule( GetBoard()->m_Modules, DC );
break; break;
case ID_MODEDIT_ADD_PAD: case ID_MODEDIT_ADD_PAD:
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
{ {
SaveCopyInUndoList( GetBoard()->m_Modules ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
AddPad( GetBoard()->m_Modules, true ); AddPad( GetBoard()->m_Modules, true );
} }
break; break;
......
...@@ -12,23 +12,28 @@ ...@@ -12,23 +12,28 @@
#include "protos.h" #include "protos.h"
/**************************************************************************/ /** Function SaveCopyInUndoList.
void WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* ItemToCopy, * Creates a new entry in undo list of commands.
UndoRedoOpType aTypeCommand, * add a picker to handle aItemToCopy
const wxPoint& aTransformPoint ) * @param aItem = the board 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 WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint )
{ {
EDA_BaseStruct* item; EDA_BaseStruct* item;
MODULE* CopyItem; MODULE* CopyItem;
PICKED_ITEMS_LIST* lastcmd; PICKED_ITEMS_LIST* lastcmd;
CopyItem = new MODULE( GetBoard() ); CopyItem = new MODULE( GetBoard() );
CopyItem->Copy( (MODULE*) ItemToCopy ); CopyItem->Copy( (MODULE*) aItem );
CopyItem->SetParent( GetBoard() ); CopyItem->SetParent( GetBoard() );
lastcmd = new PICKED_ITEMS_LIST(); lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(CopyItem); ITEM_PICKER wrapper( CopyItem, UR_MODEDIT );
lastcmd->PushItem(wrapper); lastcmd->PushItem( wrapper );
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
/* Clear current flags (which can be temporary set by a current edit command) */ /* Clear current flags (which can be temporary set by a current edit command) */
...@@ -36,22 +41,28 @@ void WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* ItemToCopy, ...@@ -36,22 +41,28 @@ void WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* ItemToCopy,
item->m_Flags = 0; item->m_Flags = 0;
/* Clear redo list, because after new save there is no redo to do */ /* Clear redo list, because after new save there is no redo to do */
while( (lastcmd = GetScreen()->PopCommandFromRedoList( ) ) != NULL ) GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
{ }
while ( 1 )
{
wrapper = lastcmd->PopItem(); /** Function SaveCopyInUndoList (overloaded).
if ( wrapper.m_PickedItem == NULL ) * Creates a new entry in undo list of commands.
break; // All items are removed * add a list of pickers to handle a list of items
delete wrapper.m_PickedItem; * @param aItemsList = the list of items modified by the command to undo
} * @param aTypeCommand = command type (see enum UndoRedoOpType)
delete lastcmd; * @param aTransformPoint = the reference point of the transformation, for commands like move
} */
void WinEDA_ModuleEditFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint )
{
// Currently Unused in modedit
wxMessageBox( wxT( "SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList..) not yet in use" ) );
} }
/*********************************************************/ /*********************************************************/
void WinEDA_ModuleEditFrame::GetComponentFromRedoList(wxCommandEvent& event) void WinEDA_ModuleEditFrame::GetComponentFromRedoList( wxCommandEvent& event )
/*********************************************************/ /*********************************************************/
/* Redo the last edition: /* Redo the last edition:
...@@ -59,15 +70,15 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList(wxCommandEvent& event) ...@@ -59,15 +70,15 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList(wxCommandEvent& event)
* - Get old version of the current edited library component * - Get old version of the current edited library component
*/ */
{ {
if ( GetScreen()->GetRedoCommandCount() <= 0 ) if( GetScreen()->GetRedoCommandCount() <= 0 )
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper( GetBoard()->m_Modules.PopFront() ); ITEM_PICKER wrapper( GetBoard()->m_Modules.PopFront(), UR_MODEDIT );
lastcmd->PushItem(wrapper); lastcmd->PushItem( wrapper );
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
lastcmd = GetScreen()->PopCommandFromRedoList( ); lastcmd = GetScreen()->PopCommandFromRedoList();
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
...@@ -82,7 +93,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList(wxCommandEvent& event) ...@@ -82,7 +93,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList(wxCommandEvent& event)
/***************************************************************************/ /***************************************************************************/
void WinEDA_ModuleEditFrame::GetComponentFromUndoList(wxCommandEvent& event) void WinEDA_ModuleEditFrame::GetComponentFromUndoList( wxCommandEvent& event )
/***************************************************************************/ /***************************************************************************/
/* Undo the last edition: /* Undo the last edition:
...@@ -90,15 +101,15 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList(wxCommandEvent& event) ...@@ -90,15 +101,15 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList(wxCommandEvent& event)
* - Get old version of the current edited library component * - Get old version of the current edited library component
*/ */
{ {
if ( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(GetBoard()->m_Modules.PopFront()); ITEM_PICKER wrapper( GetBoard()->m_Modules.PopFront(), UR_MODEDIT );
lastcmd->PushItem(wrapper); lastcmd->PushItem( wrapper );
GetScreen()->PushCommandToRedoList( lastcmd ); GetScreen()->PushCommandToRedoList( lastcmd );
lastcmd = GetScreen()->PopCommandFromUndoList( ); lastcmd = GetScreen()->PopCommandFromUndoList();
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "confirm.h" #include "confirm.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "trigo.h" #include "trigo.h"
#include "block_commande.h"
#include "drag.h" #include "drag.h"
...@@ -310,7 +311,6 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -310,7 +311,6 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
{ {
int dX, dY; int dX, dY;
TRACK* Track; TRACK* Track;
DRAG_SEGM* pt_drag;
MODULE* Module; MODULE* Module;
if( Pad == NULL ) if( Pad == NULL )
...@@ -318,13 +318,60 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -318,13 +318,60 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Module = (MODULE*) Pad->GetParent(); Module = (MODULE*) Pad->GetParent();
ITEM_PICKER picker(NULL, UR_CHANGED);
PICKED_ITEMS_LIST pickList;
/* Save dragged track segments in undo list */
for( DRAG_SEGM* pt_drag = g_DragSegmentList; pt_drag; pt_drag = pt_drag->Pnext )
{
Track = pt_drag->m_Segm;
// Set the old state
wxPoint t_start = Track->m_Start;
wxPoint t_end = Track->m_End;
if( pt_drag->m_Pad_Start )
Track->m_Start = Pad_OldPos;
if( pt_drag->m_Pad_End )
Track->m_End = Pad_OldPos;
picker.m_PickedItem = Track;
pickList.PushItem(picker);
}
/* Save old module and old items values */
wxPoint pad_curr_position = Pad->m_Pos;
Pad->m_Pos = Pad_OldPos;
if ( g_DragSegmentList == NULL )
SaveCopyInUndoList( Module, UR_CHANGED );
else
{
picker.m_PickedItem = Module;
pickList.PushItem(picker);
}
if ( g_DragSegmentList )
SaveCopyInUndoList( pickList, UR_CHANGED );
/* Placement du pad */ /* Placement du pad */
Pad->m_Pos = pad_curr_position;
Pad->Draw( DrawPanel, DC, GR_XOR ); Pad->Draw( DrawPanel, DC, GR_XOR );
/* Save old module */ /* Redraw dragged track segments */
Pad->m_Pos = Pad_OldPos; for( DRAG_SEGM* pt_drag = g_DragSegmentList; pt_drag; pt_drag = pt_drag->Pnext )
SaveCopyInUndoList( Module, UR_CHANGED ); {
Pad->m_Pos = GetScreen()->m_Curseur; Track = pt_drag->m_Segm;
// Set the new state
if( pt_drag->m_Pad_Start )
Track->m_Start = Pad->m_Pos;
if( pt_drag->m_Pad_End )
Track->m_End = Pad->m_Pos;
Track->SetState( EDIT, OFF );
if ( DC )
Track->Draw( DrawPanel, DC, GR_OR );
}
/* Compute local coordinates (i.e refer to Module position and for Module orient = 0)*/ /* Compute local coordinates (i.e refer to Module position and for Module orient = 0)*/
dX = Pad->m_Pos.x - Pad_OldPos.x; dX = Pad->m_Pos.x - Pad_OldPos.x;
...@@ -342,15 +389,6 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -342,15 +389,6 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
/* Tracage des segments dragges */
pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext )
{
Track = pt_drag->m_Segm;
Track->SetState( EDIT, OFF );
if ( DC )
Track->Draw( DrawPanel, DC, GR_OR );
}
EraseDragListe(); EraseDragListe();
......
This diff is collapsed.
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