24#include <boost/test/unit_test.hpp>
39 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
42 barcode->
SetText( wxT(
"12345" ) );
57 const std::filesystem::path savePath = tempDir.
Path() /
"barcode_roundtrip.kicad_pcb";
81 barcode->
SetText( wxT(
"12345" ) );
98 const std::filesystem::path libPath = tempLib.
CreateChildDir(
"barcode_roundtrip.pretty" );
99 const std::filesystem::path savePath = libPath /
"barcode_roundtrip.kicad_mod";
106 for(
BOARD_ITEM* item : footprint2->GraphicalItems() )
130 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
145 std::vector<TestCase> testCases = {
170 for(
size_t i = 0; i < testCases.size(); ++i )
172 const auto& tc = testCases[i];
188 if( tc.angle != 0.0 )
204 for(
int ii = 0; ii < barcodePoly.
OutlineCount(); ++ii )
208 if( tc.angle != 0.0 )
212 BOOST_CHECK_MESSAGE( canonicalPoly.
IsEmpty(),
213 "Test case " << i <<
" (" << tc.text.ToStdString() <<
"): "
214 "barcode poly isn't aligned with canonical shape" );
225 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
228 std::map<wxString, wxString> properties;
229 properties[wxT(
"PART_NUMBER" )] = wxT(
"PN12345" );
230 properties[wxT(
"VERSION" )] = wxT(
"1.0" );
231 board->SetProperties( properties );
235 barcode->
SetText( wxT(
"${PART_NUMBER}_${VERSION}" ) );
256 refBarcode->
SetText( wxT(
"PN12345_1.0" ) );
284 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
290 barcode->
SetText( wxT(
"${UNDEFINED_VAR}" ) );
318 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
325 barcode->
SetText( wxT(
"${UNDEFINED_VAR}" ) );
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...
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
std::filesystem::path CreateChildDir(const wxString &aName) const
Create and return the path to a direct child directory.
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.
wxString GetShownText(RESOLUTION_CONTEXT aContext) const
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).
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.
void DumpFootprintToFile(const FOOTPRINT &aFootprint, const std::filesystem::path &aLibraryPath)
Same as DumpBoardToFile, but for footprints.
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::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
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_EQUAL(result, "25.4")
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
VECTOR2< int32_t > VECTOR2I