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 * |
25 |
from Thuban.Model.classification import Classification |
from Thuban.Model.classification import Classification |
26 |
from Thuban.Model.color import Color |
from Thuban.Model.color import Color |
27 |
|
|
28 |
|
import time |
29 |
|
|
30 |
|
|
31 |
class MapRenderer: |
class MapRenderer: |
32 |
|
|
87 |
lc = layer.GetClassification() |
lc = layer.GetClassification() |
88 |
field = lc.GetField() |
field = lc.GetField() |
89 |
|
|
90 |
|
#print "drawing layer: ", layer.Title(), |
91 |
|
#start = time.clock() |
92 |
|
#count = 0 |
93 |
|
|
94 |
|
if shapetype != SHAPETYPE_POINT: |
95 |
|
offx, offy = self.offset |
96 |
|
draw_polygon_init(layer.shapefile.cobject(), |
97 |
|
self.dc, |
98 |
|
self.map.projection, layer.projection, |
99 |
|
self.scale, -self.scale, offx, offy) |
100 |
|
|
101 |
for i in self.layer_ids(layer): |
for i in self.layer_ids(layer): |
102 |
value = None |
value = None |
103 |
|
|
121 |
else: |
else: |
122 |
group = lc.GetDefaultGroup() |
group = lc.GetDefaultGroup() |
123 |
|
|
|
prop = group.GetProperties() |
|
124 |
|
|
125 |
if not group.IsVisible(): |
if not group.IsVisible(): |
126 |
continue |
continue |
127 |
|
|
128 |
|
prop = group.GetProperties() |
129 |
|
|
130 |
# don't recreate new objects if they are the same as before |
# don't recreate new objects if they are the same as before |
131 |
if prop != old_prop: |
if prop != old_prop: |
132 |
old_prop = prop |
old_prop = prop |
135 |
fill = Color.Transparent |
fill = Color.Transparent |
136 |
else: |
else: |
137 |
fill = prop.GetFill() |
fill = prop.GetFill() |
138 |
|
|
139 |
|
|
140 |
if fill is Color.Transparent: |
if fill is Color.Transparent: |
141 |
brush = wxTRANSPARENT_BRUSH |
brush = wxTRANSPARENT_BRUSH |
150 |
else: |
else: |
151 |
color = Color2wxColour(stroke) |
color = Color2wxColour(stroke) |
152 |
pen = wxPen(color, stroke_width, wxSOLID) |
pen = wxPen(color, stroke_width, wxSOLID) |
153 |
|
|
|
if shapetype == SHAPETYPE_POINT: |
|
154 |
self.dc.SetBrush(brush) |
self.dc.SetBrush(brush) |
155 |
self.dc.SetPen(pen) |
self.dc.SetPen(pen) |
156 |
|
|
157 |
|
if shapetype == SHAPETYPE_POINT: |
158 |
self.draw_point_shape(layer, i) |
self.draw_point_shape(layer, i) |
159 |
else: |
else: |
160 |
self.draw_polygon_shape(layer, i, pen, brush) |
self.draw_polygon_shape(layer, i, pen, brush) |
161 |
|
|
162 |
|
#count += 1 |
163 |
|
|
164 |
|
#end = time.clock() |
165 |
|
#print (end-start), "seconds -- ", count |
166 |
|
|
167 |
|
|
168 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
169 |
"""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. |
170 |
|
|
174 |
return range(layer.NumShapes()) |
return range(layer.NumShapes()) |
175 |
|
|
176 |
def draw_polygon_shape(self, layer, index, pen, brush): |
def draw_polygon_shape(self, layer, index, pen, brush): |
177 |
offx, offy = self.offset |
draw_polygon_shape(index, pen, brush) |
|
draw_polygon_shape(layer.shapefile.cobject(), index, |
|
|
self.dc, pen, brush, |
|
|
self.map.projection, layer.projection, |
|
|
self.scale, -self.scale, offx, offy) |
|
178 |
|
|
179 |
def projected_points(self, layer, index): |
def projected_points(self, layer, index): |
180 |
proj = self.map.projection |
proj = self.map.projection |