57#include <compoundfilereader.h> 
   66#include <wx/mstream.h> 
   67#include <wx/zstream.h> 
   68#include <wx/wfstream.h> 
   69#include <magic_enum.hpp> 
   83#define HARNESS_PORT_COLOR_DEFAULT_BACKGROUND COLOR4D( 0.92941176470588238, \ 
   84                                                       0.94901960784313721, \ 
   85                                                       0.98431372549019602, 1.0 ) 
 
   87#define HARNESS_PORT_COLOR_DEFAULT_OUTLINE    COLOR4D( 0.56078431372549020, \ 
   88                                                       0.61960784313725492, \ 
   89                                                       0.78823529411764703, 1.0 ) 
 
  102    int green = ( 
color & 0x00FF00 ) >> 8;
 
  103    int blue  = ( 
color & 0xFF0000 ) >> 16;
 
 
  175    if( stroke.
GetColor() == default_color || stroke.
GetColor() == alt_default_color )
 
 
  212    else if( elem.
AreaColor == aStrokeColor )
 
  218    else if( bgcolor.
WithAlpha( 1.0 ) == default_bgcolor )
 
 
  263        for( 
auto& [
name, symbol] : lib )
 
 
  315    std::vector<SCH_PIN*> pins = aSymbol->
GetPins();
 
  317    bool names_visible = 
false;
 
  318    bool numbers_visible = 
false;
 
  322        if( 
pin->GetNameTextSize() > 0 && !
pin->GetName().empty() )
 
  323            names_visible = 
true;
 
  325        if( 
pin->GetNumberTextSize() > 0 && !
pin->GetNumber().empty() )
 
  326            numbers_visible = 
true;
 
  337    if( !numbers_visible )
 
 
  386    std::map<wxString, SCH_SHEET*> sheets;
 
  387    wxFileName 
project( aProperties->at( 
"project_file" ) );
 
  389    for( 
auto& [ key, filestring] : *aProperties )
 
  391        if( !key.starts_with( 
"sch" ) )
 
  397        wxFileName                 fn( filestring );
 
  398        wxFileName                 kicad_fn( fn );
 
  399        std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>( 
m_rootSheet, pos );
 
  401        sheet->SetScreen( screen );
 
  405        sheet->SetFileName( fn.GetFullPath() );
 
  408        wxCHECK2( sheet && screen, 
continue );
 
  410        wxString pageNo = wxString::Format( wxT( 
"%d" ), page++ );
 
  420        wxCHECK2( currentScreen, 
continue );
 
  424        currentScreen->
Append( sheetPtr );
 
  425        sheets[fn.GetFullPath()] = sheetPtr;
 
  439    for( 
auto& [ filestring, sheet ] : sheets )
 
 
  451                                             const std::map<std::string, UTF8>* aProperties )
 
  453    wxCHECK( ( !aFileName.IsEmpty() || !aProperties->empty() ) && aSchematic, 
nullptr );
 
  455    wxFileName fileName( aFileName );
 
  463    std::unique_ptr<SCH_SHEET> deleter( aAppendToMe ? 
nullptr : 
m_rootSheet );
 
  467        wxCHECK_MSG( aSchematic->
IsValid(), 
nullptr, 
"Can't append to a schematic with no root!" );
 
  473        m_rootSheet->SetFileName( fileName.GetFullPath() );
 
  495    wxCHECK( rootScreen, 
nullptr );
 
  504    if( aFileName.empty() )
 
  524    int minWireWidth = std::numeric_limits<int>::max();
 
  525    int minBusWidth = std::numeric_limits<int>::max();
 
  529        std::vector<SCH_MARKER*> markers;
 
  536                minWireWidth = std::min( minWireWidth, line->
GetLineWidth() );
 
  539                minBusWidth = std::min( minBusWidth, line->
GetLineWidth() );
 
  543    std::shared_ptr<NET_SETTINGS>& netSettings = 
m_schematic->Project().GetProjectFile().NetSettings();
 
  545    if( minWireWidth < std::numeric_limits<int>::max() )
 
  546        netSettings->GetDefaultNetclass()->SetWireWidth( minWireWidth );
 
  548    if( minBusWidth < std::numeric_limits<int>::max() )
 
  549        netSettings->GetDefaultNetclass()->SetBusWidth( minBusWidth );
 
 
  572    std::vector<SCH_LINE*> busLines;
 
  573    std::map<VECTOR2I, std::vector<SCH_LINE*>> busLineMap;
 
  581            busLines.push_back( line );
 
  583            busLineMap[ line->
GetEndPoint() ].push_back( line );
 
  590                auto it = busLineMap.find( aStart );
 
  592                if( it == busLineMap.end() )
 
  598                    if( aVisited.count( line ) )
 
  601                    aVisited.insert( line );
 
  622        std::shared_ptr<BUS_ALIAS> alias = std::make_shared<BUS_ALIAS>();
 
  623        alias->SetName( harness.m_name );
 
  626            alias->Members().push_back( port.
m_name );
 
  631        BOX2I     box( harness.m_location, harness.m_size );
 
  661                int delta_x = 
center.x - pos.
x;
 
  662                int delta_y = 
center.y - pos.
y;
 
  669                    screen->
Append( busLine );
 
  676                    screen->
