/[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 437 by jonathan, Thu Feb 27 15:53:21 2003 UTC revision 492 by jonathan, Mon Mar 10 10:44:57 2003 UTC
# Line 109  class Layer(BaseLayer): Line 109  class Layer(BaseLayer):
109      def __init__(self, title, filename, projection = None,      def __init__(self, title, filename, projection = None,
110                   fill = Color.None,                   fill = Color.None,
111                   stroke = Color.Black,                   stroke = Color.Black,
112                   stroke_width = 1,                   lineWidth = 1,
113                   visible = 1):                   visible = 1):
114          """Initialize the layer.          """Initialize the layer.
115    
# Line 118  class Layer(BaseLayer): Line 118  class Layer(BaseLayer):
118          projection -- the projection object. Its Inverse method is          projection -- the projection object. Its Inverse method is
119                 assumed to map the layer's coordinates to lat/long                 assumed to map the layer's coordinates to lat/long
120                 coordinates                 coordinates
121          fill -- the fill color or None if the shapes are not filled          fill -- the fill color or Color.None if the shapes are not filled
122          stroke -- the stroke color or None if the shapes are not stroked          stroke -- the stroke color or Color.None if the shapes are not stroked
123          visible -- boolean. If true the layer is visible.          visible -- boolean. If true the layer is visible.
124    
125          colors are expected to be instances of Color class          colors are expected to be instances of Color class
# Line 142  class Layer(BaseLayer): Line 142  class Layer(BaseLayer):
142          self.shapetable = Table(filename)          self.shapetable = Table(filename)
143          self.table = self.shapetable          self.table = self.shapetable
144    
145          self.__classification = classification.Classification(self)          #
146          self.__classification.SetDefaultStroke(stroke)          # this is really important so that when the classification class
147          self.__classification.SetDefaultStrokeWidth(stroke_width)          # tries to set its parent layer the variable will exist
148            #
149            self.__classification = None
150    
151    
152            self.SetClassification(None)
153    
154            self.__classification.SetDefaultLineColor(stroke)
155            self.__classification.SetDefaultLineWidth(lineWidth)
156          self.__classification.SetDefaultFill(fill)          self.__classification.SetDefaultFill(fill)
157            self.__classification.SetLayer(self)
158    
159          self.UnsetModified()          self.UnsetModified()
160    
# Line 208  class Layer(BaseLayer): Line 217  class Layer(BaseLayer):
217          else:          else:
218              return None              return None
219    
220        def GetFieldType(self, fieldName):
221            self.open_shapefile()
222            info = self.table.field_info_by_name(fieldName)
223            if info is not None:
224                return info[0]
225            else:
226                return None
227    
228      def NumShapes(self):      def NumShapes(self):
229          """Return the number of shapes in the layer"""          """Return the number of shapes in the layer"""
230          self.open_shapefile()          self.open_shapefile()
# Line 254  class Layer(BaseLayer): Line 271  class Layer(BaseLayer):
271          return self.__classification          return self.__classification
272    
273      def SetClassification(self, clazz):      def SetClassification(self, clazz):
274          self.__classification = clazz          """Set the classification to 'clazz'
275    
276            If 'clazz' is None a default classification is created
277            """
278    
279            if clazz is None:
280                self.__classification = classification.Classification()
281            else:
282    
283                # prevent infinite recursion when calling SetLayer()
284                if clazz == self.__classification:
285                    return
286    
287                self.__classification = clazz
288                self.__classification.SetLayer(self)
289    
290          self.changed(LAYER_LEGEND_CHANGED, self)          self.changed(LAYER_LEGEND_CHANGED, self)
291    
292        def ClassChanged(self):
293            """Called from the classification object when it has changed."""
294            self.changed(LAYER_LEGEND_CHANGED, self)
295    
296      def TreeInfo(self):      def TreeInfo(self):
297          items = []          items = []
298    

Legend:
Removed from v.437  
changed lines
  Added in v.492

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26