454 |
|
|
455 |
# True -- warp the image to the size of the whole screen |
# True -- warp the image to the size of the whole screen |
456 |
# False -- only use the bound box of the layer (currently inaccurate) |
# False -- only use the bound box of the layer (currently inaccurate) |
457 |
if True: |
if True: |
458 |
#if False: |
#if False: |
459 |
pmin = [0,height] |
pmin = [0,height] |
460 |
pmax = [width, 0] |
pmax = [width, 0] |
466 |
#print bb |
#print bb |
467 |
#print pmin, pmax |
#print pmin, pmax |
468 |
|
|
469 |
fmin = [max(0, min(pmin[0], pmax[0])) - offx, |
fmin = [max(0, min(pmin[0], pmax[0])) - offx, |
470 |
offy - min(height, max(pmin[1], pmax[1]))] |
offy - min(height, max(pmin[1], pmax[1]))] |
471 |
|
|
472 |
fmax = [min(width, max(pmin[0], pmax[0])) - offx, |
fmax = [min(width, max(pmin[0], pmax[0])) - offx, |
473 |
offy - max(0, min(pmin[1], pmax[1]))] |
offy - max(0, min(pmin[1], pmax[1]))] |
474 |
|
|
475 |
xmin = fmin[0]/self.scale |
xmin = fmin[0]/self.scale |
483 |
options = 0 |
options = 0 |
484 |
options = options | layer.MaskType() |
options = options | layer.MaskType() |
485 |
|
|
486 |
img_data = self.projected_raster_layer(layer, in_proj, out_proj, |
img_data = self.projected_raster_layer(layer, in_proj, out_proj, |
487 |
(xmin,ymin,xmax,ymax), [0,0], (width, height), options) |
(xmin,ymin,xmax,ymax), [0,0], (width, height), options) |
488 |
|
|
489 |
if img_data is not None: |
if img_data is not None: |
490 |
data = (width, height, img_data) |
data = (width, height, img_data) |
491 |
self.draw_raster_data(fmin[0]+offx, offy-fmax[1], data, "RAW") |
self.draw_raster_data(fmin[0]+offx, offy-fmax[1], |
492 |
|
data, format="RAW", opacity=layer.Opacity()) |
493 |
data = None |
data = None |
494 |
|
|
495 |
def projected_raster_layer(self, layer, srcProj, dstProj, extents, |
def projected_raster_layer(self, layer, srcProj, dstProj, extents, |
523 |
|
|
524 |
raise NotImplementedError |
raise NotImplementedError |
525 |
|
|
526 |
def draw_raster_data(self, x, y, data, format="BMP"): |
def draw_raster_data(self, x, y, data, format="BMP", opacity=1.0): |
527 |
"""Draw the raster image in data onto the DC with the top |
"""Draw a raster image held in data onto the DC with the top |
528 |
left corner at (x,y) |
left corner at (x,y) |
529 |
|
|
530 |
The raster image data is a tuple of the form |
The raster image data is a tuple of the form |
541 |
The following format names should be used: |
The following format names should be used: |
542 |
|
|
543 |
'RAW' -- an array of RGB values (len=3*width*height) |
'RAW' -- an array of RGB values (len=3*width*height) |
544 |
|
'PNG' -- Portable Network Graphic (transparency supported) |
545 |
'BMP' -- Windows Bitmap |
'BMP' -- Windows Bitmap |
546 |
|
'TIFF' -- Tagged Image File Format |
547 |
|
'GIF' -- GIF Image |
548 |
'JPEG' -- JPEG Image |
'JPEG' -- JPEG Image |
549 |
|
|
550 |
The default format is 'BMP'. |
The default format is 'BMP'. |
583 |
x, y = forward(x, y) |
x, y = forward(x, y) |
584 |
x = int(round(x * scale + offx)) |
x = int(round(x * scale + offx)) |
585 |
y = int(round(-y * scale + offy)) |
y = int(round(-y * scale + offy)) |
586 |
width, height = self.dc.GetTextExtent(text) |
width, height = self.dc.GetTextExtent(text.decode('iso-8859-1')) |
587 |
if label.halign == ALIGN_LEFT: |
if label.halign == ALIGN_LEFT: |
588 |
# nothing to be done |
# nothing to be done |
589 |
pass |
pass |
598 |
y = y - height |
y = y - height |
599 |
elif label.valign == ALIGN_CENTER: |
elif label.valign == ALIGN_CENTER: |
600 |
y = y - height/2 |
y = y - height/2 |
601 |
self.dc.DrawText(text, x, y) |
self.dc.DrawText(text.decode('iso-8859-1'), x, y) |