[Thuban-commits] r2774 - in trunk/thuban: . Thuban/Model Thuban/UI test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Jun 23 00:14:16 CEST 2007


Author: bernhard
Date: 2007-06-23 00:14:15 +0200 (Sat, 23 Jun 2007)
New Revision: 2774

Modified:
   trunk/thuban/ChangeLog
   trunk/thuban/NEWS
   trunk/thuban/Thuban/Model/layer.py
   trunk/thuban/Thuban/Model/load.py
   trunk/thuban/Thuban/Model/save.py
   trunk/thuban/Thuban/UI/rasterlayerproperties.py
   trunk/thuban/Thuban/UI/renderer.py
   trunk/thuban/test/test_layer.py
   trunk/thuban/test/test_load.py
   trunk/thuban/test/test_save.py
Log:
INCOMPATIBLE CHANGE with Thuban 1.1 (development series) and 1.2.0:
Changing the raster layer attributes towards always 
using an alpha channel. As we require wx2.6 there is no real use-case 
for bitmap and this fixes a problem on the windows platform.

* NEWS: adding note about the major change using alpha always.

* Thuban/UI/renderer.py: Removed diversion for wx <2.5.3 as 
we require >= 2.6 now. Bumping copyright, adding author Bernhard.

* Thuban/UI/rasterlayerproperties.py: Removed diversion for
wx <2.5.3 as we require >= 2.6 now, so we always can do alpha channel. 
Added author Bernhard Reiter and copyright year 2007. 
Removed two old code lines which were commented out.
Commented out the code for the mask type selection.

* Thuban/Model/layer.py: Made masktype = MASK_ALPHA default for new
raster images. Bumping copyright.

* test/test_layer.py: made test_raster_layer() expect MASK_ALPHA.
Bumping copyright.

* Thuban/Model/load.py: if there is no masktype set, use alpha.
This means the behaviour changes for files saved with Thuban-1.1,
but this has been a development version. As bitmap does not work
on some platforms (windows currently) it will even fix a problem 
there. Bumping copyright

* test/test_load.py: Removed masktype from example file. Bumping
copyright.

* Thuban/Model/save.py: Do not save raster attribute "masktype" 
anymore. Bumping copyright.

* test/test_save.py: Not expecting "masktype" to be saved anymore.
Bumping copyright.


Modified: trunk/thuban/ChangeLog
===================================================================
--- trunk/thuban/ChangeLog	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/ChangeLog	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,5 +1,44 @@
 2007-06-22  Bernhard Reiter <bernhard at intevation.de>
 
+	INCOMPATIBLE CHANGE with Thuban 1.1 (development series) and 1.2.0:
+	Changing the raster layer attributes towards always 
+	using an alpha channel. As we require wx2.6 there is no real use-case 
+	for bitmap and this fixes a problem on the windows platform.
+
+	* NEWS: adding note about the major change using alpha always.
+
+	* Thuban/UI/renderer.py: Removed diversion for wx <2.5.3 as 
+	we require >= 2.6 now. Bumping copyright, adding author Bernhard.
+
+	* Thuban/UI/rasterlayerproperties.py: Removed diversion for
+	wx <2.5.3 as we require >= 2.6 now, so we always can do alpha channel. 
+	Added author Bernhard Reiter and copyright year 2007. 
+	Removed two old code lines which were commented out.
+	Commented out the code for the mask type selection.
+
+	* Thuban/Model/layer.py: Made masktype = MASK_ALPHA default for new
+	raster images. Bumping copyright.
+
+	* test/test_layer.py: made test_raster_layer() expect MASK_ALPHA.
+	Bumping copyright.
+
+	* Thuban/Model/load.py: if there is no masktype set, use alpha.
+	This means the behaviour changes for files saved with Thuban-1.1,
+	but this has been a development version. As bitmap does not work
+	on some platforms (windows currently) it will even fix a problem 
+	there. Bumping copyright
+
+	* test/test_load.py: Removed masktype from example file. Bumping
+	copyright.
+
+	* Thuban/Model/save.py: Do not save raster attribute "masktype" 
+	anymore. Bumping copyright.
+
+	* test/test_save.py: Not expecting "masktype" to be saved anymore.
+	Bumping copyright.
+
+2007-06-22  Bernhard Reiter <bernhard at intevation.de>
+
 	Minor documentation cleanups. 
 
 	* NEWS: Corrected python version relation indicating which python

