27#include <boost/test/unit_test.hpp>
42 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
45 barcode->
SetText( wxT(
"12345" ) );
59 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"barcode_roundtrip.kicad_pcb";
83 barcode->
SetText( wxT(
"12345" ) );
97 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"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 )
210 BOOST_CHECK_MESSAGE( canonicalPoly.
IsEmpty(),
211 "Test case " << i <<
" (" << tc.text.ToStdString() <<
"): "
212 "barcode poly isn't aligned with canonical shape" );
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 Vec Centre() const
virtual void SetVisible(bool aVisible)
PCB_TEXT & Text()
Access the internal PCB_TEXT object used for showing the human-readable text.
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 SetWidth(int aWidth)
void SetHeight(int aHeight)
void AssembleBarcode()
Assemble the barcode polygon and text polygons into a single polygonal representation.
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.
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_EQUAL(result, "25.4")
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
VECTOR2< int32_t > VECTOR2I