2007-08-20 01:20:48 +00:00
|
|
|
/*********************************************/
|
|
|
|
/* Edition des pistes: Routines d'effacement */
|
|
|
|
/* Effacement de segment, piste, net et zone */
|
|
|
|
/*********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Supprime 1 segment de piste.
|
2007-08-20 01:20:48 +00:00
|
|
|
* 2 Cas possibles:
|
|
|
|
* Si On est en trace de nouvelle piste: Effacement du segment en
|
|
|
|
* cours de trace
|
|
|
|
* Sinon : Effacment du segment sous le curseur.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int current_net_code;
|
|
|
|
|
|
|
|
if( Track == NULL )
|
|
|
|
return NULL;
|
2008-03-04 21:39:46 +00:00
|
|
|
|
2008-03-10 08:14:20 +00:00
|
|
|
if( Track->GetState( DELETED ) )
|
2007-11-02 18:21:43 +00:00
|
|
|
{
|
2008-03-10 08:14:20 +00:00
|
|
|
D( printf( "WinEDA_PcbFrame::Delete_Segment(): bug deleted already deleted TRACK\n" ); )
|
2007-11-02 18:21:43 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment
|
|
|
|
{
|
|
|
|
if( g_TrackSegmentCount > 0 )
|
|
|
|
{
|
2008-03-10 08:14:20 +00:00
|
|
|
int previous_layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// effacement de la piste en cours
|
|
|
|
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
|
|
|
|
|
|
|
|
// modification du trace
|
|
|
|
Track = g_CurrentTrackSegment;
|
|
|
|
g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback;
|
|
|
|
delete Track;
|
|
|
|
g_TrackSegmentCount--;
|
|
|
|
|
|
|
|
if( g_TwoSegmentTrackBuild )
|
2008-03-04 21:39:46 +00:00
|
|
|
{
|
2007-11-02 18:21:43 +00:00
|
|
|
// g_CurrentTrackSegment->Pback must not be a via, or we want delete also the via
|
2007-08-20 01:20:48 +00:00
|
|
|
if( (g_TrackSegmentCount >= 2)
|
2007-09-01 12:00:30 +00:00
|
|
|
&& (g_CurrentTrackSegment->Type() != TYPEVIA)
|
|
|
|
&& (g_CurrentTrackSegment->Pback->Type() == TYPEVIA) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Track = g_CurrentTrackSegment;
|
|
|
|
g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback;
|
|
|
|
delete Track;
|
|
|
|
g_TrackSegmentCount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while( g_TrackSegmentCount && g_CurrentTrackSegment
|
2007-09-01 12:00:30 +00:00
|
|
|
&& (g_CurrentTrackSegment->Type() == TYPEVIA) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Track = g_CurrentTrackSegment;
|
|
|
|
g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback;
|
|
|
|
delete Track;
|
|
|
|
g_TrackSegmentCount--;
|
2007-09-01 12:00:30 +00:00
|
|
|
if( g_CurrentTrackSegment && (g_CurrentTrackSegment->Type() != TYPEVIA) )
|
2007-08-23 04:28:46 +00:00
|
|
|
previous_layer = g_CurrentTrackSegment->GetLayer();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( g_CurrentTrackSegment )
|
|
|
|
g_CurrentTrackSegment->Pnext = NULL;
|
|
|
|
|
|
|
|
// Rectification couche active qui a pu changer si une via
|
|
|
|
// a ete effacee
|
2008-03-10 08:14:20 +00:00
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
Affiche_Status_Box();
|
|
|
|
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0
|
|
|
|
{
|
|
|
|
if( ( g_TrackSegmentCount == 1 )
|
2007-09-01 12:00:30 +00:00
|
|
|
&& (g_CurrentTrackSegment->Type() != TYPEVIA) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
delete g_CurrentTrackSegment;
|
|
|
|
g_TrackSegmentCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( g_TrackSegmentCount == 0 )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
if( g_HightLigt_Status )
|
|
|
|
Hight_Light( DC );
|
|
|
|
g_CurrentTrackSegment = NULL;
|
|
|
|
g_FirstTrackSegment = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
return g_CurrentTrackSegment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
} // Fin traitement si trace en cours
|
|
|
|
|
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
current_net_code = Track->GetNet();
|
2008-03-04 21:39:46 +00:00
|
|
|
|
2008-03-06 01:46:13 +00:00
|
|
|
// redraw the area where the track was
|
2008-03-10 15:00:22 +00:00
|
|
|
DrawPanel->PostDirtyRect( Track->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
SaveItemEfface( Track, 1 );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
test_1_net_connexion( DC, current_net_code );
|
2007-08-20 19:33:15 +00:00
|
|
|
m_Pcb->Display_Infos( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* Track )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Track != NULL )
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
int current_net_code = Track->GetNet();
|
2008-03-10 15:00:22 +00:00
|
|
|
Remove_One_Track( DC, Track );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
test_1_net_connexion( DC, current_net_code );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* Track )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2008-03-10 15:51:44 +00:00
|
|
|
if( Track == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( IsOK( this, _( "Delete NET ?" ) ) )
|
|
|
|
{
|
2008-03-10 15:51:44 +00:00
|
|
|
int net_code_delete = Track->GetNet();
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Recherche du debut de la zone des pistes du net_code courant */
|
2008-03-10 15:51:44 +00:00
|
|
|
TRACK* trackList = m_Pcb->m_Track->GetStartNetCode( net_code_delete );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Decompte du nombre de segments de la sous-chaine */
|
2008-03-10 15:51:44 +00:00
|
|
|
|
|
|
|
int ii;
|
|
|
|
TRACK* segm = trackList;
|
|
|
|
for( ii = 0; segm; segm = segm->Next(), ++ii )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-10 15:51:44 +00:00
|
|
|
if( segm->GetNet() != net_code_delete )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2008-03-10 15:51:44 +00:00
|
|
|
|
2008-03-11 01:19:08 +00:00
|
|
|
DrawPanel->PostDirtyRect( segm->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 15:51:44 +00:00
|
|
|
SaveItemEfface( trackList, ii );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
test_1_net_connexion( DC, net_code_delete );
|
2007-08-20 19:33:15 +00:00
|
|
|
m_Pcb->Display_Infos( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
2008-03-10 15:00:22 +00:00
|
|
|
void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de suppression de 1 piste:
|
2007-08-20 01:20:48 +00:00
|
|
|
* le segment pointe est supprime puis les segments adjacents
|
|
|
|
* jusqu'a un pad ou un point de jonction de plus de 2 segments
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-10 15:00:22 +00:00
|
|
|
TRACK* trackList;
|
|
|
|
int nb_segm;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( pt_segm == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-03-10 15:00:22 +00:00
|
|
|
trackList = Marque_Une_Piste( this, DC, pt_segm, &nb_segm, 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */
|
|
|
|
{
|
2008-03-10 15:00:22 +00:00
|
|
|
TRACK* t;
|
|
|
|
int ii;
|
|
|
|
for( t = trackList, ii=0; ii<nb_segm; ii++, t = t->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-10 15:00:22 +00:00
|
|
|
t->SetState( BUSY, OFF );
|
|
|
|
|
|
|
|
DrawPanel->PostDirtyRect( t->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 15:00:22 +00:00
|
|
|
SaveItemEfface( trackList, nb_segm );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|