This commit is contained in:
Jeff Young 2022-06-08 18:16:11 +01:00
parent f2c26ae528
commit ec40a98fe2
1 changed files with 125 additions and 123 deletions

View File

@ -70,15 +70,15 @@ using namespace std;
* Map of EAGLE pin type values to KiCad pin type values * Map of EAGLE pin type values to KiCad pin type values
*/ */
static const std::map<wxString, ELECTRICAL_PINTYPE> pinDirectionsMap = { static const std::map<wxString, ELECTRICAL_PINTYPE> pinDirectionsMap = {
{ "sup", ELECTRICAL_PINTYPE::PT_POWER_IN }, { wxT( "sup" ), ELECTRICAL_PINTYPE::PT_POWER_IN },
{ "pas", ELECTRICAL_PINTYPE::PT_PASSIVE }, { wxT( "pas" ), ELECTRICAL_PINTYPE::PT_PASSIVE },
{ "out", ELECTRICAL_PINTYPE::PT_OUTPUT }, { wxT( "out" ), ELECTRICAL_PINTYPE::PT_OUTPUT },
{ "in", ELECTRICAL_PINTYPE::PT_INPUT }, { wxT( "in" ), ELECTRICAL_PINTYPE::PT_INPUT },
{ "nc", ELECTRICAL_PINTYPE::PT_NC }, { wxT( "nc" ), ELECTRICAL_PINTYPE::PT_NC },
{ "io", ELECTRICAL_PINTYPE::PT_BIDI }, { wxT( "io" ), ELECTRICAL_PINTYPE::PT_BIDI },
{ "oc", ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR }, { wxT( "oc" ), ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR },
{ "hiz", ELECTRICAL_PINTYPE::PT_TRISTATE }, { wxT( "hiz" ), ELECTRICAL_PINTYPE::PT_TRISTATE },
{ "pwr", ELECTRICAL_PINTYPE::PT_POWER_IN }, { wxT( "pwr" ), ELECTRICAL_PINTYPE::PT_POWER_IN },
}; };
@ -143,9 +143,9 @@ wxString SCH_EAGLE_PLUGIN::getLibName()
} }
if( m_libName.IsEmpty() ) if( m_libName.IsEmpty() )
m_libName = "noname"; m_libName = wxT( "noname" );
m_libName += "-eagle-import"; m_libName += wxT( "-eagle-import" );
m_libName = LIB_ID::FixIllegalChars( m_libName, true ); m_libName = LIB_ID::FixIllegalChars( m_libName, true );
} }
@ -196,15 +196,15 @@ void SCH_EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
* </layers> * </layers>
*/ */
if( elayer.name == "Nets" ) if( elayer.name == wxT( "Nets" ) )
{ {
m_layerMap[elayer.number] = LAYER_WIRE; m_layerMap[elayer.number] = LAYER_WIRE;
} }
else if( elayer.name == "Info" || elayer.name == "Guide" ) else if( elayer.name == wxT( "Info" ) || elayer.name == wxT( "Guide" ) )
{ {
m_layerMap[elayer.number] = LAYER_NOTES; m_layerMap[elayer.number] = LAYER_NOTES;
} }
else if( elayer.name == "Busses" ) else if( elayer.name == wxT( "Busses" ) )
{ {
m_layerMap[elayer.number] = LAYER_BUS; m_layerMap[elayer.number] = LAYER_BUS;
} }
@ -227,7 +227,7 @@ static SYMBOL_ORIENTATION_T kiCadComponentRotation( float eagleDegrees )
switch( roti ) switch( roti )
{ {
default: default:
wxASSERT_MSG( false, wxString::Format( "Unhandled orientation (%d degrees)", roti ) ); wxASSERT_MSG( false, wxString::Format( wxT( "Unhandled orientation (%d degrees)" ), roti ) );
KI_FALLTHROUGH; KI_FALLTHROUGH;
case 0: case 0:
@ -371,19 +371,19 @@ SCH_EAGLE_PLUGIN::~SCH_EAGLE_PLUGIN()
const wxString SCH_EAGLE_PLUGIN::GetName() const const wxString SCH_EAGLE_PLUGIN::GetName() const
{ {
return "EAGLE"; return wxT( "EAGLE" );
} }
const wxString SCH_EAGLE_PLUGIN::GetFileExtension() const const wxString SCH_EAGLE_PLUGIN::GetFileExtension() const
{ {
return "sch"; return wxT( "sch" );
} }
const wxString SCH_EAGLE_PLUGIN::GetLibraryFileExtension() const const wxString SCH_EAGLE_PLUGIN::GetLibraryFileExtension() const
{ {
return "lbr"; return wxT( "lbr" );
} }
@ -448,7 +448,9 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
if( aAppendToMe ) if( aAppendToMe )
{ {
wxCHECK_MSG( aSchematic->IsValid(), nullptr, "Can't append to a schematic with no root!" ); wxCHECK_MSG( aSchematic->IsValid(), nullptr,
wxT( "Can't append to a schematic with no root!" ) );
m_rootSheet = &aSchematic->Root(); m_rootSheet = &aSchematic->Root();
} }
else else
@ -467,7 +469,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable(); SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable();
wxCHECK_MSG( libTable, nullptr, "Could not load symbol lib table." ); wxCHECK_MSG( libTable, nullptr, wxT( "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>();
@ -479,11 +481,10 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
{ {
// Create a new empty symbol library. // Create a new empty symbol library.
m_pi->CreateSymbolLib( getLibFileName().GetFullPath() ); m_pi->CreateSymbolLib( getLibFileName().GetFullPath() );
wxString libTableUri = "${KIPRJMOD}/" + getLibFileName().GetFullName(); wxString libTableUri = wxT( "${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, wxT( "KiCad" ) ) );
new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri, wxString( "KiCad" ) ) );
// Save project symbol library table. // Save project symbol library table.
wxFileName fn( m_schematic->Prj().GetProjectPath(), wxFileName fn( m_schematic->Prj().GetProjectPath(),
@ -505,7 +506,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
// If the attribute is found, store the Eagle version; // If the attribute is found, store the Eagle version;
// otherwise, store the dummy "0.0" version. // otherwise, store the dummy "0.0" version.
m_version = currentNode->GetAttribute( "version", "0.0" ); m_version = currentNode->GetAttribute( wxT( "version" ), wxT( "0.0" ) );
// Map all children into a readable dictionary // Map all children into a readable dictionary
NODE_MAP children = MapChildren( currentNode ); NODE_MAP children = MapChildren( currentNode );
@ -555,7 +556,7 @@ void SCH_EAGLE_PLUGIN::countNets( wxXmlNode* aSchematicNode )
NODE_MAP schematicChildren = MapChildren( aSchematicNode ); NODE_MAP schematicChildren = MapChildren( aSchematicNode );
// Loop through all the sheets // Loop through all the sheets
wxXmlNode* sheetNode = getChildrenNodes( schematicChildren, "sheets" ); wxXmlNode* sheetNode = getChildrenNodes( schematicChildren, wxT( "sheets" ) );
while( sheetNode ) while( sheetNode )
{ {
@ -563,11 +564,11 @@ void SCH_EAGLE_PLUGIN::countNets( wxXmlNode* aSchematicNode )
// Loop through all nets // Loop through all nets
// From the DTD: "Net is an electrical connection in a schematic." // From the DTD: "Net is an electrical connection in a schematic."
wxXmlNode* netNode = getChildrenNodes( sheetChildren, "nets" ); wxXmlNode* netNode = getChildrenNodes( sheetChildren, wxT( "nets" ) );
while( netNode ) while( netNode )
{ {
wxString netName = netNode->GetAttribute( "name" ); wxString netName = netNode->GetAttribute( wxT( "name" ) );
if( m_netCounts.count( netName ) ) if( m_netCounts.count( netName ) )
m_netCounts[netName] = m_netCounts[netName] + 1; m_netCounts[netName] = m_netCounts[netName] + 1;
@ -587,9 +588,9 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
{ {
// Map all children into a readable dictionary // Map all children into a readable dictionary
NODE_MAP schematicChildren = MapChildren( aSchematicNode ); NODE_MAP schematicChildren = MapChildren( aSchematicNode );
wxXmlNode* partNode = getChildrenNodes( schematicChildren, "parts" ); wxXmlNode* partNode = getChildrenNodes( schematicChildren, wxT( "parts" ) );
wxXmlNode* libraryNode = getChildrenNodes( schematicChildren, "libraries" ); wxXmlNode* libraryNode = getChildrenNodes( schematicChildren, wxT( "libraries" ) );
wxXmlNode* sheetNode = getChildrenNodes( schematicChildren, "sheets" ); wxXmlNode* sheetNode = getChildrenNodes( schematicChildren, wxT( "sheets" ) );
if( !sheetNode ) if( !sheetNode )
return; return;
@ -618,13 +619,13 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
while( libraryNode ) while( libraryNode )
{ {
NODE_MAP libraryChildren = MapChildren( libraryNode ); NODE_MAP libraryChildren = MapChildren( libraryNode );
wxXmlNode* devicesetNode = getChildrenNodes( libraryChildren, "devicesets" ); wxXmlNode* devicesetNode = getChildrenNodes( libraryChildren, wxT( "devicesets" ) );
while( devicesetNode ) while( devicesetNode )
{ {
NODE_MAP deviceSetChildren = MapChildren( devicesetNode ); NODE_MAP deviceSetChildren = MapChildren( devicesetNode );
wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, "devices" ); wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, wxT( "devices" ) );
wxXmlNode* gateNode = getChildrenNodes( deviceSetChildren, "gates" ); wxXmlNode* gateNode = getChildrenNodes( deviceSetChildren, wxT( "gates" ) );
m_totalCount += count_nodes( deviceNode ) * count_nodes( gateNode ); m_totalCount += count_nodes( deviceNode ) * count_nodes( gateNode );
@ -635,22 +636,22 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
} }
// Rewind // Rewind
libraryNode = getChildrenNodes( schematicChildren, "libraries" ); libraryNode = getChildrenNodes( schematicChildren, wxT( "libraries" ) );
while( sheetNode ) while( sheetNode )
{ {
NODE_MAP sheetChildren = MapChildren( sheetNode ); NODE_MAP sheetChildren = MapChildren( sheetNode );
m_totalCount += count_nodes( getChildrenNodes( sheetChildren, "instances" ) ); m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "instances" ) ) );
m_totalCount += count_nodes( getChildrenNodes( sheetChildren, "busses" ) ); m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "busses" ) ) );
m_totalCount += count_nodes( getChildrenNodes( sheetChildren, "nets" ) ); m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "nets" ) ) );
m_totalCount += count_nodes( getChildrenNodes( sheetChildren, "plain" ) ); m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "plain" ) ) );
sheetNode = sheetNode->GetNext(); sheetNode = sheetNode->GetNext();
} }
// Rewind // Rewind
sheetNode = getChildrenNodes( schematicChildren, "sheets" ); sheetNode = getChildrenNodes( schematicChildren, wxT( "sheets" ) );
} }
while( partNode ) while( partNode )
@ -669,7 +670,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
while( libraryNode ) while( libraryNode )
{ {
// Read the library name // Read the library name
wxString libName = libraryNode->GetAttribute( "name" ); wxString libName = libraryNode->GetAttribute( wxT( "name" ) );
EAGLE_LIBRARY* elib = &m_eagleLibs[libName]; EAGLE_LIBRARY* elib = &m_eagleLibs[libName];
elib->name = libName; elib->name = libName;
@ -686,7 +687,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
countNets( aSchematicNode ); countNets( aSchematicNode );
// Loop through all the sheets // Loop through all the sheets
int sheet_count = countChildren( sheetNode->GetParent(), "sheet" ); int sheet_count = countChildren( sheetNode->GetParent(), wxT( "sheet" ) );
// If eagle schematic has multiple sheets then create corresponding subsheets on the root sheet // If eagle schematic has multiple sheets then create corresponding subsheets on the root sheet
if( sheet_count > 1 ) if( sheet_count > 1 )
@ -699,14 +700,14 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
SCH_SHEET_PATH rootsheetpath; SCH_SHEET_PATH rootsheetpath;
rootsheetpath.push_back( m_rootSheet ); rootsheetpath.push_back( m_rootSheet );
m_rootSheet->AddInstance( rootsheetpath ); m_rootSheet->AddInstance( rootsheetpath );
m_rootSheet->SetPageNumber( rootsheetpath, "1" ); m_rootSheet->SetPageNumber( rootsheetpath, wxT( "1" ) );
while( sheetNode ) while( sheetNode )
{ {
VECTOR2I pos = VECTOR2I( x * Mils2iu( 1000 ), y * Mils2iu( 1000 ) ); VECTOR2I pos = VECTOR2I( x * Mils2iu( 1000 ), y * Mils2iu( 1000 ) );
std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>( m_rootSheet, pos ); std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>( m_rootSheet, pos );
SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
wxString pageNo = wxString::Format( "%d", i ); wxString pageNo = wxString::Format( wxT( "%d" ), i );
sheet->SetScreen( screen ); sheet->SetScreen( screen );
sheet->GetScreen()->SetFileName( sheet->GetFileName() ); sheet->GetScreen()->SetFileName( sheet->GetFileName() );
@ -807,7 +808,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
NODE_MAP sheetChildren = MapChildren( aSheetNode ); NODE_MAP sheetChildren = MapChildren( aSheetNode );
// Get description node // Get description node
wxXmlNode* descriptionNode = getChildrenNodes( sheetChildren, "description" ); wxXmlNode* descriptionNode = getChildrenNodes( sheetChildren, wxT( "description" ) );
wxString des; wxString des;
std::string filename; std::string filename;
@ -817,13 +818,13 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
if( descriptionNode ) if( descriptionNode )
{ {
des = descriptionNode->GetContent(); des = descriptionNode->GetContent();
des.Replace( "\n", "_", true ); des.Replace( wxT( "\n" ), wxT( "_" ), true );
sheetNameField.SetText( des ); sheetNameField.SetText( des );
filename = des.ToStdString(); filename = des.ToStdString();
} }
else else
{ {
filename = wxString::Format( "%s_%d", m_filename.GetName(), aSheetIndex ); filename = wxString::Format( wxT( "%s_%d" ), m_filename.GetName(), aSheetIndex );
sheetNameField.SetText( filename ); sheetNameField.SetText( filename );
} }
@ -840,7 +841,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
// Loop through all of the symbol instances. // Loop through all of the symbol instances.
wxXmlNode* instanceNode = getChildrenNodes( sheetChildren, "instances" ); wxXmlNode* instanceNode = getChildrenNodes( sheetChildren, wxT( "instances" ) );
while( instanceNode ) while( instanceNode )
{ {
@ -854,14 +855,14 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
// From the DTD: "Buses receive names which determine which signals they include. // From the DTD: "Buses receive names which determine which signals they include.
// A bus is a drawing object. It does not create any electrical connections. // A bus is a drawing object. It does not create any electrical connections.
// These are always created by means of the nets and their names." // These are always created by means of the nets and their names."
wxXmlNode* busNode = getChildrenNodes( sheetChildren, "busses" ); wxXmlNode* busNode = getChildrenNodes( sheetChildren, wxT( "busses" ) );
while( busNode ) while( busNode )
{ {
checkpoint(); checkpoint();
// Get the bus name // Get the bus name
wxString busName = translateEagleBusName( busNode->GetAttribute( "name" ) ); wxString busName = translateEagleBusName( busNode->GetAttribute( wxT( "name" ) ) );
// Load segments of this bus // Load segments of this bus
loadSegments( busNode, busName, wxString() ); loadSegments( busNode, busName, wxString() );
@ -872,15 +873,15 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
// Loop through all nets // Loop through all nets
// From the DTD: "Net is an electrical connection in a schematic." // From the DTD: "Net is an electrical connection in a schematic."
wxXmlNode* netNode = getChildrenNodes( sheetChildren, "nets" ); wxXmlNode* netNode = getChildrenNodes( sheetChildren, wxT( "nets" ) );
while( netNode ) while( netNode )
{ {
checkpoint(); checkpoint();
// Get the net name and class // Get the net name and class
wxString netName = netNode->GetAttribute( "name" ); wxString netName = netNode->GetAttribute( wxT( "name" ) );
wxString netClass = netNode->GetAttribute( "class" ); wxString netClass = netNode->GetAttribute( wxT( "class" ) );
// Load segments of this net // Load segments of this net
loadSegments( netNode, netName, netClass ); loadSegments( netNode, netName, netClass );
@ -904,7 +905,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
* } * }
*/ */
wxXmlNode* plainNode = getChildrenNodes( sheetChildren, "plain" ); wxXmlNode* plainNode = getChildrenNodes( sheetChildren, wxT( "plain" ) );
while( plainNode ) while( plainNode )
{ {
@ -912,15 +913,15 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
wxString nodeName = plainNode->GetName(); wxString nodeName = plainNode->GetName();
if( nodeName == "text" ) if( nodeName == wxT( "text" ) )
{ {
m_currentSheet->GetScreen()->Append( loadPlainText( plainNode ) ); m_currentSheet->GetScreen()->Append( loadPlainText( plainNode ) );
} }
else if( nodeName == "wire" ) else if( nodeName == wxT( "wire" ) )
{ {
m_currentSheet->GetScreen()->Append( loadWire( plainNode ) ); m_currentSheet->GetScreen()->Append( loadWire( plainNode ) );
} }
else if( nodeName == "frame" ) else if( nodeName == wxT( "frame" ) )
{ {
std::vector<SCH_LINE*> lines; std::vector<SCH_LINE*> lines;
@ -1028,7 +1029,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
wxXmlNode* currentSegment = aSegmentsNode->GetChildren(); wxXmlNode* currentSegment = aSegmentsNode->GetChildren();
SCH_SCREEN* screen = m_currentSheet->GetScreen(); SCH_SCREEN* screen = m_currentSheet->GetScreen();
int segmentCount = countChildren( aSegmentsNode, "segment" ); int segmentCount = countChildren( aSegmentsNode, wxT( "segment" ) );
// wxCHECK( screen, [>void<] ); // wxCHECK( screen, [>void<] );
while( currentSegment ) while( currentSegment )
@ -1044,7 +1045,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
while( segmentAttribute ) while( segmentAttribute )
{ {
if( segmentAttribute->GetName() == "wire" ) if( segmentAttribute->GetName() == wxT( "wire" ) )
{ {
SCH_LINE* wire = loadWire( segmentAttribute ); SCH_LINE* wire = loadWire( segmentAttribute );
@ -1081,11 +1082,11 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
{ {
wxString nodeName = segmentAttribute->GetName(); wxString nodeName = segmentAttribute->GetName();
if( nodeName == "junction" ) if( nodeName == wxT( "junction" ) )
{ {
screen->Append( loadJunction( segmentAttribute ) ); screen->Append( loadJunction( segmentAttribute ) );
} }
else if( nodeName == "label" ) else if( nodeName == wxT( "label" ) )
{ {
SCH_TEXT* label = loadLabel( segmentAttribute, netName ); SCH_TEXT* label = loadLabel( segmentAttribute, netName );
screen->Append( label ); screen->Append( label );
@ -1094,13 +1095,13 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
segDesc.labels.push_back( label ); segDesc.labels.push_back( label );
labelled = true; labelled = true;
} }
else if( nodeName == "pinref" ) else if( nodeName == wxT( "pinref" ) )
{ {
segmentAttribute->GetAttribute( "gate" ); // REQUIRED segmentAttribute->GetAttribute( wxT( "gate" ) ); // REQUIRED
wxString part = segmentAttribute->GetAttribute( "part" ); // REQUIRED wxString part = segmentAttribute->GetAttribute( wxT( "part" ) ); // REQUIRED
wxString pin = segmentAttribute->GetAttribute( "pin" ); // REQUIRED wxString pin = segmentAttribute->GetAttribute( wxT( "pin" ) ); // REQUIRED
auto powerPort = m_powerPorts.find( "#" + part ); auto powerPort = m_powerPorts.find( wxT( "#" ) + part );
if( powerPort != m_powerPorts.end() if( powerPort != m_powerPorts.end()
&& powerPort->second == EscapeString( pin, CTX_NETNAME ) ) && powerPort->second == EscapeString( pin, CTX_NETNAME ) )
@ -1108,7 +1109,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
labelled = true; labelled = true;
} }
} }
else if( nodeName == "wire" ) else if( nodeName == wxT( "wire" ) )
{ {
// already handled; // already handled;
} }
@ -1302,7 +1303,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
wxString libraryname = epart->library; wxString libraryname = epart->library;
wxString gatename = epart->deviceset + epart->device + einstance.gate; wxString gatename = epart->deviceset + epart->device + einstance.gate;
wxString symbolname = wxString( epart->deviceset + epart->device ); wxString symbolname = wxString( epart->deviceset + epart->device );
symbolname.Replace( "*", "" ); symbolname.Replace( wxT( "*" ), wxEmptyString );
wxString kisymbolname = EscapeString( symbolname, CTX_LIBID ); wxString kisymbolname = EscapeString( symbolname, CTX_LIBID );
int unit = m_eagleLibs[libraryname].GateUnit[gatename]; int unit = m_eagleLibs[libraryname].GateUnit[gatename];
@ -1358,19 +1359,19 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
wxString reference = package.IsEmpty() ? '#' + einstance.part : einstance.part; wxString reference = package.IsEmpty() ? '#' + einstance.part : einstance.part;
// reference must end with a number but EAGLE does not enforce this // reference must end with a number but EAGLE does not enforce this
if( reference.find_last_not_of( "0123456789" ) == (reference.Length()-1) ) if( reference.find_last_not_of( wxT( "0123456789" ) ) == (reference.Length()-1) )
reference.Append( "0" ); reference.Append( wxT( "0" ) );
// EAGLE allows references to be single digits. This breaks KiCad netlisting, which requires // EAGLE allows references to be single digits. This breaks KiCad netlisting, which requires
// parts to have non-digit + digit annotation. If the reference begins with a number, // parts to have non-digit + digit annotation. If the reference begins with a number,
// we prepend 'UNK' (unknown) for the symbol designator // we prepend 'UNK' (unknown) for the symbol designator
if( reference.find_first_not_of( "0123456789" ) != 0 ) if( reference.find_first_not_of( wxT( "0123456789" ) ) != 0 )
reference.Prepend( "UNK" ); reference.Prepend( wxT( "UNK" ) );
// EAGLE allows designator to start with # but that is used in KiCad // EAGLE allows designator to start with # but that is used in KiCad
// for symbols which do not have a footprint // for symbols which do not have a footprint
if( einstance.part.find_first_not_of( "#" ) != 0 ) if( einstance.part.find_first_not_of( wxT( "#" ) ) != 0 )
reference.Prepend( "UNK" ); reference.Prepend( wxT( "UNK" ) );
SCH_SHEET_PATH sheetpath; SCH_SHEET_PATH sheetpath;
m_rootSheet->LocatePathOfScreen( screen, &sheetpath ); m_rootSheet->LocatePathOfScreen( screen, &sheetpath );
@ -1400,7 +1401,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
for( const auto& a : epart->variant ) for( const auto& a : epart->variant )
{ {
SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) ); SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
field->SetName( "VARIANT_" + a.first ); field->SetName( wxT( "VARIANT_" ) + a.first );
field->SetText( a.second ); field->SetText( a.second );
field->SetVisible( false ); field->SetVisible( false );
} }
@ -1413,17 +1414,17 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
// Parse attributes for the instance // Parse attributes for the instance
while( attributeNode ) while( attributeNode )
{ {
if( attributeNode->GetName() == "attribute" ) if( attributeNode->GetName() == wxT( "attribute" ) )
{ {
EATTR attr = EATTR( attributeNode ); EATTR attr = EATTR( attributeNode );
SCH_FIELD* field = nullptr; SCH_FIELD* field = nullptr;
if( attr.name.Lower() == "name" ) if( attr.name.Lower() == wxT( "name" ) )
{ {
field = symbol->GetField( REFERENCE_FIELD ); field = symbol->GetField( REFERENCE_FIELD );
nameAttributeFound = true; nameAttributeFound = true;
} }
else if( attr.name.Lower() == "value" ) else if( attr.name.Lower() == wxT( "value" ) )
{ {
field = symbol->GetField( VALUE_FIELD ); field = symbol->GetField( VALUE_FIELD );
valueAttributeFound = true; valueAttributeFound = true;
@ -1460,15 +1461,15 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
absdegrees ); absdegrees );
} }
} }
else if( attributeNode->GetName() == "variant" ) else if( attributeNode->GetName() == wxT( "variant" ) )
{ {
wxString variant, value; wxString variant, value;
if( attributeNode->GetAttribute( "name", &variant ) if( attributeNode->GetAttribute( wxT( "name" ), &variant )
&& attributeNode->GetAttribute( "value", &value ) ) && attributeNode->GetAttribute( wxT( "value" ), &value ) )
{ {
SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) ); SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
field->SetName( "VARIANT_" + variant ); field->SetName( wxT( "VARIANT_" ) + variant );
field->SetText( value ); field->SetText( value );
field->SetVisible( false ); field->SetVisible( false );
} }
@ -1515,27 +1516,27 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
NODE_MAP libraryChildren = MapChildren( aLibraryNode ); NODE_MAP libraryChildren = MapChildren( aLibraryNode );
// Loop through the symbols and load each of them // Loop through the symbols and load each of them
wxXmlNode* symbolNode = getChildrenNodes( libraryChildren, "symbols" ); wxXmlNode* symbolNode = getChildrenNodes( libraryChildren, wxT( "symbols" ) );
while( symbolNode ) while( symbolNode )
{ {
wxString symbolName = symbolNode->GetAttribute( "name" ); wxString symbolName = symbolNode->GetAttribute( wxT( "name" ) );
aEagleLibrary->SymbolNodes[symbolName] = symbolNode; aEagleLibrary->SymbolNodes[symbolName] = symbolNode;
symbolNode = symbolNode->GetNext(); symbolNode = symbolNode->GetNext();
} }
// Loop through the device sets and load each of them // Loop through the device sets and load each of them
wxXmlNode* devicesetNode = getChildrenNodes( libraryChildren, "devicesets" ); wxXmlNode* devicesetNode = getChildrenNodes( libraryChildren, wxT( "devicesets" ) );
while( devicesetNode ) while( devicesetNode )
{ {
// Get Device set information // Get Device set information
EDEVICE_SET edeviceset = EDEVICE_SET( devicesetNode ); EDEVICE_SET edeviceset = EDEVICE_SET( devicesetNode );
wxString prefix = edeviceset.prefix ? edeviceset.prefix.Get() : ""; wxString prefix = edeviceset.prefix ? edeviceset.prefix.Get() : wxT( "" );
NODE_MAP deviceSetChildren = MapChildren( devicesetNode ); NODE_MAP deviceSetChildren = MapChildren( devicesetNode );
wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, "devices" ); wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, wxT( "devices" ) );
// For each device in the device set: // For each device in the device set:
while( deviceNode ) while( deviceNode )
@ -1545,7 +1546,7 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
// Create symbol name from deviceset and device names. // Create symbol name from deviceset and device names.
wxString symbolName = edeviceset.name + edevice.name; wxString symbolName = edeviceset.name + edevice.name;
symbolName.Replace( "*", "" ); symbolName.Replace( wxT( "*" ), wxEmptyString );
wxASSERT( !symbolName.IsEmpty() ); wxASSERT( !symbolName.IsEmpty() );
symbolName = EscapeString( symbolName, CTX_LIBID ); symbolName = EscapeString( symbolName, CTX_LIBID );
@ -1556,8 +1557,8 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
std::unique_ptr<LIB_SYMBOL> libSymbol = std::make_unique<LIB_SYMBOL>( symbolName ); std::unique_ptr<LIB_SYMBOL> libSymbol = std::make_unique<LIB_SYMBOL>( symbolName );
// Process each gate in the deviceset for this device. // Process each gate in the deviceset for this device.
wxXmlNode* gateNode = getChildrenNodes( deviceSetChildren, "gates" ); wxXmlNode* gateNode = getChildrenNodes( deviceSetChildren, wxT( "gates" ) );
int gates_count = countChildren( deviceSetChildren["gates"], "gate" ); int gates_count = countChildren( deviceSetChildren["gates"], wxT( "gate" ) );
libSymbol->SetUnitCount( gates_count ); libSymbol->SetUnitCount( gates_count );
libSymbol->LockUnits( true ); libSymbol->LockUnits( true );
@ -1619,7 +1620,7 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol, bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol,
EDEVICE* aDevice, int aGateNumber, const wxString& aGateName ) EDEVICE* aDevice, int aGateNumber, const wxString& aGateName )
{ {
wxString symbolName = aSymbolNode->GetAttribute( "name" ); wxString symbolName = aSymbolNode->GetAttribute( wxT( "name" ) );
std::vector<LIB_ITEM*> items; std::vector<LIB_ITEM*> items;
wxXmlNode* currentNode = aSymbolNode->GetChildren(); wxXmlNode* currentNode = aSymbolNode->GetChildren();
@ -1633,11 +1634,11 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_S
{ {
wxString nodeName = currentNode->GetName(); wxString nodeName = currentNode->GetName();
if( nodeName == "circle" ) if( nodeName == wxT( "circle" ) )
{ {
aSymbol->AddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) );
} }
else if( nodeName == "pin" ) else if( nodeName == wxT( "pin" ) )
{ {
EPIN ePin = EPIN( currentNode ); EPIN ePin = EPIN( currentNode );
std::unique_ptr<LIB_PIN> pin( loadPin( aSymbol, currentNode, &ePin, aGateNumber ) ); std::unique_ptr<LIB_PIN> pin( loadPin( aSymbol, currentNode, &ePin, aGateNumber ) );
@ -1653,7 +1654,7 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_S
{ {
pin->SetType( pinDir.second ); pin->SetType( pinDir.second );
if( pinDir.first == "sup" ) // power supply symbol if( pinDir.first == wxT( "sup" ) ) // power supply symbol
ispower = true; ispower = true;
break; break;
@ -1693,30 +1694,30 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_S
else else
{ {
pin->SetUnit( aGateNumber ); pin->SetUnit( aGateNumber );
pin->SetNumber( wxString::Format( "%i", pincount ) ); pin->SetNumber( wxString::Format( wxT( "%i" ), pincount ) );
aSymbol->AddDrawItem( pin.release() ); aSymbol->AddDrawItem( pin.release() );
} }
} }
else if( nodeName == "polygon" ) else if( nodeName == wxT( "polygon" ) )
{ {
aSymbol->AddDrawItem( loadSymbolPolyLine( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolPolyLine( aSymbol, currentNode, aGateNumber ) );
} }
else if( nodeName == "rectangle" ) else if( nodeName == wxT( "rectangle" ) )
{ {
aSymbol->AddDrawItem( loadSymbolRectangle( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolRectangle( aSymbol, currentNode, aGateNumber ) );
} }
else if( nodeName == "text" ) else if( nodeName == wxT( "text" ) )
{ {
std::unique_ptr<LIB_TEXT> libtext( loadSymbolText( aSymbol, currentNode, std::unique_ptr<LIB_TEXT> libtext( loadSymbolText( aSymbol, currentNode,
aGateNumber ) ); aGateNumber ) );
if( libtext->GetText().Upper() == ">NAME" ) if( libtext->GetText().Upper() == wxT( ">NAME" ) )
{ {
LIB_FIELD* field = aSymbol->GetFieldById( REFERENCE_FIELD ); LIB_FIELD* field = aSymbol->GetFieldById( REFERENCE_FIELD );
loadFieldAttributes( field, libtext.get() ); loadFieldAttributes( field, libtext.get() );
foundName = true; foundName = true;
} }
else if( libtext->GetText().Upper() == ">VALUE" ) else if( libtext->GetText().Upper() == wxT( ">VALUE" ) )
{ {
LIB_FIELD* field = aSymbol->GetFieldById( VALUE_FIELD ); LIB_FIELD* field = aSymbol->GetFieldById( VALUE_FIELD );
loadFieldAttributes( field, libtext.get() ); loadFieldAttributes( field, libtext.get() );
@ -1727,11 +1728,11 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_S
aSymbol->AddDrawItem( libtext.release() ); aSymbol->AddDrawItem( libtext.release() );
} }
} }
else if( nodeName == "wire" ) else if( nodeName == wxT( "wire" ) )
{ {
aSymbol->AddDrawItem( loadSymbolWire( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolWire( aSymbol, currentNode, aGateNumber ) );
} }
else if( nodeName == "frame" ) else if( nodeName == wxT( "frame" ) )
{ {
std::vector<LIB_ITEM*> frameItems; std::vector<LIB_ITEM*> frameItems;
@ -1894,7 +1895,7 @@ LIB_SHAPE* SCH_EAGLE_PLUGIN::loadSymbolPolyLine( std::unique_ptr<LIB_SYMBOL>& aS
while( vertex ) while( vertex )
{ {
if( vertex->GetName() == "vertex" ) // skip <xmlattr> node if( vertex->GetName() == wxT( "vertex" ) ) // skip <xmlattr> node
{ {
EVERTEX evertex( vertex ); EVERTEX evertex( vertex );
pt = VECTOR2I( evertex.x.ToSchUnits(), evertex.y.ToSchUnits() ); pt = VECTOR2I( evertex.x.ToSchUnits(), evertex.y.ToSchUnits() );
@ -1927,7 +1928,7 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlN
case 90: pin->SetOrientation( 'U' ); break; case 90: pin->SetOrientation( 'U' ); break;
case 180: pin->SetOrientation( 'L' ); break; case 180: pin->SetOrientation( 'L' ); break;
case 270: pin->SetOrientation( 'D' ); break; case 270: pin->SetOrientation( 'D' ); break;
default: wxFAIL_MSG( wxString::Format( "Unhandled orientation (%d degrees).", roti ) ); default: wxFAIL_MSG( wxString::Format( wxT( "Unhandled orientation (%d degrees)." ), roti ) );
} }
pin->SetLength( Mils2iu( 300 ) ); // Default pin length when not defined. pin->SetLength( Mils2iu( 300 ) ); // Default pin length when not defined.
@ -1936,13 +1937,13 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlN
{ {
wxString length = aEPin->length.Get(); wxString length = aEPin->length.Get();
if( length == "short" ) if( length == wxT( "short" ) )
pin->SetLength( Mils2iu( 100 ) ); pin->SetLength( Mils2iu( 100 ) );
else if( length == "middle" ) else if( length == wxT( "middle" ) )
pin->SetLength( Mils2iu( 200 ) ); pin->SetLength( Mils2iu( 200 ) );
else if( length == "long" ) else if( length == wxT( "long" ) )
pin->SetLength( Mils2iu( 300 ) ); pin->SetLength( Mils2iu( 300 ) );
else if( length == "point" ) else if( length == wxT( "point" ) )
pin->SetLength( Mils2iu( 0 ) ); pin->SetLength( Mils2iu( 0 ) );
} }
@ -1951,22 +1952,22 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlN
{ {
wxString visible = aEPin->visible.Get(); wxString visible = aEPin->visible.Get();
if( visible == "off" ) if( visible == wxT( "off" ) )
{ {
pin->SetNameTextSize( 0 ); pin->SetNameTextSize( 0 );
pin->SetNumberTextSize( 0 ); pin->SetNumberTextSize( 0 );
} }
else if( visible == "pad" ) else if( visible == wxT( "pad" ) )
{ {
pin->SetNameTextSize( 0 ); pin->SetNameTextSize( 0 );
} }
else if( visible == "pin" ) else if( visible == wxT( "pin" ) )
{ {
pin->SetNumberTextSize( 0 ); pin->SetNumberTextSize( 0 );
} }
/* /*
* else if( visible == "both" ) * else if( visible == wxT( "both" ) )
* { * {
* } * }
*/ */
@ -1976,11 +1977,11 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlN
{ {
wxString function = aEPin->function.Get(); wxString function = aEPin->function.Get();
if( function == "dot" ) if( function == wxT( "dot" ) )
pin->SetShape( GRAPHIC_PINSHAPE::INVERTED ); pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
else if( function == "clk" ) else if( function == wxT( "clk" ) )
pin->SetShape( GRAPHIC_PINSHAPE::CLOCK ); pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
else if( function == "dotclk" ) else if( function == wxT( "dotclk" ) )
pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK ); pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
} }
@ -2006,7 +2007,7 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol
std::replace( text.begin(), text.end(), '\n', '_' ); std::replace( text.begin(), text.end(), '\n', '_' );
std::replace( text.begin(), text.end(), '\r', '_' ); std::replace( text.begin(), text.end(), '\r', '_' );
libtext->SetText( text.IsEmpty() ? "~" : text ); libtext->SetText( text.IsEmpty() ? wxT( "~" ) : text );
loadTextAttributes( libtext.get(), etext ); loadTextAttributes( libtext.get(), etext );
return libtext.release(); return libtext.release();
@ -2213,7 +2214,7 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadPlainText( wxXmlNode* aSchText )
adjustedText += tmp; adjustedText += tmp;
} }
schtext->SetText( adjustedText.IsEmpty() ? "\" \"" : escapeName( adjustedText ) ); schtext->SetText( adjustedText.IsEmpty() ? wxT( "\" \"" ) : escapeName( adjustedText ) );
schtext->SetPosition( VECTOR2I( etext.x.ToSchUnits(), -etext.y.ToSchUnits() ) ); schtext->SetPosition( VECTOR2I( etext.x.ToSchUnits(), -etext.y.ToSchUnits() ) );
loadTextAttributes( schtext.get(), etext ); loadTextAttributes( schtext.get(), etext );
schtext->SetItalic( false ); schtext->SetItalic( false );
@ -2345,8 +2346,9 @@ bool SCH_EAGLE_PLUGIN::CheckHeader( const wxString& aFileName )
wxString thirdline = tempFile.GetNextLine(); wxString thirdline = tempFile.GetNextLine();
tempFile.Close(); tempFile.Close();
return firstline.StartsWith( "<?xml" ) && secondline.StartsWith( "<!DOCTYPE eagle SYSTEM" ) return firstline.StartsWith( wxT( "<?xml" ) )
&& thirdline.StartsWith( "<eagle version" ); && secondline.StartsWith( wxT( "<!DOCTYPE eagle SYSTEM" ) )
&& thirdline.StartsWith( wxT( "<eagle version" ) );
} }
@ -3036,9 +3038,9 @@ wxString SCH_EAGLE_PLUGIN::translateEagleBusName( const wxString& aEagleName ) c
if( NET_SETTINGS::ParseBusVector( aEagleName, nullptr, nullptr ) ) if( NET_SETTINGS::ParseBusVector( aEagleName, nullptr, nullptr ) )
return aEagleName; return aEagleName;
wxString ret = "{"; wxString ret = wxT( "{" );
wxStringTokenizer tokenizer( aEagleName, "," ); wxStringTokenizer tokenizer( aEagleName, wxT( "," ) );
while( tokenizer.HasMoreTokens() ) while( tokenizer.HasMoreTokens() )
{ {
@ -3050,13 +3052,13 @@ wxString SCH_EAGLE_PLUGIN::translateEagleBusName( const wxString& aEagleName ) c
// to close it out before appending the space. // to close it out before appending the space.
if( member.Freq( '!' ) % 2 > 0 ) if( member.Freq( '!' ) % 2 > 0 )
member << "!"; member << wxT( "!" );
ret << member << " "; ret << member << wxS( " " );
} }
ret.Trim( true ); ret.Trim( true );
ret << "}"; ret << wxT( "}" );
return ret; return ret;
} }