55#include <compoundfilereader.h>
61#include <wx/mstream.h>
63#include <wx/zstream.h>
64#include <wx/wfstream.h>
69#define HARNESS_PORT_COLOR_DEFAULT_BACKGROUND COLOR4D( 0.92941176470588238, \
70 0.94901960784313721, \
71 0.98431372549019602, 1.0 )
73#define HARNESS_PORT_COLOR_DEFAULT_OUTLINE COLOR4D( 0.56078431372549020, \
74 0.61960784313725492, \
75 0.78823529411764703, 1.0 )
94 int green = (
color & 0x00FF00 ) >> 8;
95 int blue = (
color & 0xFF0000 ) >> 16;
167 default_color =
COLOR4D( 0.5, 0, 0, 1.0 );
177 if(
color == default_color ||
color == alt_default_color )
203 else if( elem.
AreaColor == aStrokeColor )
209 else if( bgcolor.
WithAlpha( 1.0 ) == default_bgcolor )
240 for(
auto& [
name, symbol] : lib )
296 wxCHECK( !aFileName.IsEmpty() && aSchematic,
nullptr );
298 wxFileName fileName( aFileName );
303 std::unique_ptr<SCH_SHEET> deleter( aAppendToMe ?
nullptr :
m_rootSheet );
307 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
334 wxCHECK_MSG( libTable,
nullptr,
"Could not load symbol lib table." );
336 m_pi.
set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
344 wxString libTableUri =
"${KIPRJMOD}/" +
getLibFileName().GetFullName();
348 wxString(
"KiCad" ) ) );
357 libTable->
Format( &formatter, 0 );
368 wxCHECK( rootScreen,
nullptr );
406 wxFileName parentFileName = aFileName;
416 catch(
const CFB::CFBException& exception )
420 catch(
const std::exception& exc )
422 wxLogDebug( wxT(
"Unhandled exception in Altium schematic parsers: %s." ), exc.what() );
427 wxCHECK( currentScreen, );
435 wxCHECK2( sheet,
continue );
439 wxFileName loadAltiumFileName( parentFileName.GetPath(), sheet->
GetFileName() );
441 if( loadAltiumFileName.GetFullName().IsEmpty() || !loadAltiumFileName.IsFileReadable() )
445 msg.Printf(
_(
"The file name for sheet %s is undefined, this is probably an"
446 " Altium signal harness that got converted to a sheet." ),
464 sheet->
SetName( loadAltiumFileName.GetName() );
465 wxCHECK2( screen,
continue );
471 wxFileName projectFileName = loadAltiumFileName;
474 sheet->
SetFileName( projectFileName.GetFullName() );
475 screen->
SetFileName( projectFileName.GetFullPath() );
485 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"Storage" } );
487 if( file ==
nullptr )
492 std::map<wxString, wxString> properties = reader.
ReadProperties();
499 for(
int i = 0; i < weight; i++ )
512 "(%d bytes remaining)." ),
521 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"Additional" } );
523 if( file ==
nullptr )
535 std::map<wxString, wxString> properties = reader.
ReadProperties();
540 if( record != ALTIUM_SCH_RECORD::HEADER )
546 std::map<wxString, wxString> properties = reader.
ReadProperties();
554 case ALTIUM_SCH_RECORD::HARNESS_CONNECTOR:
558 case ALTIUM_SCH_RECORD::HARNESS_ENTRY:
562 case ALTIUM_SCH_RECORD::HARNESS_TYPE:
566 case ALTIUM_SCH_RECORD::SIGNAL_HARNESS:
570 case ALTIUM_SCH_RECORD::BLANKET:
575 m_reporter->
Report( wxString::Format(
_(
"Unknown or unexpected record ID %d found "
576 "inside \"Additional\" section." ),
597 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"FileHeader" } );
599 if( file ==
nullptr )
610 std::map<wxString, wxString> properties = reader.
ReadProperties();
615 if( record != ALTIUM_SCH_RECORD::HEADER )
628 std::map<wxString, wxString> properties = reader.
ReadProperties();
636 case ALTIUM_SCH_RECORD::HEADER:
639 case ALTIUM_SCH_RECORD::COMPONENT:
643 case ALTIUM_SCH_RECORD::PIN:
647 case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
652 case ALTIUM_SCH_RECORD::LABEL:
656 case ALTIUM_SCH_RECORD::BEZIER:
660 case ALTIUM_SCH_RECORD::POLYLINE:
664 case ALTIUM_SCH_RECORD::POLYGON:
668 case ALTIUM_SCH_RECORD::ELLIPSE:
672 case ALTIUM_SCH_RECORD::PIECHART:
677 case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
681 case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
682 case ALTIUM_SCH_RECORD::ARC:
686 case ALTIUM_SCH_RECORD::LINE:
690 case ALTIUM_SCH_RECORD::RECTANGLE:
694 case ALTIUM_SCH_RECORD::SHEET_SYMBOL:
698 case ALTIUM_SCH_RECORD::SHEET_ENTRY:
702 case ALTIUM_SCH_RECORD::POWER_PORT:
706 case ALTIUM_SCH_RECORD::PORT:
712 case ALTIUM_SCH_RECORD::NO_ERC:
716 case ALTIUM_SCH_RECORD::NET_LABEL:
720 case ALTIUM_SCH_RECORD::BUS:
724 case ALTIUM_SCH_RECORD::WIRE:
728 case ALTIUM_SCH_RECORD::TEXT_FRAME:
732 case ALTIUM_SCH_RECORD::JUNCTION:
736 case ALTIUM_SCH_RECORD::IMAGE:
740 case ALTIUM_SCH_RECORD::SHEET:
744 case ALTIUM_SCH_RECORD::SHEET_NAME:
748 case ALTIUM_SCH_RECORD::FILE_NAME:
752 case ALTIUM_SCH_RECORD::DESIGNATOR:
756 case ALTIUM_SCH_RECORD::BUS_ENTRY:
760 case ALTIUM_SCH_RECORD::TEMPLATE:
763 case ALTIUM_SCH_RECORD::PARAMETER:
767 case ALTIUM_SCH_RECORD::PARAMETER_SET:
771 case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
775 case ALTIUM_SCH_RECORD::IMPLEMENTATION:
779 case ALTIUM_SCH_RECORD::MAP_DEFINER_LIST:
782 case ALTIUM_SCH_RECORD::MAP_DEFINER:
785 case ALTIUM_SCH_RECORD::IMPL_PARAMS:
788 case ALTIUM_SCH_RECORD::NOTE:
792 case ALTIUM_SCH_RECORD::COMPILE_MASK:
796 case ALTIUM_SCH_RECORD::HYPERLINK:
800 m_reporter->
Report( wxString::Format(
_(
"Unknown or unexpected record id %d found "
801 "inside \"FileHeader\" section." ),
817 for( std::pair<const int, SCH_SYMBOL*>& symbol :
m_symbols )
827 symbol.second->SetLibSymbol( libSymbolIt->second );
862 return component->second.displaymode == aOwnerpartdisplaymode;
872 if( file.filename.IsSameAs( aFilename ) )
875 if( file.filename.EndsWith( aFilename ) )
876 nonExactMatch = &file;
879 return nonExactMatch;
884 const std::map<wxString, wxString>& aProperties )
887 wxCHECK( currentSheet, );
889 wxString sheetName = currentSheet->
GetName();
891 if( sheetName.IsEmpty() )
892 sheetName = wxT(
"root" );
900 m_reporter->
Report( wxString::Format(
_(
"Symbol \"%s\" in sheet \"%s\" at index %d "
901 "replaced with symbol \"%s\"." ),
913 wxString
name = wxString::Format(
"%s_%d%s_%s",
972 schSymbol =
m_symbols.at( libSymbolIt->first );
973 symbol = libSymbolIt->second;
992 pin->SetVisible(
false );
995 pin->SetNumberTextSize( 0 );
998 pin->SetNameTextSize( 0 );
1004 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
1005 pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
1009 case ASCH_RECORD_ORIENTATION::UPWARDS:
1010 pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
1014 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
1015 pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
1019 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
1020 pin->SetOrientation( PIN_ORIENTATION::PIN_UP );
1033 pin->SetPosition(
VECTOR2I( pinLocation.
x, -pinLocation.
y ) );
1037 case ASCH_PIN_ELECTRICAL::INPUT:
1038 pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
1041 case ASCH_PIN_ELECTRICAL::BIDI:
1042 pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
1045 case ASCH_PIN_ELECTRICAL::OUTPUT:
1046 pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
1049 case ASCH_PIN_ELECTRICAL::OPEN_COLLECTOR:
1050 pin->SetType( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR );
1053 case ASCH_PIN_ELECTRICAL::PASSIVE:
1054 pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE );
1057 case ASCH_PIN_ELECTRICAL::TRISTATE:
1058 pin->SetType( ELECTRICAL_PINTYPE::PT_TRISTATE );
1061 case ASCH_PIN_ELECTRICAL::OPEN_EMITTER:
1062 pin->SetType( ELECTRICAL_PINTYPE::PT_OPENEMITTER );
1065 case ASCH_PIN_ELECTRICAL::POWER:
1066 pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
1069 case ASCH_PIN_ELECTRICAL::UNKNOWN:
1071 pin->SetType( ELECTRICAL_PINTYPE::PT_UNSPECIFIED );
1087 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
1091 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
1100 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK_LOW );
1104 pin->SetShape( GRAPHIC_PINSHAPE::INPUT_LOW );
1110 pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW );
1117 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
1121 pin->SetShape( GRAPHIC_PINSHAPE::LINE );
1131 int vjustify, hjustify;
1134 switch( justification )
1157 switch( justification )
1180 switch( orientation )
1205 text->SetTextAngle( angle );
1215 std::map<wxString, wxString> variableMap = {
1216 {
"APPLICATION_BUILDNUMBER",
"KICAD_VERSION" },
1217 {
"SHEETNUMBER",
"#" },
1218 {
"SHEETTOTAL",
"##" },
1219 {
"TITLE",
"TITLE" },
1220 {
"REVISION",
"REVISION" },
1221 {
"DATE",
"ISSUE_DATE" },
1222 {
"CURRENTDATE",
"CURRENT_DATE" },
1223 {
"COMPANYNAME",
"COMPANY" },
1224 {
"DOCUMENTNAME",
"FILENAME" },
1225 {
"PROJECTNAME",
"PROJECTNAME" },
1233 size_t fontId =
static_cast<int>( elem.
fontId );
1248 screen->
Append( textItem );
1264 m_reporter->
Report( wxString::Format( wxT(
"Label's owner (%d) not found." ),
1270 symbol = libSymbolIt->second;
1271 schsym =
m_symbols.at( libSymbolIt->first );
1287 size_t fontId =
static_cast<int>( elem.
fontId );
1296 else if( fontId > 0 && fontId <= aFontSizes.size() )
1298 int size = aFontSizes[fontId - 1];
1332 textBox->
SetStart( sheetTopRight );
1333 textBox->
SetEnd( sheetBottomLeft );
1340 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
1354 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
1357 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
1360 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
1367 size_t fontId =
static_cast<int>( aElem->
FontID );
1384 screen->
Append( textBox );
1403 wxString::Format( wxT(
"Label's owner (%d) not found." ), aElem->
ownerindex ),
1408 symbol = libSymbolIt->second;
1409 schsym =
m_symbols.at( libSymbolIt->first );
1435 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
1448 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
1451 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
1454 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
1459 if( aElem->
FontID > 0 && aElem->
FontID <=
static_cast<int>( aFontSizes.size() ) )
1461 int size = aFontSizes[aElem->
FontID - 1];
1468 std::vector<LIB_SYMBOL*>& aSymbol )
1472 if( elem.
points.size() < 2 )
1474 m_reporter->
Report( wxString::Format(
_(
"Bezier has %d control points. At least 2 are "
1476 static_cast<int>( elem.
points.size() ) ),
1484 wxCHECK( currentScreen, );
1486 for(
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
1488 if( i + 2 == elem.
points.size() )
1492 SCH_LAYER_ID::LAYER_NOTES );
1499 currentScreen->
Append( line );
1504 std::vector<VECTOR2I> bezierPoints;
1505 std::vector<VECTOR2I> polyPoints;
1507 for(
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
1508 bezierPoints.push_back( elem.
points.at( j ) );
1511 converter.
GetPoly( polyPoints );
1513 for(
size_t k = 0; k + 1 < polyPoints.size(); k++ )
1516 SCH_LAYER_ID::LAYER_NOTES );
1522 currentScreen->
Append( line );
1541 m_reporter->
Report( wxString::Format( wxT(
"Bezier's owner (%d) not found." ),
1547 symbol = libSymbolIt->second;
1548 schsym =
m_symbols.at( libSymbolIt->first );
1554 for(
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
1556 if( i + 2 == elem.
points.size() )
1564 for(
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
1575 else if( i + 3 == elem.
points.size() )
1586 for(
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
1605 for(
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
1616 case 0: bezier->
SetStart( pos );
break;
1619 case 3: bezier->
SetEnd( pos );
break;
1632 std::vector<LIB_SYMBOL*>& aSymbol )
1666 m_reporter->
Report( wxString::Format( wxT(
"Polyline's owner (%d) not found." ),
1672 symbol = libSymbolIt->second;
1673 schsym =
m_symbols.at( libSymbolIt->first );
1702 std::vector<LIB_SYMBOL*>& aSymbol )
1737 m_reporter->
Report( wxString::Format( wxT(
"Polygon's owner (%d) not found." ),
1743 symbol = libSymbolIt->second;
1744 schsym =
m_symbols.at( libSymbolIt->first );
1782 std::vector<LIB_SYMBOL*>& aSymbol )
1798 rect->
SetEnd( sheetBottomLeft );
1819 m_reporter->
Report( wxString::Format( wxT(
"Rounded rectangle's owner (%d) not "
1826 symbol = libSymbolIt->second;
1827 schsym =
m_symbols.at( libSymbolIt->first );
1841 rect =
new LIB_SHAPE( symbol, SHAPE_T::CIRCLE );
1849 rect =
new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE );
1885 wxCHECK( currentScreen, );
1895 currentScreen->
Append( circle );
1911 currentScreen->
Append( arc );
1928 m_reporter->
Report( wxString::Format( wxT(
"Arc's owner (%d) not found." ),
1934 symbol = libSymbolIt->second;
1935 schsym =
m_symbols.at( libSymbolIt->first );
1994 wxCHECK( currentScreen, );
2000 std::vector<BEZIER<int>> beziers;
2007 schbezier->
SetStart( bezier.Start );
2010 schbezier->
SetEnd( bezier.End );
2014 currentScreen->
Append( schbezier );
2031 m_reporter->
Report( wxString::Format( wxT(
"Elliptical Arc's owner (%d) not found." ),
2037 symbol = libSymbolIt->second;
2038 schsym =
m_symbols.at( libSymbolIt->first );
2048 std::vector<BEZIER<int>> beziers;
2074 SetLibShapeLine( elem, schbezier, ALTIUM_SCH_RECORD::ELLIPTICAL_ARC );
2097 std::vector<BEZIER<int>> beziers;
2104 schbezier->
SetStart( bezier.Start );
2107 schbezier->
SetEnd( bezier.End );
2112 schbezier->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
2117 screen->
Append( schbezier );
2134 m_reporter->
Report( wxString::Format( wxT(
"Ellipse's owner (%d) not found." ),
2140 symbol = libSymbolIt->second;
2141 schsym =
m_symbols.at( libSymbolIt->first );
2145 std::vector<BEZIER<int>> beziers;
2231 screen->
Append( circle );
2247 m_reporter->
Report( wxString::Format( wxT(
"Ellipse's owner (%d) not found." ),
2253 symbol = libSymbolIt->second;
2254 schsym =
m_symbols.at( libSymbolIt->first );
2308 m_reporter->
Report( wxString::Format( wxT(
"Line's owner (%d) not found." ),
2314 symbol = libSymbolIt->second;
2315 schsym =
m_symbols.at( libSymbolIt->first );
2366 m_reporter->
Report( wxT(
"Signal harness, belonging to the part is not currently "
2373 wxString>& aProperties )
2380 wxCHECK( currentScreen, );
2389 currentScreen->
Append( sheet );
2402 m_reporter->
Report( wxT(
"Harness connector, belonging to the part is not currently "
2417 m_reporter->
Report( wxString::Format( wxT(
"Harness entry's parent (%d) not found." ),
2424 sheetIt->second->AddPin( sheetPin );
2427 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
2429 VECTOR2I pos = sheetIt->second->GetPosition();
2430 VECTOR2I size = sheetIt->second->GetSize();
2435 case ASCH_SHEET_ENTRY_SIDE::LEFT:
2438 sheetPin->
SetSide( SHEET_SIDE::LEFT );
2440 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
2443 sheetPin->
SetSide( SHEET_SIDE::RIGHT );
2445 case ASCH_SHEET_ENTRY_SIDE::TOP:
2448 sheetPin->
SetSide( SHEET_SIDE::TOP );
2450 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
2453 sheetPin->
SetSide( SHEET_SIDE::BOTTOM );
2467 m_reporter->
Report( wxString::Format( wxT(
"Harness type's parent (%d) not found." ),
2481 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
2488 wxString fullPath = fn.GetFullPath();
2490 fullPath.Replace( wxT(
"\\" ), wxT(
"/" ) );
2492 SCH_SCREEN* screen = sheetIt->second->GetScreen();
2497 m_reporter->
Report( wxString::Format(
_(
"Altium's harness connector (%s) was imported as a "
2498 "hierarchical sheet. Please review the imported "
2506 std::vector<LIB_SYMBOL*>& aSymbol )
2521 rect->
SetEnd( sheetBottomLeft );
2542 m_reporter->
Report( wxString::Format( wxT(
"Rectangle's owner (%d) not found." ),
2548 symbol = libSymbolIt->second;
2549 schsym =
m_symbols.at( libSymbolIt->first );
2578 const std::map<wxString, wxString>& aProperties )
2593 wxCHECK( currentScreen, );
2594 currentScreen->
Append( sheet );
2603 wxCHECK( rootScreen, );
2611 m_sheets.insert( { aIndex, sheet } );
2623 m_reporter->
Report( wxString::Format( wxT(
"Sheet entry's owner (%d) not found." ),
2630 sheetIt->second->AddPin( sheetPin );
2633 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
2637 VECTOR2I pos = sheetIt->second->GetPosition();
2638 VECTOR2I size = sheetIt->second->GetSize();
2643 case ASCH_SHEET_ENTRY_SIDE::LEFT:
2646 sheetPin->
SetSide( SHEET_SIDE::LEFT );
2649 case ASCH_SHEET_ENTRY_SIDE::RIGHT:
2652 sheetPin->
SetSide( SHEET_SIDE::RIGHT );
2655 case ASCH_SHEET_ENTRY_SIDE::TOP:
2658 sheetPin->
SetSide( SHEET_SIDE::TOP );
2661 case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
2664 sheetPin->
SetSide( SHEET_SIDE::BOTTOM );
2671 case ASCH_PORT_IOTYPE::UNSPECIFIED:
2672 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
2675 case ASCH_PORT_IOTYPE::OUTPUT:
2676 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
2679 case ASCH_PORT_IOTYPE::INPUT:
2680 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_INPUT );
2683 case ASCH_PORT_IOTYPE::BIDI:
2684 sheetPin->
SetShape( LABEL_FLAG_SHAPE::L_BIDI );
2875 aReporter->
Report(
_(
"Power Port with unknown style imported as 'Bar' type." ),
2906 libSymbol = powerSymbolIt->second;
2916 libSymbol->
SetDescription( wxString::Format(
_(
"Power symbol creates a global "
2917 "label with name '%s'" ), elem.
text ) );
2926 pin->SetPosition( { 0, 0 } );
2927 pin->SetLength( 0 );
2928 pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
2929 pin->SetVisible(
false );
2961 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
2967 case ASCH_RECORD_ORIENTATION::UPWARDS:
2973 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
2979 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
2990 screen->
Append( symbol );
3001 int height = aElem.
Height;
3011 textBox->
SetFillMode( FILL_T::FILLED_WITH_COLOR );
3019 case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
3023 case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
3027 case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
3032 size_t fontId =
static_cast<int>( aElem.
FontID );
3048 screen->
Append( textBox );
3050 m_reporter->
Report( wxString::Format(
_(
"Altium's harness port (%s) was imported as "
3051 "a text box. Please review the imported "
3070 switch( aElem.
Style )
3073 case ASCH_PORT_STYLE::NONE_HORIZONTAL:
3074 case ASCH_PORT_STYLE::LEFT:
3075 case ASCH_PORT_STYLE::RIGHT:
3076 case ASCH_PORT_STYLE::LEFT_RIGHT:
3080 case ASCH_PORT_STYLE::NONE_VERTICAL:
3081 case ASCH_PORT_STYLE::TOP:
3082 case ASCH_PORT_STYLE::BOTTOM:
3083 case ASCH_PORT_STYLE::TOP_BOTTOM:
3100 bool connectionFound = startIsWireTerminal
3101 || startIsBusTerminal
3102 || endIsWireTerminal
3103 || endIsBusTerminal;
3105 if( !connectionFound )
3112 VECTOR2I position = ( startIsWireTerminal || startIsBusTerminal ) ? start : end;
3127 case ASCH_PORT_IOTYPE::UNSPECIFIED:
3128 label->
SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
3131 case ASCH_PORT_IOTYPE::OUTPUT:
3132 label->
SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
3135 case ASCH_PORT_IOTYPE::INPUT:
3136 label->
SetShape( LABEL_FLAG_SHAPE::L_INPUT );
3139 case ASCH_PORT_IOTYPE::BIDI:
3140 label->
SetShape( LABEL_FLAG_SHAPE::L_BIDI );
3144 switch( aElem.
Style )
3147 case ASCH_PORT_STYLE::NONE_HORIZONTAL:
3148 case ASCH_PORT_STYLE::LEFT:
3149 case ASCH_PORT_STYLE::RIGHT:
3150 case ASCH_PORT_STYLE::LEFT_RIGHT:
3151 if( ( startIsWireTerminal || startIsBusTerminal ) )
3157 case ASCH_PORT_STYLE::NONE_VERTICAL:
3158 case ASCH_PORT_STYLE::TOP:
3159 case ASCH_PORT_STYLE::BOTTOM:
3160 case ASCH_PORT_STYLE::TOP_BOTTOM:
3161 if( ( startIsWireTerminal || startIsBusTerminal ) )
3172 label->
GetFields()[0].SetVisible(
false );
3179 if( ( startIsWireTerminal && endIsWireTerminal ) )
3187 else if( startIsBusTerminal && endIsBusTerminal )
3210 screen->
Append( noConnect );
3238 for(
size_t i = 0; i + 1 < elem.
points.size(); i++ )
3241 SCH_LAYER_ID::LAYER_BUS );
3258 for(
size_t i = 0; i + 1 < elem.
points.size(); i++ )
3281 screen->
Append( junction );
3293 && component->second.currentpartid != elem.
ownerpartid )
3297 std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>( center );
3308 wxString msg = wxString::Format(
_(
"Embedded file %s not found in storage." ),
3314 wxString storagePath = wxFileName::CreateTempFileName(
"kicad_import_" );
3317 wxMemoryInputStream fileStream( storageFile->
data.data(), storageFile->
data.size() );
3318 wxZlibInputStream zlibInputStream( fileStream );
3319 wxFFileOutputStream outputStream( storagePath );
3320 outputStream.Write( zlibInputStream );
3321 outputStream.Close();
3323 if( !bitmap->ReadImageFile( storagePath ) )
3325 m_reporter->
Report( wxString::Format(
_(
"Error reading image %s." ), storagePath ),
3331 wxRemoveFile( storagePath );
3335 if( !wxFileExists( elem.
filename ) )
3342 if( !bitmap->ReadImageFile( elem.
filename ) )
3351 VECTOR2I currentImageSize = bitmap->GetSize();
3353 double scaleX =
std::abs(
static_cast<double>( expectedImageSize.
x ) / currentImageSize.
x );
3354 double scaleY =
std::abs(
static_cast<double>( expectedImageSize.
y ) / currentImageSize.
y );
3355 bitmap->SetImageScale( std::min( scaleX, scaleY ) );
3357 bitmap->SetFlags(
IS_NEW );
3358 screen->
Append( bitmap.release() );
3364 m_altiumSheet = std::make_unique<ASCH_SHEET>( aProperties );
3371 bool isPortrait =
m_altiumSheet->sheetOrientation == ASCH_SHEET_WORKSPACEORIENTATION::PORTRAIT;
3384 case ASCH_SHEET_SIZE::A4: pageInfo.
SetType(
"A4", isPortrait );
break;
3385 case ASCH_SHEET_SIZE::A3: pageInfo.
SetType(
"A3", isPortrait );
break;
3386 case ASCH_SHEET_SIZE::A2: pageInfo.
SetType(
"A2", isPortrait );
break;
3387 case ASCH_SHEET_SIZE::A1: pageInfo.
SetType(
"A1", isPortrait );
break;
3388 case ASCH_SHEET_SIZE::A0: pageInfo.
SetType(
"A0", isPortrait );
break;
3389 case ASCH_SHEET_SIZE::A: pageInfo.
SetType(
"A", isPortrait );
break;
3390 case ASCH_SHEET_SIZE::B: pageInfo.
SetType(
"B", isPortrait );
break;
3391 case ASCH_SHEET_SIZE::C: pageInfo.
SetType(
"C", isPortrait );
break;
3392 case ASCH_SHEET_SIZE::D: pageInfo.
SetType(
"D", isPortrait );
break;
3393 case ASCH_SHEET_SIZE::E: pageInfo.
SetType(
"E", isPortrait );
break;
3394 case ASCH_SHEET_SIZE::LETTER: pageInfo.
SetType(
"USLetter", isPortrait );
break;
3395 case ASCH_SHEET_SIZE::LEGAL: pageInfo.
SetType(
"USLegal", isPortrait );
break;
3396 case ASCH_SHEET_SIZE::TABLOID: pageInfo.
SetType(
"A3", isPortrait );
break;
3397 case ASCH_SHEET_SIZE::ORCAD_A: pageInfo.
SetType(
"A", isPortrait );
break;
3398 case ASCH_SHEET_SIZE::ORCAD_B: pageInfo.
SetType(
"B", isPortrait );
break;
3399 case ASCH_SHEET_SIZE::ORCAD_C: pageInfo.
SetType(
"C", isPortrait );
break;
3400 case ASCH_SHEET_SIZE::ORCAD_D: pageInfo.
SetType(
"D", isPortrait );
break;
3401 case ASCH_SHEET_SIZE::ORCAD_E: pageInfo.
SetType(
"E", isPortrait );
break;
3419 m_reporter->
Report( wxString::Format( wxT(
"Sheetname's owner (%d) not found." ),
3442 m_reporter->
Report( wxString::Format( wxT(
"Filename's owner (%d) not found." ),
3468 m_reporter->
Report( wxString::Format( wxT(
"Designator's owner (%d) not found." ),
3482 bool emptyRef = elem.
text.IsEmpty();
3487 bool visible = !emptyRef;
3499 std::vector<LIB_SYMBOL*>& aSymbol,
3500 std::vector<int>& aFontSizes )
3507 bool emptyRef = elem.
text.IsEmpty();
3508 LIB_FIELD& refField = symbol->GetReferenceField();
3511 refField.
SetText( wxT(
"X" ) );
3517 if( elem.
fontId > 0 && elem.
fontId <=
static_cast<int>( aFontSizes.size() ) )
3519 int size = aFontSizes[elem.
fontId - 1];
3536 busWireEntry->
SetSize( { vector.
x, vector.
y } );
3539 screen->
Append( busWireEntry );
3548 std::map<wxString, wxString> variableMap = {
3549 {
"COMMENT",
"VALUE" },
3550 {
"VALUE",
"ALTIUM_VALUE" },
3556 if( elem.
text ==
"*" )
3559 wxString paramName = elem.
name.Upper();
3561 if( paramName ==
"SHEETNUMBER" )
3565 else if( paramName ==
"TITLE" )
3569 else if( paramName ==
"REVISION" )
3573 else if( paramName ==
"DATE" )
3577 else if( paramName ==
"COMPANYNAME" )
3598 wxString upperName = elem.
name.Upper();
3600 if( upperName ==
"COMMENT" )
3607 wxString fieldName = elem.
name.Upper();
3611 if( fieldName.IsEmpty() )
3613 int disambiguate = 1;
3617 fieldName = wxString::Format(
"ALTIUM_UNNAMED_%d", disambiguate++ );
3624 else if( fieldName ==
"VALUE" )
3626 fieldName =
"ALTIUM_VALUE";
3642 std::vector<LIB_SYMBOL*>& aSymbol,
3643 std::vector<int>& aFontSizes )
3657 std::map<wxString, wxString> variableMap = {
3658 {
"COMMENT",
"VALUE" },
3664 wxString upperName = elem.
name.Upper();
3666 if( upperName ==
"COMMENT" )
3668 field = &libSymbol->GetValueField();
3672 int fieldIdx = libSymbol->GetFieldCount();
3673 wxString fieldName = elem.
name.Upper();
3675 if( fieldName.IsEmpty() )
3677 int disambiguate = 1;
3681 fieldName = wxString::Format(
"ALTIUM_UNNAMED_%d", disambiguate++ );
3683 if( !libSymbol->FindField( fieldName ) )
3687 else if( fieldName ==
"VALUE" )
3689 fieldName =
"ALTIUM_VALUE";
3693 libSymbol->AddField( new_field );
3706 if( elem.
fontId > 0 && elem.
fontId <=
static_cast<int>( aFontSizes.size() ) )
3708 int size = aFontSizes[elem.
fontId - 1];
3716 const std::map<wxString, wxString>& aProperties )
3725 std::vector<LIB_SYMBOL*>& aSymbol )
3733 if( !aSymbol.empty() )
3740 txt.Printf(
"*%s*", elem.
name );
3742 symbol->SetFPFilters( wxArrayString( 1, &txt ));
3743 LIB_FIELD& footprintField = symbol->GetFootprintField();
3754 m_reporter->
Report( wxString::Format( wxT(
"Implementation's owner (%d) not found." ),
3760 const auto& libSymbolIt =
m_libSymbols.find( implementationOwnerIt->second );
3764 m_reporter->
Report( wxString::Format( wxT(
"Footprint's owner (%d) not found." ),
3765 implementationOwnerIt->second ),
3771 wxArrayString fpFilters;
3772 fpFilters.Add( fpLibId.
Format() );
3774 libSymbolIt->second->SetFPFilters( fpFilters );
3788 std::vector<LIB_SYMBOL*> symbols;
3797 symbol->
SetName( wxString::Format(
"%s (Altium Display %d)", elem.
libreference, i + 1 ) );
3805 symbols.push_back( symbol );
3814 std::map<wxString,LIB_SYMBOL*> ret;
3815 std::vector<int> fontSizes;
3819 std::map<wxString, const CFB::COMPOUND_FILE_ENTRY*> syms = aAltiumLibFile.
GetLibSymbols(
nullptr );
3821 for(
auto& [
name, entry] : syms )
3824 std::vector<LIB_SYMBOL*> symbols;
3832 std::map<wxString, wxString> properties = reader.
ReadProperties();
3836 if( record != ALTIUM_SCH_RECORD::COMPONENT )
3837 THROW_IO_ERROR(
"LibSymbol does not start with COMPONENT record" );
3842 auto handleBinaryDataLambda =
3843 [](
const std::string& binaryData ) -> std::map<wxString, wxString>
3846 std::map<wxString, wxString> result;
3850 int32_t recordId = binreader.
ReadInt32();
3852 if( recordId !=
static_cast<int32_t
>( ALTIUM_SCH_RECORD::PIN ) )
3855 result[
"RECORD"] = wxString::Format(
"%d", recordId );
3857 result[
"OWNERPARTID"] = wxString::Format(
"%d", binreader.
ReadInt16() );
3858 result[
"OWNERPARTDISPLAYMODE"] = wxString::Format(
"%d", binreader.
ReadByte() );
3859 result[
"SYMBOL_INNEREDGE"] = wxString::Format(
"%d", binreader.
ReadByte() );
3860 result[
"SYMBOL_OUTEREDGE"] = wxString::Format(
"%d", binreader.
ReadByte() );
3861 result[
"SYMBOL_INNER"] = wxString::Format(
"%d", binreader.
ReadByte() );
3862 result[
"SYMBOL_OUTER"] = wxString::Format(
"%d", binreader.
ReadByte() );
3865 result[
"ELECTRICAL"] = wxString::Format(
"%d", binreader.
ReadByte() );
3866 result[
"PINCONGLOMERATE"] = wxString::Format(
"%d", binreader.
ReadByte() );
3867 result[
"PINLENGTH"] = wxString::Format(
"%d", binreader.
ReadInt16() );
3868 result[
"LOCATION.X"] = wxString::Format(
"%d", binreader.
ReadInt16() );
3869 result[
"LOCATION.Y"] = wxString::Format(
"%d", binreader.
ReadInt16() );
3870 result[
"COLOR"] = wxString::Format(
"%d", binreader.
ReadInt32() );
3877 std::vector<std::string> partSeqSplit =
split( partSeq,
"|" );
3879 if( partSeqSplit.size() == 3 )
3881 result[
"PART"] = partSeqSplit[0];
3882 result[
"SEQ"] = partSeqSplit[2];
3887 result[
"ISKICADLIBPIN"] = wxString(
"T" );
3893 std::map<wxString, wxString> properties = reader.
ReadProperties( handleBinaryDataLambda );
3895 if( properties.empty() )
3903 case ALTIUM_SCH_RECORD::PIN:
ParsePin( properties, symbols );
break;
3905 case ALTIUM_SCH_RECORD::LABEL:
ParseLabel( properties, symbols, fontSizes );
break;
3907 case ALTIUM_SCH_RECORD::BEZIER:
ParseBezier( properties, symbols );
break;
3909 case ALTIUM_SCH_RECORD::POLYLINE:
ParsePolyline( properties, symbols );
break;
3911 case ALTIUM_SCH_RECORD::POLYGON:
ParsePolygon( properties, symbols );
break;
3913 case ALTIUM_SCH_RECORD::ELLIPSE:
ParseEllipse( properties, symbols );
break;
3915 case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
ParseRoundRectangle( properties, symbols );
break;
3917 case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
ParseEllipticalArc( properties, symbols );
break;
3919 case ALTIUM_SCH_RECORD::ARC:
ParseArc( properties, symbols );
break;
3921 case ALTIUM_SCH_RECORD::LINE:
ParseLine( properties, symbols );
break;
3923 case ALTIUM_SCH_RECORD::RECTANGLE:
ParseRectangle( properties, symbols );
break;
3925 case ALTIUM_SCH_RECORD::DESIGNATOR:
ParseLibDesignator( properties, symbols, fontSizes );
break;
3927 case ALTIUM_SCH_RECORD::PARAMETER:
ParseLibParameter( properties, symbols, fontSizes );
break;
3929 case ALTIUM_SCH_RECORD::TEXT_FRAME:
ParseTextFrame( properties, symbols, fontSizes );
break;
3932 case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
break;
3934 case ALTIUM_SCH_RECORD::IMPLEMENTATION:
ParseImplementation( properties, symbols );
break;
3936 case ALTIUM_SCH_RECORD::IMPL_PARAMS:
break;
3938 case ALTIUM_SCH_RECORD::MAP_DEFINER_LIST:
break;
3939 case ALTIUM_SCH_RECORD::MAP_DEFINER:
break;
3942 case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
break;
3945 case ALTIUM_SCH_RECORD::IMAGE:
break;
3948 m_reporter->
Report( wxString::Format(
_(
"Unknown or unexpected record id %d found "
3950 recordId, symbols[0]->
GetName() ),
3962 for(
size_t ii = 0; ii < symbols.size(); ii++ )
3969 if( valField.
GetText().IsEmpty() )
3972 if( symbols.size() == 1 )
3975 ret[wxString::Format(
"%s (Altium Display %zd)",
name, ii + 1 )] = symbol;
3985 wxFileName fn( aLibraryPath );
3987 if( fn.IsFileReadable() )
3988 return fn.GetModificationTime().GetValue().GetValue();
3990 return wxDateTime( 0.0 ).GetValue().GetValue();
4007 wxFileName fileName( aLibraryPath );
4012 std::map<wxString, LIB_SYMBOL*> ret =
ParseLibFile( altiumSchFile );
4016 catch(
const CFB::CFBException& exception )
4020 catch(
const std::exception& exc )
4022 wxLogDebug( wxT(
"Unhandled exception in Altium schematic parsers: %s." ), exc.what() );
4030 const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( {
"FileHeader" } );
4032 if( file ==
nullptr )
4042 std::map<wxString, wxString> properties = reader.
ReadProperties();
4046 if( libtype.CmpNoCase(
"Protel for Windows - Schematic Library Editor Binary File Version 5.0" ) )
4047 THROW_IO_ERROR(
_(
"Expected Altium Schematic Library file version 5.0" ) );
4049 for(
auto& [key, value] : properties )
4051 wxString upperKey = key.Upper();
4054 if( upperKey.StartsWith(
"SIZE", &remaining ) )
4056 if( !remaining.empty() )
4058 int ind = wxAtoi( remaining );
4060 if(
static_cast<int>( aFontSizes.size() ) < ind )
4061 aFontSizes.resize( ind );
4065 aFontSizes[ind - 1] = scaled;
4074 const wxString& aLibraryPath,
4083 for(
auto& [libnameStr, libSymbol] : it->second )
4084 aSymbolNameList.Add( libnameStr );
4091 const wxString& aLibraryPath,
4100 for(
auto& [libnameStr, libSymbol] : it->second )
4101 aSymbolList.push_back( libSymbol );
4106 const wxString& aAliasName,
4115 auto it2 = it->second.find( aAliasName );
4117 if( it2 != it->second.end() )
const int ALTIUM_COMPONENT_NONE
wxString AltiumPinNamesToKiCad(wxString &aString)
LIB_ID AltiumToKiCadLibID(const wxString &aLibName, const wxString &aLibReference)
wxString AltiumSpecialStringsToKiCadVariables(const wxString &aString, const std::map< wxString, wxString > &aOverrides)
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.
std::string ReadPascalString()
std::map< wxString, const CFB::COMPOUND_FILE_ENTRY * > GetLibSymbols(const CFB::COMPOUND_FILE_ENTRY *aStart) const
const CFB::COMPOUND_FILE_ENTRY * FindStream(const std::vector< std::string > &aStreamPath) const
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
size_t GetRemainingBytes() const
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
std::map< wxString, wxString > ReadProperties(std::function< std::map< wxString, wxString >(const std::string &)> handleBinaryData=[](const std::string &) { return std::map< wxString, wxString >();})
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
Generic cubic Bezier representation.
static EDA_ANGLE m_Angle0
void SetFlags(EDA_ITEM_FLAGS aMask)
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
FILL_T GetFillMode() const
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
void SetFilled(bool aFlag)
void SetFillColor(const COLOR4D &aColor)
void SetStart(const VECTOR2I &aStart)
COLOR4D GetFillColor() const
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
virtual int GetWidth() const
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)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
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...
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.
Field object used in symbol libraries.
VECTOR2I GetPosition() const override
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 '_'.
void SetPosition(const VECTOR2I &aPosition) override
STROKE_PARAMS GetStroke() const
void SetStroke(const STROKE_PARAMS &aStroke)
void AddPoint(const VECTOR2I &aPosition)
void SetPosition(const VECTOR2I &aPosition) override
VECTOR2I GetPosition() const override
Define a library symbol object.
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
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)
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
LIB_FIELD & GetValueField()
Return reference to the value field.
void SetLibId(const LIB_ID &aLibId)
virtual void SetName(const wxString &aName)
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.
Define a symbol library graphical text item.
Describe the page size and margins of a paper page on which to eventually print or plot.
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
static const wxChar Custom[]
"User" defined page type
static void SetCustomHeightMils(int 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.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
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 void SetElem(ELEM_T aIndex, _ELEM *aElem)
virtual std::map< wxString, wxString > & GetTextVars() const
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.
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.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
void ParseEllipse(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseLibHeader(const ALTIUM_COMPOUND_FILE &aAltiumSchFile, std::vector< int > &aFontSizes)
std::unique_ptr< ASCH_SHEET > m_altiumSheet
void ParseImplementationList(int aIndex, const std::map< wxString, wxString > &aProperties)
void ParsePolygon(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::vector< ASCH_PORT > m_altiumHarnessPortsCurrentSheet
void ParseLabel(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
void ParseCircle(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseArc(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseStorage(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
std::map< int, int > m_altiumImplementationList
void AddTextBox(const ASCH_TEXT_FRAME *aElem)
void ParseSheetEntry(const std::map< wxString, wxString > &aProperties)
const wxString GetName() const override
Return a brief hard coded name for this SCH_PLUGIN.
void ParsePolyline(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 EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
void ParseComponent(int aIndex, const std::map< wxString, wxString > &aProperties)
std::map< wxString, LIB_SYMBOL * > m_powerSymbols
void AddLibTextBox(const ASCH_TEXT_FRAME *aElem, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
wxFileName getLibFileName()
void ParseImage(const std::map< wxString, wxString > &aProperties)
void ParseNetLabel(const std::map< wxString, wxString > &aProperties)
void ParseBusEntry(const std::map< wxString, wxString > &aProperties)
void ParsePin(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseLibDesignator(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
void ParseSheetName(const std::map< wxString, wxString > &aProperties)
void ParseBus(const std::map< wxString, wxString > &aProperties)
void ParseAdditional(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
void ParseDesignator(const std::map< wxString, wxString > &aProperties)
void ParseSheetSymbol(int aIndex, const std::map< wxString, wxString > &aProperties)
std::vector< LIB_SYMBOL * > ParseLibComponent(const std::map< wxString, wxString > &aProperties)
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const
void ParseAltiumSch(const wxString &aFileName)
void ParsePort(const ASCH_PORT &aElem)
void ParsePowerPort(const std::map< wxString, wxString > &aProperties)
std::unique_ptr< STRING_UTF8_MAP > m_properties
void ParseWire(const std::map< wxString, wxString > &aProperties)
SCH_SCREEN * getCurrentScreen()
std::vector< ASCH_STORAGE_FILE > m_altiumStorage
std::map< int, LIB_SYMBOL * > m_libSymbols
void ParseSignalHarness(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)
std::unique_ptr< TITLE_BLOCK > m_currentTitleBlock
long long getLibraryTimestamp(const wxString &aLibraryPath) const
SCH_SHEET_PATH m_sheetPath
void ensureLoadedLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties)
void ParseHarnessType(const std::map< wxString, wxString > &aProperties)
const ASCH_STORAGE_FILE * GetFileFromStorage(const wxString &aFilename) const
void ParseLine(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
SCH_SHEET * getCurrentSheet()
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr) override
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
void ParseParameter(const std::map< wxString, wxString > &aProperties)
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
void ParseEllipticalArc(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseHarnessConnector(int aIndex, const std::map< wxString, wxString > &aProperties)
void ParseRectangle(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseTextFrame(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym, std::vector< int > &aFontSize=nullint)
std::vector< ASCH_PORT > m_altiumPortsCurrentSheet
void ParseSheet(const std::map< wxString, wxString > &aProperties)
int m_harnessOwnerIndexOffset
void ParseImplementation(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseJunction(const std::map< wxString, wxString > &aProperties)
void ParseFileHeader(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
void ParseNoERC(const std::map< wxString, wxString > &aProperties)
std::map< wxString, std::map< wxString, LIB_SYMBOL * > > m_libCache
std::map< wxString, long long > m_timestamps
void ParseRoundRectangle(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
std::map< int, ASCH_SYMBOL > m_altiumComponents
void ParseNote(const std::map< wxString, wxString > &aProperties)
std::map< int, SCH_SYMBOL * > m_symbols
std::map< wxString, LIB_SYMBOL * > ParseLibFile(const ALTIUM_COMPOUND_FILE &aAltiumSchFile)
void ParseBezier(const std::map< wxString, wxString > &aProperties, std::vector< LIB_SYMBOL * > &aSymbol=nullsym)
void ParseHarnessPort(const ASCH_PORT &aElem)
void ParseFileName(const std::map< wxString, wxString > &aProperties)
std::map< int, SCH_SHEET * > m_sheets
void ParseHarnessEntry(const std::map< wxString, wxString > &aProperties)
void SetSize(const VECTOR2I &aSize)
Class for a wire to bus entry.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
void SetShape(LABEL_FLAG_SHAPE aShape)
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
std::vector< SCH_FIELD > & GetFields()
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
void SetLineWidth(const int aSize)
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
void SetEndPoint(const VECTOR2I &aPosition)
void set(SCH_PLUGIN *aPlugin)
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
virtual void SaveLibrary(const wxString &aFileName, const STRING_UTF8_MAP *aProperties=nullptr)
virtual void CreateSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty symbol library at aLibraryPath.
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 SetPageSettings(const PAGE_INFO &aPageSettings)
EE_RTREE & Items()
Gets 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.
void SetPosition(const VECTOR2I &aPos) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void AddPoint(const VECTOR2I &aPosition)
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)
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
int GetFieldCount() const
Return the number of fields in this symbol.
void SetValueFieldText(const wxString &aValue)
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
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
TRANSFORM & GetTransform()
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void SetUnit(int aUnit)
Change the unit number to aUnit.
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
A name/value tuple with unique names and optional values.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
KIGFX::COLOR4D GetColor() const
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
static const wxString & GetSymbolLibTableFileName()
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
static REPORTER & GetInstance()
#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)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
#define IS_NEW
New item, just created.
@ FILLED_WITH_BG_BODYCOLOR
const std::string KiCadSymbolLibFileExtension
const std::string KiCadSchematicFileExtension
#define THROW_IO_ERROR(msg)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static COLOR4D GetColorFromInt(int color)
#define HARNESS_PORT_COLOR_DEFAULT_OUTLINE
static PLOT_DASH_TYPE GetPlotDashType(const ASCH_POLYLINE_LINESTYLE linestyle)
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 SetLibShapeFillAndColor(const ASCH_FILL_INTERFACE &elem, LIB_SHAPE *shape, ALTIUM_SCH_RECORD aType, int aStrokeColor)
static void SetLibShapeLine(const ASCH_BORDER_INTERFACE &elem, LIB_SHAPE *shape, ALTIUM_SCH_RECORD aType)
static const VECTOR2I GetLibEditPosition(const VECTOR2I &aPosition)
#define HARNESS_PORT_COLOR_DEFAULT_BACKGROUND
static void SetSchShapeFillAndColor(const ASCH_FILL_INTERFACE &elem, SCH_SHAPE *shape)
void SetTextPositioning(EDA_TEXT *text, ASCH_LABEL_JUSTIFICATION justification, ASCH_RECORD_ORIENTATION orientation)
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
PLOT_DASH_TYPE
Dashed line types.
std::vector< VECTOR2I > points
std::vector< VECTOR2I > points
ASCH_LABEL_JUSTIFICATION justification
ASCH_RECORD_ORIENTATION orientation