32#include <api/common/types/project_settings.pb.h>
68 if( aInitWithDefaults )
139 project::NetClass nc;
141 nc.set_name(
m_Name.ToUTF8() );
144 nc.set_type(
m_constituents.empty() ? project::NCT_EXPLICIT : project::NCT_IMPLICIT );
147 nc.add_constituents( member->GetName() );
149 project::NetClassBoardSettings* board = nc.mutable_board();
152 board->mutable_clearance()->set_value_nm( *
m_Clearance );
155 board->mutable_track_width()->set_value_nm( *
m_TrackWidth );
158 board->mutable_diff_pair_track_width()->set_value_nm( *
m_diffPairWidth );
161 board->mutable_diff_pair_gap()->set_value_nm( *
m_diffPairGap );
168 kiapi::board::types::PadStackLayer* layer = board->mutable_via_stack()->add_copper_layers();
169 layer->set_shape( kiapi::board::types::PSS_CIRCLE );
170 layer->set_layer( kiapi::board::types::BoardLayer::BL_F_Cu );
171 PackVector2( *layer->mutable_size(), { *m_ViaDia, *m_ViaDia } );
176 PackVector2( *board->mutable_via_stack()->mutable_drill()->mutable_diameter(),
177 { *m_ViaDrill, *m_ViaDrill } );
181 PackColor( *board->mutable_color(),
m_pcbColor );
183 project::NetClassSchematicSettings* schematic = nc.mutable_schematic();
186 schematic->mutable_wire_width()->set_value_nm( *
m_wireWidth );
189 schematic->mutable_bus_width()->set_value_nm( *
m_busWidth );
201 aContainer.PackFrom( nc );
208 project::NetClass nc;
210 if( !aContainer.UnpackTo( &nc ) )
213 m_Name = wxString::FromUTF8( nc.name() );
217 if( nc.type() == project::NCT_IMPLICIT )
222 if( nc.board().has_clearance() )
225 if( nc.board().has_track_width() )
228 if( nc.board().has_diff_pair_track_width() )
231 if( nc.board().has_diff_pair_gap() )
234 if( nc.board().has_diff_pair_via_gap() )
237 if( nc.board().has_via_stack() )
239 if( nc.board().via_stack().copper_layers_size() > 0 )
240 m_ViaDia = nc.board().via_stack().copper_layers().at( 0 ).size().x_nm();
242 if( nc.board().via_stack().has_drill() )
243 m_ViaDrill = nc.board().via_stack().drill().diameter().x_nm();
246 if( nc.board().has_color() )
247 m_pcbColor = UnpackColor( nc.board().color() );
249 if( nc.schematic().has_wire_width() )
250 m_wireWidth = nc.schematic().wire_width().value_nm();
252 if( nc.schematic().has_bus_width() )
253 m_busWidth = nc.schematic().bus_width().value_nm();
255 if( nc.schematic().has_color() )
283 return nc->GetName() == netclass;
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
A collection of nets and the parameters used to route or test these nets.
void SetViaDiameter(int aDia)
void SetViaDrill(int aSize)
void SetDelayProfileParent(NETCLASS *aParent)
void SetWireWidthParent(NETCLASS *parent)
COLOR4D m_pcbColor
Optional PCB color override for this netclass.
static const char Default[]
the name of the default NETCLASS
void SetuViaDrillParent(NETCLASS *parent)
void SetPriority(int aPriority)
const wxString GetHumanReadableName() const
Gets the consolidated name of this netclass (which may be an aggregate).
void SetDiffPairWidthParent(NETCLASS *parent)
void SetuViaDiameter(int aSize)
void SetDiffPairWidth(int aSize)
std::optional< int > m_ViaDrill
via drill hole diameter
void SetViaDrillParent(NETCLASS *parent)
std::optional< int > m_wireWidth
std::optional< int > m_busWidth
void SetDiffPairGapParent(NETCLASS *parent)
bool ContainsNetclassWithName(const wxString &netclass) const
Determines if the given netclass name is a constituent of this (maybe aggregate) netclass.
void ResetParents()
Resets all parent fields to point to this netclass.
void SetLineStyle(int aStyle)
std::optional< int > m_TrackWidth
track width used to route nets
int m_Priority
The priority for multiple netclass resolution.
NETCLASS(const wxString &aName, bool aInitWithDefaults=true)
Create a NETCLASS instance with aName.
void SetSchematicColor(COLOR4D aColor)
std::optional< int > m_diffPairWidth
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
std::optional< int > m_diffPairViaGap
void SetConstituentNetclasses(std::vector< NETCLASS * > &&constituents)
Sets the netclasses which make up this netclass.
void SetLineStyleParent(NETCLASS *parent)
std::optional< int > m_ViaDia
via diameter
void SetDiffPairViaGap(int aSize)
void ResetParameters()
Resets all parameters (except Name and Description)
void SetTrackWidthParent(NETCLASS *parent)
std::optional< int > m_lineStyle
const std::vector< NETCLASS * > & GetConstituentNetclasses() const
Gets the netclasses which make up this netclass.
void SetViaDiameterParent(NETCLASS *parent)
void SetPcbColor(const COLOR4D &aColor)
std::optional< int > m_Clearance
clearance when routing
void SetuViaDrill(int aSize)
void SetDelayProfile(const wxString &aDelayProfile)
void SetDiffPairGap(int aSize)
void SetBusWidthParent(NETCLASS *parent)
void SetClearance(int aClearance)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool operator==(const NETCLASS &other) const
void SetPcbColorParent(NETCLASS *parent)
void SetBusWidth(int aWidth)
void SetClearanceParent(NETCLASS *parent)
void SetWireWidth(int aWidth)
void SetDiffPairViaGapParent(NETCLASS *parent)
void SetuViaDiameterParent(NETCLASS *parent)
void SetSchematicColorParent(NETCLASS *parent)
void SetName(const wxString &aName)
Set the name of this netclass.
void SetTrackWidth(int aWidth)
std::vector< NETCLASS * > m_constituents
NETCLASSes contributing to an aggregate.
std::optional< int > m_diffPairGap
wxString m_Name
Name of the net class.
This file contains miscellaneous commonly used macros and functions.
const int DEFAULT_UVIA_DIAMETER
const int DEFAULT_DIFF_PAIR_WIDTH
const int DEFAULT_DIFF_PAIR_GAP
const int DEFAULT_DIFF_PAIR_VIAGAP
const int DEFAULT_LINE_STYLE
const int DEFAULT_CLEARANCE
const int DEFAULT_UVIA_DRILL
const int DEFAULT_TRACK_WIDTH
const int DEFAULT_WIRE_WIDTH
const int DEFAULT_VIA_DRILL
const int DEFAULT_VIA_DIAMETER
const int DEFAULT_BUS_WIDTH
constexpr int MilsToIU(int mils) const
constexpr int mmToIU(double mm) const