48 TEMP_FILE_HOLDER(
const std::string& aPrefix,
const std::string& aSuffix )
50 std::filesystem::path dir = std::filesystem::temp_directory_path() / aPrefix;
51 std::filesystem::create_directories( dir );
52 m_path = dir / (
"board" + aSuffix );
58 std::filesystem::remove( m_path, ec );
59 std::filesystem::remove( m_path.parent_path(), ec );
62 const std::filesystem::path& Path()
const {
return m_path; }
65 std::filesystem::path m_path;
69int mm(
double aMillimetres )
79 if( prim->GetShape() == aShape )
96 for(
int ii = 0; ii < expOutline.
PointCount(); ++ii )
115 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
116 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
118 fp->SetReference(
"U1" );
122 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 25.0 ) ) );
124 fp->SetTransformScale( 2.0, 1.5 );
126 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
128 pad->SetNumber(
"1" );
151 chain.SetClosed(
true );
167 const int expBezierWidth = bezier->
GetWidth();
169 const int expPolyWidth = poly->
GetWidth();
174 TEMP_FILE_HOLDER tmp(
"kicad_qa_custom_pad_primitive_roundtrip",
".kicad_pcb" );
180 FOOTPRINT* fpFound = reloaded->Footprints().empty() ? nullptr : reloaded->Footprints().front();
181 BOOST_REQUIRE_MESSAGE( fpFound,
"Footprint not found in reloaded board" );
182 BOOST_REQUIRE_MESSAGE( !fpFound->
Pads().empty(),
"Pad not found in reloaded footprint" );
184 PAD* padFound = fpFound->
Pads().front();
187 BOOST_REQUIRE_MESSAGE( bezierFound,
"Bezier primitive not found in reloaded pad" );
200 BOOST_REQUIRE_MESSAGE( polyFound,
"Polygon primitive not found in reloaded pad" );
210 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
211 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
212 fp->SetReference(
"U1" );
213 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
214 fp->SetTransformScale( 2.0, 1.5 );
216 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
218 pad->SetNumber(
"1" );
225 TEMP_FILE_HOLDER tmp(
"kicad_qa_scaled_fp_roundtrip",
".kicad_pcb" );
230 FOOTPRINT* r = reloaded->Footprints().front();
231 BOOST_CHECK_CLOSE( r->
GetScaleX(), 2.0, 1e-6 );
232 BOOST_CHECK_CLOSE( r->
GetScaleY(), 1.5, 1e-6 );
238 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
239 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
240 fp->SetReference(
"U1" );
241 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
243 fp->SetTransformScale( 2.0, 1.5 );
245 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
246 pad->SetNumber(
"1" );
251 pad->SetPosition(
VECTOR2I( mm( 53.0 ), mm( 51.0 ) ) );
260 TEMP_FILE_HOLDER tmp(
"kicad_qa_pad_pos_orient_roundtrip",
".kicad_pcb" );
265 PAD* r = reloaded->Footprints().front()->Pads().front();
274 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
275 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
276 fp->SetReference(
"U1" );
277 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
278 fp->SetTransformScale( 2.0, 1.5 );
280 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
281 pad->SetNumber(
"1" );
293 TEMP_FILE_HOLDER tmp(
"kicad_qa_pad_delta_roundtrip",
".kicad_pcb" );
298 PAD* r = reloaded->Footprints().front()->Pads().front();
309 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
310 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
311 fp->SetReference(
"U1" );
312 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
313 fp->SetTransformScale( 2.0, 1.5 );
315 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
317 pad->SetNumber(
"1" );
329 TEMP_FILE_HOLDER tmp(
"kicad_qa_pad_offset_roundtrip",
".kicad_pcb" );
334 PAD* r = reloaded->Footprints().front()->Pads().front();
345 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
346 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
347 fp->SetReference(
"U1" );
348 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
350 fp->SetTransformScale( 2.0, 1.5 );
352 std::unique_ptr<PCB_POINT> pt = std::make_unique<PCB_POINT>( fp.get() );
353 pt->SetLayer(
F_Cu );
354 pt->SetPosition(
VECTOR2I( mm( 55.0 ), mm( 52.0 ) ) );
361 TEMP_FILE_HOLDER tmp(
"kicad_qa_fp_point_roundtrip",
".kicad_pcb" );
366 FOOTPRINT* r = reloaded->Footprints().front();
378 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
379 std::unique_ptr<FOOTPRINT> fp = std::make_unique<FOOTPRINT>( board.get() );
380 fp->SetReference(
"U1" );
381 fp->SetPosition(
VECTOR2I( mm( 50.0 ), mm( 50.0 ) ) );
382 fp->SetTransformScale( 2.0, 1.5 );
384 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( fp.get() );
386 pad->SetNumber(
"1" );
398 TEMP_FILE_HOLDER tmp(
"kicad_qa_rotated_pad_roundtrip",
".kicad_pcb" );
403 PAD* r = reloaded->Footprints().front()->Pads().front();
428 pad->SetOrientation( aRelOrient );
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
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
bool IsPolyShapeValid() const
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
static constexpr EDA_ANGLE ANGLE_0
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::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
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I