26#include <api/board/board.pb.h>
58 case PCB_TRACE_T:
return std::make_unique<PCB_TRACK>( aContainer );
59 case PCB_ARC_T:
return std::make_unique<PCB_ARC>( aContainer );
60 case PCB_VIA_T:
return std::make_unique<PCB_VIA>( aContainer );
61 case PCB_TEXT_T:
return std::make_unique<PCB_TEXT>( aContainer );
62 case PCB_TEXTBOX_T:
return std::make_unique<PCB_TEXTBOX>( aContainer );
63 case PCB_TABLE_T:
return std::make_unique<PCB_TABLE>( aContainer );
65 case PCB_DRILL_MAP_T:
return std::make_unique<PCB_DRILL_MAP>( aContainer );
73 return std::make_unique<PCB_TABLECELL>( aContainer );
75 case PCB_SHAPE_T:
return std::make_unique<PCB_SHAPE>( aContainer );
76 case PCB_POINT_T:
return std::make_unique<PCB_POINT>( aContainer );
77 case PCB_BARCODE_T:
return std::make_unique<PCB_BARCODE>( aContainer );
78 case PCB_ZONE_T:
return std::make_unique<ZONE>( aContainer );
79 case PCB_GROUP_T:
return std::make_unique<PCB_GROUP>( aContainer );
80 case PCB_CONSTRAINT_T:
return std::make_unique<PCB_CONSTRAINT>( aContainer );
82 case PCB_GRID_ITEM_T:
return std::make_unique<PCB_GRID_ITEM>( aContainer );
91 return std::make_unique<PAD>( footprint );
101 return std::make_unique<PCB_FIELD>( footprint,
FIELD_T::USER );
106 BOARD* board =
dynamic_cast<BOARD*
>( aContainer );
111 return std::make_unique<FOOTPRINT>( board );
116 case PCB_DIM_RADIAL_T:
return std::make_unique<PCB_DIM_RADIAL>( aContainer );
117 case PCB_DIM_LEADER_T:
return std::make_unique<PCB_DIM_LEADER>( aContainer );
118 case PCB_DIM_CENTER_T:
return std::make_unique<PCB_DIM_CENTER>( aContainer );
139 for(
int layer : aProtoLayerSet )
146 set.
set( boardLayer );
157 for( BoardStackupLayer& layer : *aOut.mutable_layers() )
159 if( layer.type() == BoardStackupLayerType::BSLT_DIELECTRIC )
171 aOutput.set_mode( aParams.
m_Enabled ? types::PadTeardropMode::PTM_ENABLED : types::PadTeardropMode::PTM_DISABLED );
175 aOutput.mutable_max_length()->set_value_nm( aParams.
m_TdMaxLen );
176 aOutput.mutable_max_width()->set_value_nm( aParams.
m_TdMaxWidth );
185 aOutput.
m_Enabled = ( aProto.mode() == types::PadTeardropMode::PTM_ENABLED );
189 aOutput.
m_TdMaxLen = aProto.max_length().value_nm();
198 const std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE>& aInput )
202 for(
const auto& [layer, overrideVal] : aInput )
204 types::ZoneLayerOverride protoOverride = types::ZLO_NONE;
206 switch( overrideVal )
213 if( protoOverride != types::ZLO_NONE )
215 types::ZoneLayerOverrideEntry* entry = aOutput->Add();
217 entry->set_override( protoOverride );
224 const google::protobuf::RepeatedPtrField<types::ZoneLayerOverrideEntry>& aInput )
226 for(
const types::ZoneLayerOverrideEntry& entry : aInput )
230 switch( entry.override() )
246 if( file->compressedEncodedData.empty() )
249 common::types::EmbeddedFile* proto = aOutput.add_files();
250 proto->set_name(
name.ToUTF8() );
253 proto->set_data( file->compressedEncodedData );
254 proto->set_data_hash( file->data_hash );
263 for(
const common::types::EmbeddedFile& protoFile : aProto.files() )
265 auto file = std::make_shared<EMBEDDED_FILES::EMBEDDED_FILE>();
266 file->name = wxString::FromUTF8( protoFile.name() );
268 file->compressedEncodedData = protoFile.data();
269 file->data_hash = protoFile.data_hash();
277 if( !file->Validate() )
292 const google::protobuf::RepeatedPtrField<kiapi::common::commands::SelectionSpec>& aItems )
294 using kiapi::common::commands::SelectionSpec;
296 std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
297 wxCHECK( aBoard, {} );
300 std::vector<KIID_PATH> sheetPaths( aItems.size() );
304 if( aItems[
index].spec_case() == SelectionSpec::SpecCase::kSheetPath )
310 wxString fpRef = footprint->GetReference();
314 const SelectionSpec& spec = aItems[
index];
316 switch( spec.spec_case() )
318 case SelectionSpec::SpecCase::kFootprint:
320 if( fpRef == wxString::FromUTF8( spec.footprint().reference() ) )
321 orderPairs.emplace_back(
index, footprint );
326 case SelectionSpec::SpecCase::kPad:
328 if( fpRef == wxString::FromUTF8( spec.pad().reference() ) )
330 wxString padNumber = wxString::FromUTF8( spec.pad().number() );
332 for(
PAD*
pad : footprint->Pads() )
334 if( padNumber ==
pad->GetNumber() )
335 orderPairs.emplace_back(
index,
pad );
342 case SelectionSpec::SpecCase::kSheetPath:
344 if( footprint->IsWithinSchematicSheet( sheetPaths[
index] ) )
345 orderPairs.emplace_back(
index, footprint );
355 std::ranges::sort( orderPairs,
356 [](
const std::pair<int, BOARD_ITEM*>& a,
const std::pair<int, BOARD_ITEM*>& b ) ->
bool
358 return a.first < b.first;
361 std::vector<BOARD_ITEM*> items;
362 items.reserve( orderPairs.size() );
364 for(
BOARD_ITEM* val : orderPairs | std::views::values )
365 items.push_back( val );
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
std::unique_ptr< BOARD_ITEM > CreateItemForType(KICAD_T aType, BOARD_ITEM_CONTAINER *aContainer)
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
@ ZLO_FORCE_NO_ZONE_CONNECTION
BASE_SET & set(size_t pos)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Information pertinent to a Pcbnew printed circuit board.
BOARD_STACKUP GetStackupOrDefault() const
const FOOTPRINTS & Footprints() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
static RETURN_CODE DecompressAndDecode(EMBEDDED_FILE &aFile, bool aAllowEmptyHash=false)
Takes data from the #compressedEncodedData buffer and Base64 decodes it.
void ClearEmbeddedFiles(bool aDeleteFiles=true)
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
const std::map< wxString, std::shared_ptr< EMBEDDED_FILE > > & EmbeddedFileMap() const
Provide an iterable view of the file collection.
LSET is a set of PCB_LAYER_IDs.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
bool m_Enabled
Flag to enable teardrops.
bool m_CurvedEdges
True if the teardrop should be curved.
PCB_LAYER_ID
A quick note on layer IDs:
bool IsValidLayer(int aLayerId)
Test whether a given integer is a valid layer index, i.e.
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
void PackBoardStackup(const BOARD &aBoard, BoardStackup &aOut)
void PackEmbeddedFiles(common::types::EmbeddedFiles &aOutput, const EMBEDDED_FILES &aFiles)
void PackZoneLayerOverrides(google::protobuf::RepeatedPtrField< types::ZoneLayerOverrideEntry > *aOutput, const std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > &aInput)
void UnpackTeardropSettings(TEARDROP_PARAMETERS &aOutput, const types::PadTeardropSettings &aProto)
bool UnpackEmbeddedFiles(EMBEDDED_FILES &aOutput, const common::types::EmbeddedFiles &aProto)
LSET UnpackLayerSet(const google::protobuf::RepeatedField< int > &aProtoLayerSet)
std::vector< BOARD_ITEM * > FindItemsFromSyncSelection(const BOARD *aBoard, const google::protobuf::RepeatedPtrField< kiapi::common::commands::SelectionSpec > &aItems)
Resolve a cross-probe selection request against a board.
void UnpackZoneLayerOverrides(std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > &aOutput, const google::protobuf::RepeatedPtrField< types::ZoneLayerOverrideEntry > &aInput)
void PackTeardropSettings(types::PadTeardropSettings &aOutput, const TEARDROP_PARAMETERS &aParams)
KICOMMON_API KIID_PATH UnpackSheetPath(const types::SheetPath &aInput)
BARCODE class definition.
Class to handle a set of BOARD_ITEMs.
@ USER
The field ID hasn't been set yet; field is invalid.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_CONSTRAINT_T
a geometric constraint between board items
@ 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_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_GRID_ITEM_T
a subgrid placed on a board
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ 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_POINT_T
class PCB_POINT, a 0-dimensional point
@ 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