Loading change_log.txt +25 −5 Original line number Original line Diff line number Diff line Loading @@ -4,6 +4,26 @@ 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-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> 2007-Aug-20 UPDATE Geoff Harland <gharlandau@yahoo.com.au> ================================================================================ ================================================================================ + eeschema & pcbnew + eeschema & pcbnew Loading eeschema/delete.cpp +0 −4 Original line number Original line Diff line number Diff line Loading @@ -13,10 +13,6 @@ #include "protos.h" #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, static int CountConnectedItems(WinEDA_SchematicFrame * frame, Loading eeschema/general.h +0 −12 Original line number Original line Diff line number Diff line Loading @@ -24,18 +24,6 @@ #define HIGHLIGHT_COLOR WHITE #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 */ /* Used for EDA_BaseStruct, .m_Select member */ #define IS_SELECTED 1 #define IS_SELECTED 1 Loading gerbview/locate.cpp +397 −379 Original line number Original line Diff line number Diff line Loading @@ -13,7 +13,7 @@ /* variables locales */ /* variables locales */ int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour la localisation des segments */ * la localisation des segments */ /* fonctions locales */ /* fonctions locales */ static TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ); static TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ); static TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ); static TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ); Loading @@ -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 DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ); static TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ); static TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ); static int distance( int seuil ); static int distance( int seuil ); /**/ /**/ /* Macro de calcul de la coord de pointage selon le curseur /* 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 ) \ #define SET_REF_POS( ref ) if( typeloc == CURSEUR_ON_GRILLE ) \ { ref = ActiveScreen->m_Curseur; } \ { ref = ActiveScreen->m_Curseur; } \ else { ref = ActiveScreen->m_MousePosition; } else { ref = ActiveScreen->m_MousePosition; } /*************************************************************/ /*************************************************************/ EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) /*************************************************************/ /*************************************************************/ /* Fonction de localisation generale /* Fonction de localisation generale Affiche les caract de la stucture localisée et retourne un pointeur * Affiche les caract de la stucture localisée et retourne un pointeur sur celle-ci * sur celle-ci */ */ { { TEXTE_PCB* pt_texte_pcb; TEXTE_PCB* pt_texte_pcb; Loading @@ -57,10 +57,12 @@ int layer; while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) { { Track = TrackLocate; Track = TrackLocate; if(TrackLocate->m_StructType == TYPEVIA) break ; if( TrackLocate->m_StructType == TYPEVIA ) break; TrackLocate = (TRACK*) TrackLocate->Pnext; TrackLocate = (TRACK*) TrackLocate->Pnext; } } Affiche_Infos_Piste(this, Track) ; Track->Display_Infos( this ); return Track; return Track; } } Loading @@ -68,7 +70,8 @@ int layer; pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings, typeloc ); pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings, typeloc ); if( pt_texte_pcb ) // texte type PCB localise 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 ) if( ( DrawSegm = Locate_Segment_Pcb( m_Pcb, typeloc ) ) != NULL ) Loading @@ -79,7 +82,8 @@ int layer; if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone, if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone, GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) { { Affiche_Infos_Piste(this, TrackLocate) ; return TrackLocate; TrackLocate->Display_Infos( this ); return TrackLocate; } } MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox(); Loading @@ -87,27 +91,29 @@ int layer; } } /********************************************************/ /********************************************************/ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) /********************************************************/ /********************************************************/ /* Localisation de segments de contour du type edge pcb ou draw /* Localisation de segments de contour du type edge pcb ou draw (selon couche active) * (selon couche active) Retourne: * Retourne: Pointeur sur DEBUT du segment localise * Pointeur sur DEBUT du segment localise NULL si rien trouve * NULL si rien trouve */ */ { { EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct; DRAWSEGMENT* pts; DRAWSEGMENT* pts; wxPoint ref; wxPoint ref; PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen; PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen; SET_REF_POS( ref ); SET_REF_POS( ref ); PtStruct = Pcb->m_Drawings; PtStruct = Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) { { if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; pts = (DRAWSEGMENT*) PtStruct; pts = (DRAWSEGMENT*) PtStruct; ux0 = pts->m_Start.x; uy0 = pts->m_Start.y; ux0 = pts->m_Start.x; uy0 = pts->m_Start.y; /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ Loading @@ -115,7 +121,8 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; /* detection : */ /* 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) ) if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) ) { { Loading @@ -124,7 +131,8 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) ); dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) ); if( abs( rayon - dist ) <= (pts->m_Width / 2) ) 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 */ /* pour un arc, controle complementaire */ MouseAngle = (int) ArcTangente( spot_cY, spot_cX ); MouseAngle = (int) ArcTangente( spot_cY, spot_cX ); StAngle = (int) ArcTangente( dy, dx ); StAngle = (int) ArcTangente( dy, dx ); Loading @@ -135,16 +143,17 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; StAngle -= 3600; EndAngle -= 3600; StAngle -= 3600; EndAngle -= 3600; } } if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) return(pts); return pts; } } } } else else { { if( distance( pts->m_Width /2 ) ) return( pts ) ; if( distance( pts->m_Width / 2 ) ) return pts; } } } } return(NULL) ; return NULL; } } Loading @@ -154,11 +163,11 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; /****************************************************************************/ /****************************************************************************/ /* /* 1 - routine de localisation du segment de piste pointe par la souris. * 1 - routine de localisation du segment de piste pointe par la souris. 2 - routine de localisation du segment de piste pointe par le point * 2 - routine de localisation du segment de piste pointe par le point ref_pX , ref_pY.r * ref_pX , ref_pY.r * La recherche commence a l'adresse start_adresse * La recherche commence a l'adresse start_adresse */ */ TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ) TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ) Loading @@ -167,7 +176,7 @@ wxPoint ref; SET_REF_POS( ref ); SET_REF_POS( ref ); return( Locate_Pistes(start_adresse, ref, Layer) ); return Locate_Pistes( start_adresse, ref, Layer ); } } Loading @@ -178,7 +187,8 @@ int l_piste ; /* demi-largeur de la piste */ for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext ) 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 */ /* calcul des coordonnees du segment teste */ l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ ux0 = Track->m_Start.x; uy0 = Track->m_Start.y; /* coord de depart */ ux0 = Track->m_Start.x; uy0 = Track->m_Start.y; /* coord de depart */ Loading @@ -192,7 +202,7 @@ int l_piste ; /* demi-largeur de la piste */ { { if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) ) if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) ) { { return(Track) ; return Track; } } continue; continue; } } Loading @@ -200,11 +210,14 @@ int l_piste ; /* demi-largeur de la piste */ if( Layer >= 0 ) if( Layer >= 0 ) if( Track->m_Layer != Layer ) if( Track->m_Layer != Layer ) continue;/* Segments sur couches differentes */ 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, */ /* TRACK * Locate_Zone(TRACK * start_adresse, int layer, */ /* int typeloc) */ /* int typeloc) */ Loading @@ -212,13 +225,13 @@ int l_piste ; /* demi-largeur de la piste */ /****************************************************************/ /****************************************************************/ /* /* 1 - routine de localisation du segment de zone pointe par la souris. * 1 - routine de localisation du segment de zone pointe par la souris. 2 - routine de localisation du segment de zone pointe par le point * 2 - routine de localisation du segment de zone pointe par le point ref_pX , ref_pY.r * ref_pX , ref_pY.r * Si layer == -1 , le tst de la couche n'est pas fait * Si layer == -1 , le tst de la couche n'est pas fait * La recherche commence a l'adresse start_adresse * La recherche commence a l'adresse start_adresse */ */ TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) Loading @@ -227,7 +240,7 @@ wxPoint ref; SET_REF_POS( ref ); SET_REF_POS( ref ); return( Locate_Zone(start_adresse, ref, layer) ); return Locate_Zone( start_adresse, ref, layer ); } } Loading @@ -247,12 +260,14 @@ int l_segm ; /* demi-largeur de la piste */ dx -= ux0; dy -= uy0; dx -= ux0; dy -= uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; if((layer != -1) && (Zone->m_Layer != layer)) continue; if( (layer != -1) && (Zone->m_Layer != layer) ) if( distance(l_segm) ) return(Zone) ; continue; } if( distance( l_segm ) ) return(NULL) ; return Zone; } } return NULL; } /***************************************************************/ /***************************************************************/ Loading @@ -260,8 +275,8 @@ int l_segm ; /* demi-largeur de la piste */ /***************************************************************/ /***************************************************************/ /* localisation des inscriptions sur le Pcb: /* localisation des inscriptions sur le Pcb: entree : char pointeur sur le debut de la zone de recherche * entree : char pointeur sur le debut de la zone de recherche retour : pointeur sur la description du texte localise * retour : pointeur sur la description du texte localise */ */ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) Loading @@ -274,7 +289,8 @@ wxPoint ref; PtStruct = (EDA_BaseStruct*) pt_txt_pcb; PtStruct = (EDA_BaseStruct*) pt_txt_pcb; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) { { if( PtStruct->m_StructType != TYPETEXTE ) continue; if( PtStruct->m_StructType != TYPETEXTE ) continue; pt_txt_pcb = (TEXTE_PCB*) PtStruct; pt_txt_pcb = (TEXTE_PCB*) PtStruct; angle = pt_txt_pcb->m_Orient; angle = pt_txt_pcb->m_Orient; Loading @@ -288,11 +304,11 @@ wxPoint ref; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; RotatePoint( &spot_cX, &spot_cY, -angle ); RotatePoint( &spot_cX, &spot_cY, -angle ); if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) return(pt_txt_pcb) ; return pt_txt_pcb; } return(NULL) ; } } return NULL; } /*****************************/ /*****************************/ Loading @@ -300,20 +316,20 @@ wxPoint ref; /*****************************/ /*****************************/ /* /* Calcul de la distance du curseur souris a un segment de droite : * Calcul de la distance du curseur souris a un segment de droite : ( piste, edge, contour module .. * ( piste, edge, contour module .. retourne: * retourne: 0 si distance > seuil * 0 si distance > seuil 1 si distance <= seuil * 1 si distance <= seuil Variables utilisees ( doivent etre initialisees avant appel , et * Variables utilisees ( doivent etre initialisees avant appel , et sont ramenees au repere centre sur l'origine du segment) * sont ramenees au repere centre sur l'origine du segment) dx, dy = coord de l'extremite segment. * dx, dy = coord de l'extremite segment. spot_cX,spot_cY = coord du curseur souris * spot_cX,spot_cY = coord du curseur souris la recherche se fait selon 4 cas: * la recherche se fait selon 4 cas: segment horizontal * segment horizontal segment vertical * segment vertical segment 45 * segment 45 segment quelconque * segment quelconque */ */ int distance( int seuil ) int distance( int seuil ) Loading @@ -321,7 +337,7 @@ int distance(int seuil) int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ segX, segY; /* coord extremite segment tj >= 0 */ segX, segY; /* coord extremite segment tj >= 0 */ int pointX, pointY;/* coord point a tester dans repere modifie dans lequel 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; segX = dx; segY = dy; pointX = spot_cX; pointY = spot_cY; Loading @@ -340,81 +356,84 @@ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel { { if( abs( pointY ) <= seuil ) 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 */ /* Etude des extremites : cercle de rayon seuil */ if( (pointX < 0) && (pointX >= -seuil) ) if( (pointX < 0) && (pointX >= -seuil) ) { { if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) ) if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) ) return(1); return 1; } } if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) { { if( (((pointX-segX) * (pointX-segX)) + (pointY*pointY)) <= (seuil*seuil) ) if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= return(1); (seuil * seuil) ) return 1; } } } } } } else if( segX == 0 ) /* piste verticale */ else if( segX == 0 ) /* piste verticale */ { { if( abs( pointX ) <= seuil ) 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 < 0) && (pointY >= -seuil) ) { { if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) ) if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) ) return(1); return 1; } } if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) { { if( ( ((pointY-segY) * (pointY-segY)) + (pointX*pointX)) <= (seuil*seuil) ) if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= return(1); (seuil * seuil) ) return 1; } } } } } } else if( segX == segY ) /* piste a 45 degre */ else if( segX == segY ) /* piste a 45 degre */ { { /* on fait tourner les axes de 45 degre. la souris a alors les /* on fait tourner les axes de 45 degre. la souris a alors les coord : x1 = x*cos45 + y*sin45 * coord : x1 = x*cos45 + y*sin45 y1 = y*cos45 - x*sin45 * y1 = y*cos45 - x*sin45 et le segment de piste est alors horizontal. * et le segment de piste est alors horizontal. recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 * recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 remarque : sin ou cos45 = .707, et lors du recalcul des coord * 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 * dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois trop grands. (c.a.d trop petits) * trop grands. (c.a.d trop petits) spot_cX,Y doit etre * par .707 * .707 = 0.5 */ * spot_cX,Y doit etre * par .707 * .707 = 0.5 */ cXrot = (pointX + pointY) >> 1; cXrot = (pointX + pointY) >> 1; cYrot = (pointY - pointX) >> 1; cYrot = (pointY - pointX) >> 1; /* recalcul des coord de l'extremite du segment , qui sera vertical /* recalcul des coord de l'extremite du segment , qui sera vertical suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) * suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) et est en fait 1,414 plus grand , et dy45 = 0 */ * 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 doit etre * .707 pour tenir compte du coeff de reduction sur dx,dy seuil *= 7; seuil /= 10; seuil *= 7; seuil /= 10; if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */ 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 */ /* Etude des extremites : cercle de rayon seuil */ if( (cXrot < 0) && (cXrot >= -seuil) ) if( (cXrot < 0) && (cXrot >= -seuil) ) { { if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) { { if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } } } } } else /* orientation quelconque */ else /* orientation quelconque */ { { /* On fait un changement d'axe (rotation) de facon a ce que le segment /* 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; int angle; angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI); angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI); Loading @@ -423,25 +442,24 @@ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel RotatePoint( &segX, &segY, angle ); /* Rotation du segment */ RotatePoint( &segX, &segY, angle ); /* Rotation du segment */ /*la piste est Horizontale , par suite des modifs de coordonnes /*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( 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 */ /* Etude des extremites : cercle de rayon seuil */ if( (cXrot < 0) && (cXrot >= -seuil) ) if( (cXrot < 0) && (cXrot >= -seuil) ) { { if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) { { if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } } } } } return(0) ; return 0; } } include/base_struct.h +33 −1 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,7 @@ enum SEARCH_RESULT { typedef DrawStructureType KICAD_T; // shorter name typedef DrawStructureType KICAD_T; // shorter name class EDA_BaseStruct; class EDA_BaseStruct; class WinEDA_DrawFrame; /** /** * Class INSPECTOR * Class INSPECTOR Loading Loading @@ -132,7 +132,26 @@ public: EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */ EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */ EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */ EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */ int m_Flags; // flags for editions and other 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 unsigned long m_TimeStamp; // Time stamp used for logical links int m_Selected; /* Used by block commands, and selective editing */ int m_Selected; /* Used by block commands, and selective editing */ Loading Loading @@ -178,6 +197,19 @@ public: int draw_mode, int draw_mode, int Color = -1 ); 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 * Function HitTest * tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object. Loading Loading
change_log.txt +25 −5 Original line number Original line Diff line number Diff line Loading @@ -4,6 +4,26 @@ 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-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> 2007-Aug-20 UPDATE Geoff Harland <gharlandau@yahoo.com.au> ================================================================================ ================================================================================ + eeschema & pcbnew + eeschema & pcbnew Loading
eeschema/delete.cpp +0 −4 Original line number Original line Diff line number Diff line Loading @@ -13,10 +13,6 @@ #include "protos.h" #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, static int CountConnectedItems(WinEDA_SchematicFrame * frame, Loading
eeschema/general.h +0 −12 Original line number Original line Diff line number Diff line Loading @@ -24,18 +24,6 @@ #define HIGHLIGHT_COLOR WHITE #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 */ /* Used for EDA_BaseStruct, .m_Select member */ #define IS_SELECTED 1 #define IS_SELECTED 1 Loading
gerbview/locate.cpp +397 −379 Original line number Original line Diff line number Diff line Loading @@ -13,7 +13,7 @@ /* variables locales */ /* variables locales */ int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour la localisation des segments */ * la localisation des segments */ /* fonctions locales */ /* fonctions locales */ static TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ); static TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ); static TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ); static TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ); Loading @@ -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 DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ); static TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ); static TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ); static int distance( int seuil ); static int distance( int seuil ); /**/ /**/ /* Macro de calcul de la coord de pointage selon le curseur /* 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 ) \ #define SET_REF_POS( ref ) if( typeloc == CURSEUR_ON_GRILLE ) \ { ref = ActiveScreen->m_Curseur; } \ { ref = ActiveScreen->m_Curseur; } \ else { ref = ActiveScreen->m_MousePosition; } else { ref = ActiveScreen->m_MousePosition; } /*************************************************************/ /*************************************************************/ EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) /*************************************************************/ /*************************************************************/ /* Fonction de localisation generale /* Fonction de localisation generale Affiche les caract de la stucture localisée et retourne un pointeur * Affiche les caract de la stucture localisée et retourne un pointeur sur celle-ci * sur celle-ci */ */ { { TEXTE_PCB* pt_texte_pcb; TEXTE_PCB* pt_texte_pcb; Loading @@ -57,10 +57,12 @@ int layer; while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) { { Track = TrackLocate; Track = TrackLocate; if(TrackLocate->m_StructType == TYPEVIA) break ; if( TrackLocate->m_StructType == TYPEVIA ) break; TrackLocate = (TRACK*) TrackLocate->Pnext; TrackLocate = (TRACK*) TrackLocate->Pnext; } } Affiche_Infos_Piste(this, Track) ; Track->Display_Infos( this ); return Track; return Track; } } Loading @@ -68,7 +70,8 @@ int layer; pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings, typeloc ); pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings, typeloc ); if( pt_texte_pcb ) // texte type PCB localise 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 ) if( ( DrawSegm = Locate_Segment_Pcb( m_Pcb, typeloc ) ) != NULL ) Loading @@ -79,7 +82,8 @@ int layer; if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone, if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone, GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) { { Affiche_Infos_Piste(this, TrackLocate) ; return TrackLocate; TrackLocate->Display_Infos( this ); return TrackLocate; } } MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox(); Loading @@ -87,27 +91,29 @@ int layer; } } /********************************************************/ /********************************************************/ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) /********************************************************/ /********************************************************/ /* Localisation de segments de contour du type edge pcb ou draw /* Localisation de segments de contour du type edge pcb ou draw (selon couche active) * (selon couche active) Retourne: * Retourne: Pointeur sur DEBUT du segment localise * Pointeur sur DEBUT du segment localise NULL si rien trouve * NULL si rien trouve */ */ { { EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct; DRAWSEGMENT* pts; DRAWSEGMENT* pts; wxPoint ref; wxPoint ref; PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen; PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen; SET_REF_POS( ref ); SET_REF_POS( ref ); PtStruct = Pcb->m_Drawings; PtStruct = Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) { { if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; pts = (DRAWSEGMENT*) PtStruct; pts = (DRAWSEGMENT*) PtStruct; ux0 = pts->m_Start.x; uy0 = pts->m_Start.y; ux0 = pts->m_Start.x; uy0 = pts->m_Start.y; /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ Loading @@ -115,7 +121,8 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; /* detection : */ /* 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) ) if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) ) { { Loading @@ -124,7 +131,8 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) ); dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) ); if( abs( rayon - dist ) <= (pts->m_Width / 2) ) 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 */ /* pour un arc, controle complementaire */ MouseAngle = (int) ArcTangente( spot_cY, spot_cX ); MouseAngle = (int) ArcTangente( spot_cY, spot_cX ); StAngle = (int) ArcTangente( dy, dx ); StAngle = (int) ArcTangente( dy, dx ); Loading @@ -135,16 +143,17 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; StAngle -= 3600; EndAngle -= 3600; StAngle -= 3600; EndAngle -= 3600; } } if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) return(pts); return pts; } } } } else else { { if( distance( pts->m_Width /2 ) ) return( pts ) ; if( distance( pts->m_Width / 2 ) ) return pts; } } } } return(NULL) ; return NULL; } } Loading @@ -154,11 +163,11 @@ PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; /****************************************************************************/ /****************************************************************************/ /* /* 1 - routine de localisation du segment de piste pointe par la souris. * 1 - routine de localisation du segment de piste pointe par la souris. 2 - routine de localisation du segment de piste pointe par le point * 2 - routine de localisation du segment de piste pointe par le point ref_pX , ref_pY.r * ref_pX , ref_pY.r * La recherche commence a l'adresse start_adresse * La recherche commence a l'adresse start_adresse */ */ TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ) TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ) Loading @@ -167,7 +176,7 @@ wxPoint ref; SET_REF_POS( ref ); SET_REF_POS( ref ); return( Locate_Pistes(start_adresse, ref, Layer) ); return Locate_Pistes( start_adresse, ref, Layer ); } } Loading @@ -178,7 +187,8 @@ int l_piste ; /* demi-largeur de la piste */ for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext ) 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 */ /* calcul des coordonnees du segment teste */ l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ ux0 = Track->m_Start.x; uy0 = Track->m_Start.y; /* coord de depart */ ux0 = Track->m_Start.x; uy0 = Track->m_Start.y; /* coord de depart */ Loading @@ -192,7 +202,7 @@ int l_piste ; /* demi-largeur de la piste */ { { if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) ) if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) ) { { return(Track) ; return Track; } } continue; continue; } } Loading @@ -200,11 +210,14 @@ int l_piste ; /* demi-largeur de la piste */ if( Layer >= 0 ) if( Layer >= 0 ) if( Track->m_Layer != Layer ) if( Track->m_Layer != Layer ) continue;/* Segments sur couches differentes */ 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, */ /* TRACK * Locate_Zone(TRACK * start_adresse, int layer, */ /* int typeloc) */ /* int typeloc) */ Loading @@ -212,13 +225,13 @@ int l_piste ; /* demi-largeur de la piste */ /****************************************************************/ /****************************************************************/ /* /* 1 - routine de localisation du segment de zone pointe par la souris. * 1 - routine de localisation du segment de zone pointe par la souris. 2 - routine de localisation du segment de zone pointe par le point * 2 - routine de localisation du segment de zone pointe par le point ref_pX , ref_pY.r * ref_pX , ref_pY.r * Si layer == -1 , le tst de la couche n'est pas fait * Si layer == -1 , le tst de la couche n'est pas fait * La recherche commence a l'adresse start_adresse * La recherche commence a l'adresse start_adresse */ */ TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) Loading @@ -227,7 +240,7 @@ wxPoint ref; SET_REF_POS( ref ); SET_REF_POS( ref ); return( Locate_Zone(start_adresse, ref, layer) ); return Locate_Zone( start_adresse, ref, layer ); } } Loading @@ -247,12 +260,14 @@ int l_segm ; /* demi-largeur de la piste */ dx -= ux0; dy -= uy0; dx -= ux0; dy -= uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; if((layer != -1) && (Zone->m_Layer != layer)) continue; if( (layer != -1) && (Zone->m_Layer != layer) ) if( distance(l_segm) ) return(Zone) ; continue; } if( distance( l_segm ) ) return(NULL) ; return Zone; } } return NULL; } /***************************************************************/ /***************************************************************/ Loading @@ -260,8 +275,8 @@ int l_segm ; /* demi-largeur de la piste */ /***************************************************************/ /***************************************************************/ /* localisation des inscriptions sur le Pcb: /* localisation des inscriptions sur le Pcb: entree : char pointeur sur le debut de la zone de recherche * entree : char pointeur sur le debut de la zone de recherche retour : pointeur sur la description du texte localise * retour : pointeur sur la description du texte localise */ */ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) Loading @@ -274,7 +289,8 @@ wxPoint ref; PtStruct = (EDA_BaseStruct*) pt_txt_pcb; PtStruct = (EDA_BaseStruct*) pt_txt_pcb; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) { { if( PtStruct->m_StructType != TYPETEXTE ) continue; if( PtStruct->m_StructType != TYPETEXTE ) continue; pt_txt_pcb = (TEXTE_PCB*) PtStruct; pt_txt_pcb = (TEXTE_PCB*) PtStruct; angle = pt_txt_pcb->m_Orient; angle = pt_txt_pcb->m_Orient; Loading @@ -288,11 +304,11 @@ wxPoint ref; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; RotatePoint( &spot_cX, &spot_cY, -angle ); RotatePoint( &spot_cX, &spot_cY, -angle ); if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) return(pt_txt_pcb) ; return pt_txt_pcb; } return(NULL) ; } } return NULL; } /*****************************/ /*****************************/ Loading @@ -300,20 +316,20 @@ wxPoint ref; /*****************************/ /*****************************/ /* /* Calcul de la distance du curseur souris a un segment de droite : * Calcul de la distance du curseur souris a un segment de droite : ( piste, edge, contour module .. * ( piste, edge, contour module .. retourne: * retourne: 0 si distance > seuil * 0 si distance > seuil 1 si distance <= seuil * 1 si distance <= seuil Variables utilisees ( doivent etre initialisees avant appel , et * Variables utilisees ( doivent etre initialisees avant appel , et sont ramenees au repere centre sur l'origine du segment) * sont ramenees au repere centre sur l'origine du segment) dx, dy = coord de l'extremite segment. * dx, dy = coord de l'extremite segment. spot_cX,spot_cY = coord du curseur souris * spot_cX,spot_cY = coord du curseur souris la recherche se fait selon 4 cas: * la recherche se fait selon 4 cas: segment horizontal * segment horizontal segment vertical * segment vertical segment 45 * segment 45 segment quelconque * segment quelconque */ */ int distance( int seuil ) int distance( int seuil ) Loading @@ -321,7 +337,7 @@ int distance(int seuil) int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ segX, segY; /* coord extremite segment tj >= 0 */ segX, segY; /* coord extremite segment tj >= 0 */ int pointX, pointY;/* coord point a tester dans repere modifie dans lequel 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; segX = dx; segY = dy; pointX = spot_cX; pointY = spot_cY; Loading @@ -340,81 +356,84 @@ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel { { if( abs( pointY ) <= seuil ) 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 */ /* Etude des extremites : cercle de rayon seuil */ if( (pointX < 0) && (pointX >= -seuil) ) if( (pointX < 0) && (pointX >= -seuil) ) { { if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) ) if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) ) return(1); return 1; } } if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) { { if( (((pointX-segX) * (pointX-segX)) + (pointY*pointY)) <= (seuil*seuil) ) if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= return(1); (seuil * seuil) ) return 1; } } } } } } else if( segX == 0 ) /* piste verticale */ else if( segX == 0 ) /* piste verticale */ { { if( abs( pointX ) <= seuil ) 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 < 0) && (pointY >= -seuil) ) { { if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) ) if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) ) return(1); return 1; } } if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) { { if( ( ((pointY-segY) * (pointY-segY)) + (pointX*pointX)) <= (seuil*seuil) ) if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= return(1); (seuil * seuil) ) return 1; } } } } } } else if( segX == segY ) /* piste a 45 degre */ else if( segX == segY ) /* piste a 45 degre */ { { /* on fait tourner les axes de 45 degre. la souris a alors les /* on fait tourner les axes de 45 degre. la souris a alors les coord : x1 = x*cos45 + y*sin45 * coord : x1 = x*cos45 + y*sin45 y1 = y*cos45 - x*sin45 * y1 = y*cos45 - x*sin45 et le segment de piste est alors horizontal. * et le segment de piste est alors horizontal. recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 * recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 remarque : sin ou cos45 = .707, et lors du recalcul des coord * 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 * dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois trop grands. (c.a.d trop petits) * trop grands. (c.a.d trop petits) spot_cX,Y doit etre * par .707 * .707 = 0.5 */ * spot_cX,Y doit etre * par .707 * .707 = 0.5 */ cXrot = (pointX + pointY) >> 1; cXrot = (pointX + pointY) >> 1; cYrot = (pointY - pointX) >> 1; cYrot = (pointY - pointX) >> 1; /* recalcul des coord de l'extremite du segment , qui sera vertical /* recalcul des coord de l'extremite du segment , qui sera vertical suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) * suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) et est en fait 1,414 plus grand , et dy45 = 0 */ * 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 doit etre * .707 pour tenir compte du coeff de reduction sur dx,dy seuil *= 7; seuil /= 10; seuil *= 7; seuil /= 10; if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */ 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 */ /* Etude des extremites : cercle de rayon seuil */ if( (cXrot < 0) && (cXrot >= -seuil) ) if( (cXrot < 0) && (cXrot >= -seuil) ) { { if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) { { if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } } } } } else /* orientation quelconque */ else /* orientation quelconque */ { { /* On fait un changement d'axe (rotation) de facon a ce que le segment /* 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; int angle; angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI); angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI); Loading @@ -423,25 +442,24 @@ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel RotatePoint( &segX, &segY, angle ); /* Rotation du segment */ RotatePoint( &segX, &segY, angle ); /* Rotation du segment */ /*la piste est Horizontale , par suite des modifs de coordonnes /*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( 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 */ /* Etude des extremites : cercle de rayon seuil */ if( (cXrot < 0) && (cXrot >= -seuil) ) if( (cXrot < 0) && (cXrot >= -seuil) ) { { if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) { { if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) return(1); return 1; } } } } } } return(0) ; return 0; } }
include/base_struct.h +33 −1 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,7 @@ enum SEARCH_RESULT { typedef DrawStructureType KICAD_T; // shorter name typedef DrawStructureType KICAD_T; // shorter name class EDA_BaseStruct; class EDA_BaseStruct; class WinEDA_DrawFrame; /** /** * Class INSPECTOR * Class INSPECTOR Loading Loading @@ -132,7 +132,26 @@ public: EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */ EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */ EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */ EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */ int m_Flags; // flags for editions and other 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 unsigned long m_TimeStamp; // Time stamp used for logical links int m_Selected; /* Used by block commands, and selective editing */ int m_Selected; /* Used by block commands, and selective editing */ Loading Loading @@ -178,6 +197,19 @@ public: int draw_mode, int draw_mode, int Color = -1 ); 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 * Function HitTest * tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object. Loading