57 "Append a point on x",
58 { vt::VT_POINT, { 500000, 0 } },
59 { { 0, 0 }, { 500000, 0 } },
63 "Append a point on y",
64 { vt::VT_POINT, { 0, 500000 } },
65 { { 0, 0 }, { 0, 500000 } },
69 "Append a Semicircle (clockwise)",
70 { vt::CLOCKWISE_SEMICIRCLE, { 500000, 0 } },
71 { { 0, 0 }, { 500000, 250000 } },
75 "Append a Semicircle (anticlockwise)",
76 { vt::ANTICLOCKWISE_SEMICIRCLE, { 500000, 0 } },
77 { { 0, -250000 }, { 500000, 250000 } },
81 "Append a 90 degree Arc (clockwise)",
82 { vt::CLOCKWISE_ARC, { 250000, 250000 }, { 250000, 0 } },
83 { { 0, 0 }, { 250000, 250000 } },
87 "Append a 90 degree Arc (anticlockwise)",
88 { vt::ANTICLOCKWISE_ARC, { 250000, -250000 }, { 250000, 0 } },
89 { { 0, -250000 }, { 250000, 250000 } },
98 static const std::vector<VECTOR2D> coordinateMultipliers =
111 BOOST_TEST_INFO_SCOPE( c.m_CaseName );
113 for(
const VECTOR2D& mult : coordinateMultipliers )
115 BOOST_TEST_INFO_SCOPE(
"Applied scaling x=" << mult.x <<
" y=" << mult.y );
119 auto transformCoord =
122 int x = double( aPt.x ) * mult.x;
123 int y = double( aPt.y ) * mult.y;
129 BOX2I expBoxTransformed;
130 expBoxTransformed.
SetOrigin( transformCoord( c.m_ExpBBox.GetPosition() ) );
131 expBoxTransformed.
SetSize( transformCoord( c.m_ExpBBox.GetSize() ) );
136 (
chain.BBox().GetPosition() )( expBoxTransformed.
GetPosition() ) ( c.m_ExpBBoxError ) );
140 (
chain.BBox().GetSize() )( expBoxTransformed.
GetSize() ) ( c.m_ExpBBoxError ) );
152 XNODE parent( wxXML_ELEMENT_NODE, wxT(
"VERTICES" ) );
155 new XNODE( &parent, wxXML_ELEMENT_NODE, wxT(
"PT" ) );
157 auto messageMentionsSection =
158 [](
const IO_ERROR& aError ) ->
bool
160 return aError.What().Contains( wxT(
"VERTICES" ) );
163 BOOST_CHECK_EXCEPTION(
174 for(
size_t i = 0; i < aValues.size(); ++i )
176 wxString attrName = wxString::Format( wxT(
"attr%zu" ), i );
181 wxString::Format( wxT(
"%zu" ), aValues.size() ) );
193 XNODE headerNode( wxXML_ELEMENT_NODE, wxT(
"HEADER" ) );
199 XNODE* unknownNode =
new XNODE( wxXML_ELEMENT_NODE, wxT(
"FUTURE_FEATURE" ) );
200 headerNode.AddChild( unknownNode );
205 BOOST_CHECK_NO_THROW(
header.Parse( &headerNode, &ctx ) );
218 XNODE routeCodeNode( wxXML_ELEMENT_NODE, wxT(
"ROUTECODE" ) );
221 XNODE* neckNode =
new XNODE( wxXML_ELEMENT_NODE, wxT(
"NECKWIDTH" ) );
223 routeCodeNode.AddChild( neckNode );
225 XNODE* unknownNode =
new XNODE( wxXML_ELEMENT_NODE, wxT(
"NEWFEATURE_V25" ) );
226 routeCodeNode.AddChild( unknownNode );
231 BOOST_CHECK_NO_THROW( routecode.
Parse( &routeCodeNode, &ctx ) );
245 XNODE alignNode( wxXML_ELEMENT_NODE, wxT(
"ALIGN" ) );
263 XNODE readNode( wxXML_ELEMENT_NODE, wxT(
"READABILITY" ) );
282 XNODE parentNode( wxXML_ELEMENT_NODE, wxT(
"PARENT" ) );
283 XNODE* childNode =
new XNODE( wxXML_ELEMENT_NODE, wxT(
"UNEXPECTED" ) );
284 parentNode.AddChild( childNode );
294 XNODE parentNode( wxXML_ELEMENT_NODE, wxT(
"PARENT" ) );
295 XNODE* child1 =
new XNODE( wxXML_ELEMENT_NODE, wxT(
"CHILD1" ) );
296 XNODE* child2 =
new XNODE( wxXML_ELEMENT_NODE, wxT(
"CHILD2" ) );
297 parentNode.AddChild( child1 );
298 parentNode.AddChild( child2 );
311 XNODE unitsNode( wxXML_ELEMENT_NODE, wxT(
"UNITS" ) );
329 XNODE pinTypeNode( wxXML_ELEMENT_NODE, wxT(
"PINTYPE" ) );
constexpr double SCH_IU_PER_MM
Schematic internal units 1=100nm.
CADSTAR_PIN_TYPE
file: cadstar_archive_objects.h Contains common object definitions
@ UNCOMMITTED
Uncommitted pin (default)
Helper functions and common defines between schematic and PCB Archive files.
constexpr const Vec & GetPosition() const
constexpr void SetOrigin(const Vec &pos)
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr void SetSize(const SizeVec &size)
constexpr const SizeVec & GetSize() const
READABILITY
Sets the readability direction of text.
@ BOTTOM_TO_TOP
When text is vertical, show it rotated 90 degrees anticlockwise.
static UNITS ParseUnits(XNODE *aNode)
static ALIGNMENT ParseAlignment(XNODE *aNode)
ALIGNMENT
From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all ...
@ NO_ALIGNMENT
NO_ALIGNMENT has different meaning depending on the object type.
static void CheckNoNextNodes(XNODE *aNode)
static READABILITY ParseReadability(XNODE *aNode)
static std::vector< POINT > ParseAllChildPoints(XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false, int aExpectedNumPoints=UNDEFINED_VALUE)
If no children are present, it just returns an empty vector (without throwing an exception).
@ DESIGN
Inherits from design units (assumed Assignments->Technology->Units)
static void CheckNoChildNodes(XNODE *aNode)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
static int DefaultAccuracyForPCB()
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
void AddAttribute(const wxString &aName, const wxString &aValue) override
bool IsVecWithinTol(const VEC &aVec, const VEC &aExp, typename VEC::coord_type aTol)
Check that both x and y of a vector are within expected error.
static void formatNode(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, const CPTREE &aTree)
static CADSTAR_PIN_TYPE GetPinType(XNODE *aNode)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
Represents a vertex in a shape.
CADSTAR_ARCHIVE_PARSER::VERTEX m_VertexToAppend
BOOST_AUTO_TEST_CASE(AppendToChain)
CADSTAR_ARCHIVE_PARSER::VERTEX_TYPE vt
static void AddCadstarAttributes(XNODE *aNode, const std::vector< wxString > &aValues)
Helper to add "attr0", "attr1", ... attributes to an XNODE, matching the format used by the CADSTAR S...
static const std::vector< VERTEX_APPEND_CASE > appendToChainCases
std::function< wxPoint(const wxPoint &)> m_CadstarToKicadPointCallback
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
std::vector< std::string > header
const SHAPE_LINE_CHAIN chain
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D