Commit f3cd8f57 authored by dickelbeck's avatar dickelbeck
Browse files

fixed a bug in "ratsnest on module or pad", and beautification

parent 8bb93b8d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -138,7 +138,8 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
    // Save the board after the time out :
    int CurrentTime = time( NULL );
    if( !GetScreen()->IsModify() || GetScreen()->IsSave() )
    {       /* If no change, reset the time out */
    {   
        /* If no change, reset the time out */
        g_SaveTime = CurrentTime;
    }

@@ -147,7 +148,9 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
        wxString tmpFileName = GetScreen()->m_FileName;
        wxString filename    = g_SaveFileName + PcbExtBuffer;
        bool     flgmodify   = GetScreen()->IsModify();

        ( (WinEDA_PcbFrame*) this )->SavePcbFile( filename );

        if( flgmodify ) // Set the flags m_Modify cleared by SavePcbFile()
        {
            GetScreen()->SetModify();
+2 −1
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )

    case ID_PCB_SHOW_1_RATSNEST_BUTT:
        DrawStruct = PcbGeneralLocateAndDisplay();
        if( DrawStruct )
            Show_1_Ratsnest( DrawStruct, DC );
        break;

+365 −326
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
/***********************************************/
void WinEDA_PcbFrame::DisplayTrackSettings( void )
/***********************************************/

/* Display the current track width and via diameter
 */
{
@@ -47,14 +48,16 @@ CHEVELU * pt_chevelu;

    if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 )
    {
		if ( g_Show_Ratsnest ) Compile_Ratsnest( DC, TRUE );
        if( g_Show_Ratsnest )
            Compile_Ratsnest( DC, TRUE );
        return;
    }

    DrawGeneralRatsnest( DC, 0 ); /* effacement eventuel du chevelu affiche */

    pt_chevelu = m_Pcb->m_Ratsnest;
	if ( pt_chevelu == NULL ) return;
    if( pt_chevelu == NULL )
        return;

    if( g_Show_Ratsnest )
    {
@@ -62,9 +65,9 @@ CHEVELU * pt_chevelu;
        {
            pt_chevelu->status |= CH_VISIBLE;
        }

        DrawGeneralRatsnest( DC, 0 );
    }

    else
    {
        for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- )
@@ -78,11 +81,12 @@ CHEVELU * pt_chevelu;
/*************************************************************************/
void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
/*************************************************************************/

/*
 change de couche la piste pointee par la souris :
	la piste doit etre sur une des couches de travail,
	elle est mise sur l'autre couche de travail, si cela est possible
	(ou si DRC = Off ).
 *  change de couche la piste pointee par la souris :
 *  la piste doit etre sur une des couches de travail,
 *  elle est mise sur l'autre couche de travail, si cela est possible
 *  (ou si DRC = Off ).
 */
{
    int    ii;
@@ -99,7 +103,7 @@ int l1, l2 , nb_segm;
    pt_track = Marque_Une_Piste( this, DC, pt_segm, &nb_segm, GR_XOR );

    /* effacement du flag BUSY et sauvegarde en membre .param de la couche
	initiale */
     *  initiale */
    ii = nb_segm; pt_segm = pt_track;
    for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Pnext )
    {
@@ -110,11 +114,14 @@ int l1, l2 , nb_segm;
    ii = 0; pt_segm = pt_track;
    for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Pnext )
    {
		if( pt_segm->m_StructType == TYPEVIA) continue;
        if( pt_segm->m_StructType == TYPEVIA )
            continue;

        /* inversion des couches */
		if( pt_segm->m_Layer == l1 ) pt_segm->m_Layer = l2 ;
		else if(pt_segm->m_Layer == l2 ) pt_segm->m_Layer = l1 ;
        if( pt_segm->m_Layer == l1 )
            pt_segm->m_Layer = l2;
        else if( pt_segm->m_Layer == l2 )
            pt_segm->m_Layer = l1;

        if( (Drc_On) && ( Drc( this, DC, pt_segm, m_Pcb->m_Track, 1 ) == BAD_DRC ) )
        {       /* Annulation du changement */
@@ -123,11 +130,13 @@ int l1, l2 , nb_segm;
            {
                pt_segm->m_Layer = pt_segm->m_Param;
            }

            Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR );
            DisplayError( this, _( "Drc error, cancelled" ), 10 );
            return;
        }
    }

    Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL );
    /* controle des extremites de segments: sont-ils sur un pad */
    ii = 0; pt_segm = pt_track;
