/[thuban]/trunk/thuban/Thuban/Model/layer.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/Model/layer.py

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

revision 1451 by jonathan, Wed Jul 16 13:22:48 2003 UTC revision 1452 by bh, Fri Jul 18 12:57:59 2003 UTC
# Line 157  class Layer(BaseLayer): Line 157  class Layer(BaseLayer):
157    
158          self.SetShapeStore(data)          self.SetShapeStore(data)
159    
160          self.SetClassificationField(None)          self.classification_column = None
161            self.SetClassificationColumn(None)
162          self.SetClassification(None)          self.SetClassification(None)
163    
164          self.__classification.SetDefaultLineColor(stroke)          self.__classification.SetDefaultLineColor(stroke)
# Line 194  class Layer(BaseLayer): Line 195  class Layer(BaseLayer):
195          # FIXME: Maybe we should keep it the same if the type is          # FIXME: Maybe we should keep it the same if the type is
196          # compatible enough such as FIELDTYPE_DOUBLE and FIELDTYPE_INT          # compatible enough such as FIELDTYPE_DOUBLE and FIELDTYPE_INT
197          if self.__classification is not None:          if self.__classification is not None:
198              fieldname = self.classificationField              columnname = self.classification_column
199              fieldtype = self.GetFieldType(fieldname)              columntype = self.GetFieldType(columnname)
200              table = store.Table()              table = store.Table()
201              if (fieldname is not None              if (columnname is not None
202                  and (not table.HasColumn(fieldname)                  and (not table.HasColumn(columnname)
203                       or table.Column(fieldname).type != fieldtype)):                       or table.Column(columnname).type != columntype)):
204                  self.SetClassification(None)                  self.SetClassification(None)
205    
206          self.store = store          self.store = store
# Line 235  class Layer(BaseLayer): Line 236  class Layer(BaseLayer):
236      def Destroy(self):      def Destroy(self):
237          BaseLayer.Destroy(self)          BaseLayer.Destroy(self)
238          if self.__classification is not None:          if self.__classification is not None:
239              self.__classification.Unsubscribe(CLASS_CHANGED, self.ClassChanged)              self.__classification.Unsubscribe(CLASS_CHANGED,
240                                                  self._classification_changed)
241    
242      def BoundingBox(self):      def BoundingBox(self):
243          """Return the layer's bounding box in the intrinsic coordinate system.          """Return the layer's bounding box in the intrinsic coordinate system.
# Line 339  class Layer(BaseLayer): Line 341  class Layer(BaseLayer):
341    
342          return self.shapetree.find_shapes((left, bottom), (right, top))          return self.shapetree.find_shapes((left, bottom), (right, top))
343    
344      def GetClassificationField(self):      def GetClassificationColumn(self):
345          return self.classificationField          return self.classification_column
346    
347      def SetClassificationField(self, field):      def SetClassificationColumn(self, column):
348          """Set the field to classifiy on, or None. If field is not None          """Set the column to classifiy on, or None. If column is not None
349          and the field does not exist in the table, raise a ValueError.          and the column does not exist in the table, raise a ValueError.
350          """          """
351          if field:          if column:
352              fieldType = self.GetFieldType(field)              columnType = self.GetFieldType(column)
353              if fieldType is None:              if columnType is None:
354                  raise ValueError()                  raise ValueError()
355          self.classificationField = field          changed = self.classification_column != column
356            self.classification_column = column
357            if changed:
358                self.changed(LAYER_CHANGED, self)
359    
360      def HasClassification(self):      def HasClassification(self):
361          return True          return True
# Line 367  class Layer(BaseLayer): Line 372  class Layer(BaseLayer):
372          """          """
373    
374          if self.__classification is not None:          if self.__classification is not None:
375              self.__classification.Unsubscribe(CLASS_CHANGED, self.ClassChanged)              self.__classification.Unsubscribe(CLASS_CHANGED,
376                                                  self._classification_changed)
377    
378          if clazz is None:          if clazz is None:
379              clazz = classification.Classification()              clazz = classification.Classification()
380    
381          self.__classification = clazz          self.__classification = clazz
382          self.__classification.Subscribe(CLASS_CHANGED, self.ClassChanged)          self.__classification.Subscribe(CLASS_CHANGED,
383                                            self._classification_changed)
384    
385          self.ClassChanged()          self._classification_changed()
386    
387      def ClassChanged(self):      def _classification_changed(self):
388          """Called from the classification object when it has changed."""          """Called from the classification object when it has changed."""
389          self.changed(LAYER_CHANGED, self)          self.changed(LAYER_CHANGED, self)
390    

Legend:
Removed from v.1451  
changed lines
  Added in v.1452

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26