jonathan: thuban/Thuban/UI baserenderer.py, 1.15, 1.16 renderer.py, 1.55, 1.56

cvs@intevation.de cvs at intevation.de
Fri Jan 28 16:54:02 CET 2005


Author: jonathan

Update of /thubanrepository/thuban/Thuban/UI
In directory doto:/tmp/cvs-serv8849/Thuban/UI

Modified Files:
	baserenderer.py renderer.py 
Log Message:
Make layer's use_mask flag default to true. Support a bit array describing
the mask to use. Improve error handling in ProjectRasterFile (also addresses
RT #2947).


Index: baserenderer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/baserenderer.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- baserenderer.py	27 Jan 2005 14:19:41 -0000	1.15
+++ baserenderer.py	28 Jan 2005 15:54:00 -0000	1.16
@@ -484,13 +484,16 @@
         height = int(min(height, round(fmax[1] - fmin[1] + 1)))
 
         try:
+            options = 0
+            if layer.UseMask(): options = options | 1
+
             project_params = (layer.GetImageFilename(), in_proj, out_proj, 
                               (xmin, ymin, xmax, ymax), "", (width, height),
-                              layer.UseMask())
+                              options)
 
             data = (width, height, apply(ProjectRasterFile, project_params))
 
-        except (IOError, AttributeError, ValueError):
+        except (MemoryError, IOError, AttributeError, ValueError):
             # Why does this catch AttributeError and ValueError?
             # FIXME: The exception should be communicated to the user
             # better.
@@ -507,7 +510,9 @@
             (width, height, (image_data, mask_data))
         
         holding the image width, height, image data, and mask data.
-        mask_data may be None if a mask should not be used. Both kinds 
+        mask_data may be None if a mask should not be used. If 
+        format is 'RAW' the data will be RGB values and the mask
+        will be in XMB format. Otherwise, both kinds 
         of data are assumed to be in the format specified in format.
 
         The format parameter is a string with the name of the format.

Index: renderer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/renderer.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- renderer.py	27 Jan 2005 14:19:41 -0000	1.55
+++ renderer.py	28 Jan 2005 15:54:00 -0000	1.56
@@ -23,7 +23,7 @@
     wxBLACK_PEN, wxBLACK, wxSOLID, wxCROSS_HATCH, wxSWISS, wxNORMAL, \
     wxBitmapFromImage, wxImageFromStream, wxBITMAP_TYPE_BMP, \
     wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_TIF, \
-    wxBITMAP_TYPE_GIF, wxEmptyImage, wxMask
+    wxBITMAP_TYPE_GIF, wxEmptyImage, wxMask, wxBitmapFromBits
 
 from wxproj import draw_polygon_shape, draw_polygon_init
 
@@ -107,32 +107,25 @@
     def draw_raster_data(self, x,y, data, format = 'BMP'):
 
         mask = None
+
         if format == 'RAW':
             image = wxEmptyImage(data[0], data[1])
             image.SetData(data[2][0])
             if data[2][1] is not None:
-                mask = wxEmptyImage(data[0], data[1])
-                mask.SetData(data[2][1])
+                mask = wxBitmapFromBits(data[2][1], data[0], data[1], 1)
+                mask = wxMask(mask)
         else:
             stream = cStringIO.StringIO(data[2][0])
             image = wxImageFromStream(stream, raster_format_map[format])
             if data[2][1] is not None:
                 stream = cStringIO.StringIO(data[2][1])
                 mask = wxImageFromStream(stream, raster_format_map[format])
+                mask = wxMask(wxBitmapFromImage(mask, 1))
 
         bitmap = wxBitmapFromImage(image)
+        bitmap.SetMask(mask)
 
-        if mask is None:
-            self.dc.DrawBitmap(bitmap, int(round(x)), int(round(y)), False)
-        else:
-            # if we are given a mask object, try to pass it to SetMaskColour,
-            # otherwise assume it's a mask image
-            try:
-                bitmap.SetMask(wxMask(wxBitmapFromImage(mask, 1)))
-                self.dc.DrawBitmap(bitmap, int(round(x)), int(round(y)), True)
-            except (TypeError):
-                # implement using a mask image
-                raise NotImplementedError
+        self.dc.DrawBitmap(bitmap, int(round(x)), int(round(y)), True)
 
 
 class ScreenRenderer(MapRenderer):





More information about the Thuban-devel mailing list

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