CADSTAR PCB Archive Importer: Load Net Classes (Routing Widths in CADSTAR)

This commit is contained in:
Roberto Fernandez Bautista 2020-09-06 16:24:40 +01:00 committed by Seth Hillbrand
parent a3531b02e7
commit 94568e8699
2 changed files with 63 additions and 9 deletions

View File

@ -865,7 +865,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadTemplates()
(long long) getKiCadLength( csTemplate.Pouring.MinDisjointCopper )
* (long long) getKiCadLength( csTemplate.Pouring.MinDisjointCopper ) );
zone->SetZoneClearance( getKiCadLength( csTemplate.Pouring.AdditionalIsolation ) );
zone->SetLocalClearance( getKiCadLength( csTemplate.Pouring.AdditionalIsolation ) );
if( csTemplate.Pouring.FillType == TEMPLATE::POURING::COPPER_FILL_TYPE::HATCHED )
{
@ -1946,6 +1946,17 @@ CADSTAR_PCB_ARCHIVE_LOADER::PART CADSTAR_PCB_ARCHIVE_LOADER::getPart(
}
CADSTAR_PCB_ARCHIVE_LOADER::ROUTECODE CADSTAR_PCB_ARCHIVE_LOADER::getRouteCode(
const ROUTECODE_ID& aCadstarRouteCodeID )
{
wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID )
!= Assignments.Codedefs.RouteCodes.end(),
ROUTECODE() );
return Assignments.Codedefs.RouteCodes.at( aCadstarRouteCodeID );
}
CADSTAR_PCB_ARCHIVE_LOADER::HATCHCODE CADSTAR_PCB_ARCHIVE_LOADER::getHatchCode(
const HATCHCODE_ID& aCadstarHatchcodeID )
{
@ -2119,11 +2130,46 @@ NETINFO_ITEM* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet( const NET_ID& aCadstarNet
newName = wxT( "csNet-" );
newName << wxString::Format( "%i", csNet.SignalNum );
}
}
}
if( !mDoneNetClassWarning && !csNet.NetClassID.IsEmpty()
&& csNet.NetClassID != wxT( "NONE" ) )
{
wxLogMessage( _(
"The CADSTAR design contains nets with a 'Net Class' assigned. KiCad does "
"not have an equivalent to CADSTAR's Net Class so these elements were not "
"imported. Note: KiCad's version of 'Net Class' is closer to CADSTAR's "
"'Net Route Code' (which has been imported for all nets)." ) );
mDoneNetClassWarning = true;
}
if( !mDoneSpacingClassWarning && !csNet.SpacingClassID.IsEmpty()
&& csNet.SpacingClassID != wxT( "NONE" ) )
{
wxLogWarning( _(
"The CADSTAR design contains nets with a 'Spacing Class' assigned. KiCad does "
"not have an equivalent to CADSTAR's Spacing Class so these elements were not "
"imported. Please review the design rules as copper pours will affected by "
"this." ) );
mDoneSpacingClassWarning = true;
}
NETINFO_ITEM* netInfo = new NETINFO_ITEM( mBoard, newName, ++mNumNets );
mBoard->Add( netInfo, ADD_MODE::APPEND );
//todo also add the Netclass
if( mNetClassMap.find( csNet.RouteCodeID ) != mNetClassMap.end() )
{
NETCLASSPTR netclass = mNetClassMap.at( csNet.RouteCodeID );
netInfo->SetClass( netclass );
}
else
{
ROUTECODE rc = getRouteCode( csNet.RouteCodeID );
NETCLASSPTR netclass( new ::NETCLASS( rc.Name ) );
netclass->SetTrackWidth( getKiCadLength( rc.OptimalWidth ) );
netInfo->SetClass( netclass );
mNetClassMap.insert( { csNet.RouteCodeID, netclass } );
}
mNetMap.insert( { aCadstarNetID, netInfo } );
return netInfo;

View File

@ -38,11 +38,13 @@ public:
explicit CADSTAR_PCB_ARCHIVE_LOADER( wxString aFilename )
: CADSTAR_PCB_ARCHIVE_PARSER( aFilename )
{
mBoard = nullptr;
mDesignCenter.x = 0;
mDesignCenter.y = 0;
mDoneCopperWarning = false;
mNumNets = 0;
mBoard = nullptr;
mDesignCenter.x = 0;
mDesignCenter.y = 0;
mDoneCopperWarning = false;
mDoneSpacingClassWarning = false;
mDoneNetClassWarning = false;
mNumNets = 0;
}
~CADSTAR_PCB_ARCHIVE_LOADER()
@ -75,6 +77,7 @@ private:
///< the MODULE objects (these should have
///< been loaded to mBoard).
std::map<NET_ID, NETINFO_ITEM*> mNetMap; ///< Map between Cadstar and KiCad Nets
std::map<ROUTECODE_ID, NETCLASSPTR> mNetClassMap; ///< Map between Cadstar and KiCad classes
std::map<PHYSICAL_LAYER_ID, LAYER_ID> mCopperLayers; ///< Map of CADSTAR Physical layers to
///< CADSTAR Layer IDs
std::vector<LAYER_ID> mPowerPlaneLayers; ///< List of layers that are marked as
@ -87,6 +90,10 @@ private:
///< avoid multiple duplicate warnings
bool mDoneCopperWarning; ///< Used by loadCoppers() to avoid
///< multiple duplicate warnings
bool mDoneSpacingClassWarning; ///< Used by getKiCadNet() to avoid
///< multiple duplicate warnings
bool mDoneNetClassWarning; ///< Used by getKiCadNet() to avoid
///< multiple duplicate warnings
int mNumNets; ///< Number of nets loaded so far
@ -295,8 +302,9 @@ private:
LAYERPAIR getLayerPair( const LAYERPAIR_ID& aCadstarLayerPairID );
PADCODE getPadCode( const PADCODE_ID& aCadstarPadCodeID );
PART getPart( const PART_ID& aCadstarPartID );
VIACODE getViaCode( const VIACODE_ID& aCadstarViaCodeID );
ROUTECODE getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID );
TEXTCODE getTextCode( const TEXTCODE_ID& aCadstarTextCodeID );
VIACODE getViaCode( const VIACODE_ID& aCadstarViaCodeID );
wxString getAttributeName( const ATTRIBUTE_ID& aCadstarAttributeID );