[GRASS-SVN] r58345 - in grass/trunk/gui/wxpython: animation core dbmgr gui_core lmgr vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 1 11:48:33 PST 2013
Author: annakrat
Date: 2013-12-01 11:48:33 -0800 (Sun, 01 Dec 2013)
New Revision: 58345
Modified:
grass/trunk/gui/wxpython/animation/provider.py
grass/trunk/gui/wxpython/core/layerlist.py
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/core/workspace.py
grass/trunk/gui/wxpython/dbmgr/base.py
grass/trunk/gui/wxpython/gui_core/dialogs.py
grass/trunk/gui/wxpython/gui_core/simplelmgr.py
grass/trunk/gui/wxpython/lmgr/layertree.py
grass/trunk/gui/wxpython/vdigit/toolbars.py
Log:
wxGUI: unify opacity values to range <0; 1>
Modified: grass/trunk/gui/wxpython/animation/provider.py
===================================================================
--- grass/trunk/gui/wxpython/animation/provider.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/animation/provider.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -519,7 +519,7 @@
_setEnvironment(self.imageWidth, self.imageHeight, filename,
transparent=False, bgcolor=bgcolor)
- opacities = [str(op / 100.) for op in opacities]
+ opacities = [str(op) for op in opacities]
bgcolor = ':'.join([str(part) for part in bgcolor])
returncode, messages = RunCommand('g.pnmcomp',
getErrorMsg=True,
Modified: grass/trunk/gui/wxpython/core/layerlist.py
===================================================================
--- grass/trunk/gui/wxpython/core/layerlist.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/core/layerlist.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -70,7 +70,7 @@
return layers
def AddNewLayer(self, name, mapType, cmd, active=True, hidden=False,
- opacity=100, label=None, pos=0):
+ opacity=1, label=None, pos=0):
"""!Creates new layer and adds it to the list (insert to the first position).
@param ltype layer type (raster, vector, 3d-raster, ...)
@@ -255,18 +255,18 @@
def GetOpacity(self):
"""!Returns opacity value.
- @return opacity as integer between 0 and 100
+ @return opacity as float between 0 and 1
"""
- return int(self._opacity * 100)
+ return self._opacity
def SetOpacity(self, opacity):
"""!Sets opacity of the layer.
- @param opacity integer between 0 and 100
+ @param opacity float between 0 and 1
"""
- if not (0 <= opacity <= 100) or opacity != int(opacity):
- raise ValueError("Opacity must be an integer between 0 and 100, not {op}.".format(op=opacity))
- self._opacity = opacity / 100.
+ if not (0 <= opacity <= 1):
+ raise ValueError("Opacity value must be between 0 and 1, not {op}.".format(op=opacity))
+ self._opacity = opacity
opacity = property(fget=GetOpacity, fset=SetOpacity)
@@ -324,7 +324,7 @@
def ChangeLayerOpacity(self, index, layer):
"""!Changes layer opacity in renderer."""
rLayer = self._getRendererLayer(index)
- self._renderer.ChangeLayer(rLayer, opacity=layer.opacity / 100.)
+ self._renderer.ChangeLayer(rLayer, opacity=layer.opacity)
def ChangeLayerCmd(self, index, layer):
"""!Changes layer cmd in renderer."""
@@ -363,7 +363,7 @@
mapType = '3d-raster'
self._renderer.AddLayer(ltype=mapType, command=layer.cmd,
name=layer.name, active=layer.active,
- hidden=False, opacity=layer.opacity / 100.,
+ hidden=False, opacity=layer.opacity,
render=True, pos=-1)
def RemoveLayer(self, index):
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/core/render.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -218,18 +218,13 @@
return 'cell'
return self.type
- def GetOpacity(self, float = False):
+ def GetOpacity(self):
"""
Get layer opacity level
- @param float get opacity level in <0,1> otherwise <0,100>
-
- @return opacity level
+ @return opacity level (<0, 1>)
"""
- if float:
- return self.opacity
-
- return int (self.opacity * 100)
+ return self.opacity
def GetName(self, fullyQualified = True):
"""!Get map layer name
Modified: grass/trunk/gui/wxpython/core/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/core/workspace.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/core/workspace.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -697,7 +697,7 @@
else:
cmd = mapTree.GetLayerInfo(item, key = 'maplayer').GetCmd(string = False)
name = mapTree.GetItemText(item).replace(os.linesep, '\\n')
- opacity = maplayer.GetOpacity(float = True)
+ opacity = maplayer.GetOpacity()
# remove 'opacity' part
if opacity < 1:
name = name.split('(', -1)[0].strip()
Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/dbmgr/base.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -1584,7 +1584,7 @@
if self.parent and self.mapdisplay.tree and \
self.dbMgrData['treeItem']:
maptree = self.mapdisplay.tree
- opacity = maptree.GetLayerInfo(self.dbMgrData['treeItem'], key = 'maplayer').GetOpacity(float = True)
+ opacity = maptree.GetLayerInfo(self.dbMgrData['treeItem'], key = 'maplayer').GetOpacity()
self.qlayer.SetOpacity(opacity)
if zoom:
keyColumn = self.dbMgrData['mapDBInfo'].layers[self.selLayer]['key']
Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -2139,10 +2139,12 @@
return data
class SetOpacityDialog(wx.Dialog):
- """!Set opacity of map layers"""
+ """!Set opacity of map layers.
+ Dialog expects opacity between 0 and 1 and returns this range, too.
+ """
def __init__(self, parent, id = wx.ID_ANY, title = _("Set Map Layer Opacity"),
size = wx.DefaultSize, pos = wx.DefaultPosition,
- style = wx.DEFAULT_DIALOG_STYLE, opacity = 100):
+ style = wx.DEFAULT_DIALOG_STYLE, opacity = 1):
self.parent = parent # GMFrame
self.opacity = opacity # current opacity
@@ -2156,7 +2158,7 @@
sizer = wx.BoxSizer(wx.VERTICAL)
box = wx.GridBagSizer(vgap = 5, hgap = 5)
- self.value = wx.Slider(panel, id = wx.ID_ANY, value = self.opacity,
+ self.value = wx.Slider(panel, id = wx.ID_ANY, value = int(self.opacity * 100),
style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | \
wx.SL_TOP | wx.SL_LABELS,
minValue = 0, maxValue = 100,
Modified: grass/trunk/gui/wxpython/gui_core/simplelmgr.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/simplelmgr.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/gui_core/simplelmgr.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -247,8 +247,7 @@
def _setLayerOpacity(self, layer, value):
"""!Sets layer's opacity.'"""
- # * 100 to be compatible, should be changes everywhere to 0-100 range
- layer.opacity = int(value * 100)
+ layer.opacity = value
self._update()
self.opacityChanged.emit(index=self._layerList.GetLayerIndex(layer), layer=layer)
self.anyChange.emit()
@@ -259,9 +258,9 @@
active = []
selected = []
for layer in self._layerList:
- if layer.opacity < 100:
+ if layer.opacity < 1:
items.append("{name} (opacity {opacity}%)".format(name=layer.name,
- opacity=layer.opacity))
+ opacity=int(layer.opacity * 100)))
else:
items.append(layer.name)
active.append(layer.IsActive())
Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -1614,7 +1614,7 @@
if not lname:
lname = self.GetLayerInfo(item, key = 'label')
- opacity = int(mapLayer.GetOpacity(float = True) * 100)
+ opacity = int(mapLayer.GetOpacity() * 100)
if not lname:
dcmd = self.GetLayerInfo(item, key = 'cmd')
lname, found = GetLayerNameFromCmd(dcmd, layerType = mapLayer.GetType(),
@@ -1739,7 +1739,7 @@
elif type != 'group':
if self.GetPyData(item) is not None:
cmdlist = self.GetLayerInfo(item, key = 'cmd')
- opac = self.GetLayerInfo(item, key = 'maplayer').GetOpacity(float = True)
+ opac = self.GetLayerInfo(item, key = 'maplayer').GetOpacity()
chk = self.IsItemChecked(item)
hidden = not self.IsVisible(item)
# determine layer name
Modified: grass/trunk/gui/wxpython/vdigit/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/toolbars.py 2013-12-01 03:49:36 UTC (rev 58344)
+++ grass/trunk/gui/wxpython/vdigit/toolbars.py 2013-12-01 19:48:33 UTC (rev 58345)
@@ -857,7 +857,7 @@
self.MapWindow.UpdateMap(render = True)
# respect opacity
- opacity = mapLayer.GetOpacity(float = True)
+ opacity = mapLayer.GetOpacity()
if opacity < 1.0:
alpha = int(opacity * 255)
More information about the grass-commit
mailing list