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++];
 
  152            if( 
chain.PointCount() > 1 )
 
  155                    chain.SetClosed( 
true );
 
  167        else if( sym == 
'Z' )
 
  169            if( 
chain.PointCount() > 2 )
 
  171                chain.SetClosed( 
true );
 
  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 );
 
  263                chain.Append( arc, aMaxError );
 
  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 );
 
  289            chain.Append( bezierPoints );
 
  293    } 
while( pos < data.size() );
 
  295    if( 
chain.PointCount() > 1 )
 
  298            chain.SetClosed( 
true );
 
 
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...
 
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
 
const SHAPE_LINE_CHAIN chain
 
wxString result
Test unit parsing edge cases and error handling.
 
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
 
VECTOR2< double > VECTOR2D