[GRASS-SVN] r32001 - in grass/trunk/gui/wxpython: gui_modules nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jul 5 09:26:41 EDT 2008
Author: martinl
Date: 2008-07-05 09:26:40 -0400 (Sat, 05 Jul 2008)
New Revision: 32001
Modified:
grass/trunk/gui/wxpython/gui_modules/nviz.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
grass/trunk/gui/wxpython/nviz/init.cpp
grass/trunk/gui/wxpython/nviz/nviz.h
grass/trunk/gui/wxpython/nviz/surface.cpp
Log:
nviz2/wxGUI: set vector mode (line width, color and flat), general settings (background color)
Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-05 11:29:58 UTC (rev 32000)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-05 13:26:40 UTC (rev 32001)
@@ -432,16 +432,21 @@
#
self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
+ self.page = {}
# view page
self.__createViewPage()
+ self.page['view'] = 0
# surface page
self.__createSurfacePage()
- self.UpdatePage('surface')
+ self.page['surface'] = 1
# vector page
self.__createVectorPage()
- self.UpdatePage('vector')
+ self.page['vector'] = 2
# settings page
self.__createSettingsPage()
+ self.page['settings'] = 3
+ self.UpdatePage('surface')
+ self.UpdatePage('vector')
self.UpdatePage('settings')
mainSizer.Add(item=self.notebook, proportion=1,
@@ -903,10 +908,11 @@
width = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
initial=1,
min=1,
- max=100) # TODO
- # width.SetName("value")
- # self.win['vector']['lines']['width'] = width.GetId()
- # width.Bind(wx.EVT_SPINCTRL, self.OnVectorWidth)
+ max=100)
+ width.SetValue(UserSettings.Get(group='nviz', key='vector',
+ subkey=['lines', 'width']))
+ self.win['vector']['lines']['width'] = width.GetId()
+ width.Bind(wx.EVT_SPINCTRL, self.OnVectorLines)
gridSizer.Add(item=width, pos=(0, 1),
flag=wx.ALIGN_CENTER_VERTICAL)
@@ -917,7 +923,12 @@
label=_("Color:")),
pos=(0, 3), flag=wx.ALIGN_CENTER_VERTICAL)
- color = csel.ColourSelect(panel, id=wx.ID_ANY)
+ color = csel.ColourSelect(panel, id=wx.ID_ANY,
+ colour=UserSettings.Get(group='nviz', key='vector',
+ subkey=['lines', 'color']))
+ self.win['vector']['lines']['color'] = color.GetId()
+ color.Bind(csel.EVT_COLOURSELECT, self.OnVectorLines)
+
gridSizer.Add(item=color, pos=(0, 4))
gridSizer.AddGrowableCol(5)
@@ -930,8 +941,14 @@
display = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
choices = [_("on surface"),
_("flat")])
- display.SetSelection(0)
+ if UserSettings.Get(group='nviz', key='vector',
+ subkey=['lines', 'flat']):
+ display.SetSelection(1)
+ else:
+ display.SetSelection(0)
+ self.win['vector']['lines']['flat'] = display.GetId()
display.Bind(wx.EVT_CHOICE, self.OnVectorDisplay)
+
gridSizer.Add(item=display, flag=wx.ALIGN_CENTER_VERTICAL,
pos=(0, 7))
@@ -974,8 +991,39 @@
self.win['settings'] = {}
+ #
+ # general
+ #
+ self.win['settings']['general'] = {}
+ box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
+ label=" %s " % (_("General")))
+ boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+ gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
+
+ # background color
+ gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+ label=_("Background color:")),
+ pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
+
+ color = csel.ColourSelect(panel, id=wx.ID_ANY,
+ colour=UserSettings.Get(group='nviz', key='settings',
+ subkey=['general', 'bgcolor']))
+ self.win['settings']['general']['bgcolor'] = color.GetId()
+ color.Bind(csel.EVT_COLOURSELECT, self.OnSettings)
+ gridSizer.Add(item=color, pos=(0, 1))
+
+
+ boxSizer.Add(item=gridSizer, proportion=1,
+ flag=wx.ALL | wx.EXPAND, border=3)
+ pageSizer.Add(item=boxSizer, proportion=0,
+ flag=wx.EXPAND | wx.ALL,
+ border=5)
+
panel.SetSizer(pageSizer)
+
+ panel.SetSizer(pageSizer)
+
def CreateControl(self, parent, dict, name, sliderHor=True, size=200):
"""Add control (Slider + SpinCtrl)"""
dict[name] = {}
@@ -1181,9 +1229,17 @@
layer = self.mapWindow.GetSelectedLayer()
id = self.mapWindow.GetMapObjId(layer)
- #
- # surface
- #
+ if layer.type == 'raster':
+ self.ApplySurface(id)
+ elif layer.type == 'vector':
+ self.ApplyVector(id)
+
+ self.ApplySettings()
+
+ self.mapWindow.Refresh(False)
+
+ def ApplySurface(self, id):
+ """Apply changes for surfaces"""
# surface attributes
for attrb in ('topo', 'color', 'mask',
'transp', 'shine', 'emit'):
@@ -1242,8 +1298,28 @@
else:
self.mapWindow.nvizClass.SetWireColor(-1, str(color))
- self.mapWindow.Refresh(False)
+ def ApplyVector(self, id):
+ """Apply changes for vector"""
+ width = self.FindWindowById(self.win['vector']['lines']['width']).GetValue()
+ color = self.FindWindowById(self.win['vector']['lines']['color']).GetColour()
+ color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
+
+ if self.FindWindowById(self.win['vector']['lines']['flat']).GetSelection() == 0:
+ flat = False
+ else:
+ flat = True
+
+ self.mapWindow.nvizClass.SetVectorLineMode(id, str(color), width, flat)
+
+ def ApplySettings(self):
+ """Apply changes in settings"""
+ # bgcolor
+ color = self.FindWindowById(self.win['settings']['general']['bgcolor']).GetColour()
+ color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
+
+ self.mapWindow.nvizClass.SetBgColor(str(color))
+
def OnClose(self, event):
"""Close button pressed
@@ -1424,8 +1500,21 @@
else: # flat
self.FindWindowById(self.win['vector']['lines']['surface']).Enable(False)
+ self.OnVectorLines(event)
+
event.Skip()
-
+
+ def OnVectorLines(self, event):
+ """Set vector lines mode, apply changes if auto-rendering is enabled"""
+ if self.parent.autoRender.IsChecked():
+ self.OnApply(None)
+
+ def OnSettings(self, event):
+ """Update settings, apply changes if auto-rendering is enabled"""
+
+ if self.parent.autoRender.IsChecked():
+ self.OnApply(None)
+
def UpdatePage(self, pageId):
"""Update dialog (selected page)"""
layer = self.mapWindow.GetSelectedLayer()
@@ -1479,11 +1568,12 @@
win = self.FindWindowById(self.win['surface'][attr]['const'])
win.SetValue(data['value'])
+ elif pageId == 'vector':
+ pass
def SetPage(self, name):
"""Get named page"""
- if name == 'surface':
- self.notebook.SetSelection(1)
+ self.notebook.SetSelection(self.page[name])
class ViewPositionWindow(wx.Window):
"""Position control window (for NvizToolWindow)"""
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-07-05 11:29:58 UTC (rev 32000)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-07-05 13:26:40 UTC (rev 32001)
@@ -248,6 +248,19 @@
'z' : 0,
},
},
+ 'vector' : {
+ 'lines' : {
+ 'width' : 2,
+ 'color' : (0, 0, 255, 255), # blue
+ 'flat' : False,
+ 'height' : 0,
+ },
+ },
+ 'settings': {
+ 'general' : {
+ 'bgcolor' : (255, 255, 255, 255), # white
+ },
+ },
},
}
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-05 11:29:58 UTC (rev 32000)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-05 13:26:40 UTC (rev 32001)
@@ -908,7 +908,13 @@
# update nviz tools
if self.mapdisplay.toolbars['nviz']:
- self.mapdisplay.nvizToolWin.UpdatePage('surface')
+ type = self.GetPyData(self.layer_selected)[0]['maplayer'].type
+ if type == 'raster':
+ self.mapdisplay.nvizToolWin.UpdatePage('surface')
+ self.mapdisplay.nvizToolWin.SetPage('surface')
+ elif type == 'vector':
+ self.mapdisplay.nvizToolWin.UpdatePage('vector')
+ self.mapdisplay.nvizToolWin.SetPage('vector')
def OnCollapseNode(self, event):
"""
Modified: grass/trunk/gui/wxpython/nviz/init.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-05 11:29:58 UTC (rev 32000)
+++ grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-05 13:26:40 UTC (rev 32001)
@@ -114,3 +114,15 @@
{
return;
}
+
+/*!
+ \brief Set background color
+
+ \param color_str color string
+*/
+void Nviz::SetBgColor(const char *color_str)
+{
+ data->bgcolor = Nviz_color_from_str(color_str);
+
+ return;
+}
Modified: grass/trunk/gui/wxpython/nviz/nviz.h
===================================================================
--- grass/trunk/gui/wxpython/nviz/nviz.h 2008-07-05 11:29:58 UTC (rev 32000)
+++ grass/trunk/gui/wxpython/nviz/nviz.h 2008-07-05 13:26:40 UTC (rev 32001)
@@ -1,5 +1,5 @@
-#ifndef __NVIZ_H__
-#define __NVIZ_H__
+#ifndef WXNVIZ_H
+#define WXNVIZ_H
#include <vector>
@@ -57,6 +57,7 @@
int SetDisplay(void *);
void InitView();
void Reset();
+ void SetBgColor(const char *);
/* lights.cpp */
void SetLightsDefault();
@@ -84,6 +85,9 @@
int SetSurfaceRes(int, int, int);
int SetSurfaceStyle(int, int);
int SetWireColor(int, const char *);
+
+ /* vector */
+ int SetVectorLineMode(int, const char *, int, int);
};
-#endif /* __NVIZ_H__ */
+#endif /* WXNVIZ_H */
Modified: grass/trunk/gui/wxpython/nviz/surface.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/surface.cpp 2008-07-05 11:29:58 UTC (rev 32000)
+++ grass/trunk/gui/wxpython/nviz/surface.cpp 2008-07-05 13:26:40 UTC (rev 32001)
@@ -1,7 +1,7 @@
/**
- \file map_obj.cpp
+ \file surface.cpp
- \brief Experimental C++ wxWidgets Nviz prototype -- map object management
+ \brief Experimental C++ wxWidgets Nviz prototype -- surface attributes
Used by wxGUI Nviz extension.
More information about the grass-commit
mailing list