[GRASS-SVN] r42404 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 31 06:13:24 EDT 2010
Author: martinl
Date: 2010-05-31 06:13:00 -0400 (Mon, 31 May 2010)
New Revision: 42404
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI/nviz: nviz tool window intergrated into layer manager
(merge r42403 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -192,6 +192,10 @@
"""!Get map instace"""
return self.Map
+ def GetMapDisplay(self):
+ """!Get associated MapFrame"""
+ return self.mapdisplay
+
def OnIdle(self, event):
"""
Only re-order and re-render a composite map image from GRASS during
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -304,9 +304,8 @@
self.decorationDialog = None # decoration/overlays
def AddToolbar(self, name):
- """
- Add defined toolbar to the window
-
+ """!Add defined toolbar to the window
+
Currently known toolbars are:
- 'map' - basic map toolbar
- 'vdigit' - vector digitizer
@@ -399,49 +398,41 @@
style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
return
- #
# add Nviz toolbar and disable 2D display mode tools
- #
self.toolbars['nviz'] = toolbars.NvizToolbar(self, self.Map)
self.toolbars['map'].Enable2D(False)
- #
# update layer tree (-> enable 3d-rasters)
- #
if self.tree:
self.tree.EnableItemType(type='3d-raster', enable=True)
- #
# update status bar
- #
self.statusbarWin['toggle'].Enable(False)
- #
# erase map window
- #
self.MapWindow.EraseMap()
self.statusbar.SetStatusText(_("Please wait, loading data..."), 0)
- #
# create GL window & NVIZ toolbar
- #
if not self.MapWindow3D:
self.MapWindow3D = nviz.GLWindow(self, id=wx.ID_ANY,
Map=self.Map, tree=self.tree, lmgr=self._layerManager)
- # -> show after paint
- self.nvizToolWin = nviz.NvizToolWindow(self, id=wx.ID_ANY,
- mapWindow=self.MapWindow3D)
+ self.MapWindow = self.MapWindow3D
+
+ # add Nviz notebookpage
+ self._layerManager.AddNviz()
+
self.MapWindow3D.OnPaint(None) # -> LoadData
self.MapWindow3D.Show()
self.MapWindow3D.UpdateView(None)
+ else:
+ self.MapWindow = self.MapWindow3D
+ # add Nviz notebookpage
+ self._layerManager.AddNviz()
- self.nvizToolWin.Show()
-
- #
# switch from MapWindow to MapWindowGL
# add nviz toolbar
- #
self._mgr.DetachPane(self.MapWindow2D)
self.MapWindow2D.Hide()
self._mgr.AddPane(self.MapWindow3D, wx.aui.AuiPaneInfo().CentrePane().
@@ -456,18 +447,15 @@
BottomDockable(False).TopDockable(True).
CloseButton(False).Layer(2))
- self.MapWindow = self.MapWindow3D
self.SetStatusText("", 0)
self._mgr.Update()
def RemoveToolbar (self, name):
- """
- Removes toolbar from the window
+ """!Removes toolbar from the window
- TODO: Only hide, activate by calling AddToolbar()
+ @todo Only hide, activate by calling AddToolbar()
"""
-
# cannot hide main toolbar
if name == "map":
return
@@ -482,8 +470,6 @@
self.toolbars[name] = None
if name == 'nviz':
- # hide nviz tools
- self.nvizToolWin.Hide()
# unload data
# self.MapWindow3D.Reset()
# switch from MapWindowGL to MapWindow
@@ -495,12 +481,14 @@
CloseButton(False).DestroyOnClose(True).
Layer(0))
self.MapWindow = self.MapWindow2D
+ # remove nviz notebook page
+ self._layerManager.RemoveNviz()
- #
# update layer tree (-> disable 3d-rasters)
- #
if self.tree:
self.tree.EnableItemType(type='3d-raster', enable=False)
+
+
self.MapWindow.UpdateMap()
self.toolbars['map'].combo.SetValue (_("2D view"))
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -68,7 +68,10 @@
import wx
import wx.html
-import wx.lib.flatnotebook as FN
+try:
+ import wx.lib.agw.flatnotebook as FN
+except ImportError:
+ import wx.lib.flatnotebook as FN
import wx.lib.colourselect as csel
import wx.lib.filebrowsebutton as filebrowse
from wx.lib.expando import ExpandoTextCtrl, EVT_ETC_LAYOUT_NEEDED
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -172,20 +172,20 @@
if not self.init:
self.ResetView()
- if hasattr(self.parent, "nvizToolWin"):
- self.parent.nvizToolWin.UpdatePage('view')
+ if hasattr(self._layermanager, "nviz"):
+ self._layermanager.nviz.UpdatePage('view')
layer = self.GetSelectedLayer()
if layer:
if layer.type == 'raster':
- self.parent.nvizToolWin.UpdatePage('surface')
+ self._layermanager.nviz.UpdatePage('surface')
elif layer.type == 'vector':
- self.parent.nvizToolWin.UpdatePage('vector')
+ self._layermanager.nviz.UpdatePage('vector')
- self.parent.nvizToolWin.UpdateSettings()
+ self._layermanager.nviz.UpdateSettings()
# update widgets
- win = self.parent.nvizToolWin.FindWindowById( \
- self.parent.nvizToolWin.win['vector']['lines']['surface'])
+ win = self._layermanager.nviz.FindWindowById( \
+ self._layermanager.nviz.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames('raster'))
self.init = True
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -23,6 +23,11 @@
import wx
import wx.lib.colourselect as csel
+import wx.lib.scrolledpanel as SP
+try:
+ import wx.lib.agw.flatnotebook as FN
+except ImportError:
+ import wx.lib.flatnotebook as FN
import globalvar
import gselect
@@ -34,40 +39,21 @@
sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
import grass6_wxnviz as wxnviz
-class NvizToolWindow(wx.Frame):
- """!Experimental window for Nviz tools
-
- @todo integrate with Map display
+class NvizToolWindow(FN.FlatNotebook):
+ """!Nviz (3D view) tools panel
"""
- def __init__(self, parent = None, id = wx.ID_ANY, title = _("GRASS GIS 3D View Tools"),
- pos = wx.DefaultPosition, size = wx.DefaultSize,
- mapWindow = None,
- style = wx.CAPTION|wx.MINIMIZE_BOX|wx.RESIZE_BORDER):
+ def __init__(self, parent, display, id = wx.ID_ANY,
+ style = globalvar.FNPageStyle, **kwargs):
+ self.parent = parent # GMFrame
+ self.mapDisplay = display
+ self.mapWindow = display.GetWindow()
+ self._display = self.mapWindow.GetDisplay()
- self.parent = parent # MapFrame
- self.lmgr = self.parent.GetLayerManager() # GMFrame
- self.mapWindow = mapWindow
- self._display = mapWindow.GetDisplay()
+ FN.FlatNotebook.__init__(self, parent, id, style = style, **kwargs)
+ self.SetTabAreaColour(globalvar.FNPageColor)
- wx.Frame.__init__(self, parent, id, title, pos, size, style)
-
- #
- # icon
- #
- self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_nviz.ico'), wx.BITMAP_TYPE_ICO))
-
- #
- # dialog body
- #
- mainSizer = wx.BoxSizer(wx.VERTICAL)
-
self.win = {} # window ids
- #
- # notebook
- #
- self.notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
-
self.page = {}
self.win['settings'] = {}
self.win['settings']['general'] = {}
@@ -92,31 +78,16 @@
self.mapWindow.render['quick'] = False
self.mapWindow.Refresh(False)
- mainSizer.Add(item = self.notebook, proportion = 1,
- flag = wx.EXPAND | wx.ALL, border = 5)
-
- #
# bindings
- #
self.Bind(wx.EVT_CLOSE, self.OnClose)
- self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
+ self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
- #
- # layout
- #
- self.SetSizer(mainSizer)
- mainSizer.Fit(self)
-
- # self.SetSize(size) #this produces a size that is consistently too small for the controls
- self.Layout()
- self.notebook.Update()
self.Update()
- self.SetPage('view')
- self.CentreOnScreen()
+ # wx.CallAfter(self.SetPage, 'view')
def OnPageChanged(self, event):
new = event.GetSelection()
- self.notebook.ChangeSelection(new)
+ # self.ChangeSelection(new)
def PostViewEvent(self, zExag = False):
"""!Change view settings"""
@@ -125,10 +96,11 @@
def _createViewPage(self):
"""!Create view settings page"""
- panel = wx.Panel(parent = self.notebook, id = wx.ID_ANY)
- self.notebook.InsertPage(0, page = panel,
- text = " %s " % _("View"),
- select = True)
+ panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False)
+ self.InsertPage(0, page = panel,
+ text = " %s " % _("View"),
+ select = True)
pageSizer = wx.BoxSizer(wx.VERTICAL)
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
@@ -253,12 +225,13 @@
def _createSurfacePage(self):
"""!Create view settings page"""
- panel = wx.Panel(parent = self.notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False)
self.page['surface'] = {}
self.page['surface']['id'] = -1
self.page['surface']['panel'] = panel.GetId()
- # panel = scrolled.ScrolledPanel(parent = self.notebook, id = wx.ID_ANY)
+ # panel = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
# panel.SetupScrolling(scroll_x = True, scroll_y = True)
pageSizer = wx.BoxSizer(wx.VERTICAL)
@@ -541,7 +514,8 @@
def _createVectorPage(self):
"""!Create view settings page"""
- panel = wx.Panel(parent = self.notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False)
self.page['vector'] = {}
self.page['vector']['id'] = -1
self.page['vector']['panel'] = panel.GetId()
@@ -785,7 +759,8 @@
def _createVolumePage(self):
"""!Create view settings page"""
- panel = wx.Panel(parent = self.notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False)
self.page['volume'] = {}
self.page['volume']['id'] = -1
self.page['volume']['panel'] = panel.GetId()
@@ -1004,10 +979,12 @@
def _createSettingsPage(self):
"""Create settings page"""
- panel = wx.Panel(parent = self.notebook, id = wx.ID_ANY)
- self.notebook.AddPage(page = panel,
- text = " %s " % _("Settings"))
+ panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False)
+ self.AddPage(page = panel,
+ text = " %s " % _("Settings"))
+
pageSizer = wx.BoxSizer(wx.VERTICAL)
self.win['settings'] = {}
@@ -1533,7 +1510,7 @@
def OnApply(self, event):
"""Apply button pressed"""
- if self.notebook.GetSelection() == self.page['settings']['id']:
+ if self.GetSelection() == self.page['settings']['id']:
self.ApplySettings()
if event:
@@ -1572,12 +1549,12 @@
#
self.OnApply(None)
- if self.notebook.GetSelection() == self.page['settings']['id']:
+ if self.GetSelection() == self.page['settings']['id']:
fileSettings = {}
UserSettings.ReadSettingsFile(settings = fileSettings)
fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
file = UserSettings.SaveToFile(fileSettings)
- self.lmgr.goutput.WriteLog(_('Nviz settings saved to file <%s>.') % file)
+ self.parent.goutput.WriteLog(_('Nviz settings saved to file <%s>.') % file)
def OnLoad(self, event):
"""!Apply button pressed"""
@@ -1708,7 +1685,7 @@
UserSettings.Set(group = 'nviz', value = nvsettings)
file = UserSettings.SaveToFile()
- self.lmgr.goutput.WriteLog(_('Nviz settings saved to file <%s>.') % file)
+ self.parent.goutput.WriteLog(_('Nviz settings saved to file <%s>.') % file)
def OnBgColor(self, event):
"""!Background color changed"""
@@ -1722,7 +1699,7 @@
self._display.SetBgColor(str(color))
- if self.parent.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
def OnClose(self, event):
@@ -1783,7 +1760,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.parent.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
def SetMapObjUseMap(self, nvizType, attrb, map = None):
@@ -1863,14 +1840,14 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.parent.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
def OnSurfaceResolution(self, event):
"""!Draw resolution changed"""
self.SetSurfaceResolution()
- if apply and self.parent.statusbarWin['render'].IsChecked():
+ if apply and self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
def SetSurfaceResolution(self):
@@ -1924,7 +1901,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if apply and self.parent.statusbarWin['render'].IsChecked():
+ if apply and self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
def OnSurfaceModeAll(self, event):
@@ -1953,7 +1930,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if apply and self.parent.statusbarWin['render'].IsChecked():
+ if apply and self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
def _getColorString(self, color):
@@ -2546,11 +2523,11 @@
self.FindWindowById(self.win['view']['height'][control]).SetValue(hval)
elif pageId in ('surface', 'vector', 'volume'):
- current_page = self.notebook.GetSelection()
- if self.notebook.GetSelection() != self.page[pageId]['id']:
+ current_page = self.GetSelection()
+ if self.GetSelection() != self.page[pageId]['id']:
for page in ('surface', 'vector', 'volume'):
if self.page[page]['id'] > -1:
- self.notebook.RemovePage(self.page[page]['id'])
+ self.RemovePage(self.page[page]['id'])
self.page[page]['id'] = -1
oldpanel = wx.FindWindowById(self.page[page]['panel'])
oldpanel.Hide()
@@ -2559,12 +2536,12 @@
self.page['settings']['id'] = 2
panel = wx.FindWindowById(self.page[pageId]['panel'])
- self.notebook.InsertPage(n = self.page[pageId]['id'],
- page = panel,
- text = " %s " % _("Layer properties"),
- select = True)
+ self.InsertPage(indx = self.page[pageId]['id'],
+ page = panel,
+ text = " %s " % _("Layer properties"),
+ select = True)
- self.notebook.ChangeSelection(current_page)
+ # self.ChangeSelection(current_page)
if pageId == 'surface':
self.UpdateSurfacePage(layer, data['surface'])
elif pageId == 'vector':
@@ -2572,7 +2549,7 @@
elif pageId == 'volume':
self.UpdateVectorPage(layer, data['vector'])
- self.notebook.Update()
+ self.Update()
self.pageChanging = False
def UpdateSurfacePage(self, layer, data):
@@ -2844,7 +2821,7 @@
def SetPage(self, name):
"""!Get named page"""
- self.notebook.SetSelection(self.page[name]['id'])
+ self.SetSelection(self.page[name]['id'])
class ViewPositionWindow(wx.Window):
"""!Position control window (for NvizToolWindow)"""
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -292,7 +292,7 @@
self.parent.toolbars['vdigit'].OnExit()
if self.parent.toolbars['nviz']:
self.parent.toolbars['nviz'].OnExit()
-
+
def Enable2D(self, enabled):
"""!Enable/Disable 2D display mode specific tools"""
for tool in (self.pointer,
@@ -1353,18 +1353,11 @@
)
def OnSettings(self, event):
- win = self.parent.nvizToolWin
- if not win.IsShown():
- self.parent.nvizToolWin.Show()
- else:
- self.parent.nvizToolWin.Hide()
-
+ """!Show nviz notebook page"""
+ self.parent.parent.lmgr.notebook.SetSelection(3)
+
def OnExit (self, event=None):
"""!Quit nviz tool (swith to 2D mode)"""
- # hide dialogs if still open
- if self.parent.nvizToolWin:
- self.parent.nvizToolWin.Hide()
-
# set default mouse settings
self.parent.MapWindow.mouse['use'] = "pointer"
self.parent.MapWindow.mouse['box'] = "point"
@@ -1372,7 +1365,7 @@
# disable the toolbar
self.parent.RemoveToolbar("nviz")
-
+
class ModelToolbar(AbstractToolbar):
"""!Graphical modeler toolbar (see gmodeler.py)
"""
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-05-31 09:41:42 UTC (rev 42403)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-05-31 10:13:00 UTC (rev 42404)
@@ -54,7 +54,10 @@
import wx.lib.agw.customtreectrl as CT
except ImportError:
import wx.lib.customtreectrl as CT
-import wx.lib.flatnotebook as FN
+try:
+ import wx.lib.agw.flatnotebook as FN
+except ImportError:
+ import wx.lib.flatnotebook as FN
sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
from grass.script import core as grass
@@ -81,6 +84,7 @@
import gui_modules.menu as menu
import gui_modules.gmodeler as gmodeler
import gui_modules.vclean as vclean
+import gui_modules.nviz_tools as nviz_tools
from gui_modules.debug import Debug
from gui_modules.ghelp import MenuTreeWindow
from gui_modules.ghelp import AboutWindow
@@ -203,11 +207,11 @@
cbStyle = globalvar.FNPageStyle
self.gm_cb = FN.FlatNotebook(self, id=wx.ID_ANY, style=cbStyle)
self.gm_cb.SetTabAreaColour(globalvar.FNPageColor)
- self.notebook.AddPage(self.gm_cb, text=_("Map layers for each display"))
+ self.notebook.AddPage(self.gm_cb, text=_("Map layers"))
# create command output text area and add it to main notebook page
self.goutput = goutput.GMConsole(self, pageid=1)
- self.outpage = self.notebook.AddPage(self.goutput, text=_("Command console"))
+ self.notebook.AddPage(self.goutput, text=_("Command console"))
# create 'search module' notebook page
self.search = MenuTreeWindow(parent = self)
@@ -219,7 +223,21 @@
self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosed)
return self.notebook
-
+
+ def AddNviz(self):
+ """!Add nviz notebook page"""
+ self.nviz = nviz_tools.NvizToolWindow(parent = self,
+ display = self.curr_page.maptree.GetMapDisplay())
+ self.notebook.AddPage(self.nviz, text = _("3D view"))
+ self.notebook.SetSelection(self.notebook.GetPageCount() - 1)
+
+ def RemoveNviz(self):
+ """!Remove nviz notebook page"""
+ # print self.notebook.GetPage(1)
+ self.notebook.RemovePage(3)
+ del self.nviz
+ self.notebook.SetSelection(0)
+
def WorkspaceChanged(self):
"""!Update window title"""
if not self.workspaceChanged:
More information about the grass-commit
mailing list