85 |
self.shapeType = shapeType |
self.shapeType = shapeType |
86 |
table = self.GetTable() |
table = self.GetTable() |
87 |
if table is None: |
if table is None: |
88 |
|
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) |
self.SetTable(ClassTable(clazz, self.shapeType, self), true) |
93 |
else: |
else: |
94 |
table.Reset(clazz, self.shapeType) |
table.Reset(clazz, self.shapeType) |
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 |
|
|
622 |
else: |
else: |
623 |
self.fields.SetClientData(i + 1, None) |
self.fields.SetClientData(i + 1, None) |
624 |
|
|
|
self.fields.SetSelection(self.__cur_field) |
|
625 |
|
|
626 |
# |
# |
627 |
# |
# |
628 |
# |
# |
629 |
|
|
630 |
self.fieldTypeText = wxStaticText(self, -1, "") |
self.fieldTypeText = wxStaticText(self, -1, "") |
631 |
self.__SetFieldTypeText(self.__cur_field) |
topBox.Add(self.fieldTypeText, 0, wxGROW | wxALIGN_LEFT | wxALL, 4) |
|
|
|
|
topBox.Add(self.fieldTypeText, 0, wxALIGN_LEFT | wxALL, 4) |
|
|
#self.fieldTypeText.SetLabel("asdfadsfs") |
|
632 |
|
|
633 |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
634 |
propertyBox.Add(wxStaticText(self, -1, _("Field: ")), |
propertyBox.Add(wxStaticText(self, -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 |
|
|
646 |
|
|
647 |
self.classGrid = ClassGrid(self) |
self.classGrid = ClassGrid(self) |
648 |
self.__SetGridTable(self.__cur_field) |
self.__SetGridTable(self.__cur_field) |
|
print self.classGrid.GetSizeTuple() |
|
649 |
|
|
650 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
651 |
|
|
702 |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
703 |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
704 |
|
|
705 |
|
self.fields.SetSelection(self.__cur_field) |
706 |
|
self.__SelectField(self.__cur_field) |
707 |
|
|
708 |
self.SetAutoLayout(true) |
self.SetAutoLayout(true) |
709 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
710 |
topBox.Fit(self) |
topBox.Fit(self) |
713 |
|
|
714 |
def __BuildClassification(self, fieldIndex): |
def __BuildClassification(self, fieldIndex): |
715 |
|
|
716 |
|
numRows = self.classGrid.GetNumberRows() |
717 |
|
assert(numRows > 0) # there should always be a default row |
718 |
|
|
719 |
clazz = Classification() |
clazz = Classification() |
720 |
fieldName = self.fields.GetString(fieldIndex) |
if fieldIndex == 0: |
721 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldName = None |
722 |
|
fieldType = None |
723 |
|
else: |
724 |
|
fieldName = self.fields.GetString(fieldIndex) |
725 |
|
fieldType = self.layer.GetFieldType(fieldName) |
726 |
|
|
727 |
clazz.SetField(fieldName) |
clazz.SetField(fieldName) |
728 |
clazz.SetFieldType(fieldType) |
clazz.SetFieldType(fieldType) |
729 |
|
|
|
numRows = self.classGrid.GetNumberRows() |
|
|
|
|
|
assert(numRows > 0) # there should always be a default row |
|
730 |
|
|
731 |
table = self.classGrid.GetTable() |
table = self.classGrid.GetTable() |
732 |
clazz.SetDefaultGroup(table.GetClassGroup(0)) |
clazz.SetDefaultGroup(table.GetClassGroup(0)) |
753 |
|
|
754 |
self.classGrid.CreateTable(clazz, self.layer.ShapeType()) |
self.classGrid.CreateTable(clazz, self.layer.ShapeType()) |
755 |
|
|
756 |
|
|
757 |
|
|
758 |
|
type2string = {None: _("None"), |
759 |
|
FIELDTYPE_STRING: _("Text"), |
760 |
|
FIELDTYPE_INT: _("Integer"), |
761 |
|
FIELDTYPE_DOUBLE: _("Decimal")} |
762 |
|
|
763 |
def __SetFieldTypeText(self, fieldIndex): |
def __SetFieldTypeText(self, fieldIndex): |
764 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
765 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldType = self.layer.GetFieldType(fieldName) |
766 |
|
|
767 |
if fieldType is None: |
assert(Classifier.type2string.has_key(fieldType)) |
768 |
text = "None" |
|
769 |
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" |
|
770 |
|
|
771 |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
772 |
|
|
773 |
def _OnFieldSelect(self, event): |
def __SelectField(self, newIndex, oldIndex = -1): |
|
clazz = self.__BuildClassification(self.__cur_field) |
|
|
self.fields.SetClientData(self.__cur_field, clazz) |
|
774 |
|
|
775 |
self.__cur_field = self.fields.GetSelection() |
assert(oldIndex >= -1) |
776 |
self.__SetGridTable(self.__cur_field) |
|
777 |
|
if oldIndex != -1: |
778 |
|
clazz = self.__BuildClassification(oldIndex) |
779 |
|
self.fields.SetClientData(oldIndex, clazz) |
780 |
|
|
781 |
enabled = self.__cur_field != 0 |
self.__SetGridTable(newIndex) |
782 |
|
|
783 |
|
enabled = newIndex != 0 |
784 |
|
|
785 |
for b in self.controlButtons: |
for b in self.controlButtons: |
786 |
b.Enable(enabled) |
b.Enable(enabled) |
787 |
|
|
788 |
self.__SetFieldTypeText(self.__cur_field) |
self.__SetFieldTypeText(newIndex) |
789 |
|
|
790 |
|
|
791 |
|
def _OnFieldSelect(self, event): |
792 |
|
index = self.fields.GetSelection() |
793 |
|
self.__SelectField(index, self.__cur_field) |
794 |
|
self.__cur_field = index |
795 |
|
|
796 |
def _OnApply(self, event): |
def _OnApply(self, event): |
797 |
"""Put the data from the table into a new Classification and hand |
"""Put the data from the table into a new Classification and hand |
869 |
|
|
870 |
def __init__(self, parent, prop, shapeType): |
def __init__(self, parent, prop, shapeType): |
871 |
wxDialog.__init__(self, parent, -1, _("Select Properties"), |
wxDialog.__init__(self, parent, -1, _("Select Properties"), |
872 |
style = wxRESIZE_BORDER) |
style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) |
873 |
|
|
874 |
self.prop = ClassGroupProperties(prop) |
self.prop = ClassGroupProperties(prop) |
875 |
|
|
892 |
|
|
893 |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
894 |
lineColorBox.Add( |
lineColorBox.Add( |
895 |
wxButton(self, ID_SELPROP_STROKECLR, "Change Line Color"), |
wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")), |
896 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
897 |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
898 |
|
|
899 |
lineColorBox.Add( |
lineColorBox.Add( |
900 |
wxButton(self, ID_SELPROP_STROKECLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")), |
901 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
902 |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
903 |
self._OnChangeLineColorTrans) |
self._OnChangeLineColorTrans) |
908 |
if shapeType != SHAPETYPE_ARC: |
if shapeType != SHAPETYPE_ARC: |
909 |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
910 |
fillColorBox.Add( |
fillColorBox.Add( |
911 |
wxButton(self, ID_SELPROP_FILLCLR, "Change Fill Color"), |
wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")), |
912 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
913 |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
914 |
fillColorBox.Add( |
fillColorBox.Add( |
915 |
wxButton(self, ID_SELPROP_FILLCLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")), |
916 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
917 |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
918 |
self._OnChangeFillColorTrans) |
self._OnChangeFillColorTrans) |