45int mm(
double aMillimetres )
55 if( prim->GetShape() == aShape )
72 for(
int ii = 0; ii < expOutline.
PointCount(); ++ii )
91 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
92 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
94 fp->SetReference(
"U1" );
98 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 25.0 ) ) );
100 fp->SetTransformScale( 2.0, 1.5 );
102 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
104 pad->SetNumber(
"1" );
127 chain.SetClosed(
true );
143 const int expBezierWidth = bezier->
GetWidth();
145 const int expPolyWidth = poly->
GetWidth();
151 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
158 FOOTPRINT* fpFound = reloaded->Footprints().empty() ? nullptr : reloaded->Footprints().front();
159 BOOST_REQUIRE_MESSAGE( fpFound,
"Footprint not found in reloaded board" );
160 BOOST_REQUIRE_MESSAGE( !fpFound->
Pads().empty(),
"Pad not found in reloaded footprint" );
162 PAD* padFound = fpFound->
Pads().front();
165 BOOST_REQUIRE_MESSAGE( bezierFound,
"Bezier primitive not found in reloaded pad" );
178 BOOST_REQUIRE_MESSAGE( polyFound,
"Polygon primitive not found in reloaded pad" );
188 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
189 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
191 fp->SetReference(
"U1" );
195 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 25.0 ) ) );
197 fp->SetTransformScale( 2.0, 1.5 );
199 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
201 pad->SetNumber(
"1" );
219 circle->SetWidth( mm( 0.01 ) );
225 const int expSegWidth = seg->
GetWidth();
233 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
240 FOOTPRINT* fpFound = reloaded->Footprints().empty() ? nullptr : reloaded->Footprints().front();
241 BOOST_REQUIRE_MESSAGE( fpFound,
"Footprint not found in reloaded board" );
242 BOOST_REQUIRE_MESSAGE( !fpFound->
Pads().empty(),
"Pad not found in reloaded footprint" );
244 PAD* padFound = fpFound->
Pads().front();
247 BOOST_REQUIRE_MESSAGE( segFound,
"Segment primitive not found in reloaded pad" );
256 BOOST_REQUIRE_MESSAGE( circleFound,
"Elipse primitive not found in reloaded pad" );
267 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
268 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
269 fp->SetReference(
"U1" );
270 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
271 fp->SetTransformScale( 2.0, 1.5 );
273 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
275 pad->SetNumber(
"1" );
283 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
289 FOOTPRINT* r = reloaded->Footprints().front();
290 BOOST_CHECK_CLOSE( r->
GetScaleX(), 2.0, 1e-6 );
291 BOOST_CHECK_CLOSE( r->
GetScaleY(), 1.5, 1e-6 );
297 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
298 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
299 fp->SetReference(
"U1" );
300 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
302 fp->SetTransformScale( 2.0, 1.5 );
304 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
305 pad->SetNumber(
"1" );
310 pad->SetPosition(
VECTOR2I( mm( 53.0 ), mm( 51.0 ) ) );
320 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
326 PAD* r = reloaded->Footprints().front()->Pads().front();
335 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
336 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
337 fp->SetReference(
"U1" );
338 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
339 fp->SetTransformScale( 2.0, 1.5 );
341 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
342 pad->SetNumber(
"1" );
355 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
361 PAD* r = reloaded->Footprints().front()->Pads().front();
372 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
373 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
374 fp->SetReference(
"U1" );
375 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
376 fp->SetTransformScale( 2.0, 1.5 );
378 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
380 pad->SetNumber(
"1" );
393 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
399 PAD* r = reloaded->Footprints().front()->Pads().front();
410 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
411 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
412 fp->SetReference(
"U1" );
413 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
415 fp->SetTransformScale( 2.0, 1.5 );
417 std::unique_ptr<PCB_POINT> pt = std::make_unique<PCB_POINT>( fp.get() );
418 pt->SetLayer(
F_Cu );
419 pt->SetPosition(
VECTOR2I( mm( 55.0 ), mm( 52.0 ) ) );
427 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
433 FOOTPRINT* r = reloaded->Footprints().front();
445 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
446 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
447 fp->SetReference(
"U1" );
448 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
449 fp->SetTransformScale( 2.0, 1.5 );
451 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
453 pad->SetNumber(
"1" );
466 std::filesystem::path boardFile = tmp.
Path() /
"board.kicad_pcb";
472 PAD* r = reloaded->Footprints().front()->Pads().front();
497 pad->SetOrientation( aRelOrient );
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
constexpr size_type GetWidth() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
bool IsPolyShapeValid() const
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
LSET is a set of PCB_LAYER_IDs.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
VECTOR2I GetPosition() const override
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
VECTOR2I GetPosition() const override
void SetBezierC1(const VECTOR2I &aPt) override
VECTOR2I GetLibraryBezierC1() const
void SetWidth(int aWidth) override
int GetWidth() const override
void SetShape(SHAPE_T aShape) override
void SetEnd(const VECTOR2I &aEnd) override
VECTOR2I GetLibraryEnd() const
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
VECTOR2I GetLibraryStart() const
void SetStart(const VECTOR2I &aStart) override
void SetBezierC2(const VECTOR2I &aPt) override
SHAPE_POLY_SET GetLibraryPolyShape() const
VECTOR2I GetLibraryBezierC2() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
static constexpr EDA_ANGLE ANGLE_0
std::unique_ptr< BOARD > ReadBoardFromFile(const std::filesystem::path &aFilename)
void DumpBoardToFile(BOARD &board, const std::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
@ SMD
Smd pad, appears on the solder paste layer (default)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(BezierAndPolyOnTransformedFootprint)
A custom pad's bezier and polygon primitives must survive a save/reload unchanged,...
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
const SHAPE_LINE_CHAIN chain
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I