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 |
# |
# |
649 |
|
|
650 |
self.classGrid = ClassGrid(self) |
self.classGrid = ClassGrid(self) |
651 |
self.__SetGridTable(self.__cur_field) |
self.__SetGridTable(self.__cur_field) |
|
print self.classGrid.GetSizeTuple() |
|
652 |
|
|
653 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
654 |
|
|
705 |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
706 |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel) |
707 |
|
|
708 |
|
self.fields.SetSelection(self.__cur_field) |
709 |
|
self.__SelectField(self.__cur_field) |
710 |
|
|
711 |
self.SetAutoLayout(true) |
self.SetAutoLayout(true) |
712 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
713 |
topBox.Fit(self) |
topBox.Fit(self) |
716 |
|
|
717 |
def __BuildClassification(self, fieldIndex): |
def __BuildClassification(self, fieldIndex): |
718 |
|
|
719 |
|
numRows = self.classGrid.GetNumberRows() |
720 |
|
assert(numRows > 0) # there should always be a default row |
721 |
|
|
722 |
clazz = Classification() |
clazz = Classification() |
723 |
fieldName = self.fields.GetString(fieldIndex) |
if fieldIndex == 0: |
724 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldName = None |
725 |
|
fieldType = None |
726 |
|
else: |
727 |
|
fieldName = self.fields.GetString(fieldIndex) |
728 |
|
fieldType = self.layer.GetFieldType(fieldName) |
729 |
|
|
730 |
clazz.SetField(fieldName) |
clazz.SetField(fieldName) |
731 |
clazz.SetFieldType(fieldType) |
clazz.SetFieldType(fieldType) |
732 |
|
|
|
numRows = self.classGrid.GetNumberRows() |
|
|
|
|
|
assert(numRows > 0) # there should always be a default row |
|
733 |
|
|
734 |
table = self.classGrid.GetTable() |
table = self.classGrid.GetTable() |
735 |
clazz.SetDefaultGroup(table.GetClassGroup(0)) |
clazz.SetDefaultGroup(table.GetClassGroup(0)) |
756 |
|
|
757 |
self.classGrid.CreateTable(clazz, self.layer.ShapeType()) |
self.classGrid.CreateTable(clazz, self.layer.ShapeType()) |
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
type2string = {None: _("None"), |
762 |
|
FIELDTYPE_STRING: _("Text"), |
763 |
|
FIELDTYPE_INT: _("Integer"), |
764 |
|
FIELDTYPE_DOUBLE: _("Decimal")} |
765 |
|
|
766 |
def __SetFieldTypeText(self, fieldIndex): |
def __SetFieldTypeText(self, fieldIndex): |
767 |
fieldName = self.fields.GetString(fieldIndex) |
fieldName = self.fields.GetString(fieldIndex) |
768 |
fieldType = self.layer.GetFieldType(fieldName) |
fieldType = self.layer.GetFieldType(fieldName) |
769 |
|
|
770 |
if fieldType is None: |
assert(Classifier.type2string.has_key(fieldType)) |
771 |
text = "None" |
|
772 |
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" |
|
773 |
|
|
774 |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
self.fieldTypeText.SetLabel(_("Field Type: %s") % text) |
775 |
|
|
776 |
def _OnFieldSelect(self, event): |
def __SelectField(self, newIndex, oldIndex = -1): |
|
clazz = self.__BuildClassification(self.__cur_field) |
|
|
self.fields.SetClientData(self.__cur_field, clazz) |
|
777 |
|
|
778 |
self.__cur_field = self.fields.GetSelection() |
assert(oldIndex >= -1) |
779 |
self.__SetGridTable(self.__cur_field) |
|
780 |
|
if oldIndex != -1: |
781 |
|
clazz = self.__BuildClassification(oldIndex) |
782 |
|
self.fields.SetClientData(oldIndex, clazz) |
783 |
|
|
784 |
|
self.__SetGridTable(newIndex) |
785 |
|
|
786 |
enabled = self.__cur_field != 0 |
enabled = newIndex != 0 |
787 |
|
|
788 |
for b in self.controlButtons: |
for b in self.controlButtons: |
789 |
b.Enable(enabled) |
b.Enable(enabled) |
790 |
|
|
791 |
self.__SetFieldTypeText(self.__cur_field) |
self.__SetFieldTypeText(newIndex) |
792 |
|
|
793 |
|
|
794 |
|
def _OnFieldSelect(self, event): |
795 |
|
index = self.fields.GetSelection() |
796 |
|
self.__SelectField(index, self.__cur_field) |
797 |
|
self.__cur_field = index |
798 |
|
|
799 |
def _OnApply(self, event): |
def _OnApply(self, event): |
800 |
"""Put the data from the table into a new Classification and hand |
"""Put the data from the table into a new Classification and hand |
895 |
|
|
896 |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
lineColorBox = wxBoxSizer(wxHORIZONTAL) |
897 |
lineColorBox.Add( |
lineColorBox.Add( |
898 |
wxButton(self, ID_SELPROP_STROKECLR, "Change Line Color"), |
wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")), |
899 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
900 |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor) |
901 |
|
|
902 |
lineColorBox.Add( |
lineColorBox.Add( |
903 |
wxButton(self, ID_SELPROP_STROKECLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")), |
904 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
905 |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS, |
906 |
self._OnChangeLineColorTrans) |
self._OnChangeLineColorTrans) |
911 |
if shapeType != SHAPETYPE_ARC: |
if shapeType != SHAPETYPE_ARC: |
912 |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
fillColorBox = wxBoxSizer(wxHORIZONTAL) |
913 |
fillColorBox.Add( |
fillColorBox.Add( |
914 |
wxButton(self, ID_SELPROP_FILLCLR, "Change Fill Color"), |
wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")), |
915 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
916 |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor) |
917 |
fillColorBox.Add( |
fillColorBox.Add( |
918 |
wxButton(self, ID_SELPROP_FILLCLRTRANS, "Transparent"), |
wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")), |
919 |
1, wxALL | wxGROW, 4) |
1, wxALL | wxGROW, 4) |
920 |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS, |
921 |
self._OnChangeFillColorTrans) |
self._OnChangeFillColorTrans) |