35 |
from Thuban.UI.classgen import ClassGenDialog |
from Thuban.UI.classgen import ClassGenDialog |
36 |
|
|
37 |
from dialogs import NonModalNonParentDialog |
from dialogs import NonModalNonParentDialog |
38 |
|
from messages import MAP_REPLACED |
39 |
|
|
40 |
ID_CLASS_TABLE = 40011 |
ID_CLASS_TABLE = 40011 |
41 |
|
|
683 |
|
|
684 |
self.__SetTitle(layer.Title()) |
self.__SetTitle(layer.Title()) |
685 |
|
|
686 |
|
self.parent.Subscribe(MAP_REPLACED, self.map_replaced) |
687 |
self.layer = layer |
self.layer = layer |
688 |
self.map = map |
self.map = map |
689 |
|
|
704 |
|
|
705 |
if layer.HasClassification(): |
if layer.HasClassification(): |
706 |
self.originalClass = self.layer.GetClassification() |
self.originalClass = self.layer.GetClassification() |
707 |
self.originalClassField = self.layer.GetClassificationField() |
self.originalClassField = self.layer.GetClassificationColumn() |
708 |
field = self.originalClassField |
field = self.originalClassField |
709 |
fieldType = self.layer.GetFieldType(field) |
fieldType = self.layer.GetFieldType(field) |
710 |
|
|
862 |
self.haveApplied = False |
self.haveApplied = False |
863 |
|
|
864 |
def unsubscribe_messages(self): |
def unsubscribe_messages(self): |
865 |
|
self.parent.Unsubscribe(MAP_REPLACED, self.map_replaced) |
866 |
self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
867 |
self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED, |
self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED, |
868 |
self.layer_shapestore_replaced) |
self.layer_shapestore_replaced) |
872 |
self.Close() |
self.Close() |
873 |
|
|
874 |
def layer_shapestore_replaced(self, *args): |
def layer_shapestore_replaced(self, *args): |
875 |
|
"""Subscribed to the map's LAYER_SHAPESTORE_REPLACED message. |
876 |
|
|
877 |
|
Close self. |
878 |
|
""" |
879 |
|
self.Close() |
880 |
|
|
881 |
|
def map_replaced(self, *args): |
882 |
|
"""Subscribed to the mainwindow's MAP_REPLACED message. Close self.""" |
883 |
self.Close() |
self.Close() |
884 |
|
|
885 |
def EditSymbol(self, row): |
def EditSymbol(self, row): |
902 |
self.fields.SetClientData(self.__cur_field, clazz) |
self.fields.SetClientData(self.__cur_field, clazz) |
903 |
self.classGrid.GetTable().SetClassification(clazz) |
self.classGrid.GetTable().SetClassification(clazz) |
904 |
|
|
905 |
def __BuildClassification(self, fieldIndex, copyClass = False): |
def __BuildClassification(self, fieldIndex, copyClass=False, force=False): |
906 |
|
|
907 |
# numRows = self.classGrid.GetNumberRows() |
# numRows = self.classGrid.GetNumberRows() |
908 |
# assert numRows > 0 # there should always be a default row |
# assert numRows > 0 # there should always be a default row |
914 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
915 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldType = self.layer.GetFieldType(fieldName) |
916 |
|
|
917 |
clazz = self.classGrid.GetTable().GetClassification() |
clazz = self.fields.GetClientData(fieldIndex) |
918 |
|
if clazz is None or self.classGrid.GetTable().IsModified() or force: |
919 |
if copyClass: |
clazz = self.classGrid.GetTable().GetClassification() |
920 |
clazz = copy.deepcopy(clazz) |
if copyClass: |
921 |
|
clazz = copy.deepcopy(clazz) |
922 |
|
|
923 |
return clazz |
return clazz, fieldName |
924 |
|
|
925 |
def __SetGridTable(self, fieldIndex, group = None): |
def __SetGridTable(self, fieldIndex, group = None): |
926 |
|
|
957 |
assert oldIndex >= -1 |
assert oldIndex >= -1 |
958 |
|
|
959 |
if oldIndex != -1: |
if oldIndex != -1: |
960 |
clazz = self.__BuildClassification(oldIndex) |
clazz, name = self.__BuildClassification(oldIndex, force = True) |
961 |
self.fields.SetClientData(oldIndex, clazz) |
self.fields.SetClientData(oldIndex, clazz) |
962 |
|
|
963 |
self.__SetGridTable(newIndex, group) |
self.__SetGridTable(newIndex, group) |
996 |
# to begin with or it has been modified |
# to begin with or it has been modified |
997 |
# |
# |
998 |
self.classGrid.SaveEditControlValue() |
self.classGrid.SaveEditControlValue() |
999 |
if clazz is None or self.classGrid.GetTable().IsModified(): |
clazz, name = self.__BuildClassification(self.__cur_field, True) |
|
clazz = self.__BuildClassification(self.__cur_field, True) |
|
1000 |
|
|
1001 |
self.layer.SetClassificationField( |
self.layer.SetClassificationColumn(name) |
|
self.fields.GetString(self.__cur_field)) |
|
1002 |
self.layer.SetClassification(clazz) |
self.layer.SetClassification(clazz) |
1003 |
|
|
1004 |
self.haveApplied = True |
self.haveApplied = True |
1022 |
def _OnRevert(self, event): |
def _OnRevert(self, event): |
1023 |
"""The layer's current classification stays the same.""" |
"""The layer's current classification stays the same.""" |
1024 |
if self.haveApplied: |
if self.haveApplied: |
1025 |
self.layer.SetClassificationField(self.originalClassField) |
self.layer.SetClassificationColumn(self.originalClassField) |
1026 |
self.layer.SetClassification(self.originalClass) |
self.layer.SetClassification(self.originalClass) |
1027 |
|
|
1028 |
#self.Close() |
#self.Close() |