Move ALTIUM_PCB to use REPORTER for logging

Change not-yet-supported messages to debug level

(cherry picked from commit e973c15087)
This commit is contained in:
Jon Evans 2024-04-30 21:21:48 -04:00
parent e1cad6189e
commit 83be5ba63d
6 changed files with 330 additions and 75 deletions

View File

@ -44,6 +44,7 @@
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <font/outline_font.h> #include <font/outline_font.h>
#include <project.h> #include <project.h>
#include <reporter.h>
#include <trigo.h> #include <trigo.h>
#include <utf.h> #include <utf.h>
#include <wx/docview.h> #include <wx/docview.h>
@ -262,11 +263,12 @@ std::vector<PCB_LAYER_ID> ALTIUM_PCB::GetKicadLayersToIterate( ALTIUM_LAYER aAlt
} }
ALTIUM_PCB::ALTIUM_PCB( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter, ALTIUM_PCB::ALTIUM_PCB( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter, REPORTER* aReporter,
const wxString& aLibrary, const wxString& aFootprintName ) const wxString& aLibrary, const wxString& aFootprintName )
{ {
m_board = aBoard; m_board = aBoard;
m_progressReporter = aProgressReporter; m_progressReporter = aProgressReporter;
m_reporter = aReporter;
m_doneCount = 0; m_doneCount = 0;
m_lastProgressCount = 0; m_lastProgressCount = 0;
m_totalCount = 0; m_totalCount = 0;
@ -440,7 +442,13 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi
if( reader.HasParsingError() ) if( reader.HasParsingError() )
{ {
wxLogError( _( "'%s' was not parsed correctly." ), FormatPath( mappedFile ) ); if( m_reporter )
{
m_reporter->Report( wxString::Format( _( "'%s' was not parsed correctly." ),
FormatPath( mappedFile ) ),
RPT_SEVERITY_ERROR );
}
continue; continue;
} }
@ -448,7 +456,13 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi
if( reader.GetRemainingBytes() != 0 ) if( reader.GetRemainingBytes() != 0 )
{ {
wxLogError( _( "'%s' was not fully parsed." ), FormatPath( mappedFile ) ); if( m_reporter )
{
m_reporter->Report( wxString::Format( _( "'%s' was not fully parsed." ),
FormatPath( mappedFile ) ),
RPT_SEVERITY_ERROR );
}
continue; continue;
} }
} }
@ -503,8 +517,13 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi
} }
else if( isRequired ) else if( isRequired )
{ {
wxLogError( _( "File not found: '%s' for directory '%s'." ), FormatPath( mappedFile ), if( m_reporter )
magic_enum::enum_name( directory ) ); {
m_reporter->Report( wxString::Format( _( "File not found: '%s' for directory '%s'." ),
FormatPath( mappedFile ),
magic_enum::enum_name( directory ) ),
RPT_SEVERITY_ERROR );
}
} }
} }
@ -687,7 +706,13 @@ FOOTPRINT* ALTIUM_PCB::ParseFootprint( ALTIUM_COMPOUND_FILE& altiumLibFile,
} }
else else
{ {
wxLogError( _( "File not found: '%s'." ), FormatPath( parametersStreamName ) ); if( m_reporter )
{
m_reporter->Report( wxString::Format( _( "File not found: '%s'." ),
FormatPath( parametersStreamName ) ),
RPT_SEVERITY_ERROR );
}
footprint->SetLibDescription( wxT( "" ) ); footprint->SetLibDescription( wxT( "" ) );
} }
@ -858,6 +883,7 @@ void ALTIUM_PCB::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile
// THROW_IO_ERROR( "FileHeader stream is not fully parsed" ); // THROW_IO_ERROR( "FileHeader stream is not fully parsed" );
} }
void ALTIUM_PCB::ParseExtendedPrimitiveInformationData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, void ALTIUM_PCB::ParseExtendedPrimitiveInformationData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
const CFB::COMPOUND_FILE_ENTRY* aEntry ) const CFB::COMPOUND_FILE_ENTRY* aEntry )
{ {
@ -879,6 +905,7 @@ void ALTIUM_PCB::ParseExtendedPrimitiveInformationData( const ALTIUM_COMPOUND_FI
THROW_IO_ERROR( wxT( "ExtendedPrimitiveInformation stream is not fully parsed" ) ); THROW_IO_ERROR( wxT( "ExtendedPrimitiveInformation stream is not fully parsed" ) );
} }
void ALTIUM_PCB::ParseBoard6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, void ALTIUM_PCB::ParseBoard6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
const CFB::COMPOUND_FILE_ENTRY* aEntry ) const CFB::COMPOUND_FILE_ENTRY* aEntry )
{ {
@ -1021,6 +1048,7 @@ void ALTIUM_PCB::ParseBoard6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile
HelperCreateBoardOutline( elem.board_vertices ); HelperCreateBoardOutline( elem.board_vertices );
} }
void ALTIUM_PCB::HelperCreateBoardOutline( const std::vector<ALTIUM_VERTICE>& aVertices ) void ALTIUM_PCB::HelperCreateBoardOutline( const std::vector<ALTIUM_VERTICE>& aVertices )
{ {
SHAPE_LINE_CHAIN lineChain; SHAPE_LINE_CHAIN lineChain;
@ -1059,6 +1087,7 @@ void ALTIUM_PCB::HelperCreateBoardOutline( const std::vector<ALTIUM_VERTICE>& aV
} }
} }
void ALTIUM_PCB::ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, void ALTIUM_PCB::ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
const CFB::COMPOUND_FILE_ENTRY* aEntry ) const CFB::COMPOUND_FILE_ENTRY* aEntry )
{ {
@ -1089,8 +1118,13 @@ void ALTIUM_PCB::ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFi
{ {
// Name conflict, happens in some unknown circumstances // Name conflict, happens in some unknown circumstances
// unique_ptr will delete nc on this code path // unique_ptr will delete nc on this code path
wxLogWarning( _( "More than one Altium netclass with name '%s' found. " if( m_reporter )
"Only the first one will be imported." ), elem.name ); {
wxString msg;
msg.Printf( _( "More than one Altium netclass with name '%s' found. "
"Only the first one will be imported." ), elem.name );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
else else
{ {
@ -1105,6 +1139,7 @@ void ALTIUM_PCB::ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFi
m_board->m_LegacyNetclassesLoaded = true; m_board->m_LegacyNetclassesLoaded = true;
} }
void ALTIUM_PCB::ParseComponents6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, void ALTIUM_PCB::ParseComponents6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
const CFB::COMPOUND_FILE_ENTRY* aEntry ) const CFB::COMPOUND_FILE_ENTRY* aEntry )
{ {
@ -1197,9 +1232,14 @@ void ALTIUM_PCB::ParseComponentsBodies6Data( const ALTIUM_COMPOUND_FILE& aAl
if( modelTuple == m_models.end() ) if( modelTuple == m_models.end() )
{ {
wxLogError( wxT( "ComponentsBodies6 stream tries to access model id %s which does not " if( m_reporter )
"exist" ), {
elem.modelId ); wxString msg;
msg.Printf( wxT( "ComponentsBodies6 stream tries to access model id %s which does "
"not exist" ), elem.modelId );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
continue; continue;
} }
@ -1394,7 +1434,12 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem)
if( aElem.textPoint.empty() ) if( aElem.textPoint.empty() )
{ {
wxLogError( wxT( "No text position present for leader dimension object" ) ); if( m_reporter )
{
m_reporter->Report( wxT( "No text position present for leader dimension object" ),
RPT_SEVERITY_ERROR );
}
return; return;
} }
@ -1427,9 +1472,14 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem )
if( klayer == UNDEFINED_LAYER ) if( klayer == UNDEFINED_LAYER )
{ {
wxLogWarning( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. " if( m_reporter )
"It has been moved to KiCad layer Eco1_User." ), {
aElem.layer ); wxString msg;
msg.Printf( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. "
"It has been moved to KiCad layer Eco1_User." ), aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
klayer = Eco1_User; klayer = Eco1_User;
} }
@ -1483,7 +1533,12 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem )
if( aElem.textPoint.empty() ) if( aElem.textPoint.empty() )
{ {
wxLogError( wxT( "No text position present for leader dimension object" ) ); if( m_reporter )
{
m_reporter->Report( wxT( "No text position present for leader dimension object" ),
RPT_SEVERITY_ERROR );
}
return; return;
} }
@ -1505,9 +1560,14 @@ void ALTIUM_PCB::HelperParseDimensions6Datum( const ADIMENSION6& aElem )
if( klayer == UNDEFINED_LAYER ) if( klayer == UNDEFINED_LAYER )
{ {
wxLogWarning( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. " if( m_reporter )
"It has been moved to KiCad layer Eco1_User." ), {
aElem.layer ); wxString msg;
msg.Printf( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. "
"It has been moved to KiCad layer Eco1_User." ), aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_INFO );
}
klayer = Eco1_User; klayer = Eco1_User;
} }
@ -1529,9 +1589,14 @@ void ALTIUM_PCB::HelperParseDimensions6Center( const ADIMENSION6& aElem )
if( klayer == UNDEFINED_LAYER ) if( klayer == UNDEFINED_LAYER )
{ {
wxLogWarning( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. " if( m_reporter )
"It has been moved to KiCad layer Eco1_User." ), {
aElem.layer ); wxString msg;
msg.Printf( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. "
"It has been moved to KiCad layer Eco1_User." ), aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_INFO );
}
klayer = Eco1_User; klayer = Eco1_User;
} }
@ -1572,14 +1637,24 @@ void ALTIUM_PCB::ParseDimensions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPc
HelperParseDimensions6Leader( elem ); HelperParseDimensions6Leader( elem );
break; break;
case ALTIUM_DIMENSION_KIND::DATUM: case ALTIUM_DIMENSION_KIND::DATUM:
wxLogError( _( "Ignored dimension of kind %d (not yet supported)." ), elem.kind ); if( m_reporter )
{
wxString msg;
msg.Printf( _( "Ignored dimension of kind %d (not yet supported)." ), elem.kind );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
// HelperParseDimensions6Datum( elem ); // HelperParseDimensions6Datum( elem );
break; break;
case ALTIUM_DIMENSION_KIND::CENTER: case ALTIUM_DIMENSION_KIND::CENTER:
HelperParseDimensions6Center( elem ); HelperParseDimensions6Center( elem );
break; break;
default: default:
wxLogError( _( "Ignored dimension of kind %d (not yet supported)." ), elem.kind ); if( m_reporter )
{
wxString msg;
msg.Printf( _( "Ignored dimension of kind %d (not yet supported)." ), elem.kind );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
break; break;
} }
} }
@ -1619,9 +1694,15 @@ void ALTIUM_PCB::ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile
{ {
if( !altiumModelsPath.Mkdir() ) if( !altiumModelsPath.Mkdir() )
{ {
wxLogError( _( "Failed to create folder '%s'." ) + wxS( " " ) if( m_reporter )
+ _( "No 3D-models will be imported." ), {
altiumModelsPath.GetFullPath() ); wxString msg;
msg.Printf( _( "Failed to create folder '%s'." ) + wxS( " " )
+ _( "No 3D-models will be imported." ),
altiumModelsPath.GetFullPath() );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
return; return;
} }
} }
@ -1649,8 +1730,14 @@ void ALTIUM_PCB::ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile
if( stepEntry == nullptr ) if( stepEntry == nullptr )
{ {
wxLogError( _( "File not found: '%s'. 3D-model not imported." ), if( m_reporter )
FormatPath( stepPath ) ); {
wxString msg;
msg.Printf( _( "File not found: '%s'. 3D-model not imported." ),
FormatPath( stepPath ) );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
continue; continue;
} }
@ -1663,8 +1750,14 @@ void ALTIUM_PCB::ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile
if( !storagePath.IsDirWritable() ) if( !storagePath.IsDirWritable() )
{ {
wxLogError( _( "Insufficient permissions to save file '%s'." ), if( m_reporter )
storagePath.GetFullPath() ); {
wxString msg;
msg.Printf( _( "Insufficient permissions to save file '%s'." ),
storagePath.GetFullPath() );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
continue; continue;
} }
@ -1692,6 +1785,7 @@ void ALTIUM_PCB::ParseNets6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
ALTIUM_BINARY_PARSER reader( aAltiumPcbFile, aEntry ); ALTIUM_BINARY_PARSER reader( aAltiumPcbFile, aEntry );
wxASSERT( m_altiumToKicadNetcodes.empty() ); wxASSERT( m_altiumToKicadNetcodes.empty() );
while( reader.GetRemainingBytes() >= 4 /* TODO: use Header section of file */ ) while( reader.GetRemainingBytes() >= 4 /* TODO: use Header section of file */ )
{ {
checkpoint(); checkpoint();
@ -2025,10 +2119,14 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToBoardItem( const AREGION6& aElem )
if( klayer == UNDEFINED_LAYER ) if( klayer == UNDEFINED_LAYER )
{ {
wxLogWarning( if( m_reporter )
_( "Dashed outline found on an Altium layer (%d) with no KiCad equivalent. " {
"It has been moved to KiCad layer Eco1_User." ), wxString msg;
aElem.layer ); msg.Printf( _( "Dashed outline found on an Altium layer (%d) with no KiCad equivalent. "
"It has been moved to KiCad layer Eco1_User." ), aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
klayer = Eco1_User; klayer = Eco1_User;
} }
@ -2067,7 +2165,12 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToBoardItem( const AREGION6& aElem )
} }
else else
{ {
wxLogError( _( "Ignored polygon shape of kind %d (not yet supported)." ), aElem.kind ); if( m_reporter )
{
wxString msg;
msg.Printf( _( "Ignored polygon shape of kind %d (not yet supported)." ), aElem.kind );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
} }
@ -2138,19 +2241,29 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToFootprintItem( FOOTPRINT* aFoot
{ {
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogWarning( _( "Loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Loading library '%s':\n"
"Footprint %s contains a dashed outline on Altium layer (%d) with " "Footprint %s contains a dashed outline on Altium layer (%d) with "
"no KiCad equivalent. It has been moved to KiCad layer Eco1_User." ), "no KiCad equivalent. It has been moved to KiCad layer Eco1_User." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.layer ); aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
else else
{ {
wxLogWarning( _( "Footprint %s contains a dashed outline on Altium layer (%d) with " if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s contains a dashed outline on Altium layer (%d) with "
"no KiCad equivalent. It has been moved to KiCad layer Eco1_User." ), "no KiCad equivalent. It has been moved to KiCad layer Eco1_User." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.layer ); aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
klayer = Eco1_User; klayer = Eco1_User;
@ -2185,17 +2298,27 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToFootprintItem( FOOTPRINT* aFoot
{ {
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogError( _( "Error loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Error loading library '%s':\n"
"Footprint %s contains polygon shape of kind %d (not yet supported)." ), "Footprint %s contains polygon shape of kind %d (not yet supported)." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.kind ); aElem.kind );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
else else
{ {
wxLogError( _( "Footprint %s contains polygon shape of kind %d (not yet supported)." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s contains polygon shape of kind %d (not yet supported)." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.kind ); aElem.kind );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
} }
} }
@ -2753,17 +2876,27 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
// TODO: I assume other values are possible as well? // TODO: I assume other values are possible as well?
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogError( _( "Error loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Error loading library '%s':\n"
"Footprint %s pad %s is not marked as multilayer, but is a TH pad." ), "Footprint %s pad %s is not marked as multilayer, but is a TH pad." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
else else
{ {
wxLogError( _( "Footprint %s pad %s is not marked as multilayer, but is a TH pad." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s pad %s is not marked as multilayer, but is a TH pad." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
}
} }
} }
@ -2785,17 +2918,27 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
case ALTIUM_PAD_HOLE_SHAPE::SQUARE: case ALTIUM_PAD_HOLE_SHAPE::SQUARE:
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogWarning( _( "Loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Loading library '%s':\n"
"Footprint %s pad %s has a square hole (not yet supported)." ), "Footprint %s pad %s has a square hole (not yet supported)." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
else else
{ {
wxLogWarning( _( "Footprint %s pad %s has a square hole (not yet supported)." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s pad %s has a square hole (not yet supported)." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE ); pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE );
@ -2823,21 +2966,31 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
{ {
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogWarning( _( "Loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Loading library '%s':\n"
"Footprint %s pad %s has a hole-rotation of %f degrees. " "Footprint %s pad %s has a hole-rotation of %f degrees. "
"KiCad only supports 90 degree rotations." ), "KiCad only supports 90 degree rotations." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name, aElem.name,
slotRotation.AsDegrees() ); slotRotation.AsDegrees() );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
else else
{ {
wxLogWarning( _( "Footprint %s pad %s has a hole-rotation of %f degrees. " if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s pad %s has a hole-rotation of %f degrees. "
"KiCad only supports 90 degree rotations." ), "KiCad only supports 90 degree rotations." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name, aElem.name,
slotRotation.AsDegrees() ); slotRotation.AsDegrees() );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
} }
@ -2848,19 +3001,29 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
case ALTIUM_PAD_HOLE_SHAPE::UNKNOWN: case ALTIUM_PAD_HOLE_SHAPE::UNKNOWN:
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogError( _( "Error loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Error loading library '%s':\n"
"Footprint %s pad %s uses a hole of unknown kind %d." ), "Footprint %s pad %s uses a hole of unknown kind %d." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name, aElem.name,
aElem.sizeAndShape->holeshape ); aElem.sizeAndShape->holeshape );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
else else
{ {
wxLogError( _( "Footprint %s pad %s uses a hole of unknown kind %d." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s pad %s uses a hole of unknown kind %d." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name, aElem.name,
aElem.sizeAndShape->holeshape ); aElem.sizeAndShape->holeshape );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE ); pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE );
@ -2877,17 +3040,27 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
{ {
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogError( _( "Error loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Error loading library '%s':\n"
"Footprint %s pad %s uses a complex pad stack (not yet supported)." ), "Footprint %s pad %s uses a complex pad stack (not yet supported)." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
else else
{ {
wxLogError( _( "Footprint %s pad %s uses a complex pad stack (not yet supported)." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s pad %s uses a complex pad stack (not yet supported)." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
} }
@ -2926,17 +3099,27 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
default: default:
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogError( _( "Error loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Error loading library '%s':\n"
"Footprint %s pad %s uses an unknown pad-shape." ), "Footprint %s pad %s uses an unknown pad-shape." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
else else
{ {
wxLogError( _( "Footprint %s pad %s uses an unknown pad-shape." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s pad %s uses an unknown pad-shape." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
break; break;
} }
@ -2994,9 +3177,15 @@ void ALTIUM_PCB::ConvertPads6ToBoardItemOnNonCopper( const APAD6& aElem )
if( klayer == UNDEFINED_LAYER ) if( klayer == UNDEFINED_LAYER )
{ {
wxLogWarning( _( "Non-copper pad %s found on an Altium layer (%d) with no KiCad " if( m_reporter )
{
wxString msg;
msg.Printf( _( "Non-copper pad %s found on an Altium layer (%d) with no KiCad "
"equivalent. It has been moved to KiCad layer Eco1_User." ), "equivalent. It has been moved to KiCad layer Eco1_User." ),
aElem.name, aElem.layer ); aElem.name, aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_INFO );
}
klayer = Eco1_User; klayer = Eco1_User;
} }
@ -3016,21 +3205,31 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnNonCopper( FOOTPRINT* aFootprint,
{ {
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogWarning( _( "Loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Loading library '%s':\n"
"Footprint %s non-copper pad %s found on an Altium layer (%d) with no " "Footprint %s non-copper pad %s found on an Altium layer (%d) with no "
"KiCad equivalent. It has been moved to KiCad layer Eco1_User." ), "KiCad equivalent. It has been moved to KiCad layer Eco1_User." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.name, aElem.name,
aElem.layer ); aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_INFO );
}
} }
else else
{ {
wxLogWarning( _( "Footprint %s non-copper pad %s found on an Altium layer (%d) with no " if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s non-copper pad %s found on an Altium layer (%d) with no "
"KiCad equivalent. It has been moved to KiCad layer Eco1_User." ), "KiCad equivalent. It has been moved to KiCad layer Eco1_User." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.name, aElem.name,
aElem.layer ); aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_INFO );
}
} }
klayer = Eco1_User; klayer = Eco1_User;
@ -3049,19 +3248,34 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay
{ {
if( aElem.net != ALTIUM_NET_UNCONNECTED ) if( aElem.net != ALTIUM_NET_UNCONNECTED )
{ {
wxLogError( _( "Non-copper pad %s is connected to a net, which is not supported." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Non-copper pad %s is connected to a net, which is not supported." ),
aElem.name ); aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
if( aElem.holesize != 0 ) if( aElem.holesize != 0 )
{ {
wxLogError( _( "Non-copper pad %s has a hole, which is not supported." ), aElem.name ); if( m_reporter )
{
wxString msg;
msg.Printf( _( "Non-copper pad %s has a hole, which is not supported." ), aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
if( aElem.padmode != ALTIUM_PAD_MODE::SIMPLE ) if( aElem.padmode != ALTIUM_PAD_MODE::SIMPLE )
{ {
wxLogWarning( _( "Non-copper pad %s has a complex pad stack (not yet supported)." ), if( m_reporter )
aElem.name ); {
wxString msg;
msg.Printf( _( "Non-copper pad %s has a complex pad stack (not yet supported)." ),
aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
switch( aElem.topshape ) switch( aElem.topshape )
@ -3202,7 +3416,13 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay
case ALTIUM_PAD_SHAPE::UNKNOWN: case ALTIUM_PAD_SHAPE::UNKNOWN:
default: default:
wxLogError( _( "Non-copper pad %s uses an unknown pad-shape." ), aElem.name ); if( m_reporter )
{
wxString msg;
msg.Printf( _( "Non-copper pad %s uses an unknown pad-shape." ), aElem.name );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
break; break;
} }
} }
@ -3253,10 +3473,16 @@ void ALTIUM_PCB::ParseVias6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
if( !IsCopperLayer( start_klayer ) || !IsCopperLayer( end_klayer ) ) if( !IsCopperLayer( start_klayer ) || !IsCopperLayer( end_klayer ) )
{ {
wxLogError( _( "Via from layer %d to %d uses a non-copper layer, which is not " if( m_reporter )
"supported." ), {
wxString msg;
msg.Printf( _( "Via from layer %d to %d uses a non-copper layer, which is not "
"supported." ),
elem.layer_start, elem.layer_start,
elem.layer_end ); elem.layer_end );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
continue; // just assume through-hole instead. continue; // just assume through-hole instead.
} }
@ -3304,10 +3530,16 @@ void ALTIUM_PCB::ConvertTracks6ToBoardItem( const ATRACK6& aElem, const int aPri
if( m_polygons.size() <= aElem.polygon ) if( m_polygons.size() <= aElem.polygon )
{ {
// Can happen when reading old Altium files: just skip this item // Can happen when reading old Altium files: just skip this item
wxLogError( "ATRACK6 stream tries to access polygon id %u " if( m_reporter )
"of %u existing polygons. Skip it", {
(unsigned) aElem.polygon, wxString msg;
(unsigned)m_polygons.size() ); msg.Printf( wxT( "ATRACK6 stream tries to access polygon id %u "
"of %u existing polygons; skipping it" ),
static_cast<unsigned>( aElem.polygon ),
static_cast<unsigned>( m_polygons.size() ) );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
return; return;
} }
@ -3523,7 +3755,14 @@ void ALTIUM_PCB::ConvertTexts6ToBoardItem( const ATEXT6& aElem )
{ {
if( aElem.fonttype == ALTIUM_TEXT_TYPE::BARCODE ) if( aElem.fonttype == ALTIUM_TEXT_TYPE::BARCODE )
{ {
wxLogError( _( "Ignored barcode on Altium layer %d (not yet supported)." ), aElem.layer ); if( m_reporter )
{
wxString msg;
msg.Printf( _( "Ignored barcode on Altium layer %d (not yet supported)." ),
aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
return; return;
} }
@ -3538,17 +3777,27 @@ void ALTIUM_PCB::ConvertTexts6ToFootprintItem( FOOTPRINT* aFootprint, const ATEX
{ {
if( !m_footprintName.IsEmpty() ) if( !m_footprintName.IsEmpty() )
{ {
wxLogError( _( "Error loading library '%s':\n" if( m_reporter )
{
wxString msg;
msg.Printf( _( "Error loading library '%s':\n"
"Footprint %s contains barcode on Altium layer %d (not yet supported)." ), "Footprint %s contains barcode on Altium layer %d (not yet supported)." ),
m_library, m_library,
m_footprintName, m_footprintName,
aElem.layer ); aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
else else
{ {
wxLogError( _( "Footprint %s contains barcode on Altium layer %d (not yet supported)." ), if( m_reporter )
{
wxString msg;
msg.Printf( _( "Footprint %s contains barcode on Altium layer %d (not yet supported)." ),
aFootprint->GetReference(), aFootprint->GetReference(),
aElem.layer ); aElem.layer );
m_reporter->Report( msg, RPT_SEVERITY_DEBUG );
}
} }
return; return;

View File

@ -107,6 +107,7 @@ class ALTIUM_PCB
{ {
public: public:
explicit ALTIUM_PCB( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter, explicit ALTIUM_PCB( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter,
REPORTER* aReporter = nullptr,
const wxString& aLibrary = wxEmptyString, const wxString& aLibrary = wxEmptyString,
const wxString& aFootprintName = wxEmptyString); const wxString& aFootprintName = wxEmptyString);
~ALTIUM_PCB(); ~ALTIUM_PCB();
@ -253,6 +254,7 @@ private:
std::map<ALTIUM_LAYER, ZONE*> m_outer_plane; std::map<ALTIUM_LAYER, ZONE*> m_outer_plane;
PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr
REPORTER* m_reporter; ///< optional; may be nullptr
unsigned m_doneCount; unsigned m_doneCount;
unsigned m_lastProgressCount; unsigned m_lastProgressCount;
unsigned m_totalCount; ///< for progress reporting unsigned m_totalCount; ///< for progress reporting

View File

@ -100,7 +100,7 @@ BOARD* PCB_IO_ALTIUM_CIRCUIT_MAKER::LoadBoard( const wxString& aFileName, BOARD*
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, m_progressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )

View File

@ -100,7 +100,7 @@ BOARD* PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard( const wxString& aFileName, BOARD
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, m_progressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )

View File

@ -33,6 +33,7 @@
#include <io/io_utils.h> #include <io/io_utils.h>
#include <io/altium/altium_binary_parser.h> #include <io/altium/altium_binary_parser.h>
#include <pcb_io/pcb_io.h> #include <pcb_io/pcb_io.h>
#include <reporter.h>
#include <board.h> #include <board.h>
@ -41,6 +42,7 @@
PCB_IO_ALTIUM_DESIGNER::PCB_IO_ALTIUM_DESIGNER() : PCB_IO( wxS( "Altium Designer" ) ) PCB_IO_ALTIUM_DESIGNER::PCB_IO_ALTIUM_DESIGNER() : PCB_IO( wxS( "Altium Designer" ) )
{ {
m_reporter = &WXLOG_REPORTER::GetInstance();
} }
@ -116,7 +118,7 @@ BOARD* PCB_IO_ALTIUM_DESIGNER::LoadBoard( const wxString& aFileName, BOARD* aApp
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, m_progressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )
@ -278,7 +280,7 @@ FOOTPRINT* PCB_IO_ALTIUM_DESIGNER::FootprintLoad( const wxString& aLibraryPath,
continue; continue;
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, nullptr, aLibraryPath, aFootprintName ); ALTIUM_PCB pcb( m_board, nullptr, m_reporter, aLibraryPath, aFootprintName );
return pcb.ParseFootprint( *altiumLibFile, aFootprintName ); return pcb.ParseFootprint( *altiumLibFile, aFootprintName );
} }
} }

View File

@ -24,6 +24,7 @@
#include <altium_pcb.h> #include <altium_pcb.h>
#include <io/altium/altium_binary_parser.h> #include <io/altium/altium_binary_parser.h>
#include <pcb_io/pcb_io.h> #include <pcb_io/pcb_io.h>
#include <reporter.h>
#include <board.h> #include <board.h>
@ -32,6 +33,7 @@
PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() : PCB_IO( wxS( "Solidworks PCB" ) ) PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() : PCB_IO( wxS( "Solidworks PCB" ) )
{ {
m_reporter = &WXLOG_REPORTER::GetInstance();
} }
@ -119,7 +121,7 @@ BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendTo
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, m_progressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )