From 83be5ba63d82e237b8944ee6ee7c639215b14027 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 30 Apr 2024 21:21:48 -0400 Subject: [PATCH] Move ALTIUM_PCB to use REPORTER for logging Change not-yet-supported messages to debug level (cherry picked from commit e973c15087022a98f35de82ddffbb5a303ae7559) --- pcbnew/pcb_io/altium/altium_pcb.cpp | 387 ++++++++++++++---- pcbnew/pcb_io/altium/altium_pcb.h | 2 + .../altium/pcb_io_altium_circuit_maker.cpp | 2 +- .../altium/pcb_io_altium_circuit_studio.cpp | 2 +- .../pcb_io/altium/pcb_io_altium_designer.cpp | 8 +- pcbnew/pcb_io/altium/pcb_io_solidworks.cpp | 4 +- 6 files changed, 330 insertions(+), 75 deletions(-) diff --git a/pcbnew/pcb_io/altium/altium_pcb.cpp b/pcbnew/pcb_io/altium/altium_pcb.cpp index ef3c5ffcd6..59501e72db 100644 --- a/pcbnew/pcb_io/altium/altium_pcb.cpp +++ b/pcbnew/pcb_io/altium/altium_pcb.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -262,11 +263,12 @@ std::vector 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 ) { m_board = aBoard; m_progressReporter = aProgressReporter; + m_reporter = aReporter; m_doneCount = 0; m_lastProgressCount = 0; m_totalCount = 0; @@ -440,7 +442,13 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi 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; } @@ -448,7 +456,13 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi 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; } } @@ -503,8 +517,13 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi } else if( isRequired ) { - wxLogError( _( "File not found: '%s' for directory '%s'." ), FormatPath( mappedFile ), - magic_enum::enum_name( directory ) ); + if( m_reporter ) + { + 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 { - 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( "" ) ); } @@ -858,6 +883,7 @@ void ALTIUM_PCB::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile // THROW_IO_ERROR( "FileHeader stream is not fully parsed" ); } + void ALTIUM_PCB::ParseExtendedPrimitiveInformationData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, 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" ) ); } + void ALTIUM_PCB::ParseBoard6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, const CFB::COMPOUND_FILE_ENTRY* aEntry ) { @@ -1021,6 +1048,7 @@ void ALTIUM_PCB::ParseBoard6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile HelperCreateBoardOutline( elem.board_vertices ); } + void ALTIUM_PCB::HelperCreateBoardOutline( const std::vector& aVertices ) { SHAPE_LINE_CHAIN lineChain; @@ -1059,6 +1087,7 @@ void ALTIUM_PCB::HelperCreateBoardOutline( const std::vector& aV } } + void ALTIUM_PCB::ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, 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 // unique_ptr will delete nc on this code path - wxLogWarning( _( "More than one Altium netclass with name '%s' found. " - "Only the first one will be imported." ), elem.name ); + if( m_reporter ) + { + 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 { @@ -1105,6 +1139,7 @@ void ALTIUM_PCB::ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFi m_board->m_LegacyNetclassesLoaded = true; } + void ALTIUM_PCB::ParseComponents6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, const CFB::COMPOUND_FILE_ENTRY* aEntry ) { @@ -1197,9 +1232,14 @@ void ALTIUM_PCB::ParseComponentsBodies6Data( const ALTIUM_COMPOUND_FILE& aAl if( modelTuple == m_models.end() ) { - wxLogError( wxT( "ComponentsBodies6 stream tries to access model id %s which does not " - "exist" ), - elem.modelId ); + if( m_reporter ) + { + 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; } @@ -1394,7 +1434,12 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem) 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; } @@ -1427,9 +1472,14 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem ) if( klayer == UNDEFINED_LAYER ) { - wxLogWarning( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. " - "It has been moved to KiCad layer Eco1_User." ), - aElem.layer ); + if( m_reporter ) + { + 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; } @@ -1483,7 +1533,12 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem ) 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; } @@ -1505,9 +1560,14 @@ void ALTIUM_PCB::HelperParseDimensions6Datum( const ADIMENSION6& aElem ) if( klayer == UNDEFINED_LAYER ) { - wxLogWarning( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. " - "It has been moved to KiCad layer Eco1_User." ), - aElem.layer ); + if( m_reporter ) + { + 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; } @@ -1529,9 +1589,14 @@ void ALTIUM_PCB::HelperParseDimensions6Center( const ADIMENSION6& aElem ) if( klayer == UNDEFINED_LAYER ) { - wxLogWarning( _( "Dimension found on an Altium layer (%d) with no KiCad equivalent. " - "It has been moved to KiCad layer Eco1_User." ), - aElem.layer ); + if( m_reporter ) + { + 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; } @@ -1572,14 +1637,24 @@ void ALTIUM_PCB::ParseDimensions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPc HelperParseDimensions6Leader( elem ); break; 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 ); break; case ALTIUM_DIMENSION_KIND::CENTER: HelperParseDimensions6Center( elem ); break; 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; } } @@ -1619,9 +1694,15 @@ void ALTIUM_PCB::ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile { if( !altiumModelsPath.Mkdir() ) { - wxLogError( _( "Failed to create folder '%s'." ) + wxS( " " ) - + _( "No 3D-models will be imported." ), - altiumModelsPath.GetFullPath() ); + if( m_reporter ) + { + 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; } } @@ -1649,8 +1730,14 @@ void ALTIUM_PCB::ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile if( stepEntry == nullptr ) { - wxLogError( _( "File not found: '%s'. 3D-model not imported." ), - FormatPath( stepPath ) ); + if( m_reporter ) + { + wxString msg; + msg.Printf( _( "File not found: '%s'. 3D-model not imported." ), + FormatPath( stepPath ) ); + m_reporter->Report( msg, RPT_SEVERITY_ERROR ); + } + continue; } @@ -1663,8 +1750,14 @@ void ALTIUM_PCB::ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile if( !storagePath.IsDirWritable() ) { - wxLogError( _( "Insufficient permissions to save file '%s'." ), - storagePath.GetFullPath() ); + if( m_reporter ) + { + wxString msg; + msg.Printf( _( "Insufficient permissions to save file '%s'." ), + storagePath.GetFullPath() ); + m_reporter->Report( msg, RPT_SEVERITY_ERROR ); + } + continue; } @@ -1692,6 +1785,7 @@ void ALTIUM_PCB::ParseNets6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, ALTIUM_BINARY_PARSER reader( aAltiumPcbFile, aEntry ); wxASSERT( m_altiumToKicadNetcodes.empty() ); + while( reader.GetRemainingBytes() >= 4 /* TODO: use Header section of file */ ) { checkpoint(); @@ -2025,10 +2119,14 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToBoardItem( const AREGION6& aElem ) if( klayer == UNDEFINED_LAYER ) { - wxLogWarning( - _( "Dashed outline found on an Altium layer (%d) with no KiCad equivalent. " - "It has been moved to KiCad layer Eco1_User." ), - aElem.layer ); + if( m_reporter ) + { + wxString msg; + 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; } @@ -2067,7 +2165,12 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToBoardItem( const AREGION6& aElem ) } 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() ) { - 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 " "no KiCad equivalent. It has been moved to KiCad layer Eco1_User." ), m_library, m_footprintName, aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_ERROR ); + } } 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." ), aFootprint->GetReference(), aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_ERROR ); + } } klayer = Eco1_User; @@ -2185,17 +2298,27 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToFootprintItem( FOOTPRINT* aFoot { 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)." ), m_library, m_footprintName, aElem.kind ); + m_reporter->Report( msg, RPT_SEVERITY_ERROR ); + } } 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(), 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? 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." ), m_library, m_footprintName, aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_ERROR ); + } } 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(), 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: 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)." ), m_library, m_footprintName, aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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(), aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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() ) { - 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. " "KiCad only supports 90 degree rotations." ), m_library, m_footprintName, aElem.name, slotRotation.AsDegrees() ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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." ), aFootprint->GetReference(), aElem.name, 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: 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." ), m_library, m_footprintName, aElem.name, aElem.sizeAndShape->holeshape ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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(), aElem.name, aElem.sizeAndShape->holeshape ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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() ) { - 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)." ), m_library, m_footprintName, aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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(), aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } } @@ -2926,17 +3099,27 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con default: 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." ), m_library, m_footprintName, aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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(), aElem.name ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } break; } @@ -2994,9 +3177,15 @@ void ALTIUM_PCB::ConvertPads6ToBoardItemOnNonCopper( const APAD6& aElem ) 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." ), aElem.name, aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_INFO ); + } + klayer = Eco1_User; } @@ -3016,21 +3205,31 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnNonCopper( FOOTPRINT* aFootprint, { 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 " "KiCad equivalent. It has been moved to KiCad layer Eco1_User." ), m_library, m_footprintName, aElem.name, aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_INFO ); + } } 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." ), aFootprint->GetReference(), aElem.name, aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_INFO ); + } } klayer = Eco1_User; @@ -3049,19 +3248,34 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay { 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 ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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 ) { - wxLogWarning( _( "Non-copper pad %s has a complex pad stack (not yet supported)." ), - aElem.name ); + if( m_reporter ) + { + 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 ) @@ -3202,7 +3416,13 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay case ALTIUM_PAD_SHAPE::UNKNOWN: 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; } } @@ -3253,10 +3473,16 @@ void ALTIUM_PCB::ParseVias6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, if( !IsCopperLayer( start_klayer ) || !IsCopperLayer( end_klayer ) ) { - wxLogError( _( "Via from layer %d to %d uses a non-copper layer, which is not " - "supported." ), + if( m_reporter ) + { + wxString msg; + msg.Printf( _( "Via from layer %d to %d uses a non-copper layer, which is not " + "supported." ), elem.layer_start, elem.layer_end ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } + 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 ) { // Can happen when reading old Altium files: just skip this item - wxLogError( "ATRACK6 stream tries to access polygon id %u " - "of %u existing polygons. Skip it", - (unsigned) aElem.polygon, - (unsigned)m_polygons.size() ); + if( m_reporter ) + { + wxString msg; + msg.Printf( wxT( "ATRACK6 stream tries to access polygon id %u " + "of %u existing polygons; skipping it" ), + static_cast( aElem.polygon ), + static_cast( m_polygons.size() ) ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } + return; } @@ -3523,7 +3755,14 @@ void ALTIUM_PCB::ConvertTexts6ToBoardItem( const ATEXT6& aElem ) { 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; } @@ -3538,17 +3777,27 @@ void ALTIUM_PCB::ConvertTexts6ToFootprintItem( FOOTPRINT* aFootprint, const ATEX { 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)." ), m_library, m_footprintName, aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } 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(), aElem.layer ); + m_reporter->Report( msg, RPT_SEVERITY_DEBUG ); + } } return; diff --git a/pcbnew/pcb_io/altium/altium_pcb.h b/pcbnew/pcb_io/altium/altium_pcb.h index 91cd95dcdf..7fc7905535 100644 --- a/pcbnew/pcb_io/altium/altium_pcb.h +++ b/pcbnew/pcb_io/altium/altium_pcb.h @@ -107,6 +107,7 @@ class ALTIUM_PCB { public: explicit ALTIUM_PCB( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter, + REPORTER* aReporter = nullptr, const wxString& aLibrary = wxEmptyString, const wxString& aFootprintName = wxEmptyString); ~ALTIUM_PCB(); @@ -253,6 +254,7 @@ private: std::map m_outer_plane; PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr + REPORTER* m_reporter; ///< optional; may be nullptr unsigned m_doneCount; unsigned m_lastProgressCount; unsigned m_totalCount; ///< for progress reporting diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp index 00df3a641f..5727129360 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp @@ -100,7 +100,7 @@ BOARD* PCB_IO_ALTIUM_CIRCUIT_MAKER::LoadBoard( const wxString& aFileName, BOARD* try { // Parse File - ALTIUM_PCB pcb( m_board, m_progressReporter ); + ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter ); pcb.Parse( altiumPcbFile, mapping ); } catch( CFB::CFBException& exception ) diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp index 3685e9897f..4124aaa1ba 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp @@ -100,7 +100,7 @@ BOARD* PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard( const wxString& aFileName, BOARD try { // Parse File - ALTIUM_PCB pcb( m_board, m_progressReporter ); + ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter ); pcb.Parse( altiumPcbFile, mapping ); } catch( CFB::CFBException& exception ) diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp index 42992b72e8..fc3959e8f8 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -41,6 +42,7 @@ 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 { // Parse File - ALTIUM_PCB pcb( m_board, m_progressReporter ); + ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter ); pcb.Parse( altiumPcbFile, mapping ); } catch( CFB::CFBException& exception ) @@ -278,7 +280,7 @@ FOOTPRINT* PCB_IO_ALTIUM_DESIGNER::FootprintLoad( const wxString& aLibraryPath, continue; // 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 ); } } @@ -290,4 +292,4 @@ FOOTPRINT* PCB_IO_ALTIUM_DESIGNER::FootprintLoad( const wxString& aLibraryPath, THROW_IO_ERROR( wxString::Format( _( "Footprint '%s' not found in '%s'." ), aFootprintName, aLibraryPath ) ); -} \ No newline at end of file +} diff --git a/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp b/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp index 44c42413c0..2d460b0211 100644 --- a/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -32,6 +33,7 @@ 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 { // Parse File - ALTIUM_PCB pcb( m_board, m_progressReporter ); + ALTIUM_PCB pcb( m_board, m_progressReporter, m_reporter ); pcb.Parse( altiumPcbFile, mapping ); } catch( CFB::CFBException& exception )