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 |
|
|
296 |
wxGRIDTABLE_NOTIFY_ROWS_APPENDED, |
wxGRIDTABLE_NOTIFY_ROWS_APPENDED, |
297 |
newRows - curRows) # how many |
newRows - curRows) # how many |
298 |
self.GetView().ProcessTableMessage(msg) |
self.GetView().ProcessTableMessage(msg) |
299 |
|
self.GetView().FitInside() |
300 |
elif newRows < curRows: |
elif newRows < curRows: |
301 |
msg = wxGridTableMessage(self, |
msg = wxGridTableMessage(self, |
302 |
wxGRIDTABLE_NOTIFY_ROWS_DELETED, |
wxGRIDTABLE_NOTIFY_ROWS_DELETED, |
303 |
curRows - newRows, # position |
curRows - newRows, # position |
304 |
curRows - newRows) # how many |
curRows - newRows) # how many |
305 |
self.GetView().ProcessTableMessage(msg) |
self.GetView().ProcessTableMessage(msg) |
306 |
|
self.GetView().FitInside() |
307 |
|
|
308 |
def __SetRow(self, row, group): |
def __SetRow(self, row, group): |
309 |
"""Set a row's data to that of the group. |
"""Set a row's data to that of the group. |
585 |
NonModalDialog.__init__(self, parent, interactor, name, |
NonModalDialog.__init__(self, parent, interactor, name, |
586 |
_("Classifier: %s") % layer.Title()) |
_("Classifier: %s") % layer.Title()) |
587 |
|
|
588 |
|
panel = wxPanel(self, -1, size=(100, 100)) |
589 |
|
|
590 |
self.layer = layer |
self.layer = layer |
591 |
|
|
592 |
self.originalClass = self.layer.GetClassification() |
self.originalClass = self.layer.GetClassification() |
594 |
fieldType = self.originalClass.GetFieldType() |
fieldType = self.originalClass.GetFieldType() |
595 |
|
|
596 |
topBox = wxBoxSizer(wxVERTICAL) |
topBox = wxBoxSizer(wxVERTICAL) |
597 |
|
panelBox = wxBoxSizer(wxVERTICAL) |
598 |
|
|
599 |
#topBox.Add(wxStaticText(self, -1, _("Layer: %s") % layer.Title()), |
#panelBox.Add(wxStaticText(panel, -1, _("Layer: %s") % layer.Title()), |
600 |
#0, wxALIGN_LEFT | wxALL, 4) |
#0, wxALIGN_LEFT | wxALL, 4) |
601 |
topBox.Add(wxStaticText(self, -1, |
panelBox.Add(wxStaticText(panel, -1, |
602 |
_("Layer Type: %s") % layer.ShapeType()), |
_("Layer Type: %s") % layer.ShapeType()), |
603 |
0, wxALIGN_LEFT | wxALL, 4) |
0, wxALIGN_LEFT | wxALL, 4) |
604 |
|
|
606 |
# |
# |
607 |
# make field combo box |
# make field combo box |
608 |
# |
# |
609 |
self.fields = wxComboBox(self, ID_PROPERTY_SELECT, "", |
self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "", |
610 |
style = wxCB_READONLY) |
style = wxCB_READONLY) |
611 |
|
|
612 |
self.num_cols = layer.table.field_count() |
self.num_cols = layer.table.field_count() |
627 |
else: |
else: |
628 |
self.fields.SetClientData(i + 1, None) |
self.fields.SetClientData(i + 1, None) |
629 |
|
|
|
self.fields.SetSelection(self.__cur_field) |
|
|
|
|
|
# |
|
|
# |
|
|
# |
|
630 |
|
|
631 |
self.fieldTypeText = wxStaticText(self, -1, "") |
########### |
|
self.__SetFieldTypeText(self.__cur_field) |
|
632 |
|
|
633 |
topBox.Add(self.fieldTypeText, 0, wxALIGN_LEFT | wxALL, 4) |
self.fieldTypeText = wxStaticText(panel, -1, "") |
634 |
#self.fieldTypeText.SetLabel("asdfadsfs") |
panelBox.Add(self.fieldTypeText, 0, wxGROW | wxALIGN_LEFT | wxALL, 4) |
635 |
|
|
636 |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
637 |
propertyBox.Add(wxStaticText(self, -1, _("Field: ")), |
propertyBox.Add(wxStaticText(panel, -1, _("Field: ")), |
638 |
0, wxALIGN_CENTER | wxALL, 4) |
0, wxALIGN_LEFT | wxALL, 4) |
639 |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
640 |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
641 |
|
|
642 |
topBox.Add(propertyBox, 0, wxGROW, 4) |
panelBox.Add(propertyBox, 0, wxGROW, 4) |
643 |
|
|
644 |
|
########### |
645 |
# |
# |
646 |
# Classification data table |
# Classification data table |
647 |
# |
# |
648 |
|
|
649 |
controlBox = wxBoxSizer(wxHORIZONTAL) |
controlBox = wxBoxSizer(wxHORIZONTAL) |
650 |
|
|
651 |
self.classGrid = ClassGrid(self) |
self.classGrid = ClassGrid(panel) |
652 |
self.__SetGridTable(self.__cur_field) |
self.__SetGridTable(self.__cur_field) |
|
print self.classGrid.GetSizeTuple() |
|
653 |
|
|
654 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
655 |
|
|
656 |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
########### |
|
|
|
657 |
# |
# |
658 |
# Control buttons: |
# Control buttons: |
659 |
# |
# |
660 |
self.controlButtons = [] |
self.controlButtons = [] |
661 |
|
|
662 |
button = wxButton(self, ID_CLASSIFY_ADD, _("Add")) |
controlButtonBox = wxBoxSizer(wxVERTICAL) |
663 |
|
|
664 |
|
button = wxButton(panel, ID_CLASSIFY_ADD, _("Add")) |
665 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
666 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
667 |
|
|
668 |
#button = wxButton(self, ID_CLASSIFY_GENRANGE, _("Generate Ranges")) |
#button = wxButton(panel, ID_CLASSIFY_GENRANGE, _("Generate Ranges")) |
669 |
#controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
#controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
670 |
#self.controlButtons.append(button) |
#self.controlButtons.append(button) |
671 |
|
|
672 |
button = wxButton(self, ID_CLASSIFY_MOVEUP, _("Move Up")) |
button = wxButton(panel, ID_CLASSIFY_MOVEUP, _("Move Up")) |
673 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
674 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
675 |
|
|
676 |
button = wxButton(self, ID_CLASSIFY_MOVEDOWN, _("Move Down")) |
button = wxButton(panel, ID_CLASSIFY_MOVEDOWN, _("Move Down")) |
677 |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL, 4) |
678 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
679 |
|
|
680 |
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
681 |
|
|
682 |
button = wxButton(self, ID_CLASSIFY_REMOVE, _("Remove")) |
button = wxButton(panel, ID_CLASSIFY_REMOVE, _("Remove")) |
683 |
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4) |
684 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
685 |
|
|
686 |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
687 |
topBox.Add(controlBox, 1, wxGROW, 10) |
panelBox.Add(controlBox, 1, wxGROW, 10) |
688 |
|
|
689 |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
690 |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
692 |
EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp) |
EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp) |
693 |
EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown) |
EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown) |
694 |
|
|
695 |
|
########### |
696 |
|
|
697 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
698 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_OK, _("OK")), |
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_APPLY, _("Apply")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_APPLY, _("Apply")), |
702 |
0, wxALL, 4) |
0, wxALL, 4) |
703 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
704 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_CANCEL, _("Cancel")), |
705 |
0, wxALL, 4) |
0, wxALL, 4) |
706 |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10) |
panelBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
707 |
|
|
708 |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
709 |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
710 |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
711 |
|
|
712 |
self.SetAutoLayout(true) |
########### |
|
self.SetSizer(topBox) |
|
|
topBox.Fit(self) |
|
|
topBox.SetSizeHints(self) |
|
713 |
|
|
714 |
|
self.fields.SetSelection(self.__cur_field) |
715 |
|
self.__SelectField(self.__cur_field) |
716 |
|
|
717 |
|
panel.SetAutoLayout(True) |
718 |
|
panel.SetSizer(panelBox) |
719 |
|
panelBox.SetSizeHints(panel) |
720 |
|
|
721 |
|
topBox.Add(panel, 1, wxGROW, 0) |
722 |
|
panelBox.SetSizeHints(self) |
723 |
|
self.SetAutoLayout(True) |
724 |
|
self.SetSizer(topBox) |
725 |
|
|
726 |
def __BuildClassification(self, fieldIndex): |
def __BuildClassification(self, fieldIndex): |
727 |
|
|
728 |
|
numRows = self.classGrid.GetNumberRows() |
729 |
|
assert(numRows > 0) # there should always be a default row |
730 |
|
|
731 |
clazz = Classification() |
clazz = Classification() |
732 |
fieldName = self.fields.GetString(fieldIndex) |
if fieldIndex == 0: |
733 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldName = None |
734 |
|
fieldType = None |
735 |
|
else: |
736 |
|
fieldName = self.fields.GetString(fieldIndex) |
737 |
|
fieldType = self.layer.GetFieldType(fieldName) |
738 |
|
|
739 |
clazz.SetField(fieldName) |
clazz.SetField(fieldName) |
740 |
clazz.SetFieldType(fieldType) |
clazz.SetFieldType(fieldType) |
741 |
|
|
|
numRows = self.classGrid.GetNumberRows() |
|
|
|
|
|
assert(numRows > 0) # there should always be a default row |
|
742 |
|
|
743 |
table = self.classGrid.GetTable() |
table = self.classGrid.GetTable() |
744 |
clazz.SetDefaultGroup(table.GetClassGroup(0)) |
clazz.SetDefaultGroup(table.GetClassGroup(0)) |
765 |
|
|
766 |
self.classGrid.CreateTable(clazz, self.layer.ShapeType()) |
self.classGrid.CreateTable(clazz, self.layer.ShapeType()) |
767 |
|
|
768 |
|
|
769 |
|
|
770 |
|
type2string = {None: _("None"), |
771 |
|
FIELDTYPE_STRING: _("Text"), |
772 |
|
FIELDTYPE_INT: _("Integer"), |
773 |
|
FIELDTYPE_DOUBLE: _("Decimal")} |
774 |
|
|
775 |
def __SetFieldTypeText(self, fieldIndex): |
def __SetFieldTypeText(self, fieldIndex): |
776 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
777 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldType = self.layer.GetFieldType(fieldName) |
778 |
|
|
779 |
if fieldType is None: |
assert(Classifier.type2string.has_key(fieldType)) |
780 |
text = "None" |
|
781 |
elif fieldType == FIELDTYPE_STRING: |
text = Classifier.type2string[fieldType] |
|
text = "Text" |
|
|
elif fieldType == FIELDTYPE_INT: |
|
|
text = "Integer" |
|
|
elif fieldType == FIELDTYPE_DOUBLE: |
|
|
text = "Decimal" # Rational? |
|
|
else: |
|
|
assert(False) |
|
|
text = "UNKNOWN" |
|
782 |
|
|
783 |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
784 |
|
|
785 |
def _OnFieldSelect(self, event): |
def __SelectField(self, newIndex, oldIndex = -1): |
|
clazz = self.__BuildClassification(self.__cur_field) |
|
|
self.fields.SetClientData(self.__cur_field, clazz) |
|
786 |
|
|
787 |
self.__cur_field = self.fields.GetSelection() |
assert(oldIndex >= -1) |
788 |
self.__SetGridTable(self.__cur_field) |
|
789 |
|
if oldIndex != -1: |
790 |
|
clazz = self.__BuildClassification(oldIndex) |
791 |
|
self.fields.SetClientData(oldIndex, clazz) |
792 |
|
|
793 |
|
self.__SetGridTable(newIndex) |
794 |
|
|
795 |
enabled = self.__cur_field != 0 |
enabled = newIndex != 0 |
796 |
|
|
797 |
for b in self.controlButtons: |
for b in self.controlButtons: |
798 |
b.Enable(enabled) |
b.Enable(enabled) |
799 |
|
|
800 |
self.__SetFieldTypeText(self.__cur_field) |
self.__SetFieldTypeText(newIndex) |
801 |
|
|
802 |
|
|
803 |
|
def _OnFieldSelect(self, event): |
804 |
|
index = self.fields.GetSelection() |
805 |
|
self.__SelectField(index, self.__cur_field) |
806 |
|
self.__cur_field = index |
807 |
|
|
808 |
def _OnApply(self, event): |
def _OnApply(self, event): |
809 |
"""Put the data from the table into a new Classification and hand |
"""Put the data from the table into a new Classification and hand |
881 |
|
|
882 |
def __init__(self, parent, prop, shapeType): |
def __init__(self, parent, prop, shapeType): |
883 |
wxDialog.__init__(self, parent, -1, _("Select Properties"), |
wxDialog.__init__(self, parent, -1, _("Select Properties"), |
884 |
style = wxRESIZE_BORDER) |
style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) |
885 |
|
|
886 |
self.prop = ClassGroupProperties(prop) |
self.prop = ClassGroupProperties(prop) |
887 |
|
|
904 |
|
|
905 |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
906 |
lineColorBox.Add( |
lineColorBox.Add( |
907 |
wxButton(self, ID_SELPROP_STROKECLR, "Change Line Color"), |
wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")), |
908 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
909 |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
910 |
|
|
911 |
lineColorBox.Add( |
lineColorBox.Add( |
912 |
wxButton(self, ID_SELPROP_STROKECLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")), |
913 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
914 |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
915 |
self._OnChangeLineColorTrans) |
self._OnChangeLineColorTrans) |
920 |
if shapeType != SHAPETYPE_ARC: |
if shapeType != SHAPETYPE_ARC: |
921 |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
922 |
fillColorBox.Add( |
fillColorBox.Add( |
923 |
wxButton(self, ID_SELPROP_FILLCLR, "Change Fill Color"), |
wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")), |
924 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
925 |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
926 |
fillColorBox.Add( |
fillColorBox.Add( |
927 |
wxButton(self, ID_SELPROP_FILLCLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")), |
928 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
929 |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
930 |
self._OnChangeFillColorTrans) |
self._OnChangeFillColorTrans) |
960 |
EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK) |
EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK) |
961 |
EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
962 |
|
|
963 |
self.SetAutoLayout(true) |
self.SetAutoLayout(True) |
964 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
965 |
topBox.Fit(self) |
topBox.Fit(self) |
966 |
topBox.SetSizeHints(self) |
topBox.SetSizeHints(self) |