21#include <boost/test/unit_test.hpp>
30#include <api/board/board_types.pb.h>
31#include <api/common/types/embedded_files.pb.h>
67 int drillChartCount = 0;
68 int drillMapCount = 0;
69 int referenceImageCount = 0;
75 for(
PCB_TRACK* track : m_board->Tracks() )
77 switch( track->Type() )
98 for(
FOOTPRINT* footprint : m_board->Footprints() )
101 for(
ZONE* zone : m_board->Zones() )
106 switch( item->Type() )
135 static_cast<PCB_BARCODE*
>( item ), m_board.get() );
142 ++referenceImageCount;
164 static_cast<PCB_TEXT*
>( item ), m_board.get() );
170 static_cast<PCB_TEXTBOX*
>( item ), m_board.get() );
176 static_cast<PCB_SHAPE*
>( item ), m_board.get() );
184 BOOST_CHECK_GT( barcodeCount, 0 );
185 BOOST_CHECK_GT( drillChartCount, 0 );
186 BOOST_CHECK_GT( drillMapCount, 0 );
187 BOOST_CHECK_GT( referenceImageCount, 0 );
188 BOOST_CHECK_GT( tableCount, 0 );
189 BOOST_CHECK_GT( textCount, 0 );
190 BOOST_CHECK_GT( textBoxCount, 0 );
191 BOOST_CHECK_GT( shapeCount, 0 );
223 google::protobuf::Any
any;
225 kiapi::board::types::DrillChart proto;
227 BOOST_REQUIRE_GT( proto.columns_size(), 0 );
232 proto.mutable_columns( 0 )->mutable_width()->set_value_nm( width );
233 any.PackFrom( proto );
240 std::numeric_limits<int64_t>::max() } )
242 proto.mutable_columns( 0 )->mutable_width()->set_value_nm( width );
243 any.PackFrom( proto );
256 for(
PCB_TRACK* track : m_board->Tracks() )
258 switch( track->Type() )
269 for(
FOOTPRINT* footprint : m_board->Footprints() )
278 for(
const FOOTPRINT* fp : m_board->Footprints() )
280 if( fp->EmbeddedFileMap().empty() )
283 BOOST_TEST_CONTEXT( wxString::Format( wxS(
"Footprint %s embedded files" ), fp->m_Uuid.AsStdString() ) )
285 google::protobuf::Any
any;
286 fp->Serialize(
any );
288 kiapi::board::types::FootprintInstance proto;
289 BOOST_CHECK(
any.UnpackTo( &proto ) );
291 BOOST_CHECK_GT( proto.embedded_files().files_size(), 0 );
293 const kiapi::common::types::EmbeddedFile& file = proto.embedded_files().files( 0 );
294 BOOST_CHECK( !file.data().empty() );
296 std::unique_ptr<FOOTPRINT> roundTripped = std::make_unique<FOOTPRINT>( m_board.get() );
297 BOOST_CHECK( roundTripped->Deserialize(
any ) );
299 for(
const auto& [
name,
expected] : fp->EmbeddedFileMap() )
302 BOOST_CHECK_MESSAGE(
actual, wxString::Format( wxS(
"Embedded file '%s' missing after round-trip" ),
name ).c_str() );
320 m_board = std::make_unique<BOARD>();
322 ZONE* zone =
new ZONE( m_board.get() );
339 m_board->Add( zone );
341 google::protobuf::Any
any;
344 kiapi::board::types::Zone proto;
347 BOOST_REQUIRE( proto.copper_settings().has_thieving_settings() );
349 std::unique_ptr<ZONE> roundTripped = std::make_unique<ZONE>( m_board.get() );
355 BOOST_CHECK_LE( roundTripped->GetNetCode(), 0 );
369 const auto makeGridItem =
372 return std::make_unique<PCB_GRID_ITEM>(
nullptr );
402 google::protobuf::Any
any;
405 std::unique_ptr<PCB_GRID_ITEM> roundTripped = makeGridItem();
void testProtoFromKiCadObject(KiCadClass *aInput, Factory &&aCreateOutput)
constexpr EDA_IU_SCALE pcbIUScale
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetLocked(bool aLocked) override
Information pertinent to a Pcbnew printed circuit board.
For better understanding of the points that make a dimension:
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
A drill chart placed on the board, kept in step with the holes.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
std::vector< DRILL_CHART_COLUMN > & Columns()
Turns on drill symbols at the holes, for one layer.
void SetRadiusExtent(int aR)
void SetAffectsRouting(bool aOn)
void SetPosition(const VECTOR2I &aPos) override
void SetRadiusSpacing(int aR)
void SetGridItemType(PCB_GRID_TYPE aType)
void SetExtent(const VECTOR2I &aExtent)
void SetTickInterval(unsigned aInterval)
void SetOrientationDegrees(double aDeg)
void SetSpacing(const VECTOR2I &aSpacing)
void SetPhiExtentDegrees(double aDeg)
void SetAffectsPlacement(bool aOn)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetPhiSpacingDegrees(double aDeg)
void SetAssignedPriority(unsigned aPriority)
Priority 0 is reserved for the global background grid; user-assigned 0 is bumped to 1.
void SetAffectsCursor(bool aOn)
Object to handle a bitmap image that can be inserted in a PCB.
Handle a list of polygons defining a copper zone.
bool AppendCorner(const VECTOR2I &aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetFillMode(ZONE_FILL_MODE aFillMode)
void SetThievingSettings(const THIEVING_SETTINGS &aSettings)
A type-safe container of any type.
constexpr int DRILL_CHART_MAX_COLUMN_WIDTH
A chart column can be no wider than this, and no chart wider than that in total.
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
BARCODE class definition.
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
Parameters that drive copper-thieving fill generation.
BOOST_FIXTURE_TEST_CASE(BoardTypes, PROTO_TEST_FIXTURE)
BOOST_AUTO_TEST_CASE(FootprintExcludeFromSimulationRoundTrip)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
VECTOR2< int32_t > VECTOR2I