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 * |
from wxPython.wx import * |
15 |
|
|
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 |
# If no projection is specified, the scale information _might_ |
and len(self.map.layers) > 0 \ |
28 |
# be reasonable. So gray out the scalebar in these cases. |
and scale > 0.0: |
29 |
if self.map.projection is None: |
|
30 |
BlackPen = wxGREY_PEN |
# We have a projection, draw the scalebar in bw |
31 |
BlackBrush = wxGREY_BRUSH |
BlackPen = wxBLACK_PEN |
32 |
BlackText = wxColor(127,127,127) |
BlackBrush = wxBLACK_BRUSH |
33 |
else: |
BlackText = wxBLACK |
|
params = {} |
|
|
# For geographic projection we have to convert the scale from |
|
|
# Unit DD to meters. |
|
|
for p in self.map.projection.params: |
|
|
key, value = p.split('=') |
|
|
params[key] = value |
|
|
if params['proj'] == 'latlong': |
|
|
scale = scale * 0.017453 / 1000.0 |
|
|
# We have a projection, draw the scalebar in bw |
|
|
BlackPen = wxBLACK_PEN |
|
|
BlackBrush = wxBLACK_BRUSH |
|
|
BlackText = wxBLACK |
|
34 |
|
|
35 |
# Get the dimension |
# Get the dimension |
36 |
width, height = size |
width, height = size |