Replace UNIT by EAGLE_UNIT in Eagle plugin to avoid having a lot of useless hits when grep for "UNIT"

This commit is contained in:
jean-pierre charras 2017-10-23 15:37:24 +02:00
parent 7418deb454
commit 2d6496c7f6
3 changed files with 23 additions and 22 deletions

View File

@ -34,7 +34,7 @@
constexpr auto DEFAULT_ALIGNMENT = ETEXT::BOTTOM_LEFT;
ECOORD::ECOORD( const wxString& aValue, enum ECOORD::UNIT aUnit )
ECOORD::ECOORD( const wxString& aValue, enum ECOORD::EAGLE_UNIT aUnit )
{
// this array is used to adjust the fraction part value basing on the number of digits in the fraction
constexpr int DIVIDERS[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
@ -75,16 +75,17 @@ ECOORD::ECOORD( const wxString& aValue, enum ECOORD::UNIT aUnit )
}
long long int ECOORD::ToNanoMeters( int aValue, enum UNIT aUnit )
long long int ECOORD::ToNanoMeters( int aValue, enum EAGLE_UNIT aUnit )
{
long long int ret;
switch( aUnit )
{
case NM: ret = aValue; break;
case MM: ret = (long long) aValue * 1000000; break;
case INCH: ret = (long long) aValue * 25400000; break;
case MIL: ret = (long long) aValue * 25400; break;
default:
case EAGLE_NM: ret = aValue; break;
case EAGLE_MM: ret = (long long) aValue * 1000000; break;
case EAGLE_INCH: ret = (long long) aValue * 25400000; break;
case EAGLE_MIL: ret = (long long) aValue * 25400; break;
}
wxASSERT( ( ret > 0 ) == ( aValue > 0 ) ); // check for overflow
@ -165,7 +166,7 @@ template<>
ECOORD Convert<ECOORD>( const wxString& aCoord )
{
// Eagle uses millimeters as the default unit
return ECOORD( aCoord, ECOORD::UNIT::MM );
return ECOORD( aCoord, ECOORD::EAGLE_UNIT::EAGLE_MM );
}

View File

@ -386,31 +386,31 @@ typedef OPTIONAL_XML_ATTRIBUTE<ECOORD> opt_ecoord;
// Eagle coordinates
struct ECOORD
{
enum UNIT
enum EAGLE_UNIT
{
NM, ///< nanometers
MM, ///< millimeters
INCH, ///< inches
MIL, ///< mils/thous
EAGLE_NM, ///< nanometers
EAGLE_MM, ///< millimeters
EAGLE_INCH, ///< inches
EAGLE_MIL, ///< mils/thous
};
///> Value expressed in nanometers
long long int value;
///> Unit used for the value field
static constexpr UNIT ECOORD_UNIT = NM;
static constexpr EAGLE_UNIT ECOORD_UNIT = EAGLE_NM;
ECOORD()
: value( 0 )
{
}
ECOORD( int aValue, enum UNIT aUnit )
ECOORD( int aValue, enum EAGLE_UNIT aUnit )
: value( ToNanoMeters( aValue, aUnit ) )
{
}
ECOORD( const wxString& aValue, enum UNIT aUnit );
ECOORD( const wxString& aValue, enum EAGLE_UNIT aUnit );
int ToSchUnits() const
{
@ -444,7 +444,7 @@ struct ECOORD
return value == aOther.value;
}
static long long int ToNanoMeters( int aValue, enum UNIT aUnit );
static long long int ToNanoMeters( int aValue, enum EAGLE_UNIT aUnit );
};

View File

@ -85,8 +85,8 @@ typedef MODULE_MAP::const_iterator MODULE_CITER;
/// Return is in BIU.
static int parseEagle( const wxString& aDistance )
{
ECOORD::UNIT unit = ( aDistance.npos != aDistance.find( "mil" ) )
? ECOORD::UNIT::MIL : ECOORD::UNIT::MM;
ECOORD::EAGLE_UNIT unit = ( aDistance.npos != aDistance.find( "mil" ) )
? ECOORD::EAGLE_UNIT::EAGLE_MIL : ECOORD::EAGLE_UNIT::EAGLE_MM;
ECOORD coord( aDistance, unit );
@ -700,14 +700,14 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
if( *d.dimensionType == "horizontal" )
{
int newY = ( d.y1.ToPcbUnits() + d.y2.ToPcbUnits() ) / 2;
d.y1 = ECOORD( newY, ECOORD::UNIT::NM );
d.y2 = ECOORD( newY, ECOORD::UNIT::NM );
d.y1 = ECOORD( newY, ECOORD::EAGLE_UNIT::EAGLE_NM );
d.y2 = ECOORD( newY, ECOORD::EAGLE_UNIT::EAGLE_NM );
}
else if( *d.dimensionType == "vertical" )
{
int newX = ( d.x1.ToPcbUnits() + d.x2.ToPcbUnits() ) / 2;
d.x1 = ECOORD( newX, ECOORD::UNIT::NM );
d.x2 = ECOORD( newX, ECOORD::UNIT::NM );
d.x1 = ECOORD( newX, ECOORD::EAGLE_UNIT::EAGLE_NM );
d.x2 = ECOORD( newX, ECOORD::EAGLE_UNIT::EAGLE_NM );
}
}