@@ -136,17 +145,20 @@ int l1, l2 , nb_segm;
        pt_segm->start = Locate_Pad_Connecte( m_Pcb, pt_segm, START );
        pt_segm->end   = Locate_Pad_Connecte( m_Pcb, pt_segm, END );
    }

    test_1_net_connexion( DC, pt_track->m_NetCode );
    Affiche_Infos_Piste( this, pt_track );
    GetScreen()->SetModify();
}


/****************************************************************/
void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
/****************************************************************/

/*
	Change de couche active pour le routage.
	Si une piste est en cours de trace : placement d'une Via
 *  Change de couche active pour le routage.
 *  Si une piste est en cours de trace : placement d'une Via
 */
{
    TRACK*  pt_segm;
@@ -158,7 +170,8 @@ int itmp;
    {
        if( GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP )
            GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_TOP;
		else GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM ;
        else
            GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM;
        Affiche_Status_Box();
        SetToolbars();
        return;
@@ -170,10 +183,11 @@ int itmp;
    pt_segm = g_FirstTrackSegment;
    for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Pnext )
    {
		if( (pt_segm->m_StructType == TYPEVIA) &&
			(g_CurrentTrackSegment->m_End == pt_segm->m_Start) )
        if( (pt_segm->m_StructType == TYPEVIA)
           && (g_CurrentTrackSegment->m_End == pt_segm->m_Start) )
            return;
    }

    /* Test si segment possible a placer */
    if( Drc_On )
        if( Drc( this, DC, g_CurrentTrackSegment, m_Pcb->m_Track, 1 ) == BAD_DRC )
@@ -193,12 +207,14 @@ int itmp;
    Via->m_Start   = Via->m_End = g_CurrentTrackSegment->m_End;

    Via->m_Layer = GetScreen()->m_Active_Layer;

    // Provisoirement. indicate the first layer (?)

    //swap the layers.
    if( GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP )
        GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_TOP;
	else	GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM ;
    else
        GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM;

    if( (Via->m_Shape & 15) == VIA_ENTERREE )
    {
@@ -208,7 +224,8 @@ int itmp;
    {                                               // A revoir! ( la via devrait deboucher sur 1 cote )
        Via->m_Layer |= GetScreen()->m_Active_Layer << 4;
    }
	else Via->m_Layer = 0x0F;
    else
        Via->m_Layer = 0x0F;

    if( Drc_On &&( Drc( this, DC, Via, m_Pcb->m_Track, 1 ) == BAD_DRC ) )
    { /* Via impossible a placer ici */
@@ -248,27 +265,31 @@ int itmp;
/*************************************************/
void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
/*************************************************/

/* Affiche:
	le status du net en haut d'ecran du segment pointe par la souris
	ou le status PCB en bas d'ecran si pas de segment pointe
 *  le status du net en haut d'ecran du segment pointe par la souris
 *  ou le status PCB en bas d'ecran si pas de segment pointe
 */
{
    TRACK* pt_segm;
    int    masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];

    pt_segm = Locate_Pistes( m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE );
	if(pt_segm == NULL) Affiche_Infos_Status_Pcb(this);
	else test_1_net_connexion(DC, pt_segm->m_NetCode);
    if( pt_segm == NULL )
        Affiche_Infos_Status_Pcb( this );
    else
        test_1_net_connexion( DC, pt_segm->m_NetCode );
}


/**********************************************************************/
void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
/**********************************************************************/

/* Affiche le ratsnest relatif
	au net du pad pointe par la souris
	ou au module localise par la souris
	Efface le chevelu affiche si aucun module ou pad n'est selectionne
 *  au net du pad pointe par la souris
 *  ou au module localise par la souris
 *  Efface le chevelu affiche si aucun module ou pad n'est selectionne
 */
{
    int      ii;
@@ -276,14 +297,18 @@ CHEVELU * pt_chevelu;
    D_PAD*   pt_pad = NULL;
    MODULE*  Module = NULL;

	if (g_Show_Ratsnest) return;	// Deja Affich�
    if( g_Show_Ratsnest )
        return;                     // Deja Affich�

    if( !item )
        return;
    
    if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 )
    {
        Compile_Ratsnest( DC, TRUE );
    }

	if ( item && (item->m_StructType == TYPEPAD) )
    if( item->m_StructType == TYPEPAD )
    {
        pt_pad = (D_PAD*) item;
        Module = (MODULE*) pt_pad->m_Parent;
@@ -297,9 +322,11 @@ MODULE * Module = NULL;
        {
            if( pt_chevelu->m_NetCode == pt_pad->m_NetCode )
            {
				if( (pt_chevelu->status & CH_VISIBLE) != 0 ) continue;
                if( (pt_chevelu->status & CH_VISIBLE) != 0 )
                    continue;
                pt_chevelu->status |= CH_VISIBLE;
				if( (pt_chevelu->status & CH_ACTIF) == 0 ) continue;
                if( (pt_chevelu->status & CH_ACTIF) == 0 )
                    continue;

                GRSetDrawMode( DC, GR_XOR );
                GRLine( &DrawPanel->m_ClipBox, DC, pt_chevelu->pad_start->m_Pos.x,
@@ -313,7 +340,12 @@ MODULE * Module = NULL;
    }
    else
    {
		if ( item && (item->m_StructType == TYPEMODULE) )
        if( item->m_StructType == TYPETEXTEMODULE )
        {
            Module = (MODULE*) item->m_Parent;
        }
        
        else if( item->m_StructType == TYPEMODULE )
        {
            Module = (MODULE*) item;
        }
@@ -327,12 +359,15 @@ MODULE * Module = NULL;
                pt_chevelu = (CHEVELU*) m_Pcb->m_Ratsnest;
                for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- )
                {
					if( (pt_chevelu->pad_start == pt_pad) ||
						(pt_chevelu->pad_end == pt_pad) )
                    if( (pt_chevelu->pad_start == pt_pad)
                       || (pt_chevelu->pad_end == pt_pad) )
                    {
						if( pt_chevelu->status & CH_VISIBLE ) continue;
                        if( pt_chevelu->status & CH_VISIBLE )
                            continue;

                        pt_chevelu->status |= CH_VISIBLE;
						if( (pt_chevelu->status & CH_ACTIF) == 0 ) continue;
                        if( (pt_chevelu->status & CH_ACTIF) == 0 )
                            continue;

                        GRSetDrawMode( DC, GR_XOR );
                        GRLine( &DrawPanel->m_ClipBox, DC, pt_chevelu->pad_start->m_Pos.x,
@@ -344,12 +379,13 @@ MODULE * Module = NULL;
                    }
                }
            }

            pt_pad = NULL;
        }
    }

    /* Effacement complet des selections
		si aucun pad ou module n'a ete localise */
     *  si aucun pad ou module n'a ete localise */
    if( (pt_pad == NULL) && (Module == NULL) )
    {
        MsgPanel->EraseMsgBox();
@@ -364,8 +400,9 @@ MODULE * Module = NULL;
/*****************************************************/
void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC )
/*****************************************************/

/* Met en surbrillance les pads non encore connectes ( correspondants aux
chevelus actifs
 *  chevelus actifs
 */
{
    int      ii;
@@ -375,7 +412,9 @@ D_PAD * pt_pad;
    pt_chevelu = (CHEVELU*) m_Pcb->m_Ratsnest;
    for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- )
    {
		if( (pt_chevelu->status & CH_ACTIF) == 0 ) continue;
        if( (pt_chevelu->status & CH_ACTIF) == 0 )
            continue;

        pt_pad = pt_chevelu->pad_start;

        if( pt_pad )
+78 −53
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
/* Localisation des elements */
/*****************************/


#include "fctsys.h"
#include "gr_basic.h"

@@ -19,14 +20,23 @@ int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour
/* fonctions locales */
EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc );

/**/

/* Macro de calcul de la coord de pointage selon le curseur
 *  (ON/OFF grille) choisi
/**
 * Function RefPos
 * returns the reference position, coming from either the mouse position or the
 * the cursor position, based on whether the typeloc has the CURSEUR_OFF_GRILLE 
 * flag ORed in or not.
 * @param typeloc int with possible CURSEUR_OFF_GRILLE bit on.
 * @return wxPoint - The reference point, either the mouse position or 
 *   the cursor position.
 */
#define SET_REF_POS( ref_pos )  if( typeloc == CURSEUR_ON_GRILLE ) \
    { ref_pos = ActiveScreen->m_Curseur; } \
    else { ref_pos = ActiveScreen->m_MousePosition; }
wxPoint inline RefPos( int typeloc )
{
    if( typeloc & CURSEUR_OFF_GRILLE )
        return ActiveScreen->m_MousePosition;
    else
        return ActiveScreen->m_Curseur;
}
 

/**
@@ -36,7 +46,8 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int t
 * @param layer One of the two allowed layers for modules: CMP_N or CUIVRE_N
 * @return bool - true if the layer is visible, else false.
 */
bool inline IsModuleLayerVisible( int layer ) {
bool inline IsModuleLayerVisible( int layer ) 
{
    if( layer==CMP_N )
        return DisplayOpt.Show_Modules_Cmp;

@@ -146,6 +157,7 @@ EDA_BaseStruct* WinEDA_BasePcbFrame::Locate( int typeloc, int LayerSearch )
    if( Track != NULL )
    {
        TrackLocate = Track;   /* a track or a via is found */
        
        /* Search for a via */
        while( ( TrackLocate = Locate_Pistes( TrackLocate,
                                              masque_layer, typeloc ) ) != NULL )
@@ -153,6 +165,7 @@ EDA_BaseStruct* WinEDA_BasePcbFrame::Locate( int typeloc, int LayerSearch )
            Track = TrackLocate;
            if( TrackLocate->m_StructType == TYPEVIA )
                break;

            TrackLocate = (TRACK*) TrackLocate->Pnext;
        }

@@ -169,8 +182,9 @@ EDA_BaseStruct* WinEDA_BasePcbFrame::Locate( int typeloc, int LayerSearch )
    /* Search for a footprint text */

    // First search: locate texts for footprints on copper or component layer
    // Priority to the active layer (component or copper.
    // this is useful for small smd components when 2 texts overlap but are not on the same layer
    // Priority to the active layer (component or copper).
    // This is useful for small smd components when 2 texts overlap but are not 
    // on the same layer
    if( LayerSearch == LAYER_CUIVRE_N   ||   LayerSearch == CMP_N )
    {
        for( module = m_Pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext )
@@ -316,14 +330,14 @@ EDGE_MODULE* Locate_Edge_Module( MODULE* module, int typeloc )
    int             uxf, uyf, type_trace;
    int             rayon, dist;
    wxPoint         ref_pos;        /* coord du point de localisation */
    int             StAngle, EndAngle, MouseAngle;/* pour localisation d'arcs,
                                    *  angle du point de debut, de fin et du point
                                    *  de reference */

    /* pour localisation d'arcs, angle du point de debut, de fin et du point de reference */
    int             StAngle, EndAngle, MouseAngle;

    if( !module )
        return NULL;

    SET_REF_POS( ref_pos );
    ref_pos = RefPos( typeloc );

    PtStruct = module->m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
@@ -397,7 +411,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
    wxPoint         ref_pos;
    int             ux0, uy0;

    SET_REF_POS( ref_pos );
    ref_pos = RefPos( typeloc );

    PtStruct = Pcb->m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
@@ -418,6 +432,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )

        /* Localisation des SEGMENTS ?) */
        ux0 = Cotation->Barre_ox; uy0 = Cotation->Barre_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->Barre_fx - ux0; dy = Cotation->Barre_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -427,6 +442,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
            return PtStruct;

        ux0 = Cotation->TraitG_ox; uy0 = Cotation->TraitG_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->TraitG_fx - ux0; dy = Cotation->TraitG_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -436,6 +452,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
            return PtStruct;

        ux0 = Cotation->TraitD_ox; uy0 = Cotation->TraitD_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->TraitD_fx - ux0; dy = Cotation->TraitD_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -445,6 +462,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
            return PtStruct;

        ux0 = Cotation->FlecheD1_ox; uy0 = Cotation->FlecheD1_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->FlecheD1_fx - ux0; dy = Cotation->FlecheD1_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -454,6 +472,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
            return PtStruct;

        ux0 = Cotation->FlecheD2_ox; uy0 = Cotation->FlecheD2_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->FlecheD2_fx - ux0; dy = Cotation->FlecheD2_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -463,6 +482,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
            return PtStruct;

        ux0 = Cotation->FlecheG1_ox; uy0 = Cotation->FlecheG1_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->FlecheG1_fx - ux0; dy = Cotation->FlecheG1_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -472,6 +492,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
            return PtStruct;

        ux0 = Cotation->FlecheG2_ox; uy0 = Cotation->FlecheG2_oy;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = Cotation->FlecheG2_fx - ux0; dy = Cotation->FlecheG2_fy - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -501,7 +522,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
    wxPoint         ref_pos;
    PCB_SCREEN*     screen = (PCB_SCREEN*) ActiveScreen;

    SET_REF_POS( ref_pos );
    ref_pos = RefPos( typeloc );

    PtStruct = Pcb->m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
@@ -511,7 +532,9 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
        pts = (DRAWSEGMENT*) PtStruct;
        if( (pts->m_Layer != LayerSearch) && (LayerSearch != -1) )
            continue;
        
        ux0 = pts->m_Start.x; uy0 = pts->m_Start.y;
        
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
        dx      = pts->m_End.x - ux0; dy = pts->m_End.y - uy0;
        spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
@@ -520,8 +543,10 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
        if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) )
        {
            int rayon, dist, StAngle, EndAngle, MouseAngle;

            rayon = (int) hypot( (double) (dx), (double) (dy) );
            dist  = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
            
            if( abs( rayon - dist ) <= (pts->m_Width / 2) )
            {
                if( pts->m_Shape == S_CIRCLE )
@@ -531,6 +556,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
                    else if( !locate_segm )
                        locate_segm = pts;
                }

                /* pour un arc, controle complementaire */
                MouseAngle = (int) ArcTangente( spot_cY, spot_cX );
                StAngle    = (int) ArcTangente( dy, dx );
@@ -586,9 +612,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )

D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer )
{
    wxPoint ref_pos;

    SET_REF_POS( ref_pos );
    wxPoint ref_pos = RefPos( typeloc );
    return Locate_Any_Pad( Pcb, ref_pos, OnlyCurrentLayer );
}

@@ -635,9 +659,7 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer

D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc )
{
    wxPoint ref_pos;

    SET_REF_POS( ref_pos );
    wxPoint ref_pos = RefPos( typeloc );
    return Locate_Pads( module, ref_pos, masque_layer );
}

@@ -713,7 +735,8 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
    int     layer;                          /* pour calcul de couches prioritaires */
    wxPoint ref_pos;                        /* coord du point de reference pour la localisation */

    SET_REF_POS( ref_pos );
    ref_pos = RefPos( typeloc );

    pt_module = Pcb->m_Modules;
    for(  ;  pt_module;  pt_module = (MODULE*) pt_module->Pnext )
    {
@@ -795,7 +818,8 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
 *  - pointeur sur le texte localise ( ou NULL )
 *  - si Ptmodule != NULL: pointeur sur module module ( non modifie sinon )
 * 
 *  if typeloc bas the flag VISIBLE_ONLY set, only footprints which are "visible" are considered
 *  if typeloc has the flag VISIBLE_ONLY set, only footprints which are 
 * "visible" are considered
 */
{
    EDA_BaseStruct* PtStruct;
@@ -803,7 +827,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
    MODULE*         module;
    wxPoint         ref_pos;

    SET_REF_POS( ref_pos );
    ref_pos = RefPos( typeloc );

    module = *PtModule;
    if( module == NULL )
@@ -831,9 +855,8 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
                continue;
        }

        // hit-test the reference text
        pt_txt_mod = module->m_Reference;

        /* la souris est-elle dans le rectangle autour du texte*/
        if( pt_txt_mod->Locate( ref_pos ) )
        {
            if( PtModule )
@@ -841,9 +864,8 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
            return pt_txt_mod;
        }

        // hit-test the value text
        pt_txt_mod = module->m_Value;

        /* la souris est-elle dans le rectangle autour du texte*/
        if( pt_txt_mod->Locate( ref_pos ) )
        {
            if( PtModule )
@@ -851,13 +873,14 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
            return pt_txt_mod;
        }

        // hit-test any other texts
        PtStruct = module->m_Drawings;
        for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
        {
            if( PtStruct->m_StructType != TYPETEXTEMODULE )
                continue;
            
            pt_txt_mod = (TEXTE_MODULE*) PtStruct;
            /* la souris est-elle dans le rectangle autour du texte*/
            if( pt_txt_mod->Locate( ref_pos ) )
            {
                if( PtModule )
@@ -1014,9 +1037,7 @@ suite1:

TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc )
{
    wxPoint ref_pos;

    SET_REF_POS( ref_pos );
    wxPoint ref_pos = RefPos( typeloc );

    return Locate_Pistes( start_adresse, ref_pos, MasqueLayer );
}
@@ -1082,9 +1103,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa

TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc )
{
    wxPoint ref_pos;

    SET_REF_POS( ref_pos );
    wxPoint ref_pos = RefPos( typeloc );

    return Locate_Zone( start_adresse, ref_pos, layer );
}
@@ -1125,9 +1144,8 @@ TEXTE_PCB* Locate_Texte_Pcb( EDA_BaseStruct* PtStruct, int LayerSearch, int type
 *  retour : pointeur sur la description du texte localise
 */
{
    wxPoint ref;
    wxPoint ref = RefPos( typeloc );

    SET_REF_POS( ref );
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    {
        if( PtStruct->m_StructType != TYPETEXTE )
@@ -1279,6 +1297,7 @@ int distance( int seuil )
        {
            if( (cXrot >= 0) && (cXrot <= segX) )
                return 1;

            /* Etude des extremites : cercle de rayon seuil */
            if( (cXrot < 0) && (cXrot >= -seuil) )
            {
@@ -1347,18 +1366,21 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,

    if( start_adr == NULL )
        return NULL;

    for( PtSegm = start_adr; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext )
    {
        if( PtSegm->GetState( DELETED | BUSY ) == 0 )
        {
            if( ref_pos == PtSegm->m_Start )
            {       /* Test des couches */
            {       
                /* Test des couches */
                if( MaskLayer & PtSegm->ReturnMaskLayer() )
                    return PtSegm;
            }

            if( ref_pos == PtSegm->m_End )
            {       /* Test des couches */
            {       
                /* Test des couches */
                if( MaskLayer & PtSegm->ReturnMaskLayer() )
                    return PtSegm;
            }
@@ -1392,7 +1414,8 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
            if( pos == PtSegm->m_Start )
            {
                if( PtSegm->GetState( BUSY | DELETED ) == 0 )
                {    /* Test des couches */
                {    
                    /* Test des couches */
                    if( MaskLayer & PtSegm->ReturnMaskLayer() )
                        return PtSegm;
                }
@@ -1420,13 +1443,14 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch,
    if( PtStruct == NULL )
        return NULL;

    SET_REF_POS( ref_pos );
    ref_pos = RefPos( typeloc );

    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    {
        MIREPCB* item;
        if( PtStruct->m_StructType != TYPEMIRE )
            continue;

        item = (MIREPCB*) PtStruct;
        if( LayerSearch != -1 && item->m_Layer != LayerSearch )
            continue;
@@ -1434,6 +1458,7 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch,
        dX    = ref_pos.x - item->m_Pos.x;
        dY    = ref_pos.y - item->m_Pos.y;
        rayon = item->m_Size / 2;

        if( (abs( dX ) <= rayon ) && ( abs( dY ) <= rayon ) )
            break;  /* Mire Localisee */
    }