71 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
73 kicadPlugin.LoadBoard( dataPath +
"LayerWildcard.kicad_pcb", testBoard.get() );
76 BOOST_CHECK( testBoard->Zones().size() == 1 );
78 ZONE* z = testBoard->Zones()[0];
88 auto tmpBoard = std::filesystem::temp_directory_path() /
"Issue19775_RoundTrip.kicad_pcb";
92 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
93 kicadPlugin.LoadBoard( dataPath +
"LayerEnumerate.kicad_pcb", testBoard.get() );
94 kicadPlugin.SaveBoard( tmpBoard.string(), testBoard.get() );
98 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
99 kicadPlugin.LoadBoard( tmpBoard.string(), testBoard.get() );
102 BOOST_CHECK( testBoard->Zones().size() == 1 );
104 ZONE* z = testBoard->Zones()[0];
125 +
"plugins/kicad_sexpr/Issue23125_EmptyZone/";
127 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
129 kicadPlugin.LoadBoard( dataPath +
"EmptyZone.kicad_pcb", testBoard.get() );
136 ZONE* z = testBoard->Zones()[0];
150 +
"plugins/kicad_sexpr/";
152 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
154 kicadPlugin.LoadBoard( dataPath +
"ScientificNotation.kicad_pcb", testBoard.get() );
177 +
"plugins/kicad_sexpr/Issue23625_CorruptedStackup/";
179 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
181 BOOST_CHECK_NO_THROW( kicadPlugin.LoadBoard( dataPath +
"corrupted_stackup.kicad_pcb",
185 testBoard->GetDesignSettings().GetStackupDescriptor();
190 BOOST_CHECK_LE( stackup.
GetCount(), 128 );
191 BOOST_CHECK_GT( stackup.
GetCount(), 0 );
206 std::string destinationPath = dataPath +
"issue3812.kicad_pcb";
208 std::string sourcePath = dataPath +
"issue18142.kicad_pcb";
209 std::map<std::string, UTF8> props;
223 int copperLayerCount = 0;
231 return copperLayerCount;
245 std::unique_ptr<BOARD> testBoard = std::make_unique<BOARD>();
247 kicadPlugin.LoadBoard( destinationPath, testBoard.get() );
249 const BOARD_STACKUP& initialStackup = testBoard->GetDesignSettings().GetStackupDescriptor();
250 const BOARD_STACKUP_ITEM* initialFirstDielectric = findFirstDielectric( initialStackup );
251 const int initialCopperLayerCount = testBoard->GetCopperLayerCount();
252 const LSET initialEnabledLayers = testBoard->GetEnabledLayers();
253 const wxString initialFinishType = initialStackup.
m_FinishType;
255 BOOST_REQUIRE_EQUAL( initialCopperLayerCount, 4 );
256 BOOST_REQUIRE_EQUAL( countCopperLayers( initialStackup ), 4 );
258 BOOST_REQUIRE_EQUAL( initialFinishType, wxS(
"ENIG" ) );
259 const wxString initialFirstDielectricMaterial = initialFirstDielectric->
GetMaterial();
260 const int initialFirstDielectricThickness = initialFirstDielectric->
GetThickness();
262 kicadPlugin.LoadBoard( sourcePath, testBoard.get(), &props );
264 const int appendedCopperLayerCount = testBoard->GetCopperLayerCount();
266 if( appendedCopperLayerCount > initialCopperLayerCount )
267 testBoard->SetCopperLayerCount( appendedCopperLayerCount );
269 LSET enabledLayers = testBoard->GetEnabledLayers();
270 enabledLayers |= initialEnabledLayers;
271 testBoard->SetEnabledLayers( enabledLayers );
272 testBoard->GetDesignSettings().GetStackupDescriptor().SynchronizeWithBoard( &testBoard->GetDesignSettings() );
274 const BOARD_STACKUP& finalStackup = testBoard->GetDesignSettings().GetStackupDescriptor();
305 auto tmpLib = std::filesystem::temp_directory_path() /
"qa_fp_save_netinfo.pretty";
306 std::filesystem::remove_all( tmpLib );
307 std::filesystem::create_directories( tmpLib );
309 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
316 fp->
SetFPID(
LIB_ID( wxT(
"scratch" ), wxT(
"test_fp_save_netinfo" ) ) );
337 BOOST_REQUIRE_EQUAL(
pad->GetNet(), net );
338 BOOST_REQUIRE_EQUAL( shape->
GetNet(), net );
339 BOOST_REQUIRE_EQUAL( zone->
GetNet(), net );
342 BOOST_REQUIRE_NO_THROW( kicadPlugin.FootprintSave( tmpLib.string(), fp ) );
344 auto savedFile = tmpLib /
"test_fp_save_netinfo.kicad_mod";
347 std::ifstream in( savedFile );
348 BOOST_REQUIRE_MESSAGE( in.is_open(),
349 "Failed to open serialized footprint: " << savedFile.string() );
351 std::stringstream ss;
355 const std::string contents = ss.str();
359 "Saved footprint library file must not contain (net ...) tokens:\n"
367 std::unique_ptr<FOOTPRINT> detached(
static_cast<FOOTPRINT*
>( fp->
Clone() ) );
368 detached->SetParent(
nullptr );
369 detached->SetParentGroup(
nullptr );
370 detached->ClearAllNets();
376 detached->RunOnChildren(
379 switch( aItem->
Type() )
396 std::filesystem::remove_all( tmpLib );
410 std::unique_ptr<BOARD> writeBoard = std::make_unique<BOARD>();
412 ZONE* zone =
new ZONE( writeBoard.get() );
429 writeBoard->Add( zone );
431 std::filesystem::path tmpPath = std::filesystem::temp_directory_path()
432 /
"copper_thieving_roundtrip.kicad_pcb";
435 writer.
SaveBoard( tmpPath.string(), writeBoard.get() );
437 std::unique_ptr<BOARD>
readBoard = std::make_unique<BOARD>();
441 BOOST_REQUIRE_EQUAL(
readBoard->Zones().size(), 1u );
457 std::filesystem::remove( tmpPath );
467 const std::array<THIEVING_PATTERN, 3> patterns = {
477 std::unique_ptr<BOARD> writeBoard = std::make_unique<BOARD>();
479 ZONE* zone =
new ZONE( writeBoard.get() );
491 writeBoard->Add( zone );
493 std::filesystem::path tmpPath = std::filesystem::temp_directory_path()
494 /
"copper_thieving_pattern.kicad_pcb";
496 writer.
SaveBoard( tmpPath.string(), writeBoard.get() );
498 std::unique_ptr<BOARD>
readBoard = std::make_unique<BOARD>();
502 BOOST_REQUIRE_EQUAL(
readBoard->Zones().size(), 1u );
503 BOOST_CHECK(
readBoard->Zones()[0]->GetThievingSettings().pattern == pattern );
505 std::filesystem::remove( tmpPath );
519 std::filesystem::path tmpPath = std::filesystem::temp_directory_path()
520 /
"copper_thieving_old_version.kicad_pcb";
521 std::ofstream out( tmpPath );
524 out <<
"(kicad_pcb (version 20260512) (generator \"test\") (generator_version \"test\")"
525 <<
" (general (thickness 1.6)) (paper \"A4\")"
526 <<
" (layers (0 \"F.Cu\" signal) (31 \"B.Cu\" signal))"
527 <<
" (zone (net 0) (net_name \"\") (layer \"F.Cu\") (uuid \"00000000-0000-0000-0000-000000000001\")"
528 <<
" (hatch edge 0.5)"
529 <<
" (connect_pads (clearance 0))"
530 <<
" (min_thickness 0.25) (filled_areas_thickness no)"
531 <<
" (fill yes (mode thieving) (thermal_gap 0.5) (thermal_bridge_width 0.5)"
532 <<
" (island_removal_mode 0))"
533 <<
" (polygon (pts (xy 0 0) (xy 5 0) (xy 5 5) (xy 0 5))))"
537 std::unique_ptr<BOARD>
readBoard = std::make_unique<BOARD>();
541 std::filesystem::remove( tmpPath );
553 std::filesystem::path tmpPath = std::filesystem::temp_directory_path()
554 /
"copper_thieving_malformed.kicad_pcb";
555 std::ofstream out( tmpPath );
556 out <<
"(kicad_pcb (version 20260513) (generator \"test\") (generator_version \"test\")"
557 <<
" (general (thickness 1.6)) (paper \"A4\")"
558 <<
" (layers (0 \"F.Cu\" signal) (31 \"B.Cu\" signal))"
559 <<
" (zone (net 0) (net_name \"\") (layer \"F.Cu\") (uuid \"00000000-0000-0000-0000-000000000002\")"
560 <<
" (hatch edge 0.5)"
561 <<
" (connect_pads (clearance 0))"
562 <<
" (min_thickness 0.25) (filled_areas_thickness no)"
563 <<
" (fill yes (mode thieving)"
564 <<
" (thermal_gap 0.5) (thermal_bridge_width 0.5)"
565 <<
" (island_removal_mode 0)"
566 <<
" (thieving (type dots) (size -1) (gap 0)"
567 <<
" (width -5) (stagger no) (orientation 0)))"
568 <<
" (polygon (pts (xy 0 0) (xy 5 0) (xy 5 5) (xy 0 5))))"
572 std::unique_ptr<BOARD>
readBoard = std::make_unique<BOARD>();
576 BOOST_REQUIRE_EQUAL(
readBoard->Zones().size(), 1u );
580 BOOST_CHECK_GT( loaded.
gap, 0 );
583 std::filesystem::remove( tmpPath );
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
@ BS_ITEM_TYPE_DIELECTRIC
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Manage one layer needed to make a physical board.
int GetThickness(int aDielectricSubLayer=0) const
wxString GetMaterial(int aDielectricSubLayer=0) const
Manage layers needed to make a physical board.
wxString m_FinishType
The name of external copper finish.
KICAD_T Type() const
Returns the type of object.
void SetStart(const VECTOR2I &aStart)
void SetEnd(const VECTOR2I &aEnd)
VECTOR2I GetArcMid() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
A logical library item identifier and consists of various portions much like a URI.
LSET is a set of PCB_LAYER_IDs.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Handle the data for a net.
static NETINFO_ITEM * OrphanedItem()
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
int TotalVertices() const
Return total number of vertices stored in the set.
Handle a list of polygons defining a copper zone.
const THIEVING_SETTINGS & GetThievingSettings() const
ZONE_LAYER_PROPERTIES & LayerProperties(PCB_LAYER_ID aLayer)
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
bool IsCopperThieving() const
void SetFillMode(ZONE_FILL_MODE aFillMode)
void SetThievingSettings(const THIEVING_SETTINGS &aSettings)
VECTOR2I GetPosition() const override
void SetNet(NETINFO_ITEM *aNetInfo) override
Override that drops aNetInfo when this zone is in copper-thieving fill mode.
ZONE_FILL_MODE GetFillMode() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
int GetNumCorners(void) const
Access to m_Poly parameters.
std::unique_ptr< BOARD > readBoard(wxString &aFilename)
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[]
PCB_IO_KICAD_SEXPR kicadPlugin
Parameters that drive copper-thieving fill generation.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_TEST(contains==c.ExpectedContains)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Issue19775_ZoneLayerWildcards)
Declares the struct as the Boost test fixture.
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< int32_t > VECTOR2I
THIEVING_PATTERN
Shape stamped onto the grid for a copper-thieving fill.