348 |
MASK_BIT = 1 |
MASK_BIT = 1 |
349 |
MASK_ALPHA = 2 |
MASK_ALPHA = 2 |
350 |
|
|
351 |
def __init__(self, title, filename, projection = None, visible = True): |
def __init__(self, title, filename, projection = None, |
352 |
|
visible = True, opacity = 1, masktype = MASK_BIT): |
353 |
"""Initialize the Raster Layer. |
"""Initialize the Raster Layer. |
354 |
|
|
355 |
title -- title for the layer. |
title -- title for the layer. |
372 |
|
|
373 |
self.bbox = -1 |
self.bbox = -1 |
374 |
|
|
375 |
self.mask_type = self.MASK_BIT |
self.mask_type = masktype |
376 |
self.alpha_opacity = 1 |
self.opacity = opacity |
377 |
|
|
378 |
self.image_info = None |
self.image_info = None |
379 |
|
|
482 |
self.mask_type = type |
self.mask_type = type |
483 |
self.changed(LAYER_CHANGED, self) |
self.changed(LAYER_CHANGED, self) |
484 |
|
|
485 |
def AlphaOpacity(self): |
def Opacity(self): |
486 |
"""Return the level of opacity used in alpha blending, or None |
"""Return the level of opacity used in alpha blending. |
|
if mask type is not MASK_ALPHA. |
|
487 |
""" |
""" |
488 |
if self.mask_type == self.MASK_ALPHA: |
return self.opacity |
|
return self.alpha_opacity |
|
|
else: |
|
|
return None |
|
489 |
|
|
490 |
def SetAlphaOpacity(self, op): |
def SetOpacity(self, op): |
491 |
"""Set the level of alpha opacity. |
"""Set the level of alpha opacity. |
492 |
|
|
493 |
0 <= op <= 1. |
0 <= op <= 1. |
497 |
if not (0 <= op <= 1): |
if not (0 <= op <= 1): |
498 |
raise ValueError("op out of range") |
raise ValueError("op out of range") |
499 |
|
|
500 |
self.alpha_opacity = op |
if op != self.opacity: |
501 |
|
self.opacity = op |
502 |
|
self.changed(LAYER_CHANGED, self) |
503 |
|
|
504 |
def ImageInfo(self): |
def ImageInfo(self): |
505 |
return self.image_info |
return self.image_info |