Commit 148a574e authored by charras's avatar charras

More about undo/redo in pcbnew

parent 42b1020d
...@@ -314,6 +314,25 @@ void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource ) ...@@ -314,6 +314,25 @@ void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource )
m_ItemsList = aSource.m_ItemsList; // Vector's copy m_ItemsList = aSource.m_ItemsList; // Vector's copy
} }
/** function ReversePickersListOrder()
* reverses the order of pickers stored in this list
* Useful when pop a list from Undo to Redo (and vice-versa)
* because sometimes undo (or redo) a command needs to keep the
* order of successive changes.
* and obviously, undo and redo are in reverse order
*/
void PICKED_ITEMS_LIST::ReversePickersListOrder()
{
std::vector <ITEM_PICKER> tmp;
while( !m_ItemsList.empty() )
{
tmp.push_back( m_ItemsList.back() );
m_ItemsList.pop_back();
}
m_ItemsList.swap( tmp );
}
/**********************************************/ /**********************************************/
/********** UNDO_REDO_CONTAINER ***************/ /********** UNDO_REDO_CONTAINER ***************/
...@@ -355,3 +374,5 @@ PICKED_ITEMS_LIST* UNDO_REDO_CONTAINER::PopCommand() ...@@ -355,3 +374,5 @@ PICKED_ITEMS_LIST* UNDO_REDO_CONTAINER::PopCommand()
} }
return NULL; return NULL;
} }
...@@ -137,6 +137,15 @@ public: ...@@ -137,6 +137,15 @@ public:
return m_ItemsList.size(); return m_ItemsList.size();
} }
/** function ReversePickersListOrder()
* reverses the order of pickers stored in this list
* Useful when pop a list from Undo to Redo (and vice-versa)
* because sometimes undo (or redo) a command needs to keep the
* order of successive changes.
* and obviously, undo and redo are in reverse order
*/
void ReversePickersListOrder();
/** function GetItemWrapper /** function GetItemWrapper
* @return the picker of a picked item * @return the picker of a picked item
......
...@@ -386,8 +386,21 @@ public: ...@@ -386,8 +386,21 @@ public:
void Remove_One_Track( wxDC* DC, TRACK* pt_segm ); void Remove_One_Track( wxDC* DC, TRACK* pt_segm );
bool Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via ); bool Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via );
void Edit_Net_Width( wxDC* DC, int Netcode ); void Edit_Net_Width( wxDC* DC, int Netcode );
/** Function Edit_Track_Width
* Modify a full track width (using DRC control).
* a full track is the set of track segments between 2 ends: pads or a point that has more than 2 segments ends connected
* @param DC = the curred device context (can be NULL)
* @param aTrackSegment = a segment or via on the track to change
*/
void Edit_Track_Width( wxDC* DC, TRACK* Track ); void Edit_Track_Width( wxDC* DC, TRACK* Track );
int Edit_TrackSegm_Width( wxDC* DC, TRACK* segm );
/** Function Edit_TrackSegm_Width
* Modify one track segment width or one via diameter (using DRC control).
* @param DC = the curred device context (can be NULL)
* @param aTrackItem = the track segment or via to modify
*/
void Edit_TrackSegm_Width( wxDC* DC, TRACK* segm );
TRACK* Begin_Route( TRACK* track, wxDC* DC ); TRACK* Begin_Route( TRACK* track, wxDC* DC );
void End_Route( TRACK* track, wxDC* DC ); void End_Route( TRACK* track, wxDC* DC );
void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ); void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
...@@ -395,13 +408,35 @@ public: ...@@ -395,13 +408,35 @@ public:
void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ); void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
void Attribut_net( wxDC* DC, int net_code, bool Flag_On ); void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command ); void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command );
bool PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC ); bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC );
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end ); bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ); void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
void SwitchLayer( wxDC* DC, int layer ); void SwitchLayer( wxDC* DC, int layer );
bool Add_45_degrees_Segment( wxDC* DC ); bool Add_45_degrees_Segment( wxDC* DC );
bool Genere_Pad_Connexion( wxDC* DC, int layer ); bool Genere_Pad_Connexion( wxDC* DC, int layer );
/** function EraseRedundantTrack
* Called after creating a track
* Remove (if exists) the old track that have the same starting and the same ending point as the new created track
* (this is the redunding track)
* @param aDC = the current device context (can be NULL)
* @param aNewTrack = the new created track (a pointer to a segment of the track list)
* @param aNewTrackSegmentsCount = number of segments in this new track
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
*/
int EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewTrackSegmentsCount,
PICKED_ITEMS_LIST* aItemsListPicker );
/** Function SetTrackSegmentWidth
* Modify one track segment width or one via diameter (using DRC control).
* Basic routine used by other routines when editing tracks or vias
* @param aTrackItem = the track segment or via to modify
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
* @return true if done, false if no not change (because DRC error)
*/
bool SetTrackSegmentWidth( TRACK* aTrackItem, PICKED_ITEMS_LIST* aItemsListPicker );
// zone handling // zone handling
/** Function Delete_Zone_Fill /** Function Delete_Zone_Fill
......
...@@ -513,7 +513,7 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -513,7 +513,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
/* Zone selection */ /* Zone selection */
if( Block_Include_Zones ) if( Block_Include_Zones )
{ {
#if 0 #if 0
/* This section can creates problems if selected: /* This section can creates problems if selected:
* m_Pcb->m_Zone can have a *lot* of items (100 000 is easily possible) * 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) * so it is not selected (and TODO: will be removed, one day)
...@@ -641,7 +641,7 @@ void WinEDA_PcbFrame::Block_Delete() ...@@ -641,7 +641,7 @@ void WinEDA_PcbFrame::Block_Delete()
// These items are deleted, but not put in undo list // These items are deleted, but not put in undo list
case TYPE_MARKER_PCB: // a marker used to show something 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) case TYPE_ZONE: // SEG_ZONE items are now deprecated
item->UnLink(); item->UnLink();
itemsList->RemovePicker( ii ); itemsList->RemovePicker( ii );
ii--; ii--;
...@@ -715,7 +715,7 @@ void WinEDA_PcbFrame::Block_Rotate() ...@@ -715,7 +715,7 @@ void WinEDA_PcbFrame::Block_Rotate()
break; break;
// This item is not put in undo list // This item is not put in undo list
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer) case TYPE_ZONE: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii ); itemsList->RemovePicker( ii );
ii--; ii--;
break; break;
...@@ -786,7 +786,7 @@ void WinEDA_PcbFrame::Block_Flip() ...@@ -786,7 +786,7 @@ void WinEDA_PcbFrame::Block_Flip()
break; break;
// This item is not put in undo list // This item is not put in undo list
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer) case TYPE_ZONE: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii ); itemsList->RemovePicker( ii );
ii--; ii--;
break; break;
...@@ -853,7 +853,7 @@ void WinEDA_PcbFrame::Block_Move() ...@@ -853,7 +853,7 @@ void WinEDA_PcbFrame::Block_Move()
break; break;
// This item is not put in undo list // This item is not put in undo list
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer) case TYPE_ZONE: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii ); itemsList->RemovePicker( ii );
ii--; ii--;
break; break;
...@@ -928,12 +928,8 @@ void WinEDA_PcbFrame::Block_Duplicate() ...@@ -928,12 +928,8 @@ void WinEDA_PcbFrame::Block_Duplicate()
} }
break; break;
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer) case TYPE_ZONE: // SEG_ZONE items are now deprecated
{ break;
// SEG_ZONE items are not copied or put in undo list
// they must be recreated by zone filling
}
break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
{ {
......
...@@ -126,7 +126,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) ...@@ -126,7 +126,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
} }
// Swap layers: // Swap layers:
if( aItem->Type() != TYPE_MODULE ) // Modules have a global swap function if( aItem->Type() != TYPE_MODULE && aItem->Type() != TYPE_ZONE_CONTAINER ) // these items have a global swap function
{ {
int layer, layerimg; int layer, layerimg;
layer = aItem->GetLayer(); layer = aItem->GetLayer();
...@@ -139,16 +139,21 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) ...@@ -139,16 +139,21 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
{ {
case TYPE_MODULE: case TYPE_MODULE:
{ {
MODULE* m_tmp = (MODULE*) DuplicateStruct( aImage ); MODULE* tmp = (MODULE*) DuplicateStruct( aImage );
( (MODULE*) aImage )->Copy( (MODULE*) aItem ); ( (MODULE*) aImage )->Copy( (MODULE*) aItem );
( (MODULE*) aItem )->Copy( m_tmp ); ( (MODULE*) aItem )->Copy( tmp );
delete m_tmp; delete tmp;
} }
break; break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
wxMessageBox( wxT( "SwapData(): TYPE_ZONE_CONTAINER not handled" ) ); {
break; ZONE_CONTAINER* tmp = (ZONE_CONTAINER*) DuplicateStruct( aImage );
( (ZONE_CONTAINER*) aImage )->Copy( (ZONE_CONTAINER*) aItem );
( (ZONE_CONTAINER*) aItem )->Copy( tmp );
delete tmp;
}
break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
EXCHG( ( (TRACK*) aItem )->m_Start, ( (TRACK*) aImage )->m_Start ); EXCHG( ( (TRACK*) aItem )->m_Start, ( (TRACK*) aImage )->m_Start );
...@@ -189,13 +194,13 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) ...@@ -189,13 +194,13 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
case TYPE_COTATION: case TYPE_COTATION:
{ {
wxString txt = ( (COTATION*) aItem )->GetText(); wxString txt = ( (COTATION*) aItem )->GetText();
( (COTATION*) aItem )->SetText( ((COTATION*) aImage )->GetText() ); ( (COTATION*) aItem )->SetText( ( (COTATION*) aImage )->GetText() );
( (COTATION*) aImage )->SetText( txt ); ( (COTATION*) aImage )->SetText( txt );
EXCHG( ( (COTATION*) aItem )->m_Text->m_Size, ( (COTATION*) aImage )->m_Text->m_Size ); EXCHG( ( (COTATION*) aItem )->m_Text->m_Size, ( (COTATION*) aImage )->m_Text->m_Size );
EXCHG( ( (COTATION*) aItem )->m_Text->m_Width, ( (COTATION*) aImage )->m_Text->m_Width ); EXCHG( ( (COTATION*) aItem )->m_Text->m_Width, ( (COTATION*) aImage )->m_Text->m_Width );
EXCHG( ( (COTATION*) aItem )->m_Text->m_Mirror, ( (COTATION*) aImage )->m_Text->m_Mirror ); EXCHG( ( (COTATION*) aItem )->m_Text->m_Mirror, ( (COTATION*) aImage )->m_Text->m_Mirror );
} }
break; break;
default: default:
wxMessageBox( wxT( "SwapData() error: unexpected type" ) ); wxMessageBox( wxT( "SwapData() error: unexpected type" ) );
...@@ -334,7 +339,7 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItem, ...@@ -334,7 +339,7 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
switch( aCommandType ) switch( aCommandType )
{ {
case UR_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: /* Create a copy of schematic */
if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done
itemWrapper.m_Link = DuplicateStruct( aItem );; itemWrapper.m_Link = DuplicateStruct( aItem );;
if( itemWrapper.m_Link ) if( itemWrapper.m_Link )
...@@ -383,6 +388,7 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -383,6 +388,7 @@ 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: // Copy picker list:
commandToUndo->CopyList( aItemsList ); commandToUndo->CopyList( aItemsList );
...@@ -394,20 +400,21 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -394,20 +400,21 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
if( command == UR_UNSPECIFIED ) if( command == UR_UNSPECIFIED )
{ {
command = aTypeCommand; command = aTypeCommand;
commandToUndo->SetPickedItemStatus(command, ii ); commandToUndo->SetPickedItemStatus( command, ii );
} }
wxASSERT( item ); wxASSERT( item );
switch( command ) switch( command )
{ {
case UR_CHANGED: case UR_CHANGED:
/* If needed, create a copy of item, and put in undo list /* If needed, create a copy of item, and put in undo list
* in the picker, as link * in the picker, as link
* If this link is not null, the copy is already done * If this link is not null, the copy is already done
*/ */
if( commandToUndo->GetPickedItemLink(ii) == NULL ) if( commandToUndo->GetPickedItemLink( ii ) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item ), ii ); commandToUndo->SetPickedItemLink( DuplicateStruct( item ), ii );
wxASSERT( commandToUndo->GetPickedItemLink(ii) ); wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
break; break;
case UR_MOVED: case UR_MOVED:
...@@ -453,7 +460,9 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe ...@@ -453,7 +460,9 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe
bool not_found = false; bool not_found = false;
bool reBuild_ratsnest = false; bool reBuild_ratsnest = false;
for( unsigned ii = 0; ii < aList->GetCount(); ii++ ) // Undo in the reverse order of list creation: (this can allow stacked changes
// like the same item can be changes and deleted in the same complex command
for( int ii = aList->GetCount()-1; ii >= 0 ; ii-- )
{ {
item = (BOARD_ITEM*) aList->GetPickedItem( ii ); item = (BOARD_ITEM*) aList->GetPickedItem( ii );
wxASSERT( item ); wxASSERT( item );
...@@ -464,7 +473,7 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe ...@@ -464,7 +473,7 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe
{ {
// Remove this non existant item // Remove this non existant item
aList->RemovePicker( 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;
...@@ -557,12 +566,15 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -557,12 +566,15 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event )
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
/* Get the old wrapper and put it in RedoList */ /* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
GetScreen()->PushCommandToRedoList( List );
/* Undo the command */ /* Undo the command */
PutDataInPreviousState( List, false ); PutDataInPreviousState( List, false );
/* Pu the old list in RedoList */
List->ReversePickersListOrder();
GetScreen()->PushCommandToRedoList( List );
GetScreen()->SetModify(); GetScreen()->SetModify();
ReCreateHToolbar(); ReCreateHToolbar();
SetToolbars(); SetToolbars();
...@@ -583,13 +595,16 @@ void WinEDA_PcbFrame::GetBoardFromRedoList( wxCommandEvent& event ) ...@@ -583,13 +595,16 @@ void WinEDA_PcbFrame::GetBoardFromRedoList( wxCommandEvent& event )
return; return;
/* Get the old wrapper and put it in UndoList */ /* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
GetScreen()->PushCommandToUndoList( List );
/* Redo the command: */ /* Redo the command: */
PutDataInPreviousState( List, true ); PutDataInPreviousState( List, true );
/* Put the old list in UndoList */
List->ReversePickersListOrder();
GetScreen()->PushCommandToUndoList( List );
GetScreen()->SetModify(); GetScreen()->SetModify();
ReCreateHToolbar(); ReCreateHToolbar();
SetToolbars(); SetToolbars();
......
...@@ -1145,8 +1145,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src ) ...@@ -1145,8 +1145,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
/** /**
* Function SetNetNameFromNetCode * Function SetNetNameFromNetCode
* Fin the nat name corresponding to the net code. * Find the net name corresponding to the net code.
* @param aPcb: the curren board * @param aPcb: the current board
* @return bool - true if net found, else false * @return bool - true if net found, else false
*/ */
bool ZONE_CONTAINER::SetNetNameFromNetCode( void ) bool ZONE_CONTAINER::SetNetNameFromNetCode( void )
......
...@@ -165,22 +165,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -165,22 +165,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_TOGGLE_PRESENT_COMMAND: case ID_TOGGLE_PRESENT_COMMAND:
/* if( DrawPanel->ManageCurseur
* && DrawPanel->ForceCloseManageCurseur )
* {
* DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
* }
*/
break; break;
default: // Finish (abort ) the command default: // Finish (abort ) the command
if( DrawPanel->ManageCurseur if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
&& DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
if( m_ID_current_state != id ) if( m_ID_current_state != id )
{ {
...@@ -286,11 +275,6 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -286,11 +275,6 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
m_ModuleEditFrame->Iconize( false ); m_ModuleEditFrame->Iconize( false );
break; break;
case ID_NEW_PROJECT:
case ID_LOAD_PROJECT:
Files_io( event );
break;
case ID_PCB_GLOBAL_DELETE: case ID_PCB_GLOBAL_DELETE:
InstallPcbGlobalDeleteFrame( pos ); InstallPcbGlobalDeleteFrame( pos );
break; break;
...@@ -470,7 +454,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -470,7 +454,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( GetCurItem()->m_Flags & IS_DRAGGED ) if( GetCurItem()->m_Flags & IS_DRAGGED )
{ {
PlaceDraggedTrackSegment( (TRACK*) GetCurItem(), &dc ); PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc );
} }
break; break;
...@@ -482,7 +466,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -482,7 +466,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( GetCurItem()->m_Flags & IS_DRAGGED ) if( GetCurItem()->m_Flags & IS_DRAGGED )
{ {
PlaceDraggedTrackSegment( (TRACK*) GetCurItem(), &dc ); PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc );
} }
else else
{ {
...@@ -1131,7 +1115,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1131,7 +1115,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
TRACK* track = (TRACK*) GetScreen()->GetCurItem(); TRACK* track = (TRACK*) GetScreen()->GetCurItem();
wxPoint pos = GetScreen()->m_Curseur; wxPoint pos = GetScreen()->m_Curseur;
track->Draw( DrawPanel, &dc, GR_XOR ); track->Draw( DrawPanel, &dc, GR_XOR );
TRACK* newtrack = CreateLockPoint( &pos.x, &pos.y, track, NULL ); PICKED_ITEMS_LIST itemsListPicker;
TRACK* newtrack = CreateLockPoint( pos, track, NULL, &itemsListPicker);
SaveCopyInUndoList(itemsListPicker,UR_UNSPECIFIED);
track->Draw( DrawPanel, &dc, GR_XOR ); track->Draw( DrawPanel, &dc, GR_XOR );
newtrack->Draw( DrawPanel, &dc, GR_XOR ); newtrack->Draw( DrawPanel, &dc, GR_XOR );
} }
......
This diff is collapsed.
...@@ -27,6 +27,7 @@ static void EnsureEndTrackOnPad( D_PAD* Pad ); ...@@ -27,6 +27,7 @@ static void EnsureEndTrackOnPad( D_PAD* Pad );
/* variables locales */ /* variables locales */
static int OldNetCodeSurbrillance; static int OldNetCodeSurbrillance;
static int OldEtatSurbrillance; static int OldEtatSurbrillance;
static PICKED_ITEMS_LIST s_ItemsListPicker;
/************************************************************/ /************************************************************/
...@@ -53,6 +54,9 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -53,6 +54,9 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
// Clear the undo picker list:
s_ItemsListPicker.ClearListAndDeleteItems();
// Delete current (new) track // Delete current (new) track
g_CurrentTrackList.DeleteAll(); g_CurrentTrackList.DeleteAll();
} }
...@@ -95,6 +99,9 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -95,6 +99,9 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
if( aTrack == NULL ) /* Starting a new track */ if( aTrack == NULL ) /* Starting a new track */
{ {
// Prepare the undo command info
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but...
/* erase old highlight */ /* erase old highlight */
OldNetCodeSurbrillance = g_HightLigth_NetCode; OldNetCodeSurbrillance = g_HightLigth_NetCode;
OldEtatSurbrillance = g_HightLigt_Status; OldEtatSurbrillance = g_HightLigt_Status;
...@@ -126,7 +133,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -126,7 +133,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
{ {
TrackOnStartPoint = (TRACK*) LockPoint; TrackOnStartPoint = (TRACK*) LockPoint;
g_HightLigth_NetCode = TrackOnStartPoint->GetNet(); g_HightLigth_NetCode = TrackOnStartPoint->GetNet();
CreateLockPoint( &pos.x, &pos.y, TrackOnStartPoint, NULL ); CreateLockPoint( pos, TrackOnStartPoint, NULL, &s_ItemsListPicker );
} }
} }
else // no starting point, but a filled zone area can exist. This is also a good starting point. else // no starting point, but a filled zone area can exist. This is also a good starting point.
...@@ -471,10 +478,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -471,10 +478,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
g_HightLigth_NetCode = adr_buf->GetNet(); g_HightLigth_NetCode = adr_buf->GetNet();
/* creation eventuelle d'un point d'accrochage */ /* creation eventuelle d'un point d'accrochage */
LockPoint = CreateLockPoint( &g_CurrentTrackSegment->m_End.x, LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End,
&g_CurrentTrackSegment->m_End.y,
adr_buf, adr_buf,
g_CurrentTrackSegment ); g_CurrentTrackSegment,
&s_ItemsListPicker);
} }
} }
...@@ -488,11 +495,13 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -488,11 +495,13 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
TRACK* firstTrack = g_FirstTrackSegment; TRACK* firstTrack = g_FirstTrackSegment;
int newCount = g_CurrentTrackList.GetCount(); int newCount = g_CurrentTrackList.GetCount();
// Put entire new current segment list in BOARD // Put entire new current segment list in BOARD, ans prepare undo command
TRACK* track; TRACK* track;
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() ); TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() );
while( ( track = g_CurrentTrackList.PopFront() ) != NULL ) while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
{ {
ITEM_PICKER picker( track, UR_NEW );
s_ItemsListPicker.PushItem( picker );
GetBoard()->m_Track.Insert( track, insertBeforeMe ); GetBoard()->m_Track.Insert( track, insertBeforeMe );
} }
...@@ -510,8 +519,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -510,8 +519,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
// erase the old track, if exists // erase the old track, if exists
if( g_AutoDeleteOldTrack ) if( g_AutoDeleteOldTrack )
{ {
EraseOldTrack( this, GetBoard(), DC, firstTrack, newCount ); EraseRedundantTrack( DC, firstTrack, newCount, & s_ItemsListPicker );
} }
SaveCopyInUndoList(s_ItemsListPicker, UR_UNSPECIFIED);
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
/* compute the new rastnest : */ /* compute the new rastnest : */
test_1_net_connexion( DC, netcode ); test_1_net_connexion( DC, netcode );
......
...@@ -55,11 +55,11 @@ void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event ) ...@@ -55,11 +55,11 @@ void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event )
{ {
gen_rastnest = true; gen_rastnest = true;
/* Segments used in Zone filling selection */ /* ZEG_ZONE items used in Zone filling selection are now deprecated :
// for many reasons saving these items can create problems so they are not saved * and are deleted but not put in undo buffer if exist
// (because they are numerous and can be deleted in zones operation) */
pcb->m_Zone.DeleteAll(); pcb->m_Zone.DeleteAll();
while( pcb->GetAreaCount() ) while( pcb->GetAreaCount() )
{ {
item = pcb->GetArea( 0 ); item = pcb->GetArea( 0 );
...@@ -216,7 +216,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery ) ...@@ -216,7 +216,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
// Clear undo and redo lists // Clear undo and redo lists
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
......
...@@ -139,7 +139,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, ...@@ -139,7 +139,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
GetBoard()->m_Track.Insert( newTrack, insertBeforeMe ); GetBoard()->m_Track.Insert( newTrack, insertBeforeMe );
break; break;
case TYPE_ZONE: case TYPE_ZONE: // this is now deprecated, but exits in old boards
newTrack = new SEGZONE( GetBoard() ); newTrack = new SEGZONE( GetBoard() );
GetBoard()->m_Zone.Insert( (SEGZONE*)newTrack, (SEGZONE*)insertBeforeMe ); GetBoard()->m_Zone.Insert( (SEGZONE*)newTrack, (SEGZONE*)insertBeforeMe );
break; break;
...@@ -846,7 +846,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -846,7 +846,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
{ {
ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(GetBoard()); ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(GetBoard());
zone_descr->ReadDescr( File, &LineNum ); zone_descr->ReadDescr( File, &LineNum );
if ( zone_descr->GetNumCorners( ) > 2 ) // should not occur if ( zone_descr->GetNumCorners( ) > 2 ) // should always occur
GetBoard()->Add(zone_descr); GetBoard()->Add(zone_descr);
else delete zone_descr; else delete zone_descr;
continue; continue;
......
This diff is collapsed.
...@@ -50,7 +50,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -50,7 +50,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_VIA: case TYPE_VIA:
if( DrawStruct->m_Flags & IS_DRAGGED ) if( DrawStruct->m_Flags & IS_DRAGGED )
{ {
PlaceDraggedTrackSegment( (TRACK*) DrawStruct, DC ); PlaceDraggedOrMovedTrackSegment( (TRACK*) DrawStruct, DC );
exit = true; exit = true;
} }
break; break;
......
...@@ -208,9 +208,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc ); ...@@ -208,9 +208,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc );
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ); DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int layer ); D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int layer );
/* Routine cherchant le pad contenant le point px,py, sur la couche layer /* Routine cherchant le pad contenant le point px,py, sur la couche layer
* ( extremite de piste ) * ( extremite de piste )
* La liste des pads doit deja exister. * La liste des pads doit deja exister.
...@@ -290,30 +288,6 @@ void ListSetState( EDA_BaseStruct* Start, int Nbitem, int State, int onoff ); ...@@ -290,30 +288,6 @@ void ListSetState( EDA_BaseStruct* Start, int Nbitem, int State, int onoff );
/* Met a jour le membre .state d'une chaine de structures */ /* Met a jour le membre .state d'une chaine de structures */
/************/
/* DRC.CPP : */
/************/
int Drc( WinEDA_BasePcbFrame* frame, wxDC* DC,
TRACK* pt_segment, TRACK* pt_start_buffer, int show_err );
/* Teste le segment pointe par pt_segment:
* debsegment = adresse du segment a tester
* pt_start_buffer = adresse de la zone piste
* show_err (flag) si 0 pas d'affichage d'erreur sur ecran
* retourne :
* BAD_DRC (1) si Violation DRC
* OK_DRC (0) si OK */
/*****************/
/* TR_MODIF.CPP : */
/*****************/
int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
TRACK* pt_new_track, int nbptnewpiste );
void Modif_Auto_Route( TRACK* pt_debut_new_piste );
/**************/ /**************/
/* CLEAN.CPP : */ /* CLEAN.CPP : */
/**************/ /**************/
...@@ -324,21 +298,6 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche ); ...@@ -324,21 +298,6 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche );
* de net_code differents */ * de net_code differents */
/************/
/* BLOCK.CPP */
/************/
void Block_Affiche( int on_off ); /*
* routine de trace du cadre d'un Block en cours de delimitation
* Si on_off = 0 : effacement du cadre
* Si on_off = 1 : affichage du cadre */
void Trace_Block( WinEDA_DrawPanel* panel, wxDC* DC, int ox, int oy, int fx, int fy, int color );
/* Routine de trace d'un rectangle symbolisant un block
* (toujours en mode XOR) */
/************/ /************/
/* ZONES.CPP */ /* ZONES.CPP */
/************/ /************/
...@@ -362,8 +321,6 @@ void MasqueAttributs( int* masque_set, int* masque_clr ); ...@@ -362,8 +321,6 @@ void MasqueAttributs( int* masque_set, int* masque_clr );
/* DUPLTRAC.CPP */ /* DUPLTRAC.CPP */
/***************/ /***************/
BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask );
/* Routine trouvant le point " d'accrochage " d'une extremite de piste. /* Routine trouvant le point " d'accrochage " d'une extremite de piste.
* Ce point peut etre un PAD ou un autre segment de piste * Ce point peut etre un PAD ou un autre segment de piste
* Retourne: * Retourne:
...@@ -371,24 +328,26 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask ); ...@@ -371,24 +328,26 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask );
* - pointeur sur le segment ou: * - pointeur sur le segment ou:
* - NULL * - NULL
* Parametres d'appel: * Parametres d'appel:
* coord pX, pY du point tst * coord aPos du point tst
* masque des couches a tester * aLayerMask masque des couches a tester
*/ */
BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask );
TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm );
/* Routine de creation d'un point intermediaire sur un segment /* Routine de creation d'un point intermediaire sur un segment
* le segment ptsegm est casse en 2 segments se raccordant au point pX, pY * le segment aSegm est casse en 2 segments se raccordant au point pX, pY
* retourne: * retourne:
* NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja * NULL si pas de nouveau point ( c.a.d si aRefPoint correspondait deja
* a une extremite ou: * a une extremite ou:
* pointeur sur le segment cree * pointeur sur le segment cree
* si refsegm != NULL refsegm est pointeur sur le segment incident, * si aRefSegm != NULL refsegm est pointeur sur le segment incident,
* et le point cree est l'ntersection des 2 axes des segments ptsegm et * et le point cree est l'intersection des 2 axes des segments ptsegm et aRefSegm
* refsegm * retourne la valeur exacte de aRefPoint
* retourne la valeur exacte de pX et pY * Si aSegm pointe sur une via:
* retourne la valeur exacte de aRefPoint et aSegm,
* mais ne cree pas de point supplementaire
*/ */
TRACK* CreateLockPoint( wxPoint & aRefPoint, TRACK* aSegm, TRACK* aRefSegm, PICKED_ITEMS_LIST* aItemsListPicker );
/****************/ /****************/
/* CONTROLE.CPP */ /* CONTROLE.CPP */
......
...@@ -4,25 +4,23 @@ ...@@ -4,25 +4,23 @@
/**************************************************/ /**************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "wxPcbStruct.h"
#include "protos.h" #include "protos.h"
/*********************************************************************/ /** function EraseRedundantTrack
int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, * Called after creating a track
TRACK* pt_new_track, int nbptnewpiste ) * Remove (if exists) the old track that have the same starting and the same ending point as the new created track
/*********************************************************************/ * (this is the redunding track)
* @param aDC = the current device context (can be NULL)
/* Routine d'effacement de la piste redondante a la piste nouvellement cree * @param aNewTrack = the new created track (a pointer to a segment of the track list)
* pointee par pt_new_track (nbptnewpiste segments) * @param aNewTrackSegmentsCount = number of segments in this new track
* * @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
* la piste cree est supposee constituee de segments contigus en memoire avec:
* point de depart pt_newtrack->m_Start.x,y
* point d'arrivee pt_newtrack->m_End.x,y
*/ */
int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewTrackSegmentsCount, PICKED_ITEMS_LIST* aItemsListPicker )
{ {
TRACK* StartTrack, * EndTrack;/* Pointeurs des segments de debut et fin TRACK* StartTrack, * EndTrack;/* Pointeurs des segments de debut et fin
* (extremites) de la nouvelle piste */ * (extremites) de la nouvelle piste */
...@@ -35,31 +33,31 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -35,31 +33,31 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
TRACK* BufDeb, * BufEnd; /* Pointeurs de debut et de fin de la zone TRACK* BufDeb, * BufEnd; /* Pointeurs de debut et de fin de la zone
* des pistes equipotentielles */ * des pistes equipotentielles */
int netcode = pt_new_track->GetNet(); int netcode = aNewTrack->GetNet();
/* Reconstitution de la piste complete ( la nouvelle piste /* Reconstitution de la piste complete ( la nouvelle piste
* a pu demarrer sur un segment de piste en l'air * a pu demarrer sur un segment de piste en l'air
*/ */
ListSetState( pt_new_track, nbptnewpiste, BUSY, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, BUSY, OFF );
/* si la novelle piste commence par une via, il est plus sur de rechercher /* si la nouvelle piste commence par une via, il est plus sur de rechercher
* la piste complete en utilisant le segment suivant comme reference, car * la piste complete en utilisant le segment suivant comme reference, car
* une via est souvent sur un carrefour de segments, et ne caracterise pas * une via est souvent sur un carrefour de segments, et ne caracterise pas
* une piste */ * une piste */
if( pt_new_track->Type() == TYPE_VIA && (nbptnewpiste > 1 ) ) if( aNewTrack->Type() == TYPE_VIA && (aNewTrackSegmentsCount > 1 ) )
pt_new_track = pt_new_track->Next(); aNewTrack = aNewTrack->Next();
pt_new_track = Marque_Une_Piste( frame, DC, pt_new_track, &nbptnewpiste, 0 ); aNewTrack = Marque_Une_Piste( this, aDC, aNewTrack, &aNewTrackSegmentsCount, 0 );
wxASSERT( pt_new_track ); wxASSERT( aNewTrack );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
TRACK* EndNewTrack; /* Pointeur sur le dernier segment de la liste TRACK* EndNewTrack; /* Pointeur sur le dernier segment de la liste
* chainee de la mouvelle piste */ * chainee de la mouvelle piste */
EndNewTrack = pt_new_track; EndNewTrack = aNewTrack;
for( ii = 1; ii < nbptnewpiste; ii++ ) for( ii = 1; ii < aNewTrackSegmentsCount; ii++ )
{ {
wxASSERT( EndNewTrack->GetState(-1) != 0 ); wxASSERT( EndNewTrack->GetState(-1) != 0 );
D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );) D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );)
...@@ -69,13 +67,13 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -69,13 +67,13 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
wxASSERT( EndNewTrack->GetState(-1) != 0 ); wxASSERT( EndNewTrack->GetState(-1) != 0 );
D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );) D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );)
for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
track->Show( 0, std::cout ); track->Show( 0, std::cout );
#endif #endif
/* Calcul des limites de recherche des segments de piste */ /* Calcul des limites de recherche des segments de piste */
/* BufDeb pointe le 1er segment utile */ /* BufDeb pointe le 1er segment utile */
BufDeb = Pcb->m_Track->GetStartNetCode( netcode ); BufDeb = m_Pcb->m_Track->GetStartNetCode( netcode );
/* BufEnd Pointe le dernier segment */ /* BufEnd Pointe le dernier segment */
BufEnd = BufDeb->GetEndNetCode( netcode ); BufEnd = BufDeb->GetEndNetCode( netcode );
...@@ -90,7 +88,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -90,7 +88,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
} }
/* Calcul des points limites de la nouvelle piste */ /* Calcul des points limites de la nouvelle piste */
if( ReturnEndsTrack( pt_new_track, nbptnewpiste, if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount,
&StartTrack, &EndTrack ) == 0 ) &StartTrack, &EndTrack ) == 0 )
return 0; return 0;
...@@ -110,7 +108,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -110,7 +108,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
endmasklayer = EndTrack->ReturnMaskLayer(); endmasklayer = EndTrack->ReturnMaskLayer();
/* Il peut y avoir une via ou un pad sur les extremites: */ /* Il peut y avoir une via ou un pad sur les extremites: */
pt_segm = Fast_Locate_Via( Pcb->m_Track, NULL, start, startmasklayer ); pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, start, startmasklayer );
if( pt_segm ) if( pt_segm )
startmasklayer |= pt_segm->ReturnMaskLayer(); startmasklayer |= pt_segm->ReturnMaskLayer();
...@@ -121,7 +119,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -121,7 +119,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
startmasklayer |= pt_pad->m_Masque_Layer; startmasklayer |= pt_pad->m_Masque_Layer;
} }
pt_segm = Fast_Locate_Via( Pcb->m_Track, NULL, end, endmasklayer ); pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, end, endmasklayer );
if( pt_segm ) if( pt_segm )
endmasklayer |= pt_segm->ReturnMaskLayer(); endmasklayer |= pt_segm->ReturnMaskLayer();
...@@ -134,7 +132,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -134,7 +132,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
/* Marquage a DELETED de la piste nouvelle (qui ne doit pas intervenir /* Marquage a DELETED de la piste nouvelle (qui ne doit pas intervenir
* dans la recherche d'autres connexions) * dans la recherche d'autres connexions)
*/ */
ListSetState( pt_new_track, nbptnewpiste, DELETED, ON ); ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, ON );
/* test : un segment doit etre connecte au point de depart car sinon /* test : un segment doit etre connecte au point de depart car sinon
* il est inutile d'analyser l'autre point * il est inutile d'analyser l'autre point
...@@ -145,7 +143,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -145,7 +143,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
if( pt_segm == NULL ) /* Pas de piste reliee au point de depart */ if( pt_segm == NULL ) /* Pas de piste reliee au point de depart */
{ {
/* Suppression du flag DELETED */ /* Suppression du flag DELETED */
ListSetState( pt_new_track, nbptnewpiste, DELETED, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, OFF );
return 0; return 0;
} }
...@@ -188,9 +186,9 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -188,9 +186,9 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
/* Marquage a EDIT de la piste nouvelle (qui ne doit pas intervenir /* Marquage a EDIT de la piste nouvelle (qui ne doit pas intervenir
* dans la recherche d'autres pistes) */ * dans la recherche d'autres pistes) */
ListSetState( pt_new_track, nbptnewpiste, DELETED, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, OFF );
ListSetState( pt_new_track, nbptnewpiste, EDIT, ON ); ListSetState( aNewTrack, aNewTrackSegmentsCount, EDIT, ON );
/* Examen de tous les segments marques */ /* Examen de tous les segments marques */
while( nbconnect ) while( nbconnect )
...@@ -206,7 +204,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -206,7 +204,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
nbconnect--; nbconnect--;
pt_del->SetState( CHAIN, OFF ); pt_del->SetState( CHAIN, OFF );
pt_del = Marque_Une_Piste( frame, DC, pt_del, &nb_segm, 0 ); pt_del = Marque_Une_Piste( this, aDC, pt_del, &nb_segm, 0 );
/* Test si La piste marquee est redondante, c'est a dire si l'un des /* Test si La piste marquee est redondante, c'est a dire si l'un des
* segments marques est connecte au point de depart de la piste nouvelle * segments marques est connecte au point de depart de la piste nouvelle
...@@ -222,21 +220,31 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -222,21 +220,31 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
{ {
/* la piste marquee peut etre effacee */ /* la piste marquee peut etre effacee */
TRACK* NextS; TRACK* NextS;
Trace_Une_Piste( frame->DrawPanel, DC, pt_del, nb_segm, GR_XOR | GR_SURBRILL ); Trace_Une_Piste( DrawPanel, aDC, pt_del, nb_segm, GR_XOR | GR_SURBRILL );
for( jj = 0; jj < nb_segm; jj++, pt_del = NextS ) for( jj = 0; jj < nb_segm; jj++, pt_del = NextS )
{ {
NextS = pt_del->Next(); NextS = pt_del->Next();
pt_del->DeleteStructure(); if( aItemsListPicker )
{
pt_del->UnLink();
pt_del->SetStatus( 0 );
pt_del->m_Flags = 0;
ITEM_PICKER picker( pt_del, UR_DELETED );
aItemsListPicker->PushItem( picker );
}
else
pt_del->DeleteStructure();
} }
/* nettoyage des flags */ /* nettoyage des flags */
for( pt_del = Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() ) for( pt_del = m_Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() )
{ {
if( pt_del->GetState( EDIT ) ) if( pt_del->GetState( EDIT ) )
{ {
pt_del->SetState( EDIT, OFF ); pt_del->SetState( EDIT, OFF );
pt_del->Draw( frame->DrawPanel, DC, GR_OR ); if( aDC )
pt_del->Draw( DrawPanel, aDC, GR_OR );
} }
pt_del->SetState( EDIT | CHAIN, OFF ); pt_del->SetState( EDIT | CHAIN, OFF );
} }
...@@ -251,7 +259,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, ...@@ -251,7 +259,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC,
} }
/* Clear used flags */ /* Clear used flags */
for( pt_del = Pcb->m_Track; pt_del; pt_del = pt_del->Next() ) for( pt_del = m_Pcb->m_Track; pt_del; pt_del = pt_del->Next() )
{ {
pt_del->SetState( BUSY | DELETED | EDIT | CHAIN, OFF ); pt_del->SetState( BUSY | DELETED | EDIT | CHAIN, OFF );
if( pt_del == BufEnd ) // Last segment reached if( pt_del == BufEnd ) // Last segment reached
......
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