/[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

trunk/thuban/Thuban/UI/scalebar.py revision 912 by frank, Fri May 16 16:24:44 2003 UTC branches/WIP-pyshapelib-bramz/Thuban/UI/scalebar.py revision 2734 by bramz, Thu Mar 1 12:42:59 2007 UTC
# Line 9  __version__ = "$Revision$" Line 9  __version__ = "$Revision$"
9    
10  from Thuban import _  from Thuban import _
11  from Thuban.Model.scalebar import deriveInterval, roundInterval  from Thuban.Model.scalebar import deriveInterval, roundInterval
12    from Thuban.Model.proj import PROJ_UNITS_METERS
13    
14  from wxPython.wx import *  import wx
15    
16  class ScaleBar:  class ScaleBar:
17    
# Line 21  class ScaleBar: Line 22  class ScaleBar:
22          """Draw a scalebar on a given DC"""          """Draw a scalebar on a given DC"""
23    
24          # Only draw a legend if the corresponding map has a layer          # Only draw a legend if the corresponding map has a layer
25          if self.map is not None and len(self.map.layers) > 0 and scale > 0.0:          if self.map is not None \
26                and self.map.projection is not None \
27                and len(self.map.layers) > 0 \
28                and scale > 0.0:
29    
30                # We have a projection, draw the scalebar in bw
31                BlackPen = wx.BLACK_PEN
32                BlackBrush = wx.BLACK_BRUSH
33                BlackText = wx.BLACK
34    
             # If no projection is specified, the scale information _might_  
             # be reasonable. So gray out the scalebar in these cases.  
             if self.map.projection is None:  
                 BlackPen = wxGREY_PEN  
                 BlackBrush = wxGREY_BRUSH  
                 BlackText = wxColor(127,127,127)  
             else:  
                 BlackPen = wxBLACK_PEN  
                 BlackBrush = wxBLACK_BRUSH  
                 BlackText = wxBLACK  
                   
35              # Get the dimension              # Get the dimension
36              width, height = size              width, height = size
37              posx, posy    = position              posx, posy    = position
# Line 44  class ScaleBar: Line 42  class ScaleBar:
42              interval, unit = deriveInterval(width, scale)              interval, unit = deriveInterval(width, scale)
43              l2width, l2height = dc.GetTextExtent("%d %s"%(interval,unit))              l2width, l2height = dc.GetTextExtent("%d %s"%(interval,unit))
44              width = width - 4.0 - l1width/2.0 -l2width/2.0              width = width - 4.0 - l1width/2.0 -l2width/2.0
45            
46              # Having precised the width now the final interval can be calculated              # Having precised the width now the final interval can be calculated
47              interval, unit  = deriveInterval(width, scale)              interval, unit  = deriveInterval(width, scale)
48              interval, label = roundInterval(interval)              interval, label = roundInterval(interval)
49                
50              if interval > 0.0:              if interval > 0.0:
51                  # We draw 2 rectangles with half the width                  # We draw 2 rectangles with half the width
52                  if unit == 'km':                  if unit == 'km':
53                      width = int(interval*1000.0*scale/2)                      width = int(interval*1000.0*scale/2)
54                  else:                  else:
55                      width = int(interval*scale/2)                      width = int(interval*scale/2)
56                
57                  dc.SetPen(BlackPen)                  dc.SetPen(BlackPen)
58    
59                  brush = wxBrush(wxWHITE, wxSOLID)                  brush = wx.Brush(wx.WHITE, wx.SOLID)
60                  dc.SetBrush(brush)                  dc.SetBrush(brush)
61                  dc.DrawRectangle(posx+4,posy+2,width,8)                  dc.DrawRectangle(posx+4,posy+2,width,8)
62    

Legend:
Removed from v.912  
changed lines
  Added in v.2734

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26