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"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines externes : */
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
|
|
/********************************************/
|
2008-12-06 21:20:50 +00:00
|
|
|
void WinEDA_BasePcbFrame::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
|
|
|
{
|
2008-02-12 01:02:53 +00:00
|
|
|
BOARD_ITEM* item;
|
2008-12-04 04:28:11 +00:00
|
|
|
int net_code = 0;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
if( !g_UnDeleteStackPtr )
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_UnDeleteStackPtr--;
|
2008-02-12 01:02:53 +00:00
|
|
|
item = g_UnDeleteStack[g_UnDeleteStackPtr];
|
|
|
|
if( item == NULL )
|
2007-08-20 19:33:15 +00:00
|
|
|
return; // Ne devrait pas se produire
|
|
|
|
|
2008-12-06 21:20:50 +00:00
|
|
|
// we decremented the stack pointer, so the stack no longer
|
|
|
|
// owns "item". We do here, so we have to delete item if its
|
|
|
|
// not going back into the board, see default case below.
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
|
|
|
|
|
|
|
|
|
2008-02-12 01:02:53 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_VIA:
|
|
|
|
case TYPE_TRACK:
|
|
|
|
TRACK* track;
|
|
|
|
track = (TRACK*) item;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
D(printf("%s: track %p status=\"%s\"\n", __func__, track,
|
|
|
|
CONV_TO_UTF8( TRACK::ShowState( track->GetState(-1)) )
|
|
|
|
);)
|
2008-02-12 01:02:53 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
track->SetState( DELETED, OFF );
|
|
|
|
DrawPanel->PostDirtyRect( track->GetBoundingBox() );
|
|
|
|
m_Pcb->Add( track );
|
|
|
|
|
|
|
|
net_code = track->GetNet();
|
2008-12-06 21:20:50 +00:00
|
|
|
|
|
|
|
#if !defined(GERBVIEW)
|
2008-12-04 04:28:11 +00:00
|
|
|
test_1_net_connexion( DC, net_code );
|
2008-12-06 21:20:50 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
m_Pcb->Display_Infos( this );
|
|
|
|
break;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_BOARD_ITEM_LIST:
|
|
|
|
BOARD_ITEM_LIST* list;
|
|
|
|
list = (BOARD_ITEM_LIST*) item;
|
|
|
|
while( list->GetCount() )
|
|
|
|
{
|
|
|
|
TRACK* t = (TRACK*) list->Remove( 0 );
|
|
|
|
wxASSERT( t->Type()==TYPE_TRACK || t->Type()==TYPE_VIA );
|
|
|
|
t->SetState( DELETED, OFF );
|
|
|
|
DrawPanel->PostDirtyRect( t->GetBoundingBox() );
|
|
|
|
m_Pcb->Add( t );
|
|
|
|
net_code = t->GetNet();
|
|
|
|
}
|
|
|
|
delete list;
|
2008-12-06 21:20:50 +00:00
|
|
|
|
|
|
|
#if !defined(GERBVIEW)
|
2007-08-20 19:33:15 +00:00
|
|
|
test_1_net_connexion( DC, net_code );
|
2008-12-06 21:20:50 +00:00
|
|
|
#endif
|
2007-08-20 19:33:15 +00:00
|
|
|
m_Pcb->Display_Infos( this );
|
|
|
|
break;
|
|
|
|
|
2008-12-06 21:20:50 +00:00
|
|
|
#if !defined(GERBVIEW)
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MODULE:
|
2008-12-06 21:20:50 +00:00
|
|
|
// Erase general rastnest if needed
|
2007-08-20 19:33:15 +00:00
|
|
|
if( g_Show_Ratsnest )
|
|
|
|
DrawGeneralRatsnest( DC );
|
|
|
|
|
2008-02-12 01:02:53 +00:00
|
|
|
m_Pcb->Add( item );
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
item->Draw( DrawPanel, DC, GR_OR );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2008-02-12 01:02:53 +00:00
|
|
|
item->SetState( DELETED, OFF ); /* Creal DELETED flag */
|
|
|
|
item->m_Flags = 0;
|
2007-08-20 19:33:15 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2008-12-06 21:20:50 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
build_liste_pads();
|
|
|
|
ReCompile_Ratsnest_After_Changes( DC );
|
|
|
|
break;
|
2008-12-06 21:20:50 +00:00
|
|
|
#endif
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_PcbFrame::UnDeleteItem(): unexpected Struct type" ) );
|
2008-12-06 21:20:50 +00:00
|
|
|
delete item;
|
2007-08-20 19:33:15 +00:00
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
|
*/
|
2008-12-06 21:20:50 +00:00
|
|
|
BOARD_ITEM* WinEDA_BasePcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aItem == NULL || nbitems == 0 )
|
2007-08-20 19:33:15 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
// Delete last deleted item, and shift stack.
|
|
|
|
delete g_UnDeleteStack[0];
|
|
|
|
|
|
|
|
for( int ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
|
|
|
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
g_UnDeleteStackPtr--;;
|
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
switch( aItem->Type() )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_VIA:
|
|
|
|
case TYPE_TRACK:
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
DLIST<TRACK>* container = (DLIST<TRACK>*) aItem->GetList();
|
|
|
|
wxASSERT( container );
|
|
|
|
|
|
|
|
if( nbitems == 1 )
|
|
|
|
{
|
|
|
|
container->Remove( (TRACK*) aItem );
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr++] = aItem;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOARD_ITEM_LIST* list = new BOARD_ITEM_LIST();
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr++] = list;
|
|
|
|
|
2008-12-06 21:20:50 +00:00
|
|
|
// copy the numerous tracks into the list, which is already on stack
|
2008-12-04 04:28:11 +00:00
|
|
|
int i = 0;
|
|
|
|
TRACK* next;
|
|
|
|
for( TRACK* track = (TRACK*) aItem; track && i<nbitems; track = next, ++i )
|
|
|
|
{
|
|
|
|
next = track->Next();
|
|
|
|
list->PushBack( container->Remove( track ) );
|
|
|
|
}
|
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-06 21:20:50 +00:00
|
|
|
#if !defined(GERBVIEW)
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MODULE:
|
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) aItem;
|
|
|
|
m_Pcb->m_Modules.Remove( module );
|
|
|
|
module->SetState( DELETED, ON );
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr++] = module;
|
|
|
|
build_liste_pads();
|
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
break;
|
2008-12-06 21:20:50 +00:00
|
|
|
#endif
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-12-06 21:20:50 +00:00
|
|
|
// don't know why this is not simply return aItem?
|
2007-08-20 19:33:15 +00:00
|
|
|
return g_UnDeleteStack[g_UnDeleteStackPtr - 1];
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|