Commit 49e32e09 authored by dickelbeck's avatar dickelbeck
Browse files

unified m_Flags, EDA_BaseStruct::Display_Infos(), and ~GetEquipot()

parent 0421987b
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -4,6 +4,26 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with 
email address.


2007-Aug-20 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew & eeschema
  * Moved allowed m_Flags values from pcbnew.h, general.h, and eeschema/delete.cpp to base_struct.h 
    near m_Flags itself.  Several of the flags values were changed.  I am only
    comfortable with this change if m_Flags is not written to disk anywhere,
    and we need to give that some thought.  If m_Flags is a memory only usage
    and not saved to disk, then this change should be safe.  I could not find
    any case where m_Flags was being saved do disk, but I could have missed one.
    The reason for the change was to consolidate into one place the allowed values
    so that as new flags are allowed there is no conflict.
  * Moved most all the pcbnew/affiche.cpp functions to member functions of their
    respective classes with the name Display_Infos().
  * Moved GetEquipot() global function to BOARD::FindNet().
  These changes are working towards a concise locate.cpp module, on the way
  to implementing the multiple choice support.  Mass edits should be slowing down
  in a day or so.
   

2007-Aug-20 UPDATE   Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ eeschema & pcbnew
+0 −4
Original line number Diff line number Diff line
@@ -13,10 +13,6 @@

#include "protos.h"

#define SELECTEDNODE 1	/* flag indiquant que la structure a deja selectionnee */
#define STRUCT_DELETED 2	/* Bit flag de Status pour structures effacee */
#define CANDIDATE 4		/* flag indiquant que la structure est connectee */
#define SKIP_STRUCT 8	/* flag indiquant que la structure ne doit pas etre traitee */

/********************************************************************************/
static int CountConnectedItems(WinEDA_SchematicFrame * frame,
+0 −12
Original line number Diff line number Diff line
@@ -24,18 +24,6 @@

#define HIGHLIGHT_COLOR WHITE

/* Flags used in editing commnands (EDA_BaseStruct, .Flags )*/
#define IS_CHANGED 1
#define IS_LINKED 2
#define IS_MOVED 4
#define IS_NEW 8
#define IS_DELETED 0x10
#define IS_RESIZED 0x20
#define IN_EDIT 0x40
#define IS_WIRE_IMAGE 0x100
#define STARTPOINT 0x200
#define ENDPOINT 0x400
#define SELECTED 0x800

/* Used for EDA_BaseStruct, .m_Select member */
#define IS_SELECTED 1
+397 −379
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@

/* variables locales */
int ux0, uy0, dx, dy, spot_cX, spot_cY;     /* Variables utilisees pour
							 la localisation des segments */
                                             *  la localisation des segments */
/* fonctions locales */
static TRACK*       Locate_Zone( TRACK* start_adresse, int layer, int typeloc );
static TRACK*       Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer );
@@ -22,24 +22,24 @@ static TRACK * Locate_Pistes(TRACK * start_adresse, wxPoint ref,int Layer);
static DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc );
static TEXTE_PCB*   Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc );
static int          distance( int seuil );

/**/

/* Macro de calcul de la coord de pointage selon le curseur
(ON/OFF grille) choisi
 *  (ON/OFF grille) choisi
 */
#define SET_REF_POS( ref )  if( typeloc == CURSEUR_ON_GRILLE ) \
    { ref = ActiveScreen->m_Curseur; } \
    else { ref = ActiveScreen->m_MousePosition; }




/*************************************************************/
EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc )
/*************************************************************/

/* Fonction de localisation generale
	Affiche les caract de la stucture localisée et retourne un pointeur
	sur celle-ci
 *  Affiche les caract de la stucture localisée et retourne un pointeur
 *  sur celle-ci
 */
{
    TEXTE_PCB*   pt_texte_pcb;
@@ -57,10 +57,12 @@ int layer;
        while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL )
        {
            Track = TrackLocate;
			if(TrackLocate->m_StructType == TYPEVIA) break ;
            if( TrackLocate->m_StructType == TYPEVIA )
                break;
            TrackLocate = (TRACK*) TrackLocate->Pnext;
        }
		Affiche_Infos_Piste(this, Track) ;

        Track->Display_Infos( this );
        return Track;
    }

