pcbnew housekeeping

This commit is contained in:
dickelbeck 2007-10-15 03:26:38 +00:00
parent aece4e1622
commit 7c2c168189
4 changed files with 325 additions and 228 deletions

View File

@ -4,6 +4,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Oct-14 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew:
* housekeeping and translation to English on bottom third of pcbnew/clean.cpp
* my todo: figure out how to intercept double clicks on a wxWidgets text control
so I can complete the work I started on MARQUEUR error tracking.
2007-Oct-13 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-Oct-13 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+ pcbnew: + pcbnew:

View File

@ -29,7 +29,7 @@ public:
int m_Shape; // vias: shape and type, Track = shape.. int m_Shape; // vias: shape and type, Track = shape..
int m_Drill; // for vias: via drill (- 1 for default value) int m_Drill; // for vias: via drill (- 1 for default value)
BOARD_ITEM* start; // pointers on a connected item (pad or track) BOARD_ITEM* start; // pointers to a connected item (pad or track)
BOARD_ITEM* end; BOARD_ITEM* end;
// chain = 0 indique une connexion non encore traitee // chain = 0 indique une connexion non encore traitee

View File

@ -57,7 +57,8 @@ void WinEDA_PcbFrame::Clean_Pcb( wxDC* DC )
{ {
s_ConnectToPads = false; s_ConnectToPads = false;
WinEDA_CleaningOptionsFrame* frame = new WinEDA_CleaningOptionsFrame( this, DC ); WinEDA_CleaningOptionsFrame* frame = new WinEDA_CleaningOptionsFrame( this, DC );
frame->ShowModal(); frame->Destroy(); frame->ShowModal();
frame->Destroy();
DrawPanel->Refresh( true ); DrawPanel->Refresh( true );
} }
@ -68,18 +69,21 @@ void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC )
{ {
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
frame->m_Pcb->GetNumSegmTrack(); /* Met a jour le compte */ frame->m_Pcb->GetNumSegmTrack(); /* Met a jour le compte */
/* construction de la liste des coordonn<6E>s des pastilles */ /* construction de la liste des coordonn<6E>s des pastilles */
frame->m_Pcb->m_Status_Pcb = 0; frame->m_Pcb->m_Status_Pcb = 0;
frame->build_liste_pads(); frame->build_liste_pads();
frame->recalcule_pad_net_code(); frame->recalcule_pad_net_code();
if( s_CleanVias ) /* delete redundant vias */ if( s_CleanVias ) /* delete redundant vias */
{ {
TRACK* track, * next_track; TRACK* track;
TRACK* next_track;
for( track = frame->m_Pcb->m_Track; track != NULL; track = track->Next() ) for( track = frame->m_Pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->m_Shape != VIA_NORMALE ) if( track->m_Shape != VIA_NORMALE )
continue; continue;
/* Search and delete others vias at same location */ /* Search and delete others vias at same location */
TRACK* alt_track = track->Next(); TRACK* alt_track = track->Next();
for( ; alt_track != NULL; alt_track = next_track ) for( ; alt_track != NULL; alt_track = next_track )
@ -87,8 +91,10 @@ void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC )
next_track = alt_track->Next(); next_track = alt_track->Next();
if( alt_track->m_Shape != VIA_NORMALE ) if( alt_track->m_Shape != VIA_NORMALE )
continue; continue;
if( alt_track->m_Start != track->m_Start ) if( alt_track->m_Start != track->m_Start )
continue; continue;
/* delete via */ /* delete via */
alt_track->UnLink(); alt_track->UnLink();
delete alt_track; delete alt_track;
@ -119,8 +125,8 @@ void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC )
ConnectDanglingEndToPad( frame, DC ); ConnectDanglingEndToPad( frame, DC );
/* Creation de points de raccordements aux intersections de pistes */ /* Creation de points de raccordements aux intersections de pistes */
// Gen_Raccord_Track(frame, DC); // Gen_Raccord_Track(frame, DC);
} }
#endif #endif
@ -150,7 +156,7 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
* et le segment seront supprimes * et le segment seront supprimes
*/ */
{ {
TRACK* PtSegm, * pt_other, * pt_via; TRACK* segment, * pt_other, * pt_via;
TRACK* PtStartNetCode; TRACK* PtStartNetCode;
EDA_BaseStruct* NextS; EDA_BaseStruct* NextS;
D_PAD* ptr_pad; D_PAD* ptr_pad;
@ -165,17 +171,18 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
/* Correction des defauts des vias et recalcul du nombre de segm */ /* Correction des defauts des vias et recalcul du nombre de segm */
frame->m_Pcb->m_NbSegmTrack = 0; ii = 0; frame->m_Pcb->m_NbSegmTrack = 0; ii = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS ) for( segment = frame->m_Pcb->m_Track; segment != NULL; segment = (TRACK*) NextS )
{ {
frame->m_Pcb->m_NbSegmTrack++; frame->m_Pcb->m_NbSegmTrack++;
NextS = PtSegm->Pnext; NextS = segment->Pnext;
if( PtSegm->Type() == TYPEVIA )
if( segment->Type() == TYPEVIA )
{ {
if( (PtSegm->m_Start.x != PtSegm->m_End.x ) if( (segment->m_Start.x != segment->m_End.x )
|| (PtSegm->m_Start.y != PtSegm->m_End.y ) ) || (segment->m_Start.y != segment->m_End.y ) )
{ {
PtSegm->m_End.x = PtSegm->m_Start.x; segment->m_End.x = segment->m_Start.x;
PtSegm->m_End.y = PtSegm->m_Start.y; segment->m_End.y = segment->m_Start.y;
ii++; ii++;
msg.Printf( wxT( "%d " ), ii ); msg.Printf( wxT( "%d " ), ii );
Affiche_1_Parametre( frame, POS_AFF_PASSE, _( "ViaDef" ), msg, LIGHTRED ); Affiche_1_Parametre( frame, POS_AFF_PASSE, _( "ViaDef" ), msg, LIGHTRED );
@ -185,12 +192,16 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
} }
/* Suppression des pistes en l'air */ /* Suppression des pistes en l'air */
PtSegm = frame->m_Pcb->m_Track; ii = 0; segment = frame->m_Pcb->m_Track;
percent = 0; oldpercent = -1; percent = 0;
oldnetcode = 0; PtStartNetCode = frame->m_Pcb->m_Track; oldpercent = -1;
for( ; PtSegm != NULL; PtSegm = (TRACK*) NextS, ii++ ) oldnetcode = 0;
PtStartNetCode = frame->m_Pcb->m_Track;
for( ii = 0; segment != NULL; segment = (TRACK*) NextS, ii++ )
{ {
NextS = PtSegm->Pnext; NextS = segment->Pnext;
/* Affiche activite */ /* Affiche activite */
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
if( percent != oldpercent ) if( percent != oldpercent )
@ -207,36 +218,36 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
if( frame->DrawPanel->m_AbortRequest ) if( frame->DrawPanel->m_AbortRequest )
break; break;
if( PtSegm->GetNet() != oldnetcode ) if( segment->GetNet() != oldnetcode )
{ {
PtStartNetCode = PtSegm; oldnetcode = PtSegm->GetNet(); PtStartNetCode = segment; oldnetcode = segment->GetNet();
} }
flag_erase = 0; type_end = 0; flag_erase = 0; type_end = 0;
/* y a t-il une pastille sur chaque extremite */ /* y a t-il une pastille sur chaque extremite */
masklayer = PtSegm->ReturnMaskLayer(); masklayer = segment->ReturnMaskLayer();
ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, PtSegm->m_Start, masklayer ); ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, segment->m_Start, masklayer );
if( ptr_pad != NULL ) if( ptr_pad != NULL )
{ {
PtSegm->start = ptr_pad; segment->start = ptr_pad;
type_end |= START_SUR_PAD; type_end |= START_SUR_PAD;
} }
ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, PtSegm->m_End, masklayer ); ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, segment->m_End, masklayer );
if( ptr_pad != NULL ) if( ptr_pad != NULL )
{ {
PtSegm->end = ptr_pad; segment->end = ptr_pad;
type_end |= END_SUR_PAD; type_end |= END_SUR_PAD;
} }
/* Test si une extremite est connectee sur une piste */ /* Test si une extremite est connectee sur une piste */
if( (type_end & START_SUR_PAD ) == 0 ) if( (type_end & START_SUR_PAD ) == 0 )
{ {
pt_other = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, START ); NULL, START );
if( pt_other == NULL ) if( pt_other == NULL )
@ -244,39 +255,39 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
else /* Segment ou via connectee a cette extremite */ else /* Segment ou via connectee a cette extremite */
{ {
PtSegm->start = pt_other; segment->start = pt_other;
if( pt_other->Type() == TYPEVIA ) /* recherche d'un autre segment */ if( pt_other->Type() == TYPEVIA ) /* recherche d'un autre segment */
{ {
PtSegm->SetState( BUSY, ON ); segment->SetState( BUSY, ON );
pt_via = pt_other; pt_via = pt_other;
pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track,
NULL, START ); NULL, START );
if( pt_other == NULL ) if( pt_other == NULL )
flag_erase |= 2; flag_erase |= 2;
PtSegm->SetState( BUSY, OFF ); segment->SetState( BUSY, OFF );
} }
} }
} }
if( (type_end & END_SUR_PAD ) == 0 ) if( (type_end & END_SUR_PAD ) == 0 )
{ {
pt_other = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, END ); NULL, END );
if( pt_other == NULL ) if( pt_other == NULL )
flag_erase |= 0x10; flag_erase |= 0x10;
else /* Segment ou via connectee a cette extremite */ else /* Segment ou via connectee a cette extremite */
{ {
PtSegm->end = pt_other; segment->end = pt_other;
if( pt_other->Type() == TYPEVIA ) /* recherche d'un autre segment */ if( pt_other->Type() == TYPEVIA ) /* recherche d'un autre segment */
{ {
PtSegm->SetState( BUSY, ON ); segment->SetState( BUSY, ON );
pt_via = pt_other; pt_via = pt_other;
pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track,
NULL, END ); NULL, END );
if( pt_other == NULL ) if( pt_other == NULL )
flag_erase |= 0x20; flag_erase |= 0x20;
PtSegm->SetState( BUSY, OFF ); segment->SetState( BUSY, OFF );
} }
} }
} }
@ -284,23 +295,27 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
if( flag_erase ) if( flag_erase )
{ {
oldpercent = -1; /* force affichage activite */ oldpercent = -1; /* force affichage activite */
nbpoints_supprimes++; ii--;
nbpoints_supprimes++;
ii--;
msg.Printf( wxT( "%d " ), nbpoints_supprimes ); msg.Printf( wxT( "%d " ), nbpoints_supprimes );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NoConn." ), msg, LIGHTRED ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NoConn." ), msg, LIGHTRED );
/* rectification du pointeur PtSegm pour repartir en debut /* rectification du pointeur segment pour repartir en debut
* du block des segments de meme net_code */ * du block des segments de meme net_code */
if( PtSegm == PtStartNetCode ) if( segment == PtStartNetCode )
{ {
NextS = PtSegm->Pnext; NextS = segment->Pnext;
PtStartNetCode = (TRACK*) NextS; PtStartNetCode = (TRACK*) NextS;
} }
else else
NextS = PtStartNetCode; NextS = PtStartNetCode;
/* Suppression du segment */ /* Suppression du segment */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR ); segment->Draw( frame->DrawPanel, DC, GR_XOR );
PtSegm->DeleteStructure();
segment->DeleteStructure();
if( NextS == NULL ) if( NextS == NULL )
break; break;
} }
@ -313,7 +328,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/************************************************************/ /************************************************************/
/* Supprime segments nulls, points inutiles .. */ /* Supprime segments nulls, points inutiles .. */
{ {
TRACK* PtSegm, * pt_aux; TRACK* segment, * pt_aux;
EDA_BaseStruct* NextS; EDA_BaseStruct* NextS;
int ii, nbpoints_supprimes = 0; int ii, nbpoints_supprimes = 0;
int flag, no_inc, percent, oldpercent; int flag, no_inc, percent, oldpercent;
@ -326,21 +341,24 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/**********************************************/ /**********************************************/
a_color = GREEN; a_color = GREEN;
nbpoints_supprimes = 0; PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0;
percent = 0; oldpercent = -1; percent = 0;
oldpercent = -1;
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
frame->Affiche_Message( _( "Clean Null Segments" ) ); frame->Affiche_Message( _( "Clean Null Segments" ) );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NullSeg" ), wxT( "0" ), a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NullSeg" ), wxT( "0" ), a_color );
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
segment = frame->m_Pcb->m_Track;
for( segment = frame->m_Pcb->m_Track; segment != NULL; segment = (TRACK*) NextS )
{ {
NextS = PtSegm->Pnext; NextS = segment->Pnext;
if( !PtSegm->IsNull() ) if( !segment->IsNull() )
continue; continue;
/* Lenght segment = 0; delete it */ /* Lenght segment = 0; delete it */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR ); segment->Draw( frame->DrawPanel, DC, GR_XOR );
PtSegm->DeleteStructure(); segment->DeleteStructure();
nbpoints_supprimes++; nbpoints_supprimes++;
msg.Printf( wxT( " %d" ), nbpoints_supprimes ); msg.Printf( wxT( " %d" ), nbpoints_supprimes );
@ -352,9 +370,12 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/**************************************/ /**************************************/
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "Ident" ), wxT( "0" ), a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "Ident" ), wxT( "0" ), a_color );
percent = 0; oldpercent = -1;
PtSegm = frame->m_Pcb->m_Track; percent = 0;
for( ii = 0; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext, ii++ ) oldpercent = -1;
segment = frame->m_Pcb->m_Track;
for( ii = 0; segment != NULL; segment = (TRACK*) segment->Pnext, ii++ )
{ {
/* affichage activite */ /* affichage activite */
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
@ -365,6 +386,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN ); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
@ -372,28 +394,29 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
return -1; return -1;
} }
for( pt_aux = (TRACK*) PtSegm->Pnext; pt_aux != NULL; pt_aux = (TRACK*) NextS ) for( pt_aux = (TRACK*) segment->Pnext; pt_aux != NULL; pt_aux = (TRACK*) NextS )
{ {
int erase = 0; int erase = 0;
NextS = pt_aux->Pnext; NextS = pt_aux->Pnext;
if( PtSegm->Type() != pt_aux->Type() ) if( segment->Type() != pt_aux->Type() )
continue; continue;
if( PtSegm->GetLayer() != pt_aux->GetLayer() )
if( segment->GetLayer() != pt_aux->GetLayer() )
continue; continue;
if( PtSegm->GetNet() != pt_aux->GetNet() )
if( segment->GetNet() != pt_aux->GetNet() )
break; break;
if( (PtSegm->m_Start.x == pt_aux->m_Start.x ) if( segment->m_Start == pt_aux->m_Start )
&& (PtSegm->m_Start.y == pt_aux->m_Start.y) )
{ {
if( (PtSegm->m_End.x == pt_aux->m_End.x ) && (PtSegm->m_End.y==pt_aux->m_End.y) ) if( segment->m_End == pt_aux->m_End )
erase = 1; erase = 1;
} }
if( (PtSegm->m_Start.x==pt_aux->m_End.x ) && (PtSegm->m_Start.y == pt_aux->m_End.y) ) if( segment->m_Start == pt_aux->m_End )
{ {
if( (PtSegm->m_End.x==pt_aux->m_Start.x ) && (PtSegm->m_End.y==pt_aux->m_Start.y) ) if( segment->m_End == pt_aux->m_Start )
erase = 1; erase = 1;
} }
@ -415,18 +438,20 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/* suppression des points intermediaires ( segments alignes ) */ /* suppression des points intermediaires ( segments alignes ) */
/**************************************************************/ /**************************************************************/
PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0; nbpoints_supprimes = 0;
percent = 0; oldpercent = -1; percent = 0;
oldpercent = -1;
frame->Affiche_Message( _( "Merging Segments:" ) ); frame->Affiche_Message( _( "Merging Segments:" ) );
Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Merge" ), _( "0" ), a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Merge" ), _( "0" ), a_color );
ii = 0; ii = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm!= NULL; PtSegm = (TRACK*) NextS ) segment = frame->m_Pcb->m_Track;
for( segment = frame->m_Pcb->m_Track; segment!= NULL; segment = (TRACK*) NextS )
{ {
TRACK* pt_segm_s, * pt_segm_e, * pt_segm_delete; TRACK* pt_segm_s, * pt_segm_e, * pt_segm_delete;
NextS = PtSegm->Pnext; NextS = segment->Pnext;
/* affichage activite */ /* affichage activite */
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
@ -434,8 +459,10 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
{ {
frame->DisplayActivity( percent, _( "Merge: " ) ); frame->DisplayActivity( percent, _( "Merge: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN ); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
@ -443,20 +470,20 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
return -1; return -1;
} }
if( PtSegm->Type() != TYPETRACK ) if( segment->Type() != TYPETRACK )
continue; continue;
flag = no_inc = 0; flag = no_inc = 0;
/* Recherche d'un point possible raccorde sur DEBUT de segment: */ /* Recherche d'un point possible raccorde sur DEBUT de segment: */
for( pt_segm_s = (TRACK*) PtSegm->Pnext; ; ) for( pt_segm_s = (TRACK*) segment->Pnext; ; )
{ {
pt_segm_s = Locate_Piste_Connectee( PtSegm, pt_segm_s, pt_segm_s = Locate_Piste_Connectee( segment, pt_segm_s,
NULL, START ); NULL, START );
if( pt_segm_s ) if( pt_segm_s )
{ {
/* les 2 segments doivent avoir meme largeur */ /* les 2 segments doivent avoir meme largeur */
if( PtSegm->m_Width != pt_segm_s->m_Width ) if( segment->m_Width != pt_segm_s->m_Width )
break; break;
/* Ce ne peut etre une via */ /* Ce ne peut etre une via */
@ -465,7 +492,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/* On ne peut avoir que 1 seul segment connecte */ /* On ne peut avoir que 1 seul segment connecte */
pt_segm_s->SetState( BUSY, ON ); pt_segm_s->SetState( BUSY, ON );
pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, pt_aux = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, START ); NULL, START );
pt_segm_s->SetState( BUSY, OFF ); pt_segm_s->SetState( BUSY, OFF );
@ -478,7 +505,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
if( flag ) /* debut de segment raccorde a un autre segment */ if( flag ) /* debut de segment raccorde a un autre segment */
{ {
pt_segm_delete = AlignSegment( frame->m_Pcb, PtSegm, pt_segm_s, START ); pt_segm_delete = AlignSegment( frame->m_Pcb, segment, pt_segm_s, START );
if( pt_segm_delete ) if( pt_segm_delete )
{ {
nbpoints_supprimes++; no_inc = 1; nbpoints_supprimes++; no_inc = 1;
@ -487,22 +514,23 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
} }
/* Recherche d'un point possible raccorde sur FIN de segment: */ /* Recherche d'un point possible raccorde sur FIN de segment: */
for( pt_segm_e = (TRACK*) PtSegm->Pnext; ; ) for( pt_segm_e = (TRACK*) segment->Pnext; ; )
{ {
pt_segm_e = Locate_Piste_Connectee( PtSegm, pt_segm_e, pt_segm_e = Locate_Piste_Connectee( segment, pt_segm_e,
NULL, END ); NULL, END );
if( pt_segm_e ) if( pt_segm_e )
{ {
/* les 2 segments doivent avoir meme largeur */ /* les 2 segments doivent avoir meme largeur */
if( PtSegm->m_Width != pt_segm_e->m_Width ) if( segment->m_Width != pt_segm_e->m_Width )
break; break;
/* Ce ne peut etre une via */ /* Ce ne peut etre une via */
if( pt_segm_e->Type() != TYPETRACK ) if( pt_segm_e->Type() != TYPETRACK )
break; break;
/* On ne peut avoir que 1 seul segment connecte */ /* On ne peut avoir que 1 seul segment connecte */
pt_segm_e->SetState( BUSY, ON ); pt_segm_e->SetState( BUSY, ON );
pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, pt_aux = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, END ); NULL, END );
pt_segm_e->SetState( BUSY, OFF ); pt_segm_e->SetState( BUSY, OFF );
if( pt_aux == NULL ) if( pt_aux == NULL )
@ -515,7 +543,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
if( flag & 2 ) /* FIN de segment raccorde a un autre segment */ if( flag & 2 ) /* FIN de segment raccorde a un autre segment */
{ {
pt_segm_delete = AlignSegment( frame->m_Pcb, PtSegm, pt_segm_e, END ); pt_segm_delete = AlignSegment( frame->m_Pcb, segment, pt_segm_e, END );
if( pt_segm_delete ) if( pt_segm_delete )
{ {
nbpoints_supprimes++; no_inc = 1; nbpoints_supprimes++; no_inc = 1;
@ -527,7 +555,8 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
{ {
msg.Printf( wxT( "%d " ), nbpoints_supprimes ); msg.Printf( wxT( "%d " ), nbpoints_supprimes );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
NextS = PtSegm->Pnext;
NextS = segment->Pnext;
} }
} }
@ -551,8 +580,11 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
int refdx, refdy, segmdx, segmdy;/* projections des segments */ int refdx, refdy, segmdx, segmdy;/* projections des segments */
int flag = 0; int flag = 0;
refdx = pt_ref->m_End.x - pt_ref->m_Start.x; refdy = pt_ref->m_End.y - pt_ref->m_Start.y; refdx = pt_ref->m_End.x - pt_ref->m_Start.x;
segmdx = pt_segm->m_End.x - pt_segm->m_Start.x; segmdy = pt_segm->m_End.y - pt_segm->m_Start.y; refdy = pt_ref->m_End.y - pt_ref->m_Start.y;
segmdx = pt_segm->m_End.x - pt_segm->m_Start.x;
segmdy = pt_segm->m_End.y - pt_segm->m_Start.y;
/* Tst alignement vertical possible: */ /* Tst alignement vertical possible: */
if( refdx == 0 ) if( refdx == 0 )
@ -576,7 +608,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
if( flag == 0 ) if( flag == 0 )
{ {
if( (refdy * segmdx != refdx * segmdy) if( (refdy * segmdx != refdx * segmdy)
&& (refdy * segmdx != -refdx * segmdy) ) && (refdy * segmdx != -refdx * segmdy) )
return NULL; return NULL;
flag = 4; flag = 4;
} }
@ -591,7 +623,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
return NULL; return NULL;
if( (pt_ref->m_Start.x == pt_segm->m_Start.x) if( (pt_ref->m_Start.x == pt_segm->m_Start.x)
&& (pt_ref->m_Start.y == pt_segm->m_Start.y) ) && (pt_ref->m_Start.y == pt_segm->m_Start.y) )
{ {
pt_ref->m_Start.x = pt_segm->m_End.x; pt_ref->m_Start.y = pt_segm->m_End.y; pt_ref->m_Start.x = pt_segm->m_End.x; pt_ref->m_Start.y = pt_segm->m_End.y;
return pt_segm; return pt_segm;
@ -627,23 +659,24 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche ) int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
/***************************************************************************/ /***************************************************************************/
/* /**
* verification des connexions. * Function Netliste_Controle_piste
* Supprime les segments mal connectes, c.a.d. interconnectant des segments * finds all track segments which are mis-connected (to more than one net).
* de net_code differents * When such a bad segment is found, mark it as needing to be removed (supression).
*/ */
{ {
TRACK* PtSegm, * pt_aux; TRACK* segment;
EDA_BaseStruct* NextS; TRACK* other;
TRACK* next;
int net_code_s, net_code_e; int net_code_s, net_code_e;
int nbpoints_modifies = 0; int nbpoints_modifies = 0;
int flag = 0; int flag = 0;
int ii, percent, oldpercent;
wxString msg; wxString msg;
int percent = 0;
int oldpercent = -1;
a_color = RED; a_color = RED;
percent = 0; oldpercent = -1;
frame->Affiche_Message( _( "DRC Control:" ) ); frame->Affiche_Message( _( "DRC Control:" ) );
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
@ -651,18 +684,20 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
if( affiche ) if( affiche )
Affiche_1_Parametre( frame, POS_AFF_VAR, _( "NetCtr" ), wxT( "0 " ), a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, _( "NetCtr" ), wxT( "0 " ), a_color );
ii = 0; int ii = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext ) for( segment = frame->m_Pcb->m_Track; segment; segment = (TRACK*) segment->Next() )
{ {
/* affichage activite */ // display activity
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, wxT( "Drc: " ) ); frame->DisplayActivity( percent, wxT( "Drc: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN ); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
@ -670,60 +705,66 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
return flag; return flag;
} }
PtSegm->SetState( FLAG0, OFF ); segment->SetState( FLAG0, OFF );
/* Calcul du net_code des elements raccordes sur le point de debut */ // find the netcode for segment using anything connected to the "start" of "segment"
net_code_s = -1; net_code_s = -1;
if( (PtSegm->start != NULL) if( segment->start && segment->start->Type()==TYPEPAD )
&& ( ( (EDA_BaseStruct*) (PtSegm->start) )->Type() == TYPEPAD ) )
net_code_s = ( (D_PAD*) (PtSegm->start) )->GetNet();
else
{ {
pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, // get the netcode of the pad to propagate.
NULL, START ); net_code_s = ((D_PAD*)(segment->start))->GetNet();
if( pt_aux )
net_code_s = pt_aux->GetNet();
} }
if( net_code_s < 0 )
continue;/* Extremite en l'air */
/* Calcul du net_code des elements raccordes sur le point de fin */
net_code_e = -1;
if( (PtSegm->end != NULL)
&& ( ( (EDA_BaseStruct*) (PtSegm->end) )->Type() == TYPEPAD ) )
net_code_e = ( (D_PAD*) (PtSegm->end) )->GetNet();
else else
{ {
pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, START );
if( other )
net_code_s = other->GetNet();
}
if( net_code_s < 0 )
continue; // the "start" of segment is not connected
// find the netcode for segment using anything connected to the "end" of "segment"
net_code_e = -1;
if( segment->end && segment->end->Type()==TYPEPAD )
{
net_code_e = ((D_PAD*)(segment->end))->GetNet();
}
else
{
other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, END ); NULL, END );
if( pt_aux ) if( other )
net_code_e = pt_aux->GetNet(); net_code_e = other->GetNet();
} }
if( net_code_e < 0 ) if( net_code_e < 0 )
continue;/* Extremite en l'air */ continue; // the "end" of segment is not connected
/* Marquage des segments a supprimer */ // the obtained netcodes do not agree, mark the segment as needing to be removed
if( net_code_s != net_code_e ) if( net_code_s != net_code_e )
{ {
PtSegm->SetState( FLAG0, ON ); segment->SetState( FLAG0, ON );
} }
} }
/* Suppression effective des segments */ // suppression of segments
for( segment = frame->m_Pcb->m_Track; segment; segment = next )
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
{ {
NextS = PtSegm->Pnext; next = (TRACK*) segment->Next();
if( PtSegm->GetState( FLAG0 ) ) /* Connexion erronee : a supprimer */
if( segment->GetState( FLAG0 ) ) //* if segment is marked as needing to be removed
{ {
PtSegm->SetState( FLAG0, OFF ); segment->SetState( FLAG0, OFF );
flag = 1; oldpercent = -1;
flag = 1;
oldpercent = -1;
frame->m_Pcb->m_Status_Pcb = 0; frame->m_Pcb->m_Status_Pcb = 0;
frame->Supprime_Une_Piste( DC, PtSegm );
NextS = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */ frame->Supprime_Une_Piste( DC, segment );
next = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */
if( affiche ) if( affiche )
{ {
nbpoints_modifies++; nbpoints_modifies++;
@ -743,6 +784,14 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC ) static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
/***************************************************************/ /***************************************************************/
/**
* Function Gen_Raccord_Track
* tests the ends of segments. If and end is on a segment of other track, but not
* on other's end, the other segment is cut into 2, the point of cut being the end of
* segment first being operated on. This is done so that the subsequent tests
* of connection, which do not test segment overlaps, will see this continuity.
*/
/* Teste les extremites de segments : /* Teste les extremites de segments :
* si une extremite est sur un segment de piste, mais pas sur une extremite, * si une extremite est sur un segment de piste, mais pas sur une extremite,
* le segment est coupe en 2, le point de coupure etant l'extremite du segment * le segment est coupe en 2, le point de coupure etant l'extremite du segment
@ -750,8 +799,9 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
* de segments voient la connexion * de segments voient la connexion
*/ */
{ {
TRACK* PtSegm, * pt_aux, * NewTrack; TRACK* segment;
EDA_BaseStruct* NextS; TRACK* other;
TRACK* next;
int nn = 0; int nn = 0;
int masquelayer; int masquelayer;
int ii, percent, oldpercent; int ii, percent, oldpercent;
@ -764,18 +814,21 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
oldpercent = -1; ii = 0; oldpercent = -1; ii = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS ) for( segment = frame->m_Pcb->m_Track; segment; segment = next )
{ {
NextS = PtSegm->Pnext; next = (TRACK*) segment->Next();
/* affichage activite */
// display activity
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, wxT( "Tracks: " ) ); frame->DisplayActivity( percent, wxT( "Tracks: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN ); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
} }
@ -783,78 +836,103 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
if( frame->DrawPanel->m_AbortRequest ) if( frame->DrawPanel->m_AbortRequest )
return; return;
masquelayer = PtSegm->ReturnMaskLayer(); masquelayer = segment->ReturnMaskLayer();
/* examen du point de depart du segment de reference */ // look at the "start" of the "segment"
for( pt_aux = frame->m_Pcb->m_Track; ; pt_aux = (TRACK*) pt_aux->Pnext ) for( other = frame->m_Pcb->m_Track; other; other = (TRACK*) other->Next() )
{ {
if( pt_aux == NULL ) TRACK* newTrack;
other = Locate_Pistes( other, segment->m_Start, masquelayer );
if( other == NULL )
break; break;
pt_aux = Locate_Pistes( pt_aux, PtSegm->m_Start, masquelayer );
if( pt_aux == NULL ) if( other == segment )
break;
if( pt_aux == PtSegm )
continue; continue;
if( pt_aux->Type() == TYPEVIA )
if( other->Type() == TYPEVIA )
continue; continue;
if( PtSegm->m_Start == pt_aux->m_Start )
if( segment->m_Start == other->m_Start )
continue; continue;
if( PtSegm->m_Start == pt_aux->m_End )
if( segment->m_Start == other->m_End )
continue; continue;
// Test si autre extremite du segment ne serait pas deja connectee // Test if the "end" of this segment is already connected to other
if( PtSegm->m_End == pt_aux->m_Start ) if( segment->m_End == other->m_Start )
continue; continue;
if( PtSegm->m_End == pt_aux->m_End )
if( segment->m_End == other->m_End )
continue; continue;
pt_aux->Draw( frame->DrawPanel, DC, GR_XOR ); other->Draw( frame->DrawPanel, DC, GR_XOR );
NewTrack = pt_aux->Copy();
NewTrack->Insert( frame->m_Pcb, pt_aux );
nn++; nn++;
frame->m_Pcb->m_NbSegmTrack++;
msg.Printf( wxT( "%d" ), nn ); msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New <" ), msg, YELLOW ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New <" ), msg, YELLOW );
pt_aux->m_End = PtSegm->m_Start;
NewTrack->m_Start = PtSegm->m_Start;
Trace_Une_Piste( frame->DrawPanel, DC, pt_aux, 2, GR_OR );
pt_aux = NewTrack;
}
/* examen du point de fin du segment de reference */
for( pt_aux = frame->m_Pcb->m_Track; pt_aux != NULL; pt_aux = (TRACK*) pt_aux->Pnext )
{
pt_aux = Locate_Pistes( pt_aux, PtSegm->m_End, masquelayer );
if( pt_aux == NULL )
break;
if( pt_aux == PtSegm )
continue;
if( pt_aux->Type() == TYPEVIA )
continue;
if( (PtSegm->m_End.x == pt_aux->m_Start.x) && (PtSegm->m_End.y == pt_aux->m_Start.y) )
continue;
if( (PtSegm->m_End.x == pt_aux->m_End.x) && (PtSegm->m_End.y == pt_aux->m_End.y) )
continue;
if( (PtSegm->m_Start.x == pt_aux->m_Start.x)
&& (PtSegm->m_Start.y == pt_aux->m_Start.y) )
continue;
if( (PtSegm->m_Start.x == pt_aux->m_End.x) && (PtSegm->m_Start.y == pt_aux->m_End.y) )
continue;
pt_aux->Draw( frame->DrawPanel, DC, GR_XOR );
NewTrack = pt_aux->Copy();
NewTrack->Insert( frame->m_Pcb, pt_aux );
frame->m_Pcb->m_NbSegmTrack++; frame->m_Pcb->m_NbSegmTrack++;
nn++; msg.Printf( wxT( "%d" ), nn );
// create a new segment and insert it next to "other", then shorten other.
newTrack = other->Copy();
newTrack->Insert( frame->m_Pcb, other );
other->m_End = segment->m_Start;
newTrack->m_Start = segment->m_Start;
Trace_Une_Piste( frame->DrawPanel, DC, other, 2, GR_OR );
// skip forward one, skipping the newTrack
other = newTrack;
}
// look at the "end" of the "segment"
for( other = frame->m_Pcb->m_Track; other; other = (TRACK*) other->Next() )
{
TRACK* newTrack;
other = Locate_Pistes( other, segment->m_End, masquelayer );
if( other == NULL )
break;
if( other == segment )
continue;
if( other->Type() == TYPEVIA )
continue;
if( segment->m_End == other->m_Start )
continue;
if( segment->m_End == other->m_End )
continue;
if( segment->m_Start == other->m_Start )
continue;
if( segment->m_Start == other->m_End )
continue;
other->Draw( frame->DrawPanel, DC, GR_XOR );
nn++;
msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New >" ), msg, YELLOW ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New >" ), msg, YELLOW );
pt_aux->m_End.x = PtSegm->m_End.x; pt_aux->m_End.y = PtSegm->m_End.y;
NewTrack->m_Start.x = PtSegm->m_End.x; NewTrack->m_Start.y = PtSegm->m_End.y; frame->m_Pcb->m_NbSegmTrack++;
Trace_Une_Piste( frame->DrawPanel, DC, pt_aux, 2, GR_OR );
pt_aux = NewTrack; // create a new segment and insert it next to "other", then shorten other.
newTrack = other->Copy();
newTrack->Insert( frame->m_Pcb, other );
other->m_End = segment->m_End;
newTrack->m_Start = segment->m_End;
Trace_Une_Piste( frame->DrawPanel, DC, other, 2, GR_OR );
// skip forward one, skipping the newTrack
other = newTrack;
} }
} }
} }
@ -864,40 +942,43 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC ) void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC )
/**************************************************************/ /**************************************************************/
/* /**
* rajoute eventuellement un segment a une extremite de piste connectee * Function ConnectDanglingEndToPad
* a un pad si cette extremite n'est pas exactement connectee au centre * possibly adds a segment to the end of any and all tracks if their end is not exactly
* du pad. * connected into the center of the pad. This allows faster control of
* Ceci permet un controle plus rapide des connexions * connections.
*/ */
{ {
TRACK* PtSegm; TRACK* segment;
EDA_BaseStruct* NextS; TRACK* next;
D_PAD* ptr_pad; int nb_new_piste = 0;
int nb_new_piste = 0, ii;
int percent, oldpercent;
wxString msg; wxString msg;
int percent = 0;
int oldpercent = -1;
a_color = GREEN; a_color = GREEN;
percent = 0; oldpercent = -1;
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Centre" ), _( "0 " ), a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Centre" ), _( "0 " ), a_color );
ii = 0; int ii = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS ) for( segment = frame->m_Pcb->m_Track; segment; segment = next )
{ {
NextS = PtSegm->Pnext; D_PAD* pad;
/* affichage activite */
next = (TRACK*) segment->Next();
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, _( "Pads: " ) ); frame->DisplayActivity( percent, _( "Pads: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_MAX, _( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, _( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, _( "Segm" ), msg, CYAN ); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, _( "Segm" ), msg, CYAN );
@ -905,42 +986,48 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC )
return; return;
} }
ptr_pad = Locate_Pad_Connecte( frame->m_Pcb, PtSegm, START ); pad = Locate_Pad_Connecte( frame->m_Pcb, segment, START );
if( ptr_pad != NULL ) if( pad )
{ /* Test si point piste non deja connecte a un autre segment */ {
if( PtSegm->m_Start != ptr_pad->m_Pos ) // test if the track is not precisely starting on the found pad
if( segment->m_Start != pad->m_Pos )
{ {
if( Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, if( Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, START ) == NULL ) NULL, START ) == NULL )
{ {
TRACK* NewTrack = PtSegm->Copy(); TRACK* newTrack = segment->Copy();
NewTrack->Insert( frame->m_Pcb, PtSegm ); newTrack->Insert( frame->m_Pcb, segment );
NewTrack->m_End = ptr_pad->m_Pos;
NewTrack->start = PtSegm; newTrack->m_End = pad->m_Pos;
NewTrack->end = ptr_pad;
newTrack->start = segment;
newTrack->end = pad;
nb_new_piste++; nb_new_piste++;
NewTrack->Draw( frame->DrawPanel, DC, GR_OR );
newTrack->Draw( frame->DrawPanel, DC, GR_OR );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
} }
} }
} }
ptr_pad = Locate_Pad_Connecte( frame->m_Pcb, PtSegm, END ); pad = Locate_Pad_Connecte( frame->m_Pcb, segment, END );
if( ptr_pad != NULL ) if( pad )
{ /* Test si point piste "en l'air" */ {
if( (PtSegm->m_End.x != ptr_pad->m_Pos.x) // test if the track is not precisely ending on the found pad
|| (PtSegm->m_End.y != ptr_pad->m_Pos.y) ) if( segment->m_End != pad->m_Pos )
{ {
if( Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track, if( Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
NULL, END ) == NULL ) NULL, END ) == NULL )
{ {
TRACK* NewTrack = PtSegm->Copy(); TRACK* newTrack = segment->Copy();
NewTrack->Insert( frame->m_Pcb, PtSegm ); newTrack->Insert( frame->m_Pcb, segment );
NewTrack->m_Start.x = ptr_pad->m_Pos.x;
NewTrack->m_Start.y = ptr_pad->m_Pos.y; newTrack->m_Start = pad->m_Pos;
NewTrack->start = ptr_pad;
NewTrack->end = PtSegm; newTrack->start = pad;
newTrack->end = segment;
nb_new_piste++; nb_new_piste++;
msg.Printf( wxT( "e %d" ), nb_new_piste ); msg.Printf( wxT( "e %d" ), nb_new_piste );

View File

@ -196,9 +196,10 @@ void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm )
if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */ if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */
{ {
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR | GR_SURBRILL ); Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR | GR_SURBRILL );
/* Effacement flag BUSY */ /* Effacement flag BUSY */
Struct = pt_track; ii = 0; Struct = pt_track;;
for( ; ii < nb_segm; ii++, Struct = (TRACK*) Struct->Pnext ) for( ii=0; ii<nb_segm; ii++, Struct = (TRACK*) Struct->Pnext )
{ {
Struct->SetState( BUSY, OFF ); Struct->SetState( BUSY, OFF );
} }