71 void setter(
void* obj, wxAny& v )
override
75 if( !v.GetAs( &value ) )
85 footprint->
Add( newField );
93 wxAny
getter(
const void* obj )
const override
99 return wxAny( field->
GetText() );
123 const wxPoint& aPos,
const wxSize& aSize )
const override
128 editor->SetNetInfo( &board->GetNetInfo() );
133 editor->Bind( FILTERED_ITEM_SELECTED,
134 [=]( wxCommandEvent& aEvt )
136 auto& choices =
const_cast<wxPGChoices&
>( aProperty->GetChoices() );
137 wxString netname =
editor->GetSelectedNetname();
139 if( choices.Index( netname ) == wxNOT_FOUND )
140 choices.Add( netname,
editor->GetSelectedNetcode() );
142 wxVariant val(
editor->GetSelectedNetcode() );
143 aGrid->ChangePropertyValue( aProperty, val );
149 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl )
const override
153 if( aProperty->IsValueUnspecified() )
154 editor->SetIndeterminate();
156 editor->SetSelectedNetcode( (
int) aProperty->GetValue().GetLong() );
161 wxWindow* aCtrl )
const override
168 aVariant =
static_cast<long>(
editor->GetSelectedNetcode() );
172 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow,
173 wxEvent& aEvent )
const override
322 const wxString groupFields =
_HKI(
"Fields" );
346 const wxPGChoices& canonicalLayers = aProperty->
Choices();
347 wxArrayString boardLayerNames;
348 wxArrayInt boardLayerIDs;
350 for(
int ii = 0; ii < (int) aProperty->
Choices().GetCount(); ++ii )
352 int layer = canonicalLayers.GetValue( ii );
354 boardLayerNames.push_back(
m_frame->GetBoard()->GetLayerName(
ToLAYER_ID( layer ) ) );
355 boardLayerIDs.push_back( canonicalLayers.GetValue( ii ) );
361 [&](
int aValue ) -> wxColour
366 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
367 ret->SetName( aProperty->
Name() );
368 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
369 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
390 if( !selection.Front()->IsBOARD_ITEM() )
395 wxCHECK_MSG( firstItem,
nullptr,
396 wxT(
"getPropertyFromEvent for a property with nothing selected!") );
399 aEvent.GetPropertyName() );
400 wxCHECK_MSG( property,
nullptr,
401 wxT(
"getPropertyFromEvent for a property not found on the selected item!" ) );
417 wxCHECK( property, );
420 wxVariant newValue = aEvent.GetPropertyValue();
422 if(
VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), item ) )
424 wxString errorMsg = wxString::Format( wxS(
"%s: %s" ), wxGetTranslation( property->Name() ),
425 validationFailure->get()->Format(
m_frame ) );
426 m_frame->ShowInfoBarError( errorMsg );
445 wxVariant newValue = aEvent.GetPropertyValue();
450 for(
EDA_ITEM* edaItem : selection )
452 if( !edaItem->IsBOARD_ITEM() )
457 wxCHECK( property, );
469 && !
m_frame->GetPcbNewSettings()->m_AllowFreePads
470 && ( aEvent.GetPropertyName() ==
_HKI(
"Position X" )
471 || aEvent.GetPropertyName() ==
_HKI(
"Position Y" ) ) )
481 if( aEvent.GetPropertyName() ==
_HKI(
"Position X" ) )
482 newPos.
x = (int) newValue.GetLong();
484 newPos.
y = (int) newValue.GetLong();
498 item->
Set( property, newValue );
501 changes.
Push(
_(
"Edit Properties" ) );
509 if( aEvent.GetPropertyName() ==
_HKI(
"Locked" ) )
518 wxPGChoices layersAll;
519 wxPGChoices layersCu;
541 std::vector<std::pair<wxString, int>> netNames;
545 netNames.emplace_back(
UnescapeString( netInfo->GetNetname() ), netCode );
547 std::sort( netNames.begin(), netNames.end(), [](
const auto& a,
const auto& b )
549 return a.first.CmpNoCase( b.first ) < 0;
552 for(
const auto& [ netName, netCode ] : netNames )
553 nets.Add( netName, netCode );
556 netProperty->SetChoices( nets );
559 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)
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)
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.
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