12 |
wxTRANSPARENT_PEN, wxTRANSPARENT_BRUSH, \ |
wxTRANSPARENT_PEN, wxTRANSPARENT_BRUSH, \ |
13 |
wxBLACK, wxSOLID, wxCROSS_HATCH, wxSWISS, wxNORMAL |
wxBLACK, wxSOLID, wxCROSS_HATCH, wxSWISS, wxNORMAL |
14 |
|
|
15 |
from wxproj import draw_polygon_shape |
from wxproj import draw_polygon_shape, draw_polygon_init |
16 |
|
|
17 |
from Thuban import _ |
from Thuban import _ |
18 |
from Thuban.UI.common import * |
from Thuban.UI.common import * |
85 |
lc = layer.GetClassification() |
lc = layer.GetClassification() |
86 |
field = lc.GetField() |
field = lc.GetField() |
87 |
|
|
88 |
defaultProps = lc.GetDefaultGroup().GetProperties() |
|
89 |
|
if shapetype != SHAPETYPE_POINT: |
90 |
|
polygon_render_param = self.polygon_render_param(layer) |
91 |
|
|
92 |
for i in self.layer_ids(layer): |
for i in self.layer_ids(layer): |
93 |
value = None |
value = None |
105 |
# be null, at which point this call will |
# be null, at which point this call will |
106 |
# at least retreive the NullData |
# at least retreive the NullData |
107 |
# |
# |
108 |
prop = lc.GetProperties(value) |
|
109 |
|
group = lc.FindGroup(value) |
110 |
|
|
111 |
|
#prop = lc.GetProperties(value) |
112 |
else: |
else: |
113 |
prop = defaultProps |
group = lc.GetDefaultGroup() |
114 |
|
|
115 |
|
|
116 |
|
if not group.IsVisible(): |
117 |
|
continue |
118 |
|
|
119 |
|
prop = group.GetProperties() |
120 |
|
|
121 |
# don't recreate new objects if they are the same as before |
# don't recreate new objects if they are the same as before |
122 |
if prop != old_prop: |
if prop != old_prop: |
123 |
old_prop = prop |
old_prop = prop |
124 |
|
|
125 |
if shapetype == SHAPETYPE_ARC: |
if shapetype == SHAPETYPE_ARC: |
126 |
fill = Color.None |
fill = Color.Transparent |
127 |
else: |
else: |
128 |
fill = prop.GetFill() |
fill = prop.GetFill() |
129 |
|
|
130 |
if fill is Color.None: |
|
131 |
|
if fill is Color.Transparent: |
132 |
brush = wxTRANSPARENT_BRUSH |
brush = wxTRANSPARENT_BRUSH |
133 |
else: |
else: |
134 |
color = Color2wxColour(fill) |
color = Color2wxColour(fill) |
135 |
brush = wxBrush(color, wxSOLID) |
brush = wxBrush(color, wxSOLID) |
136 |
|
|
137 |
stroke = prop.GetLineColor() |
stroke = prop.GetLineColor() |
138 |
stroke_width = prop.GetLineWidth() |
stroke_width = prop.GetLineWidth() |
139 |
if stroke is Color.None: |
if stroke is Color.Transparent: |
140 |
pen = wxTRANSPARENT_PEN |
pen = wxTRANSPARENT_PEN |
141 |
else: |
else: |
142 |
color = Color2wxColour(stroke) |
color = Color2wxColour(stroke) |
143 |
pen = wxPen(color, stroke_width, wxSOLID) |
pen = wxPen(color, stroke_width, wxSOLID) |
144 |
|
|
145 |
|
|
146 |
if shapetype == SHAPETYPE_POINT: |
if shapetype == SHAPETYPE_POINT: |
147 |
self.dc.SetBrush(brush) |
self.dc.SetBrush(brush) |
148 |
self.dc.SetPen(pen) |
self.dc.SetPen(pen) |
149 |
self.draw_point_shape(layer, i) |
self.draw_point_shape(layer, i) |
150 |
else: |
else: |
151 |
self.draw_polygon_shape(layer, i, pen, brush) |
self.draw_polygon_shape(polygon_render_param, i, pen, brush) |
152 |
|
|
153 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
154 |
"""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. |
155 |
|
|
156 |
The default implementation simply returns all ids in the layer. |
The default implementation simply returns all ids in the layer. |
157 |
Override in derived classes to be more precise. |
Override in derived classes to be more precise. |
158 |
""" |
""" |
159 |
return range(layer.NumShapes()) |
return range(layer.NumShapes()) |
160 |
|
|
161 |
def draw_polygon_shape(self, layer, index, pen, brush): |
def polygon_render_param(self, layer): |
162 |
offx, offy = self.offset |
"""Return the low-lever render parameter for the layer""" |
163 |
draw_polygon_shape(layer.shapefile.cobject(), index, |
offx, offy = self.offset |
164 |
self.dc, pen, brush, |
return draw_polygon_init(layer.shapefile, self.dc, |
165 |
self.map.projection, layer.projection, |
self.map.projection, |
166 |
self.scale, -self.scale, offx, offy) |
layer.projection, |
167 |
|
self.scale, -self.scale, |
168 |
|
offx, offy) |
169 |
|
|
170 |
|
def draw_polygon_shape(self, draw_polygon_info, index, pen, brush): |
171 |
|
draw_polygon_shape(draw_polygon_info, index, pen, brush) |
172 |
|
|
173 |
def projected_points(self, layer, index): |
def projected_points(self, layer, index): |
174 |
proj = self.map.projection |
proj = self.map.projection |
272 |
|
|
273 |
shapetype = layer.ShapeType() |
shapetype = layer.ShapeType() |
274 |
if shapetype == SHAPETYPE_POLYGON: |
if shapetype == SHAPETYPE_POLYGON: |
275 |
|
offx, offy = self.offset |
276 |
|
renderparam = self.polygon_render_param(layer) |
277 |
func = self.draw_polygon_shape |
func = self.draw_polygon_shape |
278 |
args = (pen, brush) |
args = (pen, brush) |
279 |
elif shapetype == SHAPETYPE_ARC: |
elif shapetype == SHAPETYPE_ARC: |
280 |
|
renderparam = self.polygon_render_param(layer) |
281 |
func = self.draw_polygon_shape |
func = self.draw_polygon_shape |
282 |
args = (pen, None) |
args = (pen, None) |
283 |
elif shapetype == SHAPETYPE_POINT: |
elif shapetype == SHAPETYPE_POINT: |
284 |
|
renderparam = layer |
285 |
self.dc.SetBrush(brush) |
self.dc.SetBrush(brush) |
286 |
self.dc.SetPen(pen) |
self.dc.SetPen(pen) |
287 |
func = self.draw_point_shape |
func = self.draw_point_shape |
290 |
raise TypeError(_("Unhandled shape type %s") % shapetype) |
raise TypeError(_("Unhandled shape type %s") % shapetype) |
291 |
|
|
292 |
for index in self.selected_shapes: |
for index in self.selected_shapes: |
293 |
func(layer, index, *args) |
func(renderparam, index, *args) |
294 |
|
|
295 |
|
|
296 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
297 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |