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. |
580 |
|
|
581 |
|
|
582 |
class Classifier(NonModalDialog): |
class Classifier(NonModalDialog): |
583 |
|
|
584 |
def __init__(self, parent, interactor, name, layer): |
def __init__(self, parent, name, layer): |
585 |
NonModalDialog.__init__(self, parent, interactor, name, |
NonModalDialog.__init__(self, parent, name, |
586 |
_("Classifier: %s") % layer.Title()) |
_("Classifier: %s") % layer.Title()) |
587 |
|
|
588 |
panel = wxPanel(self, -1) |
panel = wxPanel(self, -1, size=(100, 100)) |
589 |
|
|
590 |
self.layer = layer |
self.layer = layer |
591 |
|
|
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(panel, -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(panel, -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 |
|
|
631 |
########### |
########### |
632 |
|
|
633 |
self.fieldTypeText = wxStaticText(panel, -1, "") |
self.fieldTypeText = wxStaticText(panel, -1, "") |
634 |
topBox.Add(self.fieldTypeText, 0, wxGROW | wxALIGN_LEFT | wxALL, 4) |
panelBox.Add(self.fieldTypeText, 0, |
635 |
|
wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4) |
636 |
|
|
637 |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
propertyBox = wxBoxSizer(wxHORIZONTAL) |
638 |
propertyBox.Add(wxStaticText(panel, -1, _("Field: ")), |
propertyBox.Add(wxStaticText(panel, -1, _("Field: ")), |
640 |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4) |
641 |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect) |
642 |
|
|
643 |
topBox.Add(propertyBox, 0, wxGROW, 4) |
panelBox.Add(propertyBox, 0, wxGROW, 4) |
644 |
|
|
645 |
########### |
########### |
646 |
# |
# |
649 |
|
|
650 |
controlBox = wxBoxSizer(wxHORIZONTAL) |
controlBox = wxBoxSizer(wxHORIZONTAL) |
651 |
|
|
652 |
self.classGrid = ClassGrid(self) |
self.classGrid = ClassGrid(panel) |
653 |
self.__SetGridTable(self.__cur_field) |
self.__SetGridTable(self.__cur_field) |
654 |
|
|
655 |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
controlBox.Add(self.classGrid, 1, wxGROW, 0) |
685 |
self.controlButtons.append(button) |
self.controlButtons.append(button) |
686 |
|
|
687 |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
controlBox.Add(controlButtonBox, 0, wxGROW, 10) |
688 |
topBox.Add(controlBox, 0, wxGROW, 10) |
panelBox.Add(controlBox, 1, wxGROW, 10) |
689 |
|
|
690 |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd) |
691 |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove) |
704 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(60, 20, 0, wxALL, 4) |
705 |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_CANCEL, _("Cancel")), |
buttonBox.Add(wxButton(panel, ID_CLASSIFY_CANCEL, _("Cancel")), |
706 |
0, wxALL, 4) |
0, wxALL, 4) |
707 |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
panelBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
708 |
|
|
709 |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK) |
710 |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply) |
716 |
self.__SelectField(self.__cur_field) |
self.__SelectField(self.__cur_field) |
717 |
|
|
718 |
panel.SetAutoLayout(True) |
panel.SetAutoLayout(True) |
719 |
panel.SetSizer(topBox) |
panel.SetSizer(panelBox) |
720 |
|
panelBox.SetSizeHints(panel) |
|
topBox.SetSizeHints(panel) |
|
|
topBox.Fit(panel) |
|
721 |
|
|
722 |
|
topBox.Add(panel, 1, wxGROW, 0) |
723 |
|
panelBox.SetSizeHints(self) |
724 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
725 |
self.Fit() |
self.SetSizer(topBox) |
726 |
|
|
727 |
|
###################### |
728 |
|
|
729 |
|
self.haveApplied = False |
730 |
|
|
731 |
def __BuildClassification(self, fieldIndex): |
def __BuildClassification(self, fieldIndex): |
732 |
|
|
826 |
|
|
827 |
self.layer.SetClassification(clazz) |
self.layer.SetClassification(clazz) |
828 |
|
|
829 |
|
self.haveApplied = True |
830 |
|
|
831 |
def _OnOK(self, event): |
def _OnOK(self, event): |
832 |
self._OnApply(event) |
self._OnApply(event) |
833 |
self.OnClose(event) |
self.OnClose(event) |
834 |
|
|
835 |
def _OnCancel(self, event): |
def _OnCancel(self, event): |
836 |
"""The layer's current classification stays the same.""" |
"""The layer's current classification stays the same.""" |
837 |
self.layer.SetClassification(self.originalClass) |
if self.haveApplied: |
838 |
|
self.layer.SetClassification(self.originalClass) |
839 |
|
|
840 |
self.OnClose(event) |
self.OnClose(event) |
841 |
|
|
842 |
def _OnAdd(self, event): |
def _OnAdd(self, event): |
902 |
previewBox = wxBoxSizer(wxVERTICAL) |
previewBox = wxBoxSizer(wxVERTICAL) |
903 |
previewBox.Add(wxStaticText(self, -1, _("Preview:")), |
previewBox.Add(wxStaticText(self, -1, _("Preview:")), |
904 |
0, wxALIGN_LEFT | wxALL, 4) |
0, wxALIGN_LEFT | wxALL, 4) |
905 |
self.previewer = ClassDataPreviewer(None, self.prop, shapeType, |
self.previewWin = ClassDataPreviewWindow(None, self.prop, shapeType, |
906 |
self, ID_SELPROP_PREVIEW, (40, 40)) |
self, ID_SELPROP_PREVIEW, (40, 40)) |
907 |
previewBox.Add(self.previewer, 1, wxGROW, 15) |
previewBox.Add(self.previewWin, 1, wxGROW, 15) |
908 |
|
|
909 |
itemBox.Add(previewBox, 1, wxALIGN_LEFT | wxALL | wxGROW, 0) |
itemBox.Add(previewBox, 1, wxALIGN_LEFT | wxALL | wxGROW, 0) |
910 |
|
|
982 |
|
|
983 |
def _OnSpin(self, event): |
def _OnSpin(self, event): |
984 |
self.prop.SetLineWidth(self.spinCtrl.GetValue()) |
self.prop.SetLineWidth(self.spinCtrl.GetValue()) |
985 |
self.previewer.Refresh() |
self.previewWin.Refresh() |
986 |
|
|
987 |
def __GetColor(self, cur): |
def __GetColor(self, cur): |
988 |
dialog = wxColourDialog(self) |
dialog = wxColourDialog(self) |
999 |
clr = self.__GetColor(self.prop.GetLineColor()) |
clr = self.__GetColor(self.prop.GetLineColor()) |
1000 |
if clr is not None: |
if clr is not None: |
1001 |
self.prop.SetLineColor(clr) |
self.prop.SetLineColor(clr) |
1002 |
self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer |
self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer |
1003 |
|
|
1004 |
def _OnChangeLineColorTrans(self, event): |
def _OnChangeLineColorTrans(self, event): |
1005 |
self.prop.SetLineColor(Color.None) |
self.prop.SetLineColor(Color.None) |
1006 |
self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer |
self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer |
1007 |
|
|
1008 |
def _OnChangeFillColor(self, event): |
def _OnChangeFillColor(self, event): |
1009 |
clr = self.__GetColor(self.prop.GetFill()) |
clr = self.__GetColor(self.prop.GetFill()) |
1010 |
if clr is not None: |
if clr is not None: |
1011 |
self.prop.SetFill(clr) |
self.prop.SetFill(clr) |
1012 |
self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer |
self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer |
1013 |
|
|
1014 |
def _OnChangeFillColorTrans(self, event): |
def _OnChangeFillColorTrans(self, event): |
1015 |
self.prop.SetFill(Color.None) |
self.prop.SetFill(Color.None) |
1016 |
self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer |
self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer |
1017 |
|
|
1018 |
def GetClassGroupProperties(self): |
def GetClassGroupProperties(self): |
1019 |
return self.prop |
return self.prop |
1020 |
|
|
1021 |
|
|
1022 |
class ClassDataPreviewer(wxWindow): |
class ClassDataPreviewWindow(wxWindow): |
1023 |
|
|
1024 |
def __init__(self, rect, prop, shapeType, |
def __init__(self, rect, prop, shapeType, |
1025 |
parent = None, id = -1, size = wxDefaultSize): |
parent = None, id = -1, size = wxDefaultSize): |
1026 |
if parent is not None: |
if parent is not None: |
1027 |
wxWindow.__init__(self, parent, id, size=size) |
wxWindow.__init__(self, parent, id, (0, 0), size) |
1028 |
EVT_PAINT(self, self._OnPaint) |
EVT_PAINT(self, self._OnPaint) |
1029 |
|
|
1030 |
self.rect = rect |
self.rect = rect |
1031 |
|
|
1032 |
self.prop = prop |
self.prop = prop |
1033 |
self.shapeType = shapeType |
self.shapeType = shapeType |
1034 |
|
self.previewer = ClassDataPreviewer() |
1035 |
|
|
1036 |
def _OnPaint(self, event): |
def _OnPaint(self, event): |
1037 |
dc = wxPaintDC(self) |
dc = wxPaintDC(self) |
1039 |
# XXX: this doesn't seem to be having an effect: |
# XXX: this doesn't seem to be having an effect: |
1040 |
dc.DestroyClippingRegion() |
dc.DestroyClippingRegion() |
1041 |
|
|
1042 |
self.Draw(dc, None) |
if self.rect is None: |
1043 |
|
w, h = self.GetSize() |
1044 |
|
rect = wxRect(0, 0, w, h) |
1045 |
|
else: |
1046 |
|
rect = self.rect |
1047 |
|
|
1048 |
|
self.previewer.Draw(dc, rect, self.prop, self.shapeType) |
1049 |
|
|
1050 |
|
class ClassDataPreviewer: |
1051 |
|
|
1052 |
def Draw(self, dc, rect, prop = None, shapeType = None): |
def Draw(self, dc, rect, prop, shapeType): |
1053 |
|
|
1054 |
if prop is None: prop = self.prop |
assert(dc is not None) |
1055 |
if shapeType is None: shapeType = self.shapeType |
assert(isinstance(prop, ClassGroupProperties)) |
1056 |
|
|
1057 |
if rect is None: |
if rect is None: |
1058 |
x = y = 0 |
x = 0 |
1059 |
w, h = self.GetClientSizeTuple() |
y = 0 |
1060 |
|
w, h = dc.GetSize() |
1061 |
else: |
else: |
1062 |
x = rect.GetX() |
x = rect.GetX() |
1063 |
y = rect.GetY() |
y = rect.GetY() |
1097 |
|
|
1098 |
def __init__(self, shapeType): |
def __init__(self, shapeType): |
1099 |
wxPyGridCellRenderer.__init__(self) |
wxPyGridCellRenderer.__init__(self) |
1100 |
self.previewer = ClassDataPreviewer(None, None, shapeType) |
self.shapeType = shapeType |
1101 |
|
self.previewer = ClassDataPreviewer() |
1102 |
|
|
1103 |
def Draw(self, grid, attr, dc, rect, row, col, isSelected): |
def Draw(self, grid, attr, dc, rect, row, col, isSelected): |
1104 |
data = grid.GetTable().GetClassGroup(row) |
data = grid.GetTable().GetClassGroup(row) |
1111 |
rect.GetWidth(), rect.GetHeight()) |
rect.GetWidth(), rect.GetHeight()) |
1112 |
|
|
1113 |
if not isinstance(data, ClassGroupMap): |
if not isinstance(data, ClassGroupMap): |
1114 |
self.previewer.Draw(dc, rect, data.GetProperties()) |
self.previewer.Draw(dc, rect, data.GetProperties(), self.shapeType) |
1115 |
|
|
1116 |
if isSelected: |
if isSelected: |
1117 |
dc.SetPen(wxPen(wxColour(0 * 255, 0 * 255, 0 * 255), |
dc.SetPen(wxPen(wxColour(0 * 255, 0 * 255, 0 * 255), |