72 void setter(
void* obj, wxAny& v )
override
76 if( !v.GetAs( &value ) )
86 footprint->
Add( newField );
94 wxAny
getter(
const void* obj )
const override
100 return wxAny( field->
GetText() );
124 const wxPoint& aPos,
const wxSize& aSize )
const override
129 editor->SetNetInfo( &board->GetNetInfo() );
134 editor->Bind( FILTERED_ITEM_SELECTED,
135 [=]( wxCommandEvent& aEvt )
137 auto& choices =
const_cast<wxPGChoices&
>( aProperty->GetChoices() );
138 wxString netname =
editor->GetSelectedNetname();
140 if( choices.Index( netname ) == wxNOT_FOUND )
141 choices.Add( netname,
editor->GetSelectedNetcode() );
143 wxVariant val(
editor->GetSelectedNetcode() );
144 aGrid->ChangePropertyValue( aProperty, val );
150 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl )
const override
154 if( aProperty->IsValueUnspecified() )
155 editor->SetIndeterminate();
157 editor->SetSelectedNetcode( (
int) aProperty->GetValue().GetLong() );
162 wxWindow* aCtrl )
const override
169 aVariant =
static_cast<long>(
editor->GetSelectedNetcode() );
173 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow,
174 wxEvent& aEvent )
const override
295 if(
FOOTPRINT* footprint = board->GetFirstFootprint() )
297 aFallbackSelection.
Clear();
298 aFallbackSelection.
Add( footprint );
299 return aFallbackSelection;
313 return selection.
Empty() ? nullptr : selection.
Front();
354 const wxString groupFields =
_HKI(
"Fields" );
378 const wxPGChoices& canonicalLayers = aProperty->
Choices();
379 wxArrayString boardLayerNames;
380 wxArrayInt boardLayerIDs;
382 for(
int ii = 0; ii < (int) aProperty->
Choices().GetCount(); ++ii )
384 int layer = canonicalLayers.GetValue( ii );
386 boardLayerNames.push_back(
m_frame->GetBoard()->GetLayerName(
ToLAYER_ID( layer ) ) );
387 boardLayerIDs.push_back( canonicalLayers.GetValue( ii ) );
393 [&](
int aValue ) -> wxColour
398 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
399 ret->SetName( aProperty->
Name() );
400 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
401 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
426 wxCHECK_MSG( firstItem,
nullptr,
427 wxT(
"getPropertyFromEvent for a property with nothing selected!") );
430 wxCHECK_MSG( property,
nullptr,
431 wxT(
"getPropertyFromEvent for a property not found on the selected item!" ) );
445 wxCHECK( property, );
448 wxVariant newValue = aEvent.GetPropertyValue();
450 if(
VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), item ) )
452 wxString errorMsg = wxString::Format( wxS(
"%s: %s" ), wxGetTranslation( property->Name() ),
453 validationFailure->get()->Format(
m_frame ) );
454 m_frame->ShowInfoBarError( errorMsg );
473 wxVariant newValue = aEvent.GetPropertyValue();
478 for(
EDA_ITEM* edaItem : selection )
480 if( !edaItem->IsBOARD_ITEM() )
485 wxCHECK( property, );
497 && !
m_frame->GetPcbNewSettings()->m_AllowFreePads
498 && ( aEvent.GetPropertyName() ==
_HKI(
"Position X" )
499 || aEvent.GetPropertyName() ==
_HKI(
"Position Y" ) ) )
509 if( aEvent.GetPropertyName() ==
_HKI(
"Position X" ) )
510 newPos.
x = (int) newValue.GetLong();
512 newPos.
y = (int) newValue.GetLong();
526 item->
Set( property, newValue );
529 changes.
Push(
_(
"Edit Properties" ) );
537 if( aEvent.GetPropertyName() ==
_HKI(
"Locked" ) )
546 wxPGChoices layersAll;
547 wxPGChoices layersCu;
569 std::vector<std::pair<wxString, int>> netNames;
573 netNames.emplace_back(
UnescapeString( netInfo->GetNetname() ), netCode );
575 std::sort( netNames.begin(), netNames.end(),
576 [](
const auto& a,
const auto& b )
578 return a.first.CmpNoCase( b.first ) < 0;
581 for(
const auto& [ netName, netCode ] : netNames )
582 nets.Add( netName, netCode );
585 netProperty->SetChoices( nets );
588 tuningNet->SetChoices( nets );
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...
BOARD_ITEM_CONTAINER * GetParent() const
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() 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
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 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