72 void setter(
void* obj, wxAny& v )
override
76 if( !v.GetAs( &value ) )
87 if( !variantName.IsEmpty() )
102 footprint->
Add( newField );
111 wxAny
getter(
const void* obj )
const override
118 wxString variantName;
125 if( !variantName.IsEmpty() )
130 return wxAny(
text );
157 const wxPoint& aPos,
const wxSize& aSize )
const override
162 editor->SetNetInfo( &board->GetNetInfo() );
167 editor->Bind( FILTERED_ITEM_SELECTED,
168 [=]( wxCommandEvent& aEvt )
170 auto& choices =
const_cast<wxPGChoices&
>( aProperty->GetChoices() );
171 wxString netname =
editor->GetSelectedNetname();
173 if( choices.Index( netname ) == wxNOT_FOUND )
174 choices.Add( netname,
editor->GetSelectedNetcode() );
176 wxVariant val(
editor->GetSelectedNetcode() );
177 aGrid->ChangePropertyValue( aProperty, val );
183 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl )
const override
187 if( aProperty->IsValueUnspecified() )
188 editor->SetIndeterminate();
190 editor->SetSelectedNetcode( (
int) aProperty->GetValue().GetLong() );
195 wxWindow* aCtrl )
const override
202 aVariant =
static_cast<long>(
editor->GetSelectedNetcode() );
206 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow,
207 wxEvent& aEvent )
const override
328 if(
FOOTPRINT* footprint = board->GetFirstFootprint() )
330 aFallbackSelection.
Clear();
331 aFallbackSelection.
Add( footprint );
332 return aFallbackSelection;
346 return selection.
Empty() ? nullptr : selection.
Front();
387 const wxString groupFields =
_HKI(
"Fields" );
411 const wxPGChoices& canonicalLayers = aProperty->
Choices();
412 wxArrayString boardLayerNames;
413 wxArrayInt boardLayerIDs;
415 for(
int ii = 0; ii < (int) aProperty->
Choices().GetCount(); ++ii )
417 int layer = canonicalLayers.GetValue( ii );
419 boardLayerNames.push_back(
m_frame->GetBoard()->GetLayerName(
ToLAYER_ID( layer ) ) );
420 boardLayerIDs.push_back( canonicalLayers.GetValue( ii ) );
426 [&](
int aValue ) -> wxColour
431 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
432 ret->SetName( aProperty->
Name() );
433 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
434 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
459 wxCHECK_MSG( firstItem,
nullptr,
460 wxT(
"getPropertyFromEvent for a property with nothing selected!") );
463 wxCHECK_MSG( property,
nullptr,
464 wxT(
"getPropertyFromEvent for a property not found on the selected item!" ) );
478 wxCHECK( property, );
481 wxVariant newValue = aEvent.GetPropertyValue();
483 if(
VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), item ) )
485 wxString errorMsg = wxString::Format( wxS(
"%s: %s" ), wxGetTranslation( property->Name() ),
486 validationFailure->get()->Format(
m_frame ) );
487 m_frame->ShowInfoBarError( errorMsg );
506 wxVariant newValue = aEvent.GetPropertyValue();
511 for(
EDA_ITEM* edaItem : selection )
513 if( !edaItem->IsBOARD_ITEM() )
518 wxCHECK( property, );
530 && !
m_frame->GetPcbNewSettings()->m_AllowFreePads
531 && ( aEvent.GetPropertyName() ==
_HKI(
"Position X" )
532 || aEvent.GetPropertyName() ==
_HKI(
"Position Y" ) ) )
542 if( aEvent.GetPropertyName() ==
_HKI(
"Position X" ) )
543 newPos.
x = (int) newValue.GetLong();
545 newPos.
y = (int) newValue.GetLong();
563 wxString variantName;
568 if( !variantName.IsEmpty() )
570 wxString propName = aEvent.GetPropertyName();
572 if( propName ==
_HKI(
"Do not Populate" )
573 || propName ==
_HKI(
"Exclude From Bill of Materials" )
574 || propName ==
_HKI(
"Exclude From Position Files" ) )
579 variant = footprint->
AddVariant( variantName );
583 bool boolValue = newValue.GetBool();
585 if( propName ==
_HKI(
"Do not Populate" ) )
586 variant->
SetDNP( boolValue );
587 else if( propName ==
_HKI(
"Exclude From Bill of Materials" ) )
589 else if( propName ==
_HKI(
"Exclude From Position Files" ) )
598 item->
Set( property, newValue );
601 changes.
Push(
_(
"Edit Properties" ) );
609 if( aEvent.GetPropertyName() ==
_HKI(
"Locked" ) )
618 wxPGChoices layersAll;
619 wxPGChoices layersCu;
645 std::vector<std::pair<wxString, int>> netNames;
649 netNames.emplace_back(
UnescapeString( netInfo->GetNetname() ), netCode );
651 std::sort( netNames.begin(), netNames.end(),
652 [](
const auto& a,
const auto& b )
654 return a.first.CmpNoCase( b.first ) < 0;
657 for(
const auto& [ netName, netCode ] : netNames )
658 nets.Add( netName, netCode );
661 netProperty->SetChoices( nets );
664 tuningNet->SetChoices( nets );
674 wxString variantName;
679 if( !variantName.IsEmpty() )
681 wxString propName = aProperty->
Name();
683 if( propName ==
_HKI(
"Do not Populate" ) )
688 else if( propName ==
_HKI(
"Exclude From Bill of Materials" ) )
693 else if( propName ==
_HKI(
"Exclude From Position Files" ) )
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD_ITEM_CONTAINER * GetParent() const
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
wxString GetCurrentVariant() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetText(const wxString &aText)
static const TOOL_EVENT SelectedEvent
Class that other classes need to inherit from, in order to be inspectable.
bool Set(PROPERTY_BASE *aProperty, wxAny &aValue, bool aNotify=true)
bool IsBOARD_ITEM() const
LSET is a set of PCB_LAYER_IDs.
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
const NETCODES_MAP & NetsByNetcode() const
Return the netcode map, at least for python.
Common, abstract interface for edit frames.
The main frame for Pcbnew.
PCB_BASE_EDIT_FRAME * m_frame
PG_NET_SELECTOR_EDITOR * m_netSelectorEditorInstance
void valueChanged(wxPropertyGridEvent &aEvent) override
Regenerates caches storing layer and net names.
PG_UNIT_EDITOR * m_unitEditorInstance
PG_RATIO_EDITOR * m_ratioEditorInstance
wxPGProperty * createPGProperty(const PROPERTY_BASE *aProperty) const override
void UpdateData() override
void rebuildProperties(const SELECTION &aSelection) override
Generates the property grid for a given selection of items.
PCB_PROPERTIES_PANEL(wxWindow *aParent, PCB_BASE_EDIT_FRAME *aFrame)
const SELECTION & getSelection(SELECTION &aFallbackSelection)
Get the current selection from the selection tool.
EDA_ITEM * getFrontItem()
Get the front item of the current selection.
virtual ~PCB_PROPERTIES_PANEL()
static std::set< wxString > m_currentFieldNames
PROPERTY_BASE * getPropertyFromEvent(const wxPropertyGridEvent &aEvent) const
PROPERTY_MANAGER & m_propMgr
PG_URL_EDITOR * m_urlEditorInstance
void AfterCommit() override
PG_CHECKBOX_EDITOR * m_checkboxEditorInstance
void updateLists(const BOARD *aBoard)
void valueChanging(wxPropertyGridEvent &aEvent) override
bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue) override
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
PG_FPID_EDITOR * m_fpEditorInstance
static const wxString EDITOR_NAME
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aWindow, wxEvent &aEvent) const override
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
PCB_BASE_EDIT_FRAME * m_frame
wxString GetName() const override
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
static const wxString EDITOR_NAME
PG_NET_SELECTOR_EDITOR(PCB_BASE_EDIT_FRAME *aFrame)
static const wxString EDITOR_NAME
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
PROPERTIES_PANEL(wxWindow *aParent, EDA_BASE_FRAME *aFrame)
int m_SuppressGridChangeEvents
virtual bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue)
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
virtual void rebuildProperties(const SELECTION &aSelection)
Generates the property grid for a given selection of items.
virtual size_t TypeHash() const =0
Return type-id of the property type.
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
< Used to generate unique IDs. Must come up front so it's initialized before ctor.
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
virtual bool Writeable(INSPECTABLE *aObject) const
const wxString & Name() const
virtual const wxPGChoices & Choices() const
Return a limited set of possible values (e.g.
Provide class metadata.Helper macro to map type hashes to names.
virtual void Add(EDA_ITEM *aItem)
virtual void Clear() override
Remove all the stored items from the group.
bool Empty() const
Checks if there is anything selected.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
static const wxString MISSING_FIELD_SENTINEL
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
Customized abstract wxPGProperty class to handle coordinate/size units.
APIIMPORT wxPGGlobalVarsClass * wxPGGlobalVars
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
static const wxString MISSING_FIELD_SENTINEL
wxString UnescapeString(const wxString &aSource)
@ USER
The field ID hasn't been set yet; field is invalid.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
wxString GetCanonicalFieldName(FIELD_T aFieldType)
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
Functions to provide common constants and other functions to assist in making a consistent UI.
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
VECTOR2< int32_t > VECTOR2I