37 wxString key = !libName.empty() ? ( libName +
":" + libReference ) : libReference;
40 libId.
Parse( key,
true );
53 for( wxString::const_iterator it = aString.begin(); it != aString.end(); ++it )
57 if( (*it).GetAsChar( &ch ) )
73 if( !tempString.empty() )
75 output +=
"~{" + tempString +
"}";
87 if( !tempString.IsEmpty() )
88 output +=
"~{" + tempString +
"}";
99 const std::map<wxString, wxString>& aOverrides )
101 if( aString.IsEmpty() || aString.at( 0 ) !=
'=' )
109 size_t delimiter = 0;
110 size_t escaping_start = 0;
113 delimiter = aString.find(
"+", start );
114 escaping_start = aString.find(
"'", start );
116 if( escaping_start < delimiter )
118 size_t text_start = escaping_start + 1;
119 size_t escaping_end = aString.find(
"'", text_start );
121 if( escaping_end == wxString::npos )
123 escaping_end = aString.size();
126 result += aString.substr( text_start, escaping_end - text_start );
128 start = escaping_end + 1;
132 wxString specialString =
133 aString.substr( start, delimiter - start ).Trim().Trim(
false );
135 if( specialString.StartsWith(
"\"" ) && specialString.EndsWith(
"\"" ) )
136 specialString = specialString.Mid( 1, specialString.Length() - 2 );
138 if( !specialString.IsEmpty() )
142 specialString.UpperCase();
144 auto overrideIt = aOverrides.find( specialString );
146 if( overrideIt != aOverrides.end() )
147 specialString = overrideIt->second;
149 result += wxString::Format( wxT(
"${%s}" ), specialString );
152 start = delimiter + 1;
154 }
while( delimiter != wxString::npos );
162 const std::map<wxString, wxString>& aOverrides )
164 if( aString.IsEmpty() )
168 if( aString.at( 0 ) ==
'.' )
170 wxString specialString = aString.substr( 1 );
172 specialString.UpperCase();
174 auto overrideIt = aOverrides.find( specialString );
176 if( overrideIt != aOverrides.end() )
177 specialString = overrideIt->second;
179 return wxString::Format( wxT(
"${%s}" ), specialString );
190 if( aString.IsEmpty() )
191 return wxEmptyString;
195 if( aString.StartsWith(
'\\', &rest ) && !rest.Contains(
'\\' ) )
196 return "~{" + rest +
"}";
204 if( aMajor == 0 || aMinor == 0 )
207 double numerator = aMajor * aMinor;
208 double majorTerm = aMajor * sin( aAngleRadians );
209 double minorTerm = aMinor * cos( aAngleRadians );
210 double denominator = sqrt( majorTerm * majorTerm + minorTerm * minorTerm );
212 double radius = numerator / denominator;
215 KiROUND( radius * sin( aAngleRadians ) ) );
wxString AltiumSchSpecialStringsToKiCadVariables(const wxString &aString, const std::map< wxString, wxString > &aOverrides)
wxString AltiumPropertyToKiCadString(const wxString &aString)
wxString AltiumPinNamesToKiCad(wxString &aString)
VECTOR2I AltiumGetEllipticalPos(double aMajor, double aMinor, double aAngleRadians)
LIB_ID AltiumToKiCadLibID(const wxString &aLibName, const wxString &aLibReference)
wxString AltiumPcbSpecialStringsToKiCadStrings(const wxString &aString, const std::map< wxString, wxString > &aOverrides)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
VECTOR2< int32_t > VECTOR2I