Formatting, some i18n, and shorter log messages.
This commit is contained in:
parent
8b295a3bd7
commit
44400ca413
|
@ -56,7 +56,6 @@
|
||||||
#include <kicad_string.h>
|
#include <kicad_string.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <wx/textfile.h>
|
|
||||||
|
|
||||||
|
|
||||||
const wxPoint GetRelativePosition( const wxPoint& aPosition, const SCH_COMPONENT* aComponent )
|
const wxPoint GetRelativePosition( const wxPoint& aPosition, const SCH_COMPONENT* aComponent )
|
||||||
|
@ -151,8 +150,9 @@ wxFileName SCH_ALTIUM_PLUGIN::getLibFileName()
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SCH_SHEET* SCH_ALTIUM_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
SCH_SHEET* SCH_ALTIUM_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
||||||
SCH_SHEET* aAppendToMe, const PROPERTIES* aProperties )
|
SCH_SHEET* aAppendToMe, const PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
wxASSERT( !aFileName || aSchematic != NULL );
|
wxASSERT( !aFileName || aSchematic != NULL );
|
||||||
|
|
||||||
|
@ -195,12 +195,12 @@ SCH_SHEET* SCH_ALTIUM_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchem
|
||||||
wxString libTableUri = "${KIPRJMOD}/" + getLibFileName().GetFullName();
|
wxString libTableUri = "${KIPRJMOD}/" + getLibFileName().GetFullName();
|
||||||
|
|
||||||
// Add the new library to the project symbol library table.
|
// Add the new library to the project symbol library table.
|
||||||
libTable->InsertRow(
|
libTable->InsertRow( new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri,
|
||||||
new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri, wxString( "KiCad" ) ) );
|
wxString( "KiCad" ) ) );
|
||||||
|
|
||||||
// Save project symbol library table.
|
// Save project symbol library table.
|
||||||
wxFileName fn( m_schematic->Prj().GetProjectPath(),
|
wxFileName fn( m_schematic->Prj().GetProjectPath(),
|
||||||
SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
||||||
|
|
||||||
// So output formatter goes out of scope and closes the file before reloading.
|
// So output formatter goes out of scope and closes the file before reloading.
|
||||||
{
|
{
|
||||||
|
@ -233,6 +233,7 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName )
|
||||||
{
|
{
|
||||||
// Open file
|
// Open file
|
||||||
FILE* fp = wxFopen( aFileName, "rb" );
|
FILE* fp = wxFopen( aFileName, "rb" );
|
||||||
|
|
||||||
if( fp == nullptr )
|
if( fp == nullptr )
|
||||||
{
|
{
|
||||||
wxLogError( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
|
wxLogError( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
|
||||||
|
@ -241,6 +242,7 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName )
|
||||||
|
|
||||||
fseek( fp, 0, SEEK_END );
|
fseek( fp, 0, SEEK_END );
|
||||||
long len = ftell( fp );
|
long len = ftell( fp );
|
||||||
|
|
||||||
if( len < 0 )
|
if( len < 0 )
|
||||||
{
|
{
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
@ -252,10 +254,9 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName )
|
||||||
|
|
||||||
size_t bytesRead = fread( buffer.get(), sizeof( unsigned char ), len, fp );
|
size_t bytesRead = fread( buffer.get(), sizeof( unsigned char ), len, fp );
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
if( static_cast<size_t>( len ) != bytesRead )
|
if( static_cast<size_t>( len ) != bytesRead )
|
||||||
{
|
|
||||||
THROW_IO_ERROR( "Reading error" );
|
THROW_IO_ERROR( "Reading error" );
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -272,10 +273,9 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName )
|
||||||
void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
||||||
{
|
{
|
||||||
const CFB::COMPOUND_FILE_ENTRY* file = FindStream( aReader, "FileHeader" );
|
const CFB::COMPOUND_FILE_ENTRY* file = FindStream( aReader, "FileHeader" );
|
||||||
|
|
||||||
if( file == nullptr )
|
if( file == nullptr )
|
||||||
{
|
|
||||||
THROW_IO_ERROR( "FileHeader not found" );
|
THROW_IO_ERROR( "FileHeader not found" );
|
||||||
}
|
|
||||||
|
|
||||||
ALTIUM_PARSER reader( aReader, file );
|
ALTIUM_PARSER reader( aReader, file );
|
||||||
|
|
||||||
|
@ -291,9 +291,7 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
||||||
ALTIUM_SCH_RECORD record = static_cast<ALTIUM_SCH_RECORD>( recordId );
|
ALTIUM_SCH_RECORD record = static_cast<ALTIUM_SCH_RECORD>( recordId );
|
||||||
|
|
||||||
if( record != ALTIUM_SCH_RECORD::HEADER )
|
if( record != ALTIUM_SCH_RECORD::HEADER )
|
||||||
{
|
|
||||||
THROW_IO_ERROR( "Header expected" );
|
THROW_IO_ERROR( "Header expected" );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare some local variables
|
// Prepare some local variables
|
||||||
|
@ -437,26 +435,21 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( reader.HasParsingError() )
|
if( reader.HasParsingError() )
|
||||||
{
|
|
||||||
THROW_IO_ERROR( "stream was not parsed correctly!" );
|
THROW_IO_ERROR( "stream was not parsed correctly!" );
|
||||||
}
|
|
||||||
|
|
||||||
if( reader.GetRemainingBytes() != 0 )
|
if( reader.GetRemainingBytes() != 0 )
|
||||||
{
|
|
||||||
THROW_IO_ERROR( "stream is not fully parsed" );
|
THROW_IO_ERROR( "stream is not fully parsed" );
|
||||||
}
|
|
||||||
|
|
||||||
// assign LIB_PART -> COMPONENT
|
// assign LIB_PART -> COMPONENT
|
||||||
for( auto component : m_components )
|
for( auto component : m_components )
|
||||||
{
|
{
|
||||||
auto kpart = m_symbols.find( component.first );
|
auto kpart = m_symbols.find( component.first );
|
||||||
|
|
||||||
if( kpart == m_symbols.end() )
|
if( kpart == m_symbols.end() )
|
||||||
{
|
|
||||||
THROW_IO_ERROR( "every component should have a symbol attached" );
|
THROW_IO_ERROR( "every component should have a symbol attached" );
|
||||||
}
|
|
||||||
|
|
||||||
m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_PART( *( kpart->second ) ),
|
m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_PART( *( kpart->second ) ),
|
||||||
m_properties.get() );
|
m_properties.get() );
|
||||||
|
|
||||||
component.second->SetLibSymbol( kpart->second );
|
component.second->SetLibSymbol( kpart->second );
|
||||||
}
|
}
|
||||||
|
@ -467,9 +460,8 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
||||||
|
|
||||||
// Handle Ports
|
// Handle Ports
|
||||||
for( const ASCH_PORT& port : m_altiumPortsCurrentSheet )
|
for( const ASCH_PORT& port : m_altiumPortsCurrentSheet )
|
||||||
{
|
|
||||||
ParsePort( port );
|
ParsePort( port );
|
||||||
}
|
|
||||||
m_altiumPortsCurrentSheet.clear();
|
m_altiumPortsCurrentSheet.clear();
|
||||||
|
|
||||||
m_components.clear();
|
m_components.clear();
|
||||||
|
@ -483,6 +475,7 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
||||||
bool SCH_ALTIUM_PLUGIN::IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const
|
bool SCH_ALTIUM_PLUGIN::IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const
|
||||||
{
|
{
|
||||||
const auto& component = m_altiumComponents.find( aOwnerindex );
|
const auto& component = m_altiumComponents.find( aOwnerindex );
|
||||||
|
|
||||||
if( component == m_altiumComponents.end() )
|
if( component == m_altiumComponents.end() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -490,15 +483,17 @@ bool SCH_ALTIUM_PLUGIN::IsComponentPartVisible( int aOwnerindex, int aOwnerpartd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_ALTIUM_PLUGIN::ParseComponent(
|
void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex,
|
||||||
int aIndex, const std::map<wxString, wxString>& aProperties )
|
const std::map<wxString, wxString>& aProperties )
|
||||||
{
|
{
|
||||||
auto pair = m_altiumComponents.insert( { aIndex, ASCH_COMPONENT( aProperties ) } );
|
auto pair = m_altiumComponents.insert( { aIndex, ASCH_COMPONENT( aProperties ) } );
|
||||||
const ASCH_COMPONENT& elem = pair.first->second;
|
const ASCH_COMPONENT& elem = pair.first->second;
|
||||||
|
|
||||||
// TODO: this is a hack until we correctly apply all transformations to every element
|
// TODO: this is a hack until we correctly apply all transformations to every element
|
||||||
wxString name = wxString::Format(
|
wxString name = wxString::Format( "%d%s_%s",
|
||||||
"%d%s_%s", elem.orientation, elem.isMirrored ? "_mirrored" : "", elem.libreference );
|
elem.orientation,
|
||||||
|
elem.isMirrored ? "_mirrored" : "",
|
||||||
|
elem.libreference );
|
||||||
LIB_ID libId = AltiumToKiCadLibID( LIB_ID::ID_SCH, getLibName(), name );
|
LIB_ID libId = AltiumToKiCadLibID( LIB_ID::ID_SCH, getLibName(), name );
|
||||||
|
|
||||||
LIB_PART* kpart = new LIB_PART( wxEmptyString );
|
LIB_PART* kpart = new LIB_PART( wxEmptyString );
|
||||||
|
@ -528,12 +523,12 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
|
||||||
ASCH_PIN elem( aProperties );
|
ASCH_PIN elem( aProperties );
|
||||||
|
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Pin has non-existent ownerindex %d",
|
||||||
"Pin tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,6 +547,7 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
|
||||||
pin->SetLength( elem.pinlength );
|
pin->SetLength( elem.pinlength );
|
||||||
|
|
||||||
wxPoint pinLocation = elem.location; // the location given is not the connection point!
|
wxPoint pinLocation = elem.location; // the location given is not the connection point!
|
||||||
|
|
||||||
switch( elem.orientation )
|
switch( elem.orientation )
|
||||||
{
|
{
|
||||||
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
|
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
|
||||||
|
@ -721,6 +717,7 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
SetEdaTextJustification( text, elem.justification );
|
SetEdaTextJustification( text, elem.justification );
|
||||||
|
|
||||||
size_t fontId = static_cast<int>( elem.fontId );
|
size_t fontId = static_cast<int>( elem.fontId );
|
||||||
|
|
||||||
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
||||||
{
|
{
|
||||||
const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
|
const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
|
||||||
|
@ -735,12 +732,12 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Label has non-existent ownerindex %d",
|
||||||
"Label tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,6 +754,7 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
SetEdaTextJustification( text, elem.justification );
|
SetEdaTextJustification( text, elem.justification );
|
||||||
|
|
||||||
size_t fontId = static_cast<int>( elem.fontId );
|
size_t fontId = static_cast<int>( elem.fontId );
|
||||||
|
|
||||||
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
||||||
{
|
{
|
||||||
const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
|
const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
|
||||||
|
@ -775,7 +773,7 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
|
||||||
if( elem.points.size() < 2 )
|
if( elem.points.size() < 2 )
|
||||||
{
|
{
|
||||||
wxLogWarning( wxString::Format( "Bezier has %d control points. At least 2 are expected.",
|
wxLogWarning( wxString::Format( "Bezier has %d control points. At least 2 are expected.",
|
||||||
static_cast<int>( elem.points.size() ) ) );
|
static_cast<int>( elem.points.size() ) ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,8 +784,9 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
|
||||||
if( i + 2 == elem.points.size() )
|
if( i + 2 == elem.points.size() )
|
||||||
{
|
{
|
||||||
// special case: single line
|
// special case: single line
|
||||||
SCH_LINE* line = new SCH_LINE(
|
SCH_LINE* line = new SCH_LINE( elem.points.at( i ) + m_sheetOffset,
|
||||||
elem.points.at( i ) + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
|
SCH_LAYER_ID::LAYER_NOTES );
|
||||||
|
|
||||||
line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
|
line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
|
||||||
line->SetLineWidth( elem.lineWidth );
|
line->SetLineWidth( elem.lineWidth );
|
||||||
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
|
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
|
||||||
|
@ -810,8 +809,9 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
|
||||||
|
|
||||||
for( size_t k = 0; k + 1 < polyPoints.size(); k++ )
|
for( size_t k = 0; k + 1 < polyPoints.size(); k++ )
|
||||||
{
|
{
|
||||||
SCH_LINE* line = new SCH_LINE(
|
SCH_LINE* line = new SCH_LINE( polyPoints.at( k ) + m_sheetOffset,
|
||||||
polyPoints.at( k ) + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
|
SCH_LAYER_ID::LAYER_NOTES );
|
||||||
|
|
||||||
line->SetEndPoint( polyPoints.at( k + 1 ) + m_sheetOffset );
|
line->SetEndPoint( polyPoints.at( k + 1 ) + m_sheetOffset );
|
||||||
line->SetLineWidth( elem.lineWidth );
|
line->SetLineWidth( elem.lineWidth );
|
||||||
|
|
||||||
|
@ -824,12 +824,12 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Bezier has non-existent ownerindex %d",
|
||||||
"Bezier tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,8 +850,8 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
|
||||||
|
|
||||||
for( size_t j = i; j < elem.points.size() && j < i + 2; j++ )
|
for( size_t j = i; j < elem.points.size() && j < i + 2; j++ )
|
||||||
{
|
{
|
||||||
line->AddPoint(
|
line->AddPoint( GetRelativePosition( elem.points.at( j ) + m_sheetOffset,
|
||||||
GetRelativePosition( elem.points.at( j ) + m_sheetOffset, component ) );
|
component ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
line->SetWidth( elem.lineWidth );
|
line->SetWidth( elem.lineWidth );
|
||||||
|
@ -866,8 +866,8 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
|
||||||
|
|
||||||
for( size_t j = i; j < elem.points.size() && j < i + 4; j++ )
|
for( size_t j = i; j < elem.points.size() && j < i + 4; j++ )
|
||||||
{
|
{
|
||||||
bezier->AddPoint(
|
bezier->AddPoint( GetRelativePosition( elem.points.at( j ) + m_sheetOffset,
|
||||||
GetRelativePosition( elem.points.at( j ) + m_sheetOffset, component ) );
|
component ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bezier->SetWidth( elem.lineWidth );
|
bezier->SetWidth( elem.lineWidth );
|
||||||
|
@ -887,24 +887,17 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
|
||||||
switch( elem.linestyle )
|
switch( elem.linestyle )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ASCH_POLYLINE_LINESTYLE::SOLID:
|
case ASCH_POLYLINE_LINESTYLE::SOLID: dashType = PLOT_DASH_TYPE::SOLID; break;
|
||||||
dashType = PLOT_DASH_TYPE::SOLID;
|
case ASCH_POLYLINE_LINESTYLE::DASHED: dashType = PLOT_DASH_TYPE::DASH; break;
|
||||||
break;
|
case ASCH_POLYLINE_LINESTYLE::DOTTED: dashType = PLOT_DASH_TYPE::DOT; break;
|
||||||
case ASCH_POLYLINE_LINESTYLE::DASHED:
|
case ASCH_POLYLINE_LINESTYLE::DASH_DOTTED: dashType = PLOT_DASH_TYPE::DASHDOT; break;
|
||||||
dashType = PLOT_DASH_TYPE::DASH;
|
|
||||||
break;
|
|
||||||
case ASCH_POLYLINE_LINESTYLE::DOTTED:
|
|
||||||
dashType = PLOT_DASH_TYPE::DOT;
|
|
||||||
break;
|
|
||||||
case ASCH_POLYLINE_LINESTYLE::DASH_DOTTED:
|
|
||||||
dashType = PLOT_DASH_TYPE::DASHDOT;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( size_t i = 0; i + 1 < elem.points.size(); i++ )
|
for( size_t i = 0; i + 1 < elem.points.size(); i++ )
|
||||||
{
|
{
|
||||||
SCH_LINE* line =
|
SCH_LINE* line = new SCH_LINE( elem.points.at( i ) + m_sheetOffset,
|
||||||
new SCH_LINE( elem.points.at( i ) + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
|
SCH_LAYER_ID::LAYER_NOTES );
|
||||||
|
|
||||||
line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
|
line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
|
||||||
line->SetLineWidth( elem.lineWidth );
|
line->SetLineWidth( elem.lineWidth );
|
||||||
line->SetLineStyle( dashType );
|
line->SetLineStyle( dashType );
|
||||||
|
@ -919,9 +912,8 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Polyline has non-existent ownerindex %d",
|
||||||
"Polyline tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,12 +969,12 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Polygon has non-existent ownerindex %d",
|
||||||
"Polygon tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,9 +989,8 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
|
||||||
line->SetUnit( elem.ownerpartid );
|
line->SetUnit( elem.ownerpartid );
|
||||||
|
|
||||||
for( wxPoint& point : elem.points )
|
for( wxPoint& point : elem.points )
|
||||||
{
|
|
||||||
line->AddPoint( GetRelativePosition( point + m_sheetOffset, component ) );
|
line->AddPoint( GetRelativePosition( point + m_sheetOffset, component ) );
|
||||||
}
|
|
||||||
line->AddPoint( GetRelativePosition( elem.points.front() + m_sheetOffset, component ) );
|
line->AddPoint( GetRelativePosition( elem.points.front() + m_sheetOffset, component ) );
|
||||||
|
|
||||||
line->SetWidth( elem.lineWidth );
|
line->SetWidth( elem.lineWidth );
|
||||||
|
@ -1059,12 +1050,12 @@ void SCH_ALTIUM_PLUGIN::ParseRoundRectangle( const std::map<wxString, wxString>&
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Rounded Rectangle has non-existent ownerindex %d",
|
||||||
"Rounded Rectangle tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,9 +1098,8 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Arc has non-existent ownerindex %d",
|
||||||
"Arc tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,12 +1154,12 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map<wxString, wxString>& aProperti
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Line has non-existent ownerindex %d",
|
||||||
"Line tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1235,12 +1225,12 @@ void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map<wxString, wxString>& aPro
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& symbol = m_symbols.find( elem.ownerindex );
|
const auto& symbol = m_symbols.find( elem.ownerindex );
|
||||||
|
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Rectangle has non-existent ownerindex %d",
|
||||||
"Rectangle tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,9 +1288,8 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map<wxString, wxString>& aPr
|
||||||
const auto& sheet = m_sheets.find( elem.ownerindex );
|
const auto& sheet = m_sheets.find( elem.ownerindex );
|
||||||
if( sheet == m_sheets.end() )
|
if( sheet == m_sheets.end() )
|
||||||
{
|
{
|
||||||
wxLogError( wxString::Format(
|
wxLogError( wxString::Format( "Sheet Entry has non-existent ownerindex %d",
|
||||||
"Sheet Entry tries to access sheet with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,8 +1571,8 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map<wxString, wxString>& aPro
|
||||||
kpart->GetReferenceField().SetText( "#PWR" );
|
kpart->GetReferenceField().SetText( "#PWR" );
|
||||||
kpart->GetValueField().SetText( elem.text );
|
kpart->GetValueField().SetText( elem.text );
|
||||||
kpart->GetValueField().SetVisible( true ); // TODO: why does this not work?
|
kpart->GetValueField().SetVisible( true ); // TODO: why does this not work?
|
||||||
kpart->SetDescription( wxString::Format(
|
kpart->SetDescription( wxString::Format( _( "Power symbol creates a global label with name '%s'" ),
|
||||||
"Power symbol creates a global label with name \"%s\"", elem.text ) );
|
elem.text ) );
|
||||||
kpart->SetKeyWords( "power-flag" );
|
kpart->SetKeyWords( "power-flag" );
|
||||||
kpart->SetLibId( libId );
|
kpart->SetLibId( libId );
|
||||||
|
|
||||||
|
@ -1691,11 +1680,16 @@ void SCH_ALTIUM_PLUGIN::ParsePort( const ASCH_PORT& aElem )
|
||||||
|
|
||||||
// check if any of the points is a terminal point
|
// check if any of the points is a terminal point
|
||||||
// TODO: there seems a problem to detect approximated connections towards component pins?
|
// TODO: there seems a problem to detect approximated connections towards component pins?
|
||||||
bool connectionFound =
|
bool connectionFound = startIsWireTerminal
|
||||||
startIsWireTerminal || startIsBusTerminal || endIsWireTerminal || endIsBusTerminal;
|
|| startIsBusTerminal
|
||||||
|
|| endIsWireTerminal
|
||||||
|
|| endIsBusTerminal;
|
||||||
|
|
||||||
if( !connectionFound )
|
if( !connectionFound )
|
||||||
wxLogError( wxString::Format(
|
{
|
||||||
"There is a Port for \"%s\", but no connections towards it?", aElem.name ) );
|
wxLogError( wxString::Format( "There is a Port for \"%s\", but no connections towards it?",
|
||||||
|
aElem.name ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Select label position. In case both match, we will add a line later.
|
// Select label position. In case both match, we will add a line later.
|
||||||
wxPoint position = ( startIsWireTerminal || startIsBusTerminal ) ? start : end;
|
wxPoint position = ( startIsWireTerminal || startIsBusTerminal ) ? start : end;
|
||||||
|
@ -1955,9 +1949,8 @@ void SCH_ALTIUM_PLUGIN::ParseSheetName( const std::map<wxString, wxString>& aPro
|
||||||
const auto& sheet = m_sheets.find( elem.ownerindex );
|
const auto& sheet = m_sheets.find( elem.ownerindex );
|
||||||
if( sheet == m_sheets.end() )
|
if( sheet == m_sheets.end() )
|
||||||
{
|
{
|
||||||
wxLogError( wxString::Format(
|
wxLogError( wxString::Format( "Sheet Name has non-existent ownerindex %d",
|
||||||
"Sheet Name tries to access sheet with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1981,9 +1974,8 @@ void SCH_ALTIUM_PLUGIN::ParseFileName( const std::map<wxString, wxString>& aProp
|
||||||
const auto& sheet = m_sheets.find( elem.ownerindex );
|
const auto& sheet = m_sheets.find( elem.ownerindex );
|
||||||
if( sheet == m_sheets.end() )
|
if( sheet == m_sheets.end() )
|
||||||
{
|
{
|
||||||
wxLogError( wxString::Format(
|
wxLogError( wxString::Format( "File Name has non-existent ownerindex %d",
|
||||||
"File Name tries to access sheet with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2008,9 +2000,8 @@ void SCH_ALTIUM_PLUGIN::ParseDesignator( const std::map<wxString, wxString>& aPr
|
||||||
if( symbol == m_symbols.end() )
|
if( symbol == m_symbols.end() )
|
||||||
{
|
{
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
wxLogWarning( wxString::Format(
|
wxLogWarning( wxString::Format( "Designator has non-existent ownerindex %d",
|
||||||
"Designator tries to access symbol with ownerindex %d which does not exist",
|
elem.ownerindex ) );
|
||||||
elem.ownerindex ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,8 @@ public:
|
||||||
int GetModifyHash() const override;
|
int GetModifyHash() const override;
|
||||||
|
|
||||||
SCH_SHEET* Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
SCH_SHEET* Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
||||||
SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL ) override;
|
SCH_SHEET* aAppendToMe = nullptr,
|
||||||
|
const PROPERTIES* aProperties = nullptr ) override;
|
||||||
|
|
||||||
bool CheckHeader( const wxString& aFileName ) override;
|
bool CheckHeader( const wxString& aFileName ) override;
|
||||||
|
|
||||||
|
@ -133,28 +134,28 @@ private:
|
||||||
void ParseParameter( const std::map<wxString, wxString>& aProperties );
|
void ParseParameter( const std::map<wxString, wxString>& aProperties );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SCH_SHEET* m_rootSheet; ///< The root 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..
|
SCH_SHEET* m_currentSheet; // The current sheet of the schematic being loaded..
|
||||||
wxFileName m_filename;
|
wxFileName m_filename;
|
||||||
SCHEMATIC* m_schematic; ///< Passed to Load(), the schematic object being loaded
|
SCHEMATIC* m_schematic; // Passed to Load(), the schematic object being loaded
|
||||||
wxString m_libName; ///< Library name to save symbols
|
wxString m_libName; // Library name to save symbols
|
||||||
|
|
||||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi; ///< Plugin to create the KiCad symbol library.
|
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi; // Plugin to create KiCad symbol library.
|
||||||
std::unique_ptr<PROPERTIES> m_properties; ///< Library plugin properties.
|
std::unique_ptr<PROPERTIES> m_properties; // Library plugin properties.
|
||||||
|
|
||||||
std::unique_ptr<TITLE_BLOCK>
|
std::unique_ptr<TITLE_BLOCK> m_currentTitleBlock; // Will be assigned at the end of parsing
|
||||||
m_currentTitleBlock; /// Will be assigned at the end of parsing a sheet
|
// a sheet
|
||||||
|
|
||||||
wxPoint m_sheetOffset;
|
wxPoint m_sheetOffset;
|
||||||
std::unique_ptr<ASCH_SHEET> m_altiumSheet;
|
std::unique_ptr<ASCH_SHEET> m_altiumSheet;
|
||||||
std::map<int, SCH_COMPONENT*> m_components;
|
std::map<int, SCH_COMPONENT*> m_components;
|
||||||
std::map<int, SCH_SHEET*> m_sheets;
|
std::map<int, SCH_SHEET*> m_sheets;
|
||||||
std::map<int, LIB_PART*> m_symbols; // for the start, every component has its unique symbol
|
std::map<int, LIB_PART*> m_symbols; // every component has its unique symbol
|
||||||
|
|
||||||
std::map<wxString, LIB_PART*> m_powerSymbols;
|
std::map<wxString, LIB_PART*> m_powerSymbols;
|
||||||
|
|
||||||
std::map<int, ASCH_COMPONENT> m_altiumComponents;
|
std::map<int, ASCH_COMPONENT> m_altiumComponents;
|
||||||
std::vector<ASCH_PORT> m_altiumPortsCurrentSheet; // we require all connections first
|
std::vector<ASCH_PORT> m_altiumPortsCurrentSheet; // we require all connections first
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SCH_ALTIUM_PLUGIN_H_
|
#endif // _SCH_ALTIUM_PLUGIN_H_
|
||||||
|
|
|
@ -405,8 +405,10 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
|
||||||
m_schematic = aSchematic;
|
m_schematic = aSchematic;
|
||||||
|
|
||||||
if( !xmlDocument.Load( m_filename.GetFullPath() ) )
|
if( !xmlDocument.Load( m_filename.GetFullPath() ) )
|
||||||
THROW_IO_ERROR(
|
{
|
||||||
wxString::Format( _( "Unable to read file \"%s\"" ), m_filename.GetFullPath() ) );
|
THROW_IO_ERROR( wxString::Format( _( "Unable to read file \"%s\"" ),
|
||||||
|
m_filename.GetFullPath() ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Delete on exception, if I own m_rootSheet, according to aAppendToMe
|
// Delete on exception, if I own m_rootSheet, according to aAppendToMe
|
||||||
unique_ptr<SCH_SHEET> deleter( aAppendToMe ? nullptr : m_rootSheet );
|
unique_ptr<SCH_SHEET> deleter( aAppendToMe ? nullptr : m_rootSheet );
|
||||||
|
@ -434,7 +436,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
|
||||||
wxCHECK_MSG( libTable, NULL, "Could not load symbol lib table." );
|
wxCHECK_MSG( libTable, NULL, "Could not load symbol lib table." );
|
||||||
|
|
||||||
m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
|
m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
|
||||||
m_properties = std::make_unique<PROPERTIES>();
|
m_properties = std::make_unique<PROPERTIES>();
|
||||||
( *m_properties )[SCH_LEGACY_PLUGIN::PropBuffering] = "";
|
( *m_properties )[SCH_LEGACY_PLUGIN::PropBuffering] = "";
|
||||||
|
|
||||||
/// @note No check is being done here to see if the existing symbol library exists so this
|
/// @note No check is being done here to see if the existing symbol library exists so this
|
||||||
|
|
|
@ -92,7 +92,8 @@ public:
|
||||||
int GetModifyHash() const override;
|
int GetModifyHash() const override;
|
||||||
|
|
||||||
SCH_SHEET* Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
SCH_SHEET* Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
||||||
SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL ) override;
|
SCH_SHEET* aAppendToMe = nullptr,
|
||||||
|
const PROPERTIES* aProperties = nullptr ) override;
|
||||||
|
|
||||||
bool CheckHeader( const wxString& aFileName ) override;
|
bool CheckHeader( const wxString& aFileName ) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue