1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 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 |
|
|
80 |
old_prop = None |
old_prop = None |
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) |
lc = layer.GetClassification() |
84 |
field = layer.classification.field |
field = lc.field |
85 |
|
|
86 |
if field is not None: |
if field is not None: |
87 |
record = layer.table.read_record(i) |
record = layer.table.read_record(i) |
93 |
# be null, at which point this call will |
# be null, at which point this call will |
94 |
# at least retreive the NullData |
# at least retreive the NullData |
95 |
# |
# |
96 |
prop = layer.classification.getProperties(value) |
prop = lc.GetClassData(value) |
97 |
|
|
98 |
if prop != old_prop: |
if prop != old_prop: |
99 |
old_prop = prop |
old_prop = prop |
100 |
|
|
101 |
if shapetype == SHAPETYPE_ARC: |
if shapetype == SHAPETYPE_ARC: |
102 |
fill = None |
fill = Color.None |
103 |
else: |
else: |
104 |
fill = prop['fill'] |
fill = prop.GetFill() |
105 |
|
|
106 |
if fill is None: |
if fill is Color.None: |
107 |
brush = wxTRANSPARENT_BRUSH |
brush = wxTRANSPARENT_BRUSH |
108 |
else: |
else: |
109 |
color = wxColour(fill.red * 255, |
color = wxColour(fill.red * 255, |
111 |
fill.blue * 255) |
fill.blue * 255) |
112 |
brush = wxBrush(color, wxSOLID) |
brush = wxBrush(color, wxSOLID) |
113 |
|
|
114 |
stroke = prop['stroke'] |
stroke = prop.GetStroke() |
115 |
stroke_width = prop['stroke_width'] |
stroke_width = prop.GetStrokeWidth() |
116 |
if stroke is None: |
if stroke is Color.None: |
117 |
pen = wxTRANSPARENT_PEN |
pen = wxTRANSPARENT_PEN |
118 |
else: |
else: |
119 |
color = wxColour(stroke.red * 255, |
color = wxColour(stroke.red * 255, |
250 |
if shapetype == SHAPETYPE_POINT: |
if shapetype == SHAPETYPE_POINT: |
251 |
self.draw_point_shape(layer, index) |
self.draw_point_shape(layer, index) |
252 |
else: |
else: |
253 |
raise TypeError("Unhandled shape type %s" % shapetype) |
raise TypeError(_("Unhandled shape type %s") % shapetype) |
254 |
|
|
255 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
256 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |