[GRASS-SVN] r33281 - in grass/branches/develbranch_6/gui/wxpython:
gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 5 16:14:00 EDT 2008
Author: martinl
Date: 2008-09-05 16:14:00 -0400 (Fri, 05 Sep 2008)
New Revision: 33281
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
Log:
wxGUI: trac #276 --- vdigit: please render closed areas transparent
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2008-09-05 20:14:00 UTC (rev 33281)
@@ -312,7 +312,8 @@
# for all non-display commands.
if compReg:
tmpreg = os.getenv("GRASS_REGION")
- del os.environ["GRASS_REGION"]
+ if os.environ.has_key("GRASS_REGION"):
+ del os.environ["GRASS_REGION"]
if len(cmdlist) == 1:
import menuform
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2008-09-05 20:14:00 UTC (rev 33281)
@@ -476,10 +476,8 @@
Debug.msg(4, "BufferedWindow.OnPaint(): redrawAll=%s" % self.redrawAll)
dc = wx.BufferedPaintDC(self, self.buffer)
-
- # we need to clear the dc BEFORE calling PrepareDC
- #bg = wx.Brush(self.GetBackgroundColour())
- dc.SetBackground(wx.Brush("White"))
+
+ ### dc.SetBackground(wx.Brush("White"))
dc.Clear()
# use PrepareDC to set position correctly
@@ -496,7 +494,9 @@
# draw vector map layer
if self.pdcVector:
- self.pdcVector.DrawToDCClipped(dc, rgn)
+ # decorate with GDDC (transparency)
+ gcdc = wx.GCDC(dc)
+ self.pdcVector.DrawToDCClipped(gcdc, rgn)
self.bufferLast = None
else: # do not redraw pdc and pdcVector
@@ -505,8 +505,10 @@
self.pdc.DrawToDC(dc)
if self.pdcVector:
- self.pdcVector.DrawToDC(dc)
-
+ # decorate with GDDC (transparency)
+ gcdc = wx.GCDC(dc)
+ self.pdcVector.DrawToDC(gcdc)
+
# store buffered image
# self.bufferLast = wx.BitmapFromImage(self.buffer.ConvertToImage())
self.bufferLast = dc.GetAsBitmap(wx.Rect(0, 0, self.Map.width, self.Map.height))
@@ -518,7 +520,7 @@
# draw temporary object on the foreground
# self.pdcTmp.DrawToDCClipped(dc, rgn)
self.pdcTmp.DrawToDC(dc)
-
+
def OnSize(self, event):
"""
Scale map image so that it is
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2008-09-05 20:14:00 UTC (rev 33281)
@@ -680,13 +680,11 @@
except ValueError:
pass
else: # -> write settings
- if type(value) == type(wx.Colour(0, 0, 0, 0)):
- print value, type(value)
if type(value) == type(()): # -> color
value = str(value[0]) + ':' +\
str(value[1]) + ':' + \
str(value[2])
-
+
return value
def Get(self, group, key=None, subkey=None, internal=False):
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2008-09-05 20:14:00 UTC (rev 33281)
@@ -1050,8 +1050,14 @@
self.parent.MapWindow.pdcVector = wx.PseudoDC()
self.parent.digit.driver.SetDevice(self.parent.MapWindow.pdcVector)
# self.parent.MapWindow.UpdateMap()
+
if not self.parent.MapWindow.resize:
self.parent.MapWindow.UpdateMap(render=True)
+
+ opacity = mapLayer.GetOpacity(float=True)
+ if opacity < 1.0:
+ alpha = int(opacity * 255)
+ self.parent.digit.driver.UpdateSettings(alpha)
return True
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py 2008-09-05 20:14:00 UTC (rev 33281)
@@ -1531,7 +1531,7 @@
"""Show/hide selected features"""
self.__display.DrawSelected(draw)
- def UpdateSettings(self):
+ def UpdateSettings(self, alpha=255):
"""Update display driver settings"""
# TODO map units
@@ -1559,9 +1559,8 @@
UserSettings.Get(group='vdigit', key='symbol',
subkey=[symbol, 'color'])[1],
UserSettings.Get(group='vdigit', key='symbol',
- subkey=[symbol, 'color'])[2],
- 255).GetRGB()
-
+ subkey=[symbol, 'color'])[2]).GetRGB()
+
self.__display.UpdateSettings (color['highlight'],
UserSettings.Get(group='vdigit', key='checkForDupl',
subkey='enabled'),
@@ -1606,7 +1605,8 @@
subkey=['direction', 'enabled']),
color['direction'],
UserSettings.Get(group='vdigit', key='lineWidth',
- subkey='value'))
+ subkey='value'),
+ alpha)
class VDigitSettingsDialog(wx.Dialog):
"""
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-09-05 20:14:00 UTC (rev 33281)
@@ -484,7 +484,7 @@
dlg.CentreOnParent()
if dlg.ShowModal() == wx.ID_OK:
- new_opacity = dlg.GetOpacity() # string
+ new_opacity = dlg.GetOpacity() # string
self.Map.ChangeOpacity(maplayer, new_opacity)
maplayer.SetOpacity(new_opacity)
opacity_pct = int(new_opacity * 100)
@@ -493,6 +493,12 @@
self.SetItemText(self.layer_selected,
layerbase + ' (opacity: ' + str(opacity_pct) + '%)')
+ # vector layer currently edited
+ if self.mapdisplay.toolbars['vdigit'] and \
+ self.mapdisplay.toolbars['vdigit'].GetLayer() == maplayer:
+ alpha = int(new_opacity * 255)
+ self.mapdisplay.digit.driver.UpdateSettings(alpha)
+
# redraw map if auto-rendering is enabled
self.rerender = True
self.reorder = True
Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp 2008-09-05 20:14:00 UTC (rev 33281)
@@ -293,7 +293,7 @@
bool eVertex, unsigned long cVertex,
bool eArea, unsigned long cArea,
bool eDirection, unsigned long cDirection,
- int lineWidth)
+ int lineWidth, int alpha)
{
settings.highlight.Set(highlight);
@@ -334,7 +334,7 @@
settings.area.color.Set(settings.area.color.Red(),
settings.area.color.Green(),
settings.area.color.Blue(),
- 100); /* transparency */
+ alpha);
settings.direction.enabled = eDirection;
settings.direction.color.Set(cDirection);
Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h 2008-09-05 14:04:15 UTC (rev 33280)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h 2008-09-05 20:14:00 UTC (rev 33281)
@@ -210,7 +210,7 @@
bool, unsigned long,
bool, unsigned long,
bool, unsigned long,
- int);
+ int, int);
};
int print_error(const char *, int);
More information about the grass-commit
mailing list