jonathan: thuban/Thuban/UI baserenderer.py, 1.16, 1.17 legend.py, 1.38, 1.39 rasterlayerproperties.py, 1.1, 1.2 renderer.py, 1.56, 1.57

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


Author: jonathan

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

Modified Files:
	baserenderer.py legend.py rasterlayerproperties.py renderer.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: baserenderer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/baserenderer.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- baserenderer.py	28 Jan 2005 15:54:00 -0000	1.16
+++ baserenderer.py	16 Feb 2005 21:14:47 -0000	1.17
@@ -485,7 +485,7 @@
 
         try:
             options = 0
-            if layer.UseMask(): options = options | 1
+            options = options | layer.MaskType()
 
             project_params = (layer.GetImageFilename(), in_proj, out_proj, 
                               (xmin, ymin, xmax, ymax), "", (width, height),
@@ -507,10 +507,11 @@
         left corner at (x,y)
 
         The raster image data is a tuple of the form
-            (width, height, (image_data, mask_data))
+            (width, height, (image_data, mask_data, alpha_data))
         
-        holding the image width, height, image data, and mask data.
-        mask_data may be None if a mask should not be used. If 
+        holding the image width, height, image data, mask data, and alpha data.
+        mask_data may be None if a mask should not be used. alpha_data may
+        also be None. If both are not None mask overrides alpha. 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.

Index: legend.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/legend.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- legend.py	8 Feb 2005 20:25:22 -0000	1.38
+++ legend.py	16 Feb 2005 21:14:47 -0000	1.39
@@ -547,6 +547,7 @@
         self.Thaw()
 
     def __FillTreeLayer(self, pid):
+
         layer = self.GetPyData(pid)
 
         self.Freeze()
@@ -569,8 +570,9 @@
                     bmp = self.__BuildGroupImage(g, shapeType)
 
                     if bmp is None:
-                        self.SetItemImage(id, -1)
-                        self.SetItemSelectedImage(id, -1)
+                        self.SetItemImage(id, -1, wxTreeItemIcon_Normal)
+                        self.SetItemImage(id, -1, wxTreeItemIcon_Selected)
+                        #self.SetItemSelectedImage(id, -1)
                     else:
                         if self.availImgListIndices:
                             i = self.availImgListIndices.pop(0)
@@ -578,8 +580,9 @@
                         else:
                             i = self.image_list.Add(bmp)
 
-                        self.SetItemImage(id, i)
-                        self.SetItemSelectedImage(id, i)
+                        self.SetItemImage(id, i, wxTreeItemIcon_Normal)
+                        self.SetItemImage(id, i, wxTreeItemIcon_Selected)
+                        #self.SetItemlectedImage(id, i)
 
         self.Thaw()
 

Index: rasterlayerproperties.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/rasterlayerproperties.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rasterlayerproperties.py	27 Jan 2005 14:19:41 -0000	1.1
+++ rasterlayerproperties.py	16 Feb 2005 21:14:47 -0000	1.2
@@ -17,13 +17,15 @@
 from Thuban.UI.layerproperties import LayerProperties
 from Thuban.Model.resource import has_gdal_support, gdal_support_status
 
+from Thuban.version import versions
+
 class RasterLayerProperties(LayerProperties):
 
     def __init__(self, parent, name, layer, *args, **kw):
         LayerProperties.__init__(self, parent, name, layer)
 
         self.old_state = {}
-        self.old_state["use_mask"] = layer.UseMask()
+        self.old_state["mask_type"] = layer.MaskType()
 
         LayerProperties.dialog_layout(self)
 
@@ -79,13 +81,22 @@
 
         maskBox = wxBoxSizer(wxHORIZONTAL)
 
-        self.maskCB = wxCheckBox(panel, -1, _("Use Mask"))
-        maskBox.Add(self.maskCB, 0, wxRIGHT, 10)
+        if versions['wxPython-tuple'] < (2,5,3):
+            choices = ["None", "Bitmap", 
+                       "Alpha (Not support by wxPython %s)" % \
+                       versions['wxPython']]
+        else:
+            choices = ["None", "Bitmap", "Alpha"]
+
+        self.maskRadioBox = wxRadioBox(panel, -1, _("Mask Type"), 
+                            choices=choices)
+        #self.maskCB = wxCheckBox(panel, -1, _("Use Mask"))
+        maskBox.Add(self.maskRadioBox, 0, wxRIGHT, 10)
 
         rasterBox.Add(maskBox, 0, wxALL, 4)
         panelBox.Add(rasterBox, 1, wxGROW | wxALL, 4)
 
-        self.maskCB.SetValue(self.old_state["use_mask"])
+        self.maskRadioBox.SetSelection(self.old_state["mask_type"])
 
     def OnTry(self, event):
         self.set_state()
@@ -95,9 +106,9 @@
             self.Close()
 
     def OnRevert(self, event):
-        self.maskCB.SetValue(self.old_state["use_mask"])
+        self.maskRadioBox.SetSelection(self.old_state["mask_type"])
         self.set_state()
 
     def set_state(self):
-        self.layer.SetUseMask(self.maskCB.GetValue() == 1)
+        self.layer.SetMaskType(self.maskRadioBox.GetSelection())
         return True

Index: renderer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/renderer.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- renderer.py	28 Jan 2005 15:54:00 -0000	1.56
+++ renderer.py	16 Feb 2005 21:14:47 -0000	1.57
@@ -43,6 +43,8 @@
 
 from types import StringType
 
+from Thuban.version import versions
+
 
 # Map the strings used for the format parameter of the draw_raster_data
 # method to the appropriate wxWindows constants
@@ -92,6 +94,8 @@
         if (layer.ShapeStore().RawShapeFormat() == RAW_SHAPEFILE
             and layer.ShapeType() in (SHAPETYPE_ARC, SHAPETYPE_POLYGON)):
             offx, offy = self.offset
+            x = lambda a, b, c, d: None
+            #return (True, x, None)
             return (True, draw_polygon_shape,
                     draw_polygon_init(layer.ShapeStore().Shapefile(),
                                       self.dc, self.map.projection,
@@ -107,20 +111,32 @@
     def draw_raster_data(self, x,y, data, format = 'BMP'):
 
         mask = None
+        width = data[0]
+        height = data[1]
+        image_data, mask_data, alpha_data = data[2]
+
+        if versions['wxPython-tuple'] < (2,5,3):
+            alpha_data = None
 
         if format == 'RAW':
-            image = wxEmptyImage(data[0], data[1])
-            image.SetData(data[2][0])
-            if data[2][1] is not None:
-                mask = wxBitmapFromBits(data[2][1], data[0], data[1], 1)
+            image = wxEmptyImage(width, height)
+            image.SetData(image_data)
+            if mask_data is not None:
+                mask = wxBitmapFromBits(mask_data, width, height, 1)
                 mask = wxMask(mask)
+            elif alpha_data is not None:
+                image.SetAlphaData(alpha_data)
         else:
-            stream = cStringIO.StringIO(data[2][0])
+            stream = cStringIO.StringIO(image_data)
             image = wxImageFromStream(stream, raster_format_map[format])
-            if data[2][1] is not None:
-                stream = cStringIO.StringIO(data[2][1])
+            if mask_data is not None:
+                stream = cStringIO.StringIO(mask_data)
                 mask = wxImageFromStream(stream, raster_format_map[format])
                 mask = wxMask(wxBitmapFromImage(mask, 1))
+            elif alpha_data is not None:
+                stream = cStringIO.StringIO(alpha_data)
+                alpha = wxImageFromStream(stream, raster_format_map[format])
+                image.SetAlpha(alpha.GetData()[:])
 
         bitmap = wxBitmapFromImage(image)
         bitmap.SetMask(mask)





More information about the Thuban-devel mailing list

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