Move importers from wxLog to REPORTER.

Fixes https://gitlab.com/kicad/code/kicad/issues/6389
This commit is contained in:
Jeff Young 2021-03-31 22:33:30 +01:00
parent a530c22eff
commit 2ad69fc56b
13 changed files with 268 additions and 162 deletions

View File

@ -113,7 +113,7 @@ REPORTER& NULL_REPORTER::GetInstance()
}
REPORTER& STDOUT_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
REPORTER& STDOUT_REPORTER::Report( const wxString& aMsg, SEVERITY aSeverity )
{
switch( aSeverity )
{
@ -126,7 +126,7 @@ REPORTER& STDOUT_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
case RPT_SEVERITY_IGNORE: break;
}
std::cout << aText << std::endl;
std::cout << aMsg << std::endl;
return *this;
}
@ -143,6 +143,34 @@ REPORTER& STDOUT_REPORTER::GetInstance()
}
REPORTER& WXLOG_REPORTER::Report( const wxString& aMsg, SEVERITY aSeverity )
{
switch( aSeverity )
{
case RPT_SEVERITY_ERROR: wxLogError( aMsg ); break;
case RPT_SEVERITY_WARNING: wxLogWarning( aMsg ); break;
case RPT_SEVERITY_UNDEFINED: wxLogMessage( aMsg ); break;
case RPT_SEVERITY_INFO: wxLogInfo( aMsg ); break;
case RPT_SEVERITY_ACTION: wxLogInfo( aMsg ); break;
case RPT_SEVERITY_EXCLUSION: break;
case RPT_SEVERITY_IGNORE: break;
}
return *this;
}
REPORTER& WXLOG_REPORTER::GetInstance()
{
static REPORTER* s_wxLogReporter = nullptr;
if( !s_wxLogReporter )
s_wxLogReporter = new WXLOG_REPORTER();
return *s_wxLogReporter;
}
REPORTER& STATUSBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
if( m_statusBar )

View File

@ -39,6 +39,8 @@
#include <profile.h>
#include <project/project_file.h>
#include <project_rescue.h>
#include <wx_html_report_box.h>
#include <dialog_HTML_reporter_base.h>
#include <reporter.h>
#include <richio.h>
#include <sch_edit_frame.h>
@ -953,10 +955,18 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
try
{
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi(
SCH_IO_MGR::FindPlugin( (SCH_IO_MGR::SCH_FILE_T) aFileType ) );
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( fileType ) );
DIALOG_HTML_REPORTER* reporter = new DIALOG_HTML_REPORTER( this );
pi->SetReporter( reporter->m_Reporter );
Schematic().SetRoot( pi->Load( aFileName, &Schematic() ) );
if( reporter->m_Reporter->HasMessage() )
reporter->ShowModal();
pi->SetReporter( &WXLOG_REPORTER::GetInstance() );
delete reporter;
// Non-KiCad schematics do not use a drawing-sheet (or if they do, it works differently
// to KiCad), so set it to an empty one
DS_DATA_MODEL& drawingSheet = DS_DATA_MODEL::GetTheInstance();

View File

@ -56,21 +56,13 @@ SCH_PLUGIN* SCH_IO_MGR::FindPlugin( SCH_FILE_T aFileType )
switch( aFileType )
{
case SCH_LEGACY:
return new SCH_LEGACY_PLUGIN();
case SCH_KICAD:
return new SCH_SEXPR_PLUGIN();
case SCH_ALTIUM:
return new SCH_ALTIUM_PLUGIN();
case SCH_CADSTAR_ARCHIVE:
return new CADSTAR_SCH_ARCHIVE_PLUGIN();
case SCH_EAGLE:
return new SCH_EAGLE_PLUGIN();
default:
;
case SCH_LEGACY: return new SCH_LEGACY_PLUGIN();
case SCH_KICAD: return new SCH_SEXPR_PLUGIN();
case SCH_ALTIUM: return new SCH_ALTIUM_PLUGIN();
case SCH_CADSTAR_ARCHIVE: return new CADSTAR_SCH_ARCHIVE_PLUGIN();
case SCH_EAGLE: return new SCH_EAGLE_PLUGIN();
default: return nullptr;
}
return NULL;
}
@ -92,23 +84,13 @@ const wxString SCH_IO_MGR::ShowType( SCH_FILE_T aType )
switch( aType )
{
default:
return wxString::Format( _( "Unknown SCH_FILE_T value: %d" ), aType );
case SCH_LEGACY:
return wxString( wxT( "Legacy" ) );
case SCH_KICAD:
return wxString( wxT( "KiCad" ) );
case SCH_ALTIUM:
return wxString( wxT( "Altium" ) );
case SCH_CADSTAR_ARCHIVE:
return wxString( wxT( "CADSTAR Schematic Archive" ) );
case SCH_EAGLE:
return wxString( wxT( "EAGLE" ) );
case SCH_LEGACY: return wxString( wxT( "Legacy" ) );
case SCH_KICAD: return wxString( wxT( "KiCad" ) );
case SCH_ALTIUM: return wxString( wxT( "Altium" ) );
case SCH_CADSTAR_ARCHIVE: return wxString( wxT( "CADSTAR Schematic Archive" ) );
case SCH_EAGLE: return wxString( wxT( "EAGLE" ) );
default: return wxString::Format( _( "Unknown SCH_FILE_T value: %d" ),
aType );
}
}

