/[thuban]/trunk/thuban/Thuban/UI/classifier.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/UI/classifier.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 977 by frank, Thu May 22 11:39:51 2003 UTC revision 1302 by jonathan, Wed Jun 25 09:39:33 2003 UTC
# Line 20  from wxPython.grid import * Line 20  from wxPython.grid import *
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, \
# Line 31  from Thuban.Model.color import Color Line 32  from Thuban.Model.color import Color
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    
# Line 670  EB_LAYER_TITLE = 0 Line 671  EB_LAYER_TITLE = 0
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    
# Line 701  class Classifier(NonModalDialog): Line 706  class Classifier(NonModalDialog):
706              field = self.originalClass.GetField()              field = self.originalClass.GetField()
707              fieldType = self.originalClass.GetFieldType()              fieldType = self.originalClass.GetFieldType()
708    
709                table = layer.ShapeStore().Table()
710              #              #
711              # make field choice box              # make field choice box
712              #              #
713              self.fields = wxChoice(panel, ID_PROPERTY_SELECT,)              self.fields = wxChoice(panel, ID_PROPERTY_SELECT,)
714    
715              self.num_cols = layer.table.NumColumns()              self.num_cols = table.NumColumns()
716              # just assume the first field in case one hasn't been              # just assume the first field in case one hasn't been
717              # specified in the file.              # specified in the file.
718              self.__cur_field = 0              self.__cur_field = 0
# Line 719  class Classifier(NonModalDialog): Line 725  class Classifier(NonModalDialog):
725                  self.fields.SetClientData(0, None)                  self.fields.SetClientData(0, None)
726    
727              for i in range(self.num_cols):              for i in range(self.num_cols):
728                  name = layer.table.Column(i).name                  name = table.Column(i).name
729                  self.fields.Append(name)                  self.fields.Append(name)
730    
731                  if name == field:                  if name == field:
# Line 853  class Classifier(NonModalDialog): Line 859  class Classifier(NonModalDialog):
859          text_title.SetFocus()          text_title.SetFocus()
860          self.haveApplied = False          self.haveApplied = False
861    
862        def unsubscribe_messages(self):
863            self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)
864            self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED,
865                                   self.layer_shapestore_replaced)
866    
867        def map_layers_removed(self, map):
868            if self.layer not in self.map.Layers():
869                self.Close()
870    
871        def layer_shapestore_replaced(self, *args):
872            self.Close()
873    
874      def EditSymbol(self, row):      def EditSymbol(self, row):
875          table = self.classGrid.GetTable()          table = self.classGrid.GetTable()
876          prop = table.GetValueAsCustom(row, COL_SYMBOL, None)          prop = table.GetValueAsCustom(row, COL_SYMBOL, None)
877    
878          # get a new ClassGroupProperties object and copy the          # get a new ClassGroupProperties object and copy the
879          # values over to our current object          # values over to our current object
880          propDlg = SelectPropertiesDialog(NULL, prop, self.layer.ShapeType())          propDlg = SelectPropertiesDialog(self, prop, self.layer.ShapeType())
881    
882          self.Enable(False)          self.Enable(False)
883          if propDlg.ShowModal() == wxID_OK:          if propDlg.ShowModal() == wxID_OK:
# Line 989  class Classifier(NonModalDialog): Line 1007  class Classifier(NonModalDialog):
1007          self.Close()          self.Close()
1008    
1009      def OnClose(self, event):      def OnClose(self, event):
1010          NonModalDialog.OnClose(self, event)          self.unsubscribe_messages()
1011            NonModalNonParentDialog.OnClose(self, event)
1012    
1013      def _OnCloseBtn(self, event):      def _OnCloseBtn(self, event):
1014          """Close is similar to Cancel except that any changes that were          """Close is similar to Cancel except that any changes that were
# Line 1352  class ClassGroupPropertiesCtrl(wxWindow, Line 1371  class ClassGroupPropertiesCtrl(wxWindow,
1371    
1372          wxWindow.__init__(self, parent, id, size = size, style = style)          wxWindow.__init__(self, parent, id, size = size, style = style)
1373    
1374            self.parent = parent
1375    
1376          self.SetProperties(props)          self.SetProperties(props)
1377          self.SetShapeType(shapeType)          self.SetShapeType(shapeType)
1378          self.AllowEdit(True)          self.AllowEdit(True)
# Line 1395  class ClassGroupPropertiesCtrl(wxWindow, Line 1416  class ClassGroupPropertiesCtrl(wxWindow,
1416      def DoEdit(self):      def DoEdit(self):
1417          if not self.allowEdit: return          if not self.allowEdit: return
1418    
1419          propDlg = SelectPropertiesDialog(NULL,          propDlg = SelectPropertiesDialog(self.parent,
1420                                           self.GetProperties(),                                           self.GetProperties(),
1421                                           self.GetShapeType())                                           self.GetShapeType())
1422    

Legend:
Removed from v.977  
changed lines
  Added in v.1302

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26