CADSTAR PCB Archive Importer: Resolve comments in MR

- Change wxASSERT(false) to wxFAIL_MSG
- Fix double negative
- Add small comment to TXT_HEIGHT_RATIO
This commit is contained in:
Roberto Fernandez Bautista 2020-10-19 18:11:52 +01:00 committed by Jon Evans
parent 6fb338d136
commit e7ab924a86
2 changed files with 21 additions and 16 deletions

View File

@ -25,7 +25,7 @@
#include <plugins/cadstar/cadstar_archive_parser.h> #include <plugins/cadstar/cadstar_archive_parser.h>
// Ratio derived from CADSTAR default font. See doxygen comment in cadstar_archive_parser.h
const double CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO = ( 24.0 - 5.0 ) / 24.0; const double CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO = ( 24.0 - 5.0 ) / 24.0;

View File

@ -177,14 +177,19 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadBoardStackup()
for( auto it = cpaLayerStack.begin(); it != cpaLayerStack.end(); ++it ) for( auto it = cpaLayerStack.begin(); it != cpaLayerStack.end(); ++it )
{ {
LAYER curLayer = cpaLayers[*it];
BOARD_STACKUP_ITEM_TYPE kicadLayerType = BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_UNDEFINED; BOARD_STACKUP_ITEM_TYPE kicadLayerType = BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_UNDEFINED;
LAYER_T copperType = LAYER_T::LT_UNDEFINED; LAYER_T copperType = LAYER_T::LT_UNDEFINED;
PCB_LAYER_ID kicadLayerID = PCB_LAYER_ID::UNDEFINED_LAYER; PCB_LAYER_ID kicadLayerID = PCB_LAYER_ID::UNDEFINED_LAYER;
wxString layerTypeName = wxEmptyString; wxString layerTypeName = wxEmptyString;
if( cpaLayers.count( *it ) == 0 ) if( cpaLayers.find( *it ) == cpaLayers.end() )
wxASSERT_MSG( true, wxT( "Unable to find layer index" ) ); {
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt: The layer "
"stack refers to layer ID '%s' which does not exist in the layer "
"definitions." ) );
}
LAYER curLayer = cpaLayers.at( *it );
if( prevWasDielectric && ( curLayer.Type != LAYER_TYPE::CONSTRUCTION ) ) if( prevWasDielectric && ( curLayer.Type != LAYER_TYPE::CONSTRUCTION ) )
{ {
@ -382,13 +387,13 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadBoardStackup()
break; break;
default: default:
wxASSERT_MSG( true, wxT( "Unknown CADSTAR Layer Sub-type" ) ); wxFAIL_MSG( "Unknown CADSTAR Layer Sub-type" );
break; break;
} }
break; break;
default: default:
wxASSERT_MSG( true, wxT( "Unknown CADSTAR Layer Type" ) ); wxFAIL_MSG( "Unknown CADSTAR Layer Type" );
break; break;
} }
@ -516,7 +521,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::remapUnsureLayers()
{ {
if( layerPair.second == PCB_LAYER_ID::UNDEFINED_LAYER ) if( layerPair.second == PCB_LAYER_ID::UNDEFINED_LAYER )
{ {
wxASSERT_MSG( false, "Unexpected Layer ID" ); wxFAIL_MSG( "Unexpected Layer ID" );
continue; continue;
} }
@ -708,7 +713,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads( const SYMDEF_PCB& aComponent,
break; break;
default: default:
wxASSERT_MSG( true, "Unknown Pad type" ); wxFAIL_MSG( "Unknown Pad type" );
} }
pad->SetName( csPad.Identifier.IsEmpty() ? wxString::Format( wxT( "%ld" ), csPad.ID ) : pad->SetName( csPad.Identifier.IsEmpty() ? wxString::Format( wxT( "%ld" ), csPad.ID ) :
@ -796,7 +801,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads( const SYMDEF_PCB& aComponent,
break; break;
default: default:
wxASSERT_MSG( true, "Unknown Pad Shape" ); wxFAIL_MSG( "Unknown Pad Shape" );
} }
if( csPadcode.ReliefClearance != UNDEFINED_VALUE ) if( csPadcode.ReliefClearance != UNDEFINED_VALUE )
@ -969,7 +974,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions()
break; break;
case UNITS::DESIGN: case UNITS::DESIGN:
wxASSERT( false ); // Should not be here wxFAIL_MSG( "DESIGN units requested - this should not happen." );
break; break;
} }
@ -1573,7 +1578,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
txt->SetTextAngle( getAngleTenthDegree( aCadstarText.OrientAngle ) + aRotationAngle ); txt->SetTextAngle( getAngleTenthDegree( aCadstarText.OrientAngle ) + aRotationAngle );
if( !aCadstarText.Mirror != !aMirrorInvert ) // If mirroring, invert angle to match CADSTAR if( aCadstarText.Mirror != aMirrorInvert ) // If mirroring, invert angle to match CADSTAR
txt->SetTextAngle( -txt->GetTextAngle() ); txt->SetTextAngle( -txt->GetTextAngle() );
txt->SetMirrored( aCadstarText.Mirror ); txt->SetMirrored( aCadstarText.Mirror );
@ -1636,7 +1641,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
break; break;
default: default:
wxASSERT_MSG( true, "Unknown Aligment - needs review!" ); wxFAIL_MSG( "Unknown Aligment - needs review!" );
} }
if( aMirrorInvert ) if( aMirrorInvert )
@ -2031,7 +2036,7 @@ SHAPE_LINE_CHAIN CADSTAR_PCB_ARCHIVE_LOADER::getLineChainFromDrawsegments(
break; break;
default: default:
wxASSERT_MSG( true, "Drawsegment type is unexpected. Ignored." ); wxFAIL_MSG( "Drawsegment type is unexpected. Ignored." );
} }
} }
@ -2087,7 +2092,7 @@ std::vector<TRACK*> CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(
break; break;
default: default:
wxASSERT_MSG( true, "Drawsegment type is unexpected. Ignored." ); wxFAIL_MSG( "Drawsegment type is unexpected. Ignored." );
continue; continue;
} }
@ -2230,7 +2235,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
break; break;
default: default:
wxASSERT_MSG( true, "Unknown Aligment - needs review!" ); wxFAIL_MSG( "Unknown Aligment - needs review!" );
} }
//TODO Handle different font types when KiCad can support it. //TODO Handle different font types when KiCad can support it.
@ -2521,7 +2526,7 @@ NETINFO_ITEM* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet( const NET_ID& aCadstarNet
} }
else else
{ {
wxASSERT_MSG( false, "A net with no pins associated?" ); wxFAIL_MSG( "A net with no pins associated?" );
newName = wxT( "csNet-" ); newName = wxT( "csNet-" );
newName << wxString::Format( "%i", csNet.SignalNum ); newName << wxString::Format( "%i", csNet.SignalNum );
} }