24 |
from Thuban.UI.classifier import ClassDataPreviewer |
from Thuban.UI.classifier import ClassDataPreviewer |
25 |
from Thuban.UI.scalebar import ScaleBar |
from Thuban.UI.scalebar import ScaleBar |
26 |
|
|
27 |
from Thuban.Model.data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT |
from Thuban.Model.data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
28 |
|
SHAPETYPE_POINT, RAW_SHAPEFILE |
29 |
|
|
30 |
from Thuban.Model.color import Transparent |
from Thuban.Model.color import Transparent |
31 |
import Thuban.Model.resource |
import Thuban.Model.resource |
58 |
def low_level_renderer(self, layer): |
def low_level_renderer(self, layer): |
59 |
"""Override inherited method to provide more efficient renderers |
"""Override inherited method to provide more efficient renderers |
60 |
|
|
61 |
For point shapes, return self.draw_point_shape and layer just as |
If the underlying data format is not a shapefile or the layer |
62 |
the base class method. For arc and polygon use the more |
contains points shapes, simply use what the inherited method |
63 |
efficient wxproj.draw_polygon_shape and its corresponding |
returns. |
64 |
parameter created with wxproj.draw_polygon_init. |
|
65 |
|
Otherwise, i.e. for arc and polygon use the more efficient |
66 |
|
wxproj.draw_polygon_shape and its corresponding parameter |
67 |
|
created with wxproj.draw_polygon_init. |
68 |
""" |
""" |
69 |
shapetype = layer.ShapeType() |
if (layer.ShapeStore().RawShapeFormat() == RAW_SHAPEFILE |
70 |
if shapetype == SHAPETYPE_POINT: |
and layer.ShapeType() in (SHAPETYPE_ARC, SHAPETYPE_POLYGON)): |
|
func = self.draw_point_shape |
|
|
param = layer |
|
|
else: |
|
71 |
offx, offy = self.offset |
offx, offy = self.offset |
72 |
param = draw_polygon_init(layer.ShapeStore().Shapefile(), self.dc, |
return (True, draw_polygon_shape, |
73 |
self.map.projection, |
draw_polygon_init(layer.ShapeStore().Shapefile(), |
74 |
|
self.dc, self.map.projection, |
75 |
layer.projection, |
layer.projection, |
76 |
self.scale, -self.scale, |
self.scale, -self.scale, offx, offy)) |
77 |
offx, offy) |
else: |
78 |
func = draw_polygon_shape |
return BaseRenderer.low_level_renderer(self, layer) |
|
return func, param |
|
79 |
|
|
80 |
def label_font(self): |
def label_font(self): |
81 |
return wxFont(self.resolution * 10, wxSWISS, wxNORMAL, wxNORMAL) |
return wxFont(self.resolution * 10, wxSWISS, wxNORMAL, wxNORMAL) |
112 |
brush = wxBrush(wxBLACK, wxCROSS_HATCH) |
brush = wxBrush(wxBLACK, wxCROSS_HATCH) |
113 |
|
|
114 |
shapetype = layer.ShapeType() |
shapetype = layer.ShapeType() |
115 |
func, param = self.low_level_renderer(layer) |
useraw, func, param = self.low_level_renderer(layer) |
116 |
args = (pen, brush) |
args = (pen, brush) |
117 |
for index in self.selected_shapes: |
for index in self.selected_shapes: |
118 |
func(param, index, *args) |
shape = layer.Shape(index) |
119 |
|
if useraw: |
120 |
|
data = shape.RawData() |
121 |
|
else: |
122 |
|
data = shape.Points() |
123 |
|
func(param, data, *args) |
124 |
|
|
125 |
def layer_ids(self, layer): |
def layer_shapes(self, layer): |
126 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |
127 |
|
|
128 |
Call the layer's ShapesInRegion method to determine the ids so |
Call the layer's ShapesInRegion method to determine the ids so |
269 |
# Render the legend |
# Render the legend |
270 |
dc.SetTextForeground(wxBLACK) |
dc.SetTextForeground(wxBLACK) |
271 |
if map.HasLayers(): |
if map.HasLayers(): |
272 |
layers = map.Layers() |
layers = map.Layers()[:] |
273 |
layers.reverse() |
layers.reverse() |
274 |
for l in layers: |
for l in layers: |
275 |
if l.Visible(): |
if l.Visible(): |