32#include <api/common/types/project_settings.pb.h>
67 if( aInitWithDefaults )
137 project::NetClass nc;
139 nc.set_name(
m_Name.ToUTF8() );
142 nc.set_type(
m_constituents.empty() ? project::NCT_EXPLICIT : project::NCT_IMPLICIT );
145 nc.add_constituents( member->GetName() );
147 project::NetClassBoardSettings* board = nc.mutable_board();
150 board->mutable_clearance()->set_value_nm( *
m_Clearance );
153 board->mutable_track_width()->set_value_nm( *
m_TrackWidth );
156 board->mutable_diff_pair_track_width()->set_value_nm( *
m_diffPairWidth );
159 board->mutable_diff_pair_gap()->set_value_nm( *
m_diffPairGap );
166 kiapi::board::types::PadStackLayer* layer = board->mutable_via_stack()->add_copper_layers();
167 layer->set_shape( kiapi::board::types::PSS_CIRCLE );
168 layer->set_layer( kiapi::board::types::BoardLayer::BL_F_Cu );
169 PackVector2( *layer->mutable_size(), { *m_ViaDia, *m_ViaDia } );
174 PackVector2( *board->mutable_via_stack()->mutable_drill()->mutable_diameter(),
175 { *m_ViaDrill, *m_ViaDrill } );
179 PackColor( *board->mutable_color(),
m_pcbColor );
181 project::NetClassSchematicSettings* schematic = nc.mutable_schematic();
184 schematic->mutable_wire_width()->set_value_nm( *
m_wireWidth );
187 schematic->mutable_bus_width()->set_value_nm( *
m_busWidth );
199 aContainer.PackFrom( nc );
206 project::NetClass nc;
208 if( !aContainer.UnpackTo( &nc ) )
211 m_Name = wxString::FromUTF8( nc.name() );
215 if( nc.type() == project::NCT_IMPLICIT )
220 if( nc.board().has_clearance() )
223 if( nc.board().has_track_width() )
226 if( nc.board().has_diff_pair_track_width() )
229 if( nc.board().has_diff_pair_gap() )
232 if( nc.board().has_diff_pair_via_gap() )
235 if( nc.board().has_via_stack() )
237 if( nc.board().via_stack().copper_layers_size() > 0 )
238 m_ViaDia = nc.board().via_stack().copper_layers().at( 0 ).size().x_nm();
240 if( nc.board().via_stack().has_drill() )
241 m_ViaDrill = nc.board().via_stack().drill().diameter().x_nm();
244 if( nc.board().has_color() )
245 m_pcbColor = UnpackColor( nc.board().color() );
247 if( nc.schematic().has_wire_width() )
248 m_wireWidth = nc.schematic().wire_width().value_nm();
250 if( nc.schematic().has_bus_width() )
251 m_busWidth = nc.schematic().bus_width().value_nm();
253 if( nc.schematic().has_color() )
281 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 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 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