View File

@ -27,6 +27,7 @@
#include <import_export.h>
#include <map>
#include <enum_vector.h>
#include <reporter.h>
class SCH_SHEET;
@ -158,6 +159,11 @@ public:
*/
virtual const wxString GetName() const = 0;
/**
* Set an optional reporter for warnings/errors.
*/
virtual void SetReporter( REPORTER* aReporter ) {}
/**
* Return the file extension for the #SCH_PLUGIN.
*/

View File

@ -80,6 +80,8 @@ SCH_ALTIUM_PLUGIN::SCH_ALTIUM_PLUGIN()
m_rootSheet = nullptr;
m_currentSheet = nullptr;
m_schematic = nullptr;
m_reporter = &WXLOG_REPORTER::GetInstance();
}
@ -241,7 +243,8 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName )
if( fp == nullptr )
{
wxLogError( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
m_reporter->Report( wxString::Format( _( "Cannot open file '%s'." ), aFileName ),
RPT_SEVERITY_ERROR );
return;
}
@ -434,7 +437,8 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
case ALTIUM_SCH_RECORD::RECORD_226:
break;
default:
wxLogError( wxString::Format( "Unknown Record id: %d", recordId ) );
m_reporter->Report( wxString::Format( _( "Unknown Record id: %d." ), recordId ),
RPT_SEVERITY_ERROR );
break;
}
}
@ -532,8 +536,9 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Pin has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Pin has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -572,7 +577,7 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
pinLocation.y += elem.pinlength;
break;
default:
wxLogWarning( "Pin has unexpected orientation" );
m_reporter->Report( _( "Pin has unexpected orientation." ), RPT_SEVERITY_WARNING );
break;
}
@ -610,15 +615,15 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
case ASCH_PIN_ELECTRICAL::UNKNOWN:
default:
pin->SetType( ELECTRICAL_PINTYPE::PT_UNSPECIFIED );
wxLogWarning( "Pin has unexpected electrical type" );
m_reporter->Report( _( "Pin has unexpected electrical type." ), RPT_SEVERITY_WARNING );
break;
}
if( elem.symbolOuterEdge == ASCH_PIN_SYMBOL_OUTEREDGE::UNKNOWN )
wxLogWarning( "Pin has unexpected outer edge type" );
m_reporter->Report( _( "Pin has unexpected outer edge type." ), RPT_SEVERITY_WARNING );
if( elem.symbolInnerEdge == ASCH_PIN_SYMBOL_INNEREDGE::UNKNOWN )
wxLogWarning( "Pin has unexpected inner edge type" );
m_reporter->Report( _( "Pin has unexpected inner edge type." ), RPT_SEVERITY_WARNING );
if( elem.symbolOuterEdge == ASCH_PIN_SYMBOL_OUTEREDGE::NEGATED )
{
@ -740,8 +745,9 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Label has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Label has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -775,8 +781,10 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
if( elem.points.size() < 2 )
{
wxLogWarning( wxString::Format( "Bezier has %d control points. At least 2 are expected.",
static_cast<int>( elem.points.size() ) ) );
m_reporter->Report( wxString::Format( _( "Bezier has %d control points. At least 2 are "
"expected." ),
static_cast<int>( elem.points.size() ) ),
RPT_SEVERITY_WARNING );
return;
}
@ -831,8 +839,9 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Bezier has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Bezier has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -915,8 +924,9 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Polyline has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Polyline has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -976,8 +986,9 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Polygon has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Polygon has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -1057,8 +1068,10 @@ void SCH_ALTIUM_PLUGIN::ParseRoundRectangle( const std::map<wxString, wxString>&
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Rounded Rectangle has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Rounded rectangle has non-existent "
"ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -1093,7 +1106,8 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
{
wxLogError( "Arc drawing is not possible for now on schematic." );
m_reporter->Report( _( "Arc drawing is not possible for now on schematic." ),
RPT_SEVERITY_ERROR );
}
else
{
@ -1101,8 +1115,9 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Arc has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Arc has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -1161,8 +1176,9 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map<wxString, wxString>& aProperti
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Line has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Line has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -1232,8 +1248,9 @@ void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map<wxString, wxString>& aPro
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Rectangle has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Rectangle has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}
@ -1351,7 +1368,8 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map<wxString, wxString>& aPr
}
wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE aStyle )
wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE aStyle,
REPORTER* aReporter )
{
if( aStyle == ASCH_POWER_PORT_STYLE::CIRCLE || aStyle == ASCH_POWER_PORT_STYLE::ARROW )
{
@ -1534,7 +1552,10 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE
else
{
if( aStyle != ASCH_POWER_PORT_STYLE::BAR )
wxLogWarning( "Power Port has unknown style, use bar instead. " );
{
aReporter->Report( _( "Power Port has unknown style, use bar instead." ),
RPT_SEVERITY_WARNING );
}
LIB_POLYLINE* line1 = new LIB_POLYLINE( aKPart );
aKPart->AddDrawItem( line1 );
@ -1591,7 +1612,7 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map<wxString, wxString>& aPro
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
pin->SetVisible( false );
wxPoint valueFieldPos = HelperGeneratePowerPortGraphics( kpart, elem.style );
wxPoint valueFieldPos = HelperGeneratePowerPortGraphics( kpart, elem.style, m_reporter );
kpart->GetValueField().SetPosition( valueFieldPos );
@ -1641,7 +1662,7 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map<wxString, wxString>& aPro
valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER );
break;
default:
wxLogWarning( "Pin has unexpected orientation" );
m_reporter->Report( _( "Pin has unexpected orientation." ), RPT_SEVERITY_WARNING );
break;
}
@ -2012,8 +2033,9 @@ void SCH_ALTIUM_PLUGIN::ParseDesignator( const std::map<wxString, wxString>& aPr
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format( "Designator has non-existent ownerindex %d",
elem.ownerindex ) );
m_reporter->Report( wxString::Format( _( "Designator has non-existent ownerindex %d." ),
elem.ownerindex ),
RPT_SEVERITY_WARNING );
return;
}

