/[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 1433 by jonathan, Wed Jul 16 13:24:25 2003 UTC revision 1464 by bh, Fri Jul 18 18:20:40 2003 UTC
# Line 35  from Thuban.Model.layer import Layer, Ra Line 35  from Thuban.Model.layer import Layer, Ra
35  from Thuban.UI.classgen import ClassGenDialog  from Thuban.UI.classgen import ClassGenDialog
36    
37  from dialogs import NonModalNonParentDialog  from dialogs import NonModalNonParentDialog
38    from messages import MAP_REPLACED
39    
40  ID_CLASS_TABLE = 40011  ID_CLASS_TABLE = 40011
41    
# Line 682  class Classifier(NonModalNonParentDialog Line 683  class Classifier(NonModalNonParentDialog
683    
684          self.__SetTitle(layer.Title())          self.__SetTitle(layer.Title())
685    
686            self.parent.Subscribe(MAP_REPLACED, self.map_replaced)
687          self.layer = layer          self.layer = layer
688          self.map = map          self.map = map
689    
# Line 702  class Classifier(NonModalNonParentDialog Line 704  class Classifier(NonModalNonParentDialog
704    
705          if layer.HasClassification():          if layer.HasClassification():
706              self.originalClass = self.layer.GetClassification()              self.originalClass = self.layer.GetClassification()
707              self.originalClassField = self.layer.GetClassificationField()              self.originalClassField = self.layer.GetClassificationColumn()
708              field = self.originalClassField              field = self.originalClassField
709              fieldType = self.layer.GetFieldType(field)              fieldType = self.layer.GetFieldType(field)
710    
# Line 860  class Classifier(NonModalNonParentDialog Line 862  class Classifier(NonModalNonParentDialog
862          self.haveApplied = False          self.haveApplied = False
863    
864      def unsubscribe_messages(self):      def unsubscribe_messages(self):
865            self.parent.Unsubscribe(MAP_REPLACED, self.map_replaced)
866          self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)          self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)
867          self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED,          self.layer.Unsubscribe(LAYER_SHAPESTORE_REPLACED,
868                                 self.layer_shapestore_replaced)                                 self.layer_shapestore_replaced)
# Line 869  class Classifier(NonModalNonParentDialog Line 872  class Classifier(NonModalNonParentDialog
872              self.Close()              self.Close()
873    
874      def layer_shapestore_replaced(self, *args):      def layer_shapestore_replaced(self, *args):
875            """Subscribed to the map's LAYER_SHAPESTORE_REPLACED message.
876    
877            Close self.
878            """
879            self.Close()
880    
881        def map_replaced(self, *args):
882            """Subscribed to the mainwindow's MAP_REPLACED message. Close self."""
883          self.Close()          self.Close()
884    
885      def EditSymbol(self, row):      def EditSymbol(self, row):
# Line 891  class Classifier(NonModalNonParentDialog Line 902  class Classifier(NonModalNonParentDialog
902          self.fields.SetClientData(self.__cur_field, clazz)          self.fields.SetClientData(self.__cur_field, clazz)
903          self.classGrid.GetTable().SetClassification(clazz)          self.classGrid.GetTable().SetClassification(clazz)
904    
905      def __BuildClassification(self, fieldIndex, copyClass = False):      def __BuildClassification(self, fieldIndex, copyClass=False, force=False):
906    
907  #       numRows = self.classGrid.GetNumberRows()  #       numRows = self.classGrid.GetNumberRows()
908  #       assert numRows > 0  # there should always be a default row  #       assert numRows > 0  # there should always be a default row
# Line 903  class Classifier(NonModalNonParentDialog Line 914  class Classifier(NonModalNonParentDialog
914              fieldName = self.fields.GetString(fieldIndex)              fieldName = self.fields.GetString(fieldIndex)
915              fieldType = self.layer.GetFieldType(fieldName)              fieldType = self.layer.GetFieldType(fieldName)
916    
917          clazz = self.classGrid.GetTable().GetClassification()          clazz = self.fields.GetClientData(fieldIndex)
918            if clazz is None or self.classGrid.GetTable().IsModified() or force:
919          if copyClass:              clazz = self.classGrid.GetTable().GetClassification()
920              clazz = copy.deepcopy(clazz)              if copyClass:
921                    clazz = copy.deepcopy(clazz)
922    
923          return clazz          return clazz, fieldName
924    
925      def __SetGridTable(self, fieldIndex, group = None):      def __SetGridTable(self, fieldIndex, group = None):
926    
# Line 945  class Classifier(NonModalNonParentDialog Line 957  class Classifier(NonModalNonParentDialog
957          assert oldIndex >= -1          assert oldIndex >= -1
958    
959          if oldIndex != -1:          if oldIndex != -1:
960              clazz = self.__BuildClassification(oldIndex)              clazz, name = self.__BuildClassification(oldIndex, force = True)
961              self.fields.SetClientData(oldIndex, clazz)              self.fields.SetClientData(oldIndex, clazz)
962    
963          self.__SetGridTable(newIndex, group)          self.__SetGridTable(newIndex, group)
# Line 984  class Classifier(NonModalNonParentDialog Line 996  class Classifier(NonModalNonParentDialog
996              # to begin with or it has been modified              # to begin with or it has been modified
997              #              #
998              self.classGrid.SaveEditControlValue()              self.classGrid.SaveEditControlValue()
999              if clazz is None or self.classGrid.GetTable().IsModified():              clazz, name = self.__BuildClassification(self.__cur_field, True)
                 clazz = self.__BuildClassification(self.__cur_field, True)  
1000    
1001              self.layer.SetClassificationField(              self.layer.SetClassificationColumn(name)
                 self.fields.GetString(self.__cur_field))  
1002              self.layer.SetClassification(clazz)              self.layer.SetClassification(clazz)
1003    
1004          self.haveApplied = True          self.haveApplied = True
# Line 1012  class Classifier(NonModalNonParentDialog Line 1022  class Classifier(NonModalNonParentDialog
1022      def _OnRevert(self, event):      def _OnRevert(self, event):
1023          """The layer's current classification stays the same."""          """The layer's current classification stays the same."""
1024          if self.haveApplied:          if self.haveApplied:
1025              self.layer.SetClassificationField(self.originalClassField)              self.layer.SetClassificationColumn(self.originalClassField)
1026              self.layer.SetClassification(self.originalClass)              self.layer.SetClassification(self.originalClass)
1027    
1028          #self.Close()          #self.Close()

Legend:
Removed from v.1433  
changed lines
  Added in v.1464

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26