56#include <compoundfilereader.h>
64#include <wx/mstream.h>
65#include <wx/zstream.h>
66#include <wx/wfstream.h>
67#include <magic_enum.hpp>
81#define HARNESS_PORT_COLOR_DEFAULT_BACKGROUND COLOR4D( 0.92941176470588238, \
82 0.94901960784313721, \
83 0.98431372549019602, 1.0 )
85#define HARNESS_PORT_COLOR_DEFAULT_OUTLINE COLOR4D( 0.56078431372549020, \
86 0.61960784313725492, \
87 0.78823529411764703, 1.0 )
100 int green = (
color & 0x00FF00 ) >> 8;
101 int blue = (
color & 0xFF0000 ) >> 16;
173 if( stroke.
GetColor() == default_color || stroke.
GetColor() == alt_default_color )
210 else if( elem.
AreaColor == aStrokeColor )
216 else if( bgcolor.
WithAlpha( 1.0 ) == default_bgcolor )
261 for(
auto& [
name, symbol] : lib )
313 std::vector<SCH_PIN*> pins = aSymbol->
GetPins();
315 bool names_visible =
false;
316 bool numbers_visible =
false;
320 if(
pin->GetNameTextSize() > 0 && !
pin->GetName().empty() )
321 names_visible =
true;
323 if(
pin->GetNumberTextSize() > 0 && !
pin->GetNumber().empty() )
324 numbers_visible =
true;
335 if( !numbers_visible )
380 const std::map<std::string, UTF8>* aProperties )
382 wxCHECK( !aFileName.IsEmpty() && aSchematic,
nullptr );
384 wxFileName fileName( aFileName );
392 std::unique_ptr<SCH_SHEET> deleter( aAppendToMe ?
nullptr :
m_rootSheet );
396 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
423 wxCHECK_MSG( libTable,
nullptr,
"Could not load symbol lib table." );
425 m_pi.reset( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
433 wxString libTableUri =
"${KIPRJMOD}/" +
getLibFileName().GetFullName();
437 wxString(
"KiCad" ) ) );
446 libTable->
Format( &formatter, 0 );
457 wxCHECK( rootScreen,
nullptr );
477 int minWireWidth = std::numeric_limits<int>::max();
478 int minBusWidth = std::numeric_limits<int>::max();
482 std::vector<SCH_MARKER*> markers;
489 minWireWidth = std::min( minWireWidth, line->
GetLineWidth() );
492 minBusWidth = std::min( minBusWidth, line->
GetLineWidth() );
498 if( minWireWidth < std::numeric_limits<int>::max() )
499 netSettings->GetDefaultNetclass()->SetWireWidth( minWireWidth );
501 if( minBusWidth < std::numeric_limits<int>::max() )
502 netSettings->GetDefaultNetclass()->SetBusWidth( minBusWidth );
523 wxFileName parentFileName = aFileName;
537 catch(
const CFB::CFBException& exception )
541 catch(
const std::exception& exc )
543 wxLogTrace(
traceAltiumSch, wxS(
"Unhandled exception in Altium schematic "
544 "parsers: %s." ), exc.what() );
554 wxCHECK( currentScreen, );
562 wxCHECK2( sheet,
continue );
566 wxFileName loadAltiumFileName( parentFileName.GetPath(), sheet->
GetFileName() );
568 if( !loadAltiumFileName.IsFileReadable() )
572 wxDir::GetAllFiles( parentFileName.GetPath(), &files, wxEmptyString,
573 wxDIR_FILES | wxDIR_HIDDEN );
575 for(
const wxString& candidate : files )
577 wxFileName candidateFname( candidate );
579 if( candidateFname.GetFullName().IsSameAs( sheet->
GetFileName(),
false ) )
581 loadAltiumFileName = candidateFname;
587 if( loadAltiumFileName.GetFullName().IsEmpty() || !loadAltiumFileName.IsFileReadable() )
591 msg.Printf(
_(
"The file name for sheet %s is undefined, this is probably an"
592 " Altium signal harness that got converted to a sheet." ),
611 if( sheet->
GetName().Trim().empty() )
612 sheet->
SetName( loadAltiumFileName.GetName() );
614 wxCHECK2( screen,
continue );
620 wxFileName projectFileName = loadAltiumFileName;
623 sheet->
SetFileName( projectFileName.GetFullName() );
624 screen->
SetFileName( projectFileName.GetFullPath() );
634 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"Storage" } );
636 if( file ==
nullptr )
641 std::map<wxString, wxString> properties = reader.
ReadProperties();
648 for(
int i = 0; i < weight; i++ )
659 "(%d bytes remaining)." ),
668 wxString streamName = wxS(
"Additional" );
670 const CFB::COMPOUND_FILE_ENTRY* file =
671 aAltiumSchFile.
FindStream( { streamName.ToStdString() } );
673 if( file ==
nullptr )
684 std::map<wxString, wxString> properties = reader.
ReadProperties();
689 if( record != ALTIUM_SCH_RECORD::HEADER )
695 std::map<wxString, wxString> properties = reader.
ReadProperties();
716 wxString streamName = wxS(
"FileHeader" );
718 const CFB::COMPOUND_FILE_ENTRY* file =
719 aAltiumSchFile.
FindStream( { streamName.ToStdString() } );
721 if( file ==
nullptr )
732 std::map<wxString, wxString> properties = reader.
ReadProperties();
736 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Capture Binary File Version 5.0" ) )
749 std::map<wxString, wxString> properties = reader.
ReadProperties();
761 for( std::pair<const int, SCH_SYMBOL*>& symbol :
m_symbols )
774 symbol.second->SetLibSymbol( libSymbolIt->second );
811 while( storageReader.
CanRead() )
813 std::map<wxString, wxString> properties = storageReader.
ReadProperties();
816 if( properties.find( wxS(
"BINARY" ) ) != properties.end() )
830 std::map<wxString, wxString> properties = reader.
ReadProperties();
834 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Capture Ascii File Version 5.0" ) )
849 std::map<wxString, wxString> properties = reader.
ReadProperties();
852 if( properties.find( wxS(
"HEADER" ) ) != properties.end() )
858 if( properties.find( wxS(
"RECORD" ) ) != properties.end() )
871 for( std::pair<const int, SCH_SYMBOL*>& symbol :
m_symbols )
884 symbol.second->SetLibSymbol( libSymbolIt->second );
920 const wxString& aSectionName )
930 case ALTIUM_SCH_RECORD::HEADER:
933 case ALTIUM_SCH_RECORD::COMPONENT:
937 case ALTIUM_SCH_RECORD::PIN:
941 case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
945 case ALTIUM_SCH_RECORD::LABEL:
949 case ALTIUM_SCH_RECORD::BEZIER:
953 case ALTIUM_SCH_RECORD::POLYLINE:
957 case ALTIUM_SCH_RECORD::POLYGON:
961 case ALTIUM_SCH_RECORD::ELLIPSE:
965 case ALTIUM_SCH_RECORD::PIECHART:
969 case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
973 case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
974 case ALTIUM_SCH_RECORD::ARC:
978 case ALTIUM_SCH_RECORD::LINE:
982 case ALTIUM_SCH_RECORD::RECTANGLE:
986 case ALTIUM_SCH_RECORD::SHEET_SYMBOL:
990 case ALTIUM_SCH_RECORD::SHEET_ENTRY:
994 case ALTIUM_SCH_RECORD::POWER_PORT:
998 case ALTIUM_SCH_RECORD::PORT:
1004 case ALTIUM_SCH_RECORD::NO_ERC:
1008 case ALTIUM_SCH_RECORD::NET_LABEL:
1012 case ALTIUM_SCH_RECORD::BUS:
1016 case ALTIUM_SCH_RECORD::WIRE:
1020 case ALTIUM_SCH_RECORD::TEXT_FRAME:
1024 case ALTIUM_SCH_RECORD::JUNCTION:
1028 case ALTIUM_SCH_RECORD::IMAGE:
1032 case ALTIUM_SCH_RECORD::SHEET:
1036 case ALTIUM_SCH_RECORD::SHEET_NAME:
1040 case ALTIUM_SCH_RECORD::FILE_NAME:
1044 case ALTIUM_SCH_RECORD::DESIGNATOR:
1048 case ALTIUM_SCH_RECORD::BUS_ENTRY:
1052 case ALTIUM_SCH_RECORD::TEMPLATE:
1056 case ALTIUM_SCH_RECORD::PARAMETER:
1060 case ALTIUM_SCH_RECORD::PARAMETER_SET:
1064 case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
1068 case ALTIUM_SCH_RECORD::IMPLEMENTATION:
1072 case ALTIUM_SCH_RECORD::MAP_DEFINER_LIST:
1075 case ALTIUM_SCH_RECORD::MAP_DEFINER:
1078 case ALTIUM_SCH_RECORD::IMPL_PARAMS:
1081 case ALTIUM_SCH_RECORD::NOTE:
1085 case ALTIUM_SCH_RECORD::COMPILE_MASK:
1089 case ALTIUM_SCH_RECORD::HYPERLINK:
1094 case ALTIUM_SCH_RECORD::HARNESS_CONNECTOR:
1098 case ALTIUM_SCH_RECORD::HARNESS_ENTRY:
1102 case ALTIUM_SCH_RECORD::HARNESS_TYPE:
1106 case ALTIUM_SCH_RECORD::SIGNAL_HARNESS:
1110 case ALTIUM_SCH_RECORD::BLANKET:
1116 wxString::Format(
_(
"Unknown or unexpected record id %d found in %s." ), recordId,
1147 if( file.filename.IsSameAs( aFilename ) )
1150 if( file.filename.EndsWith( aFilename ) )
1151 nonExactMatch = &file;
1154 return nonExactMatch;
1161 wxCHECK( currentSheet, );
1163 wxString sheetName = currentSheet->
GetName();
1165 if( sheetName.IsEmpty() )
1166 sheetName = wxT(
"root" );
1174 m_reporter->
Report( wxString::Format(
_(
"Symbol \"%s\" in sheet \"%s\" at index %d "
1175 "replaced with symbol \"%s\"." ),
1187 wxString
name = wxString::Format(
"%s_%d%s_%s",
1210 field.SetVisible(
false );
1221 screen->
Append( symbol );
1230 wxCHECK( currentSheet, );
1232 wxString sheetName = currentSheet->
GetName();
1234 if( sheetName.IsEmpty() )
1235 sheetName = wxT(
"root" );
1240 wxString baseName = altiumTemplate.
filename.AfterLast(
'\\' ).BeforeLast(
'.' );
1242 if( baseName.IsEmpty() )
1243 baseName = wxS(
"Template" );
1251 std::vector<LIB_SYMBOL*>& aSymbol )
1267 m_reporter->
Report( wxString::Format( wxT(
"Pin's owner (%d) not found." ),
1276 schSymbol =
m_symbols.at( libSymbolIt->first );
1277 symbol = libSymbolIt->second;
1296 pin->SetVisible(
false );
1299 pin->SetNumberTextSize( 0 );
1302 pin->SetNameTextSize( 0 );
1308 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
1309 pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
1313 case ASCH_RECORD_ORIENTATION::UPWARDS:
1314 pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
1318 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
1319 pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
1323 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
1324 pin->SetOrientation( PIN_ORIENTATION::PIN_UP );
1338 pin->SetPosition( pinLocation );
1342 case ASCH_PIN_ELECTRICAL::INPUT:
1343 pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
1346 case ASCH_PIN_ELECTRICAL::BIDI:
1347 pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
1350 case ASCH_PIN_ELECTRICAL::OUTPUT:
1351 pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
1354 case ASCH_PIN_ELECTRICAL::OPEN_COLLECTOR:
1355 pin->SetType( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR );
1358 case ASCH_PIN_ELECTRICAL::PASSIVE:
1359 pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE );
1362 case ASCH_PIN_ELECTRICAL::TRISTATE:
1363 pin->SetType( ELECTRICAL_PINTYPE::PT_TRISTATE );
1366 case ASCH_PIN_ELECTRICAL::OPEN_EMITTER:
1367 pin->SetType( ELECTRICAL_PINTYPE::PT_OPENEMITTER );
1370 case ASCH_PIN_ELECTRICAL::POWER:
1371 pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
1374 case ASCH_PIN_ELECTRICAL::UNKNOWN:
1376 pin->SetType( ELECTRICAL_PINTYPE::PT_UNSPECIFIED );
1392 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
1396 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
1405 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK_LOW );
1409 pin->SetShape( GRAPHIC_PINSHAPE::INPUT_LOW );
1415 pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW );
1422 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
1426 pin->SetShape( GRAPHIC_PINSHAPE::LINE );
1436 int vjustify, hjustify;
1439 switch( justification )
1462 switch( justification )
1485 switch( orientation )
1508 text->SetTextAngle( angle );
1527 std::vector<LIB_SYMBOL*>& aSymbol, std::vector<int>& aFontSizes )
1533 static const std::map<wxString, wxString> variableMap = {
1534 {
"APPLICATION_BUILDNUMBER",
"KICAD_VERSION" },
1535 {
"SHEETNUMBER",
"#" },
1536 {
"SHEETTOTAL",
"##" },
1537 {
"TITLE",
"TITLE" },
1538 {
"REVISION",
"REVISION" },
1539 {
"DATE",
"ISSUE_DATE" },
1540 {
"CURRENTDATE",
"CURRENT_DATE" },
1541 {
"COMPANYNAME",
"COMPANY" },
1542 {
"DOCUMENTNAME",
"FILENAME" },
1543 {
"DOCUMENTFULLPATHANDNAME",
"FILEPATH" },
1544 {
"PROJECTNAME",
"PROJECTNAME" },
1552 size_t fontId =
static_cast<int>( elem.
fontId );
1569 screen->
Append( textItem );
1585 m_reporter->
Report( wxString::Format( wxT(
"Label's owner (%d) not found." ),
1591 symbol = libSymbolIt->second;
1592 schsym =
m_symbols.at( libSymbolIt->first );
1607 size_t fontId = elem.
fontId;
1618 else if( fontId > 0 && fontId <= aFontSizes.size() )
1620 int size = aFontSizes[fontId - 1];
1628 std::vector<LIB_SYMBOL*>& aSymbol,
1629 std::vector<int>& aFontSizes )
1656 textBox->
SetStart( sheetTopRight );
1657 textBox->
SetEnd( sheetBottomLeft );
1664 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
1678 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
1681 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
1684 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
1689 size_t fontId =
static_cast<int>( aElem->
FontID );
1707 screen->
Append( textBox );
1712 std::vector<int>& aFontSizes )
1727 wxString::Format( wxT(
"Label's owner (%d) not found." ), aElem->
ownerindex ),
1732 symbol = libSymbolIt->second;
1733 schsym =
m_symbols.at( libSymbolIt->first );
1758 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
1771 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
1774 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
1777 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
1782 if( aElem->
FontID > 0 && aElem->
FontID <=
static_cast<int>( aFontSizes.size() ) )
1784 int size = aFontSizes[aElem->
FontID - 1];
1791 std::vector<LIB_SYMBOL*>& aSymbol )
1795 if( elem.
points.size() < 2 )
1797 m_reporter->
Report( wxString::Format(
_(
"Bezier has %d control points. At least 2 are "
1799 static_cast<int>( elem.
points.size() ) ),
1807 wxCHECK( currentScreen, );
1809 for(
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
1811 if( i + 2 == elem.
points.size() )
1815 SCH_LAYER_ID::LAYER_NOTES );
1822 currentScreen->
Append( line );
1827 std::vector<VECTOR2I> bezierPoints;
1828 std::vector<VECTOR2I> polyPoints;
1830 for(
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
1831 bezierPoints.push_back( elem.
points.at( j ) );
1834 converter.
GetPoly( polyPoints );
1836 for(
size_t k = 0; k + 1 < polyPoints.size(); k++ )
1839 SCH_LAYER_ID::LAYER_NOTES );
1845 currentScreen->
Append( line );
1864 m_reporter->
Report( wxString::Format( wxT(
"Bezier's owner (%d) not found." ),
1870 symbol = libSymbolIt->second;
1871 schsym =
m_symbols.at( libSymbolIt->first );
1877 for(
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
1879 if( i + 2 == elem.
points.size() )
1887 for(
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
1899 else if( i + 3 == elem.
points.size() )
1910 for(
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
1930 for(
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
1939 case 0: bezier->
SetStart( pos );
break;
1942 case 3: bezier->
SetEnd( pos );
break;
1956 std::vector<LIB_SYMBOL*>& aSymbol )
1960 if( elem.
Points.size() < 2 )
1968 for(
size_t i = 1; i < elem.
Points.size(); i++ )
1997 m_reporter->
Report( wxString::Format( wxT(
"Polyline's owner (%d) not found." ),
2003 symbol = libSymbolIt->second;
2004 schsym =
m_symbols.at( libSymbolIt->first );
2033 std::vector<LIB_SYMBOL*>& aSymbol )
2068 m_reporter->
Report( wxString::Format( wxT(
"Polygon's owner (%d) not found." ),
2074 symbol = libSymbolIt->second;
2075 schsym =
m_symbols.at( libSymbolIt->first );
2116 std::vector<LIB_SYMBOL*>& aSymbol )
2150 m_reporter->
Report( wxString::Format( wxT(
"Rounded rectangle's owner (%d) not "
2157 symbol = libSymbolIt->second;
2158 schsym =
m_symbols.at( libSymbolIt->first );
2176 int radius = std::min( width / 2, height / 2 );
2212 std::vector<LIB_SYMBOL*>& aSymbol )
2228 wxCHECK( currentScreen, );
2240 currentScreen->
Append( circle );
2253 currentScreen->
Append( arc );
2270 m_reporter->
Report( wxString::Format( wxT(
"Arc's owner (%d) not found." ),
2276 symbol = libSymbolIt->second;
2277 schsym =
m_symbols.at( libSymbolIt->first );
2320 std::vector<LIB_SYMBOL*>& aSymbol )
2334 wxCHECK( currentScreen, );
2340 std::vector<BEZIER<int>> beziers;
2347 schbezier->
SetStart( bezier.Start );
2350 schbezier->
SetEnd( bezier.End );
2354 currentScreen->
Append( schbezier );
2371 m_reporter->
Report( wxString::Format( wxT(
"Elliptical Arc's owner (%d) not found." ),
2377 symbol = libSymbolIt->second;
2378 schsym =
m_symbols.at( libSymbolIt->first );
2388 std::vector<BEZIER<int>> beziers;
2408 schbezier->
SetStart( bezier.Start );
2411 schbezier->
SetEnd( bezier.End );
2414 SetLibShapeLine( elem, schbezier, ALTIUM_SCH_RECORD::ELLIPTICAL_ARC );
2422 std::vector<LIB_SYMBOL*>& aSymbol )
2471 m_reporter->
Report( wxString::Format( wxT(
"Piechart's owner (%d) not found." ),
2477 symbol = libSymbolIt->second;
2478 schsym =
m_symbols.at( libSymbolIt->first );
2508 std::vector<LIB_SYMBOL*>& aSymbol )
2528 FILL_T fillMode = elem.
IsSolid ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
2533 std::vector<BEZIER<int>> beziers;
2534 std::vector<VECTOR2I> polyPoints;
2541 schbezier->
SetStart( bezier.Start );
2544 schbezier->
SetEnd( bezier.End );
2550 screen->
Append( schbezier );
2552 polyPoints.push_back( bezier.Start );
2555 if( fillMode != FILL_T::NO_FILL )
2562 for(
const VECTOR2I& point : polyPoints )
2565 schpoly->
AddPoint( polyPoints[0] );
2567 screen->
Append( schpoly );
2584 m_reporter->
Report( wxString::Format( wxT(
"Ellipse's owner (%d) not found." ),
2590 symbol = libSymbolIt->second;
2591 schsym =
m_symbols.at( libSymbolIt->first );
2597 std::vector<BEZIER<int>> beziers;
2598 std::vector<VECTOR2I> polyPoints;
2610 libbezier->
SetStart( bezier.Start );
2613 libbezier->
SetEnd( bezier.End );
2627 polyPoints.push_back( libbezier->
GetStart() );
2638 for(
const VECTOR2I& point : polyPoints )
2641 libline->
AddPoint( polyPoints[0] );
2651 std::vector<LIB_SYMBOL*>& aSymbol )
2673 screen->
Append( circle );
2689 m_reporter->
Report( wxString::Format( wxT(
"Ellipse's owner (%d) not found." ),
2695 symbol = libSymbolIt->second;
2696 schsym =
m_symbols.at( libSymbolIt->first );
2718 std::vector<LIB_SYMBOL*>& aSymbol )
2751 m_reporter->
Report( wxString::Format( wxT(
"Line's owner (%d) not found." ),
2757 symbol = libSymbolIt->second;
2758 schsym =
m_symbols.at( libSymbolIt->first );
2809 m_reporter->
Report( wxT(
"Signal harness, belonging to the part is not currently "
2816 wxString>& aProperties )
2823 wxCHECK( currentScreen, );
2832 currentScreen->
Append( sheet );
2845 m_reporter->
Report( wxT(
"Harness connector, belonging to the part is not currently "
2860 m_reporter->
Report( wxString::Format( wxT(
"Harness entry's parent (%d) not found." ),
2867 sheetIt->second->AddPin( sheetPin );
2870 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
2872 VECTOR2I pos = sheetIt->second->GetPosition();
2873 VECTOR2I size = sheetIt->second->GetSize();
2878 case ASCH_SHEET_ENTRY_SIDE::LEFT:
2881 sheetPin->
SetSide( SHEET_SIDE::LEFT );
2883 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
2886 sheetPin->
SetSide( SHEET_SIDE::RIGHT );
2888 case ASCH_SHEET_ENTRY_SIDE::TOP:
2891 sheetPin->
SetSide( SHEET_SIDE::TOP );
2893 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
2896 sheetPin->
SetSide( SHEET_SIDE::BOTTOM );
2910 m_reporter->
Report( wxString::Format( wxT(
"Harness type's parent (%d) not found." ),
2924 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
2932 wxString fullPath = fn.GetFullPath();
2934 fullPath.Replace( wxT(
"\\" ), wxT(
"/" ) );
2936 SCH_SCREEN* screen = sheetIt->second->GetScreen();
2941 m_reporter->
Report( wxString::Format(
_(
"Altium's harness connector (%s) was imported as a "
2942 "hierarchical sheet. Please review the imported "
2950 std::vector<LIB_SYMBOL*>& aSymbol )
2965 rect->
SetEnd( sheetBottomLeft );
2986 m_reporter->
Report( wxString::Format( wxT(
"Rectangle's owner (%d) not found." ),
2992 symbol = libSymbolIt->second;
2993 schsym =
m_symbols.at( libSymbolIt->first );
3007 rect->
SetEnd( sheetBottomLeft );
3035 wxCHECK( currentScreen, );
3036 currentScreen->
Append( sheet );
3045 wxCHECK( rootScreen, );
3053 m_sheets.insert( { aIndex, sheet } );
3065 m_reporter->
Report( wxString::Format( wxT(
"Sheet entry's owner (%d) not found." ),
3072 sheetIt->second->AddPin( sheetPin );
3075 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
3079 VECTOR2I pos = sheetIt->second->GetPosition();
3080 VECTOR2I size = sheetIt->second->GetSize();
3085 case ASCH_SHEET_ENTRY_SIDE::LEFT:
3088 sheetPin->
SetSide( SHEET_SIDE::LEFT );
3091 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
3094 sheetPin->
SetSide( SHEET_SIDE::RIGHT );
3097 case ASCH_SHEET_ENTRY_SIDE::TOP:
3100 sheetPin->
SetSide( SHEET_SIDE::TOP );
3103 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
3106 sheetPin->
SetSide( SHEET_SIDE::BOTTOM );
3113 case ASCH_PORT_IOTYPE::UNSPECIFIED:
3114 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
3117 case ASCH_PORT_IOTYPE::OUTPUT:
3118 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
3121 case ASCH_PORT_IOTYPE::INPUT:
3122 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_INPUT );
3125 case ASCH_PORT_IOTYPE::BIDI:
3126 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_BIDI );
3317 aReporter->
Report(
_(
"Power Port with unknown style imported as 'Bar' type." ),
3342 wxString symName( elem.
text );
3343 std::string styleName( magic_enum::enum_name<ASCH_POWER_PORT_STYLE>( elem.
style ) );
3345 if( !styleName.empty() )
3346 symName <<
'_' << styleName;
3355 libSymbol = powerSymbolIt->second;
3360 libSymbol = alreadyLoaded;
3371 libSymbol->
SetDescription( wxString::Format(
_(
"Power symbol creates a global "
3372 "label with name '%s'" ), elem.
text ) );
3381 pin->SetPosition( { 0, 0 } );
3382 pin->SetLength( 0 );
3383 pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
3384 pin->SetVisible(
false );
3417 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
3423 case ASCH_RECORD_ORIENTATION::UPWARDS:
3429 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
3435 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
3446 screen->
Append( symbol );
3457 int height = aElem.
Height;
3467 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
3475 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
3479 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
3483 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
3488 size_t fontId =
static_cast<int>( aElem.
FontID );
3506 screen->
Append( textBox );
3508 m_reporter->
Report( wxString::Format(
_(
"Altium's harness port (%s) was imported as "
3509 "a text box. Please review the imported "
3528 switch( aElem.
Style )
3531 case ASCH_PORT_STYLE::NONE_HORIZONTAL:
3532 case ASCH_PORT_STYLE::LEFT:
3533 case ASCH_PORT_STYLE::RIGHT:
3534 case ASCH_PORT_STYLE::LEFT_RIGHT:
3538 case ASCH_PORT_STYLE::NONE_VERTICAL:
3539 case ASCH_PORT_STYLE::TOP:
3540 case ASCH_PORT_STYLE::BOTTOM:
3541 case ASCH_PORT_STYLE::TOP_BOTTOM:
3558 bool connectionFound = startIsWireTerminal
3559 || startIsBusTerminal
3560 || endIsWireTerminal
3561 || endIsBusTerminal;
3563 if( !connectionFound )
3570 VECTOR2I position = ( startIsWireTerminal || startIsBusTerminal ) ? start :
end;
3585 case ASCH_PORT_IOTYPE::UNSPECIFIED: label->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
break;
3586 case ASCH_PORT_IOTYPE::OUTPUT: label->
SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
break;
3587 case ASCH_PORT_IOTYPE::INPUT: label->
SetShape( LABEL_FLAG_SHAPE::L_INPUT );
break;
3588 case ASCH_PORT_IOTYPE::BIDI: label->
SetShape( LABEL_FLAG_SHAPE::L_BIDI );
break;
3591 switch( aElem.
Style )
3594 case ASCH_PORT_STYLE::NONE_HORIZONTAL:
3595 case ASCH_PORT_STYLE::LEFT:
3596 case ASCH_PORT_STYLE::RIGHT:
3597 case ASCH_PORT_STYLE::LEFT_RIGHT:
3598 if( ( startIsWireTerminal || startIsBusTerminal ) )
3605 case ASCH_PORT_STYLE::NONE_VERTICAL:
3606 case ASCH_PORT_STYLE::TOP:
3607 case ASCH_PORT_STYLE::BOTTOM:
3608 case ASCH_PORT_STYLE::TOP_BOTTOM:
3609 if( ( startIsWireTerminal || startIsBusTerminal ) )
3621 label->
GetFields()[0].SetVisible(
false );
3628 if( ( startIsWireTerminal && endIsWireTerminal ) )
3636 else if( startIsBusTerminal && endIsBusTerminal )
3659 screen->
Append( noConnect );
3687 for(
size_t i = 0; i + 1 < elem.
points.size(); i++ )
3690 SCH_LAYER_ID::LAYER_BUS );
3707 for(
size_t i = 0; i + 1 < elem.
points.size(); i++ )
3710 SCH_LAYER_ID::LAYER_WIRE );
3730 screen->
Append( junction );
3742 && component->second.currentpartid != elem.
ownerpartid )
3746 std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>(
center );
3758 wxString msg = wxString::Format(
_(
"Embedded file %s not found in storage." ),
3764 wxString storagePath = wxFileName::CreateTempFileName(
"kicad_import_" );
3767 wxMemoryInputStream fileStream( storageFile->
data.data(), storageFile->
data.size() );
3768 wxZlibInputStream zlibInputStream( fileStream );
3769 wxFFileOutputStream outputStream( storagePath );
3770 outputStream.Write( zlibInputStream );
3771 outputStream.Close();
3775 m_reporter->
Report( wxString::Format(
_(
"Error reading image %s." ), storagePath ),
3781 wxRemoveFile( storagePath );
3785 if( !wxFileExists( elem.
filename ) )
3803 const double scaleX =
3804 std::abs(
static_cast<double>( expectedImageSize.
x ) / currentImageSize.
x );
3805 const double scaleY =
3806 std::abs(
static_cast<double>( expectedImageSize.
y ) / currentImageSize.
y );
3809 bitmap->SetFlags(
IS_NEW );
3810 screen->
Append( bitmap.release() );
3816 m_altiumSheet = std::make_unique<ASCH_SHEET>( aProperties );
3823 bool isPortrait =
m_altiumSheet->sheetOrientation == ASCH_SHEET_WORKSPACEORIENTATION::PORTRAIT;
3836 case ASCH_SHEET_SIZE::A4: pageInfo.
SetType(
"A4", isPortrait );
break;
3837 case ASCH_SHEET_SIZE::A3: pageInfo.
SetType(
"A3", isPortrait );
break;
3838 case ASCH_SHEET_SIZE::A2: pageInfo.
SetType(
"A2", isPortrait );
break;
3839 case ASCH_SHEET_SIZE::A1: pageInfo.
SetType(
"A1", isPortrait );
break;
3840 case ASCH_SHEET_SIZE::A0: pageInfo.
SetType(
"A0", isPortrait );
break;
3841 case ASCH_SHEET_SIZE::A: pageInfo.
SetType(
"A", isPortrait );
break;
3842 case ASCH_SHEET_SIZE::B: pageInfo.
SetType(
"B", isPortrait );
break;
3843 case ASCH_SHEET_SIZE::C: pageInfo.
SetType(
"C", isPortrait );
break;
3844 case ASCH_SHEET_SIZE::D: pageInfo.
SetType(
"D", isPortrait );
break;
3845 case ASCH_SHEET_SIZE::E: pageInfo.
SetType(
"E", isPortrait );
break;
3846 case ASCH_SHEET_SIZE::LETTER: pageInfo.
SetType(
"USLetter", isPortrait );
break;
3847 case ASCH_SHEET_SIZE::LEGAL: pageInfo.
SetType(
"USLegal", isPortrait );
break;
3848 case ASCH_SHEET_SIZE::TABLOID: pageInfo.
SetType(
"A3", isPortrait );
break;
3849 case ASCH_SHEET_SIZE::ORCAD_A: pageInfo.
SetType(
"A", isPortrait );
break;
3850 case ASCH_SHEET_SIZE::ORCAD_B: pageInfo.
SetType(
"B", isPortrait );
break;
3851 case ASCH_SHEET_SIZE::ORCAD_C: pageInfo.
SetType(
"C", isPortrait );
break;
3852 case ASCH_SHEET_SIZE::ORCAD_D: pageInfo.
SetType(
"D", isPortrait );
break;
3853 case ASCH_SHEET_SIZE::ORCAD_E: pageInfo.
SetType(
"E", isPortrait );
break;
3871 m_reporter->
Report( wxString::Format( wxT(
"Sheetname's owner (%d) not found." ),
3894 m_reporter->
Report( wxString::Format( wxT(
"Filename's owner (%d) not found." ),
3920 m_reporter->
Report( wxString::Format( wxT(
"Designator's owner (%d) not found." ),
3934 bool emptyRef = elem.
text.IsEmpty();
3939 bool visible = !emptyRef;
3951 std::vector<LIB_SYMBOL*>& aSymbol,
3952 std::vector<int>& aFontSizes )
3959 bool emptyRef = elem.
text.IsEmpty();
3960 SCH_FIELD& refField = symbol->GetReferenceField();
3963 refField.
SetText( wxT(
"X" ) );
3969 if( elem.
fontId > 0 && elem.
fontId <=
static_cast<int>( aFontSizes.size() ) )
3971 int size = aFontSizes[elem.
fontId - 1];
3988 busWireEntry->
SetSize( { vector.
x, vector.
y } );
3991 screen->
Append( busWireEntry );
4000 static const std::map<wxString, wxString> variableMap = {
4001 {
"COMMENT",
"VALUE" },
4002 {
"VALUE",
"ALTIUM_VALUE" },
4008 if( elem.
text ==
"*" )
4011 wxString paramName = elem.
name.Upper();
4013 if( paramName ==
"SHEETNUMBER" )
4017 else if( paramName ==
"TITLE" )
4021 else if( paramName ==
"REVISION" )
4025 else if( paramName ==
"DATE" )
4029 else if( paramName ==
"COMPANYNAME" )
4050 wxString upperName = elem.
name.Upper();
4052 if( upperName ==
"COMMENT" )
4059 wxString fieldName = elem.
name.Upper();
4061 if( fieldName.IsEmpty() )
4063 int disambiguate = 1;
4067 fieldName = wxString::Format(
"ALTIUM_UNNAMED_%d", disambiguate++ );
4074 else if( fieldName ==
"VALUE" )
4076 fieldName =
"ALTIUM_VALUE";
4092 std::vector<LIB_SYMBOL*>& aSymbol,
4093 std::vector<int>& aFontSizes )
4114 std::map<wxString, wxString> variableMap = {
4115 {
"COMMENT",
"VALUE" },
4121 wxString upperName = elem.
name.Upper();
4123 if( upperName ==
"COMMENT" )
4125 field = &libSymbol->GetValueField();
4129 int fieldIdx = libSymbol->GetNextAvailableFieldId();
4130 wxString fieldNameStem = elem.
name;
4131 wxString fieldName = fieldNameStem;
4132 int disambiguate = 1;
4134 if( fieldName.IsEmpty() )
4136 fieldNameStem =
"ALTIUM_UNNAMED";
4137 fieldName =
"ALTIUM_UNNAMED_1";
4140 else if( upperName ==
"VALUE" )
4142 fieldNameStem =
"ALTIUM_VALUE";
4143 fieldName =
"ALTIUM_VALUE";
4147 while( libSymbol->FindField( fieldName ) )
4148 fieldName = wxString::Format(
"%s_%d", fieldNameStem, disambiguate++ );
4151 libSymbol->AddField( new_field );
4162 if( elem.
fontId > 0 && elem.
fontId <=
static_cast<int>( aFontSizes.size() ) )
4164 int size = aFontSizes[elem.
fontId - 1];
4178 const std::map<wxString, wxString>& aProperties )
4187 std::vector<LIB_SYMBOL*>& aSymbol )
4191 if( elem.
type != wxS(
"PCBLIB" ) )
4195 if( aSymbol.size() == 0 && !elem.
isCurrent )
4201 wxArrayString fpFilters;
4202 fpFilters.Add( wxString::Format( wxS(
"*%s*" ), elem.
name ) );
4205 if( !aSymbol.empty() )
4211 symbol->SetFPFilters( fpFilters );
4212 SCH_FIELD& footprintField = symbol->GetFootprintField();
4223 m_reporter->
Report( wxString::Format( wxT(
"Implementation's owner (%d) not found." ),
4229 const auto& libSymbolIt =
m_libSymbols.find( implementationOwnerIt->second );
4233 m_reporter->
Report( wxString::Format( wxT(
"Footprint's owner (%d) not found." ),
4234 implementationOwnerIt->second ),
4241 libSymbolIt->second->SetFPFilters( fpFilters );
4251 wxString>& aProperties )
4255 std::vector<LIB_SYMBOL*> symbols;
4273 symbols.push_back( symbol );
4282 std::map<wxString,LIB_SYMBOL*> ret;
4283 std::vector<int> fontSizes;
4284 struct SYMBOL_PIN_FRAC
4293 std::map<wxString, ALTIUM_SYMBOL_DATA> syms = aAltiumLibFile.
GetLibSymbols(
nullptr );
4295 for(
auto& [
name, entry] : syms )
4298 std::map<int, SYMBOL_PIN_FRAC> pinFracs;
4300 if( entry.m_pinsFrac )
4302 auto parse_binary_pin_frac =
4303 [&](
const std::string& binaryData ) -> std::map<wxString, wxString>
4305 std::map<wxString, wxString> result;
4311 SYMBOL_PIN_FRAC pinFrac;
4315 pinFrac.len_frac = binreader.
ReadInt32();
4316 pinFracs.insert( { pinFracData.first, pinFrac } );
4330 std::vector<LIB_SYMBOL*> symbols;
4339 std::map<wxString, wxString> properties = reader.
ReadProperties();
4343 if( record != ALTIUM_SCH_RECORD::COMPONENT )
4344 THROW_IO_ERROR(
"LibSymbol does not start with COMPONENT record" );
4349 auto handleBinaryPinLambda =
4350 [&](
const std::string& binaryData ) -> std::map<wxString, wxString>
4352 std::map<wxString, wxString> result;
4356 int32_t recordId = binreader.
ReadInt32();
4358 if( recordId !=
static_cast<int32_t
>( ALTIUM_SCH_RECORD::PIN ) )
4361 result[
"RECORD"] = wxString::Format(
"%d", recordId );
4363 result[
"OWNERPARTID"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4364 result[
"OWNERPARTDISPLAYMODE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4365 result[
"SYMBOL_INNEREDGE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4366 result[
"SYMBOL_OUTEREDGE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4367 result[
"SYMBOL_INNER"] = wxString::Format(
"%d", binreader.
ReadByte() );
4368 result[
"SYMBOL_OUTER"] = wxString::Format(
"%d", binreader.
ReadByte() );
4371 result[
"ELECTRICAL"] = wxString::Format(
"%d", binreader.
ReadByte() );
4372 result[
"PINCONGLOMERATE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4373 result[
"PINLENGTH"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4374 result[
"LOCATION.X"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4375 result[
"LOCATION.Y"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4376 result[
"COLOR"] = wxString::Format(
"%d", binreader.
ReadInt32() );
4382 if(
auto it = pinFracs.find( pin_index ); it != pinFracs.end() )
4384 result[
"LOCATION.X_FRAC"] = wxString::Format(
"%d", it->second.x_frac );
4385 result[
"LOCATION.Y_FRAC"] = wxString::Format(
"%d", it->second.y_frac );
4386 result[
"PINLENGTH_FRAC"] = wxString::Format(
"%d", it->second.len_frac );
4390 std::vector<std::string> partSeqSplit =
split( partSeq,
"|" );
4392 if( partSeqSplit.size() == 3 )
4394 result[
"PART"] = partSeqSplit[0];
4395 result[
"SEQ"] = partSeqSplit[2];
4403 std::map<wxString, wxString> properties = reader.
ReadProperties( handleBinaryPinLambda );
4405 if( properties.empty() )
4413 case ALTIUM_SCH_RECORD::PIN:
4420 case ALTIUM_SCH_RECORD::LABEL:
ParseLabel( properties, symbols, fontSizes );
break;
4422 case ALTIUM_SCH_RECORD::BEZIER:
ParseBezier( properties, symbols );
break;
4424 case ALTIUM_SCH_RECORD::POLYLINE:
ParsePolyline( properties, symbols );
break;
4426 case ALTIUM_SCH_RECORD::POLYGON:
ParsePolygon( properties, symbols );
break;
4428 case ALTIUM_SCH_RECORD::ELLIPSE:
ParseEllipse( properties, symbols );
break;
4430 case ALTIUM_SCH_RECORD::PIECHART:
ParsePieChart( properties, symbols );
break;
4432 case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
ParseRoundRectangle( properties, symbols );
break;
4434 case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
ParseEllipticalArc( properties, symbols );
break;
4436 case ALTIUM_SCH_RECORD::ARC:
ParseArc( properties, symbols );
break;
4438 case ALTIUM_SCH_RECORD::LINE:
ParseLine( properties, symbols );
break;
4440 case ALTIUM_SCH_RECORD::RECTANGLE:
ParseRectangle( properties, symbols );
break;
4442 case ALTIUM_SCH_RECORD::DESIGNATOR:
ParseLibDesignator( properties, symbols, fontSizes );
break;
4444 case ALTIUM_SCH_RECORD::PARAMETER:
ParseLibParameter( properties, symbols, fontSizes );
break;
4446 case ALTIUM_SCH_RECORD::TEXT_FRAME:
ParseTextFrame( properties, symbols, fontSizes );
break;
4449 case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
break;
4451 case ALTIUM_SCH_RECORD::IMPLEMENTATION:
ParseImplementation( properties, symbols );
break;
4453 case ALTIUM_SCH_RECORD::IMPL_PARAMS:
break;
4455 case ALTIUM_SCH_RECORD::MAP_DEFINER_LIST:
break;
4456 case ALTIUM_SCH_RECORD::MAP_DEFINER:
break;
4459 case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
break;
4462 case ALTIUM_SCH_RECORD::IMAGE:
break;
4465 m_reporter->
Report( wxString::Format(
_(
"Unknown or unexpected record id %d found "
4467 recordId, symbols[0]->
GetName() ),
4479 for(
size_t ii = 0; ii < symbols.size(); ii++ )
4487 if( valField.
GetText().IsEmpty() )
4490 if( symbols.size() == 1 )
4493 ret[wxString::Format(
"%s (Altium Display %zd)",
name, ii + 1 )] = symbol;
4503 wxFileName fn( aLibraryPath );
4505 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
4506 return fn.GetModificationTime().GetValue().GetValue();
4508 return wxDateTime( 0.0 ).GetValue().GetValue();
4513 const std::map<std::string, UTF8>* aProperties )
4526 std::vector<std::unique_ptr<ALTIUM_COMPOUND_FILE>> compoundFiles;
4528 wxFileName fileName( aLibraryPath );
4533 if( aLibraryPath.Lower().EndsWith( wxS(
".schlib" ) ) )
4537 compoundFiles.push_back( std::make_unique<ALTIUM_COMPOUND_FILE>( aLibraryPath ) );
4539 else if( aLibraryPath.Lower().EndsWith( wxS(
".intlib" ) ) )
4543 std::unique_ptr<ALTIUM_COMPOUND_FILE> intCom =
4544 std::make_unique<ALTIUM_COMPOUND_FILE>( aLibraryPath );
4546 std::map<wxString, const CFB::COMPOUND_FILE_ENTRY*> schLibFiles =
4547 intCom->EnumDir( L
"SchLib" );
4549 for(
const auto& [schLibName, cfe] : schLibFiles )
4550 compoundFiles.push_back( intCom->DecodeIntLibStream( *cfe ) );
4553 std::map<wxString, LIB_SYMBOL*>& cacheMapRef =
m_libCache[aLibraryPath];
4555 for(
auto& altiumSchFilePtr : compoundFiles )
4557 std::map<wxString, LIB_SYMBOL*> parsed =
ParseLibFile( *altiumSchFilePtr );
4558 cacheMapRef.insert( parsed.begin(), parsed.end() );
4563 catch(
const CFB::CFBException& exception )
4567 catch(
const std::exception& exc )
4569 wxFAIL_MSG( wxString::Format( wxT(
"Unhandled exception in Altium schematic parsers: %s." ),
4577 std::vector<int>& aFontSizes )
4579 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"FileHeader" } );
4581 if( file ==
nullptr )
4591 std::map<wxString, wxString> properties = reader.
ReadProperties();
4595 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Library Editor Binary File Version 5.0" ) )
4596 THROW_IO_ERROR(
_(
"Expected Altium Schematic Library file version 5.0" ) );
4598 for(
auto& [key, value] : properties )
4600 wxString upperKey = key.Upper();
4603 if( upperKey.StartsWith(
"SIZE", &remaining ) )
4605 if( !remaining.empty() )
4607 int ind = wxAtoi( remaining );
4609 if(
static_cast<int>( aFontSizes.size() ) < ind )
4610 aFontSizes.resize( ind );
4614 aFontSizes[ind - 1] = scaled;
4623 const std::map<std::string, UTF8>* aProperties,
4624 std::function<
void(
const wxString&,
LIB_SYMBOL*)> aInserter )
4628 bool powerSymbolsOnly = ( aProperties &&
4630 != aProperties->end() );
4636 for(
auto& [libnameStr, libSymbol] : it->second )
4638 if( powerSymbolsOnly && !libSymbol->IsPower() )
4641 aInserter( libnameStr, libSymbol );
4648 const wxString& aLibraryPath,
4649 const std::map<std::string, UTF8>* aProperties )
4654 aSymbolNameList.Add( aStr );
4660 const wxString& aLibraryPath,
4661 const std::map<std::string, UTF8>* aProperties )
4666 aSymbolList.emplace_back( aSymbol );
4672 const wxString& aAliasName,
4673 const std::map<std::string, UTF8>* aProperties )
4681 auto it2 = it->second.find( aAliasName );
4683 if( it2 != it->second.end() )
const int ALTIUM_COMPONENT_NONE
wxString AltiumSchSpecialStringsToKiCadVariables(const wxString &aString, const std::map< wxString, wxString > &aOverrides)
wxString AltiumPinNamesToKiCad(wxString &aString)
LIB_ID AltiumToKiCadLibID(const wxString &aLibName, const wxString &aLibReference)
constexpr EDA_IU_SCALE schIUScale
void TransformEllipseToBeziers(const ELLIPSE< T > &aEllipse, std::vector< BEZIER< T > > &aBeziers)
Transforms an ellipse or elliptical arc into a set of quadratic Bezier curves that approximate it.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
std::map< wxString, wxString > ReadProperties()
size_t GetRemainingBytes() const
std::map< wxString, wxString > ReadProperties(std::function< std::map< wxString, wxString >(const std::string &)> handleBinaryData=[](const std::string &) { return std::map< wxString, wxString >();})
std::string ReadShortPascalString()
std::map< wxString, ALTIUM_SYMBOL_DATA > GetLibSymbols(const CFB::COMPOUND_FILE_ENTRY *aStart) const
const CFB::COMPOUND_FILE_ENTRY * FindStream(const std::vector< std::string > &aStreamPath) const
std::pair< int, std::string * > ReadCompressedString()
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMaxError=10)
Convert a Bezier curve to a polygon.
Generic cubic Bezier representation.
void SetFlags(EDA_ITEM_FLAGS aMask)
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
FILL_T GetFillMode() const
void SetLineStyle(const LINE_STYLE aStyle)
void SetFillColor(const COLOR4D &aColor)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
COLOR4D GetFillColor() const
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
virtual int GetWidth() const
void SetWidth(int aWidth)
void SetFillMode(FILL_T aFill)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetTextColor(const COLOR4D &aColor)
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
virtual void SetVisible(bool aVisible)
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
EE_TYPE OfType(KICAD_T aType) const
This class was created to handle importing ellipses from other file formats that support them nativel...
const wxString & GetName() const
Return a brief hard coded name for this IO interface.
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
virtual bool CanReadLibrary(const wxString &aFileName) const
Checks if this IO object can read the specified library file/directory.
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
COLOR4D & FromCSSRGBA(int aRed, int aGreen, int aBlue, double aAlpha=1.0)
Initialize the color from a RGBA value with 0-255 red/green/blue and 0-1 alpha.
A logical library item identifier and consists of various portions much like a URI.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.