58 wxString result = wxEmptyString;
60 *aStr = aStr->Trim(
false );
62 if( aStr->Len() == 0 )
65 if( (*aStr)[0] == wxT(
'"' ) )
68 *aStr = aStr->Mid( 1 );
70 while( aStr->Len() > 0 && (*aStr)[0] != wxT(
'"' ) )
73 *aStr = aStr->Mid( 1 );
76 if( aStr->Len() > 0 && (*aStr)[0] == wxT(
'"' ) )
79 *aStr = aStr->Mid( 1 );
84 while( aStr->Len() > 0
85 && !( (*aStr)[0] == wxT(
' ' )
86 || (*aStr)[0] == wxT(
'(' )
87 || (*aStr)[0] == wxT(
')' ) ) )
90 *aStr = aStr->Mid( 1 );
103 XNODE* result, * lNode;
106 lNode =
FindNode( aNode, wxT(
"attachedPattern" ) );
109 result =
FindNode( lNode, wxT(
"padPinMap" ) );
116 const wxString& aActualConversion )
128 u = ls[ls.Len() - 1];
131 && !( ls[ls.Len() - 1] == wxT(
'.' )
132 || ls[ls.Len() - 1] == wxT(
',' )
133 || (ls[ls.Len() - 1] >= wxT(
'0' ) && ls[ls.Len() - 1] <= wxT(
'9' ) ) ) )
135 ls = ls.Left( ls.Len() - 1 );
139 && !( ls[0] == wxT(
'-' )
140 || ls[0] == wxT(
'+' )
141 || ls[0] == wxT(
'.' )
142 || ls[0] == wxT(
',' )
143 || (ls[0] >= wxT(
'0' ) && ls[0] <= wxT(
'9' ) ) ) )
148 if( u == wxT(
'm' ) )
152#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
153 if( aActualConversion == wxT(
"SCH" )
154 || aActualConversion == wxT(
"SCHLIB" ) )
155 i = i * (0.0254 / 0.025);
171 if( ( aActualConversion == wxT(
"PCB" ) || aActualConversion == wxT(
"SCH" ) )
172 && aAxe == wxT(
'Y' ) )
179int StrToIntUnits(
const wxString& aStr,
char aAxe,
const wxString& aActualConversion )
190 result = wxEmptyString;
193 while( aStr->Len() > 0 && (*aStr)[0] != wxT(
' ' ) )
195 result += (*aStr)[0];
196 *aStr = aStr->Mid( 1 );
202 while( aStr->Len() > 0
203 && ( ( (*aStr)[0] >= wxT(
'a' ) && (*aStr)[0] <= wxT(
'z' ) )
204 || ( (*aStr)[0] >= wxT(
'A' ) && (*aStr)[0] <= wxT(
'Z' ) ) ) )
206 result += (*aStr)[0];
207 *aStr = aStr->Mid( 1 );
212 && ( result[result.Len() - 1] == wxT(
'.' )
213 || result[result.Len() - 1] == wxT(
',' )
214 || (result[result.Len() - 1] >= wxT(
'0' )
215 && result[result.Len() - 1] <= wxT(
'9' ) ) ) )
217 result += aDefaultMeasurementUnit;
226 double num, precision = 10;
228 aStr.ToCDouble( &num );
229 return KiROUND( num * precision );
235 wxString retv = aName;
236 retv.Replace( wxT(
" " ), wxT(
"_" ) );
245 reRef.Compile( wxT(
"^[[:digit:]][[:digit:]]*$" ) );
247 wxString retv = aRef;
249 if( reRef.Matches( retv ) )
250 retv.Prepend( wxT(
'.' ) );
256void SetWidth(
const wxString& aStr,
const wxString& aDefaultMeasurementUnit,
int* aWidth,
257 const wxString& aActualConversion )
262 wxT(
' ' ), aActualConversion );
266void SetHeight(
const wxString& aStr,
const wxString& aDefaultMeasurementUnit,
int* aHeight,
267 const wxString& aActualConversion )
272 wxT(
' ' ), aActualConversion );
276void SetPosition(
const wxString& aStr,
const wxString& aDefaultMeasurementUnit,
int* aX,
int* aY,
277 const wxString& aActualConversion )
282 wxT(
'X' ), aActualConversion );
284 wxT(
'Y' ), aActualConversion );
289 double* aX,
double* aY,
const wxString& aActualConversion )
306 if( aJustify.IsSameAs( wxT(
"LowerCenter" ),
false ) )
308 else if( aJustify.IsSameAs( wxT(
"LowerRight" ),
false ) )
310 else if( aJustify.IsSameAs( wxT(
"UpperLeft" ),
false ) )
312 else if( aJustify.IsSameAs( wxT(
"UpperCenter" ),
false ) )
314 else if( aJustify.IsSameAs( wxT(
"UpperRight" ),
false ) )
316 else if( aJustify.IsSameAs( wxT(
"Left" ),
false ) )
318 else if( aJustify.IsSameAs( wxT(
"Center" ),
false ) )
320 else if( aJustify.IsSameAs( wxT(
"Right" ),
false ) )
330 const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion )
335 tNode =
FindNode( aNode, wxT(
"pt" ) );
341 tNode =
FindNode( aNode, wxT(
"rotation" ) );
345 str = tNode->GetNodeContent();
356 if( str.IsSameAs( wxT(
"True" ),
false ) )
366 if( str.IsSameAs( wxT(
"True" ),
false ) )
371 tNode =
FindNode( aNode, wxT(
"textStyleRef" ) );
374 SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion );
379 const wxString& aActualConversion )
381 wxString n, propValue;
383 aNode->GetAttribute( wxT(
"Name" ), &n );
385 while( aNode->GetName() != wxT(
"www.lura.sk" ) )
388 aNode =
FindNode( aNode, wxT(
"library" ) );
391 aNode =
FindNode( aNode, wxT(
"textStyleDef" ) );
395 aNode->GetAttribute( wxT(
"Name" ), &propValue );
396 propValue.Trim(
false );
397 propValue.Trim(
true );
410 aTextValue->
isTrueType = ( propValue.IsSameAs( wxT(
"True" ),
false ) );
412 aNode =
FindNode( aNode, wxT(
"font" ) );
415 if( ( aTextValue->
isTrueType && !fontType.IsSameAs( wxT(
"TrueType" ),
false ) ) ||
416 ( !aTextValue->
isTrueType && !fontType.IsSameAs( wxT(
"Stroke" ),
false ) ) )
424 aTextValue->
isItalic = propValue.IsSameAs( wxT(
"True" ),
false );
428 if( propValue != wxEmptyString )
432 propValue.ToLong( &fontWeight );
439 lNode =
FindNode( aNode, wxT(
"fontHeight" ) );
442 SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit,
454 lNode =
FindNode( aNode, wxT(
"strokeWidth" ) );
457 SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit,
518 int cm = aValue->
mirror ? -1 : 1;
564 if( aChild->GetName().IsSameAs( aTag,
false ) )
576 wxString str = wxEmptyString;
582 str = aChild->GetNodeContent();
593 aTextValue->
text = wxEmptyString;
605 aTextValue->
isBold =
false;
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Hold an XML or S-expression element.
XNODE * GetParent() const
XNODE * GetChildren() const
static constexpr EDA_ANGLE ANGLE_0
wxString ValidateName(const wxString &aName)
wxString GetWord(wxString *aStr)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
int StrToInt1Units(const wxString &aStr)
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
void SetHeight(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aHeight, const wxString &aActualConversion)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
const double TRUETYPE_THICK_PER_HEIGHT
double StrToDoublePrecisionUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
wxString ValidateReference(const wxString &aRef)
const double STROKE_WIDTH_TO_SIZE
void SetTextSizeFromStrokeFontHeight(EDA_TEXT *aText, int aTextHeight)
const double TRUETYPE_BOLD_THICK_MUL
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
void SetDoublePrecisionPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, double *aX, double *aY, const wxString &aActualConversion)
TTEXT_JUSTIFY GetJustifyIdentificator(const wxString &aJustify)
const double TRUETYPE_HEIGHT_TO_SIZE
void SetTextJustify(EDA_TEXT *aText, TTEXT_JUSTIFY aJustify)
const double STROKE_HEIGHT_TO_SIZE
int CalculateTextLengthSize(TTEXTVALUE *aText)
XNODE * FindPinMap(XNODE *aNode)
void CorrectTextPosition(TTEXTVALUE *aValue)
const double TEXT_WIDTH_TO_SIZE_AVERAGE
const long TRUETYPE_BOLD_MIN_WEIGHT
void SetFontProperty(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)
void SetTextParameters(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
void InitTTextValue(TTEXTVALUE *aTextValue)
void SetTextSizeFromTrueTypeFontHeight(EDA_TEXT *aText, int aTextHeight)
const double TRUETYPE_WIDTH_TO_SIZE
constexpr int mmToIU(double mm) const
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I