@@ -68,7 +70,8 @@ int layer;
    pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings, typeloc );
    if( pt_texte_pcb ) // texte type PCB localise
    {
		Affiche_Infos_PCB_Texte(this, pt_texte_pcb); return pt_texte_pcb;
        pt_texte_pcb->Display_Infos( this );
        return pt_texte_pcb;
    }

    if( ( DrawSegm = Locate_Segment_Pcb( m_Pcb, typeloc ) ) != NULL )
@@ -79,7 +82,8 @@ int layer;
    if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone,
                                    GetScreen()->m_Active_Layer, typeloc ) ) != NULL )
    {
		Affiche_Infos_Piste(this, TrackLocate) ; return TrackLocate;
        TrackLocate->Display_Infos( this ); 
        return TrackLocate;
    }

    MsgPanel->EraseMsgBox();
@@ -87,27 +91,29 @@ int layer;
}



/********************************************************/
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc )
/********************************************************/

/* Localisation de segments de contour du type edge pcb ou draw
	(selon couche active)
	Retourne:
		Pointeur sur DEBUT du segment localise
		NULL si rien trouve
 *  (selon couche active)
 *  Retourne:
 *      Pointeur sur DEBUT du segment localise
 *      NULL si rien trouve
 */
{
    EDA_BaseStruct* PtStruct;
    DRAWSEGMENT*    pts;
    wxPoint         ref;
    PCB_SCREEN*     screen = (PCB_SCREEN*) ActiveScreen;

    SET_REF_POS( ref );

    PtStruct = Pcb->m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    {
		if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue;
        if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
            continue;
        pts = (DRAWSEGMENT*) PtStruct;
        ux0 = pts->m_Start.x; uy0 = pts->m_Start.y;
        /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
@@ -115,7 +121,8 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen;
        spot_cX = ref.x - ux0; spot_cY = ref.y - uy0;

        /* detection : */
		if(pts->m_Layer != screen->m_Active_Layer) continue;
        if( pts->m_Layer != screen->m_Active_Layer )
            continue;

        if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) )
        {
@@ -124,7 +131,8 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen;
            dist  = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
            if( abs( rayon - dist ) <= (pts->m_Width / 2) )
            {
				if(pts->m_Shape == S_CIRCLE) return(pts);
                if( pts->m_Shape == S_CIRCLE )
                    return pts;
                /* pour un arc, controle complementaire */
                MouseAngle = (int) ArcTangente( spot_cY, spot_cX );
                StAngle    = (int) ArcTangente( dy, dx );
@@ -135,16 +143,17 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen;
                    StAngle -= 3600; EndAngle -= 3600;
                }
                if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) )
					return(pts);
                    return pts;
            }
        }

        else
        {
			if( distance( pts->m_Width /2 ) ) return( pts ) ;
            if( distance( pts->m_Width / 2 ) )
                return pts;
        }
    }
	return(NULL) ;

    return NULL;
}


@@ -154,11 +163,11 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen;
/****************************************************************************/

/*
1 -  routine de localisation du segment de piste pointe par la souris.
2 -  routine de localisation du segment de piste pointe par le point
			ref_pX , ref_pY.r

	La recherche commence a l'adresse start_adresse
 *  1 -  routine de localisation du segment de piste pointe par la souris.
 *  2 -  routine de localisation du segment de piste pointe par le point
 *          ref_pX , ref_pY.r
 * 
 *  La recherche commence a l'adresse start_adresse
 */

TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc )
@@ -167,7 +176,7 @@ wxPoint ref;

    SET_REF_POS( ref );

	return( Locate_Pistes(start_adresse, ref, Layer) );
    return Locate_Pistes( start_adresse, ref, Layer );
}


