28#include <api/common/types/project_settings.pb.h>
64 if( aInitWithDefaults )
165 project::NetClass nc;
167 nc.set_name(
m_Name.ToUTF8() );
170 nc.set_type(
m_constituents.empty() ? project::NCT_EXPLICIT : project::NCT_IMPLICIT );
173 nc.add_constituents( member->GetName() );
175 project::NetClassBoardSettings*
board = nc.mutable_board();
194 kiapi::board::types::PadStackLayer* layer =
board->mutable_via_stack()->add_copper_layers();
195 layer->set_shape( kiapi::board::types::PSS_CIRCLE );
196 layer->set_layer( kiapi::board::types::BoardLayer::BL_F_Cu );
197 PackVector2( *layer->mutable_size(), { *m_ViaDia, *m_ViaDia } );
202 PackVector2( *
board->mutable_via_stack()->mutable_drill()->mutable_diameter(),
203 { *m_ViaDrill, *m_ViaDrill } );
212 project::NetClassSchematicSettings* schematic = nc.mutable_schematic();
230 aContainer.PackFrom( nc );
237 project::NetClass nc;
239 if( !aContainer.UnpackTo( &nc ) )
242 m_Name = wxString::FromUTF8( nc.name() );
246 if( nc.type() == project::NCT_IMPLICIT )
251 if( nc.board().has_clearance() )
254 if( nc.board().has_track_width() )
257 if( nc.board().has_diff_pair_track_width() )
260 if( nc.board().has_diff_pair_gap() )
263 if( nc.board().has_diff_pair_via_gap() )
266 if( nc.board().has_via_stack() )
268 if( nc.board().via_stack().copper_layers_size() > 0 )
269 m_ViaDia = nc.board().via_stack().copper_layers().at( 0 ).size().x_nm();
271 if( nc.board().via_stack().has_drill() )
272 m_ViaDrill = nc.board().via_stack().drill().diameter().x_nm();
275 if( nc.board().has_color() )
278 if( nc.board().has_tuning_profile() )
281 if( nc.schematic().has_wire_width() )
284 if( nc.schematic().has_bus_width() )
287 if( nc.schematic().has_color() )
315 return nc && nc->GetName().Matches( netclass );
331 name.Printf(
_(
"%s and %s" ),
337 name.Printf(
_(
"%s, %s and %s" ),
344 name.Printf(
_(
"%s, %s and %d more" ),
367 name.reserve( strLen );
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
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
bool m_isDefault
Mark if this instance is the default netclass.
std::optional< int > m_busWidth
void SetDiffPairGapParent(NETCLASS *parent)
void SetTuningProfileParent(NETCLASS *aParent)
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...
wxString m_tuningProfile
The tuning profile name being used by this netclass.
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
std::optional< int > m_uViaDia
microvia diameter
bool EqualsByPersistedFields(const NETCLASS &aOther) const
Compare every persisted field (name, priority, sized fields, colors, line style, tuning profile) to d...
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)
std::optional< int > m_uViaDrill
microvia drill hole diameter
void SetBusWidth(int aWidth)
void SetClearanceParent(NETCLASS *parent)
void SetWireWidth(int aWidth)
void SetDiffPairViaGapParent(NETCLASS *parent)
void SetTuningProfile(const wxString &aTuningProfile)
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.
KICOMMON_API void PackColor(types::Color &aOutput, const KIGFX::COLOR4D &aInput)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API KIGFX::COLOR4D UnpackColor(const types::Color &aInput)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
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