Specctra export/import: fix an issue: via drill sizes were not round tripping if they were bigger than the default.

This commit is contained in:
unknown 2015-06-23 10:37:54 +02:00 committed by jean-pierre charras
parent 077c33a400
commit 3160553d31
2 changed files with 25 additions and 17 deletions

View File

@ -3831,7 +3831,8 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
* instantiates a KiCad VIA on the heap and initializes it with internal * instantiates a KiCad VIA on the heap and initializes it with internal
* values consistent with the given PADSTACK, POINT, and netcode. * values consistent with the given PADSTACK, POINT, and netcode.
*/ */
::VIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IO_ERROR ); ::VIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode, int aViaDrillDefault )
throw( IO_ERROR );
//-----</FromSESSION>---------------------------------------------------- //-----</FromSESSION>----------------------------------------------------

View File

@ -214,35 +214,38 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro
} }
::VIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IO_ERROR ) ::VIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint,
int aNetCode, int aViaDrillDefault )
throw( IO_ERROR )
{ {
::VIA* via = 0; ::VIA* via = 0;
SHAPE* shape; SHAPE* shape;
int shapeCount = aPadstack->Length(); int shapeCount = aPadstack->Length();
int drillDiam = -1; int drill_diam_iu = -1;
int copperLayerCount = sessionBoard->GetCopperLayerCount(); int copperLayerCount = sessionBoard->GetCopperLayerCount();
// The drill diameter is encoded in the padstack name if Pcbnew did the DSN export. // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
// It is in mils and is after the colon and before the last '_' // It is after the colon and before the last '_'
int drillStartNdx = aPadstack->padstack_id.find( ':' ); int drillStartNdx = aPadstack->padstack_id.find( ':' );
if( drillStartNdx != -1 ) if( drillStartNdx != -1 )
{ {
++drillStartNdx; // skip over the ':' ++drillStartNdx; // skip over the ':'
int drillEndNdx = aPadstack->padstack_id.rfind( '_' ); int drillEndNdx = aPadstack->padstack_id.rfind( '_' );
if( drillEndNdx != -1 ) if( drillEndNdx != -1 )
{ {
std::string diamTxt( aPadstack->padstack_id, drillStartNdx, drillEndNdx-drillStartNdx ); std::string diam_txt( aPadstack->padstack_id,
const char* sdiamTxt = diamTxt.c_str(); drillStartNdx, drillEndNdx-drillStartNdx );
double drillMils = strtod( sdiamTxt, 0 );
// drillMils is not in the session units, but actual mils so we don't use scale() double drill_um = strtod( diam_txt.c_str(), 0 );
drillDiam = (int) (drillMils * 10);
/** @todo: see if we use default netclass or specific value drill_diam_iu = int( drill_um * (IU_PER_MM / 1000.0) );
*/
drillDiam = -1; // import as default: real drill is the netclass value if( drill_diam_iu == aViaDrillDefault )
drill_diam_iu = UNDEFINED_DRILL_DIAMETER;
} }
} }
@ -263,7 +266,7 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro
via = new ::VIA( sessionBoard ); via = new ::VIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) ); via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrill( drillDiam ); via->SetDrill( drill_diam_iu );
via->SetViaType( VIA_THROUGH ); via->SetViaType( VIA_THROUGH );
via->SetWidth( viaDiam ); via->SetWidth( viaDiam );
via->SetLayerPair( F_Cu, B_Cu ); via->SetLayerPair( F_Cu, B_Cu );
@ -281,7 +284,7 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro
via = new ::VIA( sessionBoard ); via = new ::VIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) ); via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrill( drillDiam ); via->SetDrill( drill_diam_iu );
via->SetViaType( VIA_THROUGH ); via->SetViaType( VIA_THROUGH );
via->SetWidth( viaDiam ); via->SetWidth( viaDiam );
via->SetLayerPair( F_Cu, B_Cu ); via->SetLayerPair( F_Cu, B_Cu );
@ -323,7 +326,7 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro
via = new ::VIA( sessionBoard ); via = new ::VIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) ); via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrill( drillDiam ); via->SetDrill( drill_diam_iu );
if( (topLayerNdx==0 && botLayerNdx==1) if( (topLayerNdx==0 && botLayerNdx==1)
|| (topLayerNdx==copperLayerCount-2 && botLayerNdx==copperLayerCount-1)) || (topLayerNdx==copperLayerCount-2 && botLayerNdx==copperLayerCount-1))
@ -544,9 +547,13 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
GetChars( psid ) ); GetChars( psid ) );
} }
NETCLASSPTR netclass = aBoard->GetDesignSettings().m_NetClasses.GetDefault();
int via_drill_default = netclass->GetViaDrill();
for( unsigned v=0; v<wire_via->vertexes.size(); ++v ) for( unsigned v=0; v<wire_via->vertexes.size(); ++v )
{ {
::VIA* via = makeVIA( padstack, wire_via->vertexes[v], netCode ); ::VIA* via = makeVIA( padstack, wire_via->vertexes[v], netCode, via_drill_default );
aBoard->Add( via ); aBoard->Add( via );
} }
} }