31 |
|
|
32 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
33 |
|
|
|
# widget id's |
|
|
ID_PROPERTY_SELECT = 4010 |
|
34 |
ID_CLASS_TABLE = 40011 |
ID_CLASS_TABLE = 40011 |
35 |
|
|
36 |
|
|
85 |
|
|
86 |
table = self.GetTable() |
table = self.GetTable() |
87 |
if table is None: |
if table is None: |
88 |
w = self.GetDefaultColSize() * 3 + self.GetDefaultRowLabelSize() |
w = self.GetDefaultColSize() * NUM_COLS \ |
89 |
h = self.GetDefaultRowSize() * 4 + self.GetDefaultColLabelSize() |
+ self.GetDefaultRowLabelSize() |
90 |
|
h = self.GetDefaultRowSize() * 4 \ |
91 |
|
+ self.GetDefaultColLabelSize() |
92 |
|
|
93 |
self.SetDimensions(-1, -1, w, h) |
self.SetDimensions(-1, -1, w, h) |
94 |
self.SetSizeHints(w, h, -1, -1) |
self.SetSizeHints(w, h, -1, -1) |
95 |
table = ClassTable(self) |
table = ClassTable(self) |
398 |
if isinstance(group, ClassGroupMap): return _("Map") |
if isinstance(group, ClassGroupMap): return _("Map") |
399 |
|
|
400 |
assert False # shouldn't get here |
assert False # shouldn't get here |
401 |
return _("") |
return "" |
402 |
|
|
403 |
def GetNumberRows(self): |
def GetNumberRows(self): |
404 |
"""Return the number of rows.""" |
"""Return the number of rows.""" |
478 |
elif type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE): |
elif type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE): |
479 |
|
|
480 |
if type == FIELDTYPE_INT: |
if type == FIELDTYPE_INT: |
481 |
|
# the float call allows the user to enter 1.0 for 1 |
482 |
conv = lambda p: int(float(p)) |
conv = lambda p: int(float(p)) |
483 |
else: |
else: |
484 |
conv = lambda p: p |
conv = lambda p: p |
493 |
# function. |
# function. |
494 |
# |
# |
495 |
try: |
try: |
496 |
return (conv(Str2Num(value)),) |
return (conv(value),) |
497 |
except ValueError: |
except ValueError: |
498 |
i = value.find('-') |
i = value.find('-') |
499 |
if i == 0: |
if i == 0: |
500 |
i = value.find('-', 1) |
i = value.find('-', 1) |
501 |
|
|
502 |
return (conv(Str2Num(value[:i])), conv(Str2Num(value[i+1:]))) |
return (conv(value[:i]), conv(value[i+1:])) |
503 |
|
|
504 |
assert False # shouldn't get here |
assert False # shouldn't get here |
505 |
return (0,) |
return (0,) |
517 |
typeName -- unused, but needed to overload wxPyGridTableBase |
typeName -- unused, but needed to overload wxPyGridTableBase |
518 |
""" |
""" |
519 |
|
|
520 |
assert col >= 0 and col < self.GetNumberCols() |
assert 0 <= col < self.GetNumberCols() |
521 |
assert row >= 0 and row < self.GetNumberRows() |
assert 0 <= row < self.GetNumberRows() |
522 |
|
|
523 |
if row == 0: |
if row == 0: |
524 |
group = self.clazz.GetDefaultGroup() |
group = self.clazz.GetDefaultGroup() |
559 |
# |
# |
560 |
if len(dataInfo) == 1: |
if len(dataInfo) == 1: |
561 |
if not isinstance(group, ClassGroupSingleton): |
if not isinstance(group, ClassGroupSingleton): |
562 |
ngroup = ClassGroupSingleton(prop = props) |
ngroup = ClassGroupSingleton(props = props) |
563 |
changed = True |
changed = True |
564 |
ngroup.SetValue(dataInfo[0]) |
ngroup.SetValue(dataInfo[0]) |
565 |
elif len(dataInfo) == 2: |
elif len(dataInfo) == 2: |
566 |
if not isinstance(group, ClassGroupRange): |
if not isinstance(group, ClassGroupRange): |
567 |
ngroup = ClassGroupRange(prop = props) |
ngroup = ClassGroupRange(props = props) |
568 |
changed = True |
changed = True |
569 |
ngroup.SetRange(dataInfo[0], dataInfo[1]) |
ngroup.SetRange(dataInfo[0], dataInfo[1]) |
570 |
else: |
else: |
651 |
self.__NotifyRowChanges(old_len, self.GetNumberRows()) |
self.__NotifyRowChanges(old_len, self.GetNumberRows()) |
652 |
|
|
653 |
|
|
654 |
ID_CLASSIFY_OK = 4001 |
ID_PROPERTY_OK = 4001 |
655 |
ID_CLASSIFY_REVERT = 4002 |
ID_PROPERTY_REVERT = 4002 |
656 |
ID_CLASSIFY_ADD = 4003 |
ID_PROPERTY_ADD = 4003 |
657 |
ID_CLASSIFY_GENCLASS = 4004 |
ID_PROPERTY_GENCLASS = 4004 |
658 |
ID_CLASSIFY_REMOVE = 4005 |
ID_PROPERTY_REMOVE = 4005 |
659 |
ID_CLASSIFY_MOVEUP = 4006 |
ID_PROPERTY_MOVEUP = 4006 |
660 |
ID_CLASSIFY_MOVEDOWN = 4007 |
ID_PROPERTY_MOVEDOWN = 4007 |
661 |
ID_CLASSIFY_TRY = 4008 |
ID_PROPERTY_TRY = 4008 |
662 |
ID_CLASSIFY_EDITSYM = 4009 |
ID_PROPERTY_EDITSYM = 4009 |
663 |
ID_CLASSIFY_CLOSE = 4010 |
ID_PROPERTY_CLOSE = 4010 |
664 |
|
ID_PROPERTY_SELECT = 4011 |
665 |
|
ID_PROPERTY_TITLE = 4012 |
666 |
|
ID_PROPERTY_FIELDTEXT = 4013 |
667 |
|
|
668 |
BTN_ADD = 0 |
BTN_ADD = 0 |
669 |
BTN_EDIT = 1 |
BTN_EDIT = 1 |
672 |
BTN_DOWN = 4 |
BTN_DOWN = 4 |
673 |
BTN_RM = 5 |
BTN_RM = 5 |
674 |
|
|
675 |
|
EB_LAYER_TITLE = 0 |
676 |
|
EB_SELECT_FIELD = 1 |
677 |
|
EB_GEN_CLASS = 2 |
678 |
|
|
679 |
class Classifier(NonModalDialog): |
class Classifier(NonModalDialog): |
680 |
|
|
681 |
type2string = {None: _("None"), |
type2string = {None: _("None"), |
684 |
FIELDTYPE_DOUBLE: _("Decimal")} |
FIELDTYPE_DOUBLE: _("Decimal")} |
685 |
|
|
686 |
def __init__(self, parent, name, layer, group = None): |
def __init__(self, parent, name, layer, group = None): |
687 |
NonModalDialog.__init__(self, parent, name, |
NonModalDialog.__init__(self, parent, name, "") |
|
_("Classifier: %s") % layer.Title()) |
|
688 |
|
|
689 |
panel = wxPanel(self, -1, size=(100, 100)) |
self.__SetTitle(layer.Title()) |
690 |
|
|
691 |
self.layer = layer |
self.layer = layer |
692 |
|
|
697 |
self.genDlg = None |
self.genDlg = None |
698 |
|
|
699 |
topBox = wxBoxSizer(wxVERTICAL) |
topBox = wxBoxSizer(wxVERTICAL) |
700 |
|
|
701 |
|
panel = wxPanel(self, -1, size=(100, 100)) |
702 |
|
|
703 |
panelBox = wxBoxSizer(wxVERTICAL) |
panelBox = wxBoxSizer(wxVERTICAL) |
704 |
|
|
705 |
#panelBox.Add(wxStaticText(panel, -1, _("Layer: %s") % layer.Title()), |
sizer = wxBoxSizer(wxHORIZONTAL) |
706 |
#0, wxALIGN_LEFT | wxALL, 4) |
sizer.Add(wxStaticText(panel, -1, _("Title: ")), |
707 |
|
0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 4) |
708 |
|
sizer.Add(wxTextCtrl(panel, ID_PROPERTY_TITLE, layer.Title()), |
709 |
|
1, wxGROW | wxALL, 4) |
710 |
|
EVT_TEXT(self, ID_PROPERTY_TITLE, self._OnTitleChanged) |
711 |
|
|
712 |
|
panelBox.Add(sizer, 0, wxGROW, 4) |
713 |
|
|
714 |
panelBox.Add(wxStaticText(panel, -1, |
panelBox.Add(wxStaticText(panel, -1, |
715 |
_("Layer Type: %s") % layer.ShapeType()), |
_("Type: %s") % layer.ShapeType()), |
716 |
0, wxALIGN_LEFT | wxALL, 4) |
0, wxALIGN_LEFT | wxALL, 4) |
717 |
|
|
718 |
|
|
719 |
|
##################### |
720 |
|
|
721 |
|
#panelBox = wxBoxSizer(wxVERTICAL) |
722 |
|
classBox = wxStaticBoxSizer( |
723 |
|
wxStaticBox(panel, -1, _("Classification")), wxVERTICAL) |
724 |
|
|
725 |
|
|
726 |
# |
# |
727 |
# make field combo box |
# make field choice box |
728 |
# |
# |
729 |
self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "", |
self.fields = wxChoice(panel, ID_PROPERTY_SELECT,) |
730 |
style = wxCB_READONLY) |
#self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "", |
731 |
|
# style = wxCB_READONLY) |
732 |
|
|
733 |
self.num_cols = layer.table.field_count() |
self.num_cols = layer.table.field_count() |
734 |
# just assume the first field in case one hasn't been |
# just assume the first field in case one hasn't been |
736 |
self.__cur_field = 0 |
self.__cur_field = 0 |
737 |
|
|
738 |
self.fields.Append("<None>") |
self.fields.Append("<None>") |
739 |
self.fields.SetClientData(0, None) |
|
740 |
|
if self.originalClass.GetFieldType() is None: |
741 |
|
self.fields.SetClientData(0, copy.deepcopy(self.originalClass)) |
742 |
|
else: |
743 |
|
self.fields.SetClientData(0, None) |
744 |
|
|
745 |
for i in range(self.num_cols): |
for i in range(self.num_cols): |
746 |
type, name, len, decc = layer.table.field_info(i) |
type, name, len, decc = layer.table.field_info(i) |
756 |
|
|
757 |
########### |
########### |
758 |
|
|
|
self.fieldTypeText = wxStaticText(panel, -1, "") |
|
|
panelBox.Add(self.fieldTypeText, 0, |
|
|
wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4) |
|
759 |
|
|
760 |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
761 |
propertyBox.Add(wxStaticText(panel, -1, _("Field: ")), |
sizer.Add(wxStaticText(panel, ID_PROPERTY_FIELDTEXT, _("Field: ")), |
762 |
0, wxALIGN_LEFT | wxALL, 4) |
0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4) |
763 |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
sizer.Add(self.fields, 1, wxGROW | wxALL, 4) |
764 |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
EVT_CHOICE(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
765 |
|
#EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
766 |
|
|
767 |
panelBox.Add(propertyBox, 0, wxGROW, 4) |
classBox.Add(sizer, 0, wxGROW, 4) |
768 |
|
|
769 |
|
self.fieldTypeText = wxStaticText(panel, -1, "") |
770 |
|
classBox.Add(self.fieldTypeText, 0, |
771 |
|
wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4) |
772 |
|
|
773 |
|
|
774 |
# |
# |
781 |
# |
# |
782 |
# Control buttons: |
# Control buttons: |
783 |
# |
# |
|
self.controlButtons = [] |
|
|
|
|
784 |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
785 |
|
|
786 |
button = wxButton(panel, ID_CLASSIFY_GENCLASS, _("Generate Class")) |
button = wxButton(panel, ID_PROPERTY_GENCLASS, _("Generate Class")) |
787 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
self.controlButtons.append(button) |
|
788 |
|
|
789 |
button = wxButton(panel, ID_CLASSIFY_ADD, _("Add")) |
button = wxButton(panel, ID_PROPERTY_ADD, _("Add")) |
790 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
self.controlButtons.append(button) |
|
791 |
|
|
792 |
button = wxButton(panel, ID_CLASSIFY_MOVEUP, _("Move Up")) |
button = wxButton(panel, ID_PROPERTY_MOVEUP, _("Move Up")) |
793 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
self.controlButtons.append(button) |
|
794 |
|
|
795 |
button = wxButton(panel, ID_CLASSIFY_MOVEDOWN, _("Move Down")) |
button = wxButton(panel, ID_PROPERTY_MOVEDOWN, _("Move Down")) |
796 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
self.controlButtons.append(button) |
|
797 |
|
|
798 |
button = wxButton(panel, ID_CLASSIFY_EDITSYM, _("Edit Symbol")) |
button = wxButton(panel, ID_PROPERTY_EDITSYM, _("Edit Symbol")) |
799 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
self.controlButtons.append(button) |
|
800 |
|
|
801 |
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
802 |
|
|
803 |
button = wxButton(panel, ID_CLASSIFY_REMOVE, _("Remove")) |
button = wxButton(panel, ID_PROPERTY_REMOVE, _("Remove")) |
804 |
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
|
self.controlButtons.append(button) |
|
805 |
|
|
806 |
|
|
807 |
########### |
########### |
810 |
# |
# |
811 |
|
|
812 |
self.classGrid = ClassGrid(panel, self) |
self.classGrid = ClassGrid(panel, self) |
|
# self.classGrid = wxGrid(panel, -1) |
|
|
# self.classGrid.SetDefaultRenderer(wxGridCellBoolRenderer()) |
|
|
# self.classGrid.SetDefaultEditor(wxGridCellBoolEditor()) |
|
|
#self.classGrid.CreateGrid(5, 5) |
|
|
#self.classGrid.SetCellEditor(0, 0, wxGridCellBoolEditor()) |
|
|
#self.classGrid.SetCellRenderer(0, 0, wxGridCellBoolRenderer()) |
|
|
#print self.classGrid.GetCellEditor(0, 0) |
|
|
#print self.classGrid.GetCellRenderer(0, 0) |
|
|
#self.classGrid = ClassGrid(panel, self) |
|
|
|
|
|
# need these |
|
|
self.__SetGridTable(self.__cur_field, group) |
|
|
self.fields.SetSelection(self.__cur_field) |
|
|
#self.classGrid.SetCellEditor(0, 0, wxGridCellBoolEditor()) |
|
|
#self.classGrid.SetCellRenderer(0, 0, wxGridCellBoolRenderer()) |
|
813 |
|
|
814 |
# calling __SelectField after creating the classGrid fills in the |
# calling __SelectField after creating the classGrid fills in the |
815 |
# grid with the correct information |
# grid with the correct information |
816 |
#self.fields.SetSelection(self.__cur_field) |
self.fields.SetSelection(self.__cur_field) |
817 |
#self.__SelectField(self.__cur_field, group = group) |
self.__SelectField(self.__cur_field, group = group) |
|
|
|
|
#self.classGrid.SelectGroup(group) |
|
818 |
|
|
819 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
820 |
|
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
821 |
|
|
822 |
|
classBox.Add(controlBox, 1, wxGROW, 10) |
823 |
|
panelBox.Add(classBox, 1, wxGROW, 0) |
824 |
|
|
825 |
|
EVT_BUTTON(self, ID_PROPERTY_ADD, self._OnAdd) |
826 |
|
EVT_BUTTON(self, ID_PROPERTY_EDITSYM, self._OnEditSymbol) |
827 |
|
EVT_BUTTON(self, ID_PROPERTY_REMOVE, self._OnRemove) |
828 |
|
EVT_BUTTON(self, ID_PROPERTY_GENCLASS, self._OnGenClass) |
829 |
|
EVT_BUTTON(self, ID_PROPERTY_MOVEUP, self._OnMoveUp) |
830 |
|
EVT_BUTTON(self, ID_PROPERTY_MOVEDOWN, self._OnMoveDown) |
831 |
|
|
832 |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
########### |
|
panelBox.Add(controlBox, 1, wxGROW, 10) |
|
833 |
|
|
834 |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
|
835 |
EVT_BUTTON(self, ID_CLASSIFY_EDITSYM, self._OnEditSymbol) |
panel.SetAutoLayout(True) |
836 |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
panel.SetSizer(panelBox) |
837 |
EVT_BUTTON(self, ID_CLASSIFY_GENCLASS, self._OnGenClass) |
panelBox.SetSizeHints(panel) |
838 |
EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp) |
|
839 |
EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown) |
topBox.Add(panel, 1, wxGROW | wxALL, 4) |
840 |
|
|
841 |
########### |
########### |
842 |
|
|
843 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
844 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_TRY, _("Try")), |
buttonBox.Add(wxButton(self, ID_PROPERTY_TRY, _("Try")), |
845 |
0, wxALL, 4) |
0, wxALL, 4) |
846 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
847 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_REVERT, _("Revert")), |
buttonBox.Add(wxButton(self, ID_PROPERTY_REVERT, _("Revert")), |
848 |
0, wxALL, 4) |
0, wxALL, 4) |
849 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
850 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_OK, _("OK")), |
buttonBox.Add(wxButton(self, ID_PROPERTY_OK, _("OK")), |
851 |
0, wxALL, 4) |
0, wxALL, 4) |
852 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
853 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_CLOSE, _("Close")), |
buttonBox.Add(wxButton(self, ID_PROPERTY_CLOSE, _("Close")), |
854 |
0, wxALL, 4) |
0, wxALL, 4) |
855 |
panelBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
856 |
|
|
857 |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
EVT_BUTTON(self, ID_PROPERTY_OK, self._OnOK) |
858 |
EVT_BUTTON(self, ID_CLASSIFY_TRY, self._OnTry) |
EVT_BUTTON(self, ID_PROPERTY_TRY, self._OnTry) |
859 |
EVT_BUTTON(self, ID_CLASSIFY_CLOSE, self._OnCloseBtn) |
EVT_BUTTON(self, ID_PROPERTY_CLOSE, self._OnCloseBtn) |
860 |
EVT_BUTTON(self, ID_CLASSIFY_REVERT, self._OnRevert) |
EVT_BUTTON(self, ID_PROPERTY_REVERT, self._OnRevert) |
861 |
|
|
862 |
########### |
########### |
863 |
|
|
864 |
|
topBox.SetSizeHints(self) |
|
panel.SetAutoLayout(True) |
|
|
panel.SetSizer(panelBox) |
|
|
panelBox.SetSizeHints(panel) |
|
|
|
|
|
topBox.Add(panel, 1, wxGROW, 0) |
|
|
panelBox.SetSizeHints(self) |
|
865 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
866 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
867 |
|
|
945 |
|
|
946 |
text = Classifier.type2string[fieldType] |
text = Classifier.type2string[fieldType] |
947 |
|
|
948 |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
self.fieldTypeText.SetLabel(_("Data Type: %s") % text) |
949 |
|
|
950 |
def __SelectField(self, newIndex, oldIndex = -1, group = None): |
def __SelectField(self, newIndex, oldIndex = -1, group = None): |
951 |
"""This method assumes that the current selection for the |
"""This method assumes that the current selection for the |
960 |
|
|
961 |
self.__SetGridTable(newIndex, group) |
self.__SetGridTable(newIndex, group) |
962 |
|
|
963 |
enabled = newIndex != 0 |
self.__EnableButtons(EB_SELECT_FIELD, newIndex != 0) |
|
|
|
|
for b in self.controlButtons: |
|
|
b.Enable(enabled) |
|
964 |
|
|
965 |
self.__SetFieldTypeText(newIndex) |
self.__SetFieldTypeText(newIndex) |
966 |
|
|
967 |
|
def __SetTitle(self, title): |
968 |
|
if title != "": |
969 |
|
title = ": " + title |
970 |
|
|
971 |
|
self.SetTitle(_("Layer Properties") + title) |
972 |
|
|
973 |
def _OnEditSymbol(self, event): |
def _OnEditSymbol(self, event): |
974 |
sel = self.classGrid.GetCurrentSelection() |
sel = self.classGrid.GetCurrentSelection() |
1026 |
|
|
1027 |
def _OnGenClass(self, event): |
def _OnGenClass(self, event): |
1028 |
|
|
|
#if self.genDlg is None: |
|
1029 |
self.genDlg = ClassGenDialog(self, self.layer, |
self.genDlg = ClassGenDialog(self, self.layer, |
1030 |
self.fields.GetString(self.__cur_field)) |
self.fields.GetString(self.__cur_field)) |
1031 |
|
|
1032 |
EVT_CLOSE(self.genDlg, self._OnGenDialogClose) |
EVT_CLOSE(self.genDlg, self._OnGenDialogClose) |
1033 |
|
|
1034 |
self.fields.Enable(False) |
self.__EnableButtons(EB_GEN_CLASS, False) |
|
self.controlButtons[BTN_EDIT].Enable(False) |
|
|
self.controlButtons[BTN_GEN].Enable(False) |
|
1035 |
|
|
1036 |
self.genDlg.Show() |
self.genDlg.Show() |
|
#if self.genDlg.ShowModal() == wxID_OK: |
|
|
# clazz = self.genDlg.GetClassification() |
|
|
# self.fields.SetClientData(self.__cur_field, clazz) |
|
|
# self.classGrid.GetTable().SetClassification(clazz) |
|
|
#self.Enable(True) |
|
|
#self.genDlg.Destroy() |
|
1037 |
|
|
1038 |
def _OnGenDialogClose(self, event): |
def _OnGenDialogClose(self, event): |
1039 |
self.genDlg.Destroy() |
self.genDlg.Destroy() |
1040 |
|
self.__EnableButtons(EB_GEN_CLASS, True) |
|
self.fields.Enable(True) |
|
|
self.controlButtons[BTN_EDIT].Enable(True) |
|
|
self.controlButtons[BTN_GEN].Enable(True) |
|
1041 |
|
|
1042 |
def _OnMoveUp(self, event): |
def _OnMoveUp(self, event): |
1043 |
sel = self.classGrid.GetCurrentSelection() |
sel = self.classGrid.GetCurrentSelection() |
1069 |
self.classGrid.SelectRow(i + 1) |
self.classGrid.SelectRow(i + 1) |
1070 |
self.classGrid.MakeCellVisible(i + 1, 0) |
self.classGrid.MakeCellVisible(i + 1, 0) |
1071 |
|
|
1072 |
|
def _OnTitleChanged(self, event): |
1073 |
|
obj = event.GetEventObject() |
1074 |
|
|
1075 |
|
self.layer.SetTitle(obj.GetValue()) |
1076 |
|
self.__SetTitle(self.layer.Title()) |
1077 |
|
|
1078 |
|
self.__EnableButtons(EB_LAYER_TITLE, self.layer.Title() != "") |
1079 |
|
|
1080 |
|
def __EnableButtons(self, case, enable): |
1081 |
|
|
1082 |
|
if case == EB_LAYER_TITLE: |
1083 |
|
list = (ID_PROPERTY_OK, |
1084 |
|
ID_PROPERTY_CLOSE) |
1085 |
|
|
1086 |
|
elif case == EB_SELECT_FIELD: |
1087 |
|
list = (ID_PROPERTY_GENCLASS, |
1088 |
|
ID_PROPERTY_ADD, |
1089 |
|
ID_PROPERTY_MOVEUP, |
1090 |
|
ID_PROPERTY_MOVEDOWN, |
1091 |
|
ID_PROPERTY_EDITSYM, |
1092 |
|
ID_PROPERTY_REMOVE) |
1093 |
|
|
1094 |
|
elif case == EB_GEN_CLASS: |
1095 |
|
list = (ID_PROPERTY_SELECT, |
1096 |
|
ID_PROPERTY_FIELDTEXT, |
1097 |
|
ID_PROPERTY_GENCLASS, |
1098 |
|
ID_PROPERTY_EDITSYM) |
1099 |
|
|
1100 |
|
for id in list: |
1101 |
|
self.FindWindowById(id).Enable(enable) |
1102 |
|
|
1103 |
ID_SELPROP_OK = 4001 |
ID_SELPROP_OK = 4001 |
1104 |
ID_SELPROP_CANCEL = 4002 |
ID_SELPROP_CANCEL = 4002 |