/[thuban]/trunk/thuban/Extensions/svgexport/svgmapwriter.py
ViewVC logotype

Diff of /trunk/thuban/Extensions/svgexport/svgmapwriter.py

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

revision 2413 by bernhard, Mon Nov 15 16:27:41 2004 UTC revision 2414 by bernhard, Mon Nov 22 11:17:47 2004 UTC
# Line 19  __version__ = "$Revision$" Line 19  __version__ = "$Revision$"
19  # $Source$  # $Source$
20  # $Id$  # $Id$
21    
22    import sys
23    
24    # Verboseness level for debugging.
25    verbose=0
26    log=sys.stdout.write
27    
28  # Regular expressions used with Fontnames  # Regular expressions used with Fontnames
29  import re  import re
# Line 88  class Pen: Line 93  class Pen:
93          self.dashes = pdashes          self.dashes = pdashes
94          self.join = 'round'          self.join = 'round'
95          self.cap = 'round'          self.cap = 'round'
96    
97        def __str__(self):
98            return "Pen(%s,%s,%s,%s,%s)" % \
99                (str(self.color), str(self.width), str(self.dashes),
100                 str(self.join), str(self.cap))
101            
102      def GetColor(self):      def GetColor(self):
103          return self.color          return self.color
# Line 112  class Brush: Line 122  class Brush:
122          """Init the brush with the given values."""          """Init the brush with the given values."""
123          self.fill = bfill          self.fill = bfill
124          self.pattern = bpattern          self.pattern = bpattern
125        
126        def __str__(self):
127            return "Brush(" + str(self.fill) + "," + str(self.pattern) + ")"
128    
129      def GetColor(self):      def GetColor(self):
130          return self.fill          return self.fill
131        
132      def GetPattern(self):      def GetPattern(self):
133          return self.pattern          return self.pattern
134    
# Line 200  class SVGRenderer(BaseRenderer): Line 213  class SVGRenderer(BaseRenderer):
213          """          """
214          points = self.projected_points(layer, points)          points = self.projected_points(layer, points)
215    
216          if brush is not TRANSPARENT_BRUSH:          if verbose > 1:
217              self.dc.SetBrush(brush)              log("drawing polygon with brush %s and pen %s\n" %
218              self.dc.SetPen(pen)                  (str(brush), str(pen)) )
219              for part in points:  
220                  self.dc.DrawLines(part)          self.dc.SetBrush(brush)
221            self.dc.SetPen(pen)
222            # FIXME: understand what BaseRenderer.draw_polygon_shape does
223            #        so complicated here and fix it here, too.
224            #        Maybe that is handling of holes?
225            for parts in points:
226                self.dc.DrawPolygon(parts,closed=1)
227            
228      def draw_point_shape(self, layer, points, pen, brush):      def draw_point_shape(self, layer, points, pen, brush):
229          """Draw a point shape from layer with the given brush and pen          """Draw a point shape from layer with the given brush and pen
# Line 248  class SVGRenderer(BaseRenderer): Line 267  class SVGRenderer(BaseRenderer):
267              # faster since we don't need the attribute information at              # faster since we don't need the attribute information at
268              # all.              # all.
269              field = None              field = None
270                if verbose > 0:
271                    log("layer %s has no classification\n" % layer.Title())
272    
273          # Determine which render function to use.          # Determine which render function to use.
274          useraw, draw_func, draw_func_param = \          useraw, draw_func, draw_func_param = \
# Line 274  class SVGRenderer(BaseRenderer): Line 295  class SVGRenderer(BaseRenderer):
295    
296              if not group.IsVisible():              if not group.IsVisible():
297                  continue                  continue
298                
299              # Render classification              # Render classification
300              shapeType = layer.ShapeType()              shapeType = layer.ShapeType()
301              props = group.GetProperties()              props = group.GetProperties()
302                
303              # put meta infos into DC              # put meta infos into DC
304              if field and value:              if field and value:
305                  dc.SetMeta({field:value, })                  dc.SetMeta({field:value, })
# Line 295  class SVGRenderer(BaseRenderer): Line 316  class SVGRenderer(BaseRenderer):
316                  data = shape.RawData()                  data = shape.RawData()
317              else:              else:
318                  data = shape.Points()                  data = shape.Points()
319                if verbose > 0 : log("Using draw_func %s\n"%(repr(draw_func)))
320              draw_func(draw_func_param, data, pen, brush)              draw_func(draw_func_param, data, pen, brush)
321              # compatibility              # compatibility
322              if 0:              if 0:
# Line 668  class VirtualDC(XMLWriter): Line 690  class VirtualDC(XMLWriter):
690          for point in polygon:          for point in polygon:
691              if i is 0:              if i is 0:
692                  data.append('M %s %s ' % (point.x, point.y))                  data.append('M %s %s ' % (point.x, point.y))
693                    i+=1
694              else:              else:
695                  data.append('L %s %s ' % (point.x, point.y))                  data.append('L %s %s ' % (point.x, point.y))
             i+=1  
696          # FIXME: Determine if path is closed          # FIXME: Determine if path is closed
697          if closed:          if closed:
698              data.append('Z')              data.append('Z')

Legend:
Removed from v.2413  
changed lines
  Added in v.2414

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26