searching and beautifying
This commit is contained in:
parent
66080848cc
commit
c1e3416a8f
|
@ -5,6 +5,20 @@ Please add newer entries at the top, list the date and your name with
|
||||||
email address.
|
email address.
|
||||||
|
|
||||||
|
|
||||||
|
2007-Aug-08 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||||
|
================================================================================
|
||||||
|
+ pcbnew & common
|
||||||
|
* Renamed locate.cpp's distance() to DistanceTest() and moved it to trigo.cpp.
|
||||||
|
Pass more parameters to DistanceTest and removed globals that were used by
|
||||||
|
distance() in locate.cpp.
|
||||||
|
Moved and renamed DistanceTest function proto from protos.h to trigo.h.
|
||||||
|
* Implemented HitTest() for class_cotation, class_mire, and a few other classes
|
||||||
|
by factoring out existing code from locate.cpp. locate.cpp should operate
|
||||||
|
exactly the same as before.
|
||||||
|
* Detected that the suspected class_module hit-testing bug was not real,
|
||||||
|
i.e. no bug found.
|
||||||
|
|
||||||
|
|
||||||
2007-aug-08 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
2007-aug-08 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||||
================================================================================
|
================================================================================
|
||||||
+ eeschema
|
+ eeschema
|
||||||
|
|
159
common/trigo.cpp
159
common/trigo.cpp
|
@ -9,6 +9,163 @@
|
||||||
#include "trigo.h"
|
#include "trigo.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************/
|
||||||
|
bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY )
|
||||||
|
/*****************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calcul de la distance du curseur souris a un segment de droite :
|
||||||
|
* ( piste, edge, contour module ..
|
||||||
|
* retourne:
|
||||||
|
* false si distance > seuil
|
||||||
|
* true 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 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 = dx; segY = dy; pointX = spot_cX; pointY = spot_cY;
|
||||||
|
|
||||||
|
/*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/
|
||||||
|
if( segX < 0 ) /* mise en >0 par symetrie par rapport a l'axe Y */
|
||||||
|
{
|
||||||
|
segX = -segX; pointX = -pointX;
|
||||||
|
}
|
||||||
|
if( segY < 0 ) /* mise en > 0 par symetrie par rapport a l'axe X */
|
||||||
|
{
|
||||||
|
segY = -segY; pointY = -pointY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( segY == 0 ) /* piste Horizontale */
|
||||||
|
{
|
||||||
|
if( abs( pointY ) <= seuil )
|
||||||
|
{
|
||||||
|
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 true;
|
||||||
|
}
|
||||||
|
if( (pointX > segX) && ( pointX <= (segX + seuil) ) )
|
||||||
|
{
|
||||||
|
if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <=
|
||||||
|
(seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( segX == 0 ) /* piste verticale */
|
||||||
|
{
|
||||||
|
if( abs( pointX ) <= seuil )
|
||||||
|
{
|
||||||
|
if( (pointY >= 0 ) && (pointY <= segY) )
|
||||||
|
return true;
|
||||||
|
if( (pointY < 0) && (pointY >= -seuil) )
|
||||||
|
{
|
||||||
|
if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if( (pointY > segY) && ( pointY <= (segY + seuil) ) )
|
||||||
|
{
|
||||||
|
if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <=
|
||||||
|
(seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 */
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
// 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 true;
|
||||||
|
|
||||||
|
/* Etude des extremites : cercle de rayon seuil */
|
||||||
|
if( (cXrot < 0) && (cXrot >= -seuil) )
|
||||||
|
{
|
||||||
|
if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
|
||||||
|
{
|
||||||
|
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 */
|
||||||
|
int angle;
|
||||||
|
|
||||||
|
angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI);
|
||||||
|
cXrot = pointX; cYrot = pointY;
|
||||||
|
|
||||||
|
RotatePoint( &cXrot, &cYrot, angle ); /* Rotation du point a tester */
|
||||||
|
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 */
|
||||||
|
|
||||||
|
if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */
|
||||||
|
{
|
||||||
|
if( (cXrot >= 0) && (cXrot <= segX) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Etude des extremites : cercle de rayon seuil */
|
||||||
|
if( (cXrot < 0) && (cXrot >= -seuil) )
|
||||||
|
{
|
||||||
|
if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
|
||||||
|
{
|
||||||
|
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************/
|
/***********************************/
|
||||||
int ArcTangente( int dy, int dx )
|
int ArcTangente( int dy, int dx )
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
@ -217,3 +374,5 @@ void RotatePoint( double* pX, double* pY, int angle )
|
||||||
*pY = fpy;
|
*pY = fpy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetClass
|
* Function GetClass
|
||||||
* returns the class name.
|
* returns the class name.
|
||||||
|
@ -264,7 +263,7 @@ public:
|
||||||
* @param typeloc
|
* @param typeloc
|
||||||
* @return EDA_BaseStruct* - if a direct hit, else NULL.
|
* @return EDA_BaseStruct* - if a direct hit, else NULL.
|
||||||
*/
|
*/
|
||||||
EDA_BaseStruct* FindPadOrModule( const wxPoint& refPos, int layer, int typeloc );
|
EDA_BaseStruct* FindPadOrModule( const wxPoint& refPos, int layer );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -322,6 +321,27 @@ public:
|
||||||
void UnLink( void );
|
void UnLink( void );
|
||||||
|
|
||||||
void Copy( DRAWSEGMENT* source );
|
void Copy( DRAWSEGMENT* source );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param ref_pos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool HitTest( const wxPoint& ref_pos );
|
||||||
|
|
||||||
|
#if defined(DEBUG)
|
||||||
|
/**
|
||||||
|
* Function GetClass
|
||||||
|
* returns the class name.
|
||||||
|
* @return wxString
|
||||||
|
*/
|
||||||
|
wxString GetClass() const
|
||||||
|
{
|
||||||
|
return wxT("pgraphic");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#define TRIGO_H
|
#define TRIGO_H
|
||||||
|
|
||||||
|
|
||||||
/* Prototype des fonctions de TRIGO.CC */
|
/* Prototype des fonctions de trigo.cpp */
|
||||||
void RotatePoint(int *pX, int *pY, int angle);
|
void RotatePoint(int *pX, int *pY, int angle);
|
||||||
void RotatePoint(int *pX, int *pY, int cx, int cy, int angle);
|
void RotatePoint(int *pX, int *pY, int cx, int cy, int angle);
|
||||||
void RotatePoint(wxPoint *point, const wxPoint & centre, int angle);
|
void RotatePoint(wxPoint *point, const wxPoint & centre, int angle);
|
||||||
|
@ -19,6 +19,7 @@ int ArcTangente(int dy, int dx);
|
||||||
Analogue a atan2 ( mais plus rapide pour les caculs si
|
Analogue a atan2 ( mais plus rapide pour les caculs si
|
||||||
l'angle est souvent 0, -1800, ou +- 900 */
|
l'angle est souvent 0, -1800, ou +- 900 */
|
||||||
|
|
||||||
|
bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -290,75 +290,64 @@ void BOARD::Show( int nestLevel, std::ostream& os )
|
||||||
|
|
||||||
|
|
||||||
// see pcbstruct.h
|
// see pcbstruct.h
|
||||||
EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer, int typeloc )
|
EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
|
||||||
{
|
{
|
||||||
class PadOrModule : public INSPECTOR
|
class PadOrModule : public INSPECTOR
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EDA_BaseStruct* found;
|
EDA_BaseStruct* found;
|
||||||
int layer;
|
int layer;
|
||||||
int typeloc;
|
|
||||||
|
|
||||||
PadOrModule( int alayer, int atypeloc ) :
|
PadOrModule( int alayer ) :
|
||||||
found(0),
|
found(0), // found is NULL
|
||||||
layer(alayer),
|
layer(alayer)
|
||||||
typeloc(atypeloc) {}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
|
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
|
||||||
{
|
{
|
||||||
const wxPoint* refPos = (const wxPoint*) testData;
|
const wxPoint& refPos = *(const wxPoint*) testData;
|
||||||
|
|
||||||
if( testItem->m_StructType == TYPEMODULE )
|
if( testItem->m_StructType == TYPEPAD )
|
||||||
|
{
|
||||||
|
if( testItem->HitTest( refPos ) )
|
||||||
|
{
|
||||||
|
found = testItem;
|
||||||
|
return SEARCH_QUIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( testItem->m_StructType == TYPEMODULE )
|
||||||
{
|
{
|
||||||
int mlayer = ((MODULE*)testItem)->m_Layer;
|
int mlayer = ((MODULE*)testItem)->m_Layer;
|
||||||
|
|
||||||
if( typeloc & MATCH_LAYER )
|
// consider only visible modules
|
||||||
|
if( IsModuleLayerVisible( mlayer ) )
|
||||||
{
|
{
|
||||||
if( layer != mlayer )
|
if( testItem->HitTest( refPos ) )
|
||||||
return SEARCH_CONTINUE;
|
{
|
||||||
}
|
// save regardless of layer test, but only quit if
|
||||||
|
// layer matches, otherwise use this item if no future
|
||||||
|
// layer match.
|
||||||
|
found = testItem;
|
||||||
|
|
||||||
if( typeloc & VISIBLE_ONLY )
|
if( layer == mlayer )
|
||||||
{
|
return SEARCH_QUIT;
|
||||||
if( !IsModuleLayerVisible(mlayer) )
|
}
|
||||||
return SEARCH_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( testItem->HitTest( *refPos ) )
|
|
||||||
{
|
|
||||||
found = testItem;
|
|
||||||
return SEARCH_QUIT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( testItem->m_StructType == TYPEPAD )
|
|
||||||
{
|
|
||||||
if( testItem->HitTest( *refPos ) )
|
|
||||||
{
|
|
||||||
found = testItem;
|
|
||||||
return SEARCH_QUIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { int debug=1; /* this should not happen, because of scanTypes */ }
|
|
||||||
|
|
||||||
return SEARCH_CONTINUE;
|
return SEARCH_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PadOrModule inspector1( layer, MATCH_LAYER );
|
PadOrModule inspector( layer );
|
||||||
PadOrModule inspector2( layer, VISIBLE_ONLY );
|
|
||||||
|
|
||||||
|
// search only for PADs first, then MODULES, and preferably a layer match
|
||||||
static const KICAD_T scanTypes[] = { TYPEPAD, TYPEMODULE, EOT };
|
static const KICAD_T scanTypes[] = { TYPEPAD, TYPEMODULE, EOT };
|
||||||
|
|
||||||
// search the current layer first
|
IterateForward( m_Modules, &inspector, &refPos, scanTypes );
|
||||||
if( SEARCH_QUIT == IterateForward( m_Modules, &inspector1, &refPos, scanTypes ) )
|
|
||||||
return inspector1.found;
|
|
||||||
|
|
||||||
// if not found, set layer to don't care and search again
|
return inspector.found;
|
||||||
if( SEARCH_QUIT == IterateForward( m_Modules, &inspector2, &refPos, scanTypes ) )
|
|
||||||
return inspector2.found;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,348 +7,476 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "pcbnew.h"
|
#include "pcbnew.h"
|
||||||
|
#include "trigo.h"
|
||||||
|
|
||||||
|
COTATION::COTATION( EDA_BaseStruct* StructFather ) :
|
||||||
|
EDA_BaseStruct( StructFather, TYPECOTATION )
|
||||||
COTATION::COTATION(EDA_BaseStruct * StructFather):
|
|
||||||
EDA_BaseStruct( StructFather, TYPECOTATION)
|
|
||||||
{
|
{
|
||||||
m_Layer = DRAW_LAYER;
|
m_Layer = DRAW_LAYER;
|
||||||
m_Width = 50;
|
m_Width = 50;
|
||||||
m_Value = 0;
|
m_Value = 0;
|
||||||
m_Shape = 0;
|
m_Shape = 0;
|
||||||
m_Unit = INCHES;
|
m_Unit = INCHES;
|
||||||
m_Text = new TEXTE_PCB(this);
|
m_Text = new TEXTE_PCB( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Effacement memoire de la structure */
|
/* Effacement memoire de la structure */
|
||||||
COTATION::~COTATION(void)
|
COTATION::~COTATION( void )
|
||||||
{
|
{
|
||||||
delete m_Text;
|
delete m_Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct
|
/* supprime du chainage la structure Struct
|
||||||
les structures arrieres et avant sont chainees directement
|
* les structures arrieres et avant sont chainees directement
|
||||||
*/
|
*/
|
||||||
void COTATION::UnLink( void )
|
void COTATION::UnLink( void )
|
||||||
{
|
{
|
||||||
/* Modification du chainage arriere */
|
/* Modification du chainage arriere */
|
||||||
if( Pback )
|
if( Pback )
|
||||||
{
|
{
|
||||||
if( Pback->m_StructType != TYPEPCB)
|
if( Pback->m_StructType != TYPEPCB )
|
||||||
{
|
{
|
||||||
Pback->Pnext = Pnext;
|
Pback->Pnext = Pnext;
|
||||||
}
|
}
|
||||||
|
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||||
|
{
|
||||||
|
( (BOARD*) Pback )->m_Drawings = Pnext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
/* Modification du chainage avant */
|
||||||
{
|
if( Pnext )
|
||||||
((BOARD*)Pback)->m_Drawings = Pnext;
|
Pnext->Pback = Pback;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modification du chainage avant */
|
Pnext = Pback = NULL;
|
||||||
if( Pnext) Pnext->Pback = Pback;
|
|
||||||
|
|
||||||
Pnext = Pback = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Changement du texte de la cotation */
|
/* Changement du texte de la cotation */
|
||||||
void COTATION:: SetText(const wxString & NewText)
|
void COTATION:: SetText( const wxString& NewText )
|
||||||
{
|
{
|
||||||
m_Text->m_Text = NewText;
|
m_Text->m_Text = NewText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************/
|
/*************************************/
|
||||||
void COTATION::Copy(COTATION * source)
|
void COTATION::Copy( COTATION* source )
|
||||||
/*************************************/
|
/*************************************/
|
||||||
{
|
{
|
||||||
m_Value = source->m_Value;
|
m_Value = source->m_Value;
|
||||||
m_Layer = source->m_Layer;
|
m_Layer = source->m_Layer;
|
||||||
m_Width = source->m_Width;
|
m_Width = source->m_Width;
|
||||||
m_Pos = source->m_Pos;
|
m_Pos = source->m_Pos;
|
||||||
m_Shape = source->m_Shape;
|
m_Shape = source->m_Shape;
|
||||||
m_Unit = source->m_Unit;
|
m_Unit = source->m_Unit;
|
||||||
m_TimeStamp = GetTimeStamp();
|
m_TimeStamp = GetTimeStamp();
|
||||||
m_Text->Copy(source->m_Text);
|
m_Text->Copy( source->m_Text );
|
||||||
|
|
||||||
Barre_ox = source->Barre_ox; Barre_oy = source->Barre_oy;
|
Barre_ox = source->Barre_ox; Barre_oy = source->Barre_oy;
|
||||||
Barre_fx = source->Barre_fx; Barre_fy = source->Barre_fy;
|
Barre_fx = source->Barre_fx; Barre_fy = source->Barre_fy;
|
||||||
TraitG_ox = source->TraitG_ox; TraitG_oy = source->TraitG_oy;
|
TraitG_ox = source->TraitG_ox; TraitG_oy = source->TraitG_oy;
|
||||||
TraitG_fx = source->TraitG_fx; TraitG_fy = source->TraitG_fy;
|
TraitG_fx = source->TraitG_fx; TraitG_fy = source->TraitG_fy;
|
||||||
TraitD_ox = source->TraitD_ox; TraitD_oy = source->TraitD_oy;
|
TraitD_ox = source->TraitD_ox; TraitD_oy = source->TraitD_oy;
|
||||||
TraitD_fx = source->TraitD_fx; TraitD_fy = source->TraitD_fy;
|
TraitD_fx = source->TraitD_fx; TraitD_fy = source->TraitD_fy;
|
||||||
FlecheD1_ox = source->FlecheD1_ox; FlecheD1_oy = source->FlecheD1_oy;
|
FlecheD1_ox = source->FlecheD1_ox; FlecheD1_oy = source->FlecheD1_oy;
|
||||||
FlecheD1_fx = source->FlecheD1_fx; FlecheD1_fy = source->FlecheD1_fy;
|
FlecheD1_fx = source->FlecheD1_fx; FlecheD1_fy = source->FlecheD1_fy;
|
||||||
FlecheD2_ox = source->FlecheD2_ox; FlecheD2_oy = source->FlecheD2_oy;
|
FlecheD2_ox = source->FlecheD2_ox; FlecheD2_oy = source->FlecheD2_oy;
|
||||||
FlecheD2_fx = source->FlecheD2_fx; FlecheD2_fy = source->FlecheD2_fy;
|
FlecheD2_fx = source->FlecheD2_fx; FlecheD2_fy = source->FlecheD2_fy;
|
||||||
FlecheG1_ox = source->FlecheG1_ox; FlecheG1_oy = source->FlecheG1_oy;
|
FlecheG1_ox = source->FlecheG1_ox; FlecheG1_oy = source->FlecheG1_oy;
|
||||||
FlecheG1_fx = source->FlecheG1_fx; FlecheG1_fy = source->FlecheG1_fy;
|
FlecheG1_fx = source->FlecheG1_fx; FlecheG1_fy = source->FlecheG1_fy;
|
||||||
FlecheG2_ox = source->FlecheG2_ox; FlecheG2_oy = source->FlecheG2_oy;
|
FlecheG2_ox = source->FlecheG2_ox; FlecheG2_oy = source->FlecheG2_oy;
|
||||||
FlecheG2_fx = source->FlecheG2_fx; FlecheG2_fy = source->FlecheG2_fy;
|
FlecheG2_fx = source->FlecheG2_fx; FlecheG2_fy = source->FlecheG2_fy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
bool COTATION::ReadCotationDescr(FILE * File, int * LineNum)
|
bool COTATION::ReadCotationDescr( FILE* File, int* LineNum )
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
{
|
{
|
||||||
char Line[2048], Text[2048];
|
char Line[2048], Text[2048];
|
||||||
|
|
||||||
while( GetLine(File, Line, LineNum ) != NULL )
|
while( GetLine( File, Line, LineNum ) != NULL )
|
||||||
{
|
{
|
||||||
if(strnicmp(Line,"$EndCOTATION",4) == 0) return TRUE;
|
if( strnicmp( Line, "$EndCOTATION", 4 ) == 0 )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if(Line[0] == 'V')
|
if( Line[0] == 'V' )
|
||||||
{
|
{
|
||||||
sscanf( Line+2," %d",&m_Value);
|
sscanf( Line + 2, " %d", &m_Value );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Line[0] == 'G')
|
if( Line[0] == 'G' )
|
||||||
{
|
{
|
||||||
sscanf( Line+2," %d %d %lX",&m_Shape, &m_Layer, &m_TimeStamp);
|
sscanf( Line + 2, " %d %d %lX", &m_Shape, &m_Layer, &m_TimeStamp );
|
||||||
|
|
||||||
/* Mise a jour des param .layer des sous structures */
|
/* Mise a jour des param .layer des sous structures */
|
||||||
if ( m_Layer < FIRST_NO_COPPER_LAYER )
|
if( m_Layer < FIRST_NO_COPPER_LAYER )
|
||||||
m_Layer = FIRST_NO_COPPER_LAYER;
|
m_Layer = FIRST_NO_COPPER_LAYER;
|
||||||
if ( m_Layer > LAST_NO_COPPER_LAYER )
|
if( m_Layer > LAST_NO_COPPER_LAYER )
|
||||||
m_Layer = LAST_NO_COPPER_LAYER;
|
m_Layer = LAST_NO_COPPER_LAYER;
|
||||||
|
|
||||||
m_Text->m_Layer = m_Layer;
|
m_Text->m_Layer = m_Layer;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Line[0] == 'T')
|
if( Line[0] == 'T' )
|
||||||
{
|
{
|
||||||
ReadDelimitedText(Text, Line+2, sizeof(Text) );
|
ReadDelimitedText( Text, Line + 2, sizeof(Text) );
|
||||||
m_Text->m_Text = CONV_FROM_UTF8(Text);
|
m_Text->m_Text = CONV_FROM_UTF8( Text );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Line[0] == 'P')
|
if( Line[0] == 'P' )
|
||||||
{
|
{
|
||||||
sscanf( Line+2," %d %d %d %d %d %d %d",
|
sscanf( Line + 2, " %d %d %d %d %d %d %d",
|
||||||
&m_Text->m_Pos.x, &m_Text->m_Pos.y,
|
&m_Text->m_Pos.x, &m_Text->m_Pos.y,
|
||||||
&m_Text->m_Size.x, &m_Text->m_Size.y,
|
&m_Text->m_Size.x, &m_Text->m_Size.y,
|
||||||
&m_Text->m_Width,&m_Text->m_Orient,
|
&m_Text->m_Width, &m_Text->m_Orient,
|
||||||
&m_Text->m_Miroir);
|
&m_Text->m_Miroir );
|
||||||
|
|
||||||
m_Pos = m_Text->m_Pos;
|
m_Pos = m_Text->m_Pos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Line[0] == 'S')
|
if( Line[0] == 'S' )
|
||||||
{
|
{
|
||||||
switch( Line[1] )
|
switch( Line[1] )
|
||||||
{
|
{
|
||||||
int Dummy;
|
int Dummy;
|
||||||
case 'b' :
|
|
||||||
sscanf( Line+2," %d %d %d %d %d %d",
|
|
||||||
&Dummy,
|
|
||||||
&Barre_ox, &Barre_oy,
|
|
||||||
&Barre_fx, &Barre_fy,
|
|
||||||
&m_Width );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd':
|
case 'b':
|
||||||
sscanf( Line+2," %d %d %d %d %d %d",
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
||||||
&Dummy,
|
&Dummy,
|
||||||
&TraitD_ox, &TraitD_oy,
|
&Barre_ox, &Barre_oy,
|
||||||
&TraitD_fx, &TraitD_fy,
|
&Barre_fx, &Barre_fy,
|
||||||
&Dummy );
|
&m_Width );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'g':
|
case 'd':
|
||||||
sscanf( Line+2," %d %d %d %d %d %d",
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
||||||
&Dummy,
|
&Dummy,
|
||||||
&TraitG_ox, &TraitG_oy,
|
&TraitD_ox, &TraitD_oy,
|
||||||
&TraitG_fx, &TraitG_fy,
|
&TraitD_fx, &TraitD_fy,
|
||||||
&Dummy );
|
&Dummy );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1':
|
case 'g':
|
||||||
sscanf( Line+2," %d %d %d %d %d %d",
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
||||||
&Dummy,
|
&Dummy,
|
||||||
&FlecheD1_ox, &FlecheD1_oy,
|
&TraitG_ox, &TraitG_oy,
|
||||||
&FlecheD1_fx, &FlecheD1_fy,
|
&TraitG_fx, &TraitG_fy,
|
||||||
&Dummy );
|
&Dummy );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '2':
|
case '1':
|
||||||
sscanf( Line+2," %d %d %d %d %d %d",
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
||||||
&Dummy,
|
&Dummy,
|
||||||
&FlecheD2_ox, &FlecheD2_oy,
|
&FlecheD1_ox, &FlecheD1_oy,
|
||||||
&FlecheD2_fx, &FlecheD2_fy,
|
&FlecheD1_fx, &FlecheD1_fy,
|
||||||
&Dummy );
|
&Dummy );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '3':
|
case '2':
|
||||||
sscanf( Line+2," %d %d %d %d %d %d\n",
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
||||||
&Dummy,
|
&Dummy,
|
||||||
&FlecheG1_ox, &FlecheG1_oy,
|
&FlecheD2_ox, &FlecheD2_oy,
|
||||||
&FlecheG1_fx, &FlecheG1_fy,
|
&FlecheD2_fx, &FlecheD2_fy,
|
||||||
&Dummy);
|
&Dummy );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '4':
|
case '3':
|
||||||
sscanf( Line+2," %d %d %d %d %d %d",
|
sscanf( Line + 2, " %d %d %d %d %d %d\n",
|
||||||
&Dummy,
|
&Dummy,
|
||||||
&FlecheG2_ox, &FlecheG2_oy,
|
&FlecheG1_ox, &FlecheG1_oy,
|
||||||
&FlecheG2_fx, &FlecheG2_fy,
|
&FlecheG1_fx, &FlecheG1_fy,
|
||||||
&Dummy );
|
&Dummy );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
case '4':
|
||||||
}
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
||||||
}
|
&Dummy,
|
||||||
return FALSE;
|
&FlecheG2_ox, &FlecheG2_oy,
|
||||||
|
&FlecheG2_fx, &FlecheG2_fy,
|
||||||
|
&Dummy );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
bool COTATION::WriteCotationDescr(FILE * File)
|
bool COTATION::WriteCotationDescr( FILE* File )
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
{
|
{
|
||||||
if( GetState(DELETED) ) return FALSE;
|
if( GetState( DELETED ) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
fprintf( File, "$COTATION\n");
|
fprintf( File, "$COTATION\n" );
|
||||||
|
|
||||||
fprintf( File,"Ge %d %d %lX\n",m_Shape,
|
fprintf( File, "Ge %d %d %lX\n", m_Shape,
|
||||||
m_Layer, m_TimeStamp);
|
m_Layer, m_TimeStamp );
|
||||||
|
|
||||||
fprintf( File,"Va %d\n",m_Value);
|
fprintf( File, "Va %d\n", m_Value );
|
||||||
|
|
||||||
if( ! m_Text->m_Text.IsEmpty() )
|
if( !m_Text->m_Text.IsEmpty() )
|
||||||
fprintf( File,"Te \"%s\"\n",CONV_TO_UTF8(m_Text->m_Text));
|
fprintf( File, "Te \"%s\"\n", CONV_TO_UTF8( m_Text->m_Text ) );
|
||||||
else fprintf( File,"Te \"?\"\n");
|
else
|
||||||
|
fprintf( File, "Te \"?\"\n" );
|
||||||
|
|
||||||
fprintf( File,"Po %d %d %d %d %d %d %d\n",
|
fprintf( File, "Po %d %d %d %d %d %d %d\n",
|
||||||
m_Text->m_Pos.x, m_Text->m_Pos.y,
|
m_Text->m_Pos.x, m_Text->m_Pos.y,
|
||||||
m_Text->m_Size.x, m_Text->m_Size.y,
|
m_Text->m_Size.x, m_Text->m_Size.y,
|
||||||
m_Text->m_Width,m_Text->m_Orient,
|
m_Text->m_Width, m_Text->m_Orient,
|
||||||
m_Text->m_Miroir);
|
m_Text->m_Miroir );
|
||||||
|
|
||||||
fprintf( File,"Sb %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
Barre_ox, Barre_oy,
|
Barre_ox, Barre_oy,
|
||||||
Barre_fx, Barre_fy, m_Width );
|
Barre_fx, Barre_fy, m_Width );
|
||||||
|
|
||||||
fprintf( File,"Sd %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "Sd %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
TraitD_ox, TraitD_oy,
|
TraitD_ox, TraitD_oy,
|
||||||
TraitD_fx, TraitD_fy, m_Width );
|
TraitD_fx, TraitD_fy, m_Width );
|
||||||
|
|
||||||
fprintf( File,"Sg %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "Sg %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
TraitG_ox, TraitG_oy,
|
TraitG_ox, TraitG_oy,
|
||||||
TraitG_fx, TraitG_fy, m_Width );
|
TraitG_fx, TraitG_fy, m_Width );
|
||||||
|
|
||||||
fprintf( File,"S1 %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "S1 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
FlecheD1_ox, FlecheD1_oy,
|
FlecheD1_ox, FlecheD1_oy,
|
||||||
FlecheD1_fx, FlecheD1_fy, m_Width );
|
FlecheD1_fx, FlecheD1_fy, m_Width );
|
||||||
|
|
||||||
fprintf( File,"S2 %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "S2 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
FlecheD2_ox, FlecheD2_oy,
|
FlecheD2_ox, FlecheD2_oy,
|
||||||
FlecheD2_fx, FlecheD2_fy, m_Width );
|
FlecheD2_fx, FlecheD2_fy, m_Width );
|
||||||
|
|
||||||
|
|
||||||
fprintf( File,"S3 %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "S3 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
FlecheG1_ox, FlecheG1_oy,
|
FlecheG1_ox, FlecheG1_oy,
|
||||||
FlecheG1_fx, FlecheG1_fy, m_Width );
|
FlecheG1_fx, FlecheG1_fy, m_Width );
|
||||||
|
|
||||||
fprintf( File,"S4 %d %d %d %d %d %d\n",S_SEGMENT,
|
fprintf( File, "S4 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||||
FlecheG2_ox, FlecheG2_oy,
|
FlecheG2_ox, FlecheG2_oy,
|
||||||
FlecheG2_fx, FlecheG2_fy, m_Width );
|
FlecheG2_fx, FlecheG2_fy, m_Width );
|
||||||
|
|
||||||
fprintf( File, "$EndCOTATION\n");
|
fprintf( File, "$EndCOTATION\n" );
|
||||||
|
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void COTATION::Draw(WinEDA_DrawPanel * panel , wxDC * DC,
|
void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
const wxPoint & offset, int mode_color)
|
const wxPoint& offset, int mode_color )
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
/* impression de 1 cotation : serie de n segments + 1 texte
|
/* impression de 1 cotation : serie de n segments + 1 texte
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int ox, oy, typeaff, width, gcolor;
|
int ox, oy, typeaff, width, gcolor;
|
||||||
int zoom = panel->GetScreen()->GetZoom();
|
int zoom = panel->GetScreen()->GetZoom();
|
||||||
|
|
||||||
ox = offset.x;
|
ox = offset.x;
|
||||||
oy = offset.y;
|
oy = offset.y;
|
||||||
|
|
||||||
m_Text->Draw(panel, DC, offset, mode_color );
|
m_Text->Draw( panel, DC, offset, mode_color );
|
||||||
|
|
||||||
gcolor = g_DesignSettings.m_LayerColor[m_Layer];
|
gcolor = g_DesignSettings.m_LayerColor[m_Layer];
|
||||||
if( (gcolor & ITEM_NOT_SHOW) != 0 ) return ;
|
if( (gcolor & ITEM_NOT_SHOW) != 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
GRSetDrawMode(DC, mode_color);
|
GRSetDrawMode( DC, mode_color );
|
||||||
typeaff = DisplayOpt.DisplayDrawItems;
|
typeaff = DisplayOpt.DisplayDrawItems;
|
||||||
width = m_Width;
|
|
||||||
if( width/zoom < 2 ) typeaff = FILAIRE;
|
|
||||||
|
|
||||||
switch( typeaff )
|
width = m_Width;
|
||||||
{
|
if( width / zoom < 2 )
|
||||||
case FILAIRE:
|
typeaff = FILAIRE;
|
||||||
width = 0;
|
|
||||||
case FILLED:
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
Barre_ox - ox, Barre_oy - oy,
|
|
||||||
Barre_fx - ox, Barre_fy- oy, width, gcolor);
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
TraitG_ox - ox, TraitG_oy - oy,
|
|
||||||
TraitG_fx - ox, TraitG_fy- oy, width, gcolor);
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
TraitD_ox - ox, TraitD_oy - oy,
|
|
||||||
TraitD_fx - ox, TraitD_fy- oy, width, gcolor);
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
FlecheD1_ox - ox, FlecheD1_oy - oy,
|
|
||||||
FlecheD1_fx - ox, FlecheD1_fy- oy, width, gcolor);
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
FlecheD2_ox - ox, FlecheD2_oy - oy,
|
|
||||||
FlecheD2_fx - ox, FlecheD2_fy- oy, width, gcolor);
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
FlecheG1_ox - ox, FlecheG1_oy - oy,
|
|
||||||
FlecheG1_fx - ox, FlecheG1_fy- oy, width, gcolor);
|
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
|
||||||
FlecheG2_ox - ox, FlecheG2_oy - oy,
|
|
||||||
FlecheG2_fx - ox, FlecheG2_fy- oy, width, gcolor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKETCH:
|
switch( typeaff )
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
{
|
||||||
Barre_ox - ox, Barre_oy - oy,
|
case FILAIRE:
|
||||||
Barre_fx - ox, Barre_fy- oy,
|
width = 0;
|
||||||
width, gcolor);
|
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
case FILLED:
|
||||||
TraitG_ox - ox, TraitG_oy - oy,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
TraitG_fx - ox, TraitG_fy- oy,
|
Barre_ox - ox, Barre_oy - oy,
|
||||||
width, gcolor);
|
Barre_fx - ox, Barre_fy - oy, width, gcolor );
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
TraitD_ox - ox, TraitD_oy - oy,
|
TraitG_ox - ox, TraitG_oy - oy,
|
||||||
TraitD_fx - ox, TraitD_fy- oy,
|
TraitG_fx - ox, TraitG_fy - oy, width, gcolor );
|
||||||
width, gcolor);
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
TraitD_ox - ox, TraitD_oy - oy,
|
||||||
FlecheD1_ox - ox, FlecheD1_oy - oy,
|
TraitD_fx - ox, TraitD_fy - oy, width, gcolor );
|
||||||
FlecheD1_fx - ox, FlecheD1_fy- oy,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
width, gcolor);
|
FlecheD1_ox - ox, FlecheD1_oy - oy,
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
FlecheD1_fx - ox, FlecheD1_fy - oy, width, gcolor );
|
||||||
FlecheD2_ox - ox, FlecheD2_oy - oy,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
FlecheD2_fx - ox, FlecheD2_fy- oy,
|
FlecheD2_ox - ox, FlecheD2_oy - oy,
|
||||||
width, gcolor);
|
FlecheD2_fx - ox, FlecheD2_fy - oy, width, gcolor );
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
FlecheG1_ox - ox, FlecheG1_oy - oy,
|
FlecheG1_ox - ox, FlecheG1_oy - oy,
|
||||||
FlecheG1_fx - ox, FlecheG1_fy- oy,
|
FlecheG1_fx - ox, FlecheG1_fy - oy, width, gcolor );
|
||||||
width, gcolor);
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
FlecheG2_ox - ox, FlecheG2_oy - oy,
|
||||||
FlecheG2_ox - ox, FlecheG2_oy - oy,
|
FlecheG2_fx - ox, FlecheG2_fy - oy, width, gcolor );
|
||||||
FlecheG2_fx - ox, FlecheG2_fy - oy,
|
break;
|
||||||
width, gcolor);
|
|
||||||
break;
|
case SKETCH:
|
||||||
}
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
Barre_ox - ox, Barre_oy - oy,
|
||||||
|
Barre_fx - ox, Barre_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
TraitG_ox - ox, TraitG_oy - oy,
|
||||||
|
TraitG_fx - ox, TraitG_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
TraitD_ox - ox, TraitD_oy - oy,
|
||||||
|
TraitD_fx - ox, TraitD_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
FlecheD1_ox - ox, FlecheD1_oy - oy,
|
||||||
|
FlecheD1_fx - ox, FlecheD1_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
FlecheD2_ox - ox, FlecheD2_oy - oy,
|
||||||
|
FlecheD2_fx - ox, FlecheD2_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
FlecheG1_ox - ox, FlecheG1_oy - oy,
|
||||||
|
FlecheG1_fx - ox, FlecheG1_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
|
FlecheG2_ox - ox, FlecheG2_oy - oy,
|
||||||
|
FlecheG2_fx - ox, FlecheG2_fy - oy,
|
||||||
|
width, gcolor );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param ref_pos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool COTATION::HitTest( const wxPoint& ref_pos )
|
||||||
|
{
|
||||||
|
int ux0, uy0;
|
||||||
|
int dx, dy, spot_cX, spot_cY;
|
||||||
|
|
||||||
|
if( m_Text )
|
||||||
|
{
|
||||||
|
// because HitTest() is present in both base classes of TEXTE_PCB
|
||||||
|
// use a clarifying cast to tell compiler which HitTest()
|
||||||
|
// to call.
|
||||||
|
if( static_cast<EDA_TextStruct*>(m_Text)->HitTest( ref_pos ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Localisation des SEGMENTS ?) */
|
||||||
|
ux0 = Barre_ox;
|
||||||
|
uy0 = Barre_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = Barre_fx - ux0;
|
||||||
|
dy = Barre_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ux0 = TraitG_ox;
|
||||||
|
uy0 = TraitG_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = TraitG_fx - ux0;
|
||||||
|
dy = TraitG_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
/* detection : */
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ux0 = TraitD_ox;
|
||||||
|
uy0 = TraitD_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = TraitD_fx - ux0;
|
||||||
|
dy = TraitD_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
/* detection : */
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ux0 = FlecheD1_ox;
|
||||||
|
uy0 = FlecheD1_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = FlecheD1_fx - ux0;
|
||||||
|
dy = FlecheD1_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
/* detection : */
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ux0 = FlecheD2_ox;
|
||||||
|
uy0 = FlecheD2_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = FlecheD2_fx - ux0;
|
||||||
|
dy = FlecheD2_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ux0 = FlecheG1_ox;
|
||||||
|
uy0 = FlecheG1_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = FlecheG1_fx - ux0;
|
||||||
|
dy = FlecheG1_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ux0 = FlecheG2_ox;
|
||||||
|
uy0 = FlecheG2_oy;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
dx = FlecheG2_fx - ux0;
|
||||||
|
dy = FlecheG2_fy - uy0;
|
||||||
|
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,42 +6,62 @@
|
||||||
|
|
||||||
#include "base_struct.h"
|
#include "base_struct.h"
|
||||||
|
|
||||||
class COTATION: public EDA_BaseStruct
|
class COTATION : public EDA_BaseStruct
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int m_Layer; // 0.. 32 ( NON bit a bit)
|
int m_Layer; // 0.. 32 ( NON bit a bit)
|
||||||
int m_Width;
|
int m_Width;
|
||||||
wxPoint m_Pos;
|
wxPoint m_Pos;
|
||||||
int m_Shape;
|
int m_Shape;
|
||||||
int m_Unit; /* 0 = inches, 1 = mm */
|
int m_Unit; /* 0 = inches, 1 = mm */
|
||||||
int m_Value; /* valeur en unites PCB de la cote */
|
int m_Value; /* valeur en unites PCB de la cote */
|
||||||
|
|
||||||
TEXTE_PCB * m_Text; /* pour affichage du texte */
|
TEXTE_PCB* m_Text; /* pour affichage du texte */
|
||||||
int Barre_ox, Barre_oy, Barre_fx, Barre_fy;
|
int Barre_ox, Barre_oy, Barre_fx, Barre_fy;
|
||||||
int TraitG_ox, TraitG_oy, TraitG_fx, TraitG_fy;
|
int TraitG_ox, TraitG_oy, TraitG_fx, TraitG_fy;
|
||||||
int TraitD_ox, TraitD_oy, TraitD_fx, TraitD_fy;
|
int TraitD_ox, TraitD_oy, TraitD_fx, TraitD_fy;
|
||||||
int FlecheD1_ox, FlecheD1_oy, FlecheD1_fx, FlecheD1_fy;
|
int FlecheD1_ox, FlecheD1_oy, FlecheD1_fx, FlecheD1_fy;
|
||||||
int FlecheD2_ox, FlecheD2_oy, FlecheD2_fx, FlecheD2_fy;
|
int FlecheD2_ox, FlecheD2_oy, FlecheD2_fx, FlecheD2_fy;
|
||||||
int FlecheG1_ox, FlecheG1_oy, FlecheG1_fx, FlecheG1_fy;
|
int FlecheG1_ox, FlecheG1_oy, FlecheG1_fx, FlecheG1_fy;
|
||||||
int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy;
|
int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
COTATION(EDA_BaseStruct * StructFather);
|
COTATION( EDA_BaseStruct* StructFather );
|
||||||
~COTATION(void);
|
~COTATION( void );
|
||||||
|
|
||||||
bool ReadCotationDescr(FILE * File, int * LineNum);
|
bool ReadCotationDescr( FILE* File, int* LineNum );
|
||||||
bool WriteCotationDescr(FILE * File);
|
bool WriteCotationDescr( FILE* File );
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct */
|
/* supprime du chainage la structure Struct */
|
||||||
void UnLink( void );
|
void UnLink( void );
|
||||||
|
|
||||||
/* Modification du texte de la cotation */
|
/* Modification du texte de la cotation */
|
||||||
void SetText(const wxString & NewText);
|
void SetText( const wxString& NewText );
|
||||||
|
|
||||||
void Copy(COTATION * source);
|
void Copy( COTATION* source );
|
||||||
|
|
||||||
void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int mode_color);
|
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int mode_color );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param ref_pos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool HitTest( const wxPoint& ref_pos );
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(DEBUG)
|
||||||
|
/**
|
||||||
|
* Function GetClass
|
||||||
|
* returns the class name.
|
||||||
|
* @return wxString
|
||||||
|
*/
|
||||||
|
wxString GetClass() const
|
||||||
|
{
|
||||||
|
return wxT( "DIMENSION" );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #define COTATION_H
|
#endif // #define COTATION_H
|
||||||
|
|
|
@ -438,6 +438,73 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool EDGE_MODULE::HitTest( const wxPoint& ref_pos )
|
||||||
|
{
|
||||||
|
int uxf, uyf;
|
||||||
|
int rayon, dist;
|
||||||
|
int dx, dy, spot_cX, spot_cY;
|
||||||
|
int ux0, uy0;
|
||||||
|
|
||||||
|
ux0 = m_Start.x;
|
||||||
|
uy0 = m_Start.y;
|
||||||
|
|
||||||
|
uxf = m_End.x;
|
||||||
|
uyf = m_End.y;
|
||||||
|
|
||||||
|
switch( m_Shape )
|
||||||
|
{
|
||||||
|
case S_SEGMENT:
|
||||||
|
/* recalcul des coordonnees avec ux0,uy0 = origine des coord. */
|
||||||
|
spot_cX = ref_pos.x - ux0;
|
||||||
|
spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
dx = uxf - ux0;
|
||||||
|
dy = uyf - uy0;
|
||||||
|
if( DistanceTest( m_Width/2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_CIRCLE:
|
||||||
|
rayon = (int) hypot( (double) (uxf - ux0), (double) (uyf - uy0) );
|
||||||
|
dist = (int) hypot( (double) (ref_pos.x - ux0), (double) (ref_pos.y - uy0) );
|
||||||
|
if( abs( rayon - dist ) <= m_Width )
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_ARC:
|
||||||
|
rayon = (int) hypot( (double) (uxf - ux0), (double) (uyf - uy0) );
|
||||||
|
dist = (int) hypot( (double) (ref_pos.x - ux0), (double) (ref_pos.y - uy0) );
|
||||||
|
|
||||||
|
if( abs( rayon - dist ) > m_Width )
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* pour un arc, controle complementaire */
|
||||||
|
int mouseAngle = (int) ArcTangente( ref_pos.y - uy0, ref_pos.x - ux0 );
|
||||||
|
int stAngle = (int) ArcTangente( uyf - uy0, uxf - ux0 );
|
||||||
|
int endAngle = stAngle + m_Angle;
|
||||||
|
|
||||||
|
if( endAngle > 3600 )
|
||||||
|
{
|
||||||
|
stAngle -= 3600;
|
||||||
|
endAngle -= 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (mouseAngle >= stAngle) && (mouseAngle <= endAngle) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // an unknown m_Shape also returns false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
/**
|
/**
|
||||||
* Function Show
|
* Function Show
|
||||||
|
|
|
@ -42,6 +42,14 @@ public:
|
||||||
int draw_mode );
|
int draw_mode );
|
||||||
void Draw3D( Pcb3D_GLCanvas* glcanvas );
|
void Draw3D( Pcb3D_GLCanvas* glcanvas );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool HitTest( const wxPoint& refPos );
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
/**
|
/**
|
||||||
* Function GetClass
|
* Function GetClass
|
||||||
|
@ -50,7 +58,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual wxString GetClass() const
|
virtual wxString GetClass() const
|
||||||
{
|
{
|
||||||
return wxT( "GRAPHIC" );
|
return wxT( "MGRAPHIC" );
|
||||||
// return wxT( "EDGE" ); ?
|
// return wxT( "EDGE" ); ?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
#include "pcbnew.h"
|
#include "pcbnew.h"
|
||||||
|
|
||||||
|
|
||||||
|
MIREPCB::MIREPCB( EDA_BaseStruct* StructFather ) :
|
||||||
MIREPCB::MIREPCB(EDA_BaseStruct * StructFather):
|
EDA_BaseStruct( StructFather, TYPEMIRE )
|
||||||
EDA_BaseStruct( StructFather, TYPEMIRE)
|
|
||||||
{
|
{
|
||||||
m_Shape = 0;
|
m_Shape = 0;
|
||||||
m_Size = 5000;
|
m_Size = 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
MIREPCB::~MIREPCB(void)
|
|
||||||
|
MIREPCB::~MIREPCB( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,161 +25,186 @@ MIREPCB::~MIREPCB(void)
|
||||||
/***************************/
|
/***************************/
|
||||||
void MIREPCB::UnLink( void )
|
void MIREPCB::UnLink( void )
|
||||||
/***************************/
|
/***************************/
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct
|
/* supprime du chainage la structure Struct
|
||||||
les structures arrieres et avant sont chainees directement
|
* les structures arrieres et avant sont chainees directement
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Modification du chainage arriere */
|
/* Modification du chainage arriere */
|
||||||
if( Pback )
|
if( Pback )
|
||||||
{
|
{
|
||||||
if( Pback->m_StructType != TYPEPCB)
|
if( Pback->m_StructType != TYPEPCB )
|
||||||
{
|
{
|
||||||
Pback->Pnext = Pnext;
|
Pback->Pnext = Pnext;
|
||||||
}
|
}
|
||||||
|
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||||
|
{
|
||||||
|
( (BOARD*) Pback )->m_Drawings = Pnext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
/* Modification du chainage avant */
|
||||||
{
|
if( Pnext )
|
||||||
((BOARD*)Pback)->m_Drawings = Pnext;
|
Pnext->Pback = Pback;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modification du chainage avant */
|
Pnext = Pback = NULL;
|
||||||
if( Pnext) Pnext->Pback = Pback;
|
|
||||||
|
|
||||||
Pnext = Pback = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
void MIREPCB::Copy(MIREPCB * source)
|
void MIREPCB::Copy( MIREPCB* source )
|
||||||
/**********************************/
|
/**********************************/
|
||||||
{
|
{
|
||||||
m_Layer = source->m_Layer;
|
m_Layer = source->m_Layer;
|
||||||
m_Width = source->m_Width;
|
m_Width = source->m_Width;
|
||||||
m_Pos = source->m_Pos;
|
m_Pos = source->m_Pos;
|
||||||
m_Shape = source->m_Shape;
|
m_Shape = source->m_Shape;
|
||||||
m_Size = source->m_Size;
|
m_Size = source->m_Size;
|
||||||
m_TimeStamp = GetTimeStamp();
|
m_TimeStamp = GetTimeStamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
bool MIREPCB::ReadMirePcbDescr(FILE * File, int * LineNum)
|
bool MIREPCB::ReadMirePcbDescr( FILE* File, int* LineNum )
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
/* Lecture de la description de 1 segment type Drawing PCB
|
/* Lecture de la description de 1 segment type Drawing PCB
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
char Line[256];
|
char Line[256];
|
||||||
|
|
||||||
while( GetLine(File, Line, LineNum ) != NULL )
|
while( GetLine( File, Line, LineNum ) != NULL )
|
||||||
{
|
{
|
||||||
if(strnicmp(Line,"$End",4 ) == 0 ) return TRUE; /* fin de liste */
|
if( strnicmp( Line, "$End", 4 ) == 0 )
|
||||||
if(Line[0] == 'P')
|
return TRUE; /* fin de liste */
|
||||||
{
|
if( Line[0] == 'P' )
|
||||||
sscanf( Line+2," %X %d %d %d %d %d %lX",
|
{
|
||||||
&m_Shape, &m_Layer,
|
sscanf( Line + 2, " %X %d %d %d %d %d %lX",
|
||||||
&m_Pos.x, &m_Pos.y,
|
&m_Shape, &m_Layer,
|
||||||
&m_Size, &m_Width, &m_TimeStamp );
|
&m_Pos.x, &m_Pos.y,
|
||||||
if ( m_Layer < FIRST_NO_COPPER_LAYER )
|
&m_Size, &m_Width, &m_TimeStamp );
|
||||||
m_Layer = FIRST_NO_COPPER_LAYER;
|
if( m_Layer < FIRST_NO_COPPER_LAYER )
|
||||||
if ( m_Layer > LAST_NO_COPPER_LAYER )
|
m_Layer = FIRST_NO_COPPER_LAYER;
|
||||||
m_Layer = LAST_NO_COPPER_LAYER;
|
if( m_Layer > LAST_NO_COPPER_LAYER )
|
||||||
|
m_Layer = LAST_NO_COPPER_LAYER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
return FALSE;
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
bool MIREPCB::WriteMirePcbDescr(FILE * File)
|
bool MIREPCB::WriteMirePcbDescr( FILE* File )
|
||||||
/************************************************/
|
/************************************************/
|
||||||
{
|
{
|
||||||
if( GetState(DELETED) ) return FALSE;
|
if( GetState( DELETED ) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
fprintf( File, "$MIREPCB\n");
|
fprintf( File, "$MIREPCB\n" );
|
||||||
fprintf( File,"Po %X %d %d %d %d %d %8.8lX\n",
|
fprintf( File, "Po %X %d %d %d %d %d %8.8lX\n",
|
||||||
m_Shape, m_Layer,
|
m_Shape, m_Layer,
|
||||||
m_Pos.x, m_Pos.y,
|
m_Pos.x, m_Pos.y,
|
||||||
m_Size, m_Width, m_TimeStamp );
|
m_Size, m_Width, m_TimeStamp );
|
||||||
fprintf( File, "$EndMIREPCB\n");
|
fprintf( File, "$EndMIREPCB\n" );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
void MIREPCB::Draw(WinEDA_DrawPanel * panel, wxDC * DC,
|
void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
const wxPoint & offset, int mode_color)
|
const wxPoint& offset, int mode_color )
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
||||||
/* Affichage de 1 mire : 2 segments + 1 cercle
|
/* Affichage de 1 mire : 2 segments + 1 cercle
|
||||||
le cercle a pour rayon le demi rayon de la mire
|
* le cercle a pour rayon le demi rayon de la mire
|
||||||
les 2 traits ont pour longueur le diametre de la mire
|
* les 2 traits ont pour longueur le diametre de la mire
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int rayon, ox, oy, gcolor, width;
|
int rayon, ox, oy, gcolor, width;
|
||||||
int dx1,dx2, dy1, dy2;
|
int dx1, dx2, dy1, dy2;
|
||||||
int typeaff;
|
int typeaff;
|
||||||
int zoom;
|
int zoom;
|
||||||
|
|
||||||
ox = m_Pos.x + offset.x;
|
ox = m_Pos.x + offset.x;
|
||||||
oy = m_Pos.y + offset.y;
|
oy = m_Pos.y + offset.y;
|
||||||
|
|
||||||
gcolor = g_DesignSettings.m_LayerColor[m_Layer];
|
gcolor = g_DesignSettings.m_LayerColor[m_Layer];
|
||||||
if ( (gcolor & ITEM_NOT_SHOW) != 0 ) return;
|
if( (gcolor & ITEM_NOT_SHOW) != 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
zoom = panel->GetZoom();
|
zoom = panel->GetZoom();
|
||||||
|
|
||||||
GRSetDrawMode(DC, mode_color);
|
GRSetDrawMode( DC, mode_color );
|
||||||
typeaff = DisplayOpt.DisplayDrawItems;
|
typeaff = DisplayOpt.DisplayDrawItems;
|
||||||
width = m_Width;
|
width = m_Width;
|
||||||
if( width/zoom < 2 ) typeaff = FILAIRE;
|
if( width / zoom < 2 )
|
||||||
|
typeaff = FILAIRE;
|
||||||
|
|
||||||
/* Trace du cercle: */
|
/* Trace du cercle: */
|
||||||
rayon = m_Size / 4;
|
rayon = m_Size / 4;
|
||||||
switch( typeaff )
|
|
||||||
{
|
|
||||||
case FILAIRE:
|
|
||||||
width = 0;
|
|
||||||
case FILLED:
|
|
||||||
GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon, width, gcolor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKETCH:
|
switch( typeaff )
|
||||||
GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon + (width/2), gcolor) ;
|
{
|
||||||
GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon - (width/2), gcolor) ;
|
case FILAIRE:
|
||||||
break;
|
width = 0;
|
||||||
}
|
|
||||||
|
case FILLED:
|
||||||
|
GRCircle( &panel->m_ClipBox, DC, ox, oy, rayon, width, gcolor );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SKETCH:
|
||||||
|
GRCircle( &panel->m_ClipBox, DC, ox, oy, rayon + (width / 2), gcolor );
|
||||||
|
GRCircle( &panel->m_ClipBox, DC, ox, oy, rayon - (width / 2), gcolor );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Trace des 2 traits */
|
/* Trace des 2 traits */
|
||||||
rayon = m_Size/2;
|
rayon = m_Size / 2;
|
||||||
dx1 = rayon, dy1 = 0;
|
dx1 = rayon, dy1 = 0;
|
||||||
dx2 = 0, dy2 = rayon;
|
dx2 = 0, dy2 = rayon;
|
||||||
|
|
||||||
if( m_Shape) /* Forme X */
|
if( m_Shape ) /* Forme X */
|
||||||
{
|
{
|
||||||
dx1 = dy1 = (rayon * 7)/5;
|
dx1 = dy1 = (rayon * 7) / 5;
|
||||||
dx2 = dx1; dy2 = -dy1;
|
dx2 = dx1; dy2 = -dy1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( typeaff )
|
switch( typeaff )
|
||||||
{
|
{
|
||||||
case FILAIRE:
|
case FILAIRE:
|
||||||
case FILLED:
|
case FILLED:
|
||||||
GRLine(&panel->m_ClipBox, DC, ox - dx1, oy - dy1,
|
GRLine( &panel->m_ClipBox, DC, ox - dx1, oy - dy1,
|
||||||
ox + dx1, oy + dy1, width, gcolor);
|
ox + dx1, oy + dy1, width, gcolor );
|
||||||
GRLine(&panel->m_ClipBox, DC, ox - dx2, oy - dy2,
|
GRLine( &panel->m_ClipBox, DC, ox - dx2, oy - dy2,
|
||||||
ox + dx2, oy + dy2, width, gcolor);
|
ox + dx2, oy + dy2, width, gcolor );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SKETCH:
|
case SKETCH:
|
||||||
GRCSegm(&panel->m_ClipBox, DC, ox - dx1, oy - dy1,
|
GRCSegm( &panel->m_ClipBox, DC, ox - dx1, oy - dy1,
|
||||||
ox + dx1, oy + dy1,
|
ox + dx1, oy + dy1,
|
||||||
width, gcolor);
|
width, gcolor );
|
||||||
GRCSegm(&panel->m_ClipBox, DC, ox - dx2, oy - dy2,
|
GRCSegm( &panel->m_ClipBox, DC, ox - dx2, oy - dy2,
|
||||||
ox + dx2, oy + dy2,
|
ox + dx2, oy + dy2,
|
||||||
width, gcolor);
|
width, gcolor );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool MIREPCB::HitTest( const wxPoint& refPos )
|
||||||
|
{
|
||||||
|
int dX = refPos.x - m_Pos.x;
|
||||||
|
int dY = refPos.y - m_Pos.y;
|
||||||
|
int rayon = m_Size / 2;
|
||||||
|
|
||||||
|
return abs(dX)<=rayon && abs(dY)<=rayon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,31 +7,38 @@
|
||||||
#include "base_struct.h"
|
#include "base_struct.h"
|
||||||
|
|
||||||
|
|
||||||
class MIREPCB: public EDA_BaseStruct
|
class MIREPCB : public EDA_BaseStruct
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int m_Layer; // 0.. 32 ( NON bit a bit)
|
int m_Layer; // 0.. 32 ( NON bit a bit)
|
||||||
int m_Width;
|
int m_Width;
|
||||||
wxPoint m_Pos;
|
wxPoint m_Pos;
|
||||||
int m_Shape; // bit 0 : 0 = forme +, 1 = forme X
|
int m_Shape; // bit 0 : 0 = forme +, 1 = forme X
|
||||||
int m_Size;
|
int m_Size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MIREPCB(EDA_BaseStruct * StructFather);
|
MIREPCB( EDA_BaseStruct* StructFather );
|
||||||
~MIREPCB(void);
|
~MIREPCB( void );
|
||||||
|
|
||||||
bool WriteMirePcbDescr(FILE * File);
|
bool WriteMirePcbDescr( FILE* File );
|
||||||
bool ReadMirePcbDescr(FILE * File, int * LineNum);
|
bool ReadMirePcbDescr( FILE* File, int* LineNum );
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct */
|
/* supprime du chainage la structure Struct */
|
||||||
void UnLink( void );
|
void UnLink( void );
|
||||||
|
|
||||||
void Copy(MIREPCB * source);
|
void Copy( MIREPCB* source );
|
||||||
|
|
||||||
void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int mode_color);
|
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int mode_color );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool HitTest( const wxPoint& refPos );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // #define MIRE_H
|
||||||
#endif // #define MIRE_H
|
|
||||||
|
|
|
@ -144,7 +144,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetClass
|
* Function GetClass
|
||||||
* returns the class name.
|
* returns the class name.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,84 +10,135 @@
|
||||||
/* Type des Vias (shape)*/
|
/* Type des Vias (shape)*/
|
||||||
|
|
||||||
/* Forme des Vias ( parametre .shape ) */
|
/* Forme des Vias ( parametre .shape ) */
|
||||||
#define VIA_NORMALE 3 /* type via : traversante (throught via) */
|
#define VIA_NORMALE 3 /* type via : traversante (throught via) */
|
||||||
#define VIA_ENTERREE 2 /* type via : enterree ou aveugle (blind via) */
|
#define VIA_ENTERREE 2 /* type via : enterree ou aveugle (blind via) */
|
||||||
#define VIA_BORGNE 1 /* type via : borgne ou demi-traversante (buried via) */
|
#define VIA_BORGNE 1 /* type via : borgne ou demi-traversante (buried via) */
|
||||||
#define VIA_NOT_DEFINED 0 /* reserved */
|
#define VIA_NOT_DEFINED 0 /* reserved */
|
||||||
#define SQUARE_VIA 0x80000000 /* Flag pour forme carree */
|
#define SQUARE_VIA 0x80000000 /* Flag pour forme carree */
|
||||||
|
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
|
|
||||||
class TRACK: public EDA_BaseLineStruct
|
class TRACK : public EDA_BaseLineStruct
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int m_Shape; // vias: shape and type, Track = shape..
|
int m_Shape; // vias: shape and type, Track = shape..
|
||||||
int m_Drill; // for vias: via drill (- 1 for default value)
|
int m_Drill; // for vias: via drill (- 1 for default value)
|
||||||
EDA_BaseStruct * start,* end; // pointers on a connected item (pad or track)
|
EDA_BaseStruct* start, * end; // pointers on a connected item (pad or track)
|
||||||
int m_NetCode; // Net number
|
int m_NetCode; // Net number
|
||||||
int m_Sous_Netcode; /* In rastnest routines : for the current net,
|
int m_Sous_Netcode; /* In rastnest routines : for the current net,
|
||||||
block number (number common to the current connected items found) */
|
* block number (number common to the current connected items found) */
|
||||||
// chain = 0 indique une connexion non encore traitee
|
|
||||||
int m_Param; // Auxiliary variable ( used in some computations )
|
// chain = 0 indique une connexion non encore traitee
|
||||||
|
int m_Param; // Auxiliary variable ( used in some computations )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TRACK(EDA_BaseStruct * StructFather, DrawStructureType idtype = TYPETRACK);
|
TRACK( EDA_BaseStruct* StructFather, DrawStructureType idtype = TYPETRACK );
|
||||||
TRACK(const TRACK & track);
|
TRACK( const TRACK& track );
|
||||||
|
|
||||||
TRACK * Next(void); // Retourne le chainage avant
|
TRACK* Next( void ); // Retourne le chainage avant
|
||||||
TRACK * Back(void) // Retourne le chainage avant
|
|
||||||
{
|
|
||||||
return (TRACK*) Pback;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct */
|
TRACK* Back( void ) // Retourne le chainage avant
|
||||||
void UnLink( void );
|
{
|
||||||
|
return (TRACK*) Pback;
|
||||||
|
}
|
||||||
|
|
||||||
// Read/write data
|
|
||||||
bool WriteTrackDescr(FILE * File);
|
|
||||||
|
|
||||||
/* Ajoute un element a la liste */
|
/* supprime du chainage la structure Struct */
|
||||||
void Insert(BOARD * Pcb, EDA_BaseStruct * InsertPoint);
|
void UnLink( void );
|
||||||
|
|
||||||
/* Recherche du meilleur point d'insertion */
|
// Read/write data
|
||||||
TRACK * GetBestInsertPoint( BOARD * Pcb);
|
bool WriteTrackDescr( FILE* File );
|
||||||
|
|
||||||
/* Copie d'un Element d'une chaine de n elements */
|
/* Ajoute un element a la liste */
|
||||||
TRACK * Copy( int NbSegm = 1 );
|
void Insert( BOARD* Pcb, EDA_BaseStruct* InsertPoint );
|
||||||
|
|
||||||
/* Recherche du debut du net
|
/* Recherche du meilleur point d'insertion */
|
||||||
( les elements sont classes par net_code croissant ) */
|
TRACK* GetBestInsertPoint( BOARD* Pcb );
|
||||||
TRACK * GetStartNetCode(int NetCode );
|
|
||||||
/* Recherche de la fin du net */
|
|
||||||
TRACK * GetEndNetCode(int NetCode);
|
|
||||||
|
|
||||||
/* Display on screen: */
|
/* Copie d'un Element d'une chaine de n elements */
|
||||||
void Draw(WinEDA_DrawPanel * panel, wxDC * DC, int draw_mode);
|
TRACK* Copy( int NbSegm = 1 );
|
||||||
|
|
||||||
/* divers */
|
/* Recherche du debut du net
|
||||||
int Shape(void) { return m_Shape & 0xFF; }
|
* ( les elements sont classes par net_code croissant ) */
|
||||||
|
TRACK* GetStartNetCode( int NetCode );
|
||||||
|
|
||||||
|
/* Recherche de la fin du net */
|
||||||
|
TRACK* GetEndNetCode( int NetCode );
|
||||||
|
|
||||||
|
/* Display on screen: */
|
||||||
|
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode );
|
||||||
|
|
||||||
|
/* divers */
|
||||||
|
int Shape( void ) { return m_Shape & 0xFF; }
|
||||||
|
|
||||||
|
int ReturnMaskLayer( void );
|
||||||
|
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
|
||||||
|
bool IsNull( void ); // return TRUE if segment lenght = 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool HitTest( const wxPoint& refPos );
|
||||||
|
|
||||||
|
#if defined(DEBUG)
|
||||||
|
/**
|
||||||
|
* Function GetClass
|
||||||
|
* returns the class name.
|
||||||
|
* @return wxString
|
||||||
|
*/
|
||||||
|
wxString GetClass() const
|
||||||
|
{
|
||||||
|
return wxT("TRACK");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
int ReturnMaskLayer(void);
|
|
||||||
int IsPointOnEnds(const wxPoint & point, int min_dist = 0);
|
|
||||||
bool IsNull(void); // return TRUE if segment lenght = 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SEGZONE: public TRACK
|
class SEGZONE : public TRACK
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SEGZONE(EDA_BaseStruct * StructFather);
|
SEGZONE( EDA_BaseStruct* StructFather );
|
||||||
|
|
||||||
|
#if defined(DEBUG)
|
||||||
|
/**
|
||||||
|
* Function GetClass
|
||||||
|
* returns the class name.
|
||||||
|
* @return wxString
|
||||||
|
*/
|
||||||
|
wxString GetClass() const
|
||||||
|
{
|
||||||
|
return wxT("ZONE");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SEGVIA: public TRACK
|
class SEGVIA : public TRACK
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SEGVIA(EDA_BaseStruct * StructFather);
|
SEGVIA( EDA_BaseStruct* StructFather );
|
||||||
bool IsViaOnLayer(int layer);
|
bool IsViaOnLayer( int layer );
|
||||||
void SetLayerPair(int top_layer, int bottom_layer);
|
void SetLayerPair( int top_layer, int bottom_layer );
|
||||||
void ReturnLayerPair(int * top_layer, int * bottom_layer);
|
void ReturnLayerPair( int* top_layer, int* bottom_layer );
|
||||||
};
|
|
||||||
|
|
||||||
|
#if defined(DEBUG)
|
||||||
|
/**
|
||||||
|
* Function GetClass
|
||||||
|
* returns the class name.
|
||||||
|
* @return wxString
|
||||||
|
*/
|
||||||
|
wxString GetClass() const
|
||||||
|
{
|
||||||
|
return wxT("VIA");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* CLASS_TRACK_H */
|
#endif /* CLASS_TRACK_H */
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
|
#include "trigo.h"
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
@ -165,6 +166,61 @@ bool DRAWSEGMENT::ReadDrawSegmentDescr( FILE* File, int* LineNum )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTest
|
||||||
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* @param ref_pos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
|
||||||
|
{
|
||||||
|
int ux0 = m_Start.x;
|
||||||
|
int uy0 = m_Start.y;
|
||||||
|
|
||||||
|
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
||||||
|
int dx = m_End.x - ux0;
|
||||||
|
int dy = m_End.y - uy0;
|
||||||
|
|
||||||
|
int spot_cX = ref_pos.x - ux0;
|
||||||
|
int spot_cY = ref_pos.y - uy0;
|
||||||
|
|
||||||
|
if( m_Shape==S_CIRCLE || 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 ) <= (m_Width / 2) )
|
||||||
|
{
|
||||||
|
if( m_Shape == S_CIRCLE )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* pour un arc, controle complementaire */
|
||||||
|
mouseAngle = (int) ArcTangente( spot_cY, spot_cX );
|
||||||
|
stAngle = (int) ArcTangente( dy, dx );
|
||||||
|
endAngle = stAngle + m_Angle;
|
||||||
|
|
||||||
|
if( endAngle > 3600 )
|
||||||
|
{
|
||||||
|
stAngle -= 3600;
|
||||||
|
endAngle -= 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mouseAngle >= stAngle && mouseAngle <= endAngle )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
/* Classe MARQUEUR */
|
/* Classe MARQUEUR */
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
2463
pcbnew/drc.cpp
2463
pcbnew/drc.cpp
File diff suppressed because it is too large
Load Diff
|
@ -128,8 +128,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
DrawStruct = m_Pcb->FindPadOrModule(
|
DrawStruct = m_Pcb->FindPadOrModule(
|
||||||
GetScreen()->RefPos(true),
|
GetScreen()->RefPos(true),
|
||||||
GetScreen()->m_Active_Layer,
|
GetScreen()->m_Active_Layer );
|
||||||
VISIBLE_ONLY );
|
|
||||||
#else
|
#else
|
||||||
DrawStruct = PcbGeneralLocateAndDisplay();
|
DrawStruct = PcbGeneralLocateAndDisplay();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
|
|
||||||
|
|
||||||
/* variables locales */
|
|
||||||
int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour
|
|
||||||
* la localisation des segments */
|
|
||||||
/* fonctions locales */
|
/* fonctions locales */
|
||||||
EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc );
|
EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc );
|
||||||
|
|
||||||
|
@ -302,72 +299,21 @@ EDGE_MODULE* Locate_Edge_Module( MODULE* module, int typeloc )
|
||||||
* NULL si rien trouve
|
* NULL si rien trouve
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
EDGE_MODULE* edge_mod;
|
|
||||||
EDA_BaseStruct* PtStruct;
|
|
||||||
int uxf, uyf, type_trace;
|
|
||||||
int rayon, dist;
|
|
||||||
wxPoint ref_pos; /* coord du point de localisation */
|
|
||||||
|
|
||||||
/* pour localisation d'arcs, angle du point de debut, de fin et du point de reference */
|
|
||||||
int StAngle, EndAngle, MouseAngle;
|
|
||||||
|
|
||||||
if( !module )
|
if( !module )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ref_pos = RefPos( typeloc );
|
/* coord du point de localisation */
|
||||||
|
wxPoint ref_pos = RefPos( typeloc );
|
||||||
|
|
||||||
PtStruct = module->m_Drawings;
|
EDA_BaseStruct* PtStruct = module->m_Drawings;
|
||||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||||
{
|
{
|
||||||
if( PtStruct->m_StructType != TYPEEDGEMODULE )
|
if( PtStruct->m_StructType != TYPEEDGEMODULE )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
edge_mod = (EDGE_MODULE*) PtStruct;
|
// calls virtual EDGE_MODULE::HitTest()
|
||||||
type_trace = edge_mod->m_Shape;
|
if( PtStruct->HitTest( ref_pos ) )
|
||||||
ux0 = edge_mod->m_Start.x; uy0 = edge_mod->m_Start.y;
|
return (EDGE_MODULE*) PtStruct;
|
||||||
uxf = edge_mod->m_End.x; uyf = edge_mod->m_End.y;
|
|
||||||
|
|
||||||
switch( type_trace )
|
|
||||||
{
|
|
||||||
case S_SEGMENT:
|
|
||||||
/* recalcul des coordonnees avec ux0,uy0 = origine des coord. */
|
|
||||||
spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
|
|
||||||
dx = uxf - ux0; dy = uyf - uy0;
|
|
||||||
/* detection : */
|
|
||||||
if( distance( edge_mod->m_Width / 2 ) )
|
|
||||||
return edge_mod;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case S_CIRCLE:
|
|
||||||
rayon = (int) hypot( (double) (uxf - ux0), (double) (uyf - uy0) );
|
|
||||||
dist = (int) hypot( (double) (ref_pos.x - ux0), (double) (ref_pos.y - uy0) );
|
|
||||||
|
|
||||||
if( abs( rayon - dist ) <= edge_mod->m_Width )
|
|
||||||
return edge_mod;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case S_ARC:
|
|
||||||
rayon = (int) hypot( (double) (uxf - ux0), (double) (uyf - uy0) );
|
|
||||||
dist = (int) hypot( (double) (ref_pos.x - ux0), (double) (ref_pos.y - uy0) );
|
|
||||||
|
|
||||||
if( abs( rayon - dist ) > edge_mod->m_Width )
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* pour un arc, controle complementaire */
|
|
||||||
MouseAngle = (int) ArcTangente( ref_pos.y - uy0, ref_pos.x - ux0 );
|
|
||||||
StAngle = (int) ArcTangente( uyf - uy0, uxf - ux0 );
|
|
||||||
EndAngle = StAngle + edge_mod->m_Angle;
|
|
||||||
|
|
||||||
if( EndAngle > 3600 )
|
|
||||||
{
|
|
||||||
StAngle -= 3600; EndAngle -= 3600;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) )
|
|
||||||
return edge_mod;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -383,105 +329,17 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
|
||||||
* return a pointer to the located item, or NULL
|
* return a pointer to the located item, or NULL
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
EDA_BaseStruct* PtStruct;
|
wxPoint ref_pos = RefPos( typeloc );
|
||||||
COTATION* Cotation;
|
|
||||||
TEXTE_PCB* pt_txt;
|
|
||||||
wxPoint ref_pos;
|
|
||||||
int ux0, uy0;
|
|
||||||
|
|
||||||
ref_pos = RefPos( typeloc );
|
EDA_BaseStruct* PtStruct = Pcb->m_Drawings;
|
||||||
|
|
||||||
PtStruct = Pcb->m_Drawings;
|
|
||||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||||
{
|
{
|
||||||
if( PtStruct->m_StructType != TYPECOTATION )
|
if( PtStruct->m_StructType != TYPECOTATION )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Cotation = (COTATION*) PtStruct;
|
// calls virtual COTATION::HitTest()
|
||||||
if( (Cotation->m_Layer != LayerSearch) && (LayerSearch != -1) )
|
if( PtStruct->HitTest( ref_pos ) )
|
||||||
continue;
|
return (COTATION*) PtStruct;
|
||||||
|
|
||||||
/* Localisation du texte ? */
|
|
||||||
pt_txt = Cotation->m_Text;
|
|
||||||
if( pt_txt )
|
|
||||||
{
|
|
||||||
// because HitTest() is present in both base classes of TEXTE_PCB
|
|
||||||
// use a dis-ambiguating cast to tell compiler which HitTest()
|
|
||||||
// to call.
|
|
||||||
if( static_cast<EDA_TextStruct*>(pt_txt)->HitTest( ref_pos ) )
|
|
||||||
return PtStruct;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( distance( Cotation->m_Width / 2 ) )
|
|
||||||
return PtStruct;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -499,73 +357,32 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
|
||||||
* Le segment sur la couche active est détecté en priorite
|
* Le segment sur la couche active est détecté en priorite
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
EDA_BaseStruct* PtStruct;
|
|
||||||
DRAWSEGMENT* pts, * locate_segm = NULL;
|
DRAWSEGMENT* locate_segm = NULL;
|
||||||
wxPoint ref_pos;
|
|
||||||
PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen;
|
PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen;
|
||||||
|
|
||||||
ref_pos = RefPos( typeloc );
|
wxPoint ref_pos = RefPos( typeloc );
|
||||||
|
|
||||||
PtStruct = Pcb->m_Drawings;
|
EDA_BaseStruct* PtStruct = Pcb->m_Drawings;
|
||||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||||
{
|
{
|
||||||
if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
|
if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
|
||||||
continue;
|
continue;
|
||||||
pts = (DRAWSEGMENT*) PtStruct;
|
|
||||||
|
DRAWSEGMENT* pts = (DRAWSEGMENT*) PtStruct;
|
||||||
|
|
||||||
if( (pts->m_Layer != LayerSearch) && (LayerSearch != -1) )
|
if( (pts->m_Layer != LayerSearch) && (LayerSearch != -1) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ux0 = pts->m_Start.x; uy0 = pts->m_Start.y;
|
if( pts->HitTest( ref_pos ) )
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
/* detection : */
|
|
||||||
if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) )
|
|
||||||
{
|
{
|
||||||
int rayon, dist, StAngle, EndAngle, MouseAngle;
|
// return this hit if layer matches, else remember in
|
||||||
|
// case no layer match is found.
|
||||||
|
if( pts->m_Layer == screen->m_Active_Layer )
|
||||||
|
return pts;
|
||||||
|
|
||||||
rayon = (int) hypot( (double) (dx), (double) (dy) );
|
else if( !locate_segm )
|
||||||
dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
|
locate_segm = pts;
|
||||||
|
|
||||||
if( abs( rayon - dist ) <= (pts->m_Width / 2) )
|
|
||||||
{
|
|
||||||
if( pts->m_Shape == S_CIRCLE )
|
|
||||||
{
|
|
||||||
if( pts->m_Layer == screen->m_Active_Layer )
|
|
||||||
return pts;
|
|
||||||
else if( !locate_segm )
|
|
||||||
locate_segm = pts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pour un arc, controle complementaire */
|
|
||||||
MouseAngle = (int) ArcTangente( spot_cY, spot_cX );
|
|
||||||
StAngle = (int) ArcTangente( dy, dx );
|
|
||||||
EndAngle = StAngle + pts->m_Angle;
|
|
||||||
|
|
||||||
if( EndAngle > 3600 )
|
|
||||||
{
|
|
||||||
StAngle -= 3600; EndAngle -= 3600;
|
|
||||||
}
|
|
||||||
if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) )
|
|
||||||
{
|
|
||||||
if( pts->m_Layer == screen->m_Active_Layer )
|
|
||||||
return pts;
|
|
||||||
else if( !locate_segm )
|
|
||||||
locate_segm = pts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( distance( pts->m_Width / 2 ) )
|
|
||||||
{
|
|
||||||
if( pts->m_Layer == screen->m_Active_Layer )
|
|
||||||
return pts;
|
|
||||||
else if( !locate_segm )
|
|
||||||
locate_segm = pts;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,14 +468,6 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
|
||||||
D_PAD* pt_pad = module->m_Pads;
|
D_PAD* pt_pad = module->m_Pads;
|
||||||
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
wxPoint shape_pos = ReturnShapePos();
|
|
||||||
|
|
||||||
why the global ux0?
|
|
||||||
ux0 = shape_pos.x;
|
|
||||||
uy0 = shape_pos.y; // pos x,y du centre du pad
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ... et sur la bonne couche */
|
/* ... et sur la bonne couche */
|
||||||
if( (pt_pad->m_Masque_Layer & masque_layer) == 0 )
|
if( (pt_pad->m_Masque_Layer & masque_layer) == 0 )
|
||||||
continue;
|
continue;
|
||||||
|
@ -704,8 +513,6 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
|
||||||
if( (typeloc & IGNORE_LOCKED) && pt_module->IsLocked() )
|
if( (typeloc & IGNORE_LOCKED) && pt_module->IsLocked() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Localisation: test des dimensions minimales, choix du meilleur candidat */
|
|
||||||
|
|
||||||
/* calcul de priorite: la priorite est donnee a la couche
|
/* calcul de priorite: la priorite est donnee a la couche
|
||||||
* d'appartenance du module et a la couche cuivre si le module
|
* d'appartenance du module et a la couche cuivre si le module
|
||||||
* est sur couche serigr,adhesive cuivre, a la couche cmp si le module
|
* est sur couche serigr,adhesive cuivre, a la couche cmp si le module
|
||||||
|
@ -718,6 +525,8 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
|
||||||
else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP )
|
else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP )
|
||||||
layer = CMP_N;
|
layer = CMP_N;
|
||||||
|
|
||||||
|
/* Localisation: test des dimensions minimales, choix du meilleur candidat */
|
||||||
|
|
||||||
/* calcul des dimensions du cadre :*/
|
/* calcul des dimensions du cadre :*/
|
||||||
lx = pt_module->m_BoundaryBox.GetWidth();
|
lx = pt_module->m_BoundaryBox.GetWidth();
|
||||||
ly = pt_module->m_BoundaryBox.GetHeight();
|
ly = pt_module->m_BoundaryBox.GetHeight();
|
||||||
|
@ -998,40 +807,28 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc )
|
||||||
|
|
||||||
TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer )
|
TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer )
|
||||||
{
|
{
|
||||||
TRACK* Track; /* pointeur sur les pistes */
|
for( TRACK* Track = start_adresse; Track; Track = (TRACK*) Track->Pnext )
|
||||||
int l_piste; /* demi-largeur de la piste */
|
|
||||||
|
|
||||||
for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext )
|
|
||||||
{
|
{
|
||||||
if( Track->GetState( BUSY | DELETED ) )
|
if( Track->GetState( BUSY | DELETED ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( (g_DesignSettings.m_LayerColor[Track->m_Layer] & ITEM_NOT_SHOW) )
|
if( (g_DesignSettings.m_LayerColor[Track->m_Layer] & ITEM_NOT_SHOW) )
|
||||||
continue;
|
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 */
|
|
||||||
dx = Track->m_End.x; dy = Track->m_End.y; /* coord d'arrivee */
|
|
||||||
|
|
||||||
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
|
||||||
dx -= ux0; dy -= uy0;
|
|
||||||
spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
|
|
||||||
|
|
||||||
if( Track->m_StructType == TYPEVIA ) /* VIA rencontree */
|
if( Track->m_StructType == TYPEVIA ) /* VIA rencontree */
|
||||||
{
|
{
|
||||||
if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) )
|
if( Track->HitTest( ref_pos ) )
|
||||||
{
|
|
||||||
return Track;
|
return Track;
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( MasqueLayer != -1 )
|
||||||
|
if( (g_TabOneLayerMask[Track->m_Layer] & MasqueLayer) == 0 )
|
||||||
|
continue; /* Segments sur couches differentes */
|
||||||
|
|
||||||
if( MasqueLayer != -1 )
|
if( Track->HitTest( ref_pos ) )
|
||||||
if( (g_TabOneLayerMask[Track->m_Layer] & MasqueLayer) == 0 )
|
return Track;
|
||||||
continue; /* Segments sur couches differentes */
|
}
|
||||||
|
|
||||||
if( distance( l_piste ) )
|
|
||||||
return Track;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1065,23 +862,12 @@ TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc )
|
||||||
|
|
||||||
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
|
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
|
||||||
{
|
{
|
||||||
TRACK* Zone; /* pointeur sur les pistes */
|
for( TRACK* Zone = start_adresse; Zone; Zone = (TRACK*) Zone->Pnext )
|
||||||
int l_segm; /* demi-largeur de la piste */
|
|
||||||
|
|
||||||
for( Zone = start_adresse; Zone != NULL; Zone = (TRACK*) Zone->Pnext )
|
|
||||||
{
|
{
|
||||||
/* calcul des coordonnees du segment teste */
|
|
||||||
l_segm = Zone->m_Width >> 1; /* l_piste = demi largeur piste */
|
|
||||||
ux0 = Zone->m_Start.x; uy0 = Zone->m_Start.y; /* coord de depart */
|
|
||||||
dx = Zone->m_End.x; dy = Zone->m_End.y; /* coord d'arrivee */
|
|
||||||
|
|
||||||
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
|
|
||||||
dx -= ux0; dy -= uy0;
|
|
||||||
spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0;
|
|
||||||
|
|
||||||
if( (layer != -1) && (Zone->m_Layer != layer) )
|
if( (layer != -1) && (Zone->m_Layer != layer) )
|
||||||
continue;
|
continue;
|
||||||
if( distance( l_segm ) )
|
|
||||||
|
if( Zone->HitTest( ref_pos ) )
|
||||||
return Zone;
|
return Zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1123,159 +909,6 @@ TEXTE_PCB* Locate_Texte_Pcb( EDA_BaseStruct* PtStruct, int LayerSearch, int type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************/
|
|
||||||
int distance( int seuil )
|
|
||||||
/*****************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 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 = dx; segY = dy; pointX = spot_cX; pointY = spot_cY;
|
|
||||||
|
|
||||||
/*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/
|
|
||||||
if( segX < 0 ) /* mise en >0 par symetrie par rapport a l'axe Y */
|
|
||||||
{
|
|
||||||
segX = -segX; pointX = -pointX;
|
|
||||||
}
|
|
||||||
if( segY < 0 ) /* mise en > 0 par symetrie par rapport a l'axe X */
|
|
||||||
{
|
|
||||||
segY = -segY; pointY = -pointY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( segY == 0 ) /* piste Horizontale */
|
|
||||||
{
|
|
||||||
if( abs( pointY ) <= seuil )
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if( (pointX > segX) && ( pointX <= (segX + seuil) ) )
|
|
||||||
{
|
|
||||||
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 >= -seuil) )
|
|
||||||
{
|
|
||||||
if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) )
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if( (pointY > segY) && ( pointY <= (segY + seuil) ) )
|
|
||||||
{
|
|
||||||
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 */
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
/* Etude des extremites : cercle de rayon seuil */
|
|
||||||
if( (cXrot < 0) && (cXrot >= -seuil) )
|
|
||||||
{
|
|
||||||
if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
|
|
||||||
{
|
|
||||||
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
|
||||||
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 */
|
|
||||||
int angle;
|
|
||||||
|
|
||||||
angle = (int) ( atan2( (float) segY, (float) segX ) * 1800 / M_PI);
|
|
||||||
cXrot = pointX; cYrot = pointY;
|
|
||||||
|
|
||||||
RotatePoint( &cXrot, &cYrot, angle ); /* Rotation du point a tester */
|
|
||||||
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 */
|
|
||||||
|
|
||||||
if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
|
|
||||||
{
|
|
||||||
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_layer )
|
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_layer )
|
||||||
|
@ -1396,11 +1029,10 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch,
|
||||||
int typeloc )
|
int typeloc )
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/* Serach for a photo target
|
/* Search for a photo target
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
wxPoint ref_pos;/* coord du point de localisation */
|
wxPoint ref_pos;/* coord du point de localisation */
|
||||||
int dX, dY, rayon;
|
|
||||||
|
|
||||||
if( PtStruct == NULL )
|
if( PtStruct == NULL )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1417,13 +1049,10 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch,
|
||||||
if( LayerSearch != -1 && item->m_Layer != LayerSearch )
|
if( LayerSearch != -1 && item->m_Layer != LayerSearch )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dX = ref_pos.x - item->m_Pos.x;
|
if( item->HitTest( ref_pos ) )
|
||||||
dY = ref_pos.y - item->m_Pos.y;
|
break;
|
||||||
rayon = item->m_Size / 2;
|
|
||||||
|
|
||||||
if( (abs( dX ) <= rayon ) && ( abs( dY ) <= rayon ) )
|
|
||||||
break; /* Mire Localisee */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PtStruct;
|
return PtStruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,24 +198,6 @@ D_PAD * Fast_Locate_Pad_Connecte(BOARD * Pcb, const wxPoint & ref_pos, int layer
|
||||||
(bonne position ET bonne couche). */
|
(bonne position ET bonne couche). */
|
||||||
|
|
||||||
|
|
||||||
int distance(int seuil);
|
|
||||||
/*
|
|
||||||
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 ( externes 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
TRACK * Locate_Zone(TRACK * start_adresse,int layer, int typeloc);
|
TRACK * Locate_Zone(TRACK * start_adresse,int layer, int typeloc);
|
||||||
TRACK * Locate_Zone(TRACK * start_adresse, const wxPoint & ref_pos,int layer);
|
TRACK * Locate_Zone(TRACK * start_adresse, const wxPoint & ref_pos,int layer);
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -122,5 +122,5 @@ public:
|
||||||
WinEDA_PcbFrame * m_Parent;
|
WinEDA_PcbFrame * m_Parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _ZONES_H_
|
||||||
// _ZONES_H_
|
|
||||||
|
|
Loading…
Reference in New Issue