[GRASS-SVN] r47899 - in grass/trunk/gui: icons/grass
wxpython/gui_modules wxpython/icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 27 08:20:01 EDT 2011
Author: annakrat
Date: 2011-08-27 05:20:01 -0700 (Sat, 27 Aug 2011)
New Revision: 47899
Added:
grass/trunk/gui/icons/grass/3d-rotate.png
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/icons/icon.py
Log:
wxNviz: add rotate icon, fix small bug in lighting
Added: grass/trunk/gui/icons/grass/3d-rotate.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/gui/icons/grass/3d-rotate.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-08-27 11:27:30 UTC (rev 47898)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-08-27 12:20:01 UTC (rev 47899)
@@ -458,7 +458,7 @@
self._mgr.AddPane(self.toolbars['map'],
wx.aui.AuiPaneInfo().
Name("maptoolbar").Caption(_("Map Toolbar")).
- ToolbarPane().Top().
+ ToolbarPane().Top().Name('mapToolbar').
LeftDockable(False).RightDockable(False).
BottomDockable(False).TopDockable(True).
CloseButton(False).Layer(2).
@@ -666,7 +666,18 @@
# change the cursor
self.MapWindow.SetCursor(self.cursors["hand"])
-
+
+ def OnRotate(self, event):
+ """!Rotate 3D view
+ """
+ if self.toolbars['map']:
+ self.toolbars['map'].OnTool(event)
+ self.toolbars['map'].action['desc'] = ''
+
+ self.MapWindow.mouse['use'] = "rotate"
+
+ # change the cursor
+ self.MapWindow.SetCursor(self.cursors["hand"])
def OnErase(self, event):
"""!Erase the canvas
"""
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-27 11:27:30 UTC (rev 47898)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-27 12:20:01 UTC (rev 47899)
@@ -417,9 +417,6 @@
size = self.GetClientSize()
self.SetDrawScalebar((pos[0], size[1] - pos[1]))
- if self.mouse['use'] == 'pan':
- pass
-
if self.mouse['use'] == 'pointer':
# get decoration or text id
self.dragid = None
@@ -443,7 +440,7 @@
if self.mouse['use'] == 'pointer':
self.DragItem(self.dragid, event)
- if self.mouse['use'] == 'pan':
+ if self.mouse['use'] == 'rotate':
dx, dy = event.GetX() - self.mouse['tmp'][0], event.GetY() - self.mouse['tmp'][1]
self.mouse['tmp'] = event.GetPositionTuple()
angle, x, y, z = self._display.GetRotationParameters(dx, dy)
@@ -501,11 +498,13 @@
self.dragid = None
self.Refresh(False)
- elif self.mouse['use'] == 'pan':
+ elif self.mouse['use'] == 'rotate':
self._display.UnsetRotation()
self.render['quick'] = False
self.Refresh(False)
+ event.Skip()
+
def OnDClick(self, event):
"""!On mouse double click"""
if self.mouse['use'] != 'pointer': return
@@ -624,7 +623,7 @@
bright = data['bright'] / 100.,
ambient = data['ambient'] / 100.)
self._display.DrawLightingModel()
- if hasattr(event, 'refresh'):
+ if event.refresh:
self.Refresh(False)
def UpdateMap(self, render = True):
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-27 11:27:30 UTC (rev 47898)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-27 12:20:01 UTC (rev 47899)
@@ -2385,7 +2385,7 @@
self._display.DrawLightingModel()
def OnLightChange(self, event):
- """!Position of the light changed"""
+ """!Position of the light changing"""
winName = self.__GetWindowName(self.win['light'], event.GetId())
if not winName:
return
@@ -2396,24 +2396,24 @@
for win in self.win['light'][winName].itervalues():
self.FindWindowById(win).SetValue(value)
- self.PostLightEvent(refresh = False)
+ self.PostLightEvent()
event.Skip()
def OnLightChanged(self, event):
- """!Light"""
- self.mapWindow.Refresh(False)
+ """!Light changed"""
+ self.PostLightEvent(refresh = True)
def OnLightColor(self, event):
"""!Color of the light changed"""
self.mapWindow.light['color'] = tuple(event.GetValue())
- self.PostLightEvent()
+ self.PostLightEvent(refresh = True)
event.Skip()
def OnLightValue(self, event):
- """!Light brightness changed"""
+ """!Light brightness/ambient changing"""
data = self.mapWindow.light
self.OnScroll(event, self.win['light'], data)
@@ -4730,7 +4730,7 @@
def UpdatePos(self, xcoord, ycoord):
x, y = PositionWindow.UpdatePos(self, xcoord, ycoord)
- event = wxUpdateLight()
+ event = wxUpdateLight(refresh = False)
wx.PostEvent(self.mapWindow, event)
return x, y
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-08-27 11:27:30 UTC (rev 47898)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-08-27 12:20:01 UTC (rev 47899)
@@ -75,9 +75,10 @@
return None
def CreateTool(self, label, bitmap, kind,
- shortHelp, longHelp, handler):
+ shortHelp, longHelp, handler, pos = -1):
"""!Add tool to the toolbar
+ @param pos if -1 add tool, if > 0 insert at given pos
@return id of tool
"""
bmpDisabled = wx.NullBitmap
@@ -86,9 +87,14 @@
tool = vars(self)[label] = wx.NewId()
Debug.msg(3, "CreateTool(): tool=%d, label=%s bitmap=%s" % \
(tool, label, bitmap))
- toolWin = self.AddLabelTool(tool, label, bitmap,
- bmpDisabled, kind,
- shortHelp, longHelp)
+ if pos < 0:
+ toolWin = self.AddLabelTool(tool, label, bitmap,
+ bmpDisabled, kind,
+ shortHelp, longHelp)
+ else:
+ toolWin = self.InsertLabelTool(pos, tool, label, bitmap,
+ bmpDisabled, kind,
+ shortHelp, longHelp)
self.Bind(wx.EVT_TOOL, handler, toolWin)
else: # separator
self.AddSeparator()
@@ -175,16 +181,15 @@
retData = list()
for args in data:
retData.append(self._defineTool(*args))
-
return retData
- def _defineTool(self, name = None, icon = None, handler = None, item = wx.ITEM_NORMAL):
+ def _defineTool(self, name = None, icon = None, handler = None, item = wx.ITEM_NORMAL, pos = -1):
"""!Define tool
"""
if name:
return (name, icon.GetBitmap(),
item, icon.GetLabel(), icon.GetDesc(),
- handler)
+ handler, pos)
return ("", "", "", "", "", "") # separator
class MapToolbar(AbstractToolbar):
@@ -307,7 +312,27 @@
self.parent.PrintMenu),
(None, ))
)
-
+ def InsertTool(self, data):
+ """!Insert tool to toolbar
+
+ @param data toolbar data"""
+ data = self._getToolbarData(data)
+ for tool in data:
+ self.CreateTool(*tool)
+ self.Realize()
+
+ self.parent._mgr.GetPane('mapToolbar').BestSize(self.GetBestSize())
+ self.parent._mgr.Update()
+
+ def RemoveTool(self, tool):
+ """!Remove tool from toolbar
+
+ @param tool tool id"""
+ self.DeleteTool(tool)
+
+ self.parent._mgr.GetPane('mapToolbar').BestSize(self.GetBestSize())
+ self.parent._mgr.Update()
+
def OnSelectTool(self, event):
"""!Select / enable tool available in tools list
"""
@@ -319,6 +344,10 @@
elif tool == self.toolId['3d'] and \
not (self.parent.MapWindow3D and self.parent.IsPaneShown('3d')):
+ self.InsertTool((('rotate', Icons['nviz']['rotate'],
+ self.parent.OnRotate,
+ wx.ITEM_CHECK,7),)) # 7 is position
+
self.ExitToolbars()
self.parent.AddNviz()
@@ -332,11 +361,13 @@
if self.parent.toolbars['vdigit']:
self.parent.toolbars['vdigit'].OnExit()
if self.parent.GetLayerManager().IsPaneShown('toolbarNviz'):
+ self.RemoveTool(self.rotate)
self.parent.RemoveNviz()
def Enable2D(self, enabled):
"""!Enable/Disable 2D display mode specific tools"""
- for tool in (self.zoomin,
+ for tool in (self.pan,
+ self.zoomin,
self.zoomout,
self.zoomback,
self.zoommenu,
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2011-08-27 11:27:30 UTC (rev 47898)
+++ grass/trunk/gui/wxpython/icons/icon.py 2011-08-27 12:20:01 UTC (rev 47899)
@@ -333,6 +333,9 @@
desc = _('Settings dialog for georectification tool')),
},
'nviz' : {
+ 'rotate': MetaIcon(img = iconSet.get('3d-rotate', wx.ART_ERROR),
+ label = _('Rotate 3D scene'),
+ desc = _('Drag with mouse to rotate 3D scene')),
'nviz_cmd': MetaIcon(img = iconSet.get('script-save', wx.ART_ERROR),
label = _('Generate command for nviz_cmd'),
desc = _('Generate command for nviz_cmd based on current state')),
More information about the grass-commit
mailing list