702 |
|
|
703 |
if layer.HasClassification(): |
if layer.HasClassification(): |
704 |
self.originalClass = self.layer.GetClassification() |
self.originalClass = self.layer.GetClassification() |
705 |
self.originalClassField = self.layer.GetClassificationField() |
self.originalClassField = self.layer.GetClassificationColumn() |
706 |
field = self.originalClassField |
field = self.originalClassField |
707 |
fieldType = self.layer.GetFieldType(field) |
fieldType = self.layer.GetFieldType(field) |
708 |
|
|
891 |
self.fields.SetClientData(self.__cur_field, clazz) |
self.fields.SetClientData(self.__cur_field, clazz) |
892 |
self.classGrid.GetTable().SetClassification(clazz) |
self.classGrid.GetTable().SetClassification(clazz) |
893 |
|
|
894 |
def __BuildClassification(self, fieldIndex, copyClass = False): |
def __BuildClassification(self, fieldIndex, copyClass=False, force=False): |
895 |
|
|
896 |
# numRows = self.classGrid.GetNumberRows() |
# numRows = self.classGrid.GetNumberRows() |
897 |
# assert numRows > 0 # there should always be a default row |
# assert numRows > 0 # there should always be a default row |
903 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
904 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldType = self.layer.GetFieldType(fieldName) |
905 |
|
|
906 |
clazz = self.classGrid.GetTable().GetClassification() |
clazz = self.fields.GetClientData(fieldIndex) |
907 |
|
if clazz is None or self.classGrid.GetTable().IsModified() or force: |
908 |
if copyClass: |
clazz = self.classGrid.GetTable().GetClassification() |
909 |
clazz = copy.deepcopy(clazz) |
if copyClass: |
910 |
|
clazz = copy.deepcopy(clazz) |
911 |
|
|
912 |
return clazz |
return clazz, fieldName |
913 |
|
|
914 |
def __SetGridTable(self, fieldIndex, group = None): |
def __SetGridTable(self, fieldIndex, group = None): |
915 |
|
|
946 |
assert oldIndex >= -1 |
assert oldIndex >= -1 |
947 |
|
|
948 |
if oldIndex != -1: |
if oldIndex != -1: |
949 |
clazz = self.__BuildClassification(oldIndex) |
clazz, name = self.__BuildClassification(oldIndex, force = True) |
950 |
self.fields.SetClientData(oldIndex, clazz) |
self.fields.SetClientData(oldIndex, clazz) |
951 |
|
|
952 |
self.__SetGridTable(newIndex, group) |
self.__SetGridTable(newIndex, group) |
985 |
# to begin with or it has been modified |
# to begin with or it has been modified |
986 |
# |
# |
987 |
self.classGrid.SaveEditControlValue() |
self.classGrid.SaveEditControlValue() |
988 |
if clazz is None or self.classGrid.GetTable().IsModified(): |
clazz, name = self.__BuildClassification(self.__cur_field, True) |
|
clazz = self.__BuildClassification(self.__cur_field, True) |
|
989 |
|
|
990 |
self.layer.SetClassificationField( |
self.layer.SetClassificationColumn(name) |
|
self.fields.GetString(self.__cur_field)) |
|
991 |
self.layer.SetClassification(clazz) |
self.layer.SetClassification(clazz) |
992 |
|
|
993 |
self.haveApplied = True |
self.haveApplied = True |
1011 |
def _OnRevert(self, event): |
def _OnRevert(self, event): |
1012 |
"""The layer's current classification stays the same.""" |
"""The layer's current classification stays the same.""" |
1013 |
if self.haveApplied: |
if self.haveApplied: |
1014 |
self.layer.SetClassificationField(self.originalClassField) |
self.layer.SetClassificationColumn(self.originalClassField) |
1015 |
self.layer.SetClassification(self.originalClass) |
self.layer.SetClassification(self.originalClass) |
1016 |
|
|
1017 |
#self.Close() |
#self.Close() |