2007-08-20 19:33:15 +00:00
|
|
|
/********************************************************/
|
|
|
|
/* Effacements : Routines de sauvegarde et d'effacement */
|
|
|
|
/********************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Routines externes : */
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
|
|
/********************************************/
|
2007-08-20 19:33:15 +00:00
|
|
|
void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************/
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Restitution d'un element (MODULE ou TRACK ) Efface
|
2007-08-20 19:33:15 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
BOARD_ITEM* PtStruct, * PtNext;
|
2007-08-20 19:33:15 +00:00
|
|
|
TRACK* pt_track;
|
|
|
|
int net_code;
|
|
|
|
|
|
|
|
if( !g_UnDeleteStackPtr )
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_UnDeleteStackPtr--;
|
|
|
|
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr];
|
|
|
|
if( PtStruct == NULL )
|
|
|
|
return; // Ne devrait pas se produire
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( PtStruct->Type() )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
|
|
|
case TYPEVIA:
|
|
|
|
case TYPETRACK:
|
|
|
|
for( ; PtStruct != NULL; PtStruct = PtNext )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
PtNext = PtStruct->Next();
|
2007-08-20 19:33:15 +00:00
|
|
|
PtStruct->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
|
|
|
|
( (TRACK*) PtStruct )->Draw( DrawPanel, DC, GR_OR );
|
|
|
|
}
|
|
|
|
|
|
|
|
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr];
|
2007-10-13 06:18:44 +00:00
|
|
|
net_code = ( (TRACK*) PtStruct )->GetNet();
|
2007-08-20 19:33:15 +00:00
|
|
|
pt_track = ( (TRACK*) PtStruct )->GetBestInsertPoint( m_Pcb );
|
|
|
|
( (TRACK*) PtStruct )->Insert( m_Pcb, pt_track );
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
|
|
|
|
|
|
|
|
test_1_net_connexion( DC, net_code );
|
|
|
|
m_Pcb->Display_Infos( this );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMODULE:
|
|
|
|
/* Erase general rastnest if needed */
|
|
|
|
if( g_Show_Ratsnest )
|
|
|
|
DrawGeneralRatsnest( DC );
|
|
|
|
|
|
|
|
/* Reinsertion du module dans la liste chainee des modules,
|
|
|
|
* en debut de chaine */
|
|
|
|
PtStruct->Pback = m_Pcb;
|
|
|
|
PtNext = m_Pcb->m_Modules;
|
|
|
|
PtStruct->Pnext = PtNext;
|
|
|
|
if( PtNext )
|
|
|
|
PtNext->Pback = PtStruct;
|
|
|
|
m_Pcb->m_Modules = (MODULE*) PtStruct;
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
|
|
|
|
|
|
|
|
( (MODULE*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
|
|
|
|
|
|
|
|
PtStruct->SetState( DELETED, OFF ); /* Creal DELETED flag */
|
|
|
|
PtStruct->m_Flags = 0;
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
build_liste_pads();
|
|
|
|
ReCompile_Ratsnest_After_Changes( DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_PcbFrame::UnDeleteItem(): unexpected Struct type" ) );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
/**************************************************************/
|
|
|
|
/* void * SaveItemEfface(int type, void * PtItem, int nbitems) */
|
|
|
|
/**************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Sauvegarde d'un element aux fins de restitution par Undelete
|
2007-08-20 19:33:15 +00:00
|
|
|
* Supporte actuellement : Module et segments de piste
|
|
|
|
*/
|
2007-09-01 12:00:30 +00:00
|
|
|
BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
BOARD_ITEM* NextS, * PtStruct = PtItem;
|
2007-08-20 19:33:15 +00:00
|
|
|
int ii;
|
|
|
|
|
|
|
|
if( (PtItem == NULL) || (nbitems == 0) )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
|
|
|
|
{
|
|
|
|
/* Delete last deleted item, and shift stack. */
|
2007-10-03 15:21:13 +00:00
|
|
|
g_UnDeleteStack[0]->DeleteStructList();
|
2007-08-20 19:33:15 +00:00
|
|
|
for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
|
|
|
|
{
|
|
|
|
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
g_UnDeleteStackPtr--;;
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( PtStruct->Type() )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
|
|
|
case TYPEVIA:
|
|
|
|
case TYPETRACK:
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
BOARD_ITEM* Back = NULL;
|
2007-08-20 19:33:15 +00:00
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr++] = PtStruct;
|
|
|
|
|
|
|
|
for( ; nbitems > 0; nbitems--, PtStruct = NextS )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
NextS = PtStruct->Next();
|
2007-08-20 19:33:15 +00:00
|
|
|
( (TRACK*) PtStruct )->UnLink();
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
PtStruct->SetState( DELETED, ON );
|
|
|
|
if( nbitems <= 1 )
|
|
|
|
NextS = NULL; /* fin de chaine */
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
PtStruct->Pnext = NextS;
|
|
|
|
PtStruct->Pback = Back; Back = PtStruct;
|
|
|
|
if( NextS == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMODULE:
|
|
|
|
{
|
|
|
|
MODULE* Module = (MODULE*) PtItem;
|
|
|
|
Module->UnLink();
|
|
|
|
Module->SetState( DELETED, ON );
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr++] = Module;
|
|
|
|
build_liste_pads();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_UnDeleteStack[g_UnDeleteStackPtr - 1];
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|