13 |
|
|
14 |
from wxproj import draw_polygon_shape |
from wxproj import draw_polygon_shape |
15 |
|
|
16 |
|
from Thuban import _ |
17 |
|
|
18 |
from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
19 |
SHAPETYPE_POINT |
SHAPETYPE_POINT |
20 |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
21 |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
22 |
|
|
23 |
|
from Thuban.Model.classification import Classification |
24 |
|
|
25 |
|
|
26 |
class MapRenderer: |
class MapRenderer: |
27 |
|
|
67 |
scale = self.scale |
scale = self.scale |
68 |
offx, offy = self.offset |
offx, offy = self.offset |
69 |
|
|
|
fill = layer.fill |
|
|
if fill is None: |
|
|
brush = wxTRANSPARENT_BRUSH |
|
|
else: |
|
|
color = wxColour(fill.red * 255, |
|
|
fill.green * 255, |
|
|
fill.blue * 255) |
|
|
brush = wxBrush(color, wxSOLID) |
|
|
stroke = layer.stroke |
|
|
stroke_width = layer.stroke_width |
|
|
if stroke is None: |
|
|
pen = wxTRANSPARENT_PEN |
|
|
else: |
|
|
color = wxColour(stroke.red * 255, |
|
|
stroke.green * 255, |
|
|
stroke.blue * 255) |
|
|
pen = wxPen(color, stroke_width, wxSOLID) |
|
|
|
|
70 |
map_proj = self.map.projection |
map_proj = self.map.projection |
71 |
layer_proj = layer.projection |
layer_proj = layer.projection |
72 |
|
|
73 |
shapetype = layer.ShapeType() |
shapetype = layer.ShapeType() |
74 |
|
|
75 |
if shapetype == SHAPETYPE_POLYGON: |
brush = wxTRANSPARENT_BRUSH |
76 |
for i in self.layer_ids(layer): |
pen = wxTRANSPARENT_PEN |
77 |
|
|
78 |
|
old_prop = None |
79 |
|
for i in self.layer_ids(layer): |
80 |
|
value = None |
81 |
|
shape = layer.Shape(i) |
82 |
|
lc = layer.classification |
83 |
|
field = lc.field |
84 |
|
|
85 |
|
if field is not None: |
86 |
|
record = layer.table.read_record(i) |
87 |
|
if record is not None: |
88 |
|
value = record[field] |
89 |
|
|
90 |
|
# |
91 |
|
# if the above statements fail 'value' should |
92 |
|
# be null, at which point this call will |
93 |
|
# at least retreive the NullData |
94 |
|
# |
95 |
|
prop = lc.GetProperties(value) |
96 |
|
|
97 |
|
if prop != old_prop: |
98 |
|
old_prop = prop |
99 |
|
|
100 |
|
if shapetype == SHAPETYPE_ARC: |
101 |
|
fill = None |
102 |
|
else: |
103 |
|
fill = prop.GetFill() |
104 |
|
|
105 |
|
if fill is None: |
106 |
|
brush = wxTRANSPARENT_BRUSH |
107 |
|
else: |
108 |
|
color = wxColour(fill.red * 255, |
109 |
|
fill.green * 255, |
110 |
|
fill.blue * 255) |
111 |
|
brush = wxBrush(color, wxSOLID) |
112 |
|
|
113 |
|
stroke = prop.GetStroke() |
114 |
|
stroke_width = prop.GetStrokeWidth() |
115 |
|
if stroke is None: |
116 |
|
pen = wxTRANSPARENT_PEN |
117 |
|
else: |
118 |
|
color = wxColour(stroke.red * 255, |
119 |
|
stroke.green * 255, |
120 |
|
stroke.blue * 255) |
121 |
|
pen = wxPen(color, stroke_width, wxSOLID) |
122 |
|
|
123 |
|
if shapetype == SHAPETYPE_POINT: |
124 |
|
self.dc.SetBrush(brush) |
125 |
|
self.dc.SetPen(pen) |
126 |
|
self.draw_point_shape(layer, i) |
127 |
|
else: |
128 |
self.draw_polygon_shape(layer, i, pen, brush) |
self.draw_polygon_shape(layer, i, pen, brush) |
|
elif shapetype == SHAPETYPE_ARC: |
|
|
for i in self.layer_ids(layer): |
|
|
self.draw_polygon_shape(layer, i, pen, None) |
|
|
else: |
|
|
self.dc.SetBrush(brush) |
|
|
self.dc.SetPen(pen) |
|
|
if shapetype == SHAPETYPE_ARC: |
|
|
f = self.draw_arc_shape |
|
|
elif shapetype == SHAPETYPE_POINT: |
|
|
f = self.draw_point_shape |
|
|
for i in self.layer_ids(layer): |
|
|
f(layer, i) |
|
129 |
|
|
130 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
131 |
"""Return the shape ids of the given layer that have to be drawn. |
"""Return the shape ids of the given layer that have to be drawn. |
241 |
index = self.selected_shape |
index = self.selected_shape |
242 |
if shapetype == SHAPETYPE_POLYGON: |
if shapetype == SHAPETYPE_POLYGON: |
243 |
self.draw_polygon_shape(layer, index, pen, brush) |
self.draw_polygon_shape(layer, index, pen, brush) |
244 |
|
elif shapetype == SHAPETYPE_ARC: |
245 |
|
self.draw_polygon_shape(layer, index, pen, None) |
246 |
else: |
else: |
247 |
self.dc.SetBrush(brush) |
self.dc.SetBrush(brush) |
248 |
self.dc.SetPen(pen) |
self.dc.SetPen(pen) |
249 |
if shapetype == SHAPETYPE_ARC: |
if shapetype == SHAPETYPE_POINT: |
250 |
f = self.draw_arc_shape |
self.draw_point_shape(layer, index) |
251 |
elif shapetype == SHAPETYPE_POINT: |
else: |
252 |
f = self.draw_point_shape |
raise TypeError(_("Unhandled shape type %s") % shapetype) |
|
f(layer, index) |
|
253 |
|
|
254 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
255 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |