QA: PCB Fields bug fixes
This commit is contained in:
parent
85f889bc19
commit
85c633eb00
|
@ -332,6 +332,11 @@ constexpr bool IsInstantiableType( const KICAD_T aType )
|
||||||
|
|
||||||
case SCH_SYMBOL_LOCATE_POWER_T:
|
case SCH_SYMBOL_LOCATE_POWER_T:
|
||||||
|
|
||||||
|
case PCB_FIELD_LOCATE_REFERENCE_T:
|
||||||
|
case PCB_FIELD_LOCATE_VALUE_T:
|
||||||
|
case PCB_FIELD_LOCATE_FOOTPRINT_T:
|
||||||
|
case PCB_FIELD_LOCATE_DATASHEET_T:
|
||||||
|
|
||||||
case PCB_LOCATE_STDVIA_T:
|
case PCB_LOCATE_STDVIA_T:
|
||||||
case PCB_LOCATE_UVIA_T:
|
case PCB_LOCATE_UVIA_T:
|
||||||
case PCB_LOCATE_BBVIA_T:
|
case PCB_LOCATE_BBVIA_T:
|
||||||
|
@ -448,6 +453,10 @@ constexpr bool IsPcbnewType( const KICAD_T aType )
|
||||||
case PCB_NETINFO_T:
|
case PCB_NETINFO_T:
|
||||||
case PCB_GROUP_T:
|
case PCB_GROUP_T:
|
||||||
|
|
||||||
|
case PCB_FIELD_LOCATE_REFERENCE_T:
|
||||||
|
case PCB_FIELD_LOCATE_VALUE_T:
|
||||||
|
case PCB_FIELD_LOCATE_FOOTPRINT_T:
|
||||||
|
case PCB_FIELD_LOCATE_DATASHEET_T:
|
||||||
case PCB_LOCATE_STDVIA_T:
|
case PCB_LOCATE_STDVIA_T:
|
||||||
case PCB_LOCATE_UVIA_T:
|
case PCB_LOCATE_UVIA_T:
|
||||||
case PCB_LOCATE_BBVIA_T:
|
case PCB_LOCATE_BBVIA_T:
|
||||||
|
|
|
@ -30,9 +30,8 @@
|
||||||
|
|
||||||
|
|
||||||
%template(MAP_STRING_STRING) std::map<wxString, wxString>;
|
%template(MAP_STRING_STRING) std::map<wxString, wxString>;
|
||||||
%rename(GetPropertiesNative) FOOTPRINT::GetProperties;
|
%rename(GetFieldsNative) FOOTPRINT::GetFields;
|
||||||
%rename(GetPropertyNative) FOOTPRINT::GetProperty;
|
%rename(SetFieldsNative) FOOTPRINT::SetFields;
|
||||||
%rename(SetPropertiesNative) FOOTPRINT::SetProperties;
|
|
||||||
%feature("flatnested");
|
%feature("flatnested");
|
||||||
%include footprint.h
|
%include footprint.h
|
||||||
%feature("flatnested", "");
|
%feature("flatnested", "");
|
||||||
|
@ -61,24 +60,24 @@
|
||||||
# the object in the garbage collector
|
# the object in the garbage collector
|
||||||
#
|
#
|
||||||
|
|
||||||
def GetProperties(self):
|
def GetFields(self):
|
||||||
""" Returns footprint properties map. """
|
""" Returns footprint fields map. """
|
||||||
properties = self.GetPropertiesNative()
|
fields = self.GetFieldsNative()
|
||||||
return {str(k): str(v) for k, v in properties.items()}
|
return {str(k): str(v) for k, v in fields.items()}
|
||||||
|
|
||||||
def GetProperty(self, key):
|
def GetField(self, key):
|
||||||
""" Returns property with a given key if it exists, throws KeyError otherwise. """
|
""" Returns Field with a given key if it exists, throws KeyError otherwise. """
|
||||||
if self.HasProperty(key):
|
if self.HasField(key):
|
||||||
return self.GetPropertyNative(key)
|
return self.GetFieldByName(key)
|
||||||
else:
|
else:
|
||||||
raise KeyError("Property not found: " + key)
|
raise KeyError("Field not found: " + key)
|
||||||
|
|
||||||
def SetProperties(self, properties):
|
def SetFields(self, fields):
|
||||||
""" Sets footprint properties map. """
|
""" Sets footprint fields map. """
|
||||||
wxproperties = MAP_STRING_STRING()
|
wxfields = MAP_STRING_STRING()
|
||||||
for k, v in properties.items():
|
for k, v in fields.items():
|
||||||
wxproperties[k] = v
|
wxfields[k] = v
|
||||||
self.SetPropertiesNative(wxproperties)
|
self.SetFieldsNative(wxfields)
|
||||||
|
|
||||||
%}
|
%}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,15 +123,15 @@ class TestBoardClass:
|
||||||
def test_footprint_properties(self):
|
def test_footprint_properties(self):
|
||||||
pcb = LoadBoard("../data/pcbnew/custom_fields.kicad_pcb")
|
pcb = LoadBoard("../data/pcbnew/custom_fields.kicad_pcb")
|
||||||
footprint = pcb.FindFootprintByReference('J1')
|
footprint = pcb.FindFootprintByReference('J1')
|
||||||
expected_properties = {
|
expected_fields = {
|
||||||
'Sheet file': 'custom_fields.kicad_sch',
|
'Sheet file': 'custom_fields.kicad_sch',
|
||||||
'Sheet name': '',
|
'Sheet name': '',
|
||||||
'myfield': 'myvalue'
|
'myfield': 'myvalue'
|
||||||
}
|
}
|
||||||
assert footprint.GetProperties() == expected_properties
|
assert footprint.GetFields() == expected_fields
|
||||||
assert footprint.GetProperty('myfield') == 'myvalue'
|
assert footprint.GetField('myfield') == 'myvalue'
|
||||||
assert footprint.HasProperty('myfield') == True
|
assert footprint.HasField('myfield') == True
|
||||||
assert footprint.HasProperty('abcd') == False
|
assert footprint.HasField('abcd') == False
|
||||||
footprint.SetProperty('abcd', 'efgh')
|
footprint.SetField('abcd', 'efgh')
|
||||||
assert footprint.HasProperty('abcd') == True
|
assert footprint.HasField('abcd') == True
|
||||||
assert footprint.GetProperty('abcd') == 'efgh'
|
assert footprint.GetField('abcd') == 'efgh'
|
||||||
|
|
Loading…
Reference in New Issue