1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
|
# Jonathan Coles <[email protected]> |
5 |
# |
# |
6 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
7 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
14 |
|
|
15 |
from wxproj import draw_polygon_shape |
from wxproj import draw_polygon_shape |
16 |
|
|
17 |
|
from Thuban import _ |
18 |
|
|
19 |
from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
20 |
SHAPETYPE_POINT |
SHAPETYPE_POINT |
21 |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
22 |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
23 |
|
|
24 |
|
from Thuban.Model.classification import Classification |
25 |
|
from Thuban.Model.color import Color |
26 |
|
|
27 |
|
|
28 |
class MapRenderer: |
class MapRenderer: |
29 |
|
|
81 |
for i in self.layer_ids(layer): |
for i in self.layer_ids(layer): |
82 |
value = None |
value = None |
83 |
shape = layer.Shape(i) |
shape = layer.Shape(i) |
84 |
field = layer.classification.field |
lc = layer.GetClassification() |
85 |
|
field = lc.field |
86 |
|
|
87 |
if field is not None: |
if field is not None: |
88 |
record = layer.table.read_record(i) |
record = layer.table.read_record(i) |
94 |
# be null, at which point this call will |
# be null, at which point this call will |
95 |
# at least retreive the NullData |
# at least retreive the NullData |
96 |
# |
# |
97 |
prop = layer.classification.getProperties(value) |
prop = lc.GetProperties(value) |
98 |
|
|
99 |
if prop != old_prop: |
if prop != old_prop: |
100 |
old_prop = prop |
old_prop = prop |
101 |
|
|
102 |
if shapetype == SHAPETYPE_ARC: |
if shapetype == SHAPETYPE_ARC: |
103 |
fill = None |
fill = Color.None |
104 |
else: |
else: |
105 |
fill = prop['fill'] |
fill = prop.GetFill() |
106 |
|
|
107 |
if fill is None: |
if fill is Color.None: |
108 |
brush = wxTRANSPARENT_BRUSH |
brush = wxTRANSPARENT_BRUSH |
109 |
else: |
else: |
110 |
color = wxColour(fill.red * 255, |
color = wxColour(fill.red * 255, |
112 |
fill.blue * 255) |
fill.blue * 255) |
113 |
brush = wxBrush(color, wxSOLID) |
brush = wxBrush(color, wxSOLID) |
114 |
|
|
115 |
stroke = prop['stroke'] |
stroke = prop.GetStroke() |
116 |
stroke_width = prop['stroke_width'] |
stroke_width = prop.GetStrokeWidth() |
117 |
if stroke is None: |
if stroke is Color.None: |
118 |
pen = wxTRANSPARENT_PEN |
pen = wxTRANSPARENT_PEN |
119 |
else: |
else: |
120 |
color = wxColour(stroke.red * 255, |
color = wxColour(stroke.red * 255, |
251 |
if shapetype == SHAPETYPE_POINT: |
if shapetype == SHAPETYPE_POINT: |
252 |
self.draw_point_shape(layer, index) |
self.draw_point_shape(layer, index) |
253 |
else: |
else: |
254 |
raise TypeError("Unhandled shape type %s" % shapetype) |
raise TypeError(_("Unhandled shape type %s") % shapetype) |
255 |
|
|
256 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
257 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |