26#include <api/board/board_types.pb.h>
91 using namespace kiapi::board::types;
94 if( !aContainer.UnpackTo( &padstack ) )
97 m_mode = FromProtoEnum<MODE>( padstack.type() );
105 Drill().
start = FromProtoEnum<PCB_LAYER_ID>( padstack.start_layer() );
106 Drill().
end = FromProtoEnum<PCB_LAYER_ID>( padstack.end_layer() );
109 if( padstack.layers_size() == 1 )
111 const PadStackLayer& layer = padstack.layers( 0 );
114 SetShape( FromProtoEnum<PAD_SHAPE>( layer.shape() ) );
115 SetAnchorShape( FromProtoEnum<PAD_SHAPE>( layer.custom_anchor_shape() ) );
121 if( layer.chamfered_corners().top_left() )
124 if( layer.chamfered_corners().top_right() )
127 if( layer.chamfered_corners().bottom_left() )
130 if( layer.chamfered_corners().bottom_right() )
134 google::protobuf::Any a;
136 for(
const GraphicShape& shapeProto : layer.custom_shapes() )
138 a.PackFrom( shapeProto );
139 std::unique_ptr<PCB_SHAPE> shape = std::make_unique<PCB_SHAPE>(
m_parent );
141 if( shape->Deserialize( a ) )
147 FromProtoEnum<UNCONNECTED_LAYER_MODE>( padstack.unconnected_layer_removal() ) );
155 using namespace kiapi::board::types;
158 padstack.set_type( ToProtoEnum<MODE, PadStackType>(
m_mode ) );
159 padstack.set_start_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>(
StartLayer() ) );
160 padstack.set_end_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>(
EndLayer() ) );
164 PadStackLayer* stackLayer = padstack.add_layers();
167 stackLayer->set_shape( ToProtoEnum<PAD_SHAPE, PadStackShape>(
Shape() ) );
168 stackLayer->set_custom_anchor_shape( ToProtoEnum<PAD_SHAPE, PadStackShape>(
AnchorShape() ) );
170 stackLayer->set_corner_rounding_ratio(
CopperLayerDefaults().shape.round_rect_radius_ratio );
172 google::protobuf::Any a;
174 for(
const std::shared_ptr<PCB_SHAPE>& shape :
Primitives() )
176 shape->Serialize( a );
177 GraphicShape* s = stackLayer->add_custom_shapes();
187 padstack.set_unconnected_layer_removal(
190 aContainer.PackFrom( padstack );
197 return wxEmptyString;
216 round_rect_corner_radius( 0 ),
217 round_rect_radius_ratio( 0.25 ),
218 chamfered_rect_ratio( 0.2 ),
226 return shape == aOther.
shape && offset == aOther.
offset
256 return size == aOther.
size && shape == aOther.
shape
257 && start == aOther.
start && end == aOther.
end;
355 int min_r = std::min( size.
x, size.
y );
486 || ( defaults.
shape.
shape == PAD_SHAPE::CUSTOM
519 for(
const std::shared_ptr<PCB_SHAPE>& prim : aPrimitivesList )
529 if( aPrimitivesList.size() )
548 wxCHECK_MSG(
false, std::nullopt,
"IsTented expects a front or back layer" );
@ NORMAL
Use all material properties from model file.
BASE_SET & reset(size_t pos=std::numeric_limits< size_t >::max())
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Represent basic circle geometry with utility geometry functions.
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
void SetRoundRectRadius(double aRadius, PCB_LAYER_ID aLayer=F_Cu)
bool operator==(const PADSTACK &aOther) const
std::optional< int > & Clearance(PCB_LAYER_ID aLayer=F_Cu)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetChamferRatio(double aRatio, PCB_LAYER_ID aLayer=F_Cu)
std::vector< std::shared_ptr< PCB_SHAPE > > & Primitives(PCB_LAYER_ID aLayer=F_Cu)
void SetChamferPositions(int aPositions, PCB_LAYER_ID aLayer=F_Cu)
std::optional< double > & SolderPasteMarginRatio(PCB_LAYER_ID aLayer=F_Cu)
wxString m_customName
! An override for the IPC-7351 padstack name
void SetAnchorShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
void SetRoundRectRadiusRatio(double aRatio, PCB_LAYER_ID aLayer=F_Cu)
DRILL_PROPS m_drill
! The primary drill parameters, which also define the start and end layers for through-hole vias and ...
void SetThermalSpokeAngle(EDA_ANGLE aAngle, PCB_LAYER_ID aLayer=F_Cu)
UNCONNECTED_LAYER_MODE m_unconnectedLayerMode
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
COPPER_LAYER_PROPS & CopperLayerDefaults()
std::optional< bool > IsTented(PCB_LAYER_ID aSide) const
Checks if this padstack is tented (covered in soldermask) on the given side.
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
std::optional< int > & SolderPasteMargin(PCB_LAYER_ID aLayer=F_Cu)
std::optional< int > & SolderMaskMargin(PCB_LAYER_ID aLayer=F_Cu)
const LSET & LayerSet() const
PADSTACK & operator=(const PADSTACK &aOther)
std::unordered_map< PCB_LAYER_ID, COPPER_LAYER_PROPS > m_copperOverrides
! Any entries here override the copper layer settings on the given copper layer.
DRILL_PROPS m_secondaryDrill
! Secondary drill, used to define back-drilling
PAD_SHAPE AnchorShape(PCB_LAYER_ID aLayer=F_Cu) const
MASK_LAYER_PROPS m_backMaskProps
! The overrides applied to back outer technical layers
COPPER_LAYER_PROPS m_defaultCopperProps
! The properties applied to copper layers if they aren't overridden
int RoundRectRadius(PCB_LAYER_ID aLayer=F_Cu) const
EDA_ANGLE ThermalSpokeAngle(PCB_LAYER_ID aLayer=F_Cu) const
void AppendPrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList, PCB_LAYER_ID aLayer=F_Cu)
Appends a copy of each shape in the given list to this padstack's custom shape list.
void AddPrimitive(PCB_SHAPE *aShape, PCB_LAYER_ID aLayer=F_Cu)
Adds a custom shape primitive to the padstack.
int & ChamferPositions(PCB_LAYER_ID aLayer=F_Cu)
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
BOARD_ITEM * m_parent
! The BOARD_ITEM this PADSTACK belongs to; will be used as the parent for owned shapes
PADSTACK(BOARD_ITEM *aParent)
LSET m_layerSet
! The board layers that this padstack is active on
double RoundRectRadiusRatio(PCB_LAYER_ID aLayer=F_Cu) const
VECTOR2I & TrapezoidDeltaSize(PCB_LAYER_ID aLayer=F_Cu)
PCB_LAYER_ID EndLayer() const
PAD_DRILL_SHAPE DrillShape(PCB_LAYER_ID aLayer=F_Cu) const
MASK_LAYER_PROPS m_frontMaskProps
! The overrides applied to front outer technical layers
VECTOR2I & Offset(PCB_LAYER_ID aLayer=F_Cu)
void ClearPrimitives(PCB_LAYER_ID aLayer=F_Cu)
VECTOR2I & Size(PCB_LAYER_ID aLayer=F_Cu)
void SetDrillShape(PAD_DRILL_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
UNCONNECTED_LAYER_MODE
! Whether or not to remove the copper shape for unconnected layers
PCB_LAYER_ID StartLayer() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
wxString Name() const
! Returns the name of this padstack in IPC-7351 format
double ChamferRatio(PCB_LAYER_ID aLayer=F_Cu) const
PAD_SHAPE Shape(PCB_LAYER_ID aLayer=F_Cu) const
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList, PCB_LAYER_ID aLayer=F_Cu)
Clears the existing primitive list (freeing the owned shapes) and adds copies of the given shapes to ...
void SetLayerSet(const LSET &aSet)
std::optional< ZONE_CONNECTION > & ZoneConnection(PCB_LAYER_ID aLayer=F_Cu)
MODE m_mode
! The copper layer variation mode this padstack is in
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
EDA_ANGLE m_orientation
! The rotation of the pad relative to an outer reference frame
@ RECT_CHAMFER_BOTTOM_RIGHT
@ RECT_CHAMFER_BOTTOM_LEFT
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_45
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
PCB_LAYER_ID
A quick note on layer IDs:
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
LSET UnpackLayerSet(const google::protobuf::RepeatedField< int > &aProtoLayerSet)
void PackVector2(kiapi::common::types::Vector2 &aOutput, const VECTOR2I aInput)
VECTOR2I UnpackVector2(const types::Vector2 &aInput)
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
#define IMPLEMENT_ENUM_TO_WXANY(type)
The features of a padstack that can vary between copper layers All parameters are optional; leaving t...
std::optional< ZONE_CONNECTION > zone_connection
std::optional< int > thermal_spoke_width
std::vector< std::shared_ptr< PCB_SHAPE > > custom_shapes
bool operator==(const COPPER_LAYER_PROPS &aOther) const
std::optional< EDA_ANGLE > thermal_spoke_angle
std::optional< int > clearance
std::optional< int > thermal_gap
! The properties of a padstack drill. Drill position is always the pad position (origin).
bool operator==(const DRILL_PROPS &aOther) const
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
! The features of a padstack that can vary on outer layers.
bool operator==(const MASK_LAYER_PROPS &aOther) const
std::optional< int > solder_mask_margin
std::optional< int > solder_paste_margin
std::optional< double > solder_paste_margin_ratio
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
std::optional< bool > has_solder_paste
True if this outer layer has solder paste.
! The set of properties that define a pad's shape on a given layer
int chamfered_rect_positions
VECTOR2I trapezoid_delta_size
Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes one end and half expands the other.
double round_rect_corner_radius
VECTOR2I offset
Offset of the shape center from the pad center.
bool operator==(const SHAPE_PROPS &aOther) const
VECTOR2I size
Size of the shape, or of the anchor pad for custom shape pads.
double chamfered_rect_ratio
Size of chamfer: ratio of smallest of X,Y size.
double round_rect_radius_ratio
PAD_SHAPE shape
Shape of the pad.
PAD_SHAPE anchor_shape
Shape of the anchor when shape == PAD_SHAPE::CUSTOM.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".