diff --git a/common/plugins/altium/altium_parser.cpp b/common/plugins/altium/altium_parser.cpp index a6bc4f7568..4fbe8215ab 100644 --- a/common/plugins/altium/altium_parser.cpp +++ b/common/plugins/altium/altium_parser.cpp @@ -193,22 +193,21 @@ int32_t ALTIUM_PARSER::ConvertToKicadUnit( const double aValue ) } -int ALTIUM_PARSER::PropertiesReadInt( const std::map& aProperties, - const wxString& aKey, int aDefault ) +int ALTIUM_PARSER::ReadInt( const std::map& aProps, const wxString& aKey, + int aDefault ) { - const std::map::const_iterator& value = aProperties.find( aKey ); - return value == aProperties.end() ? aDefault : wxAtoi( value->second ); + const std::map::const_iterator& value = aProps.find( aKey ); + return value == aProps.end() ? aDefault : wxAtoi( value->second ); } -double ALTIUM_PARSER::PropertiesReadDouble( const std::map& aProperties, - const wxString& aKey, double aDefault ) +double ALTIUM_PARSER::ReadDouble( const std::map& aProps, const wxString& aKey, + double aDefault ) { - const std::map::const_iterator& value = aProperties.find( aKey ); - if( value == aProperties.end() ) - { + const std::map::const_iterator& value = aProps.find( aKey ); + + if( value == aProps.end() ) return aDefault; - } // Locale independent str -> double conversation std::istringstream istr( (const char*) value->second.mb_str() ); @@ -220,21 +219,22 @@ double ALTIUM_PARSER::PropertiesReadDouble( const std::map& } -bool ALTIUM_PARSER::PropertiesReadBool( const std::map& aProperties, - const wxString& aKey, bool aDefault ) +bool ALTIUM_PARSER::ReadBool( const std::map& aProps, const wxString& aKey, + bool aDefault ) { - const std::map::const_iterator& value = aProperties.find( aKey ); - if( value == aProperties.end() ) + const std::map::const_iterator& value = aProps.find( aKey ); + + if( value == aProps.end() ) return aDefault; else return value->second == "T" || value->second == "TRUE"; } -int32_t ALTIUM_PARSER::PropertiesReadKicadUnit( const std::map& aProperties, - const wxString& aKey, const wxString& aDefault ) +int32_t ALTIUM_PARSER::ReadKicadUnit( const std::map& aProps, + const wxString& aKey, const wxString& aDefault ) { - const wxString& value = PropertiesReadString( aProperties, aKey, aDefault ); + const wxString& value = ReadString( aProps, aKey, aDefault ); wxString prefix; @@ -256,17 +256,17 @@ int32_t ALTIUM_PARSER::PropertiesReadKicadUnit( const std::map& aProperties, - const wxString& aKey, const wxString& aDefault ) +wxString ALTIUM_PARSER::ReadString( const std::map& aProps, + const wxString& aKey, const wxString& aDefault ) { - const auto& utf8Value = aProperties.find( wxString( "%UTF8%" ) + aKey ); + const auto& utf8Value = aProps.find( wxString( "%UTF8%" ) + aKey ); - if( utf8Value != aProperties.end() ) + if( utf8Value != aProps.end() ) return utf8Value->second; - const auto& value = aProperties.find( aKey ); + const auto& value = aProps.find( aKey ); - if( value != aProperties.end() ) + if( value != aProps.end() ) return value->second; return aDefault; diff --git a/common/plugins/altium/altium_parser.h b/common/plugins/altium/altium_parser.h index c940541c34..8b025e7509 100644 --- a/common/plugins/altium/altium_parser.h +++ b/common/plugins/altium/altium_parser.h @@ -139,20 +139,20 @@ public: static int32_t ConvertToKicadUnit( const double aValue ); - static int PropertiesReadInt( const std::map& aProperties, - const wxString& aKey, int aDefault ); + static int ReadInt( const std::map& aProps, + const wxString& aKey, int aDefault ); - static double PropertiesReadDouble( const std::map& aProperties, - const wxString& aKey, double aDefault ); + static double ReadDouble( const std::map& aProps, + const wxString& aKey, double aDefault ); - static bool PropertiesReadBool( const std::map& aProperties, - const wxString& aKey, bool aDefault ); + static bool ReadBool( const std::map& aProps, + const wxString& aKey, bool aDefault ); - static int32_t PropertiesReadKicadUnit( const std::map& aProperties, - const wxString& aKey, const wxString& aDefault ); + static int32_t ReadKicadUnit( const std::map& aProps, + const wxString& aKey, const wxString& aDefault ); - static wxString PropertiesReadString( const std::map& aProperties, - const wxString& aKey, const wxString& aDefault ); + static wxString ReadString( const std::map& aProps, + const wxString& aKey, const wxString& aDefault ); void Skip( size_t aLength ) { diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.cpp b/eeschema/sch_plugins/altium/altium_parser_sch.cpp index 9b9b0fc630..bd52bf597c 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.cpp +++ b/eeschema/sch_plugins/altium/altium_parser_sch.cpp @@ -34,9 +34,9 @@ #include "sch_plugins/altium/altium_parser_sch.h" -ALTIUM_SCH_RECORD PropertiesReadRecord( const std::map& aProperties ) +ALTIUM_SCH_RECORD ReadRecord( const std::map& aProps ) { - int recordId = ALTIUM_PARSER::PropertiesReadInt( aProperties, "RECORD", 0 ); + int recordId = ALTIUM_PARSER::ReadInt( aProps, "RECORD", 0 ); return static_cast( recordId ); } @@ -47,44 +47,42 @@ constexpr int Altium2KiCadUnit( const int val, const int frac ) } -int PropertiesReadKiCadUnitFrac( const std::map& aProperties, - const wxString& aKey ) +int ReadKiCadUnitFrac( const std::map& aProps, const wxString& aKey ) { // a unit is stored using two fields, denoting the size in mils and a fraction size - int key = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, 0 ); - int keyFrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey + "_FRAC", 0 ); + int key = ALTIUM_PARSER::ReadInt( aProps, aKey, 0 ); + int keyFrac = ALTIUM_PARSER::ReadInt( aProps, aKey + "_FRAC", 0 ); return Altium2KiCadUnit( key, keyFrac ); } -int PropertiesReadKiCadUnitFrac1( const std::map& aProperties, - const wxString& aKey ) +int ReadKiCadUnitFrac1( const std::map& aProps, const wxString& aKey ) { // a unit is stored using two fields, denoting the size in mils and a fraction size // Dunno why Altium invents different units for the same purpose - int key = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, 0 ); - int keyFrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey + "_FRAC1", 0 ); + int key = ALTIUM_PARSER::ReadInt( aProps, aKey, 0 ); + int keyFrac = ALTIUM_PARSER::ReadInt( aProps, aKey + "_FRAC1", 0 ); return Altium2KiCadUnit( key * 10, keyFrac ); } -int PropertiesReadOwnerIndex( const std::map& aProperties ) +int ReadOwnerIndex( const std::map& aProperties ) { - return ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE ); + return ALTIUM_PARSER::ReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE ); } -int PropertiesReadOwnerPartId( const std::map& aProperties ) +int ReadOwnerPartId( const std::map& aProperties ) { - return ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE ); + return ALTIUM_PARSER::ReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE ); } template -T PropertiesReadEnum( const std::map& aProperties, const wxString& aKey, - int aLower, int aUpper, T aDefault ) +T ReadEnum( const std::map& aProps, const wxString& aKey, int aLower, + int aUpper, T aDefault ) { - int value = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, static_cast( aDefault ) ); + int value = ALTIUM_PARSER::ReadInt( aProps, aKey, static_cast( aDefault )); if( value < aLower || value > aUpper ) return aDefault; @@ -101,79 +99,75 @@ ASCH_STORAGE_FILE::ASCH_STORAGE_FILE( ALTIUM_PARSER& aReader ) data = aReader.ReadVector( dataSize ); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Storage stream was not parsed correctly" ); - } } -ASCH_SYMBOL::ASCH_SYMBOL( const std::map& aProperties ) +ASCH_SYMBOL::ASCH_SYMBOL( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::COMPONENT ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::COMPONENT ); - currentpartid = ALTIUM_PARSER::PropertiesReadInt( aProperties, "CURRENTPARTID", - ALTIUM_COMPONENT_NONE ); - libreference = ALTIUM_PARSER::PropertiesReadString( aProperties, "LIBREFERENCE", "" ); - sourcelibraryname = ALTIUM_PARSER::PropertiesReadString( aProperties, "SOURCELIBRARYNAME", "" ); - componentdescription = ALTIUM_PARSER::PropertiesReadString( aProperties, "COMPONENTDESCRIPTION", - "" ); + currentpartid = ALTIUM_PARSER::ReadInt( aProps, "CURRENTPARTID", ALTIUM_COMPONENT_NONE ); + libreference = ALTIUM_PARSER::ReadString( aProps, "LIBREFERENCE", "" ); + sourcelibraryname = ALTIUM_PARSER::ReadString( aProps, "SOURCELIBRARYNAME", "" ); + componentdescription = ALTIUM_PARSER::ReadString( aProps, "COMPONENTDESCRIPTION", "" ); - orientation = ALTIUM_PARSER::PropertiesReadInt( aProperties, "ORIENTATION", 0 ); - isMirrored = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISMIRRORED", false ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + orientation = ALTIUM_PARSER::ReadInt( aProps, "ORIENTATION", 0 ); + isMirrored = ALTIUM_PARSER::ReadBool( aProps, "ISMIRRORED", false ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - partcount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PARTCOUNT", 0 ); - displaymodecount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "DISPLAYMODECOUNT", 0 ); - displaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "DISPLAYMODE", 0 ); + partcount = ALTIUM_PARSER::ReadInt( aProps, "PARTCOUNT", 0 ); + displaymodecount = ALTIUM_PARSER::ReadInt( aProps, "DISPLAYMODECOUNT", 0 ); + displaymode = ALTIUM_PARSER::ReadInt( aProps, "DISPLAYMODE", 0 ); } -ASCH_PIN::ASCH_PIN( const std::map& aProperties ) +ASCH_PIN::ASCH_PIN( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::PIN ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PIN ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - name = ALTIUM_PARSER::PropertiesReadString( aProperties, "NAME", "" ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); - designator = ALTIUM_PARSER::PropertiesReadString( aProperties, "DESIGNATOR", "" ); + name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); + designator = ALTIUM_PARSER::ReadString( aProps, "DESIGNATOR", "" ); - int symbolOuterInt = ALTIUM_PARSER::PropertiesReadInt( aProperties, "SYMBOL_OUTER", 0 ); + int symbolOuterInt = ALTIUM_PARSER::ReadInt( aProps, "SYMBOL_OUTER", 0 ); symbolOuter = static_cast( symbolOuterInt ); - int symbolInnerInt = ALTIUM_PARSER::PropertiesReadInt( aProperties, "SYMBOL_INNER", 0 ); + int symbolInnerInt = ALTIUM_PARSER::ReadInt( aProps, "SYMBOL_INNER", 0 ); symbolInner = static_cast( symbolInnerInt ); - int symbolOuterEdgeInt = ALTIUM_PARSER::PropertiesReadInt( aProperties, "SYMBOL_OUTEREDGE", 0 ); + int symbolOuterEdgeInt = ALTIUM_PARSER::ReadInt( aProps, "SYMBOL_OUTEREDGE", 0 ); symbolOuterEdge = ( symbolOuterEdgeInt == 0 || symbolOuterEdgeInt == 1 || symbolOuterEdgeInt == 4 || symbolOuterEdgeInt == 17 ) ? static_cast( symbolOuterEdgeInt ) : ASCH_PIN_SYMBOL_OUTEREDGE::NO_SYMBOL; - int symbolInnerEdgeInt = ALTIUM_PARSER::PropertiesReadInt( aProperties, "SYMBOL_INNEREDGE", 0 ); + int symbolInnerEdgeInt = ALTIUM_PARSER::ReadInt( aProps, "SYMBOL_INNEREDGE", 0 ); symbolInnerEdge = ( symbolInnerEdgeInt == 0 || symbolInnerEdgeInt == 3 ) ? static_cast( symbolInnerEdgeInt ) : ASCH_PIN_SYMBOL_INNEREDGE::NO_SYMBOL; - electrical = PropertiesReadEnum( - aProperties, "ELECTRICAL", 0, 7, ASCH_PIN_ELECTRICAL::INPUT ); + electrical = ReadEnum( aProps, "ELECTRICAL", 0, 7, + ASCH_PIN_ELECTRICAL::INPUT ); - int pinconglomerate = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PINCONGLOMERATE", 0 ); + int pinconglomerate = ALTIUM_PARSER::ReadInt( aProps, "PINCONGLOMERATE", 0 ); orientation = static_cast( pinconglomerate & 0x03 ); showPinName = ( pinconglomerate & 0x08 ) != 0; showDesignator = ( pinconglomerate & 0x10 ) != 0; - int x = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATION.X", 0 ); - int xfrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATION.X_FRAC", 0 ); - int y = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATION.Y", 0 ); - int yfrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATION.Y_FRAC", 0 ); + int x = ALTIUM_PARSER::ReadInt( aProps, "LOCATION.X", 0 ); + int xfrac = ALTIUM_PARSER::ReadInt( aProps, "LOCATION.X_FRAC", 0 ); + int y = ALTIUM_PARSER::ReadInt( aProps, "LOCATION.Y", 0 ); + int yfrac = ALTIUM_PARSER::ReadInt( aProps, "LOCATION.Y_FRAC", 0 ); location = wxPoint( Altium2KiCadUnit( x, xfrac ), -Altium2KiCadUnit( y, yfrac ) ); - int p = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PINLENGTH", 0 ); - int pfrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PINLENGTH_FRAC", 0 ); + int p = ALTIUM_PARSER::ReadInt( aProps, "PINLENGTH", 0 ); + int pfrac = ALTIUM_PARSER::ReadInt( aProps, "PINLENGTH_FRAC", 0 ); pinlength = Altium2KiCadUnit( p, pfrac ); // this code calculates the location as required by KiCad without rounding error attached @@ -204,416 +198,403 @@ ASCH_PIN::ASCH_PIN( const std::map& aProperties ) wxLogWarning( "Pin has unexpected orientation" ); break; } - kicadLocation = wxPoint( - Altium2KiCadUnit( kicadX, kicadXfrac ), -Altium2KiCadUnit( kicadY, kicadYfrac ) ); + + kicadLocation = wxPoint( Altium2KiCadUnit( kicadX, kicadXfrac ), + -Altium2KiCadUnit( kicadY, kicadYfrac ) ); } -ASCH_LABEL::ASCH_LABEL( const std::map& aProperties ) +ASCH_LABEL::ASCH_LABEL( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::LABEL ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LABEL ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); - fontId = ALTIUM_PARSER::PropertiesReadInt( aProperties, "FONTID", 0 ); - isMirrored = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISMIRRORED", false ); + fontId = ALTIUM_PARSER::ReadInt( aProps, "FONTID", 0 ); + isMirrored = ALTIUM_PARSER::ReadBool( aProps, "ISMIRRORED", false ); - justification = PropertiesReadEnum( - aProperties, "JUSTIFICATION", 0, 8, ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT ); + justification = ReadEnum( aProps, "JUSTIFICATION", 0, 8, + ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT ); } -ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map& aProperties ) +ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NOTE - || PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::TEXT_FRAME ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NOTE + || ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEXT_FRAME ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - size = wxSize( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ) - location.x, - -PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) - location.y ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + size = wxSize( ReadKiCadUnitFrac( aProps, "CORNER.X" ) - location.x, + -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) - location.y ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); text.Replace( "~1", "\n", true ); - fontId = ALTIUM_PARSER::PropertiesReadInt( aProperties, "FONTID", 0 ); - isWordWrapped = ALTIUM_PARSER::PropertiesReadBool( aProperties, "WORDWRAP", false ); - border = ALTIUM_PARSER::PropertiesReadBool( aProperties, "SHOWBORDER", false ); - textMargin = PropertiesReadKiCadUnitFrac( aProperties, "TEXTMARGIN" ); - areaColor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 ); + fontId = ALTIUM_PARSER::ReadInt( aProps, "FONTID", 0 ); + isWordWrapped = ALTIUM_PARSER::ReadBool( aProps, "WORDWRAP", false ); + border = ALTIUM_PARSER::ReadBool( aProps, "SHOWBORDER", false ); + textMargin = ReadKiCadUnitFrac( aProps, "TEXTMARGIN" ); + areaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 ); - alignment = PropertiesReadEnum( - aProperties, "ALIGNMENT", 1, 3, ASCH_TEXT_FRAME_ALIGNMENT::LEFT ); + alignment = ReadEnum( aProps, "ALIGNMENT", 1, 3, + ASCH_TEXT_FRAME_ALIGNMENT::LEFT ); } ASCH_NOTE::ASCH_NOTE( const std::map& aProperties ) : ASCH_TEXT_FRAME( aProperties ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NOTE ); + wxASSERT( ReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NOTE ); - author = ALTIUM_PARSER::PropertiesReadString( aProperties, "AUTHOR", "" ); + author = ALTIUM_PARSER::ReadString( aProperties, "AUTHOR", "" ); } -ASCH_BEZIER::ASCH_BEZIER( const std::map& aProperties ) +ASCH_BEZIER::ASCH_BEZIER( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::BEZIER ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BEZIER ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - int locationCount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 ); + int locationCount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationCount; i++ ) { const wxString si = std::to_string( i ); - points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ), - -PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) ); + points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ), + -ReadKiCadUnitFrac( aProps, "Y" + si ) ); } - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); } -ASCH_POLYLINE::ASCH_POLYLINE( const std::map& aProperties ) +ASCH_POLYLINE::ASCH_POLYLINE( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::POLYLINE ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYLINE ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - int locationCount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 ); + int locationCount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationCount; i++ ) { const wxString si = std::to_string( i ); - points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ), - -PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) ); + points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ), + -ReadKiCadUnitFrac( aProps, "Y" + si ) ); } - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); - int linestyleVar = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LINESTYLEEXT", 0 ); - linestyleVar = ALTIUM_PARSER::PropertiesReadInt( - aProperties, "LINESTYLE", linestyleVar ); // overwrite if present - linestyle = linestyleVar >= 0 && linestyleVar <= 3 ? - static_cast( linestyleVar ) : - ASCH_POLYLINE_LINESTYLE::SOLID; + int linestyleVar = ALTIUM_PARSER::ReadInt( aProps, "LINESTYLEEXT", 0 ); + linestyleVar = ALTIUM_PARSER::ReadInt( aProps, "LINESTYLE", linestyleVar ); // overwrite if present + linestyle = linestyleVar >= 0 && linestyleVar <= 3 ? + static_cast( linestyleVar ) : + ASCH_POLYLINE_LINESTYLE::SOLID; } -ASCH_POLYGON::ASCH_POLYGON( const std::map& aProperties ) +ASCH_POLYGON::ASCH_POLYGON( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::POLYGON ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYGON ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - int locationCount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 ); + int locationCount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationCount; i++ ) { const wxString si = std::to_string( i ); - points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ), - -PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) ); + points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ), + -ReadKiCadUnitFrac( aProps, "Y" + si ) ); } - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); - isSolid = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISSOLID", false ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); + isSolid = ALTIUM_PARSER::ReadBool( aProps, "ISSOLID", false ); - color = ALTIUM_PARSER::PropertiesReadInt( aProperties, "COLOR", 0 ); - areacolor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 ); + color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 ); + areacolor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 ); } -ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map& aProperties ) +ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::ROUND_RECTANGLE ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ROUND_RECTANGLE ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - bottomLeft = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - topRight = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) ); + bottomLeft = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + topRight = wxPoint( ReadKiCadUnitFrac( aProps, "CORNER.X" ), + -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) ); - topRight = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNERXRADIUS" ), - -PropertiesReadKiCadUnitFrac( aProperties, "CORNERYRADIUS" ) ); + topRight = wxPoint( ReadKiCadUnitFrac( aProps, "CORNERXRADIUS" ), + -ReadKiCadUnitFrac( aProps, "CORNERYRADIUS" ) ); - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); - isSolid = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISSOLID", false ); - isTransparent = ALTIUM_PARSER::PropertiesReadBool( aProperties, "TRANSPARENT", false ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); + isSolid = ALTIUM_PARSER::ReadBool( aProps, "ISSOLID", false ); + isTransparent = ALTIUM_PARSER::ReadBool( aProps, "TRANSPARENT", false ); - color = ALTIUM_PARSER::PropertiesReadInt( aProperties, "COLOR", 0 ); - areacolor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 ); + color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 ); + areacolor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 ); } -ASCH_ARC::ASCH_ARC( const std::map& aProperties ) +ASCH_ARC::ASCH_ARC( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::ARC ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ARC ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - center = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - radius = PropertiesReadKiCadUnitFrac( aProperties, "RADIUS" ); + center = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + radius = ReadKiCadUnitFrac( aProps, "RADIUS" ); - startAngle = ALTIUM_PARSER::PropertiesReadDouble( aProperties, "STARTANGLE", 0 ); - endAngle = ALTIUM_PARSER::PropertiesReadDouble( aProperties, "ENDANGLE", 0 ); + startAngle = ALTIUM_PARSER::ReadDouble( aProps, "STARTANGLE", 0 ); + endAngle = ALTIUM_PARSER::ReadDouble( aProps, "ENDANGLE", 0 ); - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); } -ASCH_LINE::ASCH_LINE( const std::map& aProperties ) +ASCH_LINE::ASCH_LINE( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::LINE ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LINE ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - point1 = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - point2 = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) ); + point1 = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + point2 = wxPoint( ReadKiCadUnitFrac( aProps, "CORNER.X" ), + -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) ); - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); } -ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map& aProperties ) +ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::RECTANGLE ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::RECTANGLE ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); - ownerpartdisplaymode = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTDISPLAYMODE", 0 ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); + ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 ); - bottomLeft = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - topRight = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) ); + bottomLeft = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + topRight = wxPoint( ReadKiCadUnitFrac( aProps, "CORNER.X" ), + -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) ); - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); - isSolid = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISSOLID", false ); - isTransparent = ALTIUM_PARSER::PropertiesReadBool( aProperties, "TRANSPARENT", false ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); + isSolid = ALTIUM_PARSER::ReadBool( aProps, "ISSOLID", false ); + isTransparent = ALTIUM_PARSER::ReadBool( aProps, "TRANSPARENT", false ); - color = ALTIUM_PARSER::PropertiesReadInt( aProperties, "COLOR", 0 ); - areacolor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 ); + color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 ); + areacolor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 ); } -ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map& aProperties ) +ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET_SYMBOL ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_SYMBOL ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - size = wxSize( PropertiesReadKiCadUnitFrac( aProperties, "XSIZE" ), - PropertiesReadKiCadUnitFrac( aProperties, "YSIZE" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + size = wxSize( ReadKiCadUnitFrac( aProps, "XSIZE" ), + ReadKiCadUnitFrac( aProps, "YSIZE" ) ); - isSolid = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISSOLID", false ); + isSolid = ALTIUM_PARSER::ReadBool( aProps, "ISSOLID", false ); - color = ALTIUM_PARSER::PropertiesReadInt( aProperties, "COLOR", 0 ); - areacolor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 ); + color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 ); + areacolor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 ); } -ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map& aProperties ) +ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET_ENTRY ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_ENTRY ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); // some magic, because it stores those infos in a different unit?? - distanceFromTop = PropertiesReadKiCadUnitFrac1( aProperties, "DISTANCEFROMTOP" ); + distanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" ); - side = PropertiesReadEnum( - aProperties, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT ); + side = ReadEnum( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT ); - name = ALTIUM_PARSER::PropertiesReadString( aProperties, "NAME", "" ); + name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" ); - iotype = PropertiesReadEnum( - aProperties, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED ); - style = PropertiesReadEnum( - aProperties, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL ); + iotype = ReadEnum( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED ); + style = ReadEnum( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL ); } -ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map& aProperties ) +ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::POWER_PORT ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POWER_PORT ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerpartid = ReadOwnerPartId( aProps ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - orientation = PropertiesReadEnum( - aProperties, "ORIENTATION", 0, 3, ASCH_RECORD_ORIENTATION::RIGHTWARDS ); + orientation = ReadEnum( aProps, "ORIENTATION", 0, 3, + ASCH_RECORD_ORIENTATION::RIGHTWARDS ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); - showNetName = ALTIUM_PARSER::PropertiesReadBool( aProperties, "SHOWNETNAME", true ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); + showNetName = ALTIUM_PARSER::ReadBool( aProps, "SHOWNETNAME", true ); - style = PropertiesReadEnum( - aProperties, "STYLE", 0, 10, ASCH_POWER_PORT_STYLE::CIRCLE ); + style = ReadEnum( aProps, "STYLE", 0, 10, + ASCH_POWER_PORT_STYLE::CIRCLE ); } -ASCH_PORT::ASCH_PORT( const std::map& aProperties ) +ASCH_PORT::ASCH_PORT( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::PORT ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PORT ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerpartid = ReadOwnerPartId( aProps ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - name = ALTIUM_PARSER::PropertiesReadString( aProperties, "NAME", "" ); - harnessType = ALTIUM_PARSER::PropertiesReadString( aProperties, "HARNESSTYPE", "" ); + name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" ); + harnessType = ALTIUM_PARSER::ReadString( aProps, "HARNESSTYPE", "" ); - width = PropertiesReadKiCadUnitFrac( aProperties, "WIDTH" ); - height = PropertiesReadKiCadUnitFrac( aProperties, "HEIGHT" ); + width = ReadKiCadUnitFrac( aProps, "WIDTH" ); + height = ReadKiCadUnitFrac( aProps, "HEIGHT" ); - iotype = PropertiesReadEnum( - aProperties, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED ); - style = PropertiesReadEnum( - aProperties, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL ); + iotype = ReadEnum( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED ); + style = ReadEnum( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL ); } -ASCH_NO_ERC::ASCH_NO_ERC( const std::map& aProperties ) +ASCH_NO_ERC::ASCH_NO_ERC( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NO_ERC ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NO_ERC ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - isActive = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISACTIVE", true ); - supressAll = ALTIUM_PARSER::PropertiesReadInt( aProperties, "SUPPRESSALL", true ); + isActive = ALTIUM_PARSER::ReadBool( aProps, "ISACTIVE", true ); + supressAll = ALTIUM_PARSER::ReadInt( aProps, "SUPPRESSALL", true ); } -ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map& aProperties ) +ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NET_LABEL ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NET_LABEL ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - orientation = PropertiesReadEnum( - aProperties, "ORIENTATION", 0, 3, ASCH_RECORD_ORIENTATION::RIGHTWARDS ); + orientation = ReadEnum( aProps, "ORIENTATION", 0, 3, + ASCH_RECORD_ORIENTATION::RIGHTWARDS ); } -ASCH_BUS::ASCH_BUS( const std::map& aProperties ) +ASCH_BUS::ASCH_BUS( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::BUS ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS ); - indexinsheet = ALTIUM_PARSER::PropertiesReadInt( aProperties, "INDEXINSHEET", 0 ); + indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 ); - int locationcount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 ); + int locationcount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationcount; i++ ) { const wxString si = std::to_string( i ); - points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ), - -PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) ); + points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ), + -ReadKiCadUnitFrac( aProps, "Y" + si ) ); } - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); } -ASCH_WIRE::ASCH_WIRE( const std::map& aProperties ) +ASCH_WIRE::ASCH_WIRE( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::WIRE ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::WIRE ); - /*std::cout << "-----------------------------------" << std::endl; - // debug - for( auto& property : aProperties ) - { - std::cout << " * '" << property.first << "' = '" << property.second << "'" - << std::endl; - }*/ + indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 ); - indexinsheet = ALTIUM_PARSER::PropertiesReadInt( aProperties, "INDEXINSHEET", 0 ); - - int locationcount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 ); + int locationcount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationcount; i++ ) { const wxString si = std::to_string( i ); - points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ), - -PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) ); + points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ), + -ReadKiCadUnitFrac( aProps, "Y" + si ) ); } - lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" ); + lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); } -ASCH_JUNCTION::ASCH_JUNCTION( const std::map& aProperties ) +ASCH_JUNCTION::ASCH_JUNCTION( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::JUNCTION ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::JUNCTION ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerpartid = ReadOwnerPartId( aProps ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); } -ASCH_IMAGE::ASCH_IMAGE( const std::map& aProperties ) +ASCH_IMAGE::ASCH_IMAGE( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMAGE ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMAGE ); - indexinsheet = ALTIUM_PARSER::PropertiesReadInt( aProperties, "INDEXINSHEET", 0 ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 ); + ownerpartid = ReadOwnerPartId( aProps ); - filename = ALTIUM_PARSER::PropertiesReadString( aProperties, "FILENAME", "" ); + filename = ALTIUM_PARSER::ReadString( aProps, "FILENAME", "" ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - corner = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + corner = wxPoint( ReadKiCadUnitFrac( aProps, "CORNER.X" ), + -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) ); - embedimage = ALTIUM_PARSER::PropertiesReadBool( aProperties, "EMBEDIMAGE", false ); - keepaspect = ALTIUM_PARSER::PropertiesReadBool( aProperties, "KEEPASPECT", false ); + embedimage = ALTIUM_PARSER::ReadBool( aProps, "EMBEDIMAGE", false ); + keepaspect = ALTIUM_PARSER::ReadBool( aProps, "KEEPASPECT", false ); } -ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map& aProperties, int aId ) +ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map& aProps, int aId ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET ); const wxString sid = std::to_string( aId ); - fontname = ALTIUM_PARSER::PropertiesReadString( aProperties, "FONTNAME" + sid, "" ); + fontname = ALTIUM_PARSER::ReadString( aProps, "FONTNAME" + sid, "" ); - size = PropertiesReadKiCadUnitFrac( aProperties, "SIZE" + sid ); - rotation = ALTIUM_PARSER::PropertiesReadInt( aProperties, "ROTATION" + sid, 0 ); + size = ReadKiCadUnitFrac( aProps, "SIZE" + sid ); + rotation = ALTIUM_PARSER::ReadInt( aProps, "ROTATION" + sid, 0 ); - italic = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ITALIC" + sid, false ); - bold = ALTIUM_PARSER::PropertiesReadBool( aProperties, "BOLD" + sid, false ); - underline = ALTIUM_PARSER::PropertiesReadBool( aProperties, "UNDERLINE" + sid, false ); + italic = ALTIUM_PARSER::ReadBool( aProps, "ITALIC" + sid, false ); + bold = ALTIUM_PARSER::ReadBool( aProps, "BOLD" + sid, false ); + underline = ALTIUM_PARSER::ReadBool( aProps, "UNDERLINE" + sid, false ); } wxPoint ASchSheetGetSize( ASCH_SHEET_SIZE aSheetSize ) @@ -644,126 +625,124 @@ wxPoint ASchSheetGetSize( ASCH_SHEET_SIZE aSheetSize ) } -ASCH_SHEET::ASCH_SHEET( const std::map& aProperties ) +ASCH_SHEET::ASCH_SHEET( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET ); - int fontidcount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "FONTIDCOUNT", 0 ); + int fontidcount = ALTIUM_PARSER::ReadInt( aProps, "FONTIDCOUNT", 0 ); for( int i = 1; i <= fontidcount; i++ ) - fonts.emplace_back( aProperties, i ); + fonts.emplace_back( aProps, i ); - sheetSize = PropertiesReadEnum( - aProperties, "SHEETSTYLE", 0, 17, ASCH_SHEET_SIZE::A4 ); - sheetOrientation = PropertiesReadEnum( - aProperties, "WORKSPACEORIENTATION", 0, 1, ASCH_SHEET_WORKSPACEORIENTATION::LANDSCAPE ); + sheetSize = ReadEnum( aProps, "SHEETSTYLE", 0, 17, ASCH_SHEET_SIZE::A4 ); + sheetOrientation = ReadEnum( + aProps, "WORKSPACEORIENTATION", 0, 1, ASCH_SHEET_WORKSPACEORIENTATION::LANDSCAPE ); } -ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map& aProperties ) +ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET_NAME ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_NAME ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); - orientation = PropertiesReadEnum( - aProperties, "ORIENTATION", 0, 3, ASCH_RECORD_ORIENTATION::RIGHTWARDS ); + orientation = ReadEnum( aProps, "ORIENTATION", 0, 3, + ASCH_RECORD_ORIENTATION::RIGHTWARDS ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - isHidden = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISHIDDEN", false ); + isHidden = ALTIUM_PARSER::ReadBool( aProps, "ISHIDDEN", false ); } -ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map& aProperties ) +ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::FILE_NAME ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::FILE_NAME ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); - orientation = PropertiesReadEnum( - aProperties, "ORIENTATION", 0, 3, ASCH_RECORD_ORIENTATION::RIGHTWARDS ); + orientation = ReadEnum( aProps, "ORIENTATION", 0, 3, + ASCH_RECORD_ORIENTATION::RIGHTWARDS ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - isHidden = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISHIDDEN", false ); + isHidden = ALTIUM_PARSER::ReadBool( aProps, "ISHIDDEN", false ); } -ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map& aProperties ) +ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::DESIGNATOR ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::DESIGNATOR ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); - name = ALTIUM_PARSER::PropertiesReadString( aProperties, "NAME", "" ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); - orientation = PropertiesReadEnum( - aProperties, "ORIENTATION", 0, 3, ASCH_RECORD_ORIENTATION::RIGHTWARDS ); + orientation = ReadEnum( aProps, "ORIENTATION", 0, 3, + ASCH_RECORD_ORIENTATION::RIGHTWARDS ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); } -ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map& aProperties ) +ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMPLEMENTATION ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION ); - ownerindex = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE ); - name = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELNAME", "" ); - type = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELTYPE", "" ); - libname = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELDATAFILE0", "" ); - isCurrent = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISCURRENT", false ); + ownerindex = ALTIUM_PARSER::ReadInt( aProps, "OWNERINDEX", ALTIUM_COMPONENT_NONE ); + name = ALTIUM_PARSER::ReadString( aProps, "MODELNAME", "" ); + type = ALTIUM_PARSER::ReadString( aProps, "MODELTYPE", "" ); + libname = ALTIUM_PARSER::ReadString( aProps, "MODELDATAFILE0", "" ); + isCurrent = ALTIUM_PARSER::ReadBool( aProps, "ISCURRENT", false ); } -ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map& aProperties ) +ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); } -ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map& aProperties ) +ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::BUS_ENTRY ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS_ENTRY ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); - corner = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); + corner = wxPoint( ReadKiCadUnitFrac( aProps, "CORNER.X" ), + -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) ); } -ASCH_PARAMETER::ASCH_PARAMETER( const std::map& aProperties ) +ASCH_PARAMETER::ASCH_PARAMETER( const std::map& aProps ) { - wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::PARAMETER ); + wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PARAMETER ); - ownerindex = PropertiesReadOwnerIndex( aProperties ); - ownerpartid = PropertiesReadOwnerPartId( aProperties ); + ownerindex = ReadOwnerIndex( aProps ); + ownerpartid = ReadOwnerPartId( aProps ); - location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ), - -PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) ); + location = wxPoint( ReadKiCadUnitFrac( aProps, "LOCATION.X" ), + -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) ); - orientation = PropertiesReadEnum( - aProperties, "ORIENTATION", 0, 3, ASCH_RECORD_ORIENTATION::RIGHTWARDS ); + orientation = ReadEnum( aProps, "ORIENTATION", 0, 3, + ASCH_RECORD_ORIENTATION::RIGHTWARDS ); - name = ALTIUM_PARSER::PropertiesReadString( aProperties, "NAME", "" ); - text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" ); + name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" ); + text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" ); - isHidden = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISHIDDEN", false ); - isMirrored = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISMIRRORED", false ); - isShowName = ALTIUM_PARSER::PropertiesReadBool( aProperties, "SHOWNAME", false ); + isHidden = ALTIUM_PARSER::ReadBool( aProps, "ISHIDDEN", false ); + isMirrored = ALTIUM_PARSER::ReadBool( aProps, "ISMIRRORED", false ); + isShowName = ALTIUM_PARSER::ReadBool( aProps, "SHOWNAME", false ); } diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.h b/eeschema/sch_plugins/altium/altium_parser_sch.h index 8f929400b2..7b99b54cc2 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.h +++ b/eeschema/sch_plugins/altium/altium_parser_sch.h @@ -121,7 +121,7 @@ struct ASCH_SYMBOL int displaymodecount; int displaymode; - explicit ASCH_SYMBOL( const std::map& aProperties ); + explicit ASCH_SYMBOL( const std::map& aProps ); }; @@ -216,7 +216,7 @@ struct ASCH_PIN bool showPinName; bool showDesignator; - explicit ASCH_PIN( const std::map& aProperties ); + explicit ASCH_PIN( const std::map& aProps ); }; @@ -258,7 +258,7 @@ struct ASCH_LABEL ASCH_LABEL_JUSTIFICATION justification; - explicit ASCH_LABEL( const std::map& aProperties ); + explicit ASCH_LABEL( const std::map& aProps ); }; @@ -277,7 +277,7 @@ struct ASCH_TEXT_FRAME ASCH_TEXT_FRAME_ALIGNMENT alignment; - explicit ASCH_TEXT_FRAME( const std::map& aProperties ); + explicit ASCH_TEXT_FRAME( const std::map& aProps ); }; @@ -299,7 +299,7 @@ struct ASCH_BEZIER int lineWidth; - explicit ASCH_BEZIER( const std::map& aProperties ); + explicit ASCH_BEZIER( const std::map& aProps ); }; @@ -324,7 +324,7 @@ struct ASCH_POLYLINE ASCH_POLYLINE_LINESTYLE linestyle; - explicit ASCH_POLYLINE( const std::map& aProperties ); + explicit ASCH_POLYLINE( const std::map& aProps ); }; @@ -342,7 +342,7 @@ struct ASCH_POLYGON int color; int areacolor; - explicit ASCH_POLYGON( const std::map& aProperties ); + explicit ASCH_POLYGON( const std::map& aProps ); }; @@ -364,7 +364,7 @@ struct ASCH_ROUND_RECTANGLE int color; int areacolor; - explicit ASCH_ROUND_RECTANGLE( const std::map& aProperties ); + explicit ASCH_ROUND_RECTANGLE( const std::map& aProps ); }; @@ -381,7 +381,7 @@ struct ASCH_ARC int lineWidth; - explicit ASCH_ARC( const std::map& aProperties ); + explicit ASCH_ARC( const std::map& aProps ); }; @@ -396,7 +396,7 @@ struct ASCH_LINE int lineWidth; - explicit ASCH_LINE( const std::map& aProperties ); + explicit ASCH_LINE( const std::map& aProps ); }; @@ -416,7 +416,7 @@ struct ASCH_RECTANGLE int color; int areacolor; - explicit ASCH_RECTANGLE( const std::map& aProperties ); + explicit ASCH_RECTANGLE( const std::map& aProps ); }; @@ -430,7 +430,7 @@ struct ASCH_SHEET_SYMBOL int color; int areacolor; - explicit ASCH_SHEET_SYMBOL( const std::map& aProperties ); + explicit ASCH_SHEET_SYMBOL( const std::map& aProps ); }; @@ -478,7 +478,7 @@ struct ASCH_SHEET_ENTRY wxString name; - explicit ASCH_SHEET_ENTRY( const std::map& aProperties ); + explicit ASCH_SHEET_ENTRY( const std::map& aProps ); }; @@ -511,7 +511,7 @@ struct ASCH_POWER_PORT ASCH_RECORD_ORIENTATION orientation; ASCH_POWER_PORT_STYLE style; - explicit ASCH_POWER_PORT( const std::map& aProperties ); + explicit ASCH_POWER_PORT( const std::map& aProps ); }; @@ -529,7 +529,7 @@ struct ASCH_PORT ASCH_PORT_IOTYPE iotype; ASCH_PORT_STYLE style; - explicit ASCH_PORT( const std::map& aProperties ); + explicit ASCH_PORT( const std::map& aProps ); }; @@ -540,7 +540,7 @@ struct ASCH_NO_ERC bool isActive; bool supressAll; - explicit ASCH_NO_ERC( const std::map& aProperties ); + explicit ASCH_NO_ERC( const std::map& aProps ); }; @@ -552,7 +552,7 @@ struct ASCH_NET_LABEL ASCH_RECORD_ORIENTATION orientation; - explicit ASCH_NET_LABEL( const std::map& aProperties ); + explicit ASCH_NET_LABEL( const std::map& aProps ); }; @@ -563,7 +563,7 @@ struct ASCH_BUS std::vector points; - explicit ASCH_BUS( const std::map& aProperties ); + explicit ASCH_BUS( const std::map& aProps ); }; @@ -574,7 +574,7 @@ struct ASCH_WIRE std::vector points; - explicit ASCH_WIRE( const std::map& aProperties ); + explicit ASCH_WIRE( const std::map& aProps ); }; @@ -584,7 +584,7 @@ struct ASCH_JUNCTION wxPoint location; - explicit ASCH_JUNCTION( const std::map& aProperties ); + explicit ASCH_JUNCTION( const std::map& aProps ); }; @@ -600,7 +600,7 @@ struct ASCH_IMAGE bool embedimage; bool keepaspect; - explicit ASCH_IMAGE( const std::map& aProperties ); + explicit ASCH_IMAGE( const std::map& aProps ); }; @@ -615,7 +615,7 @@ struct ASCH_SHEET_FONT bool bold; bool underline; - explicit ASCH_SHEET_FONT( const std::map& aProperties, int aId ); + explicit ASCH_SHEET_FONT( const std::map& aProps, int aId ); }; @@ -660,7 +660,7 @@ struct ASCH_SHEET ASCH_SHEET_SIZE sheetSize; ASCH_SHEET_WORKSPACEORIENTATION sheetOrientation; - explicit ASCH_SHEET( const std::map& aProperties ); + explicit ASCH_SHEET( const std::map& aProps ); }; @@ -676,7 +676,7 @@ struct ASCH_SHEET_NAME bool isHidden; - explicit ASCH_SHEET_NAME( const std::map& aProperties ); + explicit ASCH_SHEET_NAME( const std::map& aProps ); }; @@ -692,7 +692,7 @@ struct ASCH_FILE_NAME bool isHidden; - explicit ASCH_FILE_NAME( const std::map& aProperties ); + explicit ASCH_FILE_NAME( const std::map& aProps ); }; @@ -707,7 +707,7 @@ struct ASCH_DESIGNATOR ASCH_RECORD_ORIENTATION orientation; wxPoint location; - explicit ASCH_DESIGNATOR( const std::map& aProperties ); + explicit ASCH_DESIGNATOR( const std::map& aProps ); }; @@ -721,14 +721,14 @@ struct ASCH_IMPLEMENTATION bool isCurrent; - explicit ASCH_IMPLEMENTATION( const std::map& aProperties ); + explicit ASCH_IMPLEMENTATION( const std::map& aProps ); }; struct ASCH_IMPLEMENTATION_LIST { int ownerindex; - explicit ASCH_IMPLEMENTATION_LIST( const std::map& aProperties ); + explicit ASCH_IMPLEMENTATION_LIST( const std::map& aProps ); }; @@ -737,7 +737,7 @@ struct ASCH_BUS_ENTRY wxPoint location; wxPoint corner; - explicit ASCH_BUS_ENTRY( const std::map& aProperties ); + explicit ASCH_BUS_ENTRY( const std::map& aProps ); }; @@ -756,7 +756,7 @@ struct ASCH_PARAMETER bool isMirrored; bool isShowName; - explicit ASCH_PARAMETER( const std::map& aProperties ); + explicit ASCH_PARAMETER( const std::map& aProps ); }; #endif //ALTIUM_PARSER_SCH_H diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index ae5d90edd2..775c0dc007 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -294,8 +294,8 @@ void SCH_ALTIUM_PLUGIN::ParseStorage( const CFB::CompoundFileReader& aReader ) ALTIUM_PARSER reader( aReader, file ); std::map properties = reader.ReadProperties(); - wxString header = ALTIUM_PARSER::PropertiesReadString( properties, "HEADER", "" ); - int weight = ALTIUM_PARSER::PropertiesReadInt( properties, "WEIGHT", 0 ); + wxString header = ALTIUM_PARSER::ReadString( properties, "HEADER", "" ); + int weight = ALTIUM_PARSER::ReadInt( properties, "WEIGHT", 0 ); if( weight < 0 ) THROW_IO_ERROR( "Storage weight is negative!" ); @@ -337,7 +337,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader { std::map properties = reader.ReadProperties(); - int recordId = ALTIUM_PARSER::PropertiesReadInt( properties, "RECORD", 0 ); + int recordId = ALTIUM_PARSER::ReadInt( properties, "RECORD", 0 ); ALTIUM_SCH_RECORD record = static_cast( recordId ); if( record != ALTIUM_SCH_RECORD::HEADER ) @@ -355,7 +355,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader { std::map properties = reader.ReadProperties(); - int recordId = ALTIUM_PARSER::PropertiesReadInt( properties, "RECORD", 0 ); + int recordId = ALTIUM_PARSER::ReadInt( properties, "RECORD", 0 ); ALTIUM_SCH_RECORD record = static_cast( recordId ); // see: https://github.com/vadmium/python-altium/blob/master/format.md diff --git a/pcbnew/plugins/altium/altium_parser_pcb.cpp b/pcbnew/plugins/altium/altium_parser_pcb.cpp index 4faecd5b3a..2f4b714816 100644 --- a/pcbnew/plugins/altium/altium_parser_pcb.cpp +++ b/pcbnew/plugins/altium/altium_parser_pcb.cpp @@ -140,8 +140,8 @@ ALTIUM_LAYER altium_layer_from_name( const wxString& aName ) } } -void altium_parse_polygons( - std::map& aProperties, std::vector& aVertices ) +void altium_parse_polygons( std::map& aProps, + std::vector& aVertices ) { for( size_t i = 0; i < std::numeric_limits::max(); i++ ) { @@ -150,23 +150,17 @@ void altium_parse_polygons( const wxString vxi = "VX" + si; const wxString vyi = "VY" + si; - if( aProperties.find( vxi ) == aProperties.end() - || aProperties.find( vyi ) == aProperties.end() ) - { + if( aProps.find( vxi ) == aProps.end() || aProps.find( vyi ) == aProps.end() ) break; // it doesn't seem like we know beforehand how many vertices are inside a polygon - } - const bool isRound = ALTIUM_PARSER::PropertiesReadInt( aProperties, "KIND" + si, 0 ) != 0; - const int32_t radius = - ALTIUM_PARSER::PropertiesReadKicadUnit( aProperties, "R" + si, "0mil" ); - const double sa = ALTIUM_PARSER::PropertiesReadDouble( aProperties, "SA" + si, 0. ); - const double ea = ALTIUM_PARSER::PropertiesReadDouble( aProperties, "EA" + si, 0. ); - const wxPoint vp = - wxPoint( ALTIUM_PARSER::PropertiesReadKicadUnit( aProperties, vxi, "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( aProperties, vyi, "0mil" ) ); - const wxPoint cp = - wxPoint( ALTIUM_PARSER::PropertiesReadKicadUnit( aProperties, "CX" + si, "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( aProperties, "CY" + si, "0mil" ) ); + const bool isRound = ALTIUM_PARSER::ReadInt( aProps, "KIND" + si, 0 ) != 0; + const int32_t radius = ALTIUM_PARSER::ReadKicadUnit( aProps, "R" + si, "0mil" ); + const double sa = ALTIUM_PARSER::ReadDouble( aProps, "SA" + si, 0. ); + const double ea = ALTIUM_PARSER::ReadDouble( aProps, "EA" + si, 0. ); + const wxPoint vp = wxPoint( ALTIUM_PARSER::ReadKicadUnit( aProps, vxi, "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( aProps, vyi, "0mil" ) ); + const wxPoint cp = wxPoint( ALTIUM_PARSER::ReadKicadUnit( aProps, "CX" + si, "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( aProps, "CY" + si, "0mil" ) ); aVertices.emplace_back( isRound, radius, sa, ea, vp, cp ); } @@ -174,165 +168,139 @@ void altium_parse_polygons( ABOARD6::ABOARD6( ALTIUM_PARSER& aReader ) { - std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Board6 stream has no properties!" ); - } + std::map props = aReader.ReadProperties(); - /*for (auto & property : properties) { - std::cout << " * '" << property.first << "' = '" << property.second << "'" << std::endl; - }*/ + if( props.empty() ) + THROW_IO_ERROR( "Board6 stream has no props!" ); - sheetpos = wxPoint( ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "SHEETX", "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "SHEETY", "0mil" ) ); - sheetsize = wxSize( ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "SHEETWIDTH", "0mil" ), - ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "SHEETHEIGHT", "0mil" ) ); + sheetpos = wxPoint( ALTIUM_PARSER::ReadKicadUnit( props, "SHEETX", "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( props, "SHEETY", "0mil" ) ); + sheetsize = wxSize( ALTIUM_PARSER::ReadKicadUnit( props, "SHEETWIDTH", "0mil" ), + ALTIUM_PARSER::ReadKicadUnit( props, "SHEETHEIGHT", "0mil" ) ); - layercount = ALTIUM_PARSER::PropertiesReadInt( properties, "LAYERSETSCOUNT", 1 ) + 1; + layercount = ALTIUM_PARSER::ReadInt( props, "LAYERSETSCOUNT", 1 ) + 1; for( size_t i = 1; i < std::numeric_limits::max(); i++ ) { const wxString layeri = "LAYER" + std::to_string( i ); const wxString layername = layeri + "NAME"; - auto layernameit = properties.find( layername ); - if( layernameit == properties.end() ) - { + auto layernameit = props.find( layername ); + + if( layernameit == props.end() ) break; // it doesn't seem like we know beforehand how many vertices are inside a polygon - } - ABOARD6_LAYER_STACKUP curlayer; + ABOARD6_LAYER_STACKUP l; - curlayer.name = ALTIUM_PARSER::PropertiesReadString( properties, layername, "" ); - curlayer.nextId = ALTIUM_PARSER::PropertiesReadInt( properties, layeri + "NEXT", 0 ); - curlayer.prevId = ALTIUM_PARSER::PropertiesReadInt( properties, layeri + "PREV", 0 ); - curlayer.copperthick = - ALTIUM_PARSER::PropertiesReadKicadUnit( properties, layeri + "COPTHICK", "1.4mil" ); + l.name = ALTIUM_PARSER::ReadString( props, layername, "" ); + l.nextId = ALTIUM_PARSER::ReadInt( props, layeri + "NEXT", 0 ); + l.prevId = ALTIUM_PARSER::ReadInt( props, layeri + "PREV", 0 ); + l.copperthick = ALTIUM_PARSER::ReadKicadUnit( props, layeri + "COPTHICK", "1.4mil" ); - curlayer.dielectricconst = - ALTIUM_PARSER::PropertiesReadDouble( properties, layeri + "DIELCONST", 0. ); - curlayer.dielectricthick = ALTIUM_PARSER::PropertiesReadKicadUnit( - properties, layeri + "DIELHEIGHT", "60mil" ); - curlayer.dielectricmaterial = - ALTIUM_PARSER::PropertiesReadString( properties, layeri + "DIELMATERIAL", "FR-4" ); + l.dielectricconst = ALTIUM_PARSER::ReadDouble( props, layeri + "DIELCONST", 0. ); + l.dielectricthick = ALTIUM_PARSER::ReadKicadUnit( props, layeri + "DIELHEIGHT", "60mil" ); + l.dielectricmaterial = ALTIUM_PARSER::ReadString( props, layeri + "DIELMATERIAL", "FR-4" ); - stackup.push_back( curlayer ); + stackup.push_back( l ); } - altium_parse_polygons( properties, board_vertices ); + altium_parse_polygons( props, board_vertices ); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Board6 stream was not parsed correctly!" ); - } } ACLASS6::ACLASS6( ALTIUM_PARSER& aReader ) { std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Classes6 stream has no properties!" ); - } - name = ALTIUM_PARSER::PropertiesReadString( properties, "NAME", "" ); - uniqueid = ALTIUM_PARSER::PropertiesReadString( properties, "UNIQUEID", "" ); - kind = static_cast( - ALTIUM_PARSER::PropertiesReadInt( properties, "KIND", -1 ) ); + if( properties.empty() ) + THROW_IO_ERROR( "Classes6 stream has no properties!" ); + + name = ALTIUM_PARSER::ReadString( properties, "NAME", "" ); + uniqueid = ALTIUM_PARSER::ReadString( properties, "UNIQUEID", "" ); + kind = static_cast( ALTIUM_PARSER::ReadInt( properties, "KIND", -1 ) ); for( size_t i = 0; i < std::numeric_limits::max(); i++ ) { auto mit = properties.find( "M" + std::to_string( i ) ); + if( mit == properties.end() ) - { break; // it doesn't seem like we know beforehand how many components are in the netclass - } + names.push_back( mit->second ); } if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Classes6 stream was not parsed correctly" ); - } } ACOMPONENT6::ACOMPONENT6( ALTIUM_PARSER& aReader ) { - std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Components6 stream has no properties" ); - } + std::map props = aReader.ReadProperties(); - layer = altium_layer_from_name( - ALTIUM_PARSER::PropertiesReadString( properties, "LAYER", "" ) ); - position = wxPoint( ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "X", "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "Y", "0mil" ) ); - rotation = ALTIUM_PARSER::PropertiesReadDouble( properties, "ROTATION", 0. ); - locked = ALTIUM_PARSER::PropertiesReadBool( properties, "LOCKED", false ); - nameon = ALTIUM_PARSER::PropertiesReadBool( properties, "NAMEON", true ); - commenton = ALTIUM_PARSER::PropertiesReadBool( properties, "COMMENTON", false ); - sourcedesignator = ALTIUM_PARSER::PropertiesReadString( properties, "SOURCEDESIGNATOR", "" ); - sourcefootprintlibrary = - ALTIUM_PARSER::PropertiesReadString( properties, "SOURCEFOOTPRINTLIBRARY", "" ); - pattern = ALTIUM_PARSER::PropertiesReadString( properties, "PATTERN", "" ); + if( props.empty() ) + THROW_IO_ERROR( "Components6 stream has no props" ); - sourcecomponentlibrary = - ALTIUM_PARSER::PropertiesReadString( properties, "SOURCECOMPONENTLIBRARY", "" ); - sourcelibreference = - ALTIUM_PARSER::PropertiesReadString( properties, "SOURCELIBREFERENCE", "" ); + layer = altium_layer_from_name( ALTIUM_PARSER::ReadString( props, "LAYER", "" ) ); + position = wxPoint( ALTIUM_PARSER::ReadKicadUnit( props, "X", "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( props, "Y", "0mil" ) ); + rotation = ALTIUM_PARSER::ReadDouble( props, "ROTATION", 0. ); + locked = ALTIUM_PARSER::ReadBool( props, "LOCKED", false ); + nameon = ALTIUM_PARSER::ReadBool( props, "NAMEON", true ); + commenton = ALTIUM_PARSER::ReadBool( props, "COMMENTON", false ); + sourcedesignator = ALTIUM_PARSER::ReadString( props, "SOURCEDESIGNATOR", "" ); + sourcefootprintlibrary = ALTIUM_PARSER::ReadString( props, "SOURCEFOOTPRINTLIBRARY", "" ); + pattern = ALTIUM_PARSER::ReadString( props, "PATTERN", "" ); + + sourcecomponentlibrary = ALTIUM_PARSER::ReadString( props, "SOURCECOMPONENTLIBRARY", "" ); + sourcelibreference = ALTIUM_PARSER::ReadString( props, "SOURCELIBREFERENCE", "" ); nameautoposition = static_cast( - ALTIUM_PARSER::PropertiesReadInt( properties, "NAMEAUTOPOSITION", 0 ) ); + ALTIUM_PARSER::ReadInt( props, "NAMEAUTOPOSITION", 0 ) ); commentautoposition = static_cast( - ALTIUM_PARSER::PropertiesReadInt( properties, "COMMENTAUTOPOSITION", 0 ) ); + ALTIUM_PARSER::ReadInt( props, "COMMENTAUTOPOSITION", 0 ) ); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Components6 stream was not parsed correctly" ); - } } ADIMENSION6::ADIMENSION6( ALTIUM_PARSER& aReader ) { aReader.Skip( 2 ); - std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Dimensions6 stream has no properties" ); - } + std::map props = aReader.ReadProperties(); - layer = altium_layer_from_name( - ALTIUM_PARSER::PropertiesReadString( properties, "LAYER", "" ) ); - kind = static_cast( - ALTIUM_PARSER::PropertiesReadInt( properties, "DIMENSIONKIND", 0 ) ); + if( props.empty() ) + THROW_IO_ERROR( "Dimensions6 stream has no props" ); - textformat = ALTIUM_PARSER::PropertiesReadString( properties, "TEXTFORMAT", "" ); + layer = altium_layer_from_name( ALTIUM_PARSER::ReadString( props, "LAYER", "" ) ); + kind = static_cast( ALTIUM_PARSER::ReadInt( props, "DIMENSIONKIND", 0 ) ); - height = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "HEIGHT", "0mil" ); - angle = ALTIUM_PARSER::PropertiesReadDouble( properties, "ANGLE", 0. ); + textformat = ALTIUM_PARSER::ReadString( props, "TEXTFORMAT", "" ); - linewidth = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "LINEWIDTH", "10mil" ); - textheight = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "TEXTHEIGHT", "10mil" ); - textlinewidth = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "TEXTLINEWIDTH", "6mil" ); - textprecision = ALTIUM_PARSER::PropertiesReadInt( properties, "TEXTPRECISION", 2 ); - textbold = ALTIUM_PARSER::PropertiesReadBool( properties, "TEXTLINEWIDTH", false ); - textitalic = ALTIUM_PARSER::PropertiesReadBool( properties, "ITALIC", false ); + height = ALTIUM_PARSER::ReadKicadUnit( props, "HEIGHT", "0mil" ); + angle = ALTIUM_PARSER::ReadDouble( props, "ANGLE", 0. ); - arrowsize = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "ARROWSIZE", "60mil" ); + linewidth = ALTIUM_PARSER::ReadKicadUnit( props, "LINEWIDTH", "10mil" ); + textheight = ALTIUM_PARSER::ReadKicadUnit( props, "TEXTHEIGHT", "10mil" ); + textlinewidth = ALTIUM_PARSER::ReadKicadUnit( props, "TEXTLINEWIDTH", "6mil" ); + textprecision = ALTIUM_PARSER::ReadInt( props, "TEXTPRECISION", 2 ); + textbold = ALTIUM_PARSER::ReadBool( props, "TEXTLINEWIDTH", false ); + textitalic = ALTIUM_PARSER::ReadBool( props, "ITALIC", false ); - xy1 = wxPoint( ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "X1", "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "Y1", "0mil" ) ); + arrowsize = ALTIUM_PARSER::ReadKicadUnit( props, "ARROWSIZE", "60mil" ); + + xy1 = wxPoint( ALTIUM_PARSER::ReadKicadUnit( props, "X1", "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( props, "Y1", "0mil" ) ); + + int refcount = ALTIUM_PARSER::ReadInt( props, "REFERENCES_COUNT", 0 ); - int refcount = ALTIUM_PARSER::PropertiesReadInt( properties, "REFERENCES_COUNT", 0 ); for( int i = 0; i < refcount; i++ ) { - const std::string refi = "REFERENCE" + std::to_string( i ); - referencePoint.emplace_back( - ALTIUM_PARSER::PropertiesReadKicadUnit( properties, refi + "POINTX", "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( properties, refi + "POINTY", "0mil" ) ); + const std::string refi = "REFERENCE" + std::to_string( i ) + "POINT"; + referencePoint.emplace_back( ALTIUM_PARSER::ReadKicadUnit( props, refi + "X", "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( props, refi + "Y", "0mil" ) ); } for( size_t i = 1; i < std::numeric_limits::max(); i++ ) @@ -341,143 +309,91 @@ ADIMENSION6::ADIMENSION6( ALTIUM_PARSER& aReader ) const std::string textix = texti + "X"; const std::string textiy = texti + "Y"; - if( properties.find( textix ) == properties.end() - || properties.find( textiy ) == properties.end() ) - { + if( props.find( textix ) == props.end() || props.find( textiy ) == props.end() ) break; // it doesn't seem like we know beforehand how many vertices are inside a polygon - } - textPoint.emplace_back( - ALTIUM_PARSER::PropertiesReadKicadUnit( properties, textix, "0mil" ), - -ALTIUM_PARSER::PropertiesReadKicadUnit( properties, textiy, "0mil" ) ); + textPoint.emplace_back( ALTIUM_PARSER::ReadKicadUnit( props, textix, "0mil" ), + -ALTIUM_PARSER::ReadKicadUnit( props, textiy, "0mil" ) ); } - wxString dimensionunit = - ALTIUM_PARSER::PropertiesReadString( properties, "TEXTDIMENSIONUNIT", "Millimeters" ); - if( dimensionunit == "Inches" ) - { - textunit = ALTIUM_UNIT::INCHES; - } - else if( dimensionunit == "Mils" ) - { - textunit = ALTIUM_UNIT::MILS; - } - else if( dimensionunit == "Millimeters" ) - { - textunit = ALTIUM_UNIT::MILLIMETERS; - } - else if( dimensionunit == "Centimeters" ) - { - textunit = ALTIUM_UNIT::CENTIMETER; - } - else - { - textunit = ALTIUM_UNIT::UNKNOWN; - } + wxString dimensionunit = ALTIUM_PARSER::ReadString( props, "TEXTDIMENSIONUNIT", "Millimeters" ); + + if( dimensionunit == "Inches" ) textunit = ALTIUM_UNIT::INCHES; + else if( dimensionunit == "Mils" ) textunit = ALTIUM_UNIT::MILS; + else if( dimensionunit == "Millimeters" ) textunit = ALTIUM_UNIT::MILLIMETERS; + else if( dimensionunit == "Centimeters" ) textunit = ALTIUM_UNIT::CENTIMETER; + else textunit = ALTIUM_UNIT::UNKNOWN; if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Dimensions6 stream was not parsed correctly" ); - } } AMODEL::AMODEL( ALTIUM_PARSER& aReader ) { std::map properties = aReader.ReadProperties(); + if( properties.empty() ) - { THROW_IO_ERROR( "Classes6 stream has no properties!" ); - } - name = ALTIUM_PARSER::PropertiesReadString( properties, "NAME", "" ); - id = ALTIUM_PARSER::PropertiesReadString( properties, "ID", "" ); - isEmbedded = ALTIUM_PARSER::PropertiesReadBool( properties, "EMBED", false ); + name = ALTIUM_PARSER::ReadString( properties, "NAME", "" ); + id = ALTIUM_PARSER::ReadString( properties, "ID", "" ); + isEmbedded = ALTIUM_PARSER::ReadBool( properties, "EMBED", false ); - rotation.x = ALTIUM_PARSER::PropertiesReadDouble( properties, "ROTX", 0. ); - rotation.y = ALTIUM_PARSER::PropertiesReadDouble( properties, "ROTY", 0. ); - rotation.z = ALTIUM_PARSER::PropertiesReadDouble( properties, "ROTZ", 0. ); + rotation.x = ALTIUM_PARSER::ReadDouble( properties, "ROTX", 0. ); + rotation.y = ALTIUM_PARSER::ReadDouble( properties, "ROTY", 0. ); + rotation.z = ALTIUM_PARSER::ReadDouble( properties, "ROTZ", 0. ); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Classes6 stream was not parsed correctly" ); - } } ANET6::ANET6( ALTIUM_PARSER& aReader ) { std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Nets6 stream has no properties" ); - } - name = ALTIUM_PARSER::PropertiesReadString( properties, "NAME", "" ); + if( properties.empty() ) + THROW_IO_ERROR( "Nets6 stream has no properties" ); + + name = ALTIUM_PARSER::ReadString( properties, "NAME", "" ); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Nets6 stream was not parsed correctly" ); - } } APOLYGON6::APOLYGON6( ALTIUM_PARSER& aReader ) { std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Polygons6 stream has no properties" ); - } - layer = altium_layer_from_name( - ALTIUM_PARSER::PropertiesReadString( properties, "LAYER", "" ) ); - net = ALTIUM_PARSER::PropertiesReadInt( properties, "NET", ALTIUM_NET_UNCONNECTED ); - locked = ALTIUM_PARSER::PropertiesReadBool( properties, "LOCKED", false ); + if( properties.empty() ) + THROW_IO_ERROR( "Polygons6 stream has no properties" ); + + layer = altium_layer_from_name( ALTIUM_PARSER::ReadString( properties, "LAYER", "" ) ); + net = ALTIUM_PARSER::ReadInt( properties, "NET", ALTIUM_NET_UNCONNECTED ); + locked = ALTIUM_PARSER::ReadBool( properties, "LOCKED", false ); // TODO: kind - gridsize = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "GRIDSIZE", "0mil" ); - trackwidth = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "TRACKWIDTH", "0mil" ); - minprimlength = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "MINPRIMLENGTH", "0mil" ); - useoctagons = ALTIUM_PARSER::PropertiesReadBool( properties, "USEOCTAGONS", false ); + gridsize = ALTIUM_PARSER::ReadKicadUnit( properties, "GRIDSIZE", "0mil" ); + trackwidth = ALTIUM_PARSER::ReadKicadUnit( properties, "TRACKWIDTH", "0mil" ); + minprimlength = ALTIUM_PARSER::ReadKicadUnit( properties, "MINPRIMLENGTH", "0mil" ); + useoctagons = ALTIUM_PARSER::ReadBool( properties, "USEOCTAGONS", false ); - pourindex = ALTIUM_PARSER::PropertiesReadInt( properties, "POURINDEX", 0 ); + pourindex = ALTIUM_PARSER::ReadInt( properties, "POURINDEX", 0 ); - wxString hatchstyleraw = ALTIUM_PARSER::PropertiesReadString( properties, "HATCHSTYLE", "" ); + wxString hatchstyleraw = ALTIUM_PARSER::ReadString( properties, "HATCHSTYLE", "" ); - if( hatchstyleraw == "Solid" ) - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::SOLID; - } - else if( hatchstyleraw == "45Degree" ) - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::DEGREE_45; - } - else if( hatchstyleraw == "90Degree" ) - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::DEGREE_90; - } - else if( hatchstyleraw == "Horizontal" ) - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::HORIZONTAL; - } - else if( hatchstyleraw == "Vertical" ) - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::VERTICAL; - } - else if( hatchstyleraw == "None" ) - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::NONE; - } - else - { - hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::UNKNOWN; - } + if( hatchstyleraw == "Solid" ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::SOLID; + else if( hatchstyleraw == "45Degree" ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::DEGREE_45; + else if( hatchstyleraw == "90Degree" ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::DEGREE_90; + else if( hatchstyleraw == "Horizontal" ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::HORIZONTAL; + else if( hatchstyleraw == "Vertical" ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::VERTICAL; + else if( hatchstyleraw == "None" ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::NONE; + else hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::UNKNOWN; altium_parse_polygons( properties, vertices ); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Polygons6 stream was not parsed correctly" ); - } } ARULE6::ARULE6( ALTIUM_PARSER& aReader ) @@ -492,23 +408,22 @@ ARULE6::ARULE6( ALTIUM_PARSER& aReader ) aReader.Skip( 2 ); - std::map properties = aReader.ReadProperties(); - if( properties.empty() ) - { - THROW_IO_ERROR( "Rules6 stream has no properties" ); - } + std::map props = aReader.ReadProperties(); - name = ALTIUM_PARSER::PropertiesReadString( properties, "NAME", "" ); - priority = ALTIUM_PARSER::PropertiesReadInt( properties, "PRIORITY", 1 ); + if( props.empty() ) + THROW_IO_ERROR( "Rules6 stream has no props" ); - scope1expr = ALTIUM_PARSER::PropertiesReadString( properties, "SCOPE1EXPRESSION", "" ); - scope2expr = ALTIUM_PARSER::PropertiesReadString( properties, "SCOPE2EXPRESSION", "" ); + name = ALTIUM_PARSER::ReadString( props, "NAME", "" ); + priority = ALTIUM_PARSER::ReadInt( props, "PRIORITY", 1 ); - wxString rulekind = ALTIUM_PARSER::PropertiesReadString( properties, "RULEKIND", "" ); + scope1expr = ALTIUM_PARSER::ReadString( props, "SCOPE1EXPRESSION", "" ); + scope2expr = ALTIUM_PARSER::ReadString( props, "SCOPE2EXPRESSION", "" ); + + wxString rulekind = ALTIUM_PARSER::ReadString( props, "RULEKIND", "" ); if( rulekind == "Clearance" ) { kind = ALTIUM_RULE_KIND::CLEARANCE; - clearanceGap = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "GAP", "10mil" ); + clearanceGap = ALTIUM_PARSER::ReadKicadUnit( props, "GAP", "10mil" ); } else if( rulekind == "DiffPairsRouting" ) { @@ -537,29 +452,21 @@ ARULE6::ARULE6( ALTIUM_PARSER& aReader ) else if( rulekind == "PlaneClearance" ) { kind = ALTIUM_RULE_KIND::PLANE_CLEARANCE; - planeclearanceClearance = - ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "CLEARANCE", "10mil" ); + planeclearanceClearance = ALTIUM_PARSER::ReadKicadUnit( props, "CLEARANCE", "10mil" ); } else if( rulekind == "PolygonConnect" ) { kind = ALTIUM_RULE_KIND::POLYGON_CONNECT; - polygonconnectAirgapwidth = - ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "AIRGAPWIDTH", "10mil" ); - polygonconnectReliefconductorwidth = ALTIUM_PARSER::PropertiesReadKicadUnit( - properties, "RELIEFCONDUCTORWIDTH", "10mil" ); - polygonconnectReliefentries = - ALTIUM_PARSER::PropertiesReadInt( properties, "RELIEFENTRIES", 4 ); + polygonconnectAirgapwidth = ALTIUM_PARSER::ReadKicadUnit( props, "AIRGAPWIDTH", "10mil" ); + polygonconnectReliefconductorwidth = ALTIUM_PARSER::ReadKicadUnit( props, "RELIEFCONDUCTORWIDTH", "10mil" ); + polygonconnectReliefentries = ALTIUM_PARSER::ReadInt( props, "RELIEFENTRIES", 4 ); - wxString style = ALTIUM_PARSER::PropertiesReadString( properties, "CONNECTSTYLE", "" ); + wxString style = ALTIUM_PARSER::ReadString( props, "CONNECTSTYLE", "" ); - if( style == "Direct" ) - polygonconnectStyle = ALTIUM_CONNECT_STYLE::DIRECT; - else if( style == "Relief" ) - polygonconnectStyle = ALTIUM_CONNECT_STYLE::RELIEF; - else if( style == "NoConnect" ) - polygonconnectStyle = ALTIUM_CONNECT_STYLE::NONE; - else - polygonconnectStyle = ALTIUM_CONNECT_STYLE::UNKNOWN; + if( style == "Direct" ) polygonconnectStyle = ALTIUM_CONNECT_STYLE::DIRECT; + else if( style == "Relief" ) polygonconnectStyle = ALTIUM_CONNECT_STYLE::RELIEF; + else if( style == "NoConnect" ) polygonconnectStyle = ALTIUM_CONNECT_STYLE::NONE; + else polygonconnectStyle = ALTIUM_CONNECT_STYLE::UNKNOWN; } else { @@ -567,9 +474,7 @@ ARULE6::ARULE6( ALTIUM_PARSER& aReader ) } if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Rules6 stream was not parsed correctly" ); - } } AARC6::AARC6( ALTIUM_PARSER& aReader ) @@ -613,10 +518,9 @@ AARC6::AARC6( ALTIUM_PARSER& aReader ) ACOMPONENTBODY6::ACOMPONENTBODY6( ALTIUM_PARSER& aReader ) { ALTIUM_RECORD recordtype = static_cast( aReader.Read() ); + if( recordtype != ALTIUM_RECORD::MODEL ) - { THROW_IO_ERROR( "ComponentsBodies6 stream has invalid recordtype" ); - } aReader.ReadAndSetSubrecordLength(); @@ -625,33 +529,30 @@ ACOMPONENTBODY6::ACOMPONENTBODY6( ALTIUM_PARSER& aReader ) aReader.Skip( 9 ); std::map properties = aReader.ReadProperties(); + if( properties.empty() ) - { THROW_IO_ERROR( "ComponentsBodies6 stream has no properties" ); - } - modelName = ALTIUM_PARSER::PropertiesReadString( properties, "MODEL.NAME", "" ); - modelId = ALTIUM_PARSER::PropertiesReadString( properties, "MODELID", "" ); - modelIsEmbedded = ALTIUM_PARSER::PropertiesReadBool( properties, "MODEL.EMBED", false ); + modelName = ALTIUM_PARSER::ReadString( properties, "MODEL.NAME", "" ); + modelId = ALTIUM_PARSER::ReadString( properties, "MODELID", "" ); + modelIsEmbedded = ALTIUM_PARSER::ReadBool( properties, "MODEL.EMBED", false ); - modelPosition.x = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "MODEL.2D.X", "0mil" ); - modelPosition.y = -ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "MODEL.2D.Y", "0mil" ); - modelPosition.z = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "MODEL.3D.DZ", "0mil" ); + modelPosition.x = ALTIUM_PARSER::ReadKicadUnit( properties, "MODEL.2D.X", "0mil" ); + modelPosition.y = -ALTIUM_PARSER::ReadKicadUnit( properties, "MODEL.2D.Y", "0mil" ); + modelPosition.z = ALTIUM_PARSER::ReadKicadUnit( properties, "MODEL.3D.DZ", "0mil" ); - modelRotation.x = ALTIUM_PARSER::PropertiesReadDouble( properties, "MODEL.3D.ROTX", 0. ); - modelRotation.y = ALTIUM_PARSER::PropertiesReadDouble( properties, "MODEL.3D.ROTY", 0. ); - modelRotation.z = ALTIUM_PARSER::PropertiesReadDouble( properties, "MODEL.3D.ROTZ", 0. ); + modelRotation.x = ALTIUM_PARSER::ReadDouble( properties, "MODEL.3D.ROTX", 0. ); + modelRotation.y = ALTIUM_PARSER::ReadDouble( properties, "MODEL.3D.ROTY", 0. ); + modelRotation.z = ALTIUM_PARSER::ReadDouble( properties, "MODEL.3D.ROTZ", 0. ); - rotation = ALTIUM_PARSER::PropertiesReadDouble( properties, "MODEL.2D.ROTATION", 0. ); + rotation = ALTIUM_PARSER::ReadDouble( properties, "MODEL.2D.ROTATION", 0. ); - bodyOpacity = ALTIUM_PARSER::PropertiesReadDouble( properties, "BODYOPACITY3D", 1. ); + bodyOpacity = ALTIUM_PARSER::ReadDouble( properties, "BODYOPACITY3D", 1. ); aReader.SkipSubrecord(); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Components6 stream was not parsed correctly" ); - } } APAD6::APAD6( ALTIUM_PARSER& aReader ) @@ -797,10 +698,9 @@ APAD6::APAD6( ALTIUM_PARSER& aReader ) AVIA6::AVIA6( ALTIUM_PARSER& aReader ) { ALTIUM_RECORD recordtype = static_cast( aReader.Read() ); + if( recordtype != ALTIUM_RECORD::VIA ) - { THROW_IO_ERROR( "Vias6 stream has invalid recordtype" ); - } // Subrecord 1 size_t subrecord1 = aReader.ReadAndSetSubrecordLength(); @@ -838,18 +738,15 @@ AVIA6::AVIA6( ALTIUM_PARSER& aReader ) aReader.SkipSubrecord(); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Vias6 stream was not parsed correctly" ); - } } ATRACK6::ATRACK6( ALTIUM_PARSER& aReader ) { ALTIUM_RECORD recordtype = static_cast( aReader.Read() ); + if( recordtype != ALTIUM_RECORD::TRACK ) - { THROW_IO_ERROR( "Tracks6 stream has invalid recordtype" ); - } // Subrecord 1 aReader.ReadAndSetSubrecordLength(); @@ -874,18 +771,15 @@ ATRACK6::ATRACK6( ALTIUM_PARSER& aReader ) aReader.SkipSubrecord(); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Tracks6 stream was not parsed correctly" ); - } } ATEXT6::ATEXT6( ALTIUM_PARSER& aReader ) { ALTIUM_RECORD recordtype = static_cast( aReader.Read() ); + if( recordtype != ALTIUM_RECORD::TEXT ) - { THROW_IO_ERROR( "Texts6 stream has invalid recordtype" ); - } // Subrecord 1 - Properties size_t subrecord1 = aReader.ReadAndSetSubrecordLength(); @@ -914,9 +808,8 @@ ATEXT6::ATEXT6( ALTIUM_PARSER& aReader ) * https://gitlab.com/kicad/code/kicad/merge_requests/60#note_274913397 */ if( subrecord1 <= 230 ) - { textposition = ALTIUM_TEXT_POSITION::LEFT_BOTTOM; - } + aReader.Skip( 27 ); fonttype = static_cast( aReader.Read() ); @@ -933,18 +826,15 @@ ATEXT6::ATEXT6( ALTIUM_PARSER& aReader ) aReader.SkipSubrecord(); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Texts6 stream was not parsed correctly" ); - } } AFILL6::AFILL6( ALTIUM_PARSER& aReader ) { ALTIUM_RECORD recordtype = static_cast( aReader.Read() ); + if( recordtype != ALTIUM_RECORD::FILL ) - { THROW_IO_ERROR( "Fills6 stream has invalid recordtype" ); - } // Subrecord 1 aReader.ReadAndSetSubrecordLength(); @@ -968,18 +858,15 @@ AFILL6::AFILL6( ALTIUM_PARSER& aReader ) aReader.SkipSubrecord(); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Fills6 stream was not parsed correctly" ); - } } AREGION6::AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices ) { ALTIUM_RECORD recordtype = static_cast( aReader.Read() ); + if( recordtype != ALTIUM_RECORD::REGION ) - { THROW_IO_ERROR( "Regions6 stream has invalid recordtype" ); - } // Subrecord 1 aReader.ReadAndSetSubrecordLength(); @@ -1000,19 +887,18 @@ AREGION6::AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices ) aReader.Skip( 2 ); std::map properties = aReader.ReadProperties(); + if( properties.empty() ) - { THROW_IO_ERROR( "Regions6 stream has empty properties" ); - } - int pkind = ALTIUM_PARSER::PropertiesReadInt( properties, "KIND", 0 ); - bool is_cutout = ALTIUM_PARSER::PropertiesReadBool( properties, "ISBOARDCUTOUT", false ); + int pkind = ALTIUM_PARSER::ReadInt( properties, "KIND", 0 ); + bool is_cutout = ALTIUM_PARSER::ReadBool( properties, "ISBOARDCUTOUT", false ); - is_shapebased = ALTIUM_PARSER::PropertiesReadBool( properties, "ISSHAPEBASED", false ); + is_shapebased = ALTIUM_PARSER::ReadBool( properties, "ISSHAPEBASED", false ); // TODO: this can differ from the other subpolyindex?! //subpolyindex = static_cast( - // ALTIUM_PARSER::PropertiesReadInt( properties, "SUBPOLYINDEX", ALTIUM_POLYGON_NONE ) ); + // ALTIUM_PARSER::ReadInt( properties, "SUBPOLYINDEX", ALTIUM_POLYGON_NONE ) ); switch( pkind ) { @@ -1087,7 +973,5 @@ AREGION6::AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices ) aReader.SkipSubrecord(); if( aReader.HasParsingError() ) - { THROW_IO_ERROR( "Regions6 stream was not parsed correctly" ); - } } diff --git a/qa/common/plugins/altium/test_altium_parser.cpp b/qa/common/plugins/altium/test_altium_parser.cpp index 0cbdd986d8..0dd71e7fa0 100644 --- a/qa/common/plugins/altium/test_altium_parser.cpp +++ b/qa/common/plugins/altium/test_altium_parser.cpp @@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE( PropertiesReadKicadUnit ) { std::map properties = { { "TEST", c.input } }; - int result = ALTIUM_PARSER::PropertiesReadKicadUnit( properties, "TEST", "0mil" ); + int result = ALTIUM_PARSER::ReadKicadUnit( properties, "TEST", "0mil" ); // These are all valid BOOST_CHECK_EQUAL( result, c.exp_result ); diff --git a/qa/eeschema/sch_plugins/altium/test_altium_parser_sch.cpp b/qa/eeschema/sch_plugins/altium/test_altium_parser_sch.cpp index 15722f5f31..ccdd79593e 100644 --- a/qa/eeschema/sch_plugins/altium/test_altium_parser_sch.cpp +++ b/qa/eeschema/sch_plugins/altium/test_altium_parser_sch.cpp @@ -31,8 +31,8 @@ #include // Function declarations of private methods to test -int PropertiesReadKiCadUnitFrac( const std::map& aProperties, - const wxString& aKey ); +int ReadKiCadUnitFrac( const std::map& aProps, + const wxString& aKey ); struct ALTIUM_PARSER_SCH_FIXTURE @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE( PropertiesReadKiCadUnitFracConversation ) std::map properties = { { "TEST", c.input }, { "TEST_FRAC", c.input_frac } }; - int result = PropertiesReadKiCadUnitFrac( properties, "TEST" ); + int result = ReadKiCadUnitFrac( properties, "TEST" ); // These are all valid BOOST_CHECK_EQUAL( result, c.exp_result );