[GRASS-SVN] r42627 - in grass/trunk: gui/wxpython/gui_modules
include lib/nviz visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 21 19:11:30 EDT 2010
Author: martinl
Date: 2010-06-21 23:11:30 +0000 (Mon, 21 Jun 2010)
New Revision: 42627
Modified:
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_window.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/wxnviz.py
grass/trunk/include/nviz.h
grass/trunk/lib/nviz/lights.c
grass/trunk/lib/nviz/position.c
grass/trunk/visualization/nviz2/cmd/args.c
grass/trunk/visualization/nviz2/cmd/main.c
Log:
wxGUI/nviz & nviz_cmd in progress
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2010-06-21 23:11:30 UTC (rev 42627)
@@ -16,7 +16,6 @@
- CommandThread
Functions:
-
- RunCommand
(C) 2007-2008, 2010 by the GRASS Development Team
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2010-06-21 23:11:30 UTC (rev 42627)
@@ -51,13 +51,13 @@
Parent for BufferedWindow class (2D display mode) and
GLWindow (3D display mode)
"""
- def __init__(self, parent, id=wx.ID_ANY,
- pos=wx.DefaultPosition,
- size=wx.DefaultSize,
- style=wx.NO_FULL_REPAINT_ON_RESIZE,
- Map=None, tree=None, lmgr=None):
+ def __init__(self, parent, id = wx.ID_ANY,
+ Map = None, tree = None, lmgr = None):
self.parent = parent # MapFrame
-
+ self.Map = Map
+ self.tree = tree
+ self.lmgr = lmgr
+
#
# mouse attributes -- position on the screen, begin and end of
# dragging, and type of drawing
@@ -156,30 +156,17 @@
can also save the drawing to file by calling the
SaveToFile(self,file_name,file_type) method.
"""
-
- def __init__(self, parent, id,
- pos = wx.DefaultPosition,
- size = wx.DefaultSize,
- style=wx.NO_FULL_REPAINT_ON_RESIZE,
- Map=None, tree=None, lmgr=None):
-
- MapWindow.__init__(self, parent, id, pos, size, style,
- Map, tree, lmgr)
- wx.Window.__init__(self, parent, id, pos, size, style)
-
- self.Map = Map
- self.tree = tree
- self.lmgr = lmgr # Layer Manager
+ def __init__(self, parent, id = wx.ID_ANY,
+ style = wx.NO_FULL_REPAINT_ON_RESIZE,
+ Map = None, tree = None, lmgr = None, **kwargs):
+ MapWindow.__init__(self, parent, id, Map, tree, lmgr)
+ wx.Window.__init__(self, parent, id, style = style, **kwargs)
- #
- # Flags
- #
+ # flags
self.resize = False # indicates whether or not a resize event has taken place
self.dragimg = None # initialize variable for map panning
- #
- # Variable for drawing on DC
- #
+ # variables for drawing on DC
self.pen = None # pen for drawing zoom boxes, etc.
self.polypen = None # pen for drawing polylines (measurements, profiles, etc)
# List of wx.Point tuples defining a polyline (geographical coordinates)
@@ -189,9 +176,7 @@
# ID of poly line resulting from cumulative rubber band lines (e.g. measurement)
self.plineid = None
- #
- # Event bindings
- #
+ # event bindings
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_IDLE, self.OnIdle)
@@ -199,11 +184,9 @@
self.Bind(wx.EVT_MOUSE_EVENTS, self.MouseActions)
self.processMouse = True
- #
- # Render output objects
- #
+ # render output objects
self.mapfile = None # image file to be rendered
- self.img = "" # wx.Image object (self.mapfile)
+ self.img = None # wx.Image object (self.mapfile)
# used in digitization tool (do not redraw vector map)
self.imgVectorMap = None
# decoration overlays
@@ -214,14 +197,11 @@
self.textdict = {} # text, font, and color indexed by id
self.currtxtid = None # PseudoDC id for currently selected text
- #
- # Zoom objects
- #
- self.zoomhistory = [] # list of past zoom extents
- self.currzoom = 0 # current set of extents in zoom history being used
-
- self.zoomtype = 1 # 1 zoom in, 0 no zoom, -1 zoom out
- self.hitradius = 10 # distance for selecting map decorations
+ # zoom objects
+ self.zoomhistory = [] # list of past zoom extents
+ self.currzoom = 0 # current set of extents in zoom history being used
+ self.zoomtype = 1 # 1 zoom in, 0 no zoom, -1 zoom out
+ self.hitradius = 10 # distance for selecting map decorations
self.dialogOffset = 5 # offset for dialog (e.g. DisplayAttributesDialog)
# OnSize called to make sure the buffer is initialized.
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-06-21 23:11:30 UTC (rev 42627)
@@ -67,20 +67,14 @@
class GLWindow(MapWindow, glcanvas.GLCanvas):
"""!OpenGL canvas for Map Display Window"""
- def __init__(self, parent, id,
- pos = wx.DefaultPosition,
- size = wx.DefaultSize,
- style = wx.NO_FULL_REPAINT_ON_RESIZE,
+ def __init__(self, parent, id = wx.ID_ANY,
Map = None, tree = None, lmgr = None):
self.parent = parent # MapFrame
- self.Map = Map
- self.tree = tree
- self._layermanager = lmgr
glcanvas.GLCanvas.__init__(self, parent, id)
- MapWindow.__init__(self, parent, id, pos, size, style,
- Map, tree, self._layermanager)
+ MapWindow.__init__(self, parent, id,
+ Map, tree, lmgr)
self.Hide()
self.init = False
@@ -103,9 +97,9 @@
#
# create nviz instance
#
- if self._layermanager:
- logerr = self._layermanager.goutput.cmd_stderr
- logmsg = self._layermanager.goutput.cmd_output
+ if self.lmgr:
+ logerr = self.lmgr.goutput.cmd_stderr
+ logmsg = self.lmgr.goutput.cmd_output
else:
logerr = logmsg = None
self.nvizThread = NvizThread(logerr,
@@ -177,21 +171,21 @@
if not self.init:
self.ResetView()
- if hasattr(self._layermanager, "nviz"):
- self._layermanager.nviz.UpdatePage('view')
- self._layermanager.nviz.UpdatePage('light')
+ if hasattr(self.lmgr, "nviz"):
+ self.lmgr.nviz.UpdatePage('view')
+ self.lmgr.nviz.UpdatePage('light')
layer = self.GetSelectedLayer()
if layer:
if layer.type == 'raster':
- self._layermanager.nviz.UpdatePage('surface')
+ self.lmgr.nviz.UpdatePage('surface')
elif layer.type == 'vector':
- self._layermanager.nviz.UpdatePage('vector')
+ self.lmgr.nviz.UpdatePage('vector')
- ### self._layermanager.nviz.UpdateSettings()
+ ### self.lmgr.nviz.UpdateSettings()
# update widgets
- win = self._layermanager.nviz.FindWindowById( \
- self._layermanager.nviz.win['vector']['lines']['surface'])
+ win = self.lmgr.nviz.FindWindowById( \
+ self.lmgr.nviz.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames('raster'))
self.init = True
@@ -224,8 +218,8 @@
self.view['persp']['value'] = 100
if prev_value != self.view['persp']['value']:
- if hasattr(self._layermanager, "nviz"):
- self._layermanager.nviz.UpdateSettings()
+ if hasattr(self.lmgr, "nviz"):
+ self.lmgr.nviz.UpdateSettings()
self._display.SetView(self.view['pos']['x'], self.view['pos']['y'],
self.iview['height']['value'],
@@ -433,7 +427,7 @@
except gcmd.NvizError, e:
print >> sys.stderr, "Nviz:" + e.message
- self._layermanager.nviz.UpdateSettings()
+ self.lmgr.nviz.UpdateSettings()
stop = time.time()
@@ -552,9 +546,9 @@
wx.PostEvent(self, event)
# update tools window
- if hasattr(self._layermanager, "nviz") and \
+ if hasattr(self.lmgr, "nviz") and \
item == self.GetSelectedLayer(type = 'item'):
- toolWin = self._layermanager.nviz
+ toolWin = self.lmgr.nviz
if layer.type == 'raster':
win = toolWin.FindWindowById( \
toolWin.win['vector']['lines']['surface'])
@@ -614,9 +608,9 @@
self.layers.remove(item)
# update tools window
- if hasattr(self._layermanager, "nviz") and \
+ if hasattr(self.lmgr, "nviz") and \
layer.type == 'raster':
- toolWin = self._layermanager.nviz
+ toolWin = self.lmgr.nviz
win = toolWin.FindWindowById( \
toolWin.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames(layer.type))
@@ -673,9 +667,9 @@
wx.PostEvent(self, event)
# update tools window
- if hasattr(self._layermanager, "nviz") and \
+ if hasattr(self.lmgr, "nviz") and \
item == self.GetSelectedLayer(type = 'item'):
- toolWin = self._layermanager.nviz
+ toolWin = self.lmgr.nviz
toolWin.UpdatePage('vector')
toolWin.SetPage('vector')
@@ -720,9 +714,9 @@
### self.layers.remove(id)
# update tools window
- if hasattr(self._layermanager, "nviz") and \
+ if hasattr(self.lmgr, "nviz") and \
vecType is None:
- toolWin = self._layermanager.nviz
+ toolWin = self.lmgr.nviz
# remove surface page
if toolWin.GetSelection() == toolWin.page['surface']['id']:
toolWin.RemovePage(toolWin.page['surface']['id'])
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2010-06-21 23:11:30 UTC (rev 42627)
@@ -2271,6 +2271,7 @@
zmin = self.mapWindow.view['z-exag']['min']
zmax = self.mapWindow.view['z-exag']['max']
zval = self.mapWindow.view['z-exag']['value']
+ print hmin, hmax, hval
for control in ('spin', 'slider'):
self.FindWindowById(self.win['view']['height'][control]).SetRange(hmin,
hmax)
Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2010-06-21 23:11:30 UTC (rev 42627)
@@ -184,10 +184,10 @@
@param w local coordinate (default to 0)
"""
Nviz_set_light_position(self.data, lid, x, y, z, w)
- Nviz_set_light_color(self.data, lid, color[0] / 255., color[1] / 255., color[2] / 255.)
Nviz_set_light_bright(self.data, lid, bright)
- Nviz_set_light_ambient(self.data, lid, ambient, ambient, ambient)
-
+ Nviz_set_light_color(self.data, lid, int(color[0]), int(color[1]), int(color[2]))
+ Nviz_set_light_ambient(self.data, lid, ambient)
+
def LoadSurface(self, name, color_name, color_value):
"""!Load raster map (surface)
Modified: grass/trunk/include/nviz.h
===================================================================
--- grass/trunk/include/nviz.h 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/include/nviz.h 2010-06-21 23:11:30 UTC (rev 42627)
@@ -168,7 +168,7 @@
int Nviz_set_light_position(nv_data *, int, double, double, double, double);
int Nviz_set_light_bright(nv_data *, int, double);
int Nviz_set_light_color(nv_data *, int, int, int, int);
-int Nviz_set_light_ambient(nv_data *, int, double, double, double);
+int Nviz_set_light_ambient(nv_data *, int, double);
int Nviz_init_light(nv_data *, int);
int Nviz_new_light(nv_data *);
Modified: grass/trunk/lib/nviz/lights.c
===================================================================
--- grass/trunk/lib/nviz/lights.c 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/lib/nviz/lights.c 2010-06-21 23:11:30 UTC (rev 42627)
@@ -27,6 +27,7 @@
int Nviz_set_light_position(nv_data * data, int num,
double x, double y, double z, double w)
{
+ /*
double xpos, ypos;
xpos = x;
xpos = (xpos < 0) ? 0 : (xpos > 1.0) ? 1.0 : xpos;
@@ -37,7 +38,7 @@
G_debug(0, "Invalid light position coordinates (%f,%f), using %f,%f",
x, y, xpos, 1.0 - ypos);
}
-
+ */
num--;
data->light[num].id = num + 1;
data->light[num].x = x;
@@ -98,8 +99,8 @@
g = data->light[num].g * data->light[num].brt;
b = data->light[num].b * data->light[num].brt;
- G_debug(0, "Nviz_set_light_color(): num = %d r = %f g = %f b = %f",
- num + 1, r, g, b);
+ G_debug(0, "Nviz_set_light_color(): num = %d r = %d/%f g = %d/%f b = %d/%f",
+ num + 1, red, r, green, g, blue, b);
GS_setlight_color(num + 1, r, g, b);
return 1;
@@ -110,20 +111,19 @@
\param data nviz data
\param num light num (starts at 1)
- \param red,green,blue rGB values (0-1)
+ \param value ambient value (same for R/G/B) (0-1)
*/
-int Nviz_set_light_ambient(nv_data * data, int num,
- double red, double green, double blue)
+int Nviz_set_light_ambient(nv_data * data, int num, double value)
{
num--;
- data->light[num].ar = red;
- data->light[num].ag = green;
- data->light[num].ab = blue;
+ data->light[num].ar = value;
+ data->light[num].ag = value;
+ data->light[num].ab = value;
- G_debug(0, "Nviz_set_light_ambient(): num = %d r = %f g = %f b = %f",
- num + 1, red, green, blue);
- GS_setlight_ambient(num + 1, red, green, blue);
-
+ G_debug(0, "Nviz_set_light_ambient(): num = %d value = %f",
+ num + 1, value);
+ GS_setlight_ambient(num + 1, value, value, value);
+
return 1;
}
Modified: grass/trunk/lib/nviz/position.c
===================================================================
--- grass/trunk/lib/nviz/position.c 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/lib/nviz/position.c 2010-06-21 23:11:30 UTC (rev 42627)
@@ -26,14 +26,14 @@
Nviz_set_focus_state(1); /* center of view */
/* set default lights (1 & 2) */
- Nviz_set_light_position(data, 1, 0.68, 0.68, 0.80, 0.0);
+ Nviz_set_light_position(data, 1, 0.68, -0.68, 0.80, 0.0);
Nviz_set_light_bright(data, 1, 0.8);
- Nviz_set_light_color(data, 1, 1.0, 1.0, 1.0);
- Nviz_set_light_ambient(data, 1, 0.2, 0.2, 0.2);
+ Nviz_set_light_color(data, 1, 255, 255, 255);
+ Nviz_set_light_ambient(data, 1, 0.2);
Nviz_set_light_position(data, 2, 0.0, 0.0, 1.0, 0.0);
Nviz_set_light_bright(data, 2, 0.5);
- Nviz_set_light_color(data, 2, 1.0, 1.0, 1.0);
- Nviz_set_light_ambient(data, 2, 0.3, 0.3, 0.3);
+ Nviz_set_light_color(data, 2, 255, 255, 255);
+ Nviz_set_light_ambient(data, 2, 0.3);
return;
}
Modified: grass/trunk/visualization/nviz2/cmd/args.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/args.c 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/visualization/nviz2/cmd/args.c 2010-06-21 23:11:30 UTC (rev 42627)
@@ -572,7 +572,7 @@
params->light_pos->description =
_("Light position (x,y,z model coordinates)");
params->light_pos->guisection = _("Lighting");
- params->light_pos->answer = "0.68,0.68,0.80";
+ params->light_pos->answer = "0.68,-0.68,0.80";
params->light_color = G_define_standard_option(G_OPT_C_FG);
params->light_color->key = "light_color";
Modified: grass/trunk/visualization/nviz2/cmd/main.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/main.c 2010-06-21 22:47:38 UTC (rev 42626)
+++ grass/trunk/visualization/nviz2/cmd/main.c 2010-06-21 23:11:30 UTC (rev 42627)
@@ -35,7 +35,6 @@
int ret;
int red, grn, blu;
double vp_height, z_exag; /* calculated viewpoint height, z-exag */
- double light_ambient;
int width, height; /* output image size */
char *output_name;
@@ -103,9 +102,8 @@
red = grn = blu = 255;
}
Nviz_set_light_color(&data, 1, red, grn, blu);
- light_ambient = atof(params->light_ambient->answer) / 100.0;
Nviz_set_light_ambient(&data, 1,
- light_ambient, light_ambient, light_ambient);
+ atof(params->light_ambient->answer) / 100.0);
/* load raster maps (surface topography) & set attributes (map/constant) */
load_rasters(params, &data);
@@ -145,8 +143,9 @@
}
else {
z_exag = Nviz_get_exag();
- G_message(_("Vertical exaggeration not given, using calculated value %.0f"),
- z_exag);
+ G_verbose_message(_("Vertical exaggeration not given, using calculated "
+ "value %.0f"),
+ z_exag);
}
Nviz_change_exag(&data, z_exag);
@@ -155,8 +154,9 @@
}
else {
Nviz_get_exag_height(&vp_height, NULL, NULL);
- G_message(_("Viewpoint height not given, using calculated value %.0f"),
- vp_height);
+ G_verbose_message(_("Viewpoint height not given, using calculated "
+ "value %.0f"),
+ vp_height);
}
Nviz_set_viewpoint_height(vp_height);
More information about the grass-commit
mailing list