View File

@ -55,6 +55,8 @@ public:
const wxString GetName() const override;
void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; }
const wxString GetFileExtension() const override;
const wxString GetLibraryFileExtension() const override;
@ -134,6 +136,8 @@ private:
void ParseParameter( const std::map<wxString, wxString>& aProperties );
private:
REPORTER* m_reporter; // current reporter for warnings/errors
SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded..
SCH_SHEET* m_currentSheet; // The current sheet of the schematic being loaded..
SCHEMATIC* m_schematic; // Passed to Load(), the schematic object being loaded

View File

@ -99,24 +99,26 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh
if( Schematic.VariantHierarchy.Variants.size() > 0 )
{
wxLogWarning( wxString::Format(
_( "The CADSTAR design contains variants which has no KiCad equivalent. Only "
"the master variant ('%s') was loaded." ),
Schematic.VariantHierarchy.Variants.at( "V0" ).Name ) );
m_reporter->Report( wxString::Format( _( "The CADSTAR design contains variants which has "
"no KiCad equivalent. Only the master variant "
"('%s') was loaded." ),
Schematic.VariantHierarchy.Variants.at( "V0" ).Name ),
RPT_SEVERITY_WARNING );
}
if( Schematic.Groups.size() > 0 )
{
wxLogWarning(
_( "The CADSTAR design contains grouped items which has no KiCad equivalent. Any "
"grouped items have been ungrouped." ) );
m_reporter->Report( _( "The CADSTAR design contains grouped items which has no KiCad "
"equivalent. Any grouped items have been ungrouped." ),
RPT_SEVERITY_WARNING );
}
if( Schematic.ReuseBlocks.size() > 0 )
{
wxLogWarning(
_( "The CADSTAR design contains re-use blocks which has no KiCad equivalent. The "
"re-use block information has been discarded during the import." ) );
m_reporter->Report( _( "The CADSTAR design contains re-use blocks which has no KiCad "
"equivalent. The re-use block information has been discarded during "
"the import." ),
RPT_SEVERITY_WARNING );
}
@ -216,8 +218,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh
}
}
wxLogMessage(
_( "The CADSTAR design has been imported successfully.\n"
m_reporter->Report( _( "The CADSTAR design has been imported successfully.\n"
"Please review the import errors and warnings (if any)." ) );
}
@ -348,11 +349,14 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary()
if( symbolID.IsEmpty() )
{
wxLogWarning( wxString::Format(
_( "Part definition '%s' references symbol '%s' (alternate '%s') "
"which could not be found in the symbol library. The part has not "
"been loaded into the KiCad library." ),
part.Name, gate.Name, gate.Alternate ) );
m_reporter->Report( wxString::Format( _( "Part definition '%s' references symbol "
"'%s' (alternate '%s') which could not be "
"found in the symbol library. The part has "
"not been loaded into the KiCad library." ),
part.Name,
gate.Name,
gate.Alternate ),
RPT_SEVERITY_WARNING);
ok = false;
break;
@ -393,10 +397,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
{
if( m_partMap.find( sym.PartRef.RefID ) == m_partMap.end() )
{
wxLogError( wxString::Format(
_( "Symbol '%s' references part '%s' which could not be found "
"in the library. The symbol was not loaded" ),
sym.ComponentRef.Designator, sym.PartRef.RefID ) );
m_reporter->Report( wxString::Format( _( "Symbol '%s' references part '%s' which "
"could not be found in the library. The "
"symbol was not loaded" ),
sym.ComponentRef.Designator,
sym.PartRef.RefID ),
RPT_SEVERITY_ERROR);
continue;
}
@ -617,10 +623,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
}
else
{
wxLogError( wxString::Format(
_( "Symbol ID '%s' is of an unknown type. It is neither a component or a "
"net power / symbol. The symbol was not loaded." ),
sym.ID ) );
m_reporter->Report( wxString::Format( _( "Symbol ID '%s' is of an unknown type. It is "
"neither a component or a net power / symbol. "
"The symbol was not loaded." ),
sym.ID ),
RPT_SEVERITY_ERROR );
}
if( sym.ScaleRatioDenominator != 1 || sym.ScaleRatioNumerator != 1 )
@ -630,11 +637,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
if( symbolName.empty() )
symbolName = wxString::Format( "ID: %s", sym.ID);
wxLogError( wxString::Format(
_( "Symbol '%s' is scaled in the original CADSTAR schematic but this is not"
" supported in KiCad. The symbol was loaded with 1:1 scale and may require "
"manual fixing." ),
symbolName, sym.PartRef.RefID ) );
m_reporter->Report( wxString::Format( _( "Symbol '%s' is scaled in the original "
"CADSTAR schematic but this is not supported "
"in KiCad. The symbol was loaded with 1:1 "
"scale and may require manual fixing." ),
symbolName,
sym.PartRef.RefID ),
RPT_SEVERITY_ERROR );
}
}
}
@ -1057,11 +1066,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols()
if( Library.SymbolDefinitions.find( docSym.SymdefID ) == Library.SymbolDefinitions.end() )
{
wxLogError(
wxString::Format( _( "Documentation Symbol '%s' refers to symbol definition "
"ID '%s' which does not exist in the library. The symbol "
"was not loaded." ),
docSym.ID, docSym.SymdefID ) );
m_reporter->Report( wxString::Format( _( "Documentation Symbol '%s' refers to symbol "
"definition ID '%s' which does not exist in "
"the library. The symbol was not loaded." ),
docSym.ID,
docSym.SymdefID ),
RPT_SEVERITY_ERROR );
continue;
}
@ -1163,7 +1173,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables()
}
else
{
wxLogError( _( "Text Variables could not be set as there is no project attached." ) );
m_reporter->Report( _( "Text Variables could not be set as there is no project attached." ),
RPT_SEVERITY_ERROR );
}
}
@ -1560,22 +1571,26 @@ SCH_COMPONENT* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(
if( NormalizeAngle180( compAngleDeciDeg ) != NormalizeAngle180( aComponentOrientationDeciDeg ) )
{
wxLogError(
wxString::Format( _( "Symbol '%s' is rotated by an angle of %.1f degrees in the "
"original CADSTAR design but KiCad only supports rotation "
"angles multiples of 90 degrees. The connecting wires will "
"need manual fixing." ),
aCadstarSymbol.ComponentRef.Designator, compAngleDeciDeg / 10.0 ) );
m_reporter->Report( wxString::Format( _( "Symbol '%s' is rotated by an angle of %.1f "
"degrees in the original CADSTAR design but "
"KiCad only supports rotation angles multiples "
"of 90 degrees. The connecting wires will need "
"manual fixing." ),
aCadstarSymbol.ComponentRef.Designator,
compAngleDeciDeg / 10.0 ),
RPT_SEVERITY_ERROR);
}
component->SetOrientation( compOrientation );
if( m_sheetMap.find( aCadstarSymbol.LayerID ) == m_sheetMap.end() )
{
wxLogError(
wxString::Format( _( "Symbol '%s' references sheet ID '%s' which does not exist in "
"the design. The symbol was not loaded." ),
aCadstarSymbol.ComponentRef.Designator, aCadstarSymbol.LayerID ) );
m_reporter->Report( wxString::Format( _( "Symbol '%s' references sheet ID '%s' which does "
"not exist in the design. The symbol was not "
"loaded." ),
aCadstarSymbol.ComponentRef.Designator,
aCadstarSymbol.LayerID ),
RPT_SEVERITY_ERROR );
delete component;
return nullptr;
@ -1718,10 +1733,12 @@ CADSTAR_SCH_ARCHIVE_LOADER::POINT CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetEl
auto logUnknownNetElementError =
[&]()
{
wxLogError( wxString::Format( _(
"Net %s references unknown net element %s. The net was "
"not properly loaded and may require manual fixing." ),
getNetName( aNet ), aNetElementID ) );
m_reporter->Report( wxString::Format( _( "Net %s references unknown net element %s. "
"The net was not properly loaded and may "
"require manual fixing." ),
getNetName( aNet ),
aNetElementID ),
RPT_SEVERITY_ERROR );
return POINT();
};
@ -2002,12 +2019,15 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(
{
if( block.Figures.size() > 0 )
{
wxLogError( wxString::Format(
_( "The block ID %s (Block name: '%s') is drawn on sheet '%s' but is "
"not linked to another sheet in the design. KiCad requires all "
"sheet symbols to be associated to a sheet, so the block was not "
"loaded." ),
block.ID, block.Name, Sheets.SheetNames.at( aCadstarSheetID ) ) );
m_reporter->Report( wxString::Format( _( "The block ID %s (Block name: '%s') "
"is drawn on sheet '%s' but is not "
"linked to another sheet in the "
"design. KiCad requires all sheet "
"symbols to be associated to a sheet, "
"so the block was not loaded." ),
block.ID, block.Name,
Sheets.SheetNames.at( aCadstarSheetID ) ),
RPT_SEVERITY_ERROR );
}
continue;
@ -2024,9 +2044,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(
}
else
{
THROW_IO_ERROR( wxString::Format(
_( "The CADSTAR schematic might be corrupt: Block %s references a "
"child sheet but has no Figure defined." ),
THROW_IO_ERROR( wxString::Format( _( "The CADSTAR schematic might be corrupt: "
"Block %s references a child sheet but has no "
"Figure defined." ),
block.ID ) );
}

View File

@ -52,7 +52,7 @@ class SCHEMATIC;
class CADSTAR_SCH_ARCHIVE_LOADER : public CADSTAR_SCH_ARCHIVE_PARSER
{
public:
explicit CADSTAR_SCH_ARCHIVE_LOADER( wxString aFilename )
explicit CADSTAR_SCH_ARCHIVE_LOADER( wxString aFilename, REPORTER* aReporter )
: CADSTAR_SCH_ARCHIVE_PARSER( aFilename )
{
m_schematic = nullptr;
@ -60,6 +60,7 @@ public:
m_plugin = nullptr;
m_designCenter.x = 0;
m_designCenter.y = 0;
m_reporter = aReporter;
}
@ -86,6 +87,7 @@ private:
*/
typedef std::map<TERMINAL_ID, wxString> TERMINAL_TO_PINNUM_MAP;
REPORTER* m_reporter;
SCHEMATIC* m_schematic;
SCH_SHEET* m_rootSheet;
SCH_PLUGIN::SCH_PLUGIN_RELEASER* m_plugin;

View File

@ -134,7 +134,7 @@ SCH_SHEET* CADSTAR_SCH_ARCHIVE_PLUGIN::Load( const wxString& aFileName, SCHEMATI
aSchematic->Prj().SchSymbolLibTable();
}
CADSTAR_SCH_ARCHIVE_LOADER csaFile( aFileName );
CADSTAR_SCH_ARCHIVE_LOADER csaFile( aFileName, m_reporter );
csaFile.Load( aSchematic, rootSheet, &sch_plugin, libFileName );
sch_plugin->SaveLibrary( libFileName.GetFullPath() );

View File

@ -29,6 +29,8 @@
#include <sch_io_mgr.h>
#include <reporter.h>
class SCH_SHEET;
class SCH_SCREEN;
@ -40,6 +42,8 @@ public:
const wxString GetName() const override;
void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; }
const wxString GetFileExtension() const override;
const wxString GetLibraryFileExtension() const override;
@ -88,11 +92,14 @@ public:
CADSTAR_SCH_ARCHIVE_PLUGIN()
{
m_reporter = &WXLOG_REPORTER::GetInstance();
}
~CADSTAR_SCH_ARCHIVE_PLUGIN()
{
}
REPORTER* m_reporter; // current reporter for warnings/errors
};
#endif // CADSTAR_SCH_ARCHIVE_PLUGIN_H_

View File

@ -351,10 +351,11 @@ static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment, int aRe
SCH_EAGLE_PLUGIN::SCH_EAGLE_PLUGIN()
{
m_kiway = nullptr;
m_rootSheet = nullptr;
m_currentSheet = nullptr;
m_schematic = nullptr;
m_reporter = &WXLOG_REPORTER::GetInstance();
}
@ -1157,9 +1158,10 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
if( part_it == m_partlist.end() )
{
wxLogError( _( "Error parsing Eagle file. "
"Could not find \"%s\" instance but it is referenced in the schematic." ),
einstance.part );
m_reporter->Report( wxString::Format( _( "Error parsing Eagle file. Could not find '%s' "
"instance but it is referenced in the schematic." ),
einstance.part ),
RPT_SEVERITY_ERROR );
return;
}
@ -1187,8 +1189,9 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
if( !part )
{
wxLogMessage( wxString::Format( _( "Could not find %s in the imported library" ),
kisymbolname ) );
m_reporter->Report( wxString::Format( _( "Could not find '%s' in the imported library." ),
kisymbolname ),
RPT_SEVERITY_ERROR );
return;
}

View File

@ -86,6 +86,8 @@ public:
const wxString GetName() const override;
void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; }
const wxString GetFileExtension() const override;
const wxString GetLibraryFileExtension() const override;
@ -212,12 +214,13 @@ private:
std::map<int, bool> units;
};
REPORTER* m_reporter; ///< Reporter for warnings/errors
///< Map references to missing component units data
std::map<wxString, EAGLE_MISSING_CMP> m_missingCmps;
KIWAY* m_kiway; ///< For creating sub sheets.
SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded..
SCH_SHEET* m_currentSheet; ///< The current sheet of the schematic being loaded..
SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded
SCH_SHEET* m_currentSheet; ///< The current sheet of the schematic being loaded
wxString m_version; ///< Eagle file version.
wxFileName m_filename;
wxString m_libName; ///< Library name to save symbols
@ -237,7 +240,8 @@ private:
std::vector<VECTOR2I> m_wireIntersections;
///< Wires and labels of a single connection (segment in Eagle nomenclature)
typedef struct SEG_DESC_STRUCT {
typedef struct SEG_DESC_STRUCT
{
///< Test if a particular label is attached to any of the stored segments
const SEG* LabelAttached( const SCH_TEXT* aLabel ) const;

View File

@ -249,8 +249,26 @@ public:
static REPORTER& GetInstance();
REPORTER& Report( const wxString& aText,
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override { return false; }
};
class WXLOG_REPORTER : public REPORTER
{
public:
WXLOG_REPORTER()
{
}
virtual ~WXLOG_REPORTER()
{
}
static REPORTER& GetInstance();
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override { return false; }
};