Modified: trunk/thuban/NEWS
===================================================================
--- trunk/thuban/NEWS	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/NEWS	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,3 +1,17 @@
+
+Changes up to Thuban 1.2-SVN (not released yet)
+============================
+
+ - Using the alpha channel for displaying raster images all the time.
+   There is no selection possibility anymore for "masktype".
+
+ INCOMPATIBLE with Thuban 1.1 (development series) and 1.2.0:
+ Ignoring the saved masktype in .thuban files, using "alpha" in all cases.
+ With wx2.6 there is no need for other mask types anymore. Doing this
+ change fixes a problem on the windows platform, where masktype=bit did
+ not work so far.
+
+
 Changes up to Thuban 1.2.0 (released 2007-03-13)
 ==========================
 

Modified: trunk/thuban/Thuban/Model/layer.py
===================================================================
--- trunk/thuban/Thuban/Model/layer.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/Thuban/Model/layer.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,4 +1,4 @@
-# Copyright (c) 2001, 2002, 2003, 2004, 2005 by Intevation GmbH
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2007 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 # Jonathan Coles <jonathan at intevation.de>
@@ -405,7 +405,7 @@
     MASK_ALPHA = 2
 
     def __init__(self, title, filename, projection = None, 
-                 visible = True, opacity = 1, masktype = MASK_BIT):
+                 visible = True, opacity = 1, masktype = MASK_ALPHA):
         """Initialize the Raster Layer.
 
         title -- title for the layer.

Modified: trunk/thuban/Thuban/Model/load.py
===================================================================
--- trunk/thuban/Thuban/Model/load.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/Thuban/Model/load.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,4 +1,4 @@
-# Copyright (C) 2001, 2002, 2003, 2004, 2005 by Intevation GmbH
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by Intevation GmbH
 # Authors:
 # Jan-Oliver Wagner <jan at intevation.de>
 # Bernhard Herzog <bh at intevation.de>
@@ -511,7 +511,7 @@
         filename = self.encode(filename)
         visible  = self.encode(attrs.get((None, 'visible'), "true")) != "false"
         opacity  = float(attrs.get((None, 'opacity'), "1"))
-        masktype = str(attrs.get((None, 'masktype'), "bit"))
+        masktype = str(attrs.get((None, 'masktype'), "alpha"))
 
         masktypes = {"none": layer_class.MASK_NONE,
                      "bit":  layer_class.MASK_BIT,

Modified: trunk/thuban/Thuban/Model/save.py
===================================================================
--- trunk/thuban/Thuban/Model/save.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/Thuban/Model/save.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,4 +1,4 @@
-# Copyright (c) 2001-2005 by Intevation GmbH
+# Copyright (c) 2001-2005, 2007 by Intevation GmbH
 # Authors:
 # Jan-Oliver Wagner <jan at intevation.de> (2004-2005)
 # Bernhard Herzog <bh at intevation.de> (2001-2004)
@@ -299,11 +299,6 @@
         elif isinstance(layer, RasterLayer):
             attrs["filename"] = self.prepare_filename(layer.filename)
 
-            masknames = ["none", "bit", "alpha"]
-
-            if layer.MaskType() != layer.MASK_BIT:
-                attrs["masktype"] = masknames[layer.MaskType()]
-
             if layer.Opacity() != 1:
                 attrs["opacity"] = str(layer.Opacity())
 

Modified: trunk/thuban/Thuban/UI/rasterlayerproperties.py
===================================================================
--- trunk/thuban/Thuban/UI/rasterlayerproperties.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/Thuban/UI/rasterlayerproperties.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,6 +1,7 @@
-# Copyright (c) 2005 by Intevation GmbH
+# Copyright (c) 2005, 2007 by Intevation GmbH
 # Authors:
 # Jonathan Coles <jonathan at intevation.de> 
+# Bernhard Reiter <bernhard at intevation.de>
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with Thuban for details.
@@ -19,15 +20,15 @@
 
 from Thuban.version import versions
 
-ID_RB_MASK = 4002
+#ID_RB_MASK = 4002
 
 class RasterLayerProperties(LayerProperties):
 
     def __init__(self, parent, name, layer, *args, **kw):
         LayerProperties.__init__(self, parent, name, layer)
 
-        self.old_state = {}
-        self.old_state["mask_type"] = layer.MaskType()
+        #self.old_state = {}
+        #self.old_state["mask_type"] = layer.MaskType()
 
         LayerProperties.dialog_layout(self)
 
@@ -81,40 +82,36 @@
 
         # Mask 
 
-        maskBox = wx.BoxSizer(wx.HORIZONTAL)
+        #maskBox = wx.BoxSizer(wx.HORIZONTAL)
 
-        if versions['wxPython-tuple'] < (2,5,3):
-            choices = ["None", "Bitmap",
-                       "Alpha (Not support by wxPython %s)" % \
-                       versions['wxPython']]
-        else:
-            choices = ["None", "Bitmap", "Alpha"]
+        # choices = ["None", "Bitmap", "Alpha"]
 
-        self.maskRadioBox = wx.RadioBox(panel, ID_RB_MASK, _("Mask Type"),
-                            choices=choices)
-        #self.maskCB = wxCheckBox(panel, -1, _("Use Mask"))
-        maskBox.Add(self.maskRadioBox, 0, wx.RIGHT, 10)
+        #self.maskRadioBox = wx.RadioBox(panel, ID_RB_MASK, _("Mask Type"),
+        #                    choices=choices)
+        #maskBox.Add(self.maskRadioBox, 0, wx.RIGHT, 10)
 
         self.opBox = wx.BoxSizer(wx.HORIZONTAL)
         self.opSpinLabel = wx.StaticText(panel, -1, _("Opacity:"))
-        self.opBox.Add(self.opSpinLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 4)
+        self.opBox.Add(self.opSpinLabel, 0, 
+		      wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 4)
         self.opSpin = wx.SpinCtrl(panel, -1,
                                  str(self.layer.Opacity()*255),
                                  initial = self.layer.Opacity()*255,
                                  min=0, max=255)
         self.opBox.Add(self.opSpin, 0, wx.ALL, 4)
-        maskBox.Add(self.opBox, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+        #maskBox.Add(self.opBox, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
-        rasterBox.Add(maskBox, 0, wx.ALL, 4)
-        #rasterBox.Add(opBox, 0, wxALL, 4)
+        #rasterBox.Add(maskBox, 0, wx.ALL, 4)
 
+        rasterBox.Add(self.opBox, 0, wx.ALL, 4)
+
         panelBox.Add(rasterBox, 1, wx.GROW | wx.ALL, 4)
 
-        self.maskRadioBox.SetSelection(self.old_state["mask_type"])
+        #self.maskRadioBox.SetSelection(self.old_state["mask_type"])
 
-        self.OnMaskSelect(None)
+        #self.OnMaskSelect(None)
 
-        self.Bind(wx.EVT_RADIOBOX, self.OnMaskSelect, id=ID_RB_MASK)
+        #self.Bind(wx.EVT_RADIOBOX, self.OnMaskSelect, id=ID_RB_MASK)
 
     def OnTry(self, event):
         self.set_state()
@@ -124,15 +121,15 @@
             self.Close()
 
     def OnRevert(self, event):
-        self.maskRadioBox.SetSelection(self.old_state["mask_type"])
+        #self.maskRadioBox.SetSelection(self.old_state["mask_type"])
         self.set_state()
 
-    def OnMaskSelect(self, event):
-        allowOpacity = self.maskRadioBox.GetSelection()==2
-        self.opSpin.Enable(allowOpacity)
-        self.opSpinLabel.Enable(allowOpacity)
+    #def OnMaskSelect(self, event):
+    #    allowOpacity = self.maskRadioBox.GetSelection()==2
+    #    self.opSpin.Enable(allowOpacity)
+    #    self.opSpinLabel.Enable(allowOpacity)
 
     def set_state(self):
-        self.layer.SetMaskType(self.maskRadioBox.GetSelection())
+        #self.layer.SetMaskType(self.maskRadioBox.GetSelection())
         self.layer.SetOpacity(self.opSpin.GetValue()/255.0)
         return True

Modified: trunk/thuban/Thuban/UI/renderer.py
===================================================================
--- trunk/thuban/Thuban/UI/renderer.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/Thuban/UI/renderer.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,9 +1,10 @@
-# Copyright (c) 2001-2006 by Intevation GmbH
+# Copyright (c) 2001-2007 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de> (2001-2003)
 # Jonathan Coles <jonathan at intevation.de> (2003)
 # Frank Koormann <frank.koormann at intevation.de> (2003)
 # Jan-Oliver Wagner <jan at intevation.de> (2003-2005)
+# Bernhard Reiter <bernhard at intevation.de> (2006-2007)
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with Thuban for details.
@@ -123,10 +124,6 @@
 
         if Thuban.Model.resource.has_gdal_support():
 
-            if versions['wxPython-tuple'] < (2,5,3):
-                options = options | 4  # INVERT_MASK_BITS
-                options = options & ~2 # ALPHA_MASK not supported
-
             try:
                 if verbose > 0:
                     print "doing ProjectRasterFile '%s' -> '%s'" % \

Modified: trunk/thuban/test/test_layer.py
===================================================================
--- trunk/thuban/test/test_layer.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/test/test_layer.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005, 2007 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -232,7 +232,8 @@
         layer = RasterLayer("Test RasterLayer", filename)
         self.failIf(layer.HasClassification())
         self.failIf(layer.HasShapes())
-        self.assertEquals(layer.MaskType(), layer.MASK_BIT)
+        #testing the default for MaskType
+        self.assertEquals(layer.MaskType(), layer.MASK_ALPHA)
         self.assertEquals(layer.GetImageFilename(), os.path.abspath(filename))
         self.assertFloatSeqEqual(layer.BoundingBox(),
                                  [-24.5500000, 63.2833330,
@@ -483,7 +484,8 @@
         layer.Subscribe(LAYER_CHANGED, self.subscribe_with_params,
                         LAYER_CHANGED)
 
-        self.assertEquals(layer.MaskType(), layer.MASK_BIT)
+	# default mask type
+        self.assertEquals(layer.MaskType(), layer.MASK_ALPHA)
 
         layer.SetMaskType(layer.MASK_NONE)
         self.failIf(layer.MaskType() != layer.MASK_NONE)

Modified: trunk/thuban/test/test_load.py
===================================================================
--- trunk/thuban/test/test_load.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/test/test_load.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005, 2007 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -699,7 +699,7 @@
         title="single map&amp;layer">
     <map title="Test Map">
         <rasterlayer visible="false" filename="../../Data/iceland/island.tif"
-                title="My RasterLayer" opacity="0.4" masktype="alpha"/>
+                title="My RasterLayer" opacity="0.4"/>
     </map>
 </session>
 '''
@@ -717,7 +717,6 @@
 
         eq(layer.Title(), "My RasterLayer")
         eq(layer.Opacity(), 0.4)
-        eq(layer.MaskType(), layer.MASK_ALPHA)
 
         self.failIf(layer.Visible())
         self.failUnless(filenames_equal(layer.GetImageFilename(),

Modified: trunk/thuban/test/test_save.py
===================================================================
--- trunk/thuban/test/test_save.py	2007-06-22 21:56:49 UTC (rev 2773)
+++ trunk/thuban/test/test_save.py	2007-06-22 22:14:15 UTC (rev 2774)
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005, 2007 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -288,10 +288,10 @@
                 <map title="Test Map">
                     <rasterlayer title="My RasterLayer"
                             filename="../../Data/iceland/island.tif"
-                            visible="true" %s %s>
+                            visible="true" %s>
                     </rasterlayer>
                 </map>
-            </session>''' % (opname, maskname)
+            </session>''' % (opname, )
             #print written_contents
             #print "********************************************"
             #print expected_contents



More information about the Thuban-commits mailing list