@@ -178,7 +187,8 @@ int l_piste ; /* demi-largeur de la piste */

    for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext )
    {
		if( Track->GetState(BUSY|DELETED) ) continue;
        if( Track->GetState( BUSY | DELETED ) )
            continue;
        /* calcul des coordonnees du segment teste */
        l_piste = Track->m_Width >> 1;                  /* l_piste = demi largeur piste */
        ux0 = Track->m_Start.x; uy0 = Track->m_Start.y; /* coord de depart */
@@ -192,7 +202,7 @@ int l_piste ; /* demi-largeur de la piste */
        {
            if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) )
            {
				return(Track) ;
                return Track;
            }
            continue;
        }
@@ -200,11 +210,14 @@ int l_piste ; /* demi-largeur de la piste */
        if( Layer >= 0 )
            if( Track->m_Layer != Layer )
                continue;/* Segments sur couches differentes */
		if( distance(l_piste) ) return(Track) ;
        if( distance( l_piste ) )
            return Track;
    }
	return(NULL) ;

    return NULL;
}


/****************************************************************/
/* TRACK * Locate_Zone(TRACK * start_adresse, int layer,	 */
/*											int typeloc)		*/
@@ -212,13 +225,13 @@ int l_piste ; /* demi-largeur de la piste */
/****************************************************************/

/*
1 -  routine de localisation du segment de zone pointe par la souris.
2 -  routine de localisation du segment de zone pointe par le point
			ref_pX , ref_pY.r

	Si layer == -1 , le tst de la couche n'est pas fait

	La recherche commence a l'adresse start_adresse
 *  1 -  routine de localisation du segment de zone pointe par la souris.
 *  2 -  routine de localisation du segment de zone pointe par le point
 *          ref_pX , ref_pY.r
 * 
 *  Si layer == -1 , le tst de la couche n'est pas fait
 * 
 *  La recherche commence a l'adresse start_adresse
 */

TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc )
@@ -227,7 +240,7 @@ wxPoint ref;

    SET_REF_POS( ref );

	return( Locate_Zone(start_adresse, ref, layer) );
    return Locate_Zone( start_adresse, ref, layer );
}


@@ -247,12 +260,14 @@ int l_segm ; /* demi-largeur de la piste */
        dx     -= ux0; dy -= uy0;
        spot_cX = ref.x - ux0; spot_cY = ref.y - uy0;

		if((layer != -1) && (Zone->m_Layer != layer)) continue;
		if( distance(l_segm) ) return(Zone) ;
		}
	return(NULL) ;
        if( (layer != -1) && (Zone->m_Layer != layer) )
            continue;
        if( distance( l_segm ) )
            return Zone;
    }

    return NULL;
}


/***************************************************************/
@@ -260,8 +275,8 @@ int l_segm ; /* demi-largeur de la piste */
/***************************************************************/

/* localisation des inscriptions sur le Pcb:
	entree : char pointeur sur le debut de la zone de recherche
	retour : pointeur sur la description du texte localise
 *  entree : char pointeur sur le debut de la zone de recherche
 *  retour : pointeur sur la description du texte localise
 */

TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc )
@@ -274,7 +289,8 @@ wxPoint ref;
    PtStruct = (EDA_BaseStruct*) pt_txt_pcb;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    {
		if( PtStruct->m_StructType != TYPETEXTE ) continue;
        if( PtStruct->m_StructType != TYPETEXTE )
            continue;
        pt_txt_pcb = (TEXTE_PCB*) PtStruct;

        angle = pt_txt_pcb->m_Orient;
@@ -288,11 +304,11 @@ wxPoint ref;
        spot_cX = ref.x - ux0; spot_cY = ref.y - uy0;
        RotatePoint( &spot_cX, &spot_cY, -angle );
        if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) )
			 return(pt_txt_pcb) ;
		}
	return(NULL) ;
            return pt_txt_pcb;
    }

    return NULL;
}


/*****************************/
@@ -300,20 +316,20 @@ wxPoint ref;
/*****************************/

