58#include <wx/combobox.h>
80 void setter(
void* obj, wxAny& v )
override
84 if( !v.GetAs( &value ) )
95 if( !variantName.IsEmpty() )
110 footprint->
Add( newField );
119 wxAny
getter(
const void* obj )
const override
126 wxString variantName;
133 if( !variantName.IsEmpty() )
138 return wxAny(
text );
162 wxPGWindowList
CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
const wxPoint& aPos,
163 const wxSize& aSize )
const override
178 editor->SetNetInfo( &board->GetNetInfo() );
185 editor->Bind( FILTERED_ITEM_SELECTED,
186 [=]( wxCommandEvent& aEvt )
188 auto& choices =
const_cast<wxPGChoices&
>( aProperty->GetChoices() );
189 wxString netname =
editor->GetSelectedNetname();
191 if( choices.Index( netname ) == wxNOT_FOUND )
192 choices.Add( netname,
editor->GetSelectedNetcode() );
194 wxVariant val(
editor->GetSelectedNetcode() );
195 aGrid->ChangePropertyValue( aProperty, val );
201 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl )
const override
205 if( aProperty->IsValueUnspecified() )
206 editor->SetIndeterminate();
208 editor->SetSelectedNetcode( (
int) aProperty->GetValue().GetLong() );
219 aVariant =
static_cast<long>(
editor->GetSelectedNetcode() );
223 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow, wxEvent& aEvent )
const override
275 wxPGWindowList
CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
const wxPoint& aPos,
276 const wxSize& aSize )
const override
280 wxComboBox*
editor =
new wxComboBox( aGrid->GetPanel(), wxID_ANY, wxEmptyString, aPos, aSize, 0,
nullptr,
281 wxCB_DROPDOWN | wxTE_PROCESS_ENTER );
290 std::shared_ptr<bool> popupShown = std::make_shared<bool>(
false );
292 [
this, aGrid, aProperty]()
294 wxVariant val(
static_cast<long>(
m_unitBinder->GetValue() ) );
295 aGrid->ChangePropertyValue( aProperty, val );
298 editor->Bind( wxEVT_COMBOBOX_DROPDOWN,
299 [popupShown]( wxCommandEvent& aEvent )
305 editor->Bind( wxEVT_COMBOBOX,
306 [commitValue, popupShown]( wxCommandEvent& aEvent )
315 editor->Bind( wxEVT_COMBOBOX_CLOSEUP,
316 [aGrid, popupShown]( wxCommandEvent& aEvent )
318 aGrid->CallAfter( [popupShown]()
326 editor->Bind( wxEVT_CHAR_HOOK,
327 [commitValue, popupShown]( wxKeyEvent& aEvent )
331 if( ( aEvent.GetKeyCode() == WXK_RETURN
332 || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
342 editor->Bind( wxEVT_KILL_FOCUS,
343 [commitValue, popupShown]( wxFocusEvent& aEvent )
352 return wxPGWindowList(
editor,
nullptr );
355 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl )
const override
360 wxComboBox*
editor =
dynamic_cast<wxComboBox*
>( aCtrl );
363 if( aProperty->IsValueUnspecified() )
366 m_unitBinder->ChangeValue( aProperty->GetValue().GetLong() );
374 wxComboBox*
editor =
dynamic_cast<wxComboBox*
>( aCtrl );
375 wxCHECK_MSG(
editor,
false,
"PG_TRACK_WIDTH_EDITOR requires a combo box!" );
384 bool changed = aVariant.IsNull() ||
result != aVariant.GetLong();
392 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow, wxEvent& aEvent )
const override
400 std::vector<long long int> trackWidths;
403 for(
unsigned ii = 1; ii <
m_frame->GetDesignSettings().m_TrackWidthList.size(); ++ii )
404 trackWidths.push_back(
m_frame->GetDesignSettings().m_TrackWidthList[ii] );
410 for(
unsigned ii = 0; ii < aEditor->GetCount(); ++ii )
411 aEditor->SetString( ii, aEditor->GetString( ii ) + wxS(
" " ) + unitLabel );
554 if(
FOOTPRINT* footprint = board->GetFirstFootprint() )
556 aFallbackSelection.
Clear();
557 aFallbackSelection.
Add( footprint );
558 return aFallbackSelection;
572 return selection.
Empty() ? nullptr : selection.
Front();
619 wxCHECK2( field,
continue );
625 const wxString groupFields =
_HKI(
"Fields" );
656 const wxPGChoices& canonicalLayers = aProperty->
Choices();
657 wxArrayString boardLayerNames;
658 wxArrayInt boardLayerIDs;
660 for(
int ii = 0; ii < (int) aProperty->
Choices().GetCount(); ++ii )
662 int layer = canonicalLayers.GetValue( ii );
664 boardLayerNames.push_back(
m_frame->GetBoard()->GetLayerName(
ToLAYER_ID( layer ) ) );
665 boardLayerIDs.push_back( canonicalLayers.GetValue( ii ) );
671 [&](
int aValue ) -> wxColour
676 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
677 ret->SetName( aProperty->
Name() );
678 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
679 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
708 wxCHECK_MSG( firstItem,
nullptr, wxT(
"getPropertyFromEvent for a property with nothing selected!") );
711 wxCHECK_MSG( property,
nullptr, wxT(
"getPropertyFromEvent for a property not found on the selected item!" ) );
725 wxCHECK( property, );
728 wxVariant newValue = aEvent.GetPropertyValue();
730 if(
VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), item ) )
732 wxString errorMsg = wxString::Format( wxS(
"%s: %s" ), wxGetTranslation( property->Name() ),
733 validationFailure->get()->Format(
m_frame ) );
734 m_frame->ShowInfoBarError( errorMsg );
753 wxVariant newValue = aEvent.GetPropertyValue();
758 for(
EDA_ITEM* edaItem : selection )
760 if( !edaItem->IsBOARD_ITEM() )
765 wxCHECK( property, );
777 && !
m_frame->GetPcbNewSettings()->m_AllowFreePads
778 && ( aEvent.GetPropertyName() ==
_HKI(
"Position X" )
779 || aEvent.GetPropertyName() ==
_HKI(
"Position Y" ) ) )
789 if( aEvent.GetPropertyName() ==
_HKI(
"Position X" ) )
790 newPos.
x = (int) newValue.GetLong();
792 newPos.
y = (int) newValue.GetLong();
810 wxString variantName;
815 if( !variantName.IsEmpty() )
817 wxString propName = aEvent.GetPropertyName();
819 if( propName ==
_HKI(
"Do not Populate" )
820 || propName ==
_HKI(
"Exclude From Bill of Materials" )
821 || propName ==
_HKI(
"Exclude From Position Files" ) )
826 variant = footprint->
AddVariant( variantName );
830 bool boolValue = newValue.GetBool();
832 if( propName ==
_HKI(
"Do not Populate" ) )
833 variant->
SetDNP( boolValue );
834 else if( propName ==
_HKI(
"Exclude From Bill of Materials" ) )
836 else if( propName ==
_HKI(
"Exclude From Position Files" ) )
845 item->
Set( property, newValue );
848 changes.
Push(
_(
"Edit Properties" ) );
856 if( aEvent.GetPropertyName() ==
_HKI(
"Locked" ) )
865 wxPGChoices layersAll;
866 wxPGChoices layersCu;
892 std::vector<std::pair<wxString, int>> netNames;
896 netNames.emplace_back(
UnescapeString( netInfo->GetNetname() ), netCode );
898 std::sort( netNames.begin(), netNames.end(),
899 [](
const auto& a,
const auto& b )
901 return a.first.CmpNoCase( b.first ) < 0;
904 for(
const auto& [ netName, netCode ] : netNames )
905 nets.Add( netName, netCode );
908 netProperty->SetChoices( nets );
911 tuningNet->SetChoices( nets );
921 const wxString& propName = aProperty->
Name();
922 wxString variantName;
927 if( propName ==
_HKI(
"Do not Populate" ) )
932 else if( propName ==
_HKI(
"Exclude From Bill of Materials" ) )
937 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.
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_TRACK_WIDTH_EDITOR * m_trackWidthEditorInstance
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
wxString GetName() const override
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
static const wxString EDITOR_NAME
PG_NET_SELECTOR_EDITOR()=default
static const wxString EDITOR_NAME
std::unique_ptr< PROPERTY_EDITOR_UNIT_BINDER > m_unitBinder
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
void UpdateFrame(PCB_BASE_EDIT_FRAME *aFrame)
wxString GetName() const override
PG_TRACK_WIDTH_EDITOR(PCB_BASE_EDIT_FRAME *aFrame)
static const wxString EDITOR_NAME
PCB_BASE_EDIT_FRAME * m_frame
void setTrackWidthOptions(wxComboBox *aEditor) const
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
static wxString BuildEditorName(PCB_BASE_EDIT_FRAME *aFrame)
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aWindow, wxEvent &aEvent) const override
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.
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
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)
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
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)
wxString result
Test unit parsing edge cases and error handling.
@ 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