27#include <boost/test/unit_test.hpp>
42 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
45 barcode->
SetText( wxT(
"12345" ) );
60 const std::filesystem::path savePath = tempDir.
GetPath() /
"barcode_roundtrip.kicad_pcb";
84 barcode->
SetText( wxT(
"12345" ) );
101 const std::filesystem::path savePath = tempLib.
GetPath() /
"barcode_roundtrip.kicad_mod";
108 for(
BOARD_ITEM* item : footprint2->GraphicalItems() )
132 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
147 std::vector<TestCase> testCases = {
172 for(
size_t i = 0; i < testCases.size(); ++i )
174 const auto& tc = testCases[i];
190 if( tc.angle != 0.0 )
206 for(
int ii = 0; ii < barcodePoly.
OutlineCount(); ++ii )
210 if( tc.angle != 0.0 )
215 "Test case " << i <<
" (" << tc.text.ToStdString() <<
"): "
216 "barcode poly isn't aligned with canonical shape" );
227 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
230 std::map<wxString, wxString> properties;
231 properties[wxT(
"PART_NUMBER" )] = wxT(
"PN12345" );
232 properties[wxT(
"VERSION" )] = wxT(
"1.0" );
233 board->SetProperties( properties );
237 barcode->
SetText( wxT(
"${PART_NUMBER}_${VERSION}" ) );
258 refBarcode->
SetText( wxT(
"PN12345_1.0" ) );
286 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
292 barcode->
SetText( wxT(
"${UNDEFINED_VAR}" ) );
320 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
327 barcode->
SetText( wxT(
"${UNDEFINED_VAR}" ) );
349 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
352 std::map<wxString, wxString> properties;
353 properties[wxT(
"PART_NUMBER" )] = wxT(
"PN12345" );
354 board->SetProperties( properties );
358 currentBarcode->
SetText( wxT(
"INITIAL_TEXT" ) );
369 *dummyBarcode = *currentBarcode;
371 BOOST_CHECK( dummyBarcode->
GetBoard() == board.get() );
374 dummyBarcode->
SetText( wxT(
"${PART_NUMBER}" ) );
382 currentBarcode->
SetText( wxT(
"${PART_NUMBER}" ) );
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
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...
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
A temporary directory that will be deleted when it goes out of scope.
const std::filesystem::path & GetPath() const
void SetKind(BARCODE_T aKind)
void SetTextSize(int aTextSize)
Change the height of the human-readable text displayed below the barcode.
void SetErrorCorrection(BARCODE_ECC_T aErrorCorrection)
Set the error correction level used for QR codes.
void SetShowText(bool aShow)
void SetWidth(int aWidth)
void AssembleBarcode() const
Assemble the barcode polygon and text polygons into a single polygonal representation.
void SetHeight(int aHeight)
VECTOR2I GetPosition() const override
Get the position (center) of the barcode in internal units.
void SetPosition(const VECTOR2I &aPos) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the drawing layer for the barcode and its text.
int GetHeight() const
Get the barcode height (in internal units).
wxString GetShownText() const
void SetIsKnockout(bool aEnable) override
const SHAPE_POLY_SET & GetPolyShape() const
Access the underlying polygonal representation generated for the barcode.
const SHAPE_POLY_SET & GetSymbolPoly() const
Access the cached polygon for the barcode symbol only (no text, no margins/knockout).
BARCODE_ECC_T GetErrorCorrection() const
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate the barcode around a given centre by the given angle.
EDA_ANGLE GetAngle() const
BARCODE_T GetKind() const
Returns the type of the barcode (QR, CODE_39, etc.).
int GetWidth() const
Get the barcode width (in internal units).
void SetText(const wxString &aText)
Set the barcode content text to encode.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
void Unfracture()
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
@ ROUND_ALL_CORNERS
All angles are rounded.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
std::unique_ptr< FOOTPRINT > ReadFootprintFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
void DumpFootprintToFile(const FOOTPRINT &aFootprint, const std::string &aLibraryPath)
Same as DumpBoardToFile, but for footprints.
BOARD_ITEM & RequireBoardItemWithTypeAndId(const BOARD &aBoard, KICAD_T aItemType, const KIID &aID)
Get an item from the given board with a certain type and UUID.
BARCODE class definition.
BOOST_AUTO_TEST_CASE(BarcodeWriteRead)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
VECTOR2< int32_t > VECTOR2I