56#include <compoundfilereader.h>
65#include <wx/mstream.h>
66#include <wx/zstream.h>
67#include <wx/wfstream.h>
68#include <magic_enum.hpp>
82#define HARNESS_PORT_COLOR_DEFAULT_BACKGROUND COLOR4D( 0.92941176470588238, \
83 0.94901960784313721, \
84 0.98431372549019602, 1.0 )
86#define HARNESS_PORT_COLOR_DEFAULT_OUTLINE COLOR4D( 0.56078431372549020, \
87 0.61960784313725492, \
88 0.78823529411764703, 1.0 )
101 int green = (
color & 0x00FF00 ) >> 8;
102 int blue = (
color & 0xFF0000 ) >> 16;
174 if( stroke.
GetColor() == default_color || stroke.
GetColor() == alt_default_color )
211 else if( elem.
AreaColor == aStrokeColor )
217 else if( bgcolor.
WithAlpha( 1.0 ) == default_bgcolor )
262 for(
auto& [
name, symbol] : lib )
314 std::vector<SCH_PIN*> pins = aSymbol->
GetPins();
316 bool names_visible =
false;
317 bool numbers_visible =
false;
321 if(
pin->GetNameTextSize() > 0 && !
pin->GetName().empty() )
322 names_visible =
true;
324 if(
pin->GetNumberTextSize() > 0 && !
pin->GetNumber().empty() )
325 numbers_visible =
true;
336 if( !numbers_visible )
385 std::map<wxString, SCH_SHEET*> sheets;
386 wxFileName
project( aProperties->at(
"project_file" ) );
388 for(
auto& [ key, filestring] : *aProperties )
390 if( !key.starts_with(
"sch" ) )
396 wxFileName fn( filestring );
397 wxFileName kicad_fn( fn );
398 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos );
400 sheet->SetScreen( screen );
404 sheet->SetFileName( fn.GetFullPath() );
407 wxCHECK2( sheet && screen,
continue );
409 wxString pageNo = wxString::Format( wxT(
"%d" ), page++ );
419 wxCHECK2( currentScreen,
continue );
423 currentScreen->
Append( sheetPtr );
424 sheets[fn.GetFullPath()] = sheetPtr;
438 for(
auto& [ filestring, sheet ] : sheets )
450 const std::map<std::string, UTF8>* aProperties )
452 wxCHECK( ( !aFileName.IsEmpty() || !aProperties->empty() ) && aSchematic,
nullptr );
454 wxFileName fileName( aFileName );
462 std::unique_ptr<SCH_SHEET> deleter( aAppendToMe ?
nullptr :
m_rootSheet );
466 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
494 wxCHECK( rootScreen,
nullptr );
505 wxCHECK_MSG( libTable,
nullptr,
"Could not load symbol lib table." );
507 m_pi.reset( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
515 wxString libTableUri =
"${KIPRJMOD}/" +
getLibFileName().GetFullName();
519 wxString(
"KiCad" ) ) );
528 libTable->
Format( &formatter, 0 );
536 if( aFileName.empty() )
560 int minWireWidth = std::numeric_limits<int>::max();
561 int minBusWidth = std::numeric_limits<int>::max();
565 std::vector<SCH_MARKER*> markers;
572 minWireWidth = std::min( minWireWidth, line->
GetLineWidth() );
575 minBusWidth = std::min( minBusWidth, line->
GetLineWidth() );
581 if( minWireWidth < std::numeric_limits<int>::max() )
582 netSettings->GetDefaultNetclass()->SetWireWidth( minWireWidth );
584 if( minBusWidth < std::numeric_limits<int>::max() )
585 netSettings->GetDefaultNetclass()->SetBusWidth( minBusWidth );
605 std::vector<SCH_LINE*> busLines;
606 std::map<VECTOR2I, std::vector<SCH_LINE*>> busLineMap;
614 busLines.push_back( line );
616 busLineMap[ line->
GetEndPoint() ].push_back( line );
623 auto it = busLineMap.find( aStart );
625 if( it == busLineMap.end() )
631 if( aVisited.count( line ) )
634 aVisited.insert( line );
659 std::shared_ptr<BUS_ALIAS> alias = std::make_shared<BUS_ALIAS>( screen);
660 alias->SetName( harness.m_name );
662 for(
auto& port : harness.m_ports )
663 alias->Members().push_back( port.m_name );
668 BOX2I box( harness.m_location, harness.m_size );
705 busLine =
new SCH_LINE( pos, SCH_LAYER_ID::LAYER_BUS );
708 screen->
Append( busLine );
712 busLine =
new SCH_LINE( pos, SCH_LAYER_ID::LAYER_BUS );
715 screen->
Append( busLine );
726 std::set<SCH_LINE*> visited;
727 SCH_LABEL* label = walkBusLine( pos, visited );
734 if( label && !label->
GetText().StartsWith( wxT(
"{" ) ) )
735 label->
SetText( label->
GetText() + wxT(
"{" ) + harness.m_name + wxT(
"}" ) );
752 bool isVertical =
true;
754 if( harness.m_ports.size() > 1 )
756 VECTOR2I first = harness.m_ports.front().m_location;
757 VECTOR2I last = harness.m_ports.back().m_location;
759 if( first.
y == last.
y )
765 VECTOR2I bottom = harness.m_ports.front().m_entryLocation;
766 VECTOR2I top = harness.m_ports.front().m_entryLocation;
795 line =
new SCH_LINE( last_pt, SCH_LAYER_ID::LAYER_BUS );
799 ? -delta_space: delta_space, 0 ) );
805 line =
new SCH_LINE( last_pt, SCH_LAYER_ID::LAYER_BUS );
814 line =
new SCH_LINE( last_pt, SCH_LAYER_ID::LAYER_BUS );
829 wxFileName parentFileName = aFileName;
843 catch(
const CFB::CFBException& exception )
847 catch(
const std::exception& exc )
849 wxLogTrace(
traceAltiumSch, wxS(
"Unhandled exception in Altium schematic "
850 "parsers: %s." ), exc.what() );
860 wxCHECK( currentScreen, );
868 wxCHECK2( sheet,
continue );
872 wxFileName loadAltiumFileName( parentFileName.GetPath(), sheet->
GetFileName() );
874 if( !loadAltiumFileName.IsFileReadable() )
878 wxDir::GetAllFiles( parentFileName.GetPath(), &files, wxEmptyString,
879 wxDIR_FILES | wxDIR_HIDDEN );
881 for(
const wxString& candidate : files )
883 wxFileName candidateFname( candidate );
885 if( candidateFname.GetFullName().IsSameAs( sheet->
GetFileName(),
false ) )
887 loadAltiumFileName = candidateFname;
893 if( loadAltiumFileName.GetFullName().IsEmpty() || !loadAltiumFileName.IsFileReadable() )
897 msg.Printf(
_(
"The file name for sheet %s is undefined, this is probably an"
898 " Altium signal harness that got converted to a sheet." ),
917 if( sheet->
GetName().Trim().empty() )
918 sheet->
SetName( loadAltiumFileName.GetName() );
920 wxCHECK2( screen,
continue );
927 wxFileName projectFileName = loadAltiumFileName;
930 sheet->
SetFileName( projectFileName.GetFullName() );
931 screen->
SetFileName( projectFileName.GetFullPath() );
941 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"Storage" } );
943 if( file ==
nullptr )
948 std::map<wxString, wxString> properties = reader.
ReadProperties();
955 for(
int i = 0; i < weight; i++ )
965 m_errorMessages.emplace( wxString::Format(
_(
"Storage file not fully parsed "
966 "(%d bytes remaining)." ),
975 wxString streamName = wxS(
"Additional" );
977 const CFB::COMPOUND_FILE_ENTRY* file =
978 aAltiumSchFile.
FindStream( { streamName.ToStdString() } );
980 if( file ==
nullptr )
991 std::map<wxString, wxString> properties = reader.
ReadProperties();
996 if( record != ALTIUM_SCH_RECORD::HEADER )
1002 std::map<wxString, wxString> properties = reader.
ReadProperties();
1026 wxString streamName = wxS(
"FileHeader" );
1028 const CFB::COMPOUND_FILE_ENTRY* file =
1029 aAltiumSchFile.
FindStream( { streamName.ToStdString() } );
1031 if( file ==
nullptr )
1042 std::map<wxString, wxString> properties = reader.
ReadProperties();
1046 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Capture Binary File Version 5.0" ) )
1059 std::map<wxString, wxString> properties = reader.
ReadProperties();
1071 for( std::pair<const int, SCH_SYMBOL*>& symbol :
m_symbols )
1084 symbol.second->SetLibSymbol( libSymbolIt->second );
1121 while( storageReader.
CanRead() )
1123 std::map<wxString, wxString> properties = storageReader.
ReadProperties();
1126 if( properties.find( wxS(
"BINARY" ) ) != properties.end() )
1140 std::map<wxString, wxString> properties = reader.
ReadProperties();
1144 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Capture Ascii File Version 5.0" ) )
1159 std::map<wxString, wxString> properties = reader.
ReadProperties();
1162 if( properties.find( wxS(
"HEADER" ) ) != properties.end() )
1168 if( properties.find( wxS(
"RECORD" ) ) != properties.end() )
1181 for( std::pair<const int, SCH_SYMBOL*>& symbol :
m_symbols )
1194 symbol.second->SetLibSymbol( libSymbolIt->second );
1234 const wxString& aSectionName )
1244 case ALTIUM_SCH_RECORD::HEADER:
1247 case ALTIUM_SCH_RECORD::COMPONENT:
1251 case ALTIUM_SCH_RECORD::PIN:
1255 case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
1259 case ALTIUM_SCH_RECORD::LABEL:
1263 case ALTIUM_SCH_RECORD::BEZIER:
1267 case ALTIUM_SCH_RECORD::POLYLINE:
1271 case ALTIUM_SCH_RECORD::POLYGON:
1275 case ALTIUM_SCH_RECORD::ELLIPSE:
1279 case ALTIUM_SCH_RECORD::PIECHART:
1283 case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
1287 case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
1288 case ALTIUM_SCH_RECORD::ARC:
1292 case ALTIUM_SCH_RECORD::LINE:
1296 case ALTIUM_SCH_RECORD::RECTANGLE:
1300 case ALTIUM_SCH_RECORD::SHEET_SYMBOL:
1304 case ALTIUM_SCH_RECORD::SHEET_ENTRY:
1308 case ALTIUM_SCH_RECORD::POWER_PORT:
1312 case ALTIUM_SCH_RECORD::PORT:
1318 case ALTIUM_SCH_RECORD::NO_ERC:
1322 case ALTIUM_SCH_RECORD::NET_LABEL:
1326 case ALTIUM_SCH_RECORD::BUS:
1330 case ALTIUM_SCH_RECORD::WIRE:
1334 case ALTIUM_SCH_RECORD::TEXT_FRAME:
1338 case ALTIUM_SCH_RECORD::JUNCTION:
1342 case ALTIUM_SCH_RECORD::IMAGE:
1346 case ALTIUM_SCH_RECORD::SHEET:
1350 case ALTIUM_SCH_RECORD::SHEET_NAME:
1354 case ALTIUM_SCH_RECORD::FILE_NAME:
1358 case ALTIUM_SCH_RECORD::DESIGNATOR:
1362 case ALTIUM_SCH_RECORD::BUS_ENTRY:
1366 case ALTIUM_SCH_RECORD::TEMPLATE:
1370 case ALTIUM_SCH_RECORD::PARAMETER:
1374 case ALTIUM_SCH_RECORD::PARAMETER_SET:
1378 case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
1382 case ALTIUM_SCH_RECORD::IMPLEMENTATION:
1386 case ALTIUM_SCH_RECORD::MAP_DEFINER_LIST:
1389 case ALTIUM_SCH_RECORD::MAP_DEFINER:
1392 case ALTIUM_SCH_RECORD::IMPL_PARAMS:
1395 case ALTIUM_SCH_RECORD::NOTE:
1399 case ALTIUM_SCH_RECORD::COMPILE_MASK:
1403 case ALTIUM_SCH_RECORD::HYPERLINK:
1408 case ALTIUM_SCH_RECORD::HARNESS_CONNECTOR:
1412 case ALTIUM_SCH_RECORD::HARNESS_ENTRY:
1416 case ALTIUM_SCH_RECORD::HARNESS_TYPE:
1420 case ALTIUM_SCH_RECORD::SIGNAL_HARNESS:
1424 case ALTIUM_SCH_RECORD::BLANKET:
1430 wxString::Format(
_(
"Unknown or unexpected record id %d found in %s." ), recordId,
1461 if( file.filename.IsSameAs( aFilename ) )
1464 if( file.filename.EndsWith( aFilename ) )
1465 nonExactMatch = &file;
1468 return nonExactMatch;
1475 wxCHECK( currentSheet, );
1477 wxString sheetName = currentSheet->
GetName();
1479 if( sheetName.IsEmpty() )
1480 sheetName = wxT(
"root" );
1488 m_errorMessages.emplace( wxString::Format(
_(
"Symbol \"%s\" in sheet \"%s\" at index %d "
1489 "replaced with symbol \"%s\"." ),
1501 wxString
name = wxString::Format(
"%s_%d%s_%s_%s",
1527 field.SetVisible(
false );
1552 screen->
Append( symbol );
1561 wxCHECK( currentSheet, );
1563 wxString sheetName = currentSheet->
GetName();
1565 if( sheetName.IsEmpty() )
1566 sheetName = wxT(
"root" );
1571 wxString baseName = altiumTemplate.
filename.AfterLast(
'\\' ).BeforeLast(
'.' );
1573 if( baseName.IsEmpty() )
1574 baseName = wxS(
"Template" );
1582 std::vector<LIB_SYMBOL*>& aSymbol )
1598 m_errorMessages.emplace( wxString::Format( wxT(
"Pin's owner (%d) not found." ),
1607 schSymbol =
m_symbols.at( libSymbolIt->first );
1608 symbol = libSymbolIt->second;
1627 pin->SetVisible(
false );
1630 pin->SetNumberTextSize( 0 );
1633 pin->SetNameTextSize( 0 );
1639 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
1640 pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
1644 case ASCH_RECORD_ORIENTATION::UPWARDS:
1645 pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
1649 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
1650 pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
1654 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
1655 pin->SetOrientation( PIN_ORIENTATION::PIN_UP );
1669 pin->SetPosition( pinLocation );
1673 case ASCH_PIN_ELECTRICAL::INPUT:
1674 pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
1677 case ASCH_PIN_ELECTRICAL::BIDI:
1678 pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
1681 case ASCH_PIN_ELECTRICAL::OUTPUT:
1682 pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
1685 case ASCH_PIN_ELECTRICAL::OPEN_COLLECTOR:
1686 pin->SetType( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR );
1689 case ASCH_PIN_ELECTRICAL::PASSIVE:
1690 pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE );
1693 case ASCH_PIN_ELECTRICAL::TRISTATE:
1694 pin->SetType( ELECTRICAL_PINTYPE::PT_TRISTATE );
1697 case ASCH_PIN_ELECTRICAL::OPEN_EMITTER:
1698 pin->SetType( ELECTRICAL_PINTYPE::PT_OPENEMITTER );
1701 case ASCH_PIN_ELECTRICAL::POWER:
1702 pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
1705 case ASCH_PIN_ELECTRICAL::UNKNOWN:
1707 pin->SetType( ELECTRICAL_PINTYPE::PT_UNSPECIFIED );
1723 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
1727 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
1736 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK_LOW );
1740 pin->SetShape( GRAPHIC_PINSHAPE::INPUT_LOW );
1746 pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW );
1753 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
1757 pin->SetShape( GRAPHIC_PINSHAPE::LINE );
1767 int vjustify, hjustify;
1770 switch( justification )
1793 switch( justification )
1816 switch( orientation )
1839 text->SetTextAngle( angle );
1858 std::vector<LIB_SYMBOL*>& aSymbol, std::vector<int>& aFontSizes )
1864 static const std::map<wxString, wxString> variableMap = {
1865 {
"APPLICATION_BUILDNUMBER",
"KICAD_VERSION" },
1866 {
"SHEETNUMBER",
"#" },
1867 {
"SHEETTOTAL",
"##" },
1868 {
"TITLE",
"TITLE" },
1869 {
"REVISION",
"REVISION" },
1870 {
"DATE",
"ISSUE_DATE" },
1871 {
"CURRENTDATE",
"CURRENT_DATE" },
1872 {
"COMPANYNAME",
"COMPANY" },
1873 {
"DOCUMENTNAME",
"FILENAME" },
1874 {
"DOCUMENTFULLPATHANDNAME",
"FILEPATH" },
1875 {
"PROJECTNAME",
"PROJECTNAME" },
1883 size_t fontId =
static_cast<int>( elem.
fontId );
1900 screen->
Append( textItem );
1916 m_errorMessages.emplace( wxString::Format( wxT(
"Label's owner (%d) not found." ),
1922 symbol = libSymbolIt->second;
1923 schsym =
m_symbols.at( libSymbolIt->first );
1938 size_t fontId = elem.
fontId;
1949 else if( fontId > 0 && fontId <= aFontSizes.size() )
1951 int size = aFontSizes[fontId - 1];
1959 std::vector<LIB_SYMBOL*>& aSymbol,
1960 std::vector<int>& aFontSizes )
1987 textBox->
SetStart( sheetTopRight );
1988 textBox->
SetEnd( sheetBottomLeft );
1995 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
2009 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
2012 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
2015 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
2020 size_t fontId =
static_cast<int>( aElem->
FontID );
2038 screen->
Append( textBox );
2043 std::vector<int>& aFontSizes )
2058 wxString::Format( wxT(
"Label's owner (%d) not found." ), aElem->
ownerindex ),
2063 symbol = libSymbolIt->second;
2064 schsym =
m_symbols.at( libSymbolIt->first );
2089 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
2102 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
2105 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
2108 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
2113 if( aElem->
FontID > 0 && aElem->
FontID <=
static_cast<int>( aFontSizes.size() ) )
2115 int size = aFontSizes[aElem->
FontID - 1];
2122 std::vector<LIB_SYMBOL*>& aSymbol )
2126 if( elem.
points.size() < 2 )
2128 m_errorMessages.emplace( wxString::Format(
_(
"Bezier has %d control points. At least 2 are "
2130 static_cast<int>( elem.
points.size() ) ),
2138 wxCHECK( currentScreen, );
2140 for(
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
2142 if( i + 2 == elem.
points.size() )
2146 SCH_LAYER_ID::LAYER_NOTES );
2153 currentScreen->
Append( line );
2158 std::vector<VECTOR2I> bezierPoints;
2159 std::vector<VECTOR2I> polyPoints;
2161 for(
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
2162 bezierPoints.push_back( elem.
points.at( j ) );
2165 converter.
GetPoly( polyPoints );
2167 for(
size_t k = 0; k + 1 < polyPoints.size(); k++ )
2170 SCH_LAYER_ID::LAYER_NOTES );
2176 currentScreen->
Append( line );
2195 m_errorMessages.emplace( wxString::Format( wxT(
"Bezier's owner (%d) not found." ),
2201 symbol = libSymbolIt->second;
2202 schsym =
m_symbols.at( libSymbolIt->first );
2208 for(
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
2210 if( i + 2 == elem.
points.size() )
2218 for(
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
2230 else if( i + 3 == elem.
points.size() )
2241 for(
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
2261 for(
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
2270 case 0: bezier->
SetStart( pos );
break;
2273 case 3: bezier->
SetEnd( pos );
break;
2287 std::vector<LIB_SYMBOL*>& aSymbol )
2291 if( elem.
Points.size() < 2 )
2299 for(
size_t i = 1; i < elem.
Points.size(); i++ )
2328 m_errorMessages.emplace( wxString::Format( wxT(
"Polyline's owner (%d) not found." ),
2334 symbol = libSymbolIt->second;
2335 schsym =
m_symbols.at( libSymbolIt->first );
2364 std::vector<LIB_SYMBOL*>& aSymbol )
2399 m_errorMessages.emplace( wxString::Format( wxT(
"Polygon's owner (%d) not found." ),
2405 symbol = libSymbolIt->second;
2406 schsym =
m_symbols.at( libSymbolIt->first );
2447 std::vector<LIB_SYMBOL*>& aSymbol )
2481 m_errorMessages.emplace( wxString::Format( wxT(
"Rounded rectangle's owner (%d) not "
2488 symbol = libSymbolIt->second;
2489 schsym =
m_symbols.at( libSymbolIt->first );
2507 int radius = std::min( width / 2, height / 2 );
2543 std::vector<LIB_SYMBOL*>& aSymbol )
2559 wxCHECK( currentScreen, );
2584 currentScreen->
Append( arc );
2601 m_errorMessages.emplace( wxString::Format( wxT(
"Arc's owner (%d) not found." ),
2607 symbol = libSymbolIt->second;
2608 schsym =
m_symbols.at( libSymbolIt->first );
2651 std::vector<LIB_SYMBOL*>& aSymbol )
2665 wxCHECK( currentScreen, );
2671 std::vector<BEZIER<int>> beziers;
2678 schbezier->
SetStart( bezier.Start );
2681 schbezier->
SetEnd( bezier.End );
2685 currentScreen->
Append( schbezier );
2702 m_errorMessages.emplace( wxString::Format( wxT(
"Elliptical Arc's owner (%d) not found." ),
2708 symbol = libSymbolIt->second;
2709 schsym =
m_symbols.at( libSymbolIt->first );
2719 std::vector<BEZIER<int>> beziers;
2739 schbezier->
SetStart( bezier.Start );
2742 schbezier->
SetEnd( bezier.End );
2745 SetLibShapeLine( elem, schbezier, ALTIUM_SCH_RECORD::ELLIPTICAL_ARC );
2753 std::vector<LIB_SYMBOL*>& aSymbol )
2802 m_errorMessages.emplace( wxString::Format( wxT(
"Piechart's owner (%d) not found." ),
2808 symbol = libSymbolIt->second;
2809 schsym =
m_symbols.at( libSymbolIt->first );
2839 std::vector<LIB_SYMBOL*>& aSymbol )
2859 FILL_T fillMode = elem.
IsSolid ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
2864 std::vector<BEZIER<int>> beziers;
2865 std::vector<VECTOR2I> polyPoints;
2872 schbezier->
SetStart( bezier.Start );
2875 schbezier->
SetEnd( bezier.End );
2881 screen->
Append( schbezier );
2883 polyPoints.push_back( bezier.Start );
2886 if( fillMode != FILL_T::NO_FILL )
2893 for(
const VECTOR2I& point : polyPoints )
2896 schpoly->
AddPoint( polyPoints[0] );
2898 screen->
Append( schpoly );
2915 m_errorMessages.emplace( wxString::Format( wxT(
"Ellipse's owner (%d) not found." ),
2921 symbol = libSymbolIt->second;
2922 schsym =
m_symbols.at( libSymbolIt->first );
2928 std::vector<BEZIER<int>> beziers;
2929 std::vector<VECTOR2I> polyPoints;
2941 libbezier->
SetStart( bezier.Start );
2944 libbezier->
SetEnd( bezier.End );
2958 polyPoints.push_back( libbezier->
GetStart() );
2969 for(
const VECTOR2I& point : polyPoints )
2972 libline->
AddPoint( polyPoints[0] );
2982 std::vector<LIB_SYMBOL*>& aSymbol )
3000 circle->SetFillMode( FILL_T::FILLED_WITH_COLOR );
3002 circle->SetFilled(
false );
3020 m_errorMessages.emplace( wxString::Format( wxT(
"Ellipse's owner (%d) not found." ),
3026 symbol = libSymbolIt->second;
3027 schsym =
m_symbols.at( libSymbolIt->first );
3049 std::vector<LIB_SYMBOL*>& aSymbol )
3082 m_errorMessages.emplace( wxString::Format( wxT(
"Line's owner (%d) not found." ),
3088 symbol = libSymbolIt->second;
3089 schsym =
m_symbols.at( libSymbolIt->first );
3126 for(
size_t ii = 0; ii < elem.
points.size() - 1; ii++ )
3129 SCH_LAYER_ID::LAYER_BUS );
3141 m_errorMessages.emplace( wxT(
"Signal harness, belonging to the part is not currently "
3148 wxString>& aProperties )
3157 HARNESS& harness = it->second;
3168 case ASCH_SHEET_ENTRY_SIDE::LEFT:
3171 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
3174 case ASCH_SHEET_ENTRY_SIDE::TOP:
3177 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
3185 m_errorMessages.emplace( wxT(
"Harness connector, belonging to the part is not currently "
3200 m_errorMessages.emplace( wxString::Format( wxT(
"Harness entry's parent (%d) not found." ),
3206 HARNESS& harness = harnessIt->second;
3219 case ASCH_SHEET_ENTRY_SIDE::LEFT:
3222 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
3226 case ASCH_SHEET_ENTRY_SIDE::TOP:
3229 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
3243 harness.
m_ports.emplace_back( port );
3255 m_errorMessages.emplace( wxString::Format( wxT(
"Harness type's parent (%d) not found." ),
3261 HARNESS& harness = harnessIt->second;
3268 std::vector<LIB_SYMBOL*>& aSymbol )
3283 rect->
SetEnd( sheetBottomLeft );
3304 m_errorMessages.emplace( wxString::Format( wxT(
"Rectangle's owner (%d) not found." ),
3310 symbol = libSymbolIt->second;
3311 schsym =
m_symbols.at( libSymbolIt->first );
3325 rect->
SetEnd( sheetBottomLeft );
3353 wxCHECK( currentScreen, );
3354 currentScreen->
Append( sheet );
3363 wxCHECK( rootScreen, );
3371 m_sheets.insert( { aIndex, sheet } );
3383 m_errorMessages.emplace( wxString::Format( wxT(
"Sheet entry's owner (%d) not found." ),
3390 sheetIt->second->AddPin( sheetPin );
3393 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
3397 VECTOR2I pos = sheetIt->second->GetPosition();
3398 VECTOR2I size = sheetIt->second->GetSize();
3403 case ASCH_SHEET_ENTRY_SIDE::LEFT:
3406 sheetPin->
SetSide( SHEET_SIDE::LEFT );
3409 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
3412 sheetPin->
SetSide( SHEET_SIDE::RIGHT );
3415 case ASCH_SHEET_ENTRY_SIDE::TOP:
3418 sheetPin->
SetSide( SHEET_SIDE::TOP );
3421 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
3424 sheetPin->
SetSide( SHEET_SIDE::BOTTOM );
3431 case ASCH_PORT_IOTYPE::UNSPECIFIED:
3432 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
3435 case ASCH_PORT_IOTYPE::OUTPUT:
3436 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
3439 case ASCH_PORT_IOTYPE::INPUT:
3440 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_INPUT );
3443 case ASCH_PORT_IOTYPE::BIDI:
3444 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_BIDI );
3635 aReporter->
Report(
_(
"Power Port with unknown style imported as 'Bar' type." ),
3660 wxString symName( elem.
text );
3661 std::string styleName( magic_enum::enum_name<ASCH_POWER_PORT_STYLE>( elem.
style ) );
3663 if( !styleName.empty() )
3664 symName <<
'_' << styleName;
3673 libSymbol = powerSymbolIt->second;
3678 libSymbol = alreadyLoaded;
3689 libSymbol->
SetDescription( wxString::Format(
_(
"Power symbol creates a global "
3690 "label with name '%s'" ), elem.
text ) );
3699 pin->SetPosition( { 0, 0 } );
3700 pin->SetLength( 0 );
3701 pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
3702 pin->SetVisible(
false );
3735 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
3741 case ASCH_RECORD_ORIENTATION::UPWARDS:
3747 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
3753 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
3764 screen->
Append( symbol );
3792 switch( aElem.
Style )
3795 case ASCH_PORT_STYLE::NONE_HORIZONTAL:
3796 case ASCH_PORT_STYLE::LEFT:
3797 case ASCH_PORT_STYLE::RIGHT:
3798 case ASCH_PORT_STYLE::LEFT_RIGHT:
3802 case ASCH_PORT_STYLE::NONE_VERTICAL:
3803 case ASCH_PORT_STYLE::TOP:
3804 case ASCH_PORT_STYLE::BOTTOM:
3805 case ASCH_PORT_STYLE::TOP_BOTTOM:
3822 bool connectionFound = startIsWireTerminal
3823 || startIsBusTerminal
3824 || endIsWireTerminal
3825 || endIsBusTerminal;
3827 if( !connectionFound )
3831 if( harness.m_name.CmpNoCase( aElem.
HarnessType ) != 0 )
3834 BOX2I bbox( harness.m_location, harness.m_size );
3839 startIsBusTerminal =
true;
3840 connectionFound =
true;
3846 endIsBusTerminal =
true;
3847 connectionFound =
true;
3852 if( !connectionFound )
3860 VECTOR2I position = ( startIsWireTerminal || startIsBusTerminal ) ? start :
end;
3878 case ASCH_PORT_IOTYPE::UNSPECIFIED: label->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
break;
3879 case ASCH_PORT_IOTYPE::OUTPUT: label->
SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
break;
3880 case ASCH_PORT_IOTYPE::INPUT: label->
SetShape( LABEL_FLAG_SHAPE::L_INPUT );
break;
3881 case ASCH_PORT_IOTYPE::BIDI: label->
SetShape( LABEL_FLAG_SHAPE::L_BIDI );
break;
3884 switch( aElem.
Style )
3887 case ASCH_PORT_STYLE::NONE_HORIZONTAL:
3888 case ASCH_PORT_STYLE::LEFT:
3889 case ASCH_PORT_STYLE::RIGHT:
3890 case ASCH_PORT_STYLE::LEFT_RIGHT:
3891 if( ( startIsWireTerminal || startIsBusTerminal ) )
3898 case ASCH_PORT_STYLE::NONE_VERTICAL:
3899 case ASCH_PORT_STYLE::TOP:
3900 case ASCH_PORT_STYLE::BOTTOM:
3901 case ASCH_PORT_STYLE::TOP_BOTTOM:
3902 if( ( startIsWireTerminal || startIsBusTerminal ) )
3916 if( ( startIsWireTerminal && endIsWireTerminal ) )
3924 else if( startIsBusTerminal && endIsBusTerminal )
3947 screen->
Append( noConnect );
3975 for(
size_t i = 0; i + 1 < elem.
points.size(); i++ )
3978 SCH_LAYER_ID::LAYER_BUS );
3995 for(
size_t i = 0; i + 1 < elem.
points.size(); i++ )
3998 SCH_LAYER_ID::LAYER_WIRE );
4018 screen->
Append( junction );
4030 && component->second.currentpartid != elem.
ownerpartid )
4034 std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>(
center );
4046 wxString msg = wxString::Format(
_(
"Embedded file %s not found in storage." ),
4052 wxString storagePath = wxFileName::CreateTempFileName(
"kicad_import_" );
4055 wxMemoryInputStream fileStream( storageFile->
data.data(), storageFile->
data.size() );
4056 wxZlibInputStream zlibInputStream( fileStream );
4057 wxFFileOutputStream outputStream( storagePath );
4058 outputStream.Write( zlibInputStream );
4059 outputStream.Close();
4063 m_errorMessages.emplace( wxString::Format(
_(
"Error reading image %s." ), storagePath ),
4069 wxRemoveFile( storagePath );
4073 if( !wxFileExists( elem.
filename ) )
4083 wxString::Format(
_(
"Error reading image %s." ), elem.
filename ),
4092 const double scaleX =
4093 std::abs(
static_cast<double>( expectedImageSize.
x ) / currentImageSize.
x );
4094 const double scaleY =
4095 std::abs(
static_cast<double>( expectedImageSize.
y ) / currentImageSize.
y );
4098 bitmap->SetFlags(
IS_NEW );
4099 screen->
Append( bitmap.release() );
4105 m_altiumSheet = std::make_unique<ASCH_SHEET>( aProperties );
4112 bool isPortrait =
m_altiumSheet->sheetOrientation == ASCH_SHEET_WORKSPACEORIENTATION::PORTRAIT;
4125 case ASCH_SHEET_SIZE::A4: pageInfo.
SetType(
"A4", isPortrait );
break;
4126 case ASCH_SHEET_SIZE::A3: pageInfo.
SetType(
"A3", isPortrait );
break;
4127 case ASCH_SHEET_SIZE::A2: pageInfo.
SetType(
"A2", isPortrait );
break;
4128 case ASCH_SHEET_SIZE::A1: pageInfo.
SetType(
"A1", isPortrait );
break;
4129 case ASCH_SHEET_SIZE::A0: pageInfo.
SetType(
"A0", isPortrait );
break;
4130 case ASCH_SHEET_SIZE::A: pageInfo.
SetType(
"A", isPortrait );
break;
4131 case ASCH_SHEET_SIZE::B: pageInfo.
SetType(
"B", isPortrait );
break;
4132 case ASCH_SHEET_SIZE::C: pageInfo.
SetType(
"C", isPortrait );
break;
4133 case ASCH_SHEET_SIZE::D: pageInfo.
SetType(
"D", isPortrait );
break;
4134 case ASCH_SHEET_SIZE::E: pageInfo.
SetType(
"E", isPortrait );
break;
4135 case ASCH_SHEET_SIZE::LETTER: pageInfo.
SetType(
"USLetter", isPortrait );
break;
4136 case ASCH_SHEET_SIZE::LEGAL: pageInfo.
SetType(
"USLegal", isPortrait );
break;
4137 case ASCH_SHEET_SIZE::TABLOID: pageInfo.
SetType(
"A3", isPortrait );
break;
4138 case ASCH_SHEET_SIZE::ORCAD_A: pageInfo.
SetType(
"A", isPortrait );
break;
4139 case ASCH_SHEET_SIZE::ORCAD_B: pageInfo.
SetType(
"B", isPortrait );
break;
4140 case ASCH_SHEET_SIZE::ORCAD_C: pageInfo.
SetType(
"C", isPortrait );
break;
4141 case ASCH_SHEET_SIZE::ORCAD_D: pageInfo.
SetType(
"D", isPortrait );
break;
4142 case ASCH_SHEET_SIZE::ORCAD_E: pageInfo.
SetType(
"E", isPortrait );
break;
4157 wxCHECK( currentScreen, );
4163 m_errorMessages.emplace( wxString::Format( wxT(
"Sheetname's owner (%d) not found." ),
4168 wxString sheetName = elem.
text;
4169 std::set<wxString> sheetNames;
4174 sheetNames.insert( sheet->
GetName() );
4177 for(
int ii = 1; ; ++ii )
4179 if( sheetNames.find( sheetName ) == sheetNames.end() )
4182 sheetName = elem.
text + wxString::Format( wxT(
"_%d" ), ii );
4185 SCH_FIELD* sheetNameField = sheetIt->second->GetField( FIELD_T::SHEET_NAME );
4188 sheetNameField->
SetText( sheetName );
4202 m_errorMessages.emplace( wxString::Format( wxT(
"Filename's owner (%d) not found." ),
4208 SCH_FIELD* filenameField = sheetIt->second->GetField( FIELD_T::SHEET_FILENAME );
4228 m_errorMessages.emplace( wxString::Format( wxT(
"Designator's owner (%d) not found." ),
4242 bool emptyRef = elem.
text.IsEmpty();
4247 bool visible = !emptyRef;
4259 std::vector<LIB_SYMBOL*>& aSymbol,
4260 std::vector<int>& aFontSizes )
4267 bool emptyRef = elem.
text.IsEmpty();
4268 SCH_FIELD& refField = symbol->GetReferenceField();
4271 refField.
SetText( wxT(
"X" ) );
4277 if( elem.
fontId > 0 && elem.
fontId <=
static_cast<int>( aFontSizes.size() ) )
4279 int size = aFontSizes[elem.
fontId - 1];
4296 busWireEntry->
SetSize( { vector.
x, vector.
y } );
4299 screen->
Append( busWireEntry );
4308 static const std::map<wxString, wxString> variableMap = {
4309 {
"COMMENT",
"VALUE" },
4310 {
"VALUE",
"ALTIUM_VALUE" },
4316 if( elem.
text ==
"*" )
4319 wxString paramName = elem.
name.Upper();
4321 if( paramName ==
"SHEETNUMBER" )
4325 else if( paramName ==
"TITLE" )
4329 else if( paramName ==
"REVISION" )
4333 else if( paramName ==
"DATE" )
4337 else if( paramName ==
"COMPANYNAME" )
4358 wxString upperName = elem.
name.Upper();
4360 if( upperName ==
"COMMENT" )
4362 field = symbol->
GetField( FIELD_T::VALUE );
4366 wxString fieldName = elem.
name.Upper();
4368 if( fieldName.IsEmpty() )
4370 int disambiguate = 1;
4374 fieldName = wxString::Format(
"ALTIUM_UNNAMED_%d", disambiguate++ );
4376 if( !symbol->
GetField( fieldName ) )
4380 else if( fieldName ==
"VALUE" )
4382 fieldName =
"ALTIUM_VALUE";
4385 field = symbol->
AddField(
SCH_FIELD( { 0, 0 }, FIELD_T::USER, symbol, fieldName ) );
4398 std::vector<LIB_SYMBOL*>& aSymbol,
4399 std::vector<int>& aFontSizes )
4420 std::map<wxString, wxString> variableMap = {
4421 {
"COMMENT",
"VALUE" },
4427 wxString upperName = elem.
name.Upper();
4429 if( upperName ==
"COMMENT" )
4431 field = &libSymbol->GetValueField();
4435 wxString fieldNameStem = elem.
name;
4436 wxString fieldName = fieldNameStem;
4437 int disambiguate = 1;
4439 if( fieldName.IsEmpty() )
4441 fieldNameStem =
"ALTIUM_UNNAMED";
4442 fieldName =
"ALTIUM_UNNAMED_1";
4445 else if( upperName ==
"VALUE" )
4447 fieldNameStem =
"ALTIUM_VALUE";
4448 fieldName =
"ALTIUM_VALUE";
4452 while( libSymbol->GetField( fieldName ) )
4453 fieldName = wxString::Format(
"%s_%d", fieldNameStem, disambiguate++ );
4456 libSymbol->AddField( new_field );
4467 if( elem.
fontId > 0 && elem.
fontId <=
static_cast<int>( aFontSizes.size() ) )
4469 int size = aFontSizes[elem.
fontId - 1];
4483 const std::map<wxString, wxString>& aProperties )
4492 std::vector<LIB_SYMBOL*>& aSymbol )
4496 if( elem.
type != wxS(
"PCBLIB" ) )
4500 if( aSymbol.size() == 0 && !elem.
isCurrent )
4506 wxArrayString fpFilters;
4507 fpFilters.Add( wxString::Format( wxS(
"*%s*" ), elem.
name ) );
4510 if( !aSymbol.empty() )
4516 symbol->SetFPFilters( fpFilters );
4517 symbol->GetField( FIELD_T::FOOTPRINT )->SetText( fpLibId.
Format() );
4527 m_errorMessages.emplace( wxString::Format( wxT(
"Implementation's owner (%d) not found." ),
4533 const auto& libSymbolIt =
m_libSymbols.find( implementationOwnerIt->second );
4537 m_errorMessages.emplace( wxString::Format( wxT(
"Footprint's owner (%d) not found." ),
4538 implementationOwnerIt->second ),
4545 libSymbolIt->second->SetFPFilters( fpFilters );
4555 wxString>& aProperties )
4559 std::vector<LIB_SYMBOL*> symbols;
4577 symbols.push_back( symbol );
4588 std::vector<int> fontSizes;
4589 struct SYMBOL_PIN_FRAC
4598 std::map<wxString, ALTIUM_SYMBOL_DATA> syms = aAltiumLibFile.
GetLibSymbols(
nullptr );
4600 for(
auto& [
name, entry] : syms )
4603 std::map<int, SYMBOL_PIN_FRAC> pinFracs;
4605 if( entry.m_pinsFrac )
4607 auto parse_binary_pin_frac =
4608 [&](
const std::string& binaryData ) -> std::map<wxString, wxString>
4610 std::map<wxString, wxString> result;
4616 SYMBOL_PIN_FRAC pinFrac;
4620 pinFrac.len_frac = binreader.
ReadInt32();
4621 pinFracs.insert( { pinFracData.first, pinFrac } );
4635 std::vector<LIB_SYMBOL*> symbols;
4644 std::map<wxString, wxString> properties = reader.
ReadProperties();
4648 if( record != ALTIUM_SCH_RECORD::COMPONENT )
4649 THROW_IO_ERROR(
"LibSymbol does not start with COMPONENT record" );
4654 auto handleBinaryPinLambda =
4655 [&](
const std::string& binaryData ) -> std::map<wxString, wxString>
4657 std::map<wxString, wxString> result;
4661 int32_t recordId = binreader.
ReadInt32();
4663 if( recordId !=
static_cast<int32_t
>( ALTIUM_SCH_RECORD::PIN ) )
4666 result[
"RECORD"] = wxString::Format(
"%d", recordId );
4668 result[
"OWNERPARTID"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4669 result[
"OWNERPARTDISPLAYMODE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4670 result[
"SYMBOL_INNEREDGE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4671 result[
"SYMBOL_OUTEREDGE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4672 result[
"SYMBOL_INNER"] = wxString::Format(
"%d", binreader.
ReadByte() );
4673 result[
"SYMBOL_OUTER"] = wxString::Format(
"%d", binreader.
ReadByte() );
4676 result[
"ELECTRICAL"] = wxString::Format(
"%d", binreader.
ReadByte() );
4677 result[
"PINCONGLOMERATE"] = wxString::Format(
"%d", binreader.
ReadByte() );
4678 result[
"PINLENGTH"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4679 result[
"LOCATION.X"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4680 result[
"LOCATION.Y"] = wxString::Format(
"%d", binreader.
ReadInt16() );
4681 result[
"COLOR"] = wxString::Format(
"%d", binreader.
ReadInt32() );
4687 if(
auto it = pinFracs.find( pin_index ); it != pinFracs.end() )
4689 result[
"LOCATION.X_FRAC"] = wxString::Format(
"%d", it->second.x_frac );
4690 result[
"LOCATION.Y_FRAC"] = wxString::Format(
"%d", it->second.y_frac );
4691 result[
"PINLENGTH_FRAC"] = wxString::Format(
"%d", it->second.len_frac );
4695 std::vector<std::string> partSeqSplit =
split( partSeq,
"|" );
4697 if( partSeqSplit.size() == 3 )
4699 result[
"PART"] = partSeqSplit[0];
4700 result[
"SEQ"] = partSeqSplit[2];
4708 std::map<wxString, wxString> properties = reader.
ReadProperties( handleBinaryPinLambda );
4710 if( properties.empty() )
4718 case ALTIUM_SCH_RECORD::PIN:
4725 case ALTIUM_SCH_RECORD::LABEL:
ParseLabel( properties, symbols, fontSizes );
break;
4727 case ALTIUM_SCH_RECORD::BEZIER:
ParseBezier( properties, symbols );
break;
4729 case ALTIUM_SCH_RECORD::POLYLINE:
ParsePolyline( properties, symbols );
break;
4731 case ALTIUM_SCH_RECORD::POLYGON:
ParsePolygon( properties, symbols );
break;
4733 case ALTIUM_SCH_RECORD::ELLIPSE:
ParseEllipse( properties, symbols );
break;
4735 case ALTIUM_SCH_RECORD::PIECHART:
ParsePieChart( properties, symbols );
break;
4737 case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
ParseRoundRectangle( properties, symbols );
break;
4739 case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
ParseEllipticalArc( properties, symbols );
break;
4741 case ALTIUM_SCH_RECORD::ARC:
ParseArc( properties, symbols );
break;
4743 case ALTIUM_SCH_RECORD::LINE:
ParseLine( properties, symbols );
break;
4745 case ALTIUM_SCH_RECORD::RECTANGLE:
ParseRectangle( properties, symbols );
break;
4747 case ALTIUM_SCH_RECORD::DESIGNATOR:
ParseLibDesignator( properties, symbols, fontSizes );
break;
4749 case ALTIUM_SCH_RECORD::PARAMETER:
ParseLibParameter( properties, symbols, fontSizes );
break;
4751 case ALTIUM_SCH_RECORD::TEXT_FRAME:
ParseTextFrame( properties, symbols, fontSizes );
break;
4754 case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
break;
4756 case ALTIUM_SCH_RECORD::IMPLEMENTATION:
ParseImplementation( properties, symbols );
break;
4758 case ALTIUM_SCH_RECORD::IMPL_PARAMS:
break;
4760 case ALTIUM_SCH_RECORD::MAP_DEFINER_LIST:
break;
4761 case ALTIUM_SCH_RECORD::MAP_DEFINER:
break;
4764 case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
break;
4767 case ALTIUM_SCH_RECORD::IMAGE:
break;
4770 m_errorMessages.emplace( wxString::Format(
_(
"Unknown or unexpected record id %d found "
4772 recordId, symbols[0]->
GetName() ),
4784 for(
size_t ii = 0; ii < symbols.size(); ii++ )
4792 if( valField.
GetText().IsEmpty() )
4795 if( symbols.size() == 1 )
4798 ret[wxString::Format(
"%s (Altium Display %zd)",
name, ii + 1 )] = symbol;
4808 wxFileName fn( aLibraryPath );
4810 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
4811 return fn.GetModificationTime().GetValue().GetValue();
4813 return wxDateTime( 0.0 ).GetValue().GetValue();
4818 const std::map<std::string, UTF8>* aProperties )
4831 std::vector<std::unique_ptr<ALTIUM_COMPOUND_FILE>> compoundFiles;
4833 wxFileName fileName( aLibraryPath );
4838 if( aLibraryPath.Lower().EndsWith( wxS(
".schlib" ) ) )
4842 compoundFiles.push_back( std::make_unique<ALTIUM_COMPOUND_FILE>( aLibraryPath ) );
4844 else if( aLibraryPath.Lower().EndsWith( wxS(
".intlib" ) ) )
4848 std::unique_ptr<ALTIUM_COMPOUND_FILE> intCom =
4849 std::make_unique<ALTIUM_COMPOUND_FILE>( aLibraryPath );
4851 std::map<wxString, const CFB::COMPOUND_FILE_ENTRY*> schLibFiles =
4852 intCom->EnumDir( L
"SchLib" );
4854 for(
const auto& [schLibName, cfe] : schLibFiles )
4856 auto decodedStream = std::make_unique<ALTIUM_COMPOUND_FILE>();
4858 if( intCom->DecodeIntLibStream( *cfe, decodedStream.get() ) )
4859 compoundFiles.emplace_back( std::move( decodedStream ) );
4865 for(
auto& altiumSchFilePtr : compoundFiles )
4868 cacheMapRef.insert( parsed.begin(), parsed.end() );
4873 catch(
const CFB::CFBException& exception )
4877 catch(
const std::exception& exc )
4879 wxFAIL_MSG( wxString::Format( wxT(
"Unhandled exception in Altium schematic parsers: %s." ),
4887 std::vector<int>& aFontSizes )
4889 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"FileHeader" } );
4891 if( file ==
nullptr )
4901 std::map<wxString, wxString> properties = reader.
ReadProperties();
4905 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Library Editor Binary File Version 5.0" ) )
4906 THROW_IO_ERROR(
_(
"Expected Altium Schematic Library file version 5.0" ) );
4908 for(
auto& [key, value] : properties )
4910 wxString upperKey = key.Upper();
4913 if( upperKey.StartsWith(
"SIZE", &remaining ) )
4915 if( !remaining.empty() )
4917 int ind = wxAtoi( remaining );
4919 if(
static_cast<int>( aFontSizes.size() ) < ind )
4920 aFontSizes.resize( ind );
4924 aFontSizes[ind - 1] = scaled;
4933 const std::map<std::string, UTF8>* aProperties,
4934 std::function<
void(
const wxString&,
LIB_SYMBOL*)> aInserter )
4938 bool powerSymbolsOnly = ( aProperties &&
4940 != aProperties->end() );
4946 for(
auto& [libnameStr, libSymbol] : it->second )
4948 if( powerSymbolsOnly && !libSymbol->IsPower() )
4951 aInserter( libnameStr, libSymbol );
4958 const wxString& aLibraryPath,
4959 const std::map<std::string, UTF8>* aProperties )
4964 aSymbolNameList.Add( aStr );
4970 const wxString& aLibraryPath,
4971 const std::map<std::string, UTF8>* aProperties )
4976 aSymbolList.emplace_back( aSymbol );
4982 const wxString& aAliasName,
4983 const std::map<std::string, UTF8>* aProperties )
4991 auto it2 = it->second.find( aAliasName );
4993 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, ValueType, DETAIL::CASE_INSENSITIVE_COMPARER > CASE_INSENSITIVE_MAP
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.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetCenter() const
constexpr bool Contains(const Vec &aPoint) const
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 SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
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 Overlapping(const BOX2I &aRect) const
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.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Define a library symbol object.
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
void FixupDrawItems()
This function finds the filled draw items that are covering up smaller draw items and replaces their ...
wxString GetName() const override
void SetDescription(const wxString &aDescription)
Gets the Description field text value */.
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
int GetUnitCount() const override
void SetLibId(const LIB_ID &aLibId)
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
virtual void SetName(const wxString &aName)
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
Describe the page size and margins of a paper page on which to eventually print or plot.
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
static void SetCustomWidthMils(double aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
static const wxChar Custom[]
"User" defined page type
static void SetCustomHeightMils(double aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
std::shared_ptr< NET_SETTINGS > & NetSettings()
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual void SetElem(PROJECT::ELEM aIndex, _ELEM *aElem)
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual PROJECT_FILE & GetProjectFile() const
virtual std::map< wxString, wxString > & GetTextVars() const
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
void SetImageScale(double aScale)
Set the image "zoom" value.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Holds all the data relating to one schematic.
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
void SetSize(const VECTOR2I &aSize)
VECTOR2I GetPosition() const override
Class for a wire to bus entry.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
void ParseFileHeader(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
void ParseSignalHarness(const std::map< wxString, wxString > &aProperties)
std::map< int, ASCH_TEMPLATE > m_altiumTemplates
std::map< int, ASCH_SYMBOL > m_altiumComponents
void ParsePort(const ASCH_PORT &aElem)
bool IsComponentPartVisible(const ASCH_OWNER_INTERFACE &aElem) const
void ParseNote(const std::map< wxString, wxString > &aProperties)
void ParseAltiumSch(const wxString &aFileName)
std::vector< ASCH_PORT > m_altiumPortsCurrentSheet
void ParseSheetName(const std::map< wxString, wxString > &aProperties)
void ParseBusEntry(const std::map< wxString, wxString > &aProperties)
SCH_SHEET * getCurrentSheet()
void ParseStorage(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
std::map< wxString, LIB_SYMBOL * > m_powerSymbols
void ParseBus(const std::map< wxString, wxString > &aProperties)
void ParseFileName(const std::map< wxString, wxString > &aProperties)
static bool isASCIIFile(const wxString &aFileName)
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
std::map< int, SCH_SHEET * > m_sheets
void ParseLibHeader(const ALTIUM_COMPOUND_FILE &aAltiumSchFile, std::vector< int > &aFontSizes)
void ParseHarnessPort(const ASCH_PORT &aElem)
void ParseRoundRectangle(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
int GetModifyHash() const override
Return the modification hash from the library cache.
void ParseLibDesignator(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
std::map< wxString, CASE_INSENSITIVE_MAP< LIB_SYMBOL * > > m_libCache
std::map< int, int > m_altiumImplementationList
void ParseTextFrame(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
void ParsePolygon(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void fixupSymbolPinNameNumbers(SYMBOL *aSymbol)
void ParseRecord(int index, std::map< wxString, wxString > &properties, const wxString &aSectionName)
std::vector< ASCH_PORT > m_altiumHarnessPortsCurrentSheet
void ParseDesignator(const std::map< wxString, wxString > &aProperties)
int m_harnessOwnerIndexOffset
void ParsePortHelper(const ASCH_PORT &aElem)
static bool checkFileHeader(const wxString &aFileName)
long long getLibraryTimestamp(const wxString &aLibraryPath) const
void ParseSheetEntry(const std::map< wxString, wxString > &aProperties)
IO_RELEASER< SCH_IO > m_pi
static bool isBinaryFile(const wxString &aFileName)
void ParseHarnessType(const std::map< wxString, wxString > &aProperties)
void ParseJunction(const std::map< wxString, wxString > &aProperties)
void ParseLibParameter(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
void ParseASCIISchematic(const wxString &aFileName)
void ParsePolyline(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::unique_ptr< ASCH_SHEET > m_altiumSheet
void ParseComponent(int aIndex, const std::map< wxString, wxString > &aProperties)
std::unique_ptr< TITLE_BLOCK > m_currentTitleBlock
SCH_SHEET * LoadSchematicProject(SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties)
void ParseImage(const std::map< wxString, wxString > &aProperties)
void ParseArc(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseNetLabel(const std::map< wxString, wxString > &aProperties)
void ParseNoERC(const std::map< wxString, wxString > &aProperties)
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
std::unordered_map< wxString, SEVERITY > m_errorMessages
void ParseImplementationList(int aIndex, const std::map< wxString, wxString > &aProperties)
std::vector< LIB_SYMBOL * > ParseLibComponent(const std::map< wxString, wxString > &aProperties)
void ParseSheet(const std::map< wxString, wxString > &aProperties)
void ParseParameter(const std::map< wxString, wxString > &aProperties)
bool ShouldPutItemOnSheet(int aOwnerindex)
void AddLibTextBox(const ASCH_TEXT_FRAME *aElem, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
void ParsePieChart(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::unique_ptr< std::map< std::string, UTF8 > > m_properties
void ParseEllipticalArc(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::map< int, HARNESS > m_altiumHarnesses
void ParseEllipse(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseWire(const std::map< wxString, wxString > &aProperties)
void ParseHarnessEntry(const std::map< wxString, wxString > &aProperties)
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
void ParseImplementation(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseTemplate(int aIndex, const std::map< wxString, wxString > &aProperties)
void ParseAdditional(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
void AddTextBox(const ASCH_TEXT_FRAME *aElem)
void ParsePowerPort(const std::map< wxString, wxString > &aProperties)
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
const ASCH_STORAGE_FILE * GetFileFromStorage(const wxString &aFilename) const
void ParseRectangle(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void doEnumerateSymbolLib(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties, std::function< void(const wxString &, LIB_SYMBOL *)> aInserter)
std::vector< ASCH_STORAGE_FILE > m_altiumStorage
SCH_SHEET_PATH m_sheetPath
void ParseLabel(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
CASE_INSENSITIVE_MAP< LIB_SYMBOL * > ParseLibFile(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
void ParseBezier(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseLine(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseCircle(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::map< int, SCH_SYMBOL * > m_symbols
void ParseSheetSymbol(int aIndex, const std::map< wxString, wxString > &aProperties)
std::map< wxString, long long > m_timestamps
wxFileName getLibFileName()
SCH_SCREEN * getCurrentScreen()
void ParsePin(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::map< int, LIB_SYMBOL * > m_libSymbols
void ParseHarnessConnector(int aIndex, const std::map< wxString, wxString > &aProperties)
void ensureLoadedLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties)
Base class that schematic file and library loading and saving plugins should derive from.
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetUnit(int aUnit)
void SetShape(LABEL_FLAG_SHAPE aShape)
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
bool IsWire() const
Return true if the line is a wire.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetLineColor(const COLOR4D &aColor)
void SetLineWidth(const int aSize)
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
SEG GetSeg() const
Get the geometric aspect of the wire as a SEG.
bool IsBus() const
Return true if the line is a bus.
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
COLOR4D GetLineColor() const
Return #COLOR4D::UNSPECIFIED if a custom color hasn't been set for this line.
void SetEndPoint(const VECTOR2I &aPosition)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
std::vector< SCH_SHEET_INSTANCE > m_sheetInstances
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Add a bus alias definition (and transfers ownership of the pointer).
void SetPageSettings(const PAGE_INFO &aPageSettings)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const KIID & GetUuid() const
bool IsTerminalPoint(const VECTOR2I &aPosition, int aLayer) const
Test if aPosition is a connection point on aLayer.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
void SetPosition(const VECTOR2I &aPos) override
void SetFilled(bool aFilled) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void AddPoint(const VECTOR2I &aPosition)
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
void SetPosition(const VECTOR2I &aPosition) override
void SetSide(SHEET_SIDE aEdge)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetBorderColor(KIGFX::COLOR4D aColor)
void SetFileName(const wxString &aFilename)
wxString GetFileName() const
Return the filename corresponding to this sheet.
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
void SetBackgroundColor(KIGFX::COLOR4D aColor)
void SetName(const wxString &aName)
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
SCH_SCREEN * GetScreen() const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
void SetLibId(const LIB_ID &aName)
void SetPosition(const VECTOR2I &aPosition) override
void SetValueFieldText(const wxString &aValue)
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void SetFootprintFieldText(const wxString &aFootprint)
VECTOR2I GetPosition() const override
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
Simple container to manage line stroke parameters.
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
KIGFX::COLOR4D GetColor() const
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
static const wxString GetSymbolLibTableFileName()
static const char * PropPowerSymsOnly
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
A base class for LIB_SYMBOL and SCH_SYMBOL.
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
const TRANSFORM & GetTransform() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
virtual std::vector< SCH_PIN * > GetPins() const =0
static REPORTER & GetInstance()
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
#define IS_NEW
New item, just created.
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
static const std::string KiCadSchematicFileExtension
static const std::string KiCadSymbolLibFileExtension
static const wxChar traceAltiumSch[]
Flag to enable Altium schematic debugging output.
#define THROW_IO_ERROR(msg)
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
bool fileStartsWithBinaryHeader(const wxString &aFilePath, const std::vector< uint8_t > &aHeader)
Check if a file starts with a defined binary header.
bool fileStartsWithPrefix(const wxString &aFilePath, const wxString &aPrefix, bool aIgnoreWhitespace)
Check if a file starts with a defined string.
const std::vector< uint8_t > COMPOUND_FILE_HEADER
const VECTOR2I & GetOtherEnd(const SEG &aSeg, const VECTOR2I &aPoint)
Get the end point of the segment that is not the given point.
bool signbit(T v)
Integral version of std::signbit that works all compilers.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static COLOR4D GetColorFromInt(int color)
static void SetLibShapeFillAndColor(const ASCH_FILL_INTERFACE &elem, SCH_SHAPE *shape, ALTIUM_SCH_RECORD aType, int aStrokeColor)
VECTOR2I HelperGeneratePowerPortGraphics(LIB_SYMBOL *aKsymbol, ASCH_POWER_PORT_STYLE aStyle, REPORTER *aReporter)
static void SetSchShapeLine(const ASCH_BORDER_INTERFACE &elem, SCH_SHAPE *shape)
static const VECTOR2I GetRelativePosition(const VECTOR2I &aPosition, const SCH_SYMBOL *aSymbol)
static void SetLibShapeLine(const ASCH_BORDER_INTERFACE &elem, SCH_SHAPE *shape, ALTIUM_SCH_RECORD aType)
static LINE_STYLE GetPlotDashType(const ASCH_POLYLINE_LINESTYLE linestyle)
static void SetSchShapeFillAndColor(const ASCH_FILL_INTERFACE &elem, SCH_SHAPE *shape)
void SetTextPositioning(EDA_TEXT *text, ASCH_LABEL_JUSTIFICATION justification, ASCH_RECORD_ORIENTATION orientation)
Utility functions for working with shapes.
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
LINE_STYLE
Dashed line types.
std::vector< VECTOR2I > points
std::vector< VECTOR2I > points
ASCH_LABEL_JUSTIFICATION justification
ASCH_RECORD_ORIENTATION orientation
ASCH_RECORD_ORIENTATION orientation
int m_primaryConnectionPosition
ASCH_SHEET_ENTRY_SIDE m_harnessConnectorSide
ASCH_SHEET_ENTRY_SIDE Side
ASCH_RECORD_ORIENTATION orientation
ASCH_LABEL_JUSTIFICATION justification
ASCH_POLYLINE_LINESTYLE LineStyle
ASCH_LABEL_JUSTIFICATION justification
ASCH_RECORD_ORIENTATION orientation
ASCH_RECORD_ORIENTATION orientation
ASCH_LABEL_JUSTIFICATION justification
ASCH_PIN_SYMBOL::PTYPE symbolOuterEdge
ASCH_PIN_ELECTRICAL electrical
ASCH_PIN_SYMBOL::PTYPE symbolInnerEdge
ASCH_RECORD_ORIENTATION orientation
std::vector< VECTOR2I > points
ASCH_POLYLINE_LINESTYLE LineStyle
std::vector< VECTOR2I > Points
ASCH_POWER_PORT_STYLE style
ASCH_RECORD_ORIENTATION orientation
ASCH_SHEET_ENTRY_SIDE side
ASCH_RECORD_ORIENTATION orientation
std::vector< VECTOR2I > points
wxString componentdescription
wxString sourcelibraryname
ASCH_TEXT_FRAME_ALIGNMENT Alignment
std::vector< VECTOR2I > points
constexpr int IUToMils(int iu) const
constexpr int MilsToIU(int mils) const
int m_primaryConnectionPosition
ASCH_SHEET_ENTRY_SIDE m_harnessConnectorSide
std::vector< HARNESS_PORT > m_ports
A simple container for sheet instance information.
@ INTERSHEET_REFS
Global label cross-reference page numbers.
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.