23#include <boost/test/unit_test.hpp>
38 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
41 barcode->
SetText( wxT(
"12345" ) );
56 const std::filesystem::path savePath = tempDir.
GetPath() /
"barcode_roundtrip.kicad_pcb";
80 barcode->
SetText( wxT(
"12345" ) );
97 const std::filesystem::path savePath = tempLib.
GetPath() /
"barcode_roundtrip.kicad_mod";
104 for(
BOARD_ITEM* item : footprint2->GraphicalItems() )
128 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
143 std::vector<TestCase> testCases = {
168 for(
size_t i = 0; i < testCases.size(); ++i )
170 const auto& tc = testCases[i];
186 if( tc.angle != 0.0 )
202 for(
int ii = 0; ii < barcodePoly.
OutlineCount(); ++ii )
206 if( tc.angle != 0.0 )
211 "Test case " << i <<
" (" << tc.text.ToStdString() <<
"): "
212 "barcode poly isn't aligned with canonical shape" );
223 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
226 std::map<wxString, wxString> properties;
227 properties[wxT(
"PART_NUMBER" )] = wxT(
"PN12345" );
228 properties[wxT(
"VERSION" )] = wxT(
"1.0" );
229 board->SetProperties( properties );
233 barcode->
SetText( wxT(
"${PART_NUMBER}_${VERSION}" ) );
254 refBarcode->
SetText( wxT(
"PN12345_1.0" ) );
282 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
288 barcode->
SetText( wxT(
"${UNDEFINED_VAR}" ) );
316 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
323 barcode->
SetText( wxT(
"${UNDEFINED_VAR}" ) );
345 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
348 std::map<wxString, wxString> properties;
349 properties[wxT(
"PART_NUMBER" )] = wxT(
"PN12345" );
350 board->SetProperties( properties );
354 currentBarcode->
SetText( wxT(
"INITIAL_TEXT" ) );
365 *dummyBarcode = *currentBarcode;
367 BOOST_CHECK( dummyBarcode->
GetBoard() == board.get() );
370 dummyBarcode->
SetText( wxT(
"${PART_NUMBER}" ) );
378 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