20 |
from Thuban import _ |
from Thuban import _ |
21 |
from Thuban.UI.common import Color2wxColour, wxColour2Color |
from Thuban.UI.common import Color2wxColour, wxColour2Color |
22 |
|
|
23 |
|
from Thuban.Model.messages import MAP_LAYERS_REMOVED, LAYER_SHAPESTORE_REPLACED |
24 |
from Thuban.Model.range import Range |
from Thuban.Model.range import Range |
25 |
from Thuban.Model.classification import \ |
from Thuban.Model.classification import \ |
26 |
Classification, ClassGroupDefault, \ |
Classification, ClassGroupDefault, \ |
32 |
from Thuban.Model.layer import Layer, RasterLayer, \ |
from Thuban.Model.layer import Layer, RasterLayer, \ |
33 |
SHAPETYPE_ARC, SHAPETYPE_POLYGON, SHAPETYPE_POINT |
SHAPETYPE_ARC, SHAPETYPE_POLYGON, SHAPETYPE_POINT |
34 |
|
|
35 |
from Thuban.UI.classgen import ClassGenDialog, ClassGenerator |
from Thuban.UI.classgen import ClassGenDialog |
36 |
|
|
37 |
from dialogs import NonModalDialog |
from dialogs import NonModalNonParentDialog |
38 |
|
|
39 |
ID_CLASS_TABLE = 40011 |
ID_CLASS_TABLE = 40011 |
40 |
|
|
671 |
EB_SELECT_FIELD = 1 |
EB_SELECT_FIELD = 1 |
672 |
EB_GEN_CLASS = 2 |
EB_GEN_CLASS = 2 |
673 |
|
|
674 |
class Classifier(NonModalDialog): |
class Classifier(NonModalNonParentDialog): |
675 |
|
|
676 |
type2string = {None: _("None"), |
type2string = {None: _("None"), |
677 |
FIELDTYPE_STRING: _("Text"), |
FIELDTYPE_STRING: _("Text"), |
678 |
FIELDTYPE_INT: _("Integer"), |
FIELDTYPE_INT: _("Integer"), |
679 |
FIELDTYPE_DOUBLE: _("Decimal")} |
FIELDTYPE_DOUBLE: _("Decimal")} |
680 |
|
|
681 |
def __init__(self, parent, name, layer, group = None): |
def __init__(self, parent, name, map, layer, group = None): |
682 |
NonModalDialog.__init__(self, parent, name, "") |
NonModalNonParentDialog.__init__(self, parent, name, "") |
683 |
|
|
684 |
self.__SetTitle(layer.Title()) |
self.__SetTitle(layer.Title()) |
685 |
|
|
686 |
self.layer = layer |
self.layer = layer |
687 |
|
self.map = map |
688 |
|
|
689 |
|
self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
690 |
|
self.layer.Subscribe(LAYER_SHAPESTORE_REPLACED, |
691 |
|
self.layer_shapestore_replaced) |
692 |
|
|
693 |
self.genDlg = None |
self.genDlg = None |
694 |
|
|
754 |
self.fields.SetSelection(self.__cur_field) |
self.fields.SetSelection(self.__cur_field) |
755 |
self.__SelectField(self.__cur_field, group = group) |
self.__SelectField(self.__cur_field, group = group) |
756 |
|
|
757 |
button_try = wxButton(panel, ID_PROPERTY_TRY, _("Try")) |
button_try = wxButton(self, ID_PROPERTY_TRY, _("Try")) |
758 |
button_revert = wxButton(panel, ID_PROPERTY_REVERT, _("Revert")) |
button_revert = wxButton(self, ID_PROPERTY_REVERT, _("Revert")) |
759 |
button_ok = wxButton(panel, wxID_OK, _("OK")) |
button_ok = wxButton(self, wxID_OK, _("OK")) |
760 |
button_ok.SetDefault() |
button_ok.SetDefault() |
761 |
button_close = wxButton(panel, wxID_CANCEL, _("Close")) |
button_close = wxButton(self, wxID_CANCEL, _("Close")) |
762 |
|
|
763 |
############################ |
############################ |
764 |
# Layout the controls |
# Layout the controls |
818 |
|
|
819 |
|
|
820 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
821 |
buttonBox.Add(button_try, 0, wxALL, 4) |
buttonBox.Add(button_try, 0, wxRIGHT|wxEXPAND, 10) |
822 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(button_revert, 0, wxRIGHT|wxEXPAND, 10) |
823 |
buttonBox.Add(button_revert, 0, wxALL, 4) |
buttonBox.Add(button_ok, 0, wxRIGHT|wxEXPAND, 10) |
824 |
buttonBox.Add(60, 20, 0, wxALL, 4) |
buttonBox.Add(button_close, 0, wxRIGHT|wxEXPAND, 10) |
|
buttonBox.Add(button_ok, 0, wxALL, 4) |
|
|
buttonBox.Add(60, 20, 0, wxALL, 4) |
|
|
buttonBox.Add(button_close, 0, wxALL, 4) |
|
|
panelBox.Add(buttonBox, 0, |
|
|
wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0) |
|
825 |
|
|
826 |
panel.SetAutoLayout(True) |
panel.SetAutoLayout(True) |
827 |
panel.SetSizer(panelBox) |
panel.SetSizer(panelBox) |
829 |
panelBox.SetSizeHints(panel) |
panelBox.SetSizeHints(panel) |
830 |
|
|
831 |
topBox.Add(panel, 1, wxGROW | wxALL, 4) |
topBox.Add(panel, 1, wxGROW | wxALL, 4) |
832 |
|
topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10) |
833 |
|
|
834 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
835 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
858 |
text_title.SetFocus() |
text_title.SetFocus() |
859 |
self.haveApplied = False |
self.haveApplied = False |
860 |
|
|
861 |
|
def unsubscribe_messages(self): |
862 |
|
self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
863 |
|
self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED, |
864 |
|
self.layer_shapestore_replaced) |
865 |
|
|
866 |
|
def map_layers_removed(self, map): |
867 |
|
if self.layer not in self.map.Layers(): |
868 |
|
self.Close() |
869 |
|
|
870 |
|
def layer_shapestore_replaced(self, *args): |
871 |
|
self.Close() |
872 |
|
|
873 |
def EditSymbol(self, row): |
def EditSymbol(self, row): |
874 |
table = self.classGrid.GetTable() |
table = self.classGrid.GetTable() |
875 |
prop = table.GetValueAsCustom(row, COL_SYMBOL, None) |
prop = table.GetValueAsCustom(row, COL_SYMBOL, None) |
1006 |
self.Close() |
self.Close() |
1007 |
|
|
1008 |
def OnClose(self, event): |
def OnClose(self, event): |
1009 |
NonModalDialog.OnClose(self, event) |
self.unsubscribe_messages() |
1010 |
|
NonModalNonParentDialog.OnClose(self, event) |
1011 |
|
|
1012 |
def _OnCloseBtn(self, event): |
def _OnCloseBtn(self, event): |
1013 |
"""Close is similar to Cancel except that any changes that were |
"""Close is similar to Cancel except that any changes that were |
1194 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
1195 |
button_ok = wxButton(self, wxID_OK, _("OK")) |
button_ok = wxButton(self, wxID_OK, _("OK")) |
1196 |
button_ok.SetDefault() |
button_ok.SetDefault() |
1197 |
buttonBox.Add(button_ok, 0, wxALL, 4) |
buttonBox.Add(button_ok, 0, wxRIGHT|wxEXPAND, 10) |
1198 |
buttonBox.Add(wxButton(self, wxID_CANCEL, _("Cancel")), |
buttonBox.Add(wxButton(self, wxID_CANCEL, _("Cancel")), |
1199 |
0, wxALL, 4) |
0, wxRIGHT|wxEXPAND, 10) |
1200 |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10) |
topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10) |
1201 |
|
|
1202 |
#EVT_BUTTON(self, wxID_OK, self._OnOK) |
#EVT_BUTTON(self, wxID_OK, self._OnOK) |
1203 |
#EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |
#EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel) |