2007-12-29 19:15:58 +00:00
|
|
|
/*********************************************/
|
|
|
|
/******* file initpcb.cpp ********************/
|
|
|
|
/*********************************************/
|
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
|
|
|
#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;
|
2009-03-16 19:51:23 +00:00
|
|
|
bool redraw = false;
|
|
|
|
bool gen_rastnest = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxClientDC dc( m_Parent->DrawPanel );
|
|
|
|
|
|
|
|
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
2009-03-16 19:51:23 +00:00
|
|
|
m_Parent->SetCurItem( NULL );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_DelAlls->GetValue() )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
m_Parent->Clear_Pcb( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_DelZones->GetValue() )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
m_Parent->Erase_Zones( TRUE );
|
2009-03-16 19:51:23 +00:00
|
|
|
gen_rastnest = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelTexts->GetValue() )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
m_Parent->Erase_Textes_Pcb( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelEdges->GetValue() )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
m_Parent->Erase_Segments_Pcb( TRUE, TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelDrawings->GetValue() )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
m_Parent->Erase_Segments_Pcb( FALSE, TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelModules->GetValue() )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
m_Parent->Erase_Modules( TRUE );
|
2009-03-16 19:51:23 +00:00
|
|
|
gen_rastnest = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
2009-05-23 15:53:47 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
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;
|
2009-03-16 19:51:23 +00:00
|
|
|
gen_rastnest = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_DelMarkers->GetValue() )
|
|
|
|
{
|
|
|
|
m_Parent->Erase_Marqueurs();
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
2009-03-16 19:51:23 +00:00
|
|
|
|
|
|
|
if ( gen_rastnest )
|
|
|
|
m_Parent->Compile_Ratsnest( &dc, true );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( redraw )
|
|
|
|
{
|
2008-12-20 13:12:57 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
bool WinEDA_BasePcbFrame::Clear_Pcb( 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
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if( query && GetScreen()->IsModify() )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Drawings || GetBoard()->m_Modules
|
|
|
|
|| GetBoard()->m_Track || GetBoard()->m_Zone )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( !IsOK( this, _( "Current Board will be lost ?" ) ) )
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// delete the old BOARD and create a new BOARD so that the default
|
|
|
|
// layer names are put into the BOARD.
|
2009-01-05 05:21:35 +00:00
|
|
|
SetBoard( new BOARD( NULL, this ) );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
while( g_UnDeleteStackPtr > 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
g_UnDeleteStackPtr--;
|
2008-12-06 08:21:54 +00:00
|
|
|
|
|
|
|
delete g_UnDeleteStack[g_UnDeleteStackPtr];
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* init pointeurs et variables */
|
|
|
|
GetScreen()->m_FileName.Empty();
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Init parametres de gestion */
|
2009-02-07 08:33:25 +00:00
|
|
|
wxRealPoint gridsize = GetScreen()->GetGrid();
|
2008-02-12 21:12:46 +00:00
|
|
|
((PCB_SCREEN*)GetScreen())->Init();
|
2008-04-18 13:28:56 +00:00
|
|
|
GetScreen()->SetGrid( gridsize );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
g_HightLigt_Status = 0;
|
|
|
|
|
2008-01-26 02:02:27 +00:00
|
|
|
for( int ii = 1; ii < HISTORY_NUMBER; ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
g_DesignSettings.m_ViaSizeHistory[ii] =
|
2008-01-26 02:02:27 +00:00
|
|
|
g_DesignSettings.m_TrackWidthHistory[ii] = 0;
|
2009-06-19 20:13:22 +00:00
|
|
|
g_DesignSettings.m_TrackClearenceHistory[ii] = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-01-26 02:02:27 +00:00
|
|
|
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
|
2009-06-19 20:13:22 +00:00
|
|
|
g_DesignSettings.m_TrackClearenceHistory[0] = g_DesignSettings.m_TrackClearence;
|
|
|
|
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
|
2009-02-17 21:54:14 +00:00
|
|
|
|
|
|
|
/* NO, this is a global setting, and changing it here changes a loaded board's layer count when loading a module in the module editor since
|
|
|
|
the module editor calls this when loading an existing module.
|
2009-01-05 05:21:35 +00:00
|
|
|
g_DesignSettings.m_CopperLayerCount = 2; // Default copper layers count set to 2: double layer board
|
2009-02-17 21:54:14 +00:00
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
Zoom_Automatique( 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-12-03 06:54:19 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Zones( 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
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Zone.DeleteAll();
|
|
|
|
GetBoard()->DeleteZONEOutlines();
|
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-12-03 06:54:19 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Segments_Pcb( 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;
|
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
PtStruct = GetBoard()->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
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_COTATION:
|
|
|
|
case TYPE_MIRE:
|
2007-08-23 04:28:46 +00:00
|
|
|
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Delete( PtStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "Unknown/unexpected Draw Type" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-12-03 06:54:19 +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-10-03 15:21:13 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
TRACK* PtNext;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
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-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
PtNext = pt_segm->Next();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
|
|
|
|
continue;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
pt_segm->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
Compile_Ratsnest( DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Modules( 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
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Modules.DeleteAll();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2009-05-28 08:42:24 +00:00
|
|
|
m_Pcb->m_NetInfo->DeleteData();
|
|
|
|
m_Pcb->m_FullRatsnest.clear(); // empty the pad list pointers
|
|
|
|
m_Pcb->m_LocalRatsnest.clear(); // empty the pad list pointers
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_NbNodes = 0;
|
|
|
|
GetBoard()->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-12-03 06:54:19 +00:00
|
|
|
void WinEDA_PcbFrame::Erase_Textes_Pcb( 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
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
PtStruct = GetBoard()->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();
|
2008-12-04 04:28:11 +00:00
|
|
|
if( PtStruct->Type() == TYPE_TEXTE )
|
|
|
|
{
|
|
|
|
PtStruct->DeleteStructure();
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
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
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->DeleteMARKERs();
|
2007-12-03 05:14:51 +00:00
|
|
|
GetScreen()->SetModify(); // @todo : why mark this if MARKERs are not saved in the *.brd file?
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-11-27 22:49:35 +00:00
|
|
|
|