21#include <boost/test/unit_test.hpp>
30#include <api/board/board_types.pb.h>
31#include <api/common/types/embedded_files.pb.h>
69 int drillChartCount = 0;
70 int drillMapCount = 0;
71 int referenceImageCount = 0;
77 for(
PCB_TRACK* track : m_board->Tracks() )
79 switch( track->Type() )
100 for(
FOOTPRINT* footprint : m_board->Footprints() )
103 for(
ZONE* zone : m_board->Zones() )
108 switch( item->Type() )
137 static_cast<PCB_BARCODE*
>( item ), m_board.get() );
144 ++referenceImageCount;
166 static_cast<PCB_TEXT*
>( item ), m_board.get() );
172 static_cast<PCB_TEXTBOX*
>( item ), m_board.get() );
178 static_cast<PCB_SHAPE*
>( item ), m_board.get() );
186 BOOST_CHECK_GT( barcodeCount, 0 );
187 BOOST_CHECK_GT( drillChartCount, 0 );
188 BOOST_CHECK_GT( drillMapCount, 0 );
189 BOOST_CHECK_GT( referenceImageCount, 0 );
190 BOOST_CHECK_GT( tableCount, 0 );
191 BOOST_CHECK_GT( textCount, 0 );
192 BOOST_CHECK_GT( textBoxCount, 0 );
193 BOOST_CHECK_GT( shapeCount, 0 );
216 kiapi::board::types::Footprint proto;
229 BOOST_CHECK( groups.contains( wxS(
"A,B" ) ) && groups[wxS(
"A,B" )] == 0 );
230 BOOST_CHECK( groups.contains( wxS(
"C" ) ) && groups[wxS(
"C" )] == 0 );
251 google::protobuf::Any
any;
253 kiapi::board::types::DrillChart proto;
255 BOOST_REQUIRE_GT( proto.columns_size(), 0 );
260 proto.mutable_columns( 0 )->mutable_width()->set_value_nm( width );
261 (void)
any.PackFrom( proto );
268 std::numeric_limits<int64_t>::max() } )
270 proto.mutable_columns( 0 )->mutable_width()->set_value_nm( width );
271 (void)
any.PackFrom( proto );
284 for(
PCB_TRACK* track : m_board->Tracks() )
286 switch( track->Type() )
297 for(
FOOTPRINT* footprint : m_board->Footprints() )
306 for(
const FOOTPRINT* fp : m_board->Footprints() )
308 if( fp->EmbeddedFileMap().empty() )
311 BOOST_TEST_CONTEXT( wxString::Format( wxS(
"Footprint %s embedded files" ), fp->m_Uuid.AsStdString() ) )
313 google::protobuf::Any
any;
314 fp->Serialize(
any );
316 kiapi::board::types::FootprintInstance proto;
319 BOOST_CHECK_GT( proto.embedded_files().files_size(), 0 );
321 const kiapi::common::types::EmbeddedFile& file = proto.embedded_files().files( 0 );
324 std::unique_ptr<FOOTPRINT> roundTripped = std::make_unique<FOOTPRINT>( m_board.get() );
327 for(
const auto& [
name,
expected] : fp->EmbeddedFileMap() )
330 BOOST_CHECK_MESSAGE(
actual, wxString::Format( wxS(
"Embedded file '%s' missing after round-trip" ),
name ).c_str() );
348 m_board = std::make_unique<BOARD>();
350 ZONE* zone =
new ZONE( m_board.get() );
367 m_board->Add( zone );
369 google::protobuf::Any
any;
372 kiapi::board::types::Zone proto;
375 BOOST_REQUIRE( proto.copper_settings().has_thieving_settings() );
377 std::unique_ptr<ZONE> roundTripped = std::make_unique<ZONE>( m_board.get() );
383 BOOST_CHECK_LE( roundTripped->GetNetCode(), 0 );
397 const auto makeGridItem =
400 return std::make_unique<PCB_GRID_ITEM>(
nullptr );
430 google::protobuf::Any
any;
433 std::unique_ptr<PCB_GRID_ITEM> roundTripped = makeGridItem();
450 const auto makeBody =
453 return std::make_unique<PCB_3D_BODY>();
482 google::protobuf::Any
any;
485 kiapi::board::types::Body3D msg;
490 msg.set_kind( kiapi::board::types::BDK_MODEL );
493 std::unique_ptr<PCB_3D_BODY> modelBody = makeBody();
500 kiapi::board::types::Footprint definition;
503 msg.set_kind( kiapi::board::types::BDK_EXTRUDED );
504 msg.mutable_id()->set_value(
KIID().AsStdString() );
505 msg.mutable_parent()->set_value(
"00000000-0000-0000-0000-000000000001" );
506 msg.mutable_extruded()->mutable_height()->set_value_nm(
pcbIUScale.mmToIU( 2 ) );
508 *definition.add_items() =
any;
523 numberBox->SetIsProxyItem();
526 spokeTemplate->SetIsProxyItem();
530 google::protobuf::Any numberBoxAny;
531 numberBox->Serialize( numberBoxAny );
533 kiapi::board::types::BoardGraphicShape numberBoxProto;
535 BOOST_REQUIRE( numberBoxProto.has_pad_custom_shape_options() );
536 BOOST_CHECK( numberBoxProto.pad_custom_shape_options().is_number_box() );
538 google::protobuf::Any spokeAny;
539 spokeTemplate->Serialize( spokeAny );
541 kiapi::board::types::BoardGraphicShape spokeProto;
544 BOOST_CHECK( spokeProto.pad_custom_shape_options().is_thermal_spoke_template() );
546 google::protobuf::Any plainAny;
547 plainShape->Serialize( plainAny );
549 kiapi::board::types::BoardGraphicShape plainProto;
551 BOOST_CHECK( !plainProto.has_pad_custom_shape_options() );
554 google::protobuf::Any mismatchedAny;
555 spokeTemplate->Serialize( mismatchedAny );
557 kiapi::board::types::BoardGraphicShape mismatchedProto;
559 mismatchedProto.clear_shape();
560 mismatchedProto.mutable_shape()->mutable_rectangle()->mutable_top_left()->set_x_nm( 0 );
561 mismatchedProto.mutable_shape()->mutable_rectangle()->mutable_top_left()->set_y_nm( 0 );
562 mismatchedProto.mutable_shape()->mutable_rectangle()->mutable_bottom_right()->set_x_nm( 1 );
563 mismatchedProto.mutable_shape()->mutable_rectangle()->mutable_bottom_right()->set_y_nm( 1 );
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
FOOTPRINT * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
EDA_ANGLE GetAngle() const
EXTRUSION_MATERIAL m_material
A color representation with 4 components: red, green, blue, alpha.
A 3D body attached to a footprint (or, later, placed on a board).
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
EXTRUDED_3D_BODY * MutableExtruded()
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.
Turns on drill symbols at the holes, for one layer.
std::vector< GENERATED_TABLE_COLUMN > & Columns()
The columns the table shows, which are the columns of its cells.
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.
bool IsProxyItem() const override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
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.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
constexpr int GENERATED_TABLE_MAX_COLUMN_WIDTH
A column can be no wider than this.
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.
EDA_ORIENTATION orientation
BOOST_FIXTURE_TEST_CASE(BoardTypes, PROTO_TEST_FIXTURE)
BOOST_AUTO_TEST_CASE(FootprintExcludeFromSimulationRoundTrip)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
@ 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
VECTOR3< double > VECTOR3D