29#include <api/board/board_types.pb.h>
50 m_ordinal( static_cast<int>( aFieldId ) ),
69 field.mutable_id()->set_id( (
int)
GetId() );
77 kiapi::board::types::Field field;
79 aContainer.PackFrom( field );
90 SetName( wxString( field.name().c_str(), wxConvUTF8 ) );
92 if( field.has_text() )
99 if( field.text().layer() == kiapi::board::types::BoardLayer::BL_UNKNOWN )
110 kiapi::board::types::Field field;
112 if( !aContainer.UnpackTo( &field ) )
123 else if(
m_name.IsEmpty() && aUseDefaultName )
141 bool hasVariantOverride =
false;
144 if( parentFootprint && board )
152 if( variant->HasFieldValue(
GetName() ) )
160 hasVariantOverride =
true;
166 if( !hasVariantOverride )
171 std::function<bool( wxString* )>
resolver =
172 [&]( wxString* token ) ->
bool
174 if( token->IsSameAs( wxT(
"LAYER" ) ) )
180 if( parentFootprint && parentFootprint->
ResolveTextVar( token, aDepth + 1 ) )
189 if( hasTextVars && aContext !=
RAW_VALUE )
219 return _(
"User Field" );
240 return wxString::Format(
_(
"Reference field of %s" ), ref );
243 return wxString::Format(
_(
"Value field of %s (%s)" ), ref, content );
246 return wxString::Format(
_(
"Footprint field of %s (%s)" ), ref, content );
249 return wxString::Format(
_(
"Datasheet field of %s (%s)" ), ref, content );
253 return wxString::Format(
_(
"Field of %s (%s)" ), ref, content );
255 return wxString::Format(
_(
"%s field of %s (%s)" ),
GetName(), ref, content );
294 *
this = *
static_cast<const PCB_FIELD*
>( aOther );
313 return *
this == other;
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
BOARD_ITEM_CONTAINER * GetParent() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
bool ResolveTextVar(wxString *token, int aDepth) const
wxString GetCurrentVariant() const
KICAD_T Type() const
Returns the type of object.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
virtual void SetVisible(bool aVisible)
double Similarity(const EDA_TEXT &aOther) const
bool operator==(const EDA_TEXT &aRhs) const
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
bool m_ForceShowFieldsWhenFPSelected
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
bool operator==(const PCB_FIELD &aOther) const
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
PCB_FIELD(FOOTPRINT *aParent, FIELD_T aFieldId, const wxString &aName=wxEmptyString)
wxString GetTextTypeDescription() const override
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void CopyFrom(const BOARD_ITEM *aOther) override
bool HasHypertext() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int m_ordinal
Sort order for non-mandatory fields.
void SetName(const wxString &aName)
void swapData(BOARD_ITEM *aImage) override
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
PCB_TEXT(BOARD_ITEM *parent, KICAD_T idtype=PCB_TEXT_T)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
PCB_TEXT & operator=(const PCB_TEXT &aOther)
PROPERTY_BASE & SetIsHiddenFromPropertiesManager(bool aHide=true)
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
void FinalizeTextVarExpansion(wxString &aText, RESOLUTION_CONTEXT aContext)
wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
static std::string ToStdString(const wxString &aStr)
static FILENAME_RESOLVER * resolver
Some functions to handle hotkeys in KiCad.
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
static struct PCB_FIELD_DESC _PCB_FIELD_DESC
#define NO_SETTER(owner, type)
wxString GetDefaultVariantName()
wxString UnescapeString(const wxString &aSource)
bool IsURL(wxString aStr)
Performs a URL sniff-test on a string.
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property