kicad/gerbview/initpcb.cpp

215 lines
5.6 KiB
C++
Raw Normal View History

2007-08-23 04:28:46 +00:00
/**********************************************/
/* GERBVIEW : Routines d'initialisation globale */
/******* Fichier INITPCB.C ********************/
/**********************************************/
#include "fctsys.h"
#include "common.h"
#include "gerbview.h"
#include "protos.h"
/* Routines Locales */
/********************************************************/
2007-08-23 04:28:46 +00:00
bool WinEDA_GerberFrame::Clear_Pcb( wxDC* DC, bool query )
/********************************************************/
2007-08-23 04:28:46 +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-08-23 04:28:46 +00:00
int layer;
if( m_Pcb == NULL )
return FALSE;
if( query )
{
if( m_Pcb->m_Drawings || m_Pcb->m_Track || m_Pcb->m_Zone )
{
if( !IsOK( this, _( "Current Data will be lost ?" ) ) )
return FALSE;
}
}
DeleteStructList( m_Pcb->m_Drawings );
m_Pcb->m_Drawings = NULL;
DeleteStructList( m_Pcb->m_Track );
m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0;
DeleteStructList( m_Pcb->m_Zone );
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
for( ; g_UnDeleteStackPtr != 0; )
{
g_UnDeleteStackPtr--;
DeleteStructList( g_UnDeleteStack[ g_UnDeleteStackPtr] );
}
/* init pointeurs et variables */
for( layer = 0; layer < 32; layer++ )
{
if( g_GERBER_Descr_List[layer] )
g_GERBER_Descr_List[layer]->InitToolTable();
}
/* remise a 0 ou a une valeur initiale des variables de la structure */
m_Pcb->m_BoundaryBox.SetOrigin( 0, 0 );
m_Pcb->m_BoundaryBox.SetSize( 0, 0 );
m_Pcb->m_Status_Pcb = 0;
m_Pcb->m_NbLoclinks = 0;
m_Pcb->m_NbLinks = 0;
m_Pcb->m_NbPads = 0;
m_Pcb->m_NbNets = 0;
m_Pcb->m_NbNodes = 0;
m_Pcb->m_NbNoconnect = 0;
m_Pcb->m_NbSegmTrack = 0;
m_Pcb->m_NbSegmZone = 0;
/* Init parametres de gestion des ecrans PAD et PCB */
m_CurrentScreen = ActiveScreen = ScreenPcb;
GetScreen()->Init();
return TRUE;
}
2007-08-23 04:28:46 +00:00
/*********************************************************/
2007-08-23 04:28:46 +00:00
void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query )
/*********************************************************/
{
2007-08-23 04:28:46 +00:00
if( query && !IsOK( this, _( "Delete zones ?" ) ) )
return;
if( m_Pcb->m_Zone )
{
DeleteStructList( m_Pcb->m_Zone );
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
}
ScreenPcb->SetModify();
}
/*****************************************************/
2007-08-23 04:28:46 +00:00
void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC,
bool all_layers, bool query )
/*****************************************************/
{
2007-08-23 04:28:46 +00:00
BOARD_ITEM* PtStruct;
BOARD_ITEM* PtNext;
int layer = GetScreen()->m_Active_Layer;
if( all_layers )
layer = -1;
PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtNext )
{
PtNext = PtStruct->Next();
2007-09-01 12:00:30 +00:00
switch( PtStruct->Type() )
2007-08-23 04:28:46 +00:00
{
case TYPEDRAWSEGMENT:
case TYPETEXTE:
case TYPECOTATION:
case TYPEMIRE:
if( PtStruct->GetLayer() == layer || layer < 0 )
DeleteStructure( PtStruct );
break;
default:
DisplayError( this, wxT( "Type Draw inconnu/inattendu" ) );
break;
}
}
ScreenPcb->SetModify();
}
/****************************************************************/
2007-08-23 04:28:46 +00:00
void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type,
bool query )
/****************************************************************/
2007-08-23 04:28:46 +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-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 */
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext )
{
PtNext = pt_segm->Next();
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
continue;
DeleteStructure( pt_segm );
}
ScreenPcb->SetModify();
}
/*****************************************************************/
2007-08-23 04:28:46 +00:00
void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
/*****************************************************************/
{
2007-08-23 04:28:46 +00:00
BOARD_ITEM* PtStruct;
BOARD_ITEM* PtNext;
2007-08-23 04:28:46 +00:00
if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) )
return;
2007-08-23 04:28:46 +00:00
PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtNext )
{
PtNext = PtStruct->Next();
2007-09-01 12:00:30 +00:00
if( PtStruct->Type() == TYPETEXTE )
2007-08-23 04:28:46 +00:00
DeleteStructure( PtStruct );
}
2007-08-23 04:28:46 +00:00
ScreenPcb->SetModify();
}
2007-08-23 04:28:46 +00:00
/*******************************************************************/
2007-08-23 04:28:46 +00:00
void WinEDA_GerberFrame::Erase_Current_Layer( wxDC* DC, bool query )
/*******************************************************************/
{
2007-08-23 04:28:46 +00:00
TRACK* pt_segm;
BOARD_ITEM* PtNext;
int layer = GetScreen()->m_Active_Layer;
wxString msg;
msg.Printf( _( "Delete Layer %d" ), layer + 1 );
if( query && !IsOK( this, msg ) )
return;
/* Marquage des pistes a effacer */
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext )
{
PtNext = pt_segm->Next();
if( pt_segm->GetLayer() != layer )
continue;
DeleteStructure( pt_segm );
}
ScreenPcb->SetModify();
ScreenPcb->SetRefreshReq();
}