30#include <wx/filename.h>
31#include <wx/stdpaths.h>
50 TEMP_FILE_HOLDER(
const std::string& aPrefix,
const std::string& aSuffix )
52 std::filesystem::path dir = std::filesystem::temp_directory_path() / aPrefix;
53 std::filesystem::create_directories( dir );
54 m_path = dir / (
"board" + aSuffix );
60 std::filesystem::remove( m_path, ec );
61 std::filesystem::remove( m_path.parent_path(), ec );
64 const std::filesystem::path& Path()
const {
return m_path; }
67 std::filesystem::path m_path;
76 auto board = std::make_unique<BOARD>();
77 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
79 shape->SetEllipseCenter(
VECTOR2I( 100000, 200000 ) );
80 shape->SetEllipseMajorRadius( 50000 );
81 shape->SetEllipseMinorRadius( 30000 );
84 shape->SetWidth( 150 );
88 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_closed",
".kicad_pcb" );
110 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
123 auto board = std::make_unique<BOARD>();
124 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
126 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
127 shape->SetEllipseMajorRadius( 40000 );
128 shape->SetEllipseMinorRadius( 25000 );
133 shape->SetWidth( 200 );
136 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_arc",
".kicad_pcb" );
144 for(
BOARD_ITEM* item : reloaded->Drawings() )
156 BOOST_REQUIRE_MESSAGE( found,
"Elliptical arc not found in reloaded board" );
170 auto board = std::make_unique<BOARD>();
171 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
173 shape->SetEllipseCenter(
VECTOR2I( 50000, 50000 ) );
174 shape->SetEllipseMajorRadius( 30000 );
175 shape->SetEllipseMinorRadius( 20000 );
176 shape->SetEllipseRotation(
ANGLE_0 );
182 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_stroke_fill",
".kicad_pcb" );
190 for(
BOARD_ITEM* item : reloaded->Drawings() )
202 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
211 auto board = std::make_unique<BOARD>();
212 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
214 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
215 shape->SetEllipseMajorRadius( 10000 );
216 shape->SetEllipseMinorRadius( 5000 );
217 shape->SetEllipseRotation(
ANGLE_0 );
219 shape->SetWidth( 150 );
220 shape->SetLocked(
true );
223 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_locked",
".kicad_pcb" );
231 for(
BOARD_ITEM* item : reloaded->Drawings() )
243 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
250 auto board = std::make_unique<BOARD>();
251 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
253 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
254 shape->SetEllipseMajorRadius( 40000 );
255 shape->SetEllipseMinorRadius( 20000 );
258 shape->SetWidth( 150 );
261 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_negrot",
".kicad_pcb" );
269 for(
BOARD_ITEM* item : reloaded->Drawings() )
281 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
288 auto board = std::make_unique<BOARD>();
289 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
291 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
292 shape->SetEllipseMajorRadius( 30000 );
293 shape->SetEllipseMinorRadius( 15000 );
294 shape->SetEllipseRotation(
ANGLE_0 );
298 shape->SetWidth( 150 );
301 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_start_eq_end",
".kicad_pcb" );
309 for(
BOARD_ITEM* item : reloaded->Drawings() )
321 BOOST_REQUIRE_MESSAGE( found,
"Elliptical arc not found in reloaded board" );
329 auto board = std::make_unique<BOARD>();
330 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
332 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
333 shape->SetEllipseMajorRadius( 1 );
334 shape->SetEllipseMinorRadius( 1 );
335 shape->SetEllipseRotation(
ANGLE_0 );
337 shape->SetWidth( 150 );
340 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_minradii",
".kicad_pcb" );
348 for(
BOARD_ITEM* item : reloaded->Drawings() )
360 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
368 auto board = std::make_unique<BOARD>();
369 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
371 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
372 shape->SetEllipseMajorRadius( 500000000 );
373 shape->SetEllipseMinorRadius( 250000000 );
376 shape->SetWidth( 150 );
379 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_largeradii",
".kicad_pcb" );
387 for(
BOARD_ITEM* item : reloaded->Drawings() )
399 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
407 auto board = std::make_unique<BOARD>();
408 auto fp = std::make_unique<FOOTPRINT>( board.get() );
409 fp->SetReference(
"U1" );
410 fp->SetPosition(
VECTOR2I( 100000, 100000 ) );
412 auto shape = std::make_unique<PCB_SHAPE>( fp.get() );
414 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
415 shape->SetEllipseMajorRadius( 20000 );
416 shape->SetEllipseMinorRadius( 10000 );
419 shape->SetWidth( 150 );
424 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_fp",
".kicad_pcb" );
430 FOOTPRINT* fpFound = reloaded->Footprints().empty() ? nullptr : reloaded->Footprints().front();
431 BOOST_REQUIRE_MESSAGE( fpFound,
"Footprint not found in reloaded board" );
447 BOOST_REQUIRE_MESSAGE( found,
"fp_ellipse not found in reloaded footprint" );
456 auto board = std::make_unique<BOARD>();
457 auto fp = std::make_unique<FOOTPRINT>( board.get() );
458 fp->SetReference(
"U2" );
459 fp->SetPosition(
VECTOR2I( 0, 0 ) );
461 auto shape = std::make_unique<PCB_SHAPE>( fp.get() );
463 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
464 shape->SetEllipseMajorRadius( 15000 );
465 shape->SetEllipseMinorRadius( 8000 );
469 shape->SetLayer(
F_Fab );
470 shape->SetWidth( 100 );
475 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_fp_arc",
".kicad_pcb" );
481 FOOTPRINT* fpFound = reloaded->Footprints().empty() ? nullptr : reloaded->Footprints().front();
482 BOOST_REQUIRE_MESSAGE( fpFound,
"Footprint not found in reloaded board" );
498 BOOST_REQUIRE_MESSAGE( found,
"fp_ellipse_arc not found in reloaded footprint" );
509 auto board = std::make_unique<BOARD>();
510 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
512 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
513 shape->SetEllipseMajorRadius( 30000 );
514 shape->SetEllipseMinorRadius( 15000 );
515 shape->SetEllipseRotation(
ANGLE_0 );
519 shape->SetWidth( 150 );
522 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_wraparound",
".kicad_pcb" );
530 for(
BOARD_ITEM* item : reloaded->Drawings() )
542 BOOST_REQUIRE_MESSAGE( found,
"Elliptical arc not found in reloaded board" );
550 auto board = std::make_unique<BOARD>();
551 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
553 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
554 shape->SetEllipseMajorRadius( 20000 );
555 shape->SetEllipseMinorRadius( 10000 );
556 shape->SetEllipseRotation(
ANGLE_0 );
560 shape->SetWidth( 150 );
563 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_negstart",
".kicad_pcb" );
571 for(
BOARD_ITEM* item : reloaded->Drawings() )
583 BOOST_REQUIRE_MESSAGE( found,
"Elliptical arc not found in reloaded board" );
591 auto board = std::make_unique<BOARD>();
592 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
594 shape->SetEllipseCenter(
VECTOR2I( 100000, 100000 ) );
595 shape->SetEllipseMajorRadius( 50000 );
596 shape->SetEllipseMinorRadius( 30000 );
599 shape->SetWidth( 150 );
602 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_edgecuts",
".kicad_pcb" );
610 for(
BOARD_ITEM* item : reloaded->Drawings() )
622 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
629 auto board = std::make_unique<BOARD>();
630 auto shape = std::make_unique<PCB_SHAPE>( board.get() );
632 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
633 shape->SetEllipseMajorRadius( 25000 );
634 shape->SetEllipseMinorRadius( 15000 );
635 shape->SetEllipseRotation(
ANGLE_0 );
636 shape->SetLayer(
B_Cu );
637 shape->SetWidth( 200 );
640 TEMP_FILE_HOLDER tmp(
"kicad_qa_ellipse_roundtrip_bcu",
".kicad_pcb" );
648 for(
BOARD_ITEM* item : reloaded->Drawings() )
660 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in reloaded board" );
General utilities for PCB file IO for QA programs.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
bool IsLocked() const override
int GetEllipseMinorRadius() const
const VECTOR2I & GetEllipseCenter() const
EDA_ANGLE GetEllipseEndAngle() const
FILL_T GetFillMode() const
int GetEllipseMajorRadius() const
EDA_ANGLE GetEllipseRotation() const
EDA_ANGLE GetEllipseStartAngle() const
STROKE_PARAMS GetStroke() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
static constexpr EDA_ANGLE ANGLE_0
@ FILLED_SHAPE
Fill with object color.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(ClosedEllipseRoundTrip)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I