Fix some warnings in the cadstar importer

This commit is contained in:
Ian McInerney 2020-09-16 11:27:15 +01:00
parent 4ca103c82c
commit aa0b0ca7e7
2 changed files with 47 additions and 29 deletions

View File

@ -126,7 +126,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadBoardStackup()
int dielectricSublayer = 0;
int numDielectricLayers = 0;
bool prevWasDielectric = false;
BOARD_STACKUP_ITEM* tempKiCadLayer;
BOARD_STACKUP_ITEM* tempKiCadLayer = nullptr;
std::vector<PCB_LAYER_ID> layerIDs;
//Remove all layers except required ones
@ -164,9 +164,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadBoardStackup()
case LAYER_TYPE::ASSCOMPCOPP:
case LAYER_TYPE::NOLAYER:
//Shouldn't be here if CPA file is correctly parsed and not corrupt
THROW_IO_ERROR( wxString::Format(
_( "Unexpected layer '%s' in layer stack." ), curLayer.Name ) );
continue;
THROW_IO_ERROR( wxString::Format( _( "Unexpected layer '%s' in layer stack." ),
curLayer.Name ) );
case LAYER_TYPE::JUMPERLAYER:
copperType = LAYER_T::LT_JUMPER;
kicadLayerID = getKiCadCopperLayerID( ++numElecAndPowerLayers );
@ -678,13 +678,17 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads( const SYMDEF& aComponent, MODU
if( csPadcode.DrillDiameter != UNDEFINED_VALUE )
{
if( csPadcode.SlotLength != UNDEFINED_VALUE )
{
pad->SetDrillSize( { getKiCadLength( csPadcode.DrillDiameter ),
getKiCadLength( (long long) csPadcode.DrillOversize
+ (long long) csPadcode.DrillDiameter ) } );
}
else
{
pad->SetDrillSize( { getKiCadLength( csPadcode.DrillDiameter ),
getKiCadLength( csPadcode.DrillDiameter ) } );
}
}
//TODO handle csPadcode.Reassigns when KiCad supports full padstacks
}
}
@ -713,17 +717,19 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadGroups()
if( !csGroup.GroupID.IsEmpty() )
{
if( mGroupMap.find( csGroup.ID ) == mGroupMap.end() )
{
THROW_IO_ERROR( wxString::Format(
_( "The file appears to be corrupt. Unable to find group ID %s "
"in the group definitions." ),
csGroup.ID ) );
}
else if( mGroupMap.find( csGroup.ID ) == mGroupMap.end() )
{
THROW_IO_ERROR( wxString::Format(
_( "The file appears to be corrupt. Unable to find sub group %s "
"in the group map (parent group ID=%s, Name=%s)." ),
csGroup.GroupID, csGroup.ID, csGroup.Name ) );
}
else
{
PCB_GROUP* kiCadGroup = mGroupMap.at( csGroup.ID );
@ -1251,7 +1257,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNets()
wxString netnameForErrorReporting = net.Name;
if( netnameForErrorReporting.IsEmpty() )
netnameForErrorReporting = "$" + net.SignalNum;
netnameForErrorReporting = wxString::Format( "$%ld", net.SignalNum );
for( NET::CONNECTION connection : net.Connections )
{
@ -1689,7 +1695,9 @@ DRAWSEGMENT* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT&
case VERTEX_TYPE::POINT:
if( isModule( aContainer ) )
ds = new EDGE_MODULE( (MODULE*) aContainer, STROKE_T::S_SEGMENT );
{
ds = new EDGE_MODULE( static_cast<MODULE*>( aContainer ), STROKE_T::S_SEGMENT );
}
else
{
ds = new DRAWSEGMENT( aContainer );
@ -1703,11 +1711,15 @@ DRAWSEGMENT* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT&
case VERTEX_TYPE::CLOCKWISE_SEMICIRCLE:
case VERTEX_TYPE::CLOCKWISE_ARC:
cw = true;
KI_FALLTHROUGH;
case VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE:
case VERTEX_TYPE::ANTICLOCKWISE_ARC:
if( isModule( aContainer ) )
{
ds = new EDGE_MODULE( (MODULE*) aContainer, STROKE_T::S_ARC );
}
else
{
ds = new DRAWSEGMENT( aContainer );
@ -1727,6 +1739,7 @@ DRAWSEGMENT* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT&
ds->SetAngle( NormalizeAnglePos( arcAngle ) );
else
ds->SetAngle( NormalizeAngleNeg( arcAngle ) );
break;
}
@ -1748,7 +1761,7 @@ DRAWSEGMENT* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT&
ds->Move( aMoveVector );
if( isModule( aContainer ) && ds != nullptr )
( (EDGE_MODULE*) ds )->SetLocalCoord();
static_cast<EDGE_MODULE*>( ds )->SetLocalCoord();
if( !aCadstarGroupID.IsEmpty() )
addToGroup( aCadstarGroupID, ds );
@ -1768,16 +1781,16 @@ ZONE_CONTAINER* CADSTAR_PCB_ARCHIVE_LOADER::getZoneFromCadstarShape(
zone->SetHatchStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL );
}
else
{
zone->SetHatchStyle( ZONE_BORDER_DISPLAY_STYLE::NO_HATCH );
}
SHAPE_POLY_SET polygon = getPolySetFromCadstarShape( aCadstarShape, aLineThickness );
zone->AddPolygon( polygon.COutline( 0 ) );
for( int i = 0; i < polygon.HoleCount( 0 ); i++ )
{
zone->AddPolygon( polygon.CHole( 0, i ) );
}
return zone;
}

View File

@ -677,14 +677,19 @@ void CADSTAR_PCB_ARCHIVE_PARSER::HEADER::Parse( XNODE* aNode )
Format.Parse( cNode );
if( Format.Type != wxT( "LAYOUT" ) )
{
if( Format.Type == wxT( "LIBRARY" ) )
THROW_IO_ERROR(
"The selected file is a CADSTAR Library file (as opposed to a Layout "
"file). CADSTAR libraries cannot yet be imported into KiCad." );
{
THROW_IO_ERROR( "The selected file is a CADSTAR Library file (as opposed to"
" a Layout file). CADSTAR libraries cannot yet be imported"
" into KiCad." );
}
else
THROW_IO_ERROR(
"The selected file is an unknown CADSTAR format so cannot be "
{
THROW_IO_ERROR( "The selected file is an unknown CADSTAR format so cannot be "
"imported into KiCad." );
}
}
}
else if( nodeName == wxT( "JOBFILE" ) )