70 |
|
|
71 |
#wxGrid.__init__(self, parent, ID_CLASS_TABLE, size = (340, 160)) |
#wxGrid.__init__(self, parent, ID_CLASS_TABLE, size = (340, 160)) |
72 |
wxGrid.__init__(self, parent, ID_CLASS_TABLE) |
wxGrid.__init__(self, parent, ID_CLASS_TABLE) |
73 |
#self.SetTable(ClassTable(fieldData, layer.ShapeType(), self), true) |
#self.SetTable(ClassTable(fieldData, layer.ShapeType(), self), True) |
74 |
|
|
75 |
EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick) |
EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick) |
76 |
EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange) |
EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange) |
85 |
self.shapeType = shapeType |
self.shapeType = shapeType |
86 |
table = self.GetTable() |
table = self.GetTable() |
87 |
if table is None: |
if table is None: |
88 |
self.SetTable(ClassTable(clazz, self.shapeType, self), true) |
w = self.GetDefaultColSize() * 3 + self.GetDefaultRowLabelSize() |
89 |
|
h = self.GetDefaultRowSize() * 4 + self.GetDefaultColLabelSize() |
90 |
|
self.SetDimensions(-1, -1, w, h) |
91 |
|
self.SetSizeHints(w, h, -1, -1) |
92 |
|
self.SetTable(ClassTable(clazz, self.shapeType, self), True) |
93 |
else: |
else: |
94 |
table.Reset(clazz, self.shapeType) |
table.Reset(clazz, self.shapeType) |
95 |
|
|
283 |
|
|
284 |
self.__NotifyRowChanges(old_len, len(self.tdata)) |
self.__NotifyRowChanges(old_len, len(self.tdata)) |
285 |
|
|
|
view = self.GetView() |
|
|
w = view.GetDefaultColSize() * 3 + view.GetDefaultRowLabelSize() |
|
|
h = view.GetDefaultRowSize() * 4 + view.GetDefaultColLabelSize() |
|
|
view.SetDimensions(-1, -1, w, h) |
|
|
view.SetSizeHints(w, h, -1, -1) |
|
286 |
|
|
287 |
self.GetView().EndBatch() |
self.GetView().EndBatch() |
288 |
|
|
583 |
NonModalDialog.__init__(self, parent, interactor, name, |
NonModalDialog.__init__(self, parent, interactor, name, |
584 |
_("Classifier: %s") % layer.Title()) |
_("Classifier: %s") % layer.Title()) |
585 |
|
|
586 |
|
panel = wxPanel(self, -1) |
587 |
|
|
588 |
self.layer = layer |
self.layer = layer |
589 |
|
|
590 |
self.originalClass = self.layer.GetClassification() |
self.originalClass = self.layer.GetClassification() |
593 |
|
|
594 |
topBox = wxBoxSizer(wxVERTICAL) |
topBox = wxBoxSizer(wxVERTICAL) |
595 |
|
|
596 |
#topBox.Add(wxStaticText(self, -1, _("Layer: %s") % layer.Title()), |
#topBox.Add(wxStaticText(panel, -1, _("Layer: %s") % layer.Title()), |
597 |
#0, wxALIGN_LEFT | wxALL, 4) |
#0, wxALIGN_LEFT | wxALL, 4) |
598 |
topBox.Add(wxStaticText(self, -1, |
topBox.Add(wxStaticText(panel, -1, |
599 |
_("Layer Type: %s") % layer.ShapeType()), |
_("Layer Type: %s") % layer.ShapeType()), |
600 |
0, wxALIGN_LEFT | wxALL, 4) |
0, wxALIGN_LEFT | wxALL, 4) |
601 |
|
|
603 |
# |
# |
604 |
# make field combo box |
# make field combo box |
605 |
# |
# |
606 |
self.fields = wxComboBox(self, ID_PROPERTY_SELECT, "", |
self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "", |
607 |
style = wxCB_READONLY) |
style = wxCB_READONLY) |
608 |
|
|
609 |
self.num_cols = layer.table.field_count() |
self.num_cols = layer.table.field_count() |
625 |
self.fields.SetClientData(i + 1, None) |
self.fields.SetClientData(i + 1, None) |
626 |
|
|
627 |
|
|
628 |
# |
########### |
|
# |
|
|
# |
|
|
|
|
|
self.fieldTypeText = wxStaticText(self, -1, "") |
|
|
self.__SetFieldTypeText(self.__cur_field) |
|
629 |
|
|
630 |
topBox.Add(self.fieldTypeText, 0, wxALIGN_LEFT | wxALL, 4) |
self.fieldTypeText = wxStaticText(panel, -1, "") |
631 |
#self.fieldTypeText.SetLabel("asdfadsfs") |
topBox.Add(self.fieldTypeText, 0, wxGROW | wxALIGN_LEFT | wxALL, 4) |
632 |
|
|
633 |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
634 |
propertyBox.Add(wxStaticText(self, -1, _("Field: ")), |
propertyBox.Add(wxStaticText(panel, -1, _("Field: ")), |
635 |
0, wxALIGN_CENTER | wxALL, 4) |
0, wxALIGN_LEFT | wxALL, 4) |
636 |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
637 |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
638 |
|
|
639 |
topBox.Add(propertyBox, 0, wxGROW, 4) |
topBox.Add(propertyBox, 0, wxGROW, 4) |
640 |
|
|
641 |
|
########### |
642 |
# |
# |
643 |
# Classification data table |
# Classification data table |
644 |
# |
# |
650 |
|
|
651 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
652 |
|
|
653 |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
########### |
|
|
|
654 |
# |
# |
655 |
# Control buttons: |
# Control buttons: |
656 |
# |
# |
657 |
self.controlButtons = [] |
self.controlButtons = [] |
658 |
|
|
659 |
button = wxButton(self, ID_CLASSIFY_ADD, _("Add")) |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
660 |
|
|
661 |
|
button = wxButton(panel, ID_CLASSIFY_ADD, _("Add")) |
662 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
663 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
664 |
|
|
665 |
#button = wxButton(self, ID_CLASSIFY_GENRANGE, _("Generate Ranges")) |
#button = wxButton(panel, ID_CLASSIFY_GENRANGE, _("Generate Ranges")) |
666 |
#controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
#controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
667 |
#self.controlButtons.append(button) |
#self.controlButtons.append(button) |
668 |
|
|
669 |
button = wxButton(self, ID_CLASSIFY_MOVEUP, _("Move Up")) |
button = wxButton(panel, ID_CLASSIFY_MOVEUP, _("Move Up")) |
670 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
671 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
672 |
|
|
673 |
button = wxButton(self, ID_CLASSIFY_MOVEDOWN, _("Move Down")) |
button = wxButton(panel, ID_CLASSIFY_MOVEDOWN, _("Move Down")) |
674 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
675 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
676 |
|
|
677 |
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
678 |
|
|
679 |
button = wxButton(self, ID_CLASSIFY_REMOVE, _("Remove")) |
button = wxButton(panel, ID_CLASSIFY_REMOVE, _("Remove")) |
680 |
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
681 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
682 |
|
|
683 |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
684 |
topBox.Add(controlBox, 1, wxGROW, 10) |
topBox.Add(controlBox, 0, wxGROW, 10) |
685 |
|
|
686 |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
687 |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
689 |
EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp) |
EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp) |
690 |
EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown) |
EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown) |
691 |
|
|
692 |
|
########### |
693 |
|
|
694 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
695 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_OK, _("OK")), |
696 |
0, wxALL, 4) |
0, wxALL, 4) |
697 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
698 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_APPLY, _("Apply")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_APPLY, _("Apply")), |
699 |
0, wxALL, 4) |
0, wxALL, 4) |
700 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
701 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_CANCEL, _("Cancel")), |
702 |
0, wxALL, 4) |
0, wxALL, 4) |
703 |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10) |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
704 |
|
|
705 |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
706 |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
707 |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
708 |
|
|
709 |
|
########### |
710 |
|
|
711 |
self.fields.SetSelection(self.__cur_field) |
self.fields.SetSelection(self.__cur_field) |
712 |
self.__SelectField(self.__cur_field) |
self.__SelectField(self.__cur_field) |
713 |
|
|
714 |
self.SetAutoLayout(true) |
panel.SetAutoLayout(True) |
715 |
self.SetSizer(topBox) |
panel.SetSizer(topBox) |
716 |
topBox.Fit(self) |
|
717 |
topBox.SetSizeHints(self) |
topBox.SetSizeHints(panel) |
718 |
|
topBox.Fit(panel) |
719 |
|
|
720 |
|
self.SetAutoLayout(True) |
721 |
|
self.Fit() |
722 |
|
|
723 |
|
|
724 |
def __BuildClassification(self, fieldIndex): |
def __BuildClassification(self, fieldIndex): |
765 |
|
|
766 |
|
|
767 |
|
|
768 |
type2string = {None: "None", |
type2string = {None: _("None"), |
769 |
FIELDTYPE_STRING: "Text", |
FIELDTYPE_STRING: _("Text"), |
770 |
FIELDTYPE_INT: "Integer", |
FIELDTYPE_INT: _("Integer"), |
771 |
FIELDTYPE_DOUBLE: "Decimal"} |
FIELDTYPE_DOUBLE: _("Decimal")} |
772 |
|
|
773 |
def __SetFieldTypeText(self, fieldIndex): |
def __SetFieldTypeText(self, fieldIndex): |
774 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
780 |
|
|
781 |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
782 |
|
|
783 |
def __SelectField(self, fieldIndex): |
def __SelectField(self, newIndex, oldIndex = -1): |
784 |
clazz = self.__BuildClassification(fieldIndex) |
|
785 |
self.fields.SetClientData(fieldIndex, clazz) |
assert(oldIndex >= -1) |
786 |
|
|
787 |
self.__cur_field = self.fields.GetSelection() |
if oldIndex != -1: |
788 |
self.__SetGridTable(fieldIndex) |
clazz = self.__BuildClassification(oldIndex) |
789 |
|
self.fields.SetClientData(oldIndex, clazz) |
790 |
|
|
791 |
enabled = fieldIndex != 0 |
self.__SetGridTable(newIndex) |
792 |
|
|
793 |
|
enabled = newIndex != 0 |
794 |
|
|
795 |
for b in self.controlButtons: |
for b in self.controlButtons: |
796 |
b.Enable(enabled) |
b.Enable(enabled) |
797 |
|
|
798 |
self.__SetFieldTypeText(fieldIndex) |
self.__SetFieldTypeText(newIndex) |
799 |
|
|
800 |
|
|
801 |
def _OnFieldSelect(self, event): |
def _OnFieldSelect(self, event): |
802 |
self.__SelectField(self.__cur_field) |
index = self.fields.GetSelection() |
803 |
|
self.__SelectField(index, self.__cur_field) |
804 |
|
self.__cur_field = index |
805 |
|
|
806 |
def _OnApply(self, event): |
def _OnApply(self, event): |
807 |
"""Put the data from the table into a new Classification and hand |
"""Put the data from the table into a new Classification and hand |
879 |
|
|
880 |
def __init__(self, parent, prop, shapeType): |
def __init__(self, parent, prop, shapeType): |
881 |
wxDialog.__init__(self, parent, -1, _("Select Properties"), |
wxDialog.__init__(self, parent, -1, _("Select Properties"), |
882 |
style = wxRESIZE_BORDER) |
style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) |
883 |
|
|
884 |
self.prop = ClassGroupProperties(prop) |
self.prop = ClassGroupProperties(prop) |
885 |
|
|
902 |
|
|
903 |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
904 |
lineColorBox.Add( |
lineColorBox.Add( |
905 |
wxButton(self, ID_SELPROP_STROKECLR, "Change Line Color"), |
wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")), |
906 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
907 |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
908 |
|
|
909 |
lineColorBox.Add( |
lineColorBox.Add( |
910 |
wxButton(self, ID_SELPROP_STROKECLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")), |
911 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
912 |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
913 |
self._OnChangeLineColorTrans) |
self._OnChangeLineColorTrans) |
918 |
if shapeType != SHAPETYPE_ARC: |
if shapeType != SHAPETYPE_ARC: |
919 |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
920 |
fillColorBox.Add( |
fillColorBox.Add( |
921 |
wxButton(self, ID_SELPROP_FILLCLR, "Change Fill Color"), |
wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")), |
922 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
923 |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
924 |
fillColorBox.Add( |
fillColorBox.Add( |
925 |
wxButton(self, ID_SELPROP_FILLCLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")), |
926 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
927 |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
928 |
self._OnChangeFillColorTrans) |
self._OnChangeFillColorTrans) |
958 |
EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK) |
EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK) |
959 |
EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
960 |
|
|
961 |
self.SetAutoLayout(true) |
self.SetAutoLayout(True) |
962 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
963 |
topBox.Fit(self) |
topBox.Fit(self) |
964 |
topBox.SetSizeHints(self) |
topBox.SetSizeHints(self) |