20 |
from Thuban import _ |
from Thuban import _ |
21 |
from Thuban.UI.common import Color2wxColour, wxColour2Color |
from Thuban.UI.common import Color2wxColour, wxColour2Color |
22 |
|
|
23 |
|
from Thuban.Model.messages import MAP_LAYERS_REMOVED, LAYER_SHAPESTORE_REPLACED |
24 |
from Thuban.Model.range import Range |
from Thuban.Model.range import Range |
25 |
from Thuban.Model.classification import \ |
from Thuban.Model.classification import \ |
26 |
Classification, ClassGroupDefault, \ |
Classification, ClassGroupDefault, \ |
678 |
FIELDTYPE_INT: _("Integer"), |
FIELDTYPE_INT: _("Integer"), |
679 |
FIELDTYPE_DOUBLE: _("Decimal")} |
FIELDTYPE_DOUBLE: _("Decimal")} |
680 |
|
|
681 |
def __init__(self, parent, name, layer, group = None): |
def __init__(self, parent, name, map, layer, group = None): |
682 |
NonModalNonParentDialog.__init__(self, parent, name, "") |
NonModalNonParentDialog.__init__(self, parent, name, "") |
683 |
|
|
684 |
self.__SetTitle(layer.Title()) |
self.__SetTitle(layer.Title()) |
685 |
|
|
686 |
self.layer = layer |
self.layer = layer |
687 |
|
self.map = map |
688 |
|
|
689 |
|
self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
690 |
|
self.layer.Subscribe(LAYER_SHAPESTORE_REPLACED, |
691 |
|
self.layer_shapestore_replaced) |
692 |
|
|
693 |
self.genDlg = None |
self.genDlg = None |
694 |
|
|
706 |
field = self.originalClass.GetField() |
field = self.originalClass.GetField() |
707 |
fieldType = self.originalClass.GetFieldType() |
fieldType = self.originalClass.GetFieldType() |
708 |
|
|
709 |
|
table = layer.ShapeStore().Table() |
710 |
# |
# |
711 |
# make field choice box |
# make field choice box |
712 |
# |
# |
713 |
self.fields = wxChoice(panel, ID_PROPERTY_SELECT,) |
self.fields = wxChoice(panel, ID_PROPERTY_SELECT,) |
714 |
|
|
715 |
self.num_cols = layer.table.NumColumns() |
self.num_cols = table.NumColumns() |
716 |
# just assume the first field in case one hasn't been |
# just assume the first field in case one hasn't been |
717 |
# specified in the file. |
# specified in the file. |
718 |
self.__cur_field = 0 |
self.__cur_field = 0 |
725 |
self.fields.SetClientData(0, None) |
self.fields.SetClientData(0, None) |
726 |
|
|
727 |
for i in range(self.num_cols): |
for i in range(self.num_cols): |
728 |
name = layer.table.Column(i).name |
name = table.Column(i).name |
729 |
self.fields.Append(name) |
self.fields.Append(name) |
730 |
|
|
731 |
if name == field: |
if name == field: |
859 |
text_title.SetFocus() |
text_title.SetFocus() |
860 |
self.haveApplied = False |
self.haveApplied = False |
861 |
|
|
862 |
|
def unsubscribe_messages(self): |
863 |
|
self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
864 |
|
self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED, |
865 |
|
self.layer_shapestore_replaced) |
866 |
|
|
867 |
|
def map_layers_removed(self, map): |
868 |
|
if self.layer not in self.map.Layers(): |
869 |
|
self.Close() |
870 |
|
|
871 |
|
def layer_shapestore_replaced(self, *args): |
872 |
|
self.Close() |
873 |
|
|
874 |
def EditSymbol(self, row): |
def EditSymbol(self, row): |
875 |
table = self.classGrid.GetTable() |
table = self.classGrid.GetTable() |
876 |
prop = table.GetValueAsCustom(row, COL_SYMBOL, None) |
prop = table.GetValueAsCustom(row, COL_SYMBOL, None) |
877 |
|
|
878 |
# get a new ClassGroupProperties object and copy the |
# get a new ClassGroupProperties object and copy the |
879 |
# values over to our current object |
# values over to our current object |
880 |
propDlg = SelectPropertiesDialog(NULL, prop, self.layer.ShapeType()) |
propDlg = SelectPropertiesDialog(self, prop, self.layer.ShapeType()) |
881 |
|
|
882 |
self.Enable(False) |
self.Enable(False) |
883 |
if propDlg.ShowModal() == wxID_OK: |
if propDlg.ShowModal() == wxID_OK: |
961 |
|
|
962 |
self.__SetGridTable(newIndex, group) |
self.__SetGridTable(newIndex, group) |
963 |
|
|
964 |
self.__EnableButtons(EB_SELECT_FIELD, newIndex != 0) |
self.__EnableButtons(EB_SELECT_FIELD) |
965 |
|
|
966 |
self.__SetFieldTypeText(newIndex) |
self.__SetFieldTypeText(newIndex) |
967 |
|
|
1007 |
self.Close() |
self.Close() |
1008 |
|
|
1009 |
def OnClose(self, event): |
def OnClose(self, event): |
1010 |
|
self.unsubscribe_messages() |
1011 |
NonModalNonParentDialog.OnClose(self, event) |
NonModalNonParentDialog.OnClose(self, event) |
1012 |
|
|
1013 |
def _OnCloseBtn(self, event): |
def _OnCloseBtn(self, event): |
1038 |
|
|
1039 |
EVT_CLOSE(self.genDlg, self._OnGenDialogClose) |
EVT_CLOSE(self.genDlg, self._OnGenDialogClose) |
1040 |
|
|
1041 |
self.__EnableButtons(EB_GEN_CLASS, False) |
self.__EnableButtons(EB_GEN_CLASS) |
1042 |
|
|
1043 |
self.genDlg.Show() |
self.genDlg.Show() |
1044 |
|
|
1045 |
def _OnGenDialogClose(self, event): |
def _OnGenDialogClose(self, event): |
1046 |
self.genDlg.Destroy() |
self.genDlg.Destroy() |
1047 |
self.__EnableButtons(EB_GEN_CLASS, True) |
self.genDlg = None |
1048 |
|
self.__EnableButtons(EB_GEN_CLASS) |
1049 |
|
|
1050 |
def _OnMoveUp(self, event): |
def _OnMoveUp(self, event): |
1051 |
sel = self.classGrid.GetCurrentSelection() |
sel = self.classGrid.GetCurrentSelection() |
1083 |
self.layer.SetTitle(obj.GetValue()) |
self.layer.SetTitle(obj.GetValue()) |
1084 |
self.__SetTitle(self.layer.Title()) |
self.__SetTitle(self.layer.Title()) |
1085 |
|
|
1086 |
self.__EnableButtons(EB_LAYER_TITLE, self.layer.Title() != "") |
self.__EnableButtons(EB_LAYER_TITLE) |
1087 |
|
|
1088 |
def __EnableButtons(self, case, enable): |
def __EnableButtons(self, case): |
1089 |
|
|
1090 |
|
list = {wxID_OK : True, |
1091 |
|
wxID_CANCEL : True, |
1092 |
|
ID_PROPERTY_ADD : True, |
1093 |
|
ID_PROPERTY_MOVEUP : True, |
1094 |
|
ID_PROPERTY_MOVEDOWN : True, |
1095 |
|
ID_PROPERTY_REMOVE : True, |
1096 |
|
ID_PROPERTY_SELECT : True, |
1097 |
|
ID_PROPERTY_FIELDTEXT : True, |
1098 |
|
ID_PROPERTY_GENCLASS : True, |
1099 |
|
ID_PROPERTY_EDITSYM : True} |
1100 |
|
|
1101 |
if case == EB_LAYER_TITLE: |
if case == EB_LAYER_TITLE: |
1102 |
list = (wxID_OK, |
if self.layer.Title() == "": |
1103 |
wxID_CANCEL) |
list[wxID_OK] = False |
1104 |
|
list[wxID_CANCEL] = False |
1105 |
|
|
1106 |
elif case == EB_SELECT_FIELD: |
elif case == EB_SELECT_FIELD: |
1107 |
list = (ID_PROPERTY_GENCLASS, |
if self.fields.GetSelection() == 0: |
1108 |
ID_PROPERTY_ADD, |
list[ID_PROPERTY_GENCLASS] = False |
1109 |
ID_PROPERTY_MOVEUP, |
list[ID_PROPERTY_ADD] = False |
1110 |
ID_PROPERTY_MOVEDOWN, |
list[ID_PROPERTY_MOVEUP] = False |
1111 |
ID_PROPERTY_EDITSYM, |
list[ID_PROPERTY_MOVEDOWN] = False |
1112 |
ID_PROPERTY_REMOVE) |
list[ID_PROPERTY_REMOVE] = False |
1113 |
|
|
1114 |
elif case == EB_GEN_CLASS: |
elif case == EB_GEN_CLASS: |
1115 |
list = (ID_PROPERTY_SELECT, |
if self.genDlg is not None: |
1116 |
ID_PROPERTY_FIELDTEXT, |
list[ID_PROPERTY_SELECT] = False |
1117 |
ID_PROPERTY_GENCLASS, |
list[ID_PROPERTY_FIELDTEXT] = False |
1118 |
ID_PROPERTY_EDITSYM) |
list[ID_PROPERTY_GENCLASS] = False |
1119 |
|
|
1120 |
for id in list: |
for id, enable in list.items(): |
1121 |
self.FindWindowById(id).Enable(enable) |
win = self.FindWindowById(id) |
1122 |
|
if win: |
1123 |
|
win.Enable(enable) |
1124 |
|
|
1125 |
ID_SELPROP_SPINCTRL = 4002 |
ID_SELPROP_SPINCTRL = 4002 |
1126 |
ID_SELPROP_PREVIEW = 4003 |
ID_SELPROP_PREVIEW = 4003 |
1386 |
|
|
1387 |
wxWindow.__init__(self, parent, id, size = size, style = style) |
wxWindow.__init__(self, parent, id, size = size, style = style) |
1388 |
|
|
1389 |
|
self.parent = parent |
1390 |
|
|
1391 |
self.SetProperties(props) |
self.SetProperties(props) |
1392 |
self.SetShapeType(shapeType) |
self.SetShapeType(shapeType) |
1393 |
self.AllowEdit(True) |
self.AllowEdit(True) |
1431 |
def DoEdit(self): |
def DoEdit(self): |
1432 |
if not self.allowEdit: return |
if not self.allowEdit: return |
1433 |
|
|
1434 |
propDlg = SelectPropertiesDialog(NULL, |
propDlg = SelectPropertiesDialog(self.parent, |
1435 |
self.GetProperties(), |
self.GetProperties(), |
1436 |
self.GetShapeType()) |
self.GetShapeType()) |
1437 |
|
|