18 |
from wxPython.grid import * |
from wxPython.grid import * |
19 |
|
|
20 |
from Thuban import _ |
from Thuban import _ |
|
from Thuban.common import * |
|
21 |
from Thuban.UI.common import * |
from Thuban.UI.common import * |
22 |
|
|
23 |
from Thuban.Model.classification import * |
from Thuban.Model.classification import * |
30 |
|
|
31 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
32 |
|
|
|
# widget id's |
|
|
ID_PROPERTY_SELECT = 4010 |
|
33 |
ID_CLASS_TABLE = 40011 |
ID_CLASS_TABLE = 40011 |
34 |
|
|
35 |
|
|
62 |
use for display. |
use for display. |
63 |
""" |
""" |
64 |
|
|
65 |
wxGrid.__init__(self, parent, ID_CLASS_TABLE) |
wxGrid.__init__(self, parent, ID_CLASS_TABLE, style = 0) |
66 |
|
|
67 |
self.classifier = classifier |
self.classifier = classifier |
68 |
|
|
84 |
|
|
85 |
table = self.GetTable() |
table = self.GetTable() |
86 |
if table is None: |
if table is None: |
87 |
w = self.GetDefaultColSize() * 3 + self.GetDefaultRowLabelSize() |
w = self.GetDefaultColSize() * NUM_COLS \ |
88 |
h = self.GetDefaultRowSize() * 4 + self.GetDefaultColLabelSize() |
+ self.GetDefaultRowLabelSize() |
89 |
|
h = self.GetDefaultRowSize() * 4 \ |
90 |
|
+ self.GetDefaultColLabelSize() |
91 |
|
|
92 |
self.SetDimensions(-1, -1, w, h) |
self.SetDimensions(-1, -1, w, h) |
93 |
self.SetSizeHints(w, h, -1, -1) |
self.SetSizeHints(w, h, -1, -1) |
94 |
table = ClassTable(self) |
table = ClassTable(self) |
397 |
if isinstance(group, ClassGroupMap): return _("Map") |
if isinstance(group, ClassGroupMap): return _("Map") |
398 |
|
|
399 |
assert False # shouldn't get here |
assert False # shouldn't get here |
400 |
return _("") |
return "" |
401 |
|
|
402 |
def GetNumberRows(self): |
def GetNumberRows(self): |
403 |
"""Return the number of rows.""" |
"""Return the number of rows.""" |
477 |
elif type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE): |
elif type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE): |
478 |
|
|
479 |
if type == FIELDTYPE_INT: |
if type == FIELDTYPE_INT: |
480 |
|
# the float call allows the user to enter 1.0 for 1 |
481 |
conv = lambda p: int(float(p)) |
conv = lambda p: int(float(p)) |
482 |
else: |
else: |
483 |
conv = lambda p: p |
conv = lambda p: p |
492 |
# function. |
# function. |
493 |
# |
# |
494 |
try: |
try: |
495 |
return (conv(Str2Num(value)),) |
return (conv(value),) |
496 |
except ValueError: |
except ValueError: |
497 |
i = value.find('-') |
i = value.find('-') |
498 |
if i == 0: |
if i == 0: |
499 |
i = value.find('-', 1) |
i = value.find('-', 1) |
500 |
|
|
501 |
return (conv(Str2Num(value[:i])), conv(Str2Num(value[i+1:]))) |
return (conv(value[:i]), conv(value[i+1:])) |
502 |
|
|
503 |
assert False # shouldn't get here |
assert False # shouldn't get here |
504 |
return (0,) |
return (0,) |
516 |
typeName -- unused, but needed to overload wxPyGridTableBase |
typeName -- unused, but needed to overload wxPyGridTableBase |
517 |
""" |
""" |
518 |
|
|
519 |
assert col >= 0 and col < self.GetNumberCols() |
assert 0 <= col < self.GetNumberCols() |
520 |
assert row >= 0 and row < self.GetNumberRows() |
assert 0 <= row < self.GetNumberRows() |
521 |
|
|
522 |
if row == 0: |
if row == 0: |
523 |
group = self.clazz.GetDefaultGroup() |
group = self.clazz.GetDefaultGroup() |
558 |
# |
# |
559 |
if len(dataInfo) == 1: |
if len(dataInfo) == 1: |
560 |
if not isinstance(group, ClassGroupSingleton): |
if not isinstance(group, ClassGroupSingleton): |
561 |
ngroup = ClassGroupSingleton(prop = props) |
ngroup = ClassGroupSingleton(props = props) |
562 |
changed = True |
changed = True |
563 |
ngroup.SetValue(dataInfo[0]) |
ngroup.SetValue(dataInfo[0]) |
564 |
elif len(dataInfo) == 2: |
elif len(dataInfo) == 2: |
565 |
if not isinstance(group, ClassGroupRange): |
if not isinstance(group, ClassGroupRange): |
566 |
ngroup = ClassGroupRange(prop = props) |
ngroup = ClassGroupRange(props = props) |
567 |
changed = True |
changed = True |
568 |
ngroup.SetRange(dataInfo[0], dataInfo[1]) |
ngroup.SetRange(dataInfo[0], dataInfo[1]) |
569 |
else: |
else: |
650 |
self.__NotifyRowChanges(old_len, self.GetNumberRows()) |
self.__NotifyRowChanges(old_len, self.GetNumberRows()) |
651 |
|
|
652 |
|
|
653 |
ID_CLASSIFY_OK = 4001 |
ID_PROPERTY_REVERT = 4002 |
654 |
ID_CLASSIFY_REVERT = 4002 |
ID_PROPERTY_ADD = 4003 |
655 |
ID_CLASSIFY_ADD = 4003 |
ID_PROPERTY_GENCLASS = 4004 |
656 |
ID_CLASSIFY_GENCLASS = 4004 |
ID_PROPERTY_REMOVE = 4005 |
657 |
ID_CLASSIFY_REMOVE = 4005 |
ID_PROPERTY_MOVEUP = 4006 |
658 |
ID_CLASSIFY_MOVEUP = 4006 |
ID_PROPERTY_MOVEDOWN = 4007 |
659 |
ID_CLASSIFY_MOVEDOWN = 4007 |
ID_PROPERTY_TRY = 4008 |
660 |
ID_CLASSIFY_TRY = 4008 |
ID_PROPERTY_EDITSYM = 4009 |
661 |
ID_CLASSIFY_EDITSYM = 4009 |
ID_PROPERTY_SELECT = 4011 |
662 |
ID_CLASSIFY_CLOSE = 4010 |
ID_PROPERTY_TITLE = 4012 |
663 |
|
ID_PROPERTY_FIELDTEXT = 4013 |
664 |
|
|
665 |
BTN_ADD = 0 |
BTN_ADD = 0 |
666 |
BTN_EDIT = 1 |
BTN_EDIT = 1 |
669 |
BTN_DOWN = 4 |
BTN_DOWN = 4 |
670 |
BTN_RM = 5 |
BTN_RM = 5 |
671 |
|
|
672 |
|
EB_LAYER_TITLE = 0 |
673 |
|
EB_SELECT_FIELD = 1 |
674 |
|
EB_GEN_CLASS = 2 |
675 |
|
|
676 |
class Classifier(NonModalDialog): |
class Classifier(NonModalDialog): |
677 |
|
|
678 |
type2string = {None: _("None"), |
type2string = {None: _("None"), |
681 |
FIELDTYPE_DOUBLE: _("Decimal")} |
FIELDTYPE_DOUBLE: _("Decimal")} |
682 |
|
|
683 |
def __init__(self, parent, name, layer, group = None): |
def __init__(self, parent, name, layer, group = None): |
684 |
NonModalDialog.__init__(self, parent, name, |
NonModalDialog.__init__(self, parent, name, "") |
|
_("Classifier: %s") % layer.Title()) |
|
685 |
|
|
686 |
panel = wxPanel(self, -1, size=(100, 100)) |
self.__SetTitle(layer.Title()) |
687 |
|
|
688 |
self.layer = layer |
self.layer = layer |
689 |
|
|
693 |
|
|
694 |
self.genDlg = None |
self.genDlg = None |
695 |
|
|
696 |
topBox = wxBoxSizer(wxVERTICAL) |
############################ |
697 |
panelBox = wxBoxSizer(wxVERTICAL) |
# Create the controls |
698 |
|
# |
|
#panelBox.Add(wxStaticText(panel, -1, _("Layer: %s") % layer.Title()), |
|
|
#0, wxALIGN_LEFT | wxALL, 4) |
|
|
panelBox.Add(wxStaticText(panel, -1, |
|
|
_("Layer Type: %s") % layer.ShapeType()), |
|
|
0, wxALIGN_LEFT | wxALL, 4) |
|
699 |
|
|
700 |
|
panel = wxPanel(self, -1) |
701 |
|
|
702 |
|
text_title = wxTextCtrl(panel, ID_PROPERTY_TITLE, layer.Title()) |
703 |
# |
# |
704 |
# make field combo box |
# make field choice box |
705 |
# |
# |
706 |
self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "", |
self.fields = wxChoice(panel, ID_PROPERTY_SELECT,) |
|
style = wxCB_READONLY) |
|
707 |
|
|
708 |
self.num_cols = layer.table.field_count() |
self.num_cols = layer.table.NumColumns() |
709 |
# just assume the first field in case one hasn't been |
# just assume the first field in case one hasn't been |
710 |
# specified in the file. |
# specified in the file. |
711 |
self.__cur_field = 0 |
self.__cur_field = 0 |
712 |
|
|
713 |
self.fields.Append("<None>") |
self.fields.Append("<None>") |
714 |
self.fields.SetClientData(0, None) |
|
715 |
|
if self.originalClass.GetFieldType() is None: |
716 |
|
self.fields.SetClientData(0, copy.deepcopy(self.originalClass)) |
717 |
|
else: |
718 |
|
self.fields.SetClientData(0, None) |
719 |
|
|
720 |
for i in range(self.num_cols): |
for i in range(self.num_cols): |
721 |
type, name, len, decc = layer.table.field_info(i) |
name = layer.table.Column(i).name |
722 |
self.fields.Append(name) |
self.fields.Append(name) |
723 |
|
|
724 |
if name == field: |
if name == field: |
729 |
self.fields.SetClientData(i + 1, None) |
self.fields.SetClientData(i + 1, None) |
730 |
|
|
731 |
|
|
|
########### |
|
|
|
|
732 |
self.fieldTypeText = wxStaticText(panel, -1, "") |
self.fieldTypeText = wxStaticText(panel, -1, "") |
|
panelBox.Add(self.fieldTypeText, 0, |
|
|
wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4) |
|
733 |
|
|
734 |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
button_gen = wxButton(panel, ID_PROPERTY_GENCLASS, _("Generate Class")) |
|
propertyBox.Add(wxStaticText(panel, -1, _("Field: ")), |
|
|
0, wxALIGN_LEFT | wxALL, 4) |
|
|
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
|
|
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
|
735 |
|
|
736 |
panelBox.Add(propertyBox, 0, wxGROW, 4) |
button_add = wxButton(panel, ID_PROPERTY_ADD, _("Add")) |
737 |
|
button_moveup = wxButton(panel, ID_PROPERTY_MOVEUP, _("Move Up")) |
738 |
|
button_movedown = wxButton(panel, ID_PROPERTY_MOVEDOWN, _("Move Down")) |
739 |
|
button_edit = wxButton(panel, ID_PROPERTY_EDITSYM, _("Edit Symbol")) |
740 |
|
button_remove = wxButton(panel, ID_PROPERTY_REMOVE, _("Remove")) |
741 |
|
|
742 |
|
|
743 |
# |
button_try = wxButton(panel, ID_PROPERTY_TRY, _("Try")) |
744 |
# Control Box |
button_revert = wxButton(panel, ID_PROPERTY_REVERT, _("Revert")) |
745 |
# |
button_ok = wxButton(panel, wxID_OK, _("OK")) |
746 |
controlBox = wxBoxSizer(wxHORIZONTAL) |
button_ok.SetDefault() |
747 |
|
button_close = wxButton(panel, wxID_CANCEL, _("Close")) |
748 |
|
|
749 |
|
self.classGrid = ClassGrid(panel, self) |
750 |
|
|
751 |
########### |
# calling __SelectField after creating the classGrid fills in the |
752 |
# |
# grid with the correct information |
753 |
# Control buttons: |
self.fields.SetSelection(self.__cur_field) |
754 |
|
self.__SelectField(self.__cur_field, group = group) |
755 |
|
|
756 |
|
############################ |
757 |
|
# Layout the controls |
758 |
# |
# |
|
self.controlButtons = [] |
|
759 |
|
|
760 |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
topBox = wxBoxSizer(wxVERTICAL) |
761 |
|
panelBox = wxBoxSizer(wxVERTICAL) |
762 |
|
|
763 |
button = wxButton(panel, ID_CLASSIFY_GENCLASS, _("Generate Class")) |
sizer = wxBoxSizer(wxHORIZONTAL) |
764 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
sizer.Add(wxStaticText(panel, -1, _("Title: ")), |
765 |
self.controlButtons.append(button) |
0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 4) |
766 |
|
sizer.Add(text_title, 1, wxGROW, 0) |
|
button = wxButton(panel, ID_CLASSIFY_ADD, _("Add")) |
|
|
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
|
self.controlButtons.append(button) |
|
|
|
|
|
button = wxButton(panel, ID_CLASSIFY_MOVEUP, _("Move Up")) |
|
|
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
|
self.controlButtons.append(button) |
|
|
|
|
|
button = wxButton(panel, ID_CLASSIFY_MOVEDOWN, _("Move Down")) |
|
|
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
|
self.controlButtons.append(button) |
|
|
|
|
|
button = wxButton(panel, ID_CLASSIFY_EDITSYM, _("Edit Symbol")) |
|
|
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
|
|
self.controlButtons.append(button) |
|
|
|
|
|
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
|
|
|
|
|
button = wxButton(panel, ID_CLASSIFY_REMOVE, _("Remove")) |
|
|
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
|
|
self.controlButtons.append(button) |
|
767 |
|
|
768 |
|
panelBox.Add(sizer, 0, wxGROW, 4) |
769 |
|
|
770 |
########### |
panelBox.Add(wxStaticText(panel, -1, |
771 |
# |
_("Type: %s") % layer.ShapeType()), |
772 |
# Classification data table |
0, wxALIGN_LEFT | wxALL, 4) |
|
# |
|
773 |
|
|
774 |
self.classGrid = ClassGrid(panel, self) |
classBox = wxStaticBoxSizer( |
775 |
# self.classGrid = wxGrid(panel, -1) |
wxStaticBox(panel, -1, _("Classification")), wxVERTICAL) |
|
# 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) |
|
776 |
|
|
|
# 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()) |
|
777 |
|
|
778 |
# calling __SelectField after creating the classGrid fills in the |
sizer = wxBoxSizer(wxHORIZONTAL) |
779 |
# grid with the correct information |
sizer.Add(wxStaticText(panel, ID_PROPERTY_FIELDTEXT, _("Field: ")), |
780 |
#self.fields.SetSelection(self.__cur_field) |
0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4) |
781 |
#self.__SelectField(self.__cur_field, group = group) |
sizer.Add(self.fields, 1, wxGROW | wxALL, 4) |
782 |
|
|
783 |
#self.classGrid.SelectGroup(group) |
classBox.Add(sizer, 0, wxGROW, 4) |
784 |
|
|
785 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
classBox.Add(self.fieldTypeText, 0, |
786 |
|
wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4) |
787 |
|
|
788 |
|
controlBox = wxBoxSizer(wxHORIZONTAL) |
789 |
|
controlButtonBox = wxBoxSizer(wxVERTICAL) |
790 |
|
|
791 |
|
controlButtonBox.Add(button_gen, 0, wxGROW|wxALL, 4) |
792 |
|
controlButtonBox.Add(button_add, 0, wxGROW|wxALL, 4) |
793 |
|
controlButtonBox.Add(button_moveup, 0, wxGROW|wxALL, 4) |
794 |
|
controlButtonBox.Add(button_movedown, 0, wxGROW|wxALL, 4) |
795 |
|
controlButtonBox.Add(button_edit, 0, wxGROW|wxALL, 4) |
796 |
|
controlButtonBox.Add(60, 20, 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4) |
797 |
|
controlButtonBox.Add(button_remove, 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4) |
798 |
|
|
799 |
|
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
800 |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
|
panelBox.Add(controlBox, 1, wxGROW, 10) |
|
801 |
|
|
802 |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
classBox.Add(controlBox, 1, wxGROW, 10) |
803 |
EVT_BUTTON(self, ID_CLASSIFY_EDITSYM, self._OnEditSymbol) |
panelBox.Add(classBox, 1, wxGROW, 0) |
|
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
|
|
EVT_BUTTON(self, ID_CLASSIFY_GENCLASS, self._OnGenClass) |
|
|
EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp) |
|
|
EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown) |
|
804 |
|
|
|
########### |
|
805 |
|
|
806 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
807 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_TRY, _("Try")), |
buttonBox.Add(button_try, 0, wxALL, 4) |
|
0, wxALL, 4) |
|
808 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
809 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_REVERT, _("Revert")), |
buttonBox.Add(button_revert, 0, wxALL, 4) |
|
0, wxALL, 4) |
|
810 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
811 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_OK, _("OK")), |
buttonBox.Add(button_ok, 0, wxALL, 4) |
|
0, wxALL, 4) |
|
812 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
813 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_CLOSE, _("Close")), |
buttonBox.Add(button_close, 0, wxALL, 4) |
814 |
0, wxALL, 4) |
panelBox.Add(buttonBox, 0, |
815 |
panelBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
|
|
|
|
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
|
|
EVT_BUTTON(self, ID_CLASSIFY_TRY, self._OnTry) |
|
|
EVT_BUTTON(self, ID_CLASSIFY_CLOSE, self._OnCloseBtn) |
|
|
EVT_BUTTON(self, ID_CLASSIFY_REVERT, self._OnRevert) |
|
|
|
|
|
########### |
|
|
|
|
816 |
|
|
817 |
panel.SetAutoLayout(True) |
panel.SetAutoLayout(True) |
818 |
panel.SetSizer(panelBox) |
panel.SetSizer(panelBox) |
819 |
|
panelBox.Fit(panel) |
820 |
panelBox.SetSizeHints(panel) |
panelBox.SetSizeHints(panel) |
821 |
|
|
822 |
topBox.Add(panel, 1, wxGROW, 0) |
topBox.Add(panel, 1, wxGROW | wxALL, 4) |
823 |
panelBox.SetSizeHints(self) |
|
824 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
825 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
826 |
|
topBox.Fit(self) |
827 |
|
topBox.SetSizeHints(self) |
828 |
|
self.Layout() |
829 |
|
|
830 |
|
########### |
831 |
|
|
832 |
|
EVT_CHOICE(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
833 |
|
EVT_TEXT(self, ID_PROPERTY_TITLE, self._OnTitleChanged) |
834 |
|
EVT_BUTTON(self, wxID_OK, self._OnOK) |
835 |
|
EVT_BUTTON(self, ID_PROPERTY_TRY, self._OnTry) |
836 |
|
EVT_BUTTON(self, wxID_CANCEL, self._OnCloseBtn) |
837 |
|
EVT_BUTTON(self, ID_PROPERTY_REVERT, self._OnRevert) |
838 |
|
|
839 |
|
EVT_BUTTON(self, ID_PROPERTY_ADD, self._OnAdd) |
840 |
|
EVT_BUTTON(self, ID_PROPERTY_EDITSYM, self._OnEditSymbol) |
841 |
|
EVT_BUTTON(self, ID_PROPERTY_REMOVE, self._OnRemove) |
842 |
|
EVT_BUTTON(self, ID_PROPERTY_GENCLASS, self._OnGenClass) |
843 |
|
EVT_BUTTON(self, ID_PROPERTY_MOVEUP, self._OnMoveUp) |
844 |
|
EVT_BUTTON(self, ID_PROPERTY_MOVEDOWN, self._OnMoveDown) |
845 |
|
|
|
#self.Fit() |
|
846 |
###################### |
###################### |
847 |
|
|
848 |
|
self.fields.SetFocus() |
849 |
self.haveApplied = False |
self.haveApplied = False |
850 |
|
|
851 |
def EditSymbol(self, row): |
def EditSymbol(self, row): |
923 |
|
|
924 |
text = Classifier.type2string[fieldType] |
text = Classifier.type2string[fieldType] |
925 |
|
|
926 |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
self.fieldTypeText.SetLabel(_("Data Type: %s") % text) |
927 |
|
|
928 |
def __SelectField(self, newIndex, oldIndex = -1, group = None): |
def __SelectField(self, newIndex, oldIndex = -1, group = None): |
929 |
"""This method assumes that the current selection for the |
"""This method assumes that the current selection for the |
938 |
|
|
939 |
self.__SetGridTable(newIndex, group) |
self.__SetGridTable(newIndex, group) |
940 |
|
|
941 |
enabled = newIndex != 0 |
self.__EnableButtons(EB_SELECT_FIELD, newIndex != 0) |
|
|
|
|
for b in self.controlButtons: |
|
|
b.Enable(enabled) |
|
942 |
|
|
943 |
self.__SetFieldTypeText(newIndex) |
self.__SetFieldTypeText(newIndex) |
944 |
|
|
945 |
|
def __SetTitle(self, title): |
946 |
|
if title != "": |
947 |
|
title = ": " + title |
948 |
|
|
949 |
|
self.SetTitle(_("Layer Properties") + title) |
950 |
|
|
951 |
def _OnEditSymbol(self, event): |
def _OnEditSymbol(self, event): |
952 |
sel = self.classGrid.GetCurrentSelection() |
sel = self.classGrid.GetCurrentSelection() |
981 |
self._OnTry(event) |
self._OnTry(event) |
982 |
self.Close() |
self.Close() |
983 |
|
|
984 |
|
def OnClose(self, event): |
985 |
|
NonModalDialog.OnClose(self, event) |
986 |
|
|
987 |
def _OnCloseBtn(self, event): |
def _OnCloseBtn(self, event): |
988 |
"""Close is similar to Cancel except that any changes that were |
"""Close is similar to Cancel except that any changes that were |
989 |
made and applied remain applied, but the currently displayed |
made and applied remain applied, but the currently displayed |
1007 |
|
|
1008 |
def _OnGenClass(self, event): |
def _OnGenClass(self, event): |
1009 |
|
|
|
#if self.genDlg is None: |
|
1010 |
self.genDlg = ClassGenDialog(self, self.layer, |
self.genDlg = ClassGenDialog(self, self.layer, |
1011 |
self.fields.GetString(self.__cur_field)) |
self.fields.GetString(self.__cur_field)) |
1012 |
|
|
1013 |
EVT_CLOSE(self.genDlg, self._OnGenDialogClose) |
EVT_CLOSE(self.genDlg, self._OnGenDialogClose) |
1014 |
|
|
1015 |
self.fields.Enable(False) |
self.__EnableButtons(EB_GEN_CLASS, False) |
|
self.controlButtons[BTN_EDIT].Enable(False) |
|
|
self.controlButtons[BTN_GEN].Enable(False) |
|
1016 |
|
|
1017 |
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() |
|
1018 |
|
|
1019 |
def _OnGenDialogClose(self, event): |
def _OnGenDialogClose(self, event): |
1020 |
self.genDlg.Destroy() |
self.genDlg.Destroy() |
1021 |
|
self.__EnableButtons(EB_GEN_CLASS, True) |
|
self.fields.Enable(True) |
|
|
self.controlButtons[BTN_EDIT].Enable(True) |
|
|
self.controlButtons[BTN_GEN].Enable(True) |
|
1022 |
|
|
1023 |
def _OnMoveUp(self, event): |
def _OnMoveUp(self, event): |
1024 |
sel = self.classGrid.GetCurrentSelection() |
sel = self.classGrid.GetCurrentSelection() |
1050 |
self.classGrid.SelectRow(i + 1) |
self.classGrid.SelectRow(i + 1) |
1051 |
self.classGrid.MakeCellVisible(i + 1, 0) |
self.classGrid.MakeCellVisible(i + 1, 0) |
1052 |
|
|
1053 |
|
def _OnTitleChanged(self, event): |
1054 |
|
obj = event.GetEventObject() |
1055 |
|
|
1056 |
|
self.layer.SetTitle(obj.GetValue()) |
1057 |
|
self.__SetTitle(self.layer.Title()) |
1058 |
|
|
1059 |
|
self.__EnableButtons(EB_LAYER_TITLE, self.layer.Title() != "") |
1060 |
|
|
1061 |
|
def __EnableButtons(self, case, enable): |
1062 |
|
|
1063 |
|
if case == EB_LAYER_TITLE: |
1064 |
|
list = (wxID_OK, |
1065 |
|
wxID_CANCEL) |
1066 |
|
|
1067 |
|
elif case == EB_SELECT_FIELD: |
1068 |
|
list = (ID_PROPERTY_GENCLASS, |
1069 |
|
ID_PROPERTY_ADD, |
1070 |
|
ID_PROPERTY_MOVEUP, |
1071 |
|
ID_PROPERTY_MOVEDOWN, |
1072 |
|
ID_PROPERTY_EDITSYM, |
1073 |
|
ID_PROPERTY_REMOVE) |
1074 |
|
|
1075 |
|
elif case == EB_GEN_CLASS: |
1076 |
|
list = (ID_PROPERTY_SELECT, |
1077 |
|
ID_PROPERTY_FIELDTEXT, |
1078 |
|
ID_PROPERTY_GENCLASS, |
1079 |
|
ID_PROPERTY_EDITSYM) |
1080 |
|
|
1081 |
|
for id in list: |
1082 |
|
self.FindWindowById(id).Enable(enable) |
1083 |
|
|
|
ID_SELPROP_OK = 4001 |
|
|
ID_SELPROP_CANCEL = 4002 |
|
1084 |
ID_SELPROP_SPINCTRL = 4002 |
ID_SELPROP_SPINCTRL = 4002 |
1085 |
ID_SELPROP_PREVIEW = 4003 |
ID_SELPROP_PREVIEW = 4003 |
1086 |
ID_SELPROP_STROKECLR = 4004 |
ID_SELPROP_STROKECLR = 4004 |
1119 |
ctrlBox = wxBoxSizer(wxVERTICAL) |
ctrlBox = wxBoxSizer(wxVERTICAL) |
1120 |
|
|
1121 |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
1122 |
lineColorBox.Add( |
button = wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")) |
1123 |
wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")), |
button.SetFocus() |
1124 |
1, wxALL | wxGROW, 4) |
lineColorBox.Add(button, 1, wxALL | wxGROW, 4) |
1125 |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
1126 |
|
|
1127 |
lineColorBox.Add( |
lineColorBox.Add( |
1167 |
# Control buttons: |
# Control buttons: |
1168 |
# |
# |
1169 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
1170 |
buttonBox.Add(wxButton(self, ID_SELPROP_OK, _("OK")), |
button_ok = wxButton(self, wxID_OK, _("OK")) |
1171 |
0, wxALL, 4) |
button_ok.SetDefault() |
1172 |
buttonBox.Add(wxButton(self, ID_SELPROP_CANCEL, _("Cancel")), |
buttonBox.Add(button_ok, 0, wxALL, 4) |
1173 |
|
buttonBox.Add(wxButton(self, wxID_CANCEL, _("Cancel")), |
1174 |
0, wxALL, 4) |
0, wxALL, 4) |
1175 |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10) |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10) |
1176 |
|
|
1177 |
EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK) |
#EVT_BUTTON(self, wxID_OK, self._OnOK) |
1178 |
EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
#EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
1179 |
|
|
1180 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
1181 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
1182 |
topBox.Fit(self) |
topBox.Fit(self) |
1183 |
topBox.SetSizeHints(self) |
topBox.SetSizeHints(self) |
1184 |
|
|
1185 |
def _OnOK(self, event): |
def OnOK(self, event): |
1186 |
self.EndModal(wxID_OK) |
self.EndModal(wxID_OK) |
1187 |
|
|
1188 |
def _OnCancel(self, event): |
def OnCancel(self, event): |
1189 |
self.EndModal(wxID_CANCEL) |
self.EndModal(wxID_CANCEL) |
1190 |
|
|
1191 |
def _OnSpin(self, event): |
def _OnSpin(self, event): |