2007-08-20 01:20:48 +00:00
|
|
|
/**********************************************/
|
|
|
|
/* PCBNEW : Routines d'initialisation globale */
|
|
|
|
/******* Fichier INITPCB.C ********************/
|
|
|
|
/**********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "autorout.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/**************************************/
|
|
|
|
/* dialog WinEDA_PcbGlobalDeleteFrame */
|
|
|
|
/**************************************/
|
|
|
|
#include "dialog_initpcb.cpp"
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::InstallPcbGlobalDeleteFrame( const wxPoint& pos )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_PcbGlobalDeleteFrame* frame =
|
|
|
|
new WinEDA_PcbGlobalDeleteFrame( this );
|
|
|
|
|
|
|
|
frame->ShowModal(); frame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int track_mask;
|
|
|
|
bool redraw = FALSE;
|
|
|
|
wxClientDC dc( m_Parent->DrawPanel );
|
|
|
|
|
|
|
|
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
|
|
|
if( m_DelAlls->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Clear_Pcb( &dc, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_DelZones->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Zones( &dc, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelTexts->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Textes_Pcb( &dc, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelEdges->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Segments_Pcb( &dc, TRUE, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelDrawings->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Segments_Pcb( &dc, FALSE, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelModules->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Modules( &dc, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelTracks->GetValue() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
track_mask = 0;
|
|
|
|
if( !m_TrackFilterLocked->GetValue() )
|
|
|
|
track_mask |= SEGM_FIXE;
|
|
|
|
if( !m_TrackFilterAR->GetValue() )
|
|
|
|
track_mask |= SEGM_AR;
|
|
|
|
|
|
|
|
m_Parent->Erase_Pistes( &dc, track_mask, TRUE );
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelMarkers->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Marqueurs();
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( redraw )
|
|
|
|
{
|
2007-09-12 02:14:07 +00:00
|
|
|
m_Parent->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Realise les init des pointeurs et variables
|
2007-08-20 01:20:48 +00:00
|
|
|
* Si query == FALSE, il n'y aura pas de confirmation
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_Pcb == NULL )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if( query && GetScreen()->IsModify() )
|
|
|
|
{
|
|
|
|
if( m_Pcb->m_Drawings ||m_Pcb->m_Modules
|
|
|
|
|| m_Pcb->m_Track || m_Pcb->m_Zone )
|
|
|
|
{
|
|
|
|
if( !IsOK( this, _( "Current Board will be lost ?" ) ) )
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Suppression des listes chainees */
|
|
|
|
DeleteStructList( m_Pcb->m_Equipots );
|
|
|
|
m_Pcb->m_Equipots = NULL;
|
|
|
|
|
|
|
|
DeleteStructList( m_Pcb->m_Drawings );
|
|
|
|
m_Pcb->m_Drawings = NULL;
|
|
|
|
|
|
|
|
DeleteStructList( m_Pcb->m_Modules );
|
|
|
|
m_Pcb->m_Modules = 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;
|
|
|
|
DelLimitesZone( DC, FALSE );
|
|
|
|
|
|
|
|
for( ; g_UnDeleteStackPtr != 0; )
|
|
|
|
{
|
|
|
|
g_UnDeleteStackPtr--;
|
|
|
|
DeleteStructList( g_UnDeleteStack[g_UnDeleteStackPtr] );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init pointeurs et variables */
|
|
|
|
GetScreen()->m_FileName.Empty();
|
|
|
|
memset( buf_work, 0, BUFMEMSIZE );
|
|
|
|
adr_lowmem = adr_max = buf_work;
|
|
|
|
|
|
|
|
if( m_Pcb->m_Pads )
|
|
|
|
{
|
|
|
|
MyFree( m_Pcb->m_Pads );
|
|
|
|
m_Pcb->m_Pads = NULL;
|
|
|
|
}
|
|
|
|
if( m_Pcb->m_Ratsnest )
|
|
|
|
MyFree( m_Pcb->m_Ratsnest );
|
|
|
|
if( m_Pcb->m_LocalRatsnest )
|
|
|
|
MyFree( m_Pcb->m_LocalRatsnest );
|
|
|
|
m_Pcb->m_Ratsnest = NULL;
|
|
|
|
m_Pcb->m_LocalRatsnest = NULL;
|
|
|
|
|
|
|
|
/* remise a 0 ou a une valeur initiale des variables de la structure */
|
|
|
|
m_Pcb->m_BoundaryBox.SetOrigin( wxPoint( 0, 0 ) );
|
|
|
|
m_Pcb->m_BoundaryBox.SetSize( wxSize( 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;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Init parametres de gestion */
|
|
|
|
GetScreen()->Init();
|
|
|
|
|
|
|
|
g_HightLigt_Status = 0;
|
|
|
|
|
|
|
|
for( int ii = 1; ii < HIST0RY_NUMBER; ii++ )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_ViaSizeHistory[ii] =
|
|
|
|
g_DesignSettings.m_TrackWidhtHistory[ii] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_DesignSettings.m_TrackWidhtHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
|
|
|
|
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
|
|
|
|
|
|
|
|
Zoom_Automatique( TRUE );
|
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( query && !IsOK( this, _( "Delete Zones ?" ) ) )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_Pcb->m_Zone )
|
|
|
|
{
|
|
|
|
while( m_Pcb->m_Zone )
|
|
|
|
DeleteStructure( m_Pcb->m_Zone );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Pcb->m_NbSegmZone = 0;
|
|
|
|
}
|
|
|
|
DelLimitesZone( DC, FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, 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-08-20 01:20:48 +00:00
|
|
|
int masque_layer = (~EDGE_LAYER) & 0x1FFF0000;
|
|
|
|
|
|
|
|
if( is_edges )
|
|
|
|
{
|
|
|
|
masque_layer = EDGE_LAYER;
|
|
|
|
if( query && !IsOK( this, _( "Delete Board edges ?" ) ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( query && !IsOK( this, _( "Delete draw items?" ) ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
PtStruct = m_Pcb->m_Drawings;
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; PtStruct != NULL; PtStruct = PtNext )
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
PtNext = PtStruct->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( PtStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case TYPEDRAWSEGMENT:
|
|
|
|
case TYPETEXTE:
|
|
|
|
case TYPECOTATION:
|
|
|
|
case TYPEMIRE:
|
2007-08-23 04:28:46 +00:00
|
|
|
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
|
2007-08-20 01:20:48 +00:00
|
|
|
DeleteStructure( PtStruct );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "Unknown/unexpected Draw Type" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Efface les segments de piste, selon les autorisations affichees
|
2007-08-20 01:20:48 +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-20 01:20:48 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
EDA_BaseStruct* 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->Pnext;
|
|
|
|
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
|
|
|
|
continue;
|
|
|
|
DeleteStructure( pt_segm );
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
Compile_Ratsnest( DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( query && !IsOK( this, _( "Delete Modules?" ) ) )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( m_Pcb->m_Modules )
|
|
|
|
DeleteStructure( m_Pcb->m_Modules );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
m_Pcb->m_NbNets = 0;
|
|
|
|
m_Pcb->m_NbPads = 0;
|
|
|
|
m_Pcb->m_NbNodes = 0;
|
|
|
|
m_Pcb->m_NbLinks = 0;
|
|
|
|
m_Pcb->m_NbNoconnect = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************/
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
BOARD_ITEM* PtStruct, * PtNext;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
PtStruct = m_Pcb->m_Drawings;
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; PtStruct != NULL; PtStruct = PtNext )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
PtNext = PtStruct->Next();
|
|
|
|
if( PtStruct->Type() == TYPETEXTE )
|
2007-08-20 01:20:48 +00:00
|
|
|
DeleteStructure( PtStruct );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-30 11:15:54 +00:00
|
|
|
/*******************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Marqueurs()
|
2007-07-30 11:15:54 +00:00
|
|
|
/*******************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
BOARD_ITEM* PtStruct, * PtNext;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
PtStruct = m_Pcb->m_Drawings;
|
|
|
|
for( ; PtStruct != NULL; PtStruct = PtNext )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
PtNext = PtStruct->Next();
|
|
|
|
if( PtStruct->Type() == TYPEMARQUEUR )
|
2007-08-20 01:20:48 +00:00
|
|
|
DeleteStructure( PtStruct );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|