Commit c7187652 authored by charras's avatar charras

More about undo/redo in pcbnew

parent 5699ee3b
...@@ -292,12 +292,12 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aI ...@@ -292,12 +292,12 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aI
} }
/** function RemovePickedItem /** function RemovePicker
* remove one entry (one picker) from the list of picked items * remove one entry (one picker) from the list of picked items
* @param aIdx = index of the picker in the picked list * @param aIdx = index of the picker in the picked list
* @return true if ok, or false if did not exist * @return true if ok, or false if did not exist
*/ */
bool PICKED_ITEMS_LIST::RemovePickedItem( unsigned aIdx ) bool PICKED_ITEMS_LIST::RemovePicker( unsigned aIdx )
{ {
if( aIdx >= m_ItemsList.size() ) if( aIdx >= m_ItemsList.size() )
return false; return false;
...@@ -308,17 +308,11 @@ bool PICKED_ITEMS_LIST::RemovePickedItem( unsigned aIdx ) ...@@ -308,17 +308,11 @@ bool PICKED_ITEMS_LIST::RemovePickedItem( 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 * Picked items are not copied. just pointers on them are copied
*/ */
void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource ) void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource )
{ {
ITEM_PICKER picker; m_ItemsList = aSource.m_ItemsList; // Vector's copy
for( unsigned ii = 0; ii < aSource.GetCount(); ii++ )
{
picker = aSource.m_ItemsList[ii];
PushItem( picker );
}
} }
......
...@@ -274,37 +274,38 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -274,37 +274,38 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
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_TransformPoint = aTransformPoint;
// Copy picker list:
commandToUndo->CopyList( aItemsList );
ITEM_PICKER itemWrapper; // Verify list, and creates data if needed
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii );
if( item == NULL ) wxASSERT( item );
continue;
UndoRedoOpType command = aItemsList.GetPickedItemStatus( ii ); UndoRedoOpType command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED ) if( command == UR_UNSPECIFIED )
{ {
command = aTypeCommand; command = aTypeCommand;
commandToUndo->SetPickedItemStatus(command, ii );
} }
itemWrapper.m_PickedItem = item;
itemWrapper.m_PickedItemType = item->Type();
itemWrapper.m_UndoRedoStatus = command;
itemWrapper.m_Link = aItemsList.GetPickedItemLink( ii );
switch( command ) switch( command )
{ {
case UR_CHANGED: /* Create a copy of item */ case UR_CHANGED: /* Create a copy of item */
if( itemWrapper.m_Link == NULL ) /* If needed, create a copy of item, and put in undo list
itemWrapper.m_Link = DuplicateStruct( item ); * in the picker, as link
if ( itemWrapper.m_Link ) * If this link is not null, the copy is already done
commandToUndo->PushItem( itemWrapper ); */
if( commandToUndo->GetPickedItemLink(ii) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item ), ii );
wxASSERT( commandToUndo->GetPickedItemLink(ii) );
break; break;
case UR_MOVED: case UR_MOVED:
case UR_MIRRORED_Y: case UR_MIRRORED_Y:
case UR_NEW: case UR_NEW:
case UR_DELETED: case UR_DELETED:
commandToUndo->PushItem( itemWrapper );
break; break;
default: default:
...@@ -325,7 +326,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -325,7 +326,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
/* 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 */
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
} }
else else // Should not occur
delete commandToUndo; delete commandToUndo;
} }
......
...@@ -196,12 +196,12 @@ public: ...@@ -196,12 +196,12 @@ public:
*/ */
bool SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx ); bool SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx );
/** function RemovePickedItem /** function RemovePicker
* remùove one entry (one picker) from the list of picked items * remove one entry (one picker) from the list of picked items
* @param aIdx = index of the picker in the picked list * @param aIdx = index of the picker in the picked list
* @return true if ok, or false if did not exist * @return true if ok, or false if did not exist
*/ */
bool RemovePickedItem( unsigned aIdx ); bool RemovePicker( unsigned aIdx );
/** Function CopyList /** Function CopyList
* copy all data from aSource * copy all data from aSource
......
...@@ -121,9 +121,6 @@ public: ...@@ -121,9 +121,6 @@ public:
int ReadSetup( FILE* File, int* LineNum ); int ReadSetup( FILE* File, int* LineNum );
int ReadGeneralDescrPcb( FILE* File, int* LineNum ); int ReadGeneralDescrPcb( FILE* File, int* LineNum );
// PCB handling
bool Clear_Pcb( bool query );
/** /**
* Function PcbGeneralLocateAndDisplay * Function PcbGeneralLocateAndDisplay
......
...@@ -254,6 +254,13 @@ public: ...@@ -254,6 +254,13 @@ public:
int SavePcbFormatAscii( FILE* File ); int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( FILE* File ); bool WriteGeneralDescrPcb( FILE* File );
// BOARD handling
/** function Clear_Pcb()
* delete all and reinitialize the current board
* @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool Clear_Pcb( bool aQuery );
/** /**
* Function RecreateBOMFileFromBoard * Function RecreateBOMFileFromBoard
* Recreates a .cmp file from the current loaded board * Recreates a .cmp file from the current loaded board
...@@ -348,12 +355,6 @@ public: ...@@ -348,12 +355,6 @@ public:
// loading modules: see WinEDA_BasePcbFrame // loading modules: see WinEDA_BasePcbFrame
// Board handling // Board handling
void Erase_Zones( bool query );
void Erase_Segments_Pcb( bool is_edges, bool query );
void Erase_Pistes( wxDC* DC, int masque_type, bool query );
void Erase_Modules( bool query );
void Erase_Textes_Pcb( bool query );
void Erase_Marqueurs();
void RemoveStruct( BOARD_ITEM* Item, wxDC* DC ); void RemoveStruct( BOARD_ITEM* Item, wxDC* DC );
void Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via ); void Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via );
...@@ -655,6 +656,13 @@ public: ...@@ -655,6 +656,13 @@ public:
virtual void OnSelectGrid( wxCommandEvent& event ); virtual void OnSelectGrid( wxCommandEvent& event );
void LoadModuleFromBoard( wxCommandEvent& event ); void LoadModuleFromBoard( wxCommandEvent& event );
// BOARD handling
/** function Clear_Pcb()
* delete all and reinitialize the current board
* @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool Clear_Pcb( bool aQuery );
/* handlers for block commands */ /* handlers for block commands */
int ReturnBlockCommand( int key ); int ReturnBlockCommand( int key );
virtual void HandleBlockPlace( wxDC* DC ); virtual void HandleBlockPlace( wxDC* DC );
......
...@@ -417,7 +417,6 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -417,7 +417,6 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
*/ */
void WinEDA_PcbFrame::Block_SelectItems() void WinEDA_PcbFrame::Block_SelectItems()
{ {
BOARD_ITEM* PtStruct;
int masque_layer; int masque_layer;
GetScreen()->m_BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
...@@ -428,7 +427,6 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -428,7 +427,6 @@ void WinEDA_PcbFrame::Block_SelectItems()
/* Effacement des modules */ /* Effacement des modules */
if( Block_Include_Modules ) if( Block_Include_Modules )
{ {
;
for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() ) for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() )
{ {
if( module->HitTest( GetScreen()->m_BlockLocate ) ) if( module->HitTest( GetScreen()->m_BlockLocate ) )
...@@ -463,7 +461,7 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -463,7 +461,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
if( !Block_Include_Edges_Items ) if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER; masque_layer &= ~EDGE_LAYER;
for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
bool select_me = false; bool select_me = false;
switch( PtStruct->Type() ) switch( PtStruct->Type() )
...@@ -512,19 +510,25 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -512,19 +510,25 @@ void WinEDA_PcbFrame::Block_SelectItems()
} }
} }
/* Effacement des Zones */ /* Zone selection */
if( Block_Include_Zones ) if( Block_Include_Zones )
{ {
#if 0
/* This section can creates problems if selected:
* m_Pcb->m_Zone can have a *lot* of items (100 000 is easily possible)
* so it is not selected (and TODO: will be removed, one day)
*/
for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = pt_segm->Next() ) for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = pt_segm->Next() )
{ { /* Segments used in Zone filling selection */
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) ) if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
{ {
picker.m_PickedItem = PtStruct; picker.m_PickedItem = pt_segm;
picker.m_PickedItemType = PtStruct->Type(); picker.m_PickedItemType = pt_segm->Type();
itemsList->PushItem( picker ); itemsList->PushItem( picker );
} }
} }
#endif
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
if( m_Pcb->GetArea( ii )->HitTest( GetScreen()->m_BlockLocate ) ) if( m_Pcb->GetArea( ii )->HitTest( GetScreen()->m_BlockLocate ) )
...@@ -536,7 +540,7 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -536,7 +540,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
} }
} }
} }
} }
/**************************************************************************/ /**************************************************************************/
...@@ -630,13 +634,20 @@ void WinEDA_PcbFrame::Block_Delete() ...@@ -630,13 +634,20 @@ void WinEDA_PcbFrame::Block_Delete()
case TYPE_TEXTE: // a text on a layer case TYPE_TEXTE: // a text on a layer
case TYPE_TRACK: // a track segment (segment on a copper layer) case TYPE_TRACK: // a track segment (segment on a copper layer)
case TYPE_VIA: // a via (like atrack segment on a copper layer) case TYPE_VIA: // a via (like atrack segment on a copper layer)
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
case TYPE_MARKER_PCB: // a marker used to show something
case TYPE_COTATION: // a dimension (graphic item) case TYPE_COTATION: // a dimension (graphic item)
case TYPE_MIRE: // a target (graphic item) case TYPE_MIRE: // a target (graphic item)
item->UnLink(); item->UnLink();
break; break;
// These items are deleted, but not put in undo list
case TYPE_MARKER_PCB: // a marker used to show something
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
item->UnLink();
itemsList->RemovePicker( ii );
ii--;
item->DeleteStructure();
break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Delete( ) error: unexpected type" ) ); wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Delete( ) error: unexpected type" ) );
break; break;
...@@ -696,7 +707,6 @@ void WinEDA_PcbFrame::Block_Rotate() ...@@ -696,7 +707,6 @@ void WinEDA_PcbFrame::Block_Rotate()
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
break; break;
case TYPE_ZONE: // a segment used to fill a zone area (segment on a copper layer)
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPE_TEXTE: case TYPE_TEXTE:
...@@ -704,6 +714,11 @@ void WinEDA_PcbFrame::Block_Rotate() ...@@ -704,6 +714,11 @@ void WinEDA_PcbFrame::Block_Rotate()
case TYPE_COTATION: case TYPE_COTATION:
break; break;
// This item is not put in undo list
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
itemsList->RemovePicker( ii );
ii--;
break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Rotate( ) error: unexpected type" ) ); wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Rotate( ) error: unexpected type" ) );
...@@ -763,7 +778,6 @@ void WinEDA_PcbFrame::Block_Flip() ...@@ -763,7 +778,6 @@ void WinEDA_PcbFrame::Block_Flip()
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
break; break;
case TYPE_ZONE: // a segment used to fill a zone area (segment on a copper layer)
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPE_TEXTE: case TYPE_TEXTE:
...@@ -771,6 +785,12 @@ void WinEDA_PcbFrame::Block_Flip() ...@@ -771,6 +785,12 @@ void WinEDA_PcbFrame::Block_Flip()
case TYPE_COTATION: case TYPE_COTATION:
break; break;
// This item is not put in undo list
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
itemsList->RemovePicker( ii );
ii--;
break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Flip( ) error: unexpected type" ) ); wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Flip( ) error: unexpected type" ) );
...@@ -825,7 +845,6 @@ void WinEDA_PcbFrame::Block_Move() ...@@ -825,7 +845,6 @@ void WinEDA_PcbFrame::Block_Move()
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
break; break;
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPE_TEXTE: case TYPE_TEXTE:
...@@ -833,6 +852,12 @@ void WinEDA_PcbFrame::Block_Move() ...@@ -833,6 +852,12 @@ void WinEDA_PcbFrame::Block_Move()
case TYPE_COTATION: case TYPE_COTATION:
break; break;
// This item is not put in undo list
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
itemsList->RemovePicker( ii );
ii--;
break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Move( ) error: unexpected type" ) ); wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Move( ) error: unexpected type" ) );
break; break;
...@@ -905,10 +930,8 @@ void WinEDA_PcbFrame::Block_Duplicate() ...@@ -905,10 +930,8 @@ void WinEDA_PcbFrame::Block_Duplicate()
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer) case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
{ {
SEGZONE* track = (SEGZONE*) item; // SEG_ZONE items are not copied or put in undo list
SEGZONE* new_track = (SEGZONE*) track->Copy(); // they must be recreated by zone filling
newitem = new_track;
m_Pcb->m_Track.PushFront( new_track );
} }
break; break;
......
...@@ -126,11 +126,14 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) ...@@ -126,11 +126,14 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
} }
// Swap layers: // Swap layers:
int layer, layerimg; if( aItem->Type() != TYPE_MODULE ) // Modules have a global swap function
layer = aItem->GetLayer(); {
layerimg = aImage->GetLayer(); int layer, layerimg;
aItem->SetLayer( layerimg ); layer = aItem->GetLayer();
aImage->SetLayer( layer ); layerimg = aImage->GetLayer();
aItem->SetLayer( layerimg );
aImage->SetLayer( layer );
}
switch( aItem->Type() ) switch( aItem->Type() )
{ {
...@@ -211,7 +214,7 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem ) ...@@ -211,7 +214,7 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem )
{ {
if( aItem == NULL ) if( aItem == NULL )
{ {
wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) ); wxMessageBox( wxT( "DuplicateStruct() error: NULL aItem" ) );
return NULL; return NULL;
} }
...@@ -380,28 +383,31 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -380,28 +383,31 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
// Copy picker list:
commandToUndo->CopyList( aItemsList );
ITEM_PICKER itemWrapper; // Verify list, and creates data if needed
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
BOARD_ITEM* item = (BOARD_ITEM*) aItemsList.GetPickedItem( ii ); BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii );
UndoRedoOpType command = aItemsList.GetPickedItemStatus( ii ); UndoRedoOpType command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED ) if( command == UR_UNSPECIFIED )
{
command = aTypeCommand; command = aTypeCommand;
commandToUndo->SetPickedItemStatus(command, ii );
}
wxASSERT( item ); wxASSERT( item );
itemWrapper.m_PickedItem = item;
itemWrapper.m_PickedItemType = item->Type();
itemWrapper.m_UndoRedoStatus = command;
itemWrapper.m_Link = aItemsList.GetPickedItemLink( ii );
switch( command ) switch( command )
{ {
case UR_CHANGED: /* If needed, create a copy of item, and put in undo list */ case UR_CHANGED:
if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done /* If needed, create a copy of item, and put in undo list
itemWrapper.m_Link = DuplicateStruct( item ); * in the picker, as link
if( itemWrapper.m_Link ) * If this link is not null, the copy is already done
commandToUndo->PushItem( itemWrapper ); */
if( commandToUndo->GetPickedItemLink(ii) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item ), ii );
wxASSERT( commandToUndo->GetPickedItemLink(ii) );
break; break;
case UR_MOVED: case UR_MOVED:
...@@ -410,7 +416,6 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -410,7 +416,6 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
case UR_FLIPPED: case UR_FLIPPED:
case UR_NEW: case UR_NEW:
case UR_DELETED: case UR_DELETED:
commandToUndo->PushItem( itemWrapper );
break; break;
default: default:
...@@ -428,10 +433,10 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -428,10 +433,10 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
/* Save the copy in undo list */ /* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo ); GetScreen()->PushCommandToUndoList( commandToUndo );
/* Clear redo list, because after new save there is no redo to do */ /* Clear redo list, because after a new command one cannot redo a command */
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
} }
else else // Should not occur
delete commandToUndo; delete commandToUndo;
} }
...@@ -452,21 +457,23 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe ...@@ -452,21 +457,23 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe
{ {
item = (BOARD_ITEM*) aList->GetPickedItem( ii ); item = (BOARD_ITEM*) aList->GetPickedItem( ii );
wxASSERT( item ); wxASSERT( item );
#if 1
if( aList->GetPickedItemStatus( ii ) != UR_DELETED ) if( aList->GetPickedItemStatus( ii ) != UR_DELETED )
{ {
if( !TestForExistingItem( GetBoard(), item ) ) if( !TestForExistingItem( GetBoard(), item ) )
{ {
// Remove this non existant item // Remove this non existant item
aList->RemovePickedItem( ii ); aList->RemovePicker( ii );
ii--; // the current item was removed, ii points now the next item ii--; // the current item was removed, ii points now the next item
// whe must decrement it because it will be incremented // whe must decrement it because it will be incremented
not_found = true; not_found = true;
continue; continue;
} }
} }
#endif
item->m_Flags = 0; item->m_Flags = 0;
// see if one must rebuild ratsnets and pointers lists // see if we must rebuild ratsnets and pointers lists
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_MODULE: case TYPE_MODULE:
...@@ -528,9 +535,9 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe ...@@ -528,9 +535,9 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe
} }
if( not_found ) if( not_found )
wxMessageBox( wxT( "Incomplete undo/redo command: item not found" ) ); wxMessageBox( wxT( "Incomplete undo/redo operation: some items not found" ) );
// Rebuild pointers and rastnest // Rebuild pointers and rastnest that can be changed.
if( reBuild_ratsnest ) if( reBuild_ratsnest )
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
} }
...@@ -542,8 +549,8 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -542,8 +549,8 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event )
/** Function GetBoardFromUndoList /** Function GetBoardFromUndoList
* Undo the last edition: * Undo the last edition:
* - Save the current board in Redo list * - Save the current board state in Redo list
* - Get an old version of the board from Undo list * - Get an old version of the board state from Undo list
* @return none * @return none
*/ */
{ {
...@@ -612,7 +619,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -612,7 +619,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
unsigned icnt = aList.m_CommandsList.size(); unsigned icnt = aList.m_CommandsList.size();
if( aItemCount > 0 ) if( aItemCount > 0 )
icnt = aItemCount; icnt = aItemCount;
bool displ_error = true;
for( unsigned ii = 0; ii < icnt; ii++ ) for( unsigned ii = 0; ii < icnt; ii++ )
{ {
if( aList.m_CommandsList.size() == 0 ) if( aList.m_CommandsList.size() == 0 )
......
...@@ -533,6 +533,14 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event ) ...@@ -533,6 +533,14 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event )
bool change_layer = FALSE; bool change_layer = FALSE;
wxPoint modpos; wxPoint modpos;
if( m_CurrentModule->m_Flags == 0 ) // this is a simple edition, we must create an undo entry
{
if( m_Parent->m_Ident == PCB_FRAME )
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED );
else
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_MODEDIT );
}
if( m_DC ) if( m_DC )
{ {
m_Parent->DrawPanel->CursorOff( m_DC ); m_Parent->DrawPanel->CursorOff( m_DC );
......
...@@ -20,8 +20,8 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, wxDC* DC, bool ...@@ -20,8 +20,8 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, wxDC* DC, bool
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales : */ /* Variables locales : */
static wxPoint cursor_pos; // position originelle du curseur souris (fct deplacement) static wxPoint s_InitialPosition; // position originelle du curseur souris (fct deplacement)
static wxPoint cursor_pos0; // position courante du curseur souris static wxPoint s_LastPosition; // position courante du curseur souris
/****************************************************************************/ /****************************************************************************/
void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
...@@ -34,7 +34,7 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) ...@@ -34,7 +34,7 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
return; return;
drawitem->Draw( DrawPanel, DC, GR_XOR ); drawitem->Draw( DrawPanel, DC, GR_XOR );
drawitem->m_Flags |= IS_MOVED; drawitem->m_Flags |= IS_MOVED;
cursor_pos = cursor_pos0 = GetScreen()->m_Curseur; s_InitialPosition = s_LastPosition = GetScreen()->m_Curseur;
drawitem->DisplayInfo( this ); drawitem->DisplayInfo( this );
DrawPanel->ManageCurseur = Move_Segment; DrawPanel->ManageCurseur = Move_Segment;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; DrawPanel->ForceCloseManageCurseur = Exit_EditEdge;
...@@ -54,6 +54,7 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) ...@@ -54,6 +54,7 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
if( drawitem == NULL ) if( drawitem == NULL )
return; return;
SaveCopyInUndoList(drawitem, UR_MOVED, s_LastPosition - s_InitialPosition);
drawitem->Draw( DrawPanel, DC, GR_OR ); drawitem->Draw( DrawPanel, DC, GR_OR );
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
...@@ -82,13 +83,10 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -82,13 +83,10 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Segment->Draw( panel, DC, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
wxPoint delta; wxPoint delta;
delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x; delta = panel->GetScreen()->m_Curseur - s_LastPosition;
delta.y = panel->GetScreen()->m_Curseur.y - cursor_pos.y; Segment->m_Start += delta;
Segment->m_Start.x += delta.x; Segment->m_End += delta;
Segment->m_Start.y += delta.y; s_LastPosition = panel->GetScreen()->m_Curseur;
Segment->m_End.x += delta.x;
Segment->m_End.y += delta.y;
cursor_pos = panel->GetScreen()->m_Curseur;
Segment->Draw( panel, DC, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
DisplayOpt.DisplayDrawItems = t_fill; DisplayOpt.DisplayDrawItems = t_fill;
...@@ -151,10 +149,12 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -151,10 +149,12 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
PICKED_ITEMS_LIST pickList;
ITEM_PICKER picker(NULL, UR_DELETED);
BOARD_ITEM* PtNext; BOARD_ITEM* PtNext;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext ) for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext )
{ {
GetScreen()->SetModify();
PtNext = item->Next(); PtNext = item->Next();
switch( item->Type() ) switch( item->Type() )
...@@ -165,7 +165,9 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -165,7 +165,9 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( item->GetLayer() == layer ) if( item->GetLayer() == layer )
{ {
item->Draw( DrawPanel, DC, GR_XOR ); item->Draw( DrawPanel, DC, GR_XOR );
item->DeleteStructure(); item->UnLink();
picker.m_PickedItem = item;
pickList.PushItem(picker);
} }
break; break;
...@@ -174,6 +176,12 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -174,6 +176,12 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
break; break;
} }
} }
if( pickList.GetCount() )
{
GetScreen()->SetModify();
SaveCopyInUndoList(Segment, UR_DELETED);
}
} }
...@@ -194,8 +202,8 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -194,8 +202,8 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
else else
{ {
wxPoint pos = Panel->GetScreen()->m_Curseur; wxPoint pos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = cursor_pos0; Panel->GetScreen()->m_Curseur = s_InitialPosition;
Panel->ManageCurseur( Panel, DC, TRUE ); Panel->ManageCurseur( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = pos; Panel->GetScreen()->m_Curseur = pos;
Segment->m_Flags = 0; Segment->m_Flags = 0;
...@@ -247,6 +255,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, ...@@ -247,6 +255,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
{ {
if( Segment->m_Shape == S_SEGMENT ) if( Segment->m_Shape == S_SEGMENT )
{ {
SaveCopyInUndoList(Segment, UR_NEW );
GetBoard()->Add( Segment ); GetBoard()->Add( Segment );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -287,17 +296,15 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -287,17 +296,15 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
Segment->Draw( DrawPanel, DC, GR_OR ); Segment->Draw( DrawPanel, DC, GR_OR );
/* Effacement si Longueur nulle */ /* Effacement si Longueur nulle */
if( (Segment->m_Start.x == Segment->m_End.x) if( Segment->m_Start == Segment->m_End)
&& (Segment->m_Start.y == Segment->m_End.y) )
Segment ->DeleteStructure(); Segment ->DeleteStructure();
else else
{ {
Segment->m_Flags = 0; Segment->m_Flags = 0;
GetBoard()->Add( Segment ); GetBoard()->Add( Segment );
GetScreen()->SetModify(); GetScreen()->SetModify();
SaveCopyInUndoList(Segment, UR_NEW );
} }
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
......
...@@ -33,108 +33,133 @@ void WinEDA_PcbFrame::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) ...@@ -33,108 +33,133 @@ void WinEDA_PcbFrame::InstallPcbGlobalDeleteFrame( const wxPoint& pos )
void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event ) void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event )
/***********************************************************************/ /***********************************************************************/
{ {
int track_mask; bool gen_rastnest = false;
bool redraw = false;
bool gen_rastnest = false;
wxClientDC dc( m_Parent->DrawPanel );
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
m_Parent->SetCurItem( NULL ); m_Parent->SetCurItem( NULL );
if( m_DelAlls->GetValue() ) if( m_DelAlls->GetValue() )
{ {
m_Parent->Clear_Pcb( TRUE ); m_Parent->Clear_Pcb( true );
redraw = TRUE;
} }
else else
{ {
if( !IsOK( this, _( "Ok to delete selected items ?" ) ) )
return;
BOARD * pcb = m_Parent->GetBoard();
PICKED_ITEMS_LIST pickersList;
ITEM_PICKER itemPicker( NULL, UR_DELETED );
BOARD_ITEM* item, * nextitem;
if( m_DelZones->GetValue() ) if( m_DelZones->GetValue() )
{ {
m_Parent->Erase_Zones( TRUE );
gen_rastnest = true; gen_rastnest = true;
redraw = TRUE;
}
if( m_DelTexts->GetValue() ) /* Segments used in Zone filling selection */
{ // for many reasons saving these items can create problems so they are not saved
m_Parent->Erase_Textes_Pcb( TRUE ); // (because they are numerous and can be deleted in zones operation)
redraw = TRUE; pcb->m_Zone.DeleteAll();
while( pcb->GetAreaCount() )
{
item = pcb->GetArea( 0 );
itemPicker.m_PickedItem = item;
pickersList.PushItem( itemPicker );
pcb->Remove( item );
}
} }
int masque_layer = 0;
if( m_DelDrawings->GetValue() )
masque_layer = (~EDGE_LAYER) & 0x1FFF0000;
if( m_DelEdges->GetValue() ) if( m_DelEdges->GetValue() )
{ masque_layer |= EDGE_LAYER;
m_Parent->Erase_Segments_Pcb( TRUE, TRUE );
redraw = TRUE;
}
if( m_DelDrawings->GetValue() ) for( item = pcb->m_Drawings; item != NULL; item = nextitem )
{ {
m_Parent->Erase_Segments_Pcb( FALSE, TRUE ); nextitem = item->Next();
redraw = TRUE; bool removeme = (g_TabOneLayerMask[ item->GetLayer()] & masque_layer) != 0;
if( ( item->Type() == TYPE_TEXTE ) && m_DelTexts->GetValue() )
removeme = true;
if( removeme )
{
itemPicker.m_PickedItem = item;
pickersList.PushItem( itemPicker );
item->UnLink();
}
} }
if( m_DelModules->GetValue() ) if( m_DelModules->GetValue() )
{ {
m_Parent->Erase_Modules( TRUE );
gen_rastnest = true; gen_rastnest = true;
redraw = TRUE; for( item = pcb->m_Modules; item; item = nextitem )
{
nextitem = item->Next();
itemPicker.m_PickedItem = item;
pickersList.PushItem( itemPicker );
item->UnLink();
}
} }
if( m_DelTracks->GetValue() ) if( m_DelTracks->GetValue() )
{ {
track_mask = 0; int track_mask_filter = 0;
if( !m_TrackFilterLocked->GetValue() ) if( !m_TrackFilterLocked->GetValue() )
track_mask |= SEGM_FIXE; track_mask_filter |= SEGM_FIXE;
if( !m_TrackFilterAR->GetValue() ) if( !m_TrackFilterAR->GetValue() )
track_mask |= SEGM_AR; track_mask_filter |= SEGM_AR;
for( item = pcb->m_Track; item != NULL; item = nextitem )
m_Parent->Erase_Pistes( &dc, track_mask, TRUE ); {
redraw = TRUE; nextitem = item->Next();
if( (item->GetState( SEGM_FIXE | SEGM_AR ) & track_mask_filter) != 0 )
continue;
itemPicker.m_PickedItem = item;
pickersList.PushItem( itemPicker );
item->UnLink();
gen_rastnest = true; gen_rastnest = true;
}
} }
if( m_DelMarkers->GetValue() ) if( pickersList.GetCount() )
{ m_Parent->SaveCopyInUndoList( pickersList, UR_DELETED );
m_Parent->Erase_Marqueurs();
redraw = TRUE;
}
if ( gen_rastnest ) if( m_DelMarkers->GetValue() )
m_Parent->Compile_Ratsnest( &dc, true ); pcb->DeleteMARKERs();
if( gen_rastnest )
m_Parent->Compile_Ratsnest( NULL, true );
} }
if( redraw ) m_Parent->DrawPanel->Refresh();
{
m_Parent->DrawPanel->Refresh();
}
EndModal( 1 ); EndModal( 1 );
} }
/*********************************************************/ /** function WinEDA_PcbFrame::Clear_Pcb()
bool WinEDA_BasePcbFrame::Clear_Pcb( bool query ) * delete all and reinitialize the current board
/*********************************************************/ * @param aQuery = true to prompt user for confirmation, false to initialize silently
/* Realise les init des pointeurs et variables
* Si query == FALSE, il n'y aura pas de confirmation
*/ */
bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery )
{ {
if( GetBoard() == NULL ) if( GetBoard() == NULL )
return FALSE; return FALSE;
if( query && GetScreen()->IsModify() ) if( aQuery )
{ {
if( GetBoard()->m_Drawings || GetBoard()->m_Modules if( GetBoard()->m_Drawings || GetBoard()->m_Modules
|| GetBoard()->m_Track || GetBoard()->m_Zone ) || GetBoard()->m_Track || GetBoard()->m_Zone )
{ {
if( !IsOK( this, _( "Current Board will be lost ?" ) ) ) if( !IsOK( this,
_( "Current Board will be lost and this operation and cannot be undone. Continue ?" ) ) )
return FALSE; return FALSE;
} }
} }
// Clear undo and redo lists because we want a full deletion
GetScreen()->ClearUndoRedoList();
// delete the old BOARD and create a new BOARD so that the default // delete the old BOARD and create a new BOARD so that the default
// layer names are put into the BOARD. // layer names are put into the BOARD.
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL, this ) );
...@@ -146,7 +171,7 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query ) ...@@ -146,7 +171,7 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
/* Init parametres de gestion */ /* Init parametres de gestion */
wxRealPoint gridsize = GetScreen()->GetGrid(); wxRealPoint gridsize = GetScreen()->GetGrid();
((PCB_SCREEN*)GetScreen())->Init(); GetScreen()->Init();
GetScreen()->SetGrid( gridsize ); GetScreen()->SetGrid( gridsize );
g_HightLigt_Status = 0; g_HightLigt_Status = 0;
...@@ -158,160 +183,54 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query ) ...@@ -158,160 +183,54 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
g_DesignSettings.m_TrackClearenceHistory[ii] = 0; g_DesignSettings.m_TrackClearenceHistory[ii] = 0;
} }
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth; g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
g_DesignSettings.m_TrackClearenceHistory[0] = g_DesignSettings.m_TrackClearence; g_DesignSettings.m_TrackClearenceHistory[0] = g_DesignSettings.m_TrackClearence;
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
/* NO, this is a global setting, and changing it here changes a loaded board's layer count when loading a module in the module editor since
the module editor calls this when loading an existing module.
g_DesignSettings.m_CopperLayerCount = 2; // Default copper layers count set to 2: double layer board g_DesignSettings.m_CopperLayerCount = 2; // Default copper layers count set to 2: double layer board
*/
Zoom_Automatique( TRUE ); Zoom_Automatique( true );
return TRUE; return true;
} }
/************************************************************/
void WinEDA_PcbFrame::Erase_Zones( bool query )
/************************************************************/
{
if( query && !IsOK( this, _( "Delete Zones ?" ) ) )
return;
GetBoard()->m_Zone.DeleteAll();
GetBoard()->DeleteZONEOutlines();
GetScreen()->SetModify();
}
/*****************************************************************************/ /** function WinEDA_ModuleEditFrame::Clear_Pcb()
void WinEDA_PcbFrame::Erase_Segments_Pcb( bool is_edges, bool query ) * delete all and reinitialize the current board
/*****************************************************************************/ * @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
{ {
BOARD_ITEM* PtStruct; if( GetBoard() == NULL )
BOARD_ITEM* PtNext; return FALSE;
int masque_layer = (~EDGE_LAYER) & 0x1FFF0000;
if( is_edges )
{
masque_layer = EDGE_LAYER;
if( query && !IsOK( this, _( "Delete Board edges ?" ) ) )
return;
}
else
{
if( query && !IsOK( this, _( "Delete draw items?" ) ) )
return;
}
PtStruct = GetBoard()->m_Drawings; if( aQuery && GetScreen()->IsModify() )
for( ; PtStruct != NULL; PtStruct = PtNext )
{ {
PtNext = PtStruct->Next(); if( GetBoard()->m_Modules )
switch( PtStruct->Type() )
{ {
case TYPE_DRAWSEGMENT: if( !IsOK( this,
case TYPE_TEXTE: _( "Current Footprint will be lost and this operation and cannot be undone. Continue ?" ) ) )
case TYPE_COTATION: return FALSE;
case TYPE_MIRE:
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
GetBoard()->Delete( PtStruct );
break;
default:
DisplayError( this, wxT( "Unknown/unexpected Draw Type" ) );
break;
} }
} }
GetScreen()->SetModify(); // Clear undo and redo lists
} GetScreen()->ClearUndoRedoList();
// Delete the current footprint
/**************************************************************************/
void WinEDA_PcbFrame::Erase_Pistes( wxDC * DC, int masque_type, bool query )
/**************************************************************************/
/* Efface les segments de piste, selon les autorisations affichees
* masque_type = masque des options de selection:
* SEGM_FIXE, SEGM_AR
* Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1
*/
{
TRACK* pt_segm;
TRACK* PtNext;
if( query && !IsOK( this, _( "Delete Tracks?" ) ) )
return;
/* Marquage des pistes a effacer */
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext )
{
PtNext = pt_segm->Next();
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
continue;
pt_segm->DeleteStructure();
}
GetScreen()->SetModify();
Compile_Ratsnest( DC, TRUE );
}
/**************************************************************/
void WinEDA_PcbFrame::Erase_Modules( bool query )
/**************************************************************/
{
if( query && !IsOK( this, _( "Delete Modules?" ) ) )
return;
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
GetBoard()->m_Status_Pcb = 0; /* init pointeurs et variables */
m_Pcb->m_NetInfo->DeleteData(); GetScreen()->m_FileName.Empty();
m_Pcb->m_FullRatsnest.clear(); // empty the pad list pointers
m_Pcb->m_LocalRatsnest.clear(); // empty the pad list pointers
GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0;
GetScreen()->SetModify();
}
/************************************************************/
void WinEDA_PcbFrame::Erase_Textes_Pcb( bool query )
/************************************************************/
{
BOARD_ITEM* PtStruct, * PtNext;
if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) )
return;
PtStruct = GetBoard()->m_Drawings; SetCurItem( NULL );
for( ; PtStruct != NULL; PtStruct = PtNext )
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPE_TEXTE )
{
PtStruct->DeleteStructure();
}
}
GetScreen()->SetModify(); /* Init parametres de gestion */
} wxRealPoint gridsize = GetScreen()->GetGrid();
GetScreen()->Init();
GetScreen()->SetGrid( gridsize );
Zoom_Automatique( true );
/*******************************************/ return true;
void WinEDA_PcbFrame::Erase_Marqueurs()
/*******************************************/
{
GetBoard()->DeleteMARKERs();
GetScreen()->SetModify(); // @todo : why mark this if MARKERs are not saved in the *.brd file?
} }
...@@ -364,8 +364,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -364,8 +364,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0; GetBoard()->m_Modules->m_Flags = 0;
//if either m_Reference or m_Value are gone, reinstate them - // if either m_Reference or m_Value are gone, reinstall them -
//otherwise it becomes hard to see what you are working with in the layout! // otherwise you cannot see what you are doing on board
if( GetBoard() && GetBoard()->m_Modules ) if( GetBoard() && GetBoard()->m_Modules )
{ {
TEXTE_MODULE* ref = GetBoard()->m_Modules->m_Reference; TEXTE_MODULE* ref = GetBoard()->m_Modules->m_Reference;
......
...@@ -122,7 +122,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) ...@@ -122,7 +122,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
if( g_Show_Ratsnest ) if( g_Show_Ratsnest )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Anormal ! */ if( g_DragSegmentList ) /* Should not occur ! */
{ {
EraseDragListe(); EraseDragListe();
} }
......
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