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, \ |
65 |
scale = self.scale |
scale = self.scale |
66 |
offx, offy = self.offset |
offx, offy = self.offset |
67 |
|
|
|
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) |
|
|
|
|
68 |
map_proj = self.map.projection |
map_proj = self.map.projection |
69 |
layer_proj = layer.projection |
layer_proj = layer.projection |
70 |
|
|
71 |
shapetype = layer.ShapeType() |
shapetype = layer.ShapeType() |
72 |
|
|
73 |
if shapetype == SHAPETYPE_POLYGON: |
brush = wxTRANSPARENT_BRUSH |
74 |
for i in self.layer_ids(layer): |
pen = wxTRANSPARENT_PEN |
75 |
|
|
76 |
|
old_prop = None |
77 |
|
for i in self.layer_ids(layer): |
78 |
|
value = None |
79 |
|
shape = layer.Shape(i) |
80 |
|
field = layer.classification.field |
81 |
|
|
82 |
|
if field is not None: |
83 |
|
record = layer.table.read_record(i) |
84 |
|
if record is not None: |
85 |
|
value = record[field] |
86 |
|
|
87 |
|
# |
88 |
|
# if the above statements fail 'value' should |
89 |
|
# be null, at which point this call will |
90 |
|
# at least retreive the NullData |
91 |
|
# |
92 |
|
prop = layer.classification.getProperties(value) |
93 |
|
|
94 |
|
if prop != old_prop: |
95 |
|
old_prop = prop |
96 |
|
|
97 |
|
if shapetype == SHAPETYPE_ARC: |
98 |
|
fill = None |
99 |
|
else: |
100 |
|
fill = prop['fill'] |
101 |
|
|
102 |
|
if fill is None: |
103 |
|
brush = wxTRANSPARENT_BRUSH |
104 |
|
else: |
105 |
|
color = wxColour(fill.red * 255, |
106 |
|
fill.green * 255, |
107 |
|
fill.blue * 255) |
108 |
|
brush = wxBrush(color, wxSOLID) |
109 |
|
|
110 |
|
stroke = prop['stroke'] |
111 |
|
stroke_width = prop['stroke_width'] |
112 |
|
if stroke is None: |
113 |
|
pen = wxTRANSPARENT_PEN |
114 |
|
else: |
115 |
|
color = wxColour(stroke.red * 255, |
116 |
|
stroke.green * 255, |
117 |
|
stroke.blue * 255) |
118 |
|
pen = wxPen(color, stroke_width, wxSOLID) |
119 |
|
|
120 |
|
if shapetype == SHAPETYPE_POINT: |
121 |
|
self.dc.SetBrush(brush) |
122 |
|
self.dc.SetPen(pen) |
123 |
|
self.draw_point_shape(layer, i) |
124 |
|
else: |
125 |
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) |
|
126 |
|
|
127 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
128 |
"""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. |
246 |
if shapetype == SHAPETYPE_POINT: |
if shapetype == SHAPETYPE_POINT: |
247 |
self.draw_point_shape(layer, index) |
self.draw_point_shape(layer, index) |
248 |
else: |
else: |
249 |
raise TypeError("Unhandled shape type %s" % shapetype) |
raise TypeError(_("Unhandled shape type %s") % shapetype) |
250 |
|
|
251 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
252 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |