29#include <wx/translation.h>
37 if( !aValue.ToCDouble( &value ) )
38 THROW_IO_ERROR( wxString::Format(
_(
"Failed to parse number from '%s'" ), aValue ) );
71 const wxString& baselineAlign )
75 if( baselineAlign == wxS(
"" ) || baselineAlign == wxS(
"auto" )
76 || baselineAlign == wxS(
"use-script" ) || baselineAlign == wxS(
"no-change" )
77 || baselineAlign == wxS(
"reset-size" ) || baselineAlign == wxS(
"alphabetic" )
78 || baselineAlign == wxS(
"inherit" ) )
82 else if( baselineAlign == wxS(
"ideographic" ) || baselineAlign == wxS(
"text-after-edge" ) )
86 else if( baselineAlign == wxS(
"central" ) )
90 else if( baselineAlign == wxS(
"middle" ) )
94 else if( baselineAlign == wxS(
"mathematical" ) )
98 else if( baselineAlign == wxS(
"hanging" ) || baselineAlign == wxS(
"text-before-edge" ) )
110std::vector<SHAPE_LINE_CHAIN>
113 std::vector<SHAPE_LINE_CHAIN> result;
119 auto readNumber = [&]( wxString& aOut )
121 wxUniChar ch = data[pos];
123 while( ch ==
' ' || ch ==
',' )
126 while( isdigit( ch ) || ch ==
'.' || ch ==
'-' )
131 if( pos == data.size() )
140 wxUniChar sym = data[pos++];
157 result.emplace_back(
chain );
167 else if( sym ==
'Z' )
172 result.emplace_back(
chain );
176 else if( sym ==
'L' || isdigit( sym ) || sym ==
'-' )
180 if( isdigit( sym ) || sym ==
'-' )
185 if( pos >= data.size() )
188 wxUniChar ch = data[pos];
190 while( ch ==
' ' || ch ==
',' )
192 if( ++pos >= data.size() )
198 if( !isdigit( ch ) && ch !=
'-' )
212 else if( sym ==
'A' )
217 if( pos >= data.size() )
220 wxUniChar ch = data[pos];
222 while( ch ==
' ' || ch ==
',' )
224 if( ++pos >= data.size() )
230 if( !isdigit( ch ) && ch !=
'-' )
233 wxString radX, radY,
unknown, farFlag, cwFlag, endX, endY;
238 readNumber( farFlag );
239 readNumber( cwFlag );
243 bool isFar = farFlag == wxS(
"1" );
244 bool cw = cwFlag == wxS(
"1" );
251 double d =
delta.EuclideanNorm();
252 double h = sqrt( std::max( 0.0, rad.
x * rad.
x - d * d / 4 ) );
258 VECTOR2D arcCenter = start +
delta / 2 +
delta.Perpendicular().Resize( ( isFar ^
cw ) ? h : -h );
268 else if( sym ==
'C' )
270 wxString p1_xStr, p1_yStr, p2_xStr, p2_yStr, p3_xStr, p3_yStr;
271 readNumber( p1_xStr );
272 readNumber( p1_yStr );
273 readNumber( p2_xStr );
274 readNumber( p2_yStr );
275 readNumber( p3_xStr );
276 readNumber( p3_yStr );
286 std::vector<VECTOR2I> bezierPoints;
287 converter.
GetPoly( bezierPoints, aMaxError );
293 }
while( pos < data.size() );
300 result.emplace_back(
chain );
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMaxError=10)
Convert a Bezier curve to a polygon.
static double Convert(const wxString &aValue)
double RelPosX(double aValue)
double RelPosY(double aValue)
VECTOR2< T > RelPos(const VECTOR2< T > &aVec)
void TransformTextToBaseline(EDA_TEXT *textItem, const wxString &baselineAlign)
std::vector< SHAPE_LINE_CHAIN > ParseLineChains(const wxString &aData, int aMaxError, bool aForceClosed)
virtual double ScaleSize(double aValue)=0
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const VECTOR2I & GetTextPos() const
const EDA_ANGLE & GetTextAngle() const
void SetTextPos(const VECTOR2I &aPoint)
VECTOR2I GetTextSize() const
SHAPE_ARC & ConstructFromStartEndCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aClockwise=false, double aWidth=0)
Constructs this arc from the given start, end and center.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Clear()
Remove all points from the line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
#define THROW_IO_ERROR(msg)
const SHAPE_LINE_CHAIN chain
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.