jonathan: thuban/Thuban/Model layer.py,1.62,1.63

cvs@intevation.de cvs at intevation.de
Wed Feb 16 22:14:49 CET 2005


Author: jonathan

Update of /thubanrepository/thuban/Thuban/Model
In directory doto:/tmp/cvs-serv7505/Thuban/Model

Modified Files:
	layer.py 
Log Message:
Further wxPython 2.5 changes using patches from Daniel Calvelo Aros
so that that wxproj doesn't crash. Added GUI support for selecting
alpha channel (opacity can't be selected yet).


Index: layer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/layer.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- layer.py	28 Jan 2005 15:54:00 -0000	1.62
+++ layer.py	16 Feb 2005 21:14:47 -0000	1.63
@@ -344,6 +344,10 @@
 
 class RasterLayer(BaseLayer):
 
+    MASK_NONE  = 0
+    MASK_BIT   = 1
+    MASK_ALPHA = 2
+
     def __init__(self, title, filename, projection = None, visible = True):
         """Initialize the Raster Layer.
 
@@ -367,7 +371,8 @@
 
         self.bbox = -1
 
-        self.use_mask = True
+        self.mask_type = self.MASK_BIT
+        self.alpha_opacity = 1
 
         self.image_info = None
 
@@ -458,18 +463,44 @@
     def GetImageFilename(self):
         return self.filename
 
-    def UseMask(self):
+    def MaskType(self):
         """Return True if the mask should be used when rendering the layer."""
-        return self.use_mask
+        return self.mask_type
 
-    def SetUseMask(self, use):
-        """Set whether to use a mask when render the image.
+    def SetMaskType(self, type):
+        """Set the type of mask to use.
+
+        type can be one of MASK_NONE, MASK_BIT, MASK_ALPHA
 
         If the state changes, a LAYER_CHANGED message is sent.
         """
-        if use != self.use_mask: 
-            self.use_mask = use
+        if type not in (self.MASK_NONE, self.MASK_BIT, self.MASK_ALPHA):
+            raise ValueError("type is invalid")
+
+        if type != self.mask_type: 
+            self.mask_type = type
             self.changed(LAYER_CHANGED, self)
+
+    def AlphaOpacity(self):
+        """Return the level of opacity used in alpha blending, or None
+        if mask type is not MASK_ALPHA.
+        """
+        if self.mask_type == self.MASK_ALPHA:
+            return self.alpha_opacity
+        else:
+            return None
+
+    def SetAlphaOpacity(self, op):
+        """Set the level of alpha opacity. 
+
+        0 <= op <= 1.
+
+        The layer is fully opaque when op = 1.
+        """
+        if not (0 <= op <= 1):
+            raise ValueError("op out of range")
+
+        self.alpha_opacity = op
 
     def ImageInfo(self):
         return self.image_info





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)