22 |
wxImageFromStream, wxBITMAP_TYPE_BMP |
wxImageFromStream, wxBITMAP_TYPE_BMP |
23 |
|
|
24 |
from wxproj import draw_polygon_shape, draw_polygon_init |
from wxproj import draw_polygon_shape, draw_polygon_init |
|
from gdalwarp import ProjectRasterFile |
|
25 |
|
|
26 |
from Thuban.UI.common import Color2wxColour |
from Thuban.UI.common import Color2wxColour |
27 |
from Thuban.UI.classifier import ClassDataPreviewer |
from Thuban.UI.classifier import ClassDataPreviewer |
36 |
from Thuban.Model.color import Color |
from Thuban.Model.color import Color |
37 |
import Thuban.Model.resource |
import Thuban.Model.resource |
38 |
|
|
39 |
|
if Thuban.Model.resource.has_gdal_support(): |
40 |
|
from gdalwarp import ProjectRasterFile |
41 |
|
|
42 |
class MapRenderer: |
class MapRenderer: |
43 |
|
|
44 |
"""Class to render a map onto a wxDC""" |
"""Class to render a map onto a wxDC""" |
85 |
# and only begin drawing layers once we have drawn it. |
# and only begin drawing layers once we have drawn it. |
86 |
# That way we avoid drawing layers that won't be seen. |
# That way we avoid drawing layers that won't be seen. |
87 |
# |
# |
88 |
for layer in map.Layers(): |
if Thuban.Model.resource.has_gdal_support(): |
89 |
if isinstance(layer, RasterLayer) and layer.Visible(): |
for layer in map.Layers(): |
90 |
seenRaster = False |
if isinstance(layer, RasterLayer) and layer.Visible(): |
91 |
break |
seenRaster = False |
92 |
|
break |
93 |
|
|
94 |
for layer in map.Layers(): |
for layer in map.Layers(): |
95 |
# if honor_visibility is true, only draw visible layers, |
# if honor_visibility is true, only draw visible layers, |
520 |
# Render title |
# Render title |
521 |
dc.DrawText(l.Title(), posx, posy) |
dc.DrawText(l.Title(), posx, posy) |
522 |
posy+=stepy |
posy+=stepy |
523 |
# Render classification |
if l.HasClassification(): |
524 |
clazz = l.GetClassification() |
# Render classification |
525 |
shapeType = l.ShapeType() |
clazz = l.GetClassification() |
526 |
for g in clazz: |
shapeType = l.ShapeType() |
527 |
if g.IsVisible(): |
for g in clazz: |
528 |
previewer.Draw(dc, |
if g.IsVisible(): |
529 |
wxRect(posx+dx, posy, iconwidth, iconheight), |
previewer.Draw(dc, |
530 |
g.GetProperties(), shapeType) |
wxRect(posx+dx, posy, |
531 |
dc.DrawText(g.GetDisplayText(), |
iconwidth, iconheight), |
532 |
posx+2*dx+iconwidth, posy) |
g.GetProperties(), shapeType) |
533 |
posy+=stepy |
dc.DrawText(g.GetDisplayText(), |
534 |
|
posx+2*dx+iconwidth, posy) |
535 |
|
posy+=stepy |
536 |
|
|
537 |
def render_scalebar(self, map): |
def render_scalebar(self, map): |
538 |
"""Render the scalebar.""" |
"""Render the scalebar.""" |