/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/scalebar.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/scalebar.py

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

revision 871 by frank, Fri May 9 08:33:29 2003 UTC revision 1240 by frank, Thu Jun 19 09:25:31 2003 UTC
# Line 17  class ScaleBar: Line 17  class ScaleBar:
17      def __init__(self, map):      def __init__(self, map):
18          self.map = map          self.map = map
19    
20      def DrawScalebar(self, scale, dc):      def DrawScaleBar(self, scale, dc, position, size):
21          """Draw a scalebar on a given DC"""          """Draw a scalebar on a given DC"""
22    
23          # Only draw a legend if the corresponding map has a layer          # Only draw a legend if the corresponding map has a layer
# Line 30  class ScaleBar: Line 30  class ScaleBar:
30                  BlackBrush = wxGREY_BRUSH                  BlackBrush = wxGREY_BRUSH
31                  BlackText = wxColor(127,127,127)                  BlackText = wxColor(127,127,127)
32              else:              else:
33                    params = {}
34                    # For geographic projection we have to convert the scale from
35                    # Unit DD to meters.
36                    for p in self.map.projection.params:
37                        key, value = p.split('=')
38                        params[key] = value
39                    if params['proj'] == 'latlong':
40                        scale = scale * 0.017453 / 1000.0
41                    # We have a projection, draw the scalebar in bw
42                  BlackPen = wxBLACK_PEN                  BlackPen = wxBLACK_PEN
43                  BlackBrush = wxBLACK_BRUSH                  BlackBrush = wxBLACK_BRUSH
44                  BlackText = wxBLACK                  BlackText = wxBLACK
45                                    
46              # Get the dimension              # Get the dimension
47              width, height = dc.GetSizeTuple()              width, height = size
48                posx, posy    = position
49              l1width, l1height = dc.GetTextExtent("%d"%0)              l1width, l1height = dc.GetTextExtent("%d"%0)
50    
51              # Make a first guess for the interval (to get the size we have              # Make a first guess for the interval (to get the size we have
# Line 59  class ScaleBar: Line 69  class ScaleBar:
69    
70                  brush = wxBrush(wxWHITE, wxSOLID)                  brush = wxBrush(wxWHITE, wxSOLID)
71                  dc.SetBrush(brush)                  dc.SetBrush(brush)
72                  dc.DrawRectangle(4,2,width,8)                  dc.DrawRectangle(posx+4,posy+2,width,8)
73    
74                  dc.SetBrush(BlackBrush)                  dc.SetBrush(BlackBrush)
75                  dc.DrawRectangle(width+4,2,width,8)                  dc.DrawRectangle(posx+width+4,posy+2,width,8)
76    
77                  dc.SetTextForeground(BlackText)                  dc.SetTextForeground(BlackText)
78                  dc.DrawText("%d"%0, 4 - l1width/2, 12)                  dc.DrawText("%d"%0, posx+ 4 - l1width/2, posy+12)
79    
80                  l2width, l2height = dc.GetTextExtent("%s %s"%(label, unit))                  l2width, l2height = dc.GetTextExtent("%s %s"%(label, unit))
81                  dc.DrawText("%s %s"%(interval, unit), 2*width+4 - l2width/2, 12)                  dc.DrawText("%s %s"%(interval, unit), posx+ 2*width+4 - l2width/2, posy + 12)
82    

Legend:
Removed from v.871  
changed lines
  Added in v.1240

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26