2007-08-23 04:28:46 +00:00
|
|
|
/**********************************************/
|
|
|
|
/* GERBVIEW : Routines d'initialisation globale */
|
|
|
|
/******* Fichier INITPCB.C ********************/
|
|
|
|
/**********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.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
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "gerbview.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
bool WinEDA_GerberFrame::Clear_Pcb( bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Realise les init des pointeurs et variables
|
2007-08-23 04:28:46 +00:00
|
|
|
* Si Item == NULL, il n'y aura pas de confirmation
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int layer;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard() == NULL )
|
2007-08-23 04:28:46 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if( query )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Drawings || GetBoard()->m_Track || GetBoard()->m_Zone )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
if( !IsOK( this, _( "Current Data will be lost ?" ) ) )
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Drawings.DeleteAll();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Track.DeleteAll();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Zone.DeleteAll();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
for( ; g_UnDeleteStackPtr != 0; )
|
|
|
|
{
|
|
|
|
g_UnDeleteStackPtr--;
|
2008-12-06 08:21:54 +00:00
|
|
|
delete g_UnDeleteStack[ g_UnDeleteStackPtr];
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* init pointeurs et variables */
|
|
|
|
for( layer = 0; layer < 32; layer++ )
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
if( g_GERBER_List[layer] )
|
|
|
|
g_GERBER_List[layer]->InitToolTable();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remise a 0 ou a une valeur initiale des variables de la structure */
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_BoundaryBox.SetOrigin( 0, 0 );
|
|
|
|
GetBoard()->m_BoundaryBox.SetSize( 0, 0 );
|
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
|
|
|
GetBoard()->m_NbNodes = 0;
|
|
|
|
GetBoard()->m_NbNoconnect = 0;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
/* Init parametres de gestion des ecrans PAD et PCB */
|
2008-04-17 16:25:29 +00:00
|
|
|
SetBaseScreen( ActiveScreen = ScreenPcb );
|
|
|
|
GetScreen()->Init();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
void WinEDA_GerberFrame::Erase_Zones( bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
if( query && !IsOK( this, _( "Delete zones ?" ) ) )
|
|
|
|
return;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Zone.DeleteAll();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
ScreenPcb->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/************************************************************************/
|
|
|
|
void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
|
|
|
|
/************************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-06 08:21:54 +00:00
|
|
|
int layer = GetScreen()->m_Active_Layer;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
if( all_layers )
|
|
|
|
layer = -1;
|
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
BOARD_ITEM* next;
|
2009-01-05 05:21:35 +00:00
|
|
|
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = next )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2008-12-06 08:21:54 +00:00
|
|
|
next = item->Next();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
switch( item->Type() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_COTATION:
|
|
|
|
case TYPE_MIRE:
|
2008-12-06 08:21:54 +00:00
|
|
|
if( item->GetLayer() == layer || layer < 0 )
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Delete( item );
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "Type Draw inconnu/inattendu" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScreenPcb->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/******************************************************************/
|
|
|
|
void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query )
|
|
|
|
/******************************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Efface les segments de piste, selon les autorisations affichees
|
2007-08-23 04:28:46 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
BOARD_ITEM* PtNext;
|
|
|
|
|
|
|
|
if( query && !IsOK( this, _( "Delete Tracks?" ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Marquage des pistes a effacer */
|
2009-01-05 05:21:35 +00:00
|
|
|
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
PtNext = pt_segm->Next();
|
|
|
|
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
|
|
|
|
continue;
|
2007-10-03 15:21:13 +00:00
|
|
|
pt_segm->DeleteStructure();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScreenPcb->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
BOARD_ITEM* PtStruct;
|
|
|
|
BOARD_ITEM* PtNext;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
PtStruct = GetBoard()->m_Drawings;
|
2007-08-23 04:28:46 +00:00
|
|
|
for( ; PtStruct != NULL; PtStruct = PtNext )
|
|
|
|
{
|
|
|
|
PtNext = PtStruct->Next();
|
2008-12-04 04:28:11 +00:00
|
|
|
if( PtStruct->Type() == TYPE_TEXTE )
|
2007-10-03 15:21:13 +00:00
|
|
|
PtStruct->DeleteStructure();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
ScreenPcb->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/*********************************************************/
|
|
|
|
void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
|
|
|
|
/*********************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
int layer = GetScreen()->m_Active_Layer;
|
2007-08-23 04:28:46 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg.Printf( _( "Delete Layer %d" ), layer + 1 );
|
|
|
|
if( query && !IsOK( this, msg ) )
|
|
|
|
return;
|
|
|
|
|
2007-11-02 10:14:12 +00:00
|
|
|
/* Delete tracks (spots and lines) */
|
|
|
|
TRACK* PtNext;
|
2009-01-05 05:21:35 +00:00
|
|
|
for( TRACK* pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
PtNext = pt_segm->Next();
|
|
|
|
if( pt_segm->GetLayer() != layer )
|
|
|
|
continue;
|
2007-10-03 15:21:13 +00:00
|
|
|
pt_segm->DeleteStructure();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 10:14:12 +00:00
|
|
|
/* Delete polygons */
|
|
|
|
SEGZONE* Nextzone;
|
2009-01-05 05:21:35 +00:00
|
|
|
for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = Nextzone )
|
2007-11-02 10:14:12 +00:00
|
|
|
{
|
|
|
|
Nextzone = zone->Next();
|
|
|
|
if( zone->GetLayer() != layer )
|
|
|
|
continue;
|
|
|
|
zone->DeleteStructure();
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
ScreenPcb->SetModify();
|
|
|
|
ScreenPcb->SetRefreshReq();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|