Append( busLine );
 
  686        std::set<SCH_LINE*> visited;
 
  687        SCH_LABEL* label = walkBusLine( pos, visited );
 
  694        if( label && !label->
GetText().StartsWith( wxT( 
"{" ) ) )
 
  695            label->
SetText( label->
GetText() + wxT( 
"{" ) + harness.m_name + wxT( 
"}" ) );
 
  712        bool isVertical = 
true;
 
  714        if( harness.m_ports.size() > 1 )
 
  716            VECTOR2I first = harness.m_ports.front().m_location;
 
  717            VECTOR2I last = harness.m_ports.back().m_location;
 
  719            if( first.
y == last.
y )
 
  725            VECTOR2I bottom = harness.m_ports.front().m_entryLocation;
 
  726            VECTOR2I top = harness.m_ports.front().m_entryLocation;
 
 
  791    wxFileName parentFileName( aFileName );
 
  798        wxFileName relative = parentFileName;
 
  801        m_progressReporter->Report( wxString::Format( 
_( 
"Importing %s" ), relative.GetFullPath() ) );
 
  819        catch( 
const CFB::CFBException& exception )
 
  823        catch( 
const std::exception& exc )
 
  825            wxLogTrace( 
traceAltiumSch, wxS( 
"Unhandled exception in Altium schematic parser: %s." ),
 
  836    wxCHECK( currentScreen,  );
 
  844        wxCHECK2( sheet, 
continue );
 
  848        wxFileName loadAltiumFileName( parentFileName.GetPath(), sheet->
GetFileName() );
 
  850        if( !loadAltiumFileName.IsFileReadable() )
 
  854            wxDir::GetAllFiles( parentFileName.GetPath(), &files, wxEmptyString,
 
  855                                wxDIR_FILES | wxDIR_HIDDEN );
 
  857            for( 
const wxString& candidate : files )
 
  859                wxFileName candidateFname( candidate );
 
  861                if( candidateFname.GetFullName().IsSameAs( sheet->
GetFileName(), 
false ) )
 
  863                    loadAltiumFileName = candidateFname;
 
  869        if( loadAltiumFileName.GetFullName().IsEmpty() || !loadAltiumFileName.IsFileReadable() )
 
  871            m_errorMessages.emplace( wxString::Format( 
_( 
"The file name for sheet %s is undefined, " 
  872                                                          "this is probably an Altium signal harness " 
  873                                                          "that got converted to a sheet." ),
 
  880        m_rootSheet->SearchHierarchy( loadAltiumFileName.GetFullPath(), &loadedScreen );
 
  886            wxFileName projectFileName = loadAltiumFileName;
 
  887            projectFileName.SetPath( 
m_schematic->Project().GetProjectPath() );
 
  889            sheet->
SetFileName( projectFileName.GetFullName() );
 
  897            if( sheet->
GetName().Trim().empty() )
 
  898                sheet->
SetName( loadAltiumFileName.GetName() );
 
  900            wxCHECK2( screen, 
continue );
 
  907            wxFileName projectFileName = loadAltiumFileName;
 
  908            projectFileName.SetPath( 
m_schematic->Project().GetProjectPath() );
 
  910            sheet->
SetFileName( projectFileName.GetFullName() );
 
  911            screen->
SetFileName( projectFileName.GetFullPath() );
 
 
  921    const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( { 
"Storage" } );
 
  923    if( file == 
nullptr )
 
  928    std::map<wxString, wxString> properties = reader.
ReadProperties();
 
  935    for( 
int i = 0; i < weight; i++ )
 
  945        m_errorMessages.emplace( wxString::Format( 
_( 
"Storage file not fully parsed (%d bytes remaining)." ),
 
 
  954    wxString streamName = wxS( 
"Additional" );
 
  956    const CFB::COMPOUND_FILE_ENTRY* file =
 
  957            aAltiumSchFile.
FindStream( { streamName.ToStdString() } );
 
  959    if( file == 
nullptr )
 
  970        std::map<wxString, wxString> properties = reader.
ReadProperties();
 
  981        std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 
 1005    wxString streamName = wxS( 
"FileHeader" );
 
 1007    const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( { streamName.ToStdString() } );
 
 1009    if( file == 
nullptr )
 
 1020        std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 1024        if( libtype.CmpNoCase( 
"Protel for Windows - Schematic Capture Binary File Version 5.0" ) )
 
 1037        std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 1049    for( std::pair<const int, SCH_SYMBOL*>& symbol : 
m_symbols )
 
 1059        symbol.second->SetLibSymbol( libSymbolIt->second );
 
 
 1096        while( storageReader.
CanRead() )
 
 1098            std::map<wxString, wxString> properties = storageReader.
ReadProperties();
 
 1101            if( properties.find( wxS( 
"BINARY" ) ) != properties.end() )
 
 1115        std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 1119        if( libtype.CmpNoCase( 
"Protel for Windows - Schematic Capture Ascii File Version 5.0" ) )
 
 1134        std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 1137        if( properties.find( wxS( 
"HEADER" ) ) != properties.end() )
 
 1143        if( properties.find( wxS( 
"RECORD" ) ) != properties.end() )
 
 1156    for( std::pair<const int, SCH_SYMBOL*>& symbol : 
m_symbols )
 
 1166        symbol.second->SetLibSymbol( libSymbolIt->second );
 
 
 1206                                 const wxString& aSectionName )
 
 1402                wxString::Format( 
_( 
"Unknown or unexpected record id %d found in %s." ), recordId,
 
 
 1433        if( file.filename.IsSameAs( aFilename ) )
 
 1436        if( file.filename.EndsWith( aFilename ) )
 
 1437            nonExactMatch = &file;
 
 1440    return nonExactMatch;
 
 
 1447    wxCHECK( currentSheet,  );
 
 1449    wxString sheetName = currentSheet->
GetName();
 
 1451    if( sheetName.IsEmpty() )
 
 1452        sheetName = wxT( 
"root" );
 
 1460        m_errorMessages.emplace( wxString::Format( 
_( 
"Symbol '%s' in sheet '%s' at index %d " 
 1461                                                      "replaced with symbol \"%s\"." ),
 
 1473    wxString 
name = wxString::Format( 
"%s_%d%s_%s_%s",
 
 1498        field.SetVisible( 
false );
 
 1523    screen->
Append( symbol );
 
 
 1532    wxCHECK( currentSheet,  );
 
 1534    wxString sheetName = currentSheet->
GetName();
 
 1536    if( sheetName.IsEmpty() )
 
 1537        sheetName = wxT( 
"root" );
 
 1542    wxString baseName = altiumTemplate.
filename.AfterLast( 
'\\' ).BeforeLast( 
'.' );
 
 1544    if( baseName.IsEmpty() )
 
 1545        baseName = wxS( 
"Template" );
 
 
 1553                              std::vector<LIB_SYMBOL*>& aSymbol )
 
 1568            m_errorMessages.emplace( wxString::Format( wxT( 
"Pin's owner (%d) not found." ),
 
 1577        schSymbol = 
m_symbols.at( libSymbolIt->first );
 
 1578        symbol = libSymbolIt->second;
 
 1597        pin->SetVisible( 
false );
 
 1600        pin->SetNumberTextSize( 0 );
 
 1603        pin->SetNameTextSize( 0 );
 
 1639    pin->SetPosition( pinLocation );
 
 
 1737    int       vjustify, hjustify;
 
 1740    switch( justification )
 
 1763    switch( justification )
 
 1786    switch( orientation )
 
 1809    text->SetTextAngle( angle );
 
 
 1828                                std::vector<LIB_SYMBOL*>& aSymbol, std::vector<int>& aFontSizes )
 
 1834        static const std::map<wxString, wxString> variableMap = {
 
 1835            { 
"APPLICATION_BUILDNUMBER", 
"KICAD_VERSION" },
 
 1836            { 
"SHEETNUMBER",             
"#"             },
 
 1837            { 
"SHEETTOTAL",              
"##"            },
 
 1838            { 
"TITLE",                   
"TITLE"         },  
 
 1839            { 
"REVISION",                
"REVISION"      },  
 
 1840            { 
"DATE",                    
"ISSUE_DATE"    },
 
 1841            { 
"CURRENTDATE",             
"CURRENT_DATE"  },
 
 1842            { 
"COMPANYNAME",             
"COMPANY"       },
 
 1843            { 
"DOCUMENTNAME",            
"FILENAME"      },
 
 1844            { 
"DOCUMENTFULLPATHANDNAME", 
"FILEPATH"      },
 
 1845            { 
"PROJECTNAME",             
"PROJECTNAME"   },
 
 1853        size_t fontId = 
static_cast<int>( elem.
fontId );
 
 1870        screen->
Append( textItem );
 
 1890            symbol = libSymbolIt->second;
 
 1891            schsym = 
m_symbols.at( libSymbolIt->first );
 
 1906        size_t fontId = elem.
fontId;
 
 1917        else if( fontId > 0 && fontId <= aFontSizes.size() )
 
 1919            int size = aFontSizes[fontId - 1];
 
 
 1927                                    std::vector<LIB_SYMBOL*>& aSymbol,
 
 1928                                    std::vector<int>& aFontSizes )
 
 
 1955    textBox->
SetStart( sheetTopRight );
 
 1956    textBox->
SetEnd( sheetBottomLeft );
 
 1986    size_t fontId = 
static_cast<int>( aElem->
FontID );
 
 2004    screen->
Append( textBox );
 
 
 2009                                   std::vector<int>& aFontSizes )
 
 2028        symbol = libSymbolIt->second;
 
 2029        schsym = 
m_symbols.at( libSymbolIt->first );
 
 2077    if( aElem->
FontID > 0 && aElem->
FontID <= 
static_cast<int>( aFontSizes.size() ) )
 
 2079        int size = aFontSizes[aElem->
FontID - 1];
 
 
 2086                                 std::vector<LIB_SYMBOL*>&           aSymbol )
 
 2090    if( elem.
points.size() < 2 )
 
 2092        m_errorMessages.emplace( wxString::Format( 
_( 
"Bezier has %d control points. At least 2 are expected." ),
 
 2093                                                   static_cast<int>( elem.
points.size() ) ),
 
 2101        wxCHECK( currentScreen,  );
 
 2103        for( 
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
 
 2105            if( i + 2 == elem.
points.size() )
 
 2116                currentScreen->
Append( line );
 
 2121                std::vector<VECTOR2I> bezierPoints;
 
 2122                std::vector<VECTOR2I> polyPoints;
 
 2124                for( 
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
 
 2125                    bezierPoints.push_back( elem.
points.at( j ) );
 
 2128                converter.
GetPoly( polyPoints );
 
 2130                for( 
size_t k = 0; k + 1 < polyPoints.size(); k++ )
 
 2139                    currentScreen->
Append( line );
 
 2157                m_errorMessages.emplace( wxString::Format( wxT( 
"Bezier's owner (%d) not found." ),
 
 2163            symbol = libSymbolIt->second;
 
 2164            schsym = 
m_symbols.at( libSymbolIt->first );
 
 2170        for( 
size_t i = 0; i + 1 < elem.
points.size(); i += 3 )
 
 2172            if( i + 2 == elem.
points.size() )
 
 2180                for( 
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
 
 2192            else if( i + 3 == elem.
points.size() )
 
 2203                for( 
size_t j = i; j < elem.
points.size() && j < i + 2; j++ )
 
 2223                for( 
size_t j = i; j < elem.
points.size() && j < i + 4; j++ )
 
 2232                    case 0: bezier->
SetStart( pos );    
break;
 
 2235                    case 3: bezier->
SetEnd( pos );      
break;
 
 
 2249                                   std::vector<LIB_SYMBOL*>&           aSymbol )
 
 2253    if( elem.
Points.size() < 2 )
 
 2261        for( 
size_t i = 1; i < elem.
Points.size(); i++ )
 
 2289                m_errorMessages.emplace( wxString::Format( wxT( 
"Polyline's owner (%d) not found." ),
 
 2295            symbol = libSymbolIt->second;
 
 2296            schsym = 
m_symbols.at( libSymbolIt->first );
 
 
 2325                                  std::vector<LIB_SYMBOL*>& aSymbol )
 
 2359                m_errorMessages.emplace( wxString::Format( wxT( 
"Polygon's owner (%d) not found." ),
 
 2365            symbol = libSymbolIt->second;
 
 2366            schsym = 
m_symbols.at( libSymbolIt->first );
 
 
 2407                                         std::vector<LIB_SYMBOL*>& aSymbol )
 
 2440                m_errorMessages.emplace( wxString::Format( wxT( 
"Rounded rectangle's owner (%d) not found." ),
 
 2446            symbol = libSymbolIt->second;
 
 2447            schsym = 
m_symbols.at( libSymbolIt->first );
 
 2465            int      radius = std::min( width / 2, height / 2 );
 
 
 2501                              std::vector<LIB_SYMBOL*>& aSymbol )
 
 2517        wxCHECK( currentScreen,  );
 
 2542            currentScreen->
Append( arc );
 
 2563            symbol = libSymbolIt->second;
 
 2564            schsym = 
m_symbols.at( libSymbolIt->first );
 
 
 2607                                        std::vector<LIB_SYMBOL*>& aSymbol )
 
 2621        wxCHECK( currentScreen,  );
 
 2627        std::vector<BEZIER<int>> beziers;
 
 2634            schbezier->
SetStart( bezier.Start );
 
 2637            schbezier->
SetEnd( bezier.End );
 
 2641            currentScreen->
Append( schbezier );
 
 2657                m_errorMessages.emplace( wxString::Format( wxT( 
"Elliptical Arc's owner (%d) not found." ),
 
 2663            symbol = libSymbolIt->second;
 
 2664            schsym = 
m_symbols.at( libSymbolIt->first );
 
 2674        std::vector<BEZIER<int>> beziers;
 
 2694                schbezier->
SetStart( bezier.Start );
 
 2697                schbezier->
SetEnd( bezier.End );
 
 
 2708                                  std::vector<LIB_SYMBOL*>& aSymbol )
 
 2756                m_errorMessages.emplace( wxString::Format( wxT( 
"Piechart's owner (%d) not found." ),
 
 2762            symbol = libSymbolIt->second;
 
 2763            schsym = 
m_symbols.at( libSymbolIt->first );
 
 
 2793                                  std::vector<LIB_SYMBOL*>& aSymbol )
 
 2818        std::vector<BEZIER<int>> beziers;
 
 2819        std::vector<VECTOR2I>    polyPoints;
 
 2826            schbezier->
SetStart( bezier.Start );
 
 2829            schbezier->
SetEnd( bezier.End );
 
 2835            screen->
Append( schbezier );
 
 2837            polyPoints.push_back( bezier.Start );
 
 2847            for( 
const VECTOR2I& point : polyPoints )
 
 2850            schpoly->
AddPoint( polyPoints[0] );
 
 2852            screen->
Append( schpoly );
 
 2873            symbol = libSymbolIt->second;
 
 2874            schsym = 
m_symbols.at( libSymbolIt->first );
 
 2880        std::vector<BEZIER<int>> beziers;
 
 2881        std::vector<VECTOR2I>    polyPoints;
 
 2893                libbezier->
SetStart( bezier.Start );
 
 2896                libbezier->
SetEnd( bezier.End );
 
 2910            polyPoints.push_back( libbezier->
GetStart() );
 
 2921            for( 
const VECTOR2I& point : polyPoints )
 
 2924            libline->
AddPoint( polyPoints[0] );
 
 
 2934                                 std::vector<LIB_SYMBOL*>& aSymbol )
 
 2954            circle->SetFilled( 
false );
 
 2976            symbol = libSymbolIt->second;
 
 2977            schsym = 
m_symbols.at( libSymbolIt->first );
 
 
 2999                               std::vector<LIB_SYMBOL*>& aSymbol )
 
 3035            symbol = libSymbolIt->second;
 
 3036            schsym = 
m_symbols.at( libSymbolIt->first );
 
 
 3073        for( 
size_t ii = 0; ii < elem.
points.size() - 1; ii++ )
 
 3086        m_errorMessages.emplace( wxT( 
"Signal harness, belonging to the part is not currently supported." ),
 
 
 3093                                           wxString>& aProperties )
 
 3102        HARNESS& harness = it->second;
 
 3130        m_errorMessages.emplace( wxT( 
"Harness connector, belonging to the part is not currently supported." ),
 
 
 3144        m_errorMessages.emplace( wxString::Format( wxT( 
"Harness entry's parent (%d) not found." ),
 
 3150    HARNESS& harness = harnessIt->second;
 
 3187    harness.
m_ports.emplace_back( port );
 
 
 3199        m_errorMessages.emplace( wxString::Format( wxT( 
"Harness type's parent (%d) not found." ),
 
 3205    HARNESS& harness = harnessIt->second;
 
 
 3211                                    std::vector<LIB_SYMBOL*>& aSymbol )
 
 3226        rect->
SetEnd( sheetBottomLeft );
 
 3246                m_errorMessages.emplace( wxString::Format( wxT( 
"Rectangle's owner (%d) not found." ),
 
 3252            symbol = libSymbolIt->second;
 
 3253            schsym = 
m_symbols.at( libSymbolIt->first );
 
 3267            rect->
SetEnd( sheetBottomLeft );
 
 
 3295    wxCHECK( currentScreen,  );
 
 3296    currentScreen->
Append( sheet );
 
 3305    wxCHECK( rootScreen,  );
 
 3313    m_sheets.insert( { aIndex, sheet } );
 
 
 3331    sheetIt->second->AddPin( sheetPin );
 
 3338    VECTOR2I pos = sheetIt->second->GetPosition();
 
 3339    VECTOR2I size = sheetIt->second->GetSize();
 
 
 3576            aReporter->
Report( 
_( 
"Power Port with unknown style imported as 'Bar' type." ),
 
 
 3601    wxString    symName( elem.
text );
 
 3602    std::string styleName( magic_enum::enum_name<ASCH_POWER_PORT_STYLE>( elem.
style ) );
 
 3604    if( !styleName.empty() )
 
 3605        symName << 
'_' << styleName;
 
 3614        libSymbol = powerSymbolIt->second; 
 
 3620        libSymbol->
SetName( symName );
 
 3625        libSymbol->
SetDescription( wxString::Format( 
_( 
"Power symbol creates a global label with name '%s'" ),
 
 3635        pin->SetPosition( { 0, 0 } );
 
 3636        pin->SetLength( 0 );
 
 3638        pin->SetVisible( 
false );
 
 3695    screen->
Append( symbol );
 
 
 3723    switch( aElem.
Style )
 
 3753    bool connectionFound = startIsWireTerminal
 
 3754                            || startIsBusTerminal
 
 3755                            || endIsWireTerminal
 
 3756                            || endIsBusTerminal;
 
 3758    if( !connectionFound )
 
 3762            if( harness.m_name.CmpNoCase( aElem.
HarnessType ) != 0 )
 
 3765            BOX2I bbox( harness.m_location, harness.m_size );
 
 3770                startIsBusTerminal = 
true;
 
 3771                connectionFound = 
true;
 
 3777                endIsBusTerminal = 
true;
 
 3778                connectionFound = 
true;
 
 3783        if( !connectionFound )
 
 3791    VECTOR2I        position = ( startIsWireTerminal || startIsBusTerminal ) ? start : 
end;
 
 3815    switch( aElem.
Style )
 
 3822        if( ( startIsWireTerminal || startIsBusTerminal ) )
 
 3833        if( ( startIsWireTerminal || startIsBusTerminal ) )
 
 3847    if( ( startIsWireTerminal && endIsWireTerminal ) )
 
 3855    else if( startIsBusTerminal && endIsBusTerminal )
 
 
 3878        screen->
Append( noConnect );
 
 
 3906    for( 
size_t i = 0; i + 1 < elem.
points.size(); i++ )
 
 
 3925    for( 
size_t i = 0; i + 1 < elem.
points.size(); i++ )
 
 
 3947    screen->
Append( junction );
 
 
 3959        && component->second.currentpartid != elem.
ownerpartid )
 
 3963    std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>( 
center );
 
 3975            m_errorMessages.emplace( wxString::Format( 
_( 
"Embedded file %s not found in storage." ),
 
 3981        wxString storagePath = wxFileName::CreateTempFileName( 
"kicad_import_" );
 
 3984        wxMemoryInputStream fileStream( storageFile->
data.data(), storageFile->
data.size() );
 
 3985        wxZlibInputStream   zlibInputStream( fileStream );
 
 3986        wxFFileOutputStream outputStream( storagePath );
 
 3987        outputStream.Write( zlibInputStream );
 
 3988        outputStream.Close();
 
 3992            m_errorMessages.emplace( wxString::Format( 
_( 
"Error reading image %s." ), storagePath ),
 
 3998        wxRemoveFile( storagePath );
 
 4002        if( !wxFileExists( elem.
filename ) )
 
 4020    const double   scaleX = 
std::abs( 
static_cast<double>( expectedImageSize.
x ) / currentImageSize.
x );
 
 4021    const double   scaleY = 
std::abs( 
static_cast<double>( expectedImageSize.
y ) / currentImageSize.
y );
 
 4024    bitmap->SetFlags( 
IS_NEW );
 
 4025    screen->
Append( bitmap.release() );
 
 
 4031    m_altiumSheet = std::make_unique<ASCH_SHEET>( aProperties );
 
 
 4083    wxCHECK( currentScreen,  );
 
 4089        m_errorMessages.emplace( wxString::Format( wxT( 
"Sheetname's owner (%d) not found." ),
 
 4095    wxString           sheetName = elem.
text;
 
 4096    std::set<wxString> sheetNames;
 
 4101        sheetNames.insert( sheet->
GetName() );
 
 4104    for( 
int ii = 1; ; ++ii )
 
 4106        if( sheetNames.find( sheetName ) == sheetNames.end() )
 
 4109        sheetName = elem.
text + wxString::Format( wxT( 
"_%d" ), ii );
 
 4115    sheetNameField->
SetText( sheetName );
 
 
 4129        m_errorMessages.emplace( wxString::Format( wxT( 
"Filename's owner (%d) not found." ),
 
 
 4155        m_errorMessages.emplace( wxString::Format( wxT( 
"Designator's owner (%d) not found." ),
 
 4169    bool emptyRef = elem.
text.IsEmpty();
 
 4174    bool visible = !emptyRef;
 
 
 4186                                        std::vector<LIB_SYMBOL*>&           aSymbol,
 
 4187                                        std::vector<int>&                   aFontSizes )
 
 4194        bool emptyRef = elem.
text.IsEmpty();
 
 4195        SCH_FIELD& refField = symbol->GetReferenceField();
 
 4198            refField.
SetText( wxT( 
"X" ) );
 
 4204        if( elem.
fontId > 0 && elem.
fontId <= 
static_cast<int>( aFontSizes.size() ) )
 
 4206            int size = aFontSizes[elem.
fontId - 1];
 
 
 4223    busWireEntry->
SetSize( { vector.
x, vector.
y } );
 
 4226    screen->
Append( busWireEntry );
 
 
 4235    static const std::map<wxString, wxString> variableMap = {
 
 4236        { 
"COMMENT", 
"VALUE"        },
 
 4237        { 
"VALUE",   
"ALTIUM_VALUE" },
 
 4243        if( elem.
text == 
"*" )
 
 4246        wxString paramName = elem.
name.Upper();
 
 4248        if( paramName == 
"SHEETNUMBER" )
 
 4252        else if( paramName == 
"TITLE" )
 
 4256        else if( paramName == 
"REVISION" )
 
 4260        else if( paramName == 
"DATE" )
 
 4264        else if( paramName == 
"COMPANYNAME" )
 
 4285        wxString    upperName = elem.
name.Upper();
 
 4287        if( upperName == 
"COMMENT" )
 
 4293            wxString fieldName = elem.
name.Upper();
 
 4295            if( fieldName.IsEmpty() )
 
 4297                int disambiguate = 1;
 
 4301                    fieldName = wxString::Format( 
"ALTIUM_UNNAMED_%d", disambiguate++ );
 
 4303                    if( !symbol->
GetField( fieldName ) )
 
 4307            else if( fieldName == 
"VALUE" )
 
 4309                fieldName = 
"ALTIUM_VALUE";
 
 
 4326                                       std::vector<LIB_SYMBOL*>& aSymbol,
 
 4327                                       std::vector<int>& aFontSizes )
 
 4348    std::map<wxString, wxString> variableMap = {
 
 4349        { 
"COMMENT", 
"VALUE" },
 
 4355        wxString    upperName = elem.
name.Upper();
 
 4357        if( upperName == 
"COMMENT" )
 
 4359            field = &libSymbol->GetValueField();
 
 4363            wxString fieldNameStem = elem.
name;
 
 4364            wxString fieldName = fieldNameStem;
 
 4365            int disambiguate = 1;
 
 4367            if( fieldName.IsEmpty() )
 
 4369                fieldNameStem = 
"ALTIUM_UNNAMED";
 
 4370                fieldName = 
"ALTIUM_UNNAMED_1";
 
 4373            else if( upperName == 
"VALUE" )
 
 4375                fieldNameStem = 
"ALTIUM_VALUE";
 
 4376                fieldName = 
"ALTIUM_VALUE";
 
 4380            while( libSymbol->GetField( fieldName ) )
 
 4381                fieldName = wxString::Format( 
"%s_%d", fieldNameStem, disambiguate++ );
 
 4384            libSymbol->AddField( new_field );
 
 4395        if( elem.
fontId > 0 && elem.
fontId <= 
static_cast<int>( aFontSizes.size() ) )
 
 4397            int size = aFontSizes[elem.
fontId - 1];
 
 
 4411                                             const std::map<wxString, wxString>& aProperties )
 
 
 4420                                         std::vector<LIB_SYMBOL*>& aSymbol )
 
 4424    if( elem.
type != wxS( 
"PCBLIB" ) )
 
 4428    if( aSymbol.size() == 0 && !elem.
isCurrent )
 
 4434    wxArrayString fpFilters;
 
 4435    fpFilters.Add( wxString::Format( wxS( 
"*%s*" ), elem.
name ) );
 
 4438    if( !aSymbol.empty() )
 
 4444            symbol->SetFPFilters( fpFilters );
 
 4455        m_errorMessages.emplace( wxString::Format( wxT( 
"Implementation's owner (%d) not found." ),
 
 4461    const auto& libSymbolIt = 
m_libSymbols.find( implementationOwnerIt->second );
 
 4465        m_errorMessages.emplace( wxString::Format( wxT( 
"Footprint's owner (%d) not found." ),
 
 4466                                                   implementationOwnerIt->second ),
 
 4473    libSymbolIt->second->SetFPFilters( fpFilters ); 
 
 
 4483                                                           wxString>& aProperties )
 
 4487    std::vector<LIB_SYMBOL*> symbols;
 
 4496            symbol->
SetName( wxString::Format( 
"%s (Altium Display %d)", elem.
libreference, i + 1 ) );
 
 4504        symbols.push_back( symbol );
 
 
 4515    std::vector<int> fontSizes;
 
 4516    struct SYMBOL_PIN_FRAC
 
 4525    std::map<wxString, ALTIUM_SYMBOL_DATA> syms = aAltiumLibFile.
GetLibSymbols( 
nullptr );
 
 4527    for( 
auto& [
name, entry] : syms )
 
 4529        std::map<int, SYMBOL_PIN_FRAC> pinFracs;
 
 4531        if( entry.m_pinsFrac )
 
 4533            auto parse_binary_pin_frac =
 
 4534                    [&]( 
const std::string& binaryData ) -> std::map<wxString, wxString>
 
 4536                        std::map<wxString, wxString> 
result;
 
 4542                        SYMBOL_PIN_FRAC      pinFrac;
 
 4546                        pinFrac.len_frac = binreader.
ReadInt32();
 
 4547                        pinFracs.insert( { pinFracData.first, pinFrac } );
 
 4559        std::vector<LIB_SYMBOL*> symbols;
 
 4566            std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 4571                THROW_IO_ERROR( 
"LibSymbol does not start with COMPONENT record" );
 
 4576        auto handleBinaryPinLambda =
 
 4577                [&]( 
const std::string& binaryData ) -> std::map<wxString, wxString>
 
 4579                    std::map<wxString, wxString> 
result;
 
 4583                    int32_t recordId = binreader.
ReadInt32();
 
 4588                    result[
"RECORD"] = wxString::Format( 
"%d", recordId );
 
 4590                    result[
"OWNERPARTID"] = wxString::Format( 
"%d",  binreader.
ReadInt16() );
 
 4591                    result[
"OWNERPARTDISPLAYMODE"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4592                    result[
"SYMBOL_INNEREDGE"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4593                    result[
"SYMBOL_OUTEREDGE"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4594                    result[
"SYMBOL_INNER"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4595                    result[
"SYMBOL_OUTER"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4598                    result[
"ELECTRICAL"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4599                    result[
"PINCONGLOMERATE"] = wxString::Format( 
"%d",  binreader.
ReadByte() );
 
 4600                    result[
"PINLENGTH"] = wxString::Format( 
"%d",  binreader.
ReadInt16() );
 
 4601                    result[
"LOCATION.X"] = wxString::Format( 
"%d",  binreader.
ReadInt16() );
 
 4602                    result[
"LOCATION.Y"] = wxString::Format( 
"%d",  binreader.
ReadInt16() );
 
 4608                    if( 
auto it = pinFracs.find( pin_index ); it != pinFracs.end() )
 
 4610                        result[
"LOCATION.X_FRAC"] = wxString::Format( 
"%d", it->second.x_frac );
 
 4611                        result[
"LOCATION.Y_FRAC"] = wxString::Format( 
"%d", it->second.y_frac );
 
 4612                        result[
"PINLENGTH_FRAC"] = wxString::Format( 
"%d", it->second.len_frac );
 
 4616                    std::vector<std::string> partSeqSplit = 
split( partSeq, 
"|" );
 
 4618                    if( partSeqSplit.size() == 3 )
 
 4620                        result[
"PART"] = partSeqSplit[0];
 
 4621                        result[
"SEQ"] = partSeqSplit[2];
 
 4629            std::map<wxString, wxString> properties = reader.
ReadProperties( handleBinaryPinLambda );
 
 4631            if( properties.empty() )
 
 4680                m_errorMessages.emplace( wxString::Format( 
_( 
"Unknown or unexpected record id %d found in %s." ),
 
 4694        for( 
size_t ii = 0; ii < symbols.size(); ii++ )
 
 4702            if( valField.
GetText().IsEmpty() )
 
 4705            if( symbols.size() == 1 )
 
 4708                ret[wxString::Format( 
"%s (Altium Display %zd)", 
name, ii + 1 )] = symbol;
 
 
 4718    wxFileName fn( aLibraryPath );
 
 4720    if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
 
 4721        return fn.GetModificationTime().GetValue().GetValue();
 
 
 4728                                         const std::map<std::string, UTF8>* aProperties )
 
 4741    std::vector<std::unique_ptr<ALTIUM_COMPOUND_FILE>> compoundFiles;
 
 4743    wxFileName fileName( aLibraryPath );
 
 4748        if( aLibraryPath.Lower().EndsWith( wxS( 
".schlib" ) ) )
 
 4752            compoundFiles.push_back( std::make_unique<ALTIUM_COMPOUND_FILE>( aLibraryPath ) );
 
 4754        else if( aLibraryPath.Lower().EndsWith( wxS( 
".intlib" ) ) )
 
 4758            std::unique_ptr<ALTIUM_COMPOUND_FILE> intCom = std::make_unique<ALTIUM_COMPOUND_FILE>( aLibraryPath );
 
 4760            std::map<wxString, const CFB::COMPOUND_FILE_ENTRY*> schLibFiles = intCom->EnumDir( 
L"SchLib" );
 
 4762            for( 
const auto& [schLibName, cfe] : schLibFiles )
 
 4764                std::unique_ptr<ALTIUM_COMPOUND_FILE> decodedStream = std::make_unique<ALTIUM_COMPOUND_FILE>();
 
 4766                if( intCom->DecodeIntLibStream( *cfe, decodedStream.get() ) )
 
 4767                    compoundFiles.emplace_back( std::move( decodedStream ) );
 
 4773        for( 
const std::unique_ptr<ALTIUM_COMPOUND_FILE>& altiumSchFilePtr : compoundFiles )
 
 4776            cacheMapRef.insert( parsed.begin(), parsed.end() );
 
 4781    catch( 
const CFB::CFBException& exception )
 
 4785    catch( 
const std::exception& exc )
 
 4787        wxFAIL_MSG( wxString::Format( wxT( 
"Unhandled exception in Altium schematic parsers: %s." ),
 
 
 4795                                    std::vector<int>& aFontSizes )
 
 4797    const CFB::COMPOUND_FILE_ENTRY* file = aAltiumSchFile.
FindStream( { 
"FileHeader" } );
 
 4799    if( file == 
nullptr )
 
 4807    std::map<wxString, wxString> properties = reader.
ReadProperties();
 
 4811    if( libtype.CmpNoCase( 
"Protel for Windows - Schematic Library Editor Binary File Version 5.0" ) )
 
 4812        THROW_IO_ERROR( 
_( 
"Expected Altium Schematic Library file version 5.0" ) );
 
 4814    for( 
auto& [key, value] : properties )
 
 4816        wxString upperKey = key.Upper();
 
 4819        if( upperKey.StartsWith( 
"SIZE", &remaining ) )
 
 4821            if( !remaining.empty() )
 
 4823                int ind = wxAtoi( remaining );
 
 4825                if( 
static_cast<int>( aFontSizes.size() ) < ind )
 
 4826                    aFontSizes.resize( ind );
 
 4829                int scaled = 
schIUScale.MilsToIU( wxAtoi( value ) * 72.0 / 10.0 );
 
 4830                aFontSizes[ind - 1] = scaled;
 
 
 4838                                          const std::map<std::string, UTF8>* aProperties,
 
 4839                                          std::function<
void(
const wxString&, 
LIB_SYMBOL*)> aInserter )
 
 4843    bool powerSymbolsOnly = ( aProperties &&
 
 4850        for( 
auto& [libnameStr, libSymbol] : it->second )
 
 4852            if( powerSymbolsOnly && !libSymbol->IsPower() )
 
 4855            aInserter( libnameStr, libSymbol );
 
 
 4862                                        const std::map<std::string, UTF8>* aProperties )
 
 4867                              aSymbolNameList.Add( aStr );
 
 
 4873                                        const wxString& aLibraryPath,
 
 4874                                        const std::map<std::string, UTF8>* aProperties )
 
 4879                              aSymbolList.emplace_back( aSymbol );
 
 
 4885                                       const std::map<std::string, UTF8>* aProperties )
 
 4893        auto it2 = it->second.find( aAliasName );
 
 4895        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
 
constexpr double ARC_LOW_DEF_MM
 
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
 
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
 
A base class for most all the KiCad significant classes used in schematics and boards.
 
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)
 
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.
 
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, 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.
 
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 FixupDrawItems()
This function finds the filled draw items that are covering up smaller draw items and replaces their ...
 
wxString GetName() const override
 
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
 
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.
 
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.
 
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
 
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 void SetCustomHeightMils(double aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
 
virtual const wxString GetProjectPath() const
Return the full path of the project.
 
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)
Report a string with a given severity.
 
Holds all the data relating to one schematic.
 
PROJECT & Project() 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 SetNameShown(bool aShown=true)
 
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)
 
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)
 
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)
 
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
 
SCH_IO(const wxString &aName)
 
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.
 
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.
 
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
 
void push_back(SCH_SHEET *aSheet)
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.
 
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
 
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
 
static const char * PropPowerSymsOnly
 
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
 
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
 
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.
 
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
 
@ 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)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
 
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)
 
@ PT_INPUT
usual pin input: must be connected
 
@ PT_TRISTATE
tri state bus pin
 
@ PT_BIDI
input or output (like port for a microprocessor)
 
@ PT_OPENEMITTER
pin type open emitter
 
@ PT_OPENCOLLECTOR
pin type open collector
 
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
 
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
 
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
 
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
 
@ PIN_RIGHT
The pin extends rightwards from the connection point.
 
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
 
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
 
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
 
int m_primaryConnectionPosition
 
ASCH_SHEET_ENTRY_SIDE m_harnessConnectorSide
 
std::vector< HARNESS_PORT > m_ports
 
A simple container for sheet instance information.
 
@ USER
The field ID hasn't been set yet; field is invalid.
 
@ INTERSHEET_REFS
Global label cross-reference page numbers.
 
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
 
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
 
@ REFERENCE
Field Reference of part, i.e. "IC21".
 
@ VALUE
Field Value of part, i.e. "3.3K".
 
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
 
wxString result
Test unit parsing edge cases and error handling.
 
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.