/*
 Calcul de la distance du curseur souris a un segment de droite :
 ( piste, edge, contour module ..
	retourne:
		0 si distance > seuil
		1 si distance <= seuil
	Variables utilisees ( doivent etre initialisees avant appel , et
	sont ramenees au repere centre sur l'origine du segment)
		dx, dy = coord de l'extremite segment.
		spot_cX,spot_cY = coord du curseur souris
	la recherche se fait selon 4 cas:
		segment horizontal
		segment vertical
		segment 45
		segment quelconque
 *  Calcul de la distance du curseur souris a un segment de droite :
 *  ( piste, edge, contour module ..
 *  retourne:
 *      0 si distance > seuil
 *      1 si distance <= seuil
 *  Variables utilisees ( doivent etre initialisees avant appel , et
 *  sont ramenees au repere centre sur l'origine du segment)
 *      dx, dy = coord de l'extremite segment.
 *      spot_cX,spot_cY = coord du curseur souris
 *  la recherche se fait selon 4 cas:
 *      segment horizontal
 *      segment vertical
 *      segment 45
 *      segment quelconque
 */

int distance( int seuil )
@@ -321,7 +337,7 @@ int distance(int seuil)
    int cXrot, cYrot,   /* coord du point (souris) dans le repere tourne */
        segX, segY;     /* coord extremite segment tj >= 0 */
    int pointX, pointY;/* coord point a tester dans repere modifie dans lequel
	 					segX et segY sont >=0 */
                     *  segX et segY sont >=0 */

    segX = dx; segY = dy; pointX = spot_cX; pointY = spot_cY;

@@ -340,81 +356,84 @@ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel
    {
        if( abs( pointY ) <= seuil )
        {
			if((pointX >= 0) && (pointX <= segX) ) return(1);
            if( (pointX >= 0) && (pointX <= segX) )
                return 1;
            /* Etude des extremites : cercle de rayon seuil */
            if( (pointX < 0) && (pointX >= -seuil) )
            {
                if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) )
					return(1);
                    return 1;
            }
            if( (pointX > segX) && ( pointX <= (segX + seuil) ) )
            {
				if( (((pointX-segX) * (pointX-segX)) + (pointY*pointY)) <= (seuil*seuil) )
					return(1);
                if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <=
                   (seuil * seuil) )
                    return 1;
            }
        }
    }

    else if( segX == 0 ) /* piste verticale */
    {
        if( abs( pointX ) <= seuil )
        {
			if((pointY >= 0 ) && (pointY <= segY) ) return(1);
            if( (pointY >= 0 ) && (pointY <= segY) )
                return 1;
            if( (pointY < 0) && (pointY >= -seuil) )
            {
                if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) )
					return(1);
                    return 1;
            }
            if( (pointY > segY) && ( pointY <= (segY + seuil) ) )
            {
				if( ( ((pointY-segY) * (pointY-segY)) + (pointX*pointX)) <= (seuil*seuil) )
					return(1);
                if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <=
                   (seuil * seuil) )
                    return 1;
            }
        }
    }

    else if( segX == segY )    /* piste a 45 degre */
    {
        /* on fait tourner les axes de 45 degre. la souris a alors les
		coord : x1 = x*cos45 + y*sin45
				y1 = y*cos45 - x*sin45
		et le segment de piste est alors horizontal.
		recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 
		remarque : sin ou cos45 = .707, et lors du recalcul des coord
		dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois
		trop grands. (c.a.d trop petits)
		spot_cX,Y doit etre * par .707 * .707 = 0.5 */
         *  coord : x1 = x*cos45 + y*sin45
         *      y1 = y*cos45 - x*sin45
         *  et le segment de piste est alors horizontal.
         *  recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10
         *  remarque : sin ou cos45 = .707, et lors du recalcul des coord
         *  dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois
         *  trop grands. (c.a.d trop petits)
         *  spot_cX,Y doit etre * par .707 * .707 = 0.5 */

        cXrot = (pointX + pointY) >> 1;
        cYrot = (pointY - pointX) >> 1;

        /* recalcul des coord de l'extremite du segment , qui sera vertical
		suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY)
		et est en fait 1,414 plus grand , et dy45 = 0 */
         *  suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY)
         *  et est en fait 1,414 plus grand , et dy45 = 0 */

        // seuil doit etre * .707 pour tenir compte du coeff de reduction sur dx,dy
        seuil *= 7; seuil /= 10;
        if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */
        {
			if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ;
            if( (cXrot >= 0) && (cXrot <= segX) )
                return 1;

            /* Etude des extremites : cercle de rayon seuil */
            if( (cXrot < 0) && (cXrot >= -seuil) )
            {
                if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) )
					return(1);
                    return 1;
            }
            if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
            {
                if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
					return(1);
                    return 1;
            }
        }
    }
    else    /* orientation quelconque */
    {
        /* On fait un changement d'axe (rotation) de facon a ce que le segment
		de piste soit horizontal dans le nouveau repere */
         *  de piste soit horizontal dans le nouveau repere */
        int angle;

        angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI);
