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";
61 std::filesystem::remove( savePath );
84 barcode->
SetText( wxT(
"12345" ) );
98 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"barcode_roundtrip.kicad_mod";
100 std::filesystem::remove( savePath );
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}" ) );
347 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
350 std::map<wxString, wxString> properties;
351 properties[wxT(
"PART_NUMBER" )] = wxT(
"PN12345" );
352 board->SetProperties( properties );
356 currentBarcode->
SetText( wxT(
"INITIAL_TEXT" ) );
367 *dummyBarcode = *currentBarcode;
371 BOOST_CHECK( dummyBarcode->
GetBoard() == board.get() );
372 BOOST_CHECK( dummyBarcode->
Text().
GetBoard() == board.get() );
375 dummyBarcode->
SetText( wxT(
"${PART_NUMBER}" ) );
383 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.
BOARD_ITEM_CONTAINER * GetParent() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
A base class for most all the KiCad significant classes used in schematics and boards.
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).
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_EQUAL(result, "25.4")
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
VECTOR2< int32_t > VECTOR2I