diff --git a/common/io/altium/altium_ascii_parser.cpp b/common/io/altium/altium_ascii_parser.cpp index 8cba09a053..e477dc2f7e 100644 --- a/common/io/altium/altium_ascii_parser.cpp +++ b/common/io/altium/altium_ascii_parser.cpp @@ -117,7 +117,8 @@ std::map ALTIUM_ASCII_PARSER::ReadProperties() if( canonicalKey == wxT( "DESIGNATOR" ) || canonicalKey == wxT( "NAME" ) || canonicalKey == wxT( "TEXT" ) ) { - value = AltiumPropertyToKiCadString( value ); + if( kv[ wxT( "RECORD" ) ] != wxT( "4" ) ) + value = AltiumPropertyToKiCadString( value ); } } diff --git a/common/io/altium/altium_binary_parser.cpp b/common/io/altium/altium_binary_parser.cpp index 352b925b1c..1b63acfb8f 100644 --- a/common/io/altium/altium_binary_parser.cpp +++ b/common/io/altium/altium_binary_parser.cpp @@ -432,7 +432,8 @@ std::map ALTIUM_BINARY_PARSER::ReadProperties( || canonicalKey == wxT( "NAME" ) || canonicalKey == wxT( "TEXT" ) ) { - value = AltiumPropertyToKiCadString( value.Trim() ); + if( kv[ wxT( "RECORD" ) ] != wxT( "4" ) ) + value = AltiumPropertyToKiCadString( value.Trim() ); } kv.insert( { canonicalKey, value.Trim() } ); diff --git a/common/io/altium/altium_parser_utils.cpp b/common/io/altium/altium_parser_utils.cpp index 824618d6f7..6a9096a815 100644 --- a/common/io/altium/altium_parser_utils.cpp +++ b/common/io/altium/altium_parser_utils.cpp @@ -45,40 +45,52 @@ LIB_ID AltiumToKiCadLibID( const wxString& aLibName, const wxString& aLibReferen wxString AltiumPropertyToKiCadString( const wxString& aString ) { - wxString converted; - bool inOverbar = false; + wxString output; + wxString tempString; + bool hasPrev = false; + wxUniChar prev; - for( wxString::const_iterator chIt = aString.begin(); chIt != aString.end(); ++chIt ) + for( wxString::const_iterator it = aString.begin(); it != aString.end(); ++it ) { - wxString::const_iterator lookahead = chIt + 1; + char ch = 0; - if( lookahead != aString.end() && *lookahead == '\\' ) + if( (*it).GetAsChar( &ch ) ) { - if( !inOverbar ) + if( ch == '\\' ) { - converted += "~{"; - inOverbar = true; - } + if( hasPrev ) + { + tempString += prev; + hasPrev = false; + } - converted += *chIt; - chIt = lookahead; + continue; // Backslash is ignored and not added to the output + } } - else + + if( hasPrev ) // Two letters in a row with no backslash { - if( inOverbar ) + if( !tempString.empty() ) { - converted += "}"; - inOverbar = false; + output += "~{" + tempString + "}"; + tempString.Clear(); } - converted += *chIt; + output += prev; } + + prev = *it; + hasPrev = true; } - if( inOverbar ) - converted += "}"; + // Append any leftover escaped string + if( !tempString.IsEmpty() ) + output += "~{" + tempString + "}"; + + if( hasPrev ) + output += prev; - return converted; + return output; } @@ -148,9 +160,7 @@ wxString AltiumPcbSpecialStringsToKiCadStrings( const wxString& const std::map& aOverrides ) { if( aString.IsEmpty() ) - { return aString; - } // special case: string starts with dot -> whole string is special string if( aString.at( 0 ) == '.' ) @@ -174,57 +184,15 @@ wxString AltiumPcbSpecialStringsToKiCadStrings( const wxString& wxString AltiumPinNamesToKiCad( wxString& aString ) { - wxString output; - wxString tempString; - bool hasPrev = false; - wxUniChar prev; - - - for( wxString::const_iterator it = aString.begin(); it != aString.end(); ++it ) - { - char ch = 0; - - if( (*it).GetAsChar( &ch ) ) - { - if( ch == '\\' ) - { - if( hasPrev ) - { - tempString += prev; - hasPrev = false; - } - - continue; // Backslash is ignored and not added to the output - } - } - - if( hasPrev ) // Two letters in a row with no backslash - { - if( !tempString.empty() ) - { - output += "~{" + tempString + "}"; - tempString.Clear(); - } + if( aString.IsEmpty() ) + return wxEmptyString; - output += prev; - } + wxString rest; - prev = *it; - hasPrev = true; - } + if( aString.StartsWith( '\\', &rest ) && !rest.Contains( '\\' ) ) + return "~{" + rest + "}"; - // Append any leftover escaped string - if( !tempString.IsEmpty() ) - { - output += "~{" + tempString + "}"; - } - - if( hasPrev ) - { - output += prev; - } - - return output; + return AltiumPropertyToKiCadString( aString ); } VECTOR2I AltiumGetEllipticalPos( double aMajor, double aMinor, double aAngleRadians )