@@ -423,25 +442,24 @@ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel
        RotatePoint( &segX, &segY, angle );     /* Rotation du segment */

        /*la piste est Horizontale , par suite des modifs de coordonnes
		et d'axe, donc segX = longueur du segment */
         *  et d'axe, donc segX = longueur du segment */

        if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */
        {
			if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ; 
            if( (cXrot >= 0) && (cXrot <= segX) )
                return 1;
            /* Etude des extremites : cercle de rayon seuil */
            if( (cXrot < 0) && (cXrot >= -seuil) )
            {
                if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) )
					return(1);
                    return 1;
            }
            if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
            {
                if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
					return(1);
                    return 1;
            }
        }
    }
	return(0) ;
    return 0;
}

+33 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ enum SEARCH_RESULT {
typedef DrawStructureType   KICAD_T;    // shorter name

class EDA_BaseStruct;

class WinEDA_DrawFrame;

/**
 * Class INSPECTOR
@@ -132,7 +132,26 @@ public:
    EDA_BaseStruct* m_Parent;           /* Linked list: Link (parent struct) */
    EDA_BaseStruct* m_Son;              /* Linked list: Link (son struct) */
    EDA_BaseStruct* m_Image;            /* Link to an image copy for undelete or abort command */

    int             m_Flags;            // flags for editions and other
#define IS_CHANGED      (1<<0)    
#define IS_LINKED       (1<<1)
#define IN_EDIT         (1<<2)
#define IS_MOVED        (1<<3)
#define IS_NEW          (1<<4)
#define IS_RESIZED      (1<<5)
#define IS_DRAGGED      (1<<6)
#define IS_DELETED      (1<<7)
#define IS_WIRE_IMAGE   (1<<8)
#define STARTPOINT      (1<<9)
#define ENDPOINT        (1<<10)
#define SELECTED        (1<<11)
#define SELECTEDNODE    (1<<12)         ///< flag indiquant que la structure a deja selectionnee
#define STRUCT_DELETED  (1<<13)         ///< Bit flag de Status pour structures effacee
#define CANDIDATE       (1<<14)         ///< flag indiquant que la structure est connectee
#define SKIP_STRUCT     (1<<15)         ///< flag indiquant que la structure ne doit pas etre traitee


    unsigned long   m_TimeStamp;        // Time stamp used for logical links
    int             m_Selected;         /* Used by block commands, and selective editing */

@@ -178,6 +197,19 @@ public:
                          int               draw_mode,
                          int               Color = -1 );

    
    /**
     * Function Display_Infos
     * has knowledge about the frame and how and where to put status information
     * about this object into the frame's message panel.
     * @param frame A WinEDA_DrawFrame in which to print status information.
     */ 
    virtual void    Display_Infos( WinEDA_DrawFrame* frame )
    {
        // derived classes may implement this 
    }
    
    
    /**
     * Function HitTest
     * tests if the given wxPoint is within the bounds of this object.
Loading