[GRASS-SVN] r44214 - in grass/branches/releasebranch_6_4: include
include/Make lib/nviz visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 7 10:59:20 EST 2010
Author: martinl
Date: 2010-11-07 07:59:20 -0800 (Sun, 07 Nov 2010)
New Revision: 44214
Modified:
grass/branches/releasebranch_6_4/include/Make/Platform.make.in
grass/branches/releasebranch_6_4/include/nviz.h
grass/branches/releasebranch_6_4/lib/nviz/change_view.c
grass/branches/releasebranch_6_4/lib/nviz/cplanes_obj.c
grass/branches/releasebranch_6_4/lib/nviz/draw.c
grass/branches/releasebranch_6_4/lib/nviz/exag.c
grass/branches/releasebranch_6_4/lib/nviz/lights.c
grass/branches/releasebranch_6_4/lib/nviz/map_obj.c
grass/branches/releasebranch_6_4/lib/nviz/nviz.c
grass/branches/releasebranch_6_4/lib/nviz/position.c
grass/branches/releasebranch_6_4/lib/nviz/render.c
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/Makefile
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/args.c
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/description.html
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/local_proto.h
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/main.c
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/surface.c
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/vector.c
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/volume.c
grass/branches/releasebranch_6_4/visualization/nviz2/cmd/write_img.c
Log:
backport nvizlib & nviz_cmd from devbr6
Modified: grass/branches/releasebranch_6_4/include/Make/Platform.make.in
===================================================================
--- grass/branches/releasebranch_6_4/include/Make/Platform.make.in 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/include/Make/Platform.make.in 2010-11-07 15:59:20 UTC (rev 44214)
@@ -160,10 +160,11 @@
OPENGLLIB = @OPENGLLIB@
OPENGLULIB = @OPENGLULIB@
OPENGLWM = @OPENGLWM@
-#USE_GLWM = @USE_GLWM@
+# USE_GLWM = @USE_GLWM@
OPENGL_X11 = @OPENGL_X11@
OPENGL_AQUA = @OPENGL_AQUA@
OPENGL_WINDOWS = @OPENGL_WINDOWS@
+USE_OPENGL = @USE_OPENGL@
#tcl/tk stuff
TCLINCDIR = @TCLINCDIR@
Modified: grass/branches/releasebranch_6_4/include/nviz.h
===================================================================
--- grass/branches/releasebranch_6_4/include/nviz.h 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/include/nviz.h 2010-11-07 15:59:20 UTC (rev 44214)
@@ -76,6 +76,14 @@
float x, y, z, w; /* position */
} light_data;
+struct fringe_data
+{
+ int id;
+ unsigned long color;
+ float elev;
+ int where[4];
+};
+
typedef struct
{
/* ranges */
@@ -89,37 +97,16 @@
/* light */
light_data light[MAX_LIGHTS];
-
+
+ /* fringe */
+ int num_fringes;
+ struct fringe_data **fringe;
+
/* background color */
int bgcolor;
} nv_data;
-/* The following structure is used to associate client data with surfaces.
- * We do this so that we don't have to rely on the surface ID (which is libal to change
- * between subsequent executions of nviz) when saving set-up info to files.
- */
-
-typedef struct
-{
- /* We use logical names to assign textual names to map objects.
- When Nviz needs to refer to a map object it uses the logical name
- rather than the map ID. By setting appropriate logical names, we
- can reuse names inbetween executions of Nviz. The Nviz library
- also provides a mechanism for aliasing between logical names.
- Thus several logical names may refer to the same map object.
- Aliases are meant to support the case in which two logical names
- happen to be the same. The Nviz library automatically assigns
- logical names uniquely if they are not specified in the creation
- of a map object. When loading a saved file containing several map
- objects, it is expected that the map 0bjects will be aliased to
- their previous names. This ensures that old scripts will work.
- */
-
- char *logical_name;
-
-} nv_clientdata;
-
struct render_window
{
#if defined(OPENGL_X11)
@@ -141,11 +128,11 @@
/* change_view.c */
int Nviz_resize_window(int, int);
int Nviz_update_ranges(nv_data *);
-int Nviz_set_viewpoint_position(nv_data *, float, float);
-int Nviz_set_viewpoint_height(nv_data *, float);
-int Nviz_set_viewpoint_persp(nv_data *, int);
-int Nviz_set_viewpoint_twist(nv_data *, int);
-int Nviz_change_exag(nv_data *, float);
+int Nviz_set_viewpoint_position(double, double);
+int Nviz_set_viewpoint_height(double);
+int Nviz_set_viewpoint_persp(int);
+int Nviz_set_viewpoint_twist(int);
+int Nviz_change_exag(nv_data *, double);
/* cplanes_obj.c */
int Nviz_new_cplane(nv_data *, int);
@@ -154,27 +141,27 @@
/* draw.c */
int Nviz_draw_all_surf(nv_data *);
-int Nviz_draw_all_vect(nv_data *);
-int Nviz_draw_all_site(nv_data *);
-int Nviz_draw_all_vol(nv_data *);
+int Nviz_draw_all_vect();
+int Nviz_draw_all_site();
+int Nviz_draw_all_vol();
int Nviz_draw_all(nv_data *);
int Nviz_draw_quick(nv_data *, int);
/* exag.c */
-int Nviz_get_exag_height(float *, float *, float *);
-float Nviz_get_exag();
+int Nviz_get_exag_height(double *, double *, double *);
+double Nviz_get_exag();
/* lights.c */
-int Nviz_set_light_position(nv_data *, int, float, float, float, float);
-int Nviz_set_light_bright(nv_data *, int, float);
-int Nviz_set_light_color(nv_data *, int, float, float, float);
-int Nviz_set_light_ambient(nv_data *, int, float, float, float);
+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);
int Nviz_init_light(nv_data *, int);
int Nviz_new_light(nv_data *);
/* map_obj.c */
-int Nviz_new_map_obj(int, const char *, float, nv_data *);
-int Nviz_set_attr(int, int, int, int, const char *, float, nv_data *);
+int Nviz_new_map_obj(int, const char *, double, nv_data *);
+int Nviz_set_attr(int, int, int, int, const char *, double, nv_data *);
void Nviz_set_surface_attr_default();
int Nviz_set_vpoint_attr_default();
int Nviz_set_volume_attr_default();
@@ -182,11 +169,17 @@
/* nviz.c */
void Nviz_init_data(nv_data *);
+void Nviz_destroy_data(nv_data *);
void Nviz_set_bgcolor(nv_data *, int);
+int Nviz_get_bgcolor(nv_data *);
int Nviz_color_from_str(const char *);
+struct fringe_data *Nviz_new_fringe(nv_data *, int, unsigned long,
+ double, int, int, int, int);
+struct fringe_data *Nviz_set_fringe(nv_data *, int, unsigned long,
+ double, int, int, int, int);
/* position.c */
-void Nviz_init_view();
+void Nviz_init_view(nv_data *);
int Nviz_set_focus_state(int);
int Nviz_set_focus_map(int, int);
Modified: grass/branches/releasebranch_6_4/lib/nviz/change_view.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/change_view.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/change_view.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,15 @@
/*!
- \file change_view.c
+ \file lib/nviz/change_view.c
- \brief Change view settings
+ \brief Nviz library -- Change view settings
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/change_view.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
@@ -40,6 +36,7 @@
ret = 0;
}
+ G_debug(1, "Nviz_resize_window(): width = %d height = %d", width, height);
GS_set_viewport(0, width, 0, height);
/* GS_clear(0x0000FF); causes red flash - debug only */
@@ -94,7 +91,7 @@
\return 1
*/
-int Nviz_set_viewpoint_position(nv_data * data, float x_pos, float y_pos)
+int Nviz_set_viewpoint_position(double x_pos, double y_pos)
{
float xpos, ypos, from[3];
float tempx, tempy;
@@ -105,10 +102,11 @@
ypos = (ypos < 0) ? 0 : (ypos > 1.0) ? 1.0 : ypos;
if (x_pos < 0.0 || x_pos > 1.0 || y_pos < 0.0 || y_pos > 1.0) {
- G_warning(_("Invalid view position coordinates, using %f,%f"),
+ G_debug(3, "Invalid view position coordinates, using %f,%f",
xpos, 1.0 - ypos);
}
+ G_debug(1, "Nviz_set_viewpoint_position(): x = %f y = %f", x_pos, y_pos);
GS_get_from(from);
tempx = xpos * RANGE - RANGE_OFFSET;
@@ -135,10 +133,12 @@
\return 1
*/
-int Nviz_set_viewpoint_height(nv_data * data, float height)
+int Nviz_set_viewpoint_height(double height)
{
float from[3];
+ G_debug(1, "Nviz_set_viewpoint_height(): value = %f", height);
+
GS_get_from_real(from);
if (height != from[Z]) {
@@ -165,10 +165,12 @@
\return 1
*/
-int Nviz_set_viewpoint_persp(nv_data * data, int persp)
+int Nviz_set_viewpoint_persp(int persp)
{
int fov;
+ G_debug(1, "Nviz_set_viewpoint_persp(): value = %d", persp);
+
fov = (int)(10 * persp);
GS_set_fov(fov);
@@ -185,8 +187,9 @@
\return 1
*/
-int Nviz_set_viewpoint_twist(nv_data * data, int twist)
+int Nviz_set_viewpoint_twist(int twist)
{
+ G_debug(1, "Nviz_set_viewpoint_twist(): value = %d", twist);
GS_set_twist(10 * twist);
/* Nviz_draw_quick(data); */
@@ -202,10 +205,11 @@
\return 1
*/
-int Nviz_change_exag(nv_data * data, float exag)
+int Nviz_change_exag(nv_data * data, double exag)
{
- float temp;
+ double temp;
+ G_debug(1, "Nviz_change_exag(): value = %f", exag);
temp = GS_global_exag();
if (exag != temp) {
Modified: grass/branches/releasebranch_6_4/lib/nviz/cplanes_obj.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/cplanes_obj.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/cplanes_obj.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,15 @@
/*!
- \file cplanes_obj.c
-
+ \file lib/nviz/cplanes_obj.c
+
\brief Nviz library -- Clip planes manipulation
-
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
+
Based on visualization/nviz/src/cutplanes_obj.c
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/nviz.h>
Modified: grass/branches/releasebranch_6_4/lib/nviz/draw.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/draw.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/draw.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,20 +1,16 @@
/*!
- \file draw.c
+ \file lib/nviz/draw.c
\brief Nviz library -- Draw map objects to GLX context
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/draw.c and
visualization/nviz/src/togl_flythrough.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/nviz.h>
@@ -115,11 +111,9 @@
/*!
\brief Draw all loaded vector sets (lines)
- \param dc nviz data
-
\return 1
*/
-int Nviz_draw_all_vect(nv_data * dc)
+int Nviz_draw_all_vect()
{
// GS_set_cancel(0);
@@ -142,11 +136,9 @@
/*!
\brief Draw all loaded vector point sets
- \param dc nviz data
-
\return 1
*/
-int Nviz_draw_all_site(nv_data * dc)
+int Nviz_draw_all_site()
{
int i;
int *site_list, nsites;
@@ -172,12 +164,10 @@
/*!
\brief Draw all loaded volume sets
-
- \param dc nviz data
\return 1
*/
-int Nviz_draw_all_vol(nv_data * dc)
+int Nviz_draw_all_vol()
{
int *vol_list, nvols, i;
@@ -208,10 +198,9 @@
*/
int Nviz_draw_all(nv_data * data)
{
+ int i;
int draw_surf, draw_vect, draw_site, draw_vol;
- int draw_north_arrow, arrow_x, draw_label, draw_legend;
- int draw_fringe, draw_scalebar, draw_bar_x;
-
+
draw_surf = 1;
draw_vect = 1;
draw_site = 1;
@@ -244,6 +233,11 @@
if (draw_vol)
Nviz_draw_all_vol(data);
+ for(i = 0; i < data->num_fringes; i++) {
+ struct fringe_data * f = data->fringe[i];
+ GS_draw_fringe(f->id, f->color, f->elev, f->where);
+ }
+
GS_done_draw();
GS_set_draw(GSD_BACK);
Modified: grass/branches/releasebranch_6_4/lib/nviz/exag.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/exag.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/exag.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,15 @@
/*!
- \file exag.c
+ \file lib/nviz/exag.c
\brief Nviz library -- Exaggeration functions
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/exag.c
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/nviz.h>
@@ -29,7 +25,7 @@
\return 1
*/
-int Nviz_get_exag_height(float *val, float *min, float *max)
+int Nviz_get_exag_height(double *val, double *min, double *max)
{
float longdim, exag, texag, hmin, hmax, fmin, fmax;
int nsurfs, i, *surf_list;
@@ -64,6 +60,9 @@
if (max)
*max = fmax;
+ G_debug(1, "Nviz_get_exag_height(): value = %f min = %f max = %f",
+ *val, min ? *min : 0.0 , max ? *max : 0.0);
+
return 1;
}
@@ -74,7 +73,7 @@
\return value
*/
-float Nviz_get_exag()
+double Nviz_get_exag()
{
float exag, texag;
int nsurfs, i, *surf_list;
@@ -95,5 +94,6 @@
if (nsurfs > 0)
G_free(surf_list);
+ G_debug(1, "Nviz_get_exag(): value = %f", exag);
return exag;
}
Modified: grass/branches/releasebranch_6_4/lib/nviz/lights.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/lights.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/lights.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,15 @@
/*!
- \file lights.c
+ \file lib/nviz/lights.c
- \brief Nviz library -- Change view settings
+ \brief Nviz library -- Change lighting settings
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/lights.c
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
@@ -23,18 +19,35 @@
\brief Set light position
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
\param x,y,z,w position, model coordinates
+
+ \return 1
*/
int Nviz_set_light_position(nv_data * data, int num,
- float x, float y, float z, float w)
+ double x, double y, double z, double w)
{
+ /*
+ double xpos, ypos;
+ xpos = x;
+ xpos = (xpos < 0) ? 0 : (xpos > 1.0) ? 1.0 : xpos;
+ ypos = 1.0 - y;
+ ypos = (ypos < 0) ? 0 : (ypos > 1.0) ? 1.0 : ypos;
+
+ if (x < 0.0 || x > 1.0 || y < 0.0 || y > 1.0) {
+ G_debug(1, "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;
data->light[num].y = y;
data->light[num].z = z;
data->light[num].w = w;
+ G_debug(1, "Nviz_set_light_position(): num = %d x = %f y = %f z = %f w = %f",
+ num + 1, x, y, z, w);
GS_setlight_position(num + 1, x, y, z, w);
return 1;
@@ -44,19 +57,22 @@
\brief Set light brightness
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
\param value brightness value
*/
-int Nviz_set_light_bright(nv_data * data, int num, float value)
+int Nviz_set_light_bright(nv_data * data, int num, double value)
{
- float r, g, b;
+ double r, g, b;
+ num--;
data->light[num].brt = value;
r = data->light[num].r * data->light[num].brt;
g = data->light[num].g * data->light[num].brt;
b = data->light[num].b * data->light[num].brt;
+ G_debug(1, "Nviz_set_light_bright(): num = %d value = %f r = %f g = %f b = %f",
+ num + 1, value, r, g, b);
GS_setlight_color(num + 1, r, g, b);
return 1;
@@ -66,22 +82,25 @@
\brief Set light color
\param data nviz data
- \param num light num (starts with 0)
- \param red,green,blue rGB values (0-1)
+ \param num light num (starts at 1)
+ \param red,green,blue RGB values (0-255)
*/
int Nviz_set_light_color(nv_data * data, int num,
- float red, float green, float blue)
+ int red, int green, int blue)
{
- float r, g, b;
+ double r, g, b;
- data->light[num].r = red;
- data->light[num].g = green;
- data->light[num].b = blue;
+ num--;
+ data->light[num].r = red / 255.;
+ data->light[num].g = green / 255.;
+ data->light[num].b = blue / 255.;
r = data->light[num].r * data->light[num].brt;
g = data->light[num].g * data->light[num].brt;
b = data->light[num].b * data->light[num].brt;
+ G_debug(1, "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;
@@ -91,18 +110,20 @@
\brief Set light ambient
\param data nviz data
- \param num light num (starts with 0)
- \param red,green,blue rGB values (0-1)
+ \param num light num (starts at 1)
+ \param value ambient value (same for R/G/B) (0-1)
*/
-int Nviz_set_light_ambient(nv_data * data, int num,
- float red, float green, float blue)
+int Nviz_set_light_ambient(nv_data * data, int num, double value)
{
- data->light[num].ar = red;
- data->light[num].ag = green;
- data->light[num].ab = blue;
+ num--;
+ data->light[num].ar = value;
+ data->light[num].ag = value;
+ data->light[num].ab = value;
- GS_setlight_ambient(num + 1, red, green, blue);
-
+ G_debug(1, "Nviz_set_light_ambient(): num = %d value = %f",
+ num + 1, value);
+ GS_setlight_ambient(num + 1, value, value, value);
+
return 1;
}
@@ -110,10 +131,11 @@
\brief Init new light
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
*/
int Nviz_init_light(nv_data * data, int num)
{
+ num--;
if (num >= MAX_LIGHTS) {
return 0;
}
@@ -134,6 +156,14 @@
return 1;
}
+/*!
+ \brief Define new light
+
+ \param data nviz data
+
+ \return 1 on success
+ \return 0 on failure
+*/
int Nviz_new_light(nv_data * data)
{
int num;
@@ -145,7 +175,8 @@
return 0;
}
- Nviz_init_light(data, num - 1);
+ Nviz_init_light(data, num);
return 1;
}
+
Modified: grass/branches/releasebranch_6_4/lib/nviz/map_obj.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/map_obj.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/map_obj.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,22 +1,18 @@
/*!
- \file map_obj.c
+ \file lib/nviz/map_obj.c
\brief Nviz library -- Define creation and interface functions for map objects.
- Map objects are considered to be surfaces, vector plots,
- or site files.
+ Map objects are considered to be surfaces, vector plots, or site
+ files.
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/map_obj.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <stdlib.h>
@@ -45,13 +41,11 @@
\return map object id
\return -1 on error
*/
-int Nviz_new_map_obj(int type, const char *name, float value, nv_data * data)
+int Nviz_new_map_obj(int type, const char *name, double value, nv_data * data)
{
int new_id, i;
int num_surfs, *surf_list;
- nv_clientdata *client_data;
-
/*
* For each type of map obj do the following --
* 1) Verify we havn't maxed out the number of
@@ -166,36 +160,7 @@
G_warning(_("Nviz_new_map_obj(): unsupported data type"));
return -1;
}
-
- /* initialize the client data filled for the new map object */
- client_data = (nv_clientdata *) G_malloc(sizeof(nv_clientdata));
-
- if (name) {
- client_data->logical_name = G_store(name);
- }
- else {
- char temp_space[80];
- time_t tp;
-
- /* Need to generate a random id */
- time(&tp);
- switch (type) {
- case MAP_OBJ_SURF:{
- sprintf(temp_space, "%s*%ld", "surface", tp);
- break;
- }
- default:{
- sprintf(temp_space, "%s*%ld", "unknown", tp);
- break;
- }
- }
- client_data->logical_name = G_store(temp_space);
- }
-
- G_debug(3, "new_map_obj(): logical name=%s", client_data->logical_name);
-
- GS_Set_ClientData(new_id, (void *)client_data);
-
+
return new_id;
}
@@ -207,16 +172,16 @@
\param desc attribute descriptor
\param src attribute source
\param str_value attribute value as string (if NULL, check for <i>num_value</i>)
- \param num_value attribute value as float
+ \param num_value attribute value as double
\return 1 on success
\return 0 on failure
*/
int Nviz_set_attr(int id, int type, int desc, int src,
- const char *str_value, float num_value, nv_data * data)
+ const char *str_value, double num_value, nv_data * data)
{
int ret;
- float value;
+ double value;
switch (type) {
case (MAP_OBJ_SURF):{
@@ -229,7 +194,7 @@
* Note that we require the constant to be an integer
*/
if (str_value)
- value = (float)atof(str_value);
+ value = (double)atof(str_value);
else
value = num_value;
Modified: grass/branches/releasebranch_6_4/lib/nviz/nviz.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/nviz.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/nviz.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,15 @@
/*!
- \file nviz.c
+ \file lib/nviz/nviz.c
\brief Nviz library -- Data management
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
@@ -45,9 +41,28 @@
Nviz_new_light(data);
}
+ /* fringe */
+ data->num_fringes = 0;
+ data->fringe = NULL;
+
return;
}
+/*! \brief Free allocated space by nv_data struct
+
+ \param data nviz data
+*/
+void Nviz_destroy_data(nv_data *data)
+{
+ int i;
+ for (i = 0; data->num_fringes; i++) {
+ G_free(data->fringe[i]);
+ data->fringe[i] = NULL;
+ }
+ data->num_fringes = 0;
+ data->fringe = NULL;
+}
+
/*!
\brief Set background color
@@ -62,6 +77,18 @@
}
/*!
+ \brief Get background color
+
+ \param data nviz data
+
+ \return color color value
+ */
+int Nviz_get_bgcolor(nv_data * data)
+{
+ return data->bgcolor;
+}
+
+/*!
\brief Get color value from color string (name or RGB triplet)
\param color_str color string
@@ -81,3 +108,94 @@
return (red & RED_MASK) + ((int)((grn) << 8) & GRN_MASK) +
((int)((blu) << 16) & BLU_MASK);
}
+
+/*! Add new fringe
+
+ \param data nviz data
+ \param id surface id
+ \param color color
+ \param elev fringe elevation
+ \param nw,ne,sw,se 1 (turn on) 0 (turn off)
+
+ \return pointer to allocated fringe_data structure
+ \return NULL on error
+*/
+struct fringe_data *Nviz_new_fringe(nv_data *data,
+ int id, unsigned long color,
+ double elev, int nw, int ne, int sw, int se)
+{
+ int num;
+ int *surf;
+ struct fringe_data *f;
+
+ if (!GS_surf_exists(id)) {
+ /* select first surface from the list */
+ surf = GS_get_surf_list(&num);
+ if (num < 1)
+ return NULL;
+ id = surf[0];
+ }
+
+
+ f = (struct fringe_data *) G_malloc(sizeof(struct fringe_data));
+ f->id = id;
+ f->color = color;
+ f->elev = elev;
+ f->where[0] = nw;
+ f->where[1] = ne;
+ f->where[2] = sw;
+ f->where[3] = se;
+
+ data->fringe = (struct fringe_data **) G_realloc(data->fringe, data->num_fringes + 1 * sizeof(struct fringe_data *));
+ data->fringe[data->num_fringes++] = f;
+
+ return f;
+}
+
+/*! Set fringe
+
+ \param data nviz data
+ \param id surface id
+ \param color color
+ \param elev fringe elevation
+ \param nw,ne,sw,se 1 (turn on) 0 (turn off)
+
+ \return pointer to allocated fringe_data structure
+ \return NULL on error
+*/
+struct fringe_data *Nviz_set_fringe(nv_data *data,
+ int id, unsigned long color,
+ double elev, int nw, int ne, int sw, int se)
+{
+ int i, num;
+ int *surf;
+ struct fringe_data *f;
+
+ if (!GS_surf_exists(id)) {
+ /* select first surface from the list */
+ surf = GS_get_surf_list(&num);
+ if (num < 1)
+ return NULL;
+ id = surf[0];
+ }
+
+ for (i = 0; i < data->num_fringes; i++) {
+ f = data->fringe[i];
+ if (f->id == id) {
+ f->color = color;
+ f->elev = elev;
+ f->where[0] = nw;
+ f->where[1] = ne;
+ f->where[2] = sw;
+ f->where[3] = se;
+
+ return f;
+ }
+ }
+
+ f = Nviz_new_fringe(data,
+ id, color,
+ elev, nw, ne, sw, se);
+
+ return f;
+}
Modified: grass/branches/releasebranch_6_4/lib/nviz/position.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/position.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/position.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,34 +1,40 @@
/*!
- \file position.c
-
+ \file lib/nviz/position.c
+
\brief Nviz library -- Position, focus settings
-
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
+
Based on visualization/nviz/src/position.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
#include <grass/nviz.h>
/*!
- Initialize view and position settings (focus)
+ Initialize view, position, lighting settings (focus)
Set position to center of view
*/
-void Nviz_init_view()
+void Nviz_init_view(nv_data *data)
{
GS_init_view();
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_bright(data, 1, 0.8);
+ 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, 255, 255, 255);
+ Nviz_set_light_ambient(data, 2, 0.3);
+
return;
}
Modified: grass/branches/releasebranch_6_4/lib/nviz/render.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/nviz/render.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/lib/nviz/render.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,15 @@
/*!
- \file render.c
+ \file lib/nviz/render.c
\brief Nviz library -- GLX context manipulation
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/togl.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/Makefile
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/Makefile 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/Makefile 2010-11-07 15:59:20 UTC (rev 44214)
@@ -21,13 +21,13 @@
EXTRA_CFLAGS += $(XCFLAGS)
endif
-XTRA_LDFLAGS = $(OGL_LIBS)
+EXTRA_LDFLAGS = $(OGL_LIBS)
-EXTRA_CFLAGS=$(XCFLAGS) $(XMINC)
-
-LIBES = $(GISLIB) $(XLIBPATH) $(XLIB) $(XEXTRALIBS) $(OGSFLIB) $(NVIZLIB)
+LIBES = $(GISLIB) $(OGSFLIB) $(NVIZLIB) $(G3DLIB)
DEPENDENCIES = $(GISDEP) $(NVIZDEP)
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_OPENGL),)
default: cmd
+endif
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/args.c
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/args.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/args.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,17 @@
/*!
- \file args.c
+ \file args.c
+
+ \brief Parse command
+
+ (C) 2008, 2010 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+*/
- \brief Parse command
-
- (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
- */
-
#include <stdlib.h>
#include <string.h>
@@ -31,23 +29,26 @@
static void args_vpoint(struct GParams *);
static void args_viewpoint(struct GParams *);
static void args_volume(struct GParams *);
+static void args_lighting(struct GParams *);
+static void args_fringe(struct GParams *);
/*!
- \brief Parse command
-
- \param argc number of arguments
- \param argv arguments array
- \param params GRASS parameters
-
- \return 1
- */
+ \brief Parse command
+
+ \param argc number of arguments
+ \param argv arguments array
+ \param params GRASS parameters
+
+ \return 1
+*/
void parse_command(int argc, char *argv[], struct GParams *params)
{
params->mode_all = G_define_flag();
params->mode_all->key = 'a';
params->mode_all->description =
_("Use draw mode for all loaded surfaces");
-
+ params->mode_all->guisection = _("Surfaces");
+
/*** surface attributes ***/
args_surface(params);
@@ -67,11 +68,17 @@
/*** viewpoint ***/
args_viewpoint(params);
+ /*** lighting ***/
+ args_lighting(params);
+
+ /*** fringe ***/
+ args_fringe(params);
+
/*** output image ***/
/* output */
params->output = G_define_standard_option(G_OPT_F_OUTPUT);
params->output->description =
- _("Name for output file (do not add extension)");
+ _("Name for output image file (without extension)");
params->output->guisection = _("Image");
/* format */
@@ -94,7 +101,7 @@
params->size->type = TYPE_INTEGER;
params->size->key_desc = "width,height";
params->size->answer = "640,480";
- params->size->description = _("Width and height of output image");
+ params->size->description = _("Size (width, height) of output image");
params->size->required = YES;
params->size->guisection = _("Image");
@@ -112,7 +119,7 @@
params->elev_map->required = NO;
params->elev_map->multiple = YES;
params->elev_map->description = _("Name of raster map(s) for elevation");
- params->elev_map->guisection = _("Surface");
+ params->elev_map->guisection = _("Surfaces");
params->elev_const = G_define_option();
params->elev_const->key = "elevation_value";
@@ -121,29 +128,28 @@
params->elev_const->required = NO;
params->elev_const->multiple = YES;
params->elev_const->description = _("Elevation value(s)");
- params->elev_const->guisection = _("Surface");
+ params->elev_const->guisection = _("Surfaces");
/* color */
params->color_map = G_define_standard_option(G_OPT_R_MAP);
params->color_map->multiple = YES;
params->color_map->required = NO;
params->color_map->description = _("Name of raster map(s) for color");
- params->color_map->guisection = _("Surface");
+ params->color_map->guisection = _("Surfaces");
params->color_map->key = "color_map";
params->color_const = G_define_standard_option(G_OPT_C_FG);
params->color_const->multiple = YES;
params->color_const->label = _("Color value(s)");
- params->color_const->guisection = _("Surface");
- params->color_const->key = "color_value";
+ params->color_const->guisection = _("Surfaces");
params->color_const->answer = NULL;
-
+
/* mask */
params->mask_map = G_define_standard_option(G_OPT_R_MAP);
params->mask_map->multiple = YES;
params->mask_map->required = NO;
params->mask_map->description = _("Name of raster map(s) for mask");
- params->mask_map->guisection = _("Surface");
+ params->mask_map->guisection = _("Surfaces");
params->mask_map->key = "mask_map";
/* transparency */
@@ -152,7 +158,7 @@
params->transp_map->required = NO;
params->transp_map->description =
_("Name of raster map(s) for transparency");
- params->transp_map->guisection = _("Surface");
+ params->transp_map->guisection = _("Surfaces");
params->transp_map->key = "transparency_map";
params->transp_const = G_define_option();
@@ -162,7 +168,7 @@
params->transp_const->required = NO;
params->transp_const->multiple = YES;
params->transp_const->description = _("Transparency value(s)");
- params->transp_const->guisection = _("Surface");
+ params->transp_const->guisection = _("Surfaces");
params->transp_const->options = "0-255";
/* shininess */
@@ -170,7 +176,7 @@
params->shine_map->multiple = YES;
params->shine_map->required = NO;
params->shine_map->description = _("Name of raster map(s) for shininess");
- params->shine_map->guisection = _("Surface");
+ params->shine_map->guisection = _("Surfaces");
params->shine_map->key = "shininess_map";
params->shine_const = G_define_option();
@@ -180,7 +186,7 @@
params->shine_const->required = NO;
params->shine_const->multiple = YES;
params->shine_const->description = _("Shininess value(s)");
- params->shine_const->guisection = _("Surface");
+ params->shine_const->guisection = _("Surfaces");
params->shine_const->options = "0-255";
/* emission */
@@ -188,7 +194,7 @@
params->emit_map->multiple = YES;
params->emit_map->required = NO;
params->emit_map->description = _("Name of raster map(s) for emission");
- params->emit_map->guisection = _("Surface");
+ params->emit_map->guisection = _("Surfaces");
params->emit_map->key = "emission_map";
params->emit_const = G_define_option();
@@ -198,7 +204,7 @@
params->emit_const->required = NO;
params->emit_const->multiple = YES;
params->emit_const->description = _("Emission value(s)");
- params->emit_const->guisection = _("Surface");
+ params->emit_const->guisection = _("Surfaces");
params->emit_const->options = "0-255";
/*
@@ -209,7 +215,7 @@
params->mode->key = "mode";
params->mode->key_desc = "string";
params->mode->type = TYPE_STRING;
- params->mode->required = YES;
+ params->mode->required = NO;
params->mode->multiple = YES;
params->mode->description = _("Draw mode");
params->mode->options = "coarse,fine,both";
@@ -221,7 +227,7 @@
params->res_fine->key = "resolution_fine";
params->res_fine->key_desc = "value";
params->res_fine->type = TYPE_INTEGER;
- params->res_fine->required = YES;
+ params->res_fine->required = NO;
params->res_fine->multiple = YES;
params->res_fine->description = _("Fine resolution");
params->res_fine->answer = "6";
@@ -232,7 +238,7 @@
params->res_coarse->key = "resolution_coarse";
params->res_coarse->key_desc = "value";
params->res_coarse->type = TYPE_INTEGER;
- params->res_coarse->required = YES;
+ params->res_coarse->required = NO;
params->res_coarse->multiple = YES;
params->res_coarse->description = _("Coarse resolution");
params->res_coarse->answer = "9";
@@ -243,7 +249,7 @@
params->style->key = "style";
params->style->key_desc = "string";
params->style->type = TYPE_STRING;
- params->style->required = YES;
+ params->style->required = NO;
params->style->multiple = YES;
params->style->description = _("Draw style");
params->style->options = "wire,surface";
@@ -255,7 +261,7 @@
params->shade->key = "shading";
params->shade->key_desc = "string";
params->shade->type = TYPE_STRING;
- params->shade->required = YES;
+ params->shade->required = NO;
params->shade->multiple = YES;
params->shade->description = _("Shading");
params->shade->options = "flat,gouraud";
@@ -265,7 +271,7 @@
/* wire color */
params->wire_color = G_define_standard_option(G_OPT_C_FG);
params->wire_color->multiple = YES;
- params->wire_color->required = YES;
+ params->wire_color->required = NO;
params->wire_color->label = _("Wire color");
params->wire_color->key = "wire_color";
params->wire_color->answer = "136:136:136";
@@ -276,7 +282,7 @@
params->shade->key = "shading";
params->shade->key_desc = "string";
params->shade->type = TYPE_STRING;
- params->shade->required = YES;
+ params->shade->required = NO;
params->shade->multiple = YES;
params->shade->description = _("Shading");
params->shade->options = "flat,gouraud";
@@ -285,10 +291,10 @@
/* position */
params->surface_pos = G_define_option();
- params->surface_pos->key = "position";
+ params->surface_pos->key = "surface_position";
params->surface_pos->key_desc = "x,y,z";
params->surface_pos->type = TYPE_INTEGER;
- params->surface_pos->required = YES;
+ params->surface_pos->required = NO;
params->surface_pos->multiple = YES;
params->surface_pos->description = _("Position");
params->surface_pos->guisection = _("Draw");
@@ -332,7 +338,7 @@
params->vline_mode->key = "vline_mode";
params->vline_mode->key_desc = "string";
params->vline_mode->type = TYPE_STRING;
- params->vline_mode->required = YES;
+ params->vline_mode->required = NO;
params->vline_mode->multiple = YES;
params->vline_mode->description = _("Vector line display mode");
params->vline_mode->options = "surface,flat";
@@ -356,7 +362,7 @@
params->vline_pos->key = "vline_position";
params->vline_pos->key_desc = "x,y,z";
params->vline_pos->type = TYPE_INTEGER;
- params->vline_pos->required = YES;
+ params->vline_pos->required = NO;
params->vline_pos->multiple = YES;
params->vline_pos->description = _("Position");
params->vline_pos->guisection = _("Vector lines");
@@ -412,7 +418,7 @@
params->vpoint_marker->key = "vpoint_marker";
params->vpoint_marker->key_desc = "string";
params->vpoint_marker->type = TYPE_STRING;
- params->vpoint_marker->required = YES;
+ params->vpoint_marker->required = NO;
params->vpoint_marker->multiple = YES;
params->vpoint_marker->description = _("Icon marker");
params->vpoint_marker->options =
@@ -425,7 +431,7 @@
params->vpoint_pos->key = "vpoint_position";
params->vpoint_pos->key_desc = "x,y,z";
params->vpoint_pos->type = TYPE_INTEGER;
- params->vpoint_pos->required = YES;
+ params->vpoint_pos->required = NO;
params->vpoint_pos->multiple = YES;
params->vpoint_pos->description = _("Position");
params->vpoint_pos->guisection = _("Vector points");
@@ -446,7 +452,7 @@
params->pos->description =
_("Viewpoint position (x,y model coordinates)");
params->pos->guisection = _("Viewpoint");
- params->pos->answer = "0.85,0.85";
+ params->pos->answer = "0.84,0.16";
/* height */
params->height = G_define_option();
@@ -498,7 +504,7 @@
{
params->volume = G_define_standard_option(G_OPT_R3_MAPS);
params->volume->required = NO;
- params->volume->guisection = _("Volume");
+ params->volume->guisection = _("Volumes");
params->volume->key = "volume";
/* mode */
@@ -506,7 +512,7 @@
params->volume_mode->key = "volume_mode";
params->volume_mode->key_desc = "string";
params->volume_mode->type = TYPE_STRING;
- params->volume_mode->required = YES;
+ params->volume_mode->required = NO;
params->volume_mode->multiple = YES;
params->volume_mode->description = _("Volume draw mode");
params->volume_mode->options = "isosurface,slice";
@@ -518,7 +524,7 @@
params->volume_shade->key = "volume_shading";
params->volume_shade->key_desc = "string";
params->volume_shade->type = TYPE_STRING;
- params->volume_shade->required = YES;
+ params->volume_shade->required = NO;
params->volume_shade->multiple = YES;
params->volume_shade->description = _("Volume shading");
params->volume_shade->options = "flat,gouraud";
@@ -530,10 +536,10 @@
params->volume_pos->key = "volume_position";
params->volume_pos->key_desc = "x,y,z";
params->volume_pos->type = TYPE_INTEGER;
- params->volume_pos->required = YES;
+ params->volume_pos->required = NO;
params->volume_pos->multiple = YES;
params->volume_pos->description = _("Volume position");
- params->volume_pos->guisection = _("Volume");
+ params->volume_pos->guisection = _("Volumes");
params->volume_pos->answer = "0,0,0";
/* resolution */
@@ -541,11 +547,11 @@
params->volume_res->key = "volume_resolution";
params->volume_res->key_desc = "value";
params->volume_res->type = TYPE_INTEGER;
- params->volume_res->required = YES;
+ params->volume_res->required = NO;
params->volume_res->multiple = YES;
params->volume_res->description = _("Volume resolution");
params->volume_res->answer = "3";
- params->volume_res->guisection = _("Volume");
+ params->volume_res->guisection = _("Volumes");
/* isosurface level */
params->isosurf_level = G_define_option();
@@ -555,11 +561,81 @@
params->isosurf_level->required = NO;
params->isosurf_level->multiple = YES;
params->isosurf_level->description = _("Isosurface level");
- params->isosurf_level->guisection = _("Volume");
+ params->isosurf_level->guisection = _("Volumes");
return;
}
+void args_lighting(struct GParams *params)
+{
+ params->light_pos = G_define_option();
+ params->light_pos->key = "light_position";
+ params->light_pos->key_desc = "x,y,z";
+ params->light_pos->type = TYPE_DOUBLE;
+ params->light_pos->required = NO;
+ params->light_pos->multiple = NO;
+ 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_color = G_define_standard_option(G_OPT_C_FG);
+ params->light_color->key = "light_color";
+ params->light_color->label = _("Light color");
+ params->light_color->guisection = _("Lighting");
+ params->light_color->answer = "white";
+
+ params->light_bright = G_define_option();
+ params->light_bright->key = "light_brightness";
+ params->light_bright->type = TYPE_INTEGER;
+ params->light_bright->required = NO;
+ params->light_bright->multiple = NO;
+ params->light_bright->description = _("Light brightness");
+ params->light_bright->guisection = _("Lighting");
+ params->light_bright->answer = "80";
+ params->light_bright->options="0-100";
+
+ params->light_ambient = G_define_option();
+ params->light_ambient->key = "light_ambient";
+ params->light_ambient->type = TYPE_INTEGER;
+ params->light_ambient->required = NO;
+ params->light_ambient->multiple = NO;
+ params->light_ambient->description = _("Light ambient");
+ params->light_ambient->guisection = _("Lighting");
+ params->light_ambient->answer = "20";
+ params->light_ambient->options="0-100";
+}
+
+void args_fringe(struct GParams *params)
+{
+ params->fringe = G_define_option();
+ params->fringe->key = "fringe";
+ params->fringe->type = TYPE_STRING;
+ params->fringe->options = "nw,ne,sw,se";
+ params->fringe->descriptions = _("nw;North-West edge;"
+ "ne;North-East edge;"
+ "sw;South-West edge;"
+ "se;South-East edge");
+ params->fringe->description = _("Fringe edges");
+ params->fringe->guisection = _("Fringe");
+ params->fringe->multiple = YES;
+
+ params->fringe_color = G_define_standard_option(G_OPT_C_FG);
+ params->fringe_color->key = "fringe_color";
+ params->fringe_color->label = _("Fringe color");
+ params->fringe_color->guisection = _("Fringe");
+ params->fringe_color->answer = "grey";
+
+ params->fringe_elev = G_define_option();
+ params->fringe_elev->key = "fringe_elevation";
+ params->fringe_elev->type = TYPE_INTEGER;
+ params->fringe_elev->required = NO;
+ params->fringe_elev->multiple = NO;
+ params->fringe_elev->description = _("Fringe elevation");
+ params->fringe_elev->guisection = _("Fringe");
+ params->fringe_elev->answer = "55";
+}
+
/*!
\brief Get number of answers of given option
@@ -583,9 +659,9 @@
}
/*!
- \brief Check parameters consistency
-
- \param params module parameters
+ \brief Check parameters consistency
+
+ \param params module parameters
*/
void check_parameters(const struct GParams *params)
{
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/description.html
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/description.html 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/description.html 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,29 @@
<h2>DESCRIPTION</h2>
-Experimental CLI prototype of NVIZ.
+<em>nviz_cmd</em> allows users to realistically render multiple
+<em>surfaces</em> (raster data) in a 3D space, optionally using
+thematic coloring, draping 2D <em>vector</em> data over the surfaces,
+displaying 3D vector data in the space, and visualization
+of <em>volume</em> data (3D raster data) from the command line.
-<p>
-TODO
+<h2>EXAMPLE</h2>
+Render elevation map in a 3D space.
+
+<div class="code"><pre>
+g.region rast=elevation
+nviz_cmd elevation_map=elevation output=elev perspective=15
+</pre></div>
+
<h2>SEE ALSO</h2>
<em>
-<a HREF="nviz.html">TCL/TK-based NVIZ</a>
+<a HREF="wxGUI.Nviz.html">wxGUI 3D Viewer</a>
</em>
<h2>AUTHOR</h2>
-Martin Landa (Google Summer of Code 2008)
+Martin Landa (Google Summer of Code 2008/2010)
<p>
<i>Last changed: $Date$</i>
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/local_proto.h
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/local_proto.h 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/local_proto.h 2010-11-07 15:59:20 UTC (rev 44214)
@@ -11,22 +11,26 @@
struct Option
/* surface */
*elev_map, *elev_const, *color_map, *color_const,
- *mask_map, *transp_map, *transp_const, *shine_map, *shine_const,
- *emit_map, *emit_const,
+ *mask_map, *transp_map, *transp_const, *shine_map, *shine_const,
+ *emit_map, *emit_const,
/* surface draw mode */
- *mode, *res_fine, *res_coarse, *style, *shade, *wire_color, *surface_pos,
+ *mode, *res_fine, *res_coarse, *style, *shade, *wire_color, *surface_pos,
/* vector lines */
- *vlines, *vline_width, *vline_color, *vline_mode, *vline_height, *vline_pos,
+ *vlines, *vline_width, *vline_color, *vline_mode, *vline_height, *vline_pos,
/* vector points */
- *vpoints, *vpoint_size, *vpoint_marker, *vpoint_color, *vpoint_width, *vpoint_pos,
+ *vpoints, *vpoint_size, *vpoint_marker, *vpoint_color, *vpoint_width, *vpoint_pos,
/* volumes */
- *volume, *volume_mode, *volume_shade, *volume_pos, *volume_res, *isosurf_level,
+ *volume, *volume_mode, *volume_shade, *volume_pos, *volume_res, *isosurf_level,
/* misc */
- *exag, *bgcolor,
+ *exag, *bgcolor,
/* viewpoint */
- *pos, *height, *persp, *twist,
+ *pos, *height, *persp, *twist,
/* output */
- *output, *format, *size;
+ *output, *format, *size,
+ /* lighting */
+ *light_pos, *light_color, *light_bright, *light_ambient,
+ /* fringe */
+ *fringe, *fringe_color, *fringe_elev;
};
/* args.c */
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/main.c
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/main.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/main.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -3,15 +3,15 @@
*
* MODULE: nviz_cmd
*
- * AUTHOR(S): Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ * AUTHOR(S): Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*
- * PURPOSE: Experimental NVIZ CLI prototype
+ * PURPOSE: Renders GIS data in 3D space.
*
- * COPYRIGHT: (C) 2008 by the GRASS Development Team
+ * COPYRIGHT: (C) 2008,2010 by the GRASS Development Team
*
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
+ * This program is free software under the GNU General
+ * Public License (>=v2). Read the file COPYING that
+ * comes with GRASS for details.
*
*****************************************************************************/
@@ -19,6 +19,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/colors.h>
#include <grass/glocale.h>
#include <grass/nviz.h>
@@ -31,11 +32,12 @@
struct GModule *module;
struct GParams *params;
- int ret;
- float vp_height, z_exag; /* calculated viewpoint height, z-exag */
+ int i, ret;
+ int red, grn, blu;
+ double vp_height, z_exag; /* calculated viewpoint height, z-exag */
int width, height; /* output image size */
char *output_name;
-
+
nv_data data;
struct render_window *offscreen;
@@ -44,7 +46,10 @@
module = G_define_module();
module->keywords = _("visualization, raster, vector, raster3d");
- module->description = _("Experimental NVIZ CLI prototype.");
+ module->label = _("Allows rendering GIS data is a 3D space.");
+ module->description = _("Renders surfaces (raster data), "
+ "2D/3D vector data, and "
+ "volumes (3D raster data) in a 3D space.");
params = (struct GParams *)G_malloc(sizeof(struct GParams));
@@ -79,18 +84,8 @@
/* set background color */
Nviz_set_bgcolor(&data, Nviz_color_from_str(params->bgcolor->answer));
- /* init view */
- Nviz_init_view();
- /* set lights */
- /* TODO: add options */
- Nviz_set_light_position(&data, 0, 0.68, -0.68, 0.80, 0.0);
- Nviz_set_light_bright(&data, 0, 0.8);
- Nviz_set_light_color(&data, 0, 1.0, 1.0, 1.0);
- Nviz_set_light_ambient(&data, 0, 0.2, 0.2, 0.2);
- Nviz_set_light_position(&data, 1, 0.0, 0.0, 1.0, 0.0);
- Nviz_set_light_bright(&data, 1, 0.5);
- Nviz_set_light_color(&data, 1, 1.0, 1.0, 1.0);
- Nviz_set_light_ambient(&data, 1, 0.3, 0.3, 0.3);
+ /* init view, lights */
+ Nviz_init_view(&data);
/* load raster maps (surface topography) & set attributes (map/constant) */
load_rasters(params, &data);
@@ -130,8 +125,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);
@@ -139,18 +135,55 @@
vp_height = atof(params->height->answer);
}
else {
- Nviz_get_exag_height(&vp_height, NULL, NULL);
- G_message(_("Viewpoint height not given, using calculated value %.0f"),
- vp_height);
+ double min, max;
+ Nviz_get_exag_height(&vp_height, &min, &max);
+ G_verbose_message(_("Viewpoint height not given, using calculated "
+ "value %.0f"),
+ vp_height);
}
- Nviz_set_viewpoint_height(&data, vp_height);
+ Nviz_set_viewpoint_height(vp_height);
- Nviz_set_viewpoint_position(&data,
- atof(params->pos->answers[0]),
+ Nviz_set_viewpoint_position(atof(params->pos->answers[0]),
atof(params->pos->answers[1]));
- Nviz_set_viewpoint_twist(&data, atoi(params->twist->answer));
- Nviz_set_viewpoint_persp(&data, atoi(params->persp->answer));
+ Nviz_set_viewpoint_twist(atoi(params->twist->answer));
+ Nviz_set_viewpoint_persp(atoi(params->persp->answer));
+ /* set lights */
+ Nviz_set_light_position(&data, 1,
+ atof(params->light_pos->answers[0]),
+ atof(params->light_pos->answers[1]),
+ atof(params->light_pos->answers[2]),
+ 0.0);
+ Nviz_set_light_bright(&data, 1,
+ atoi(params->light_bright->answer) / 100.0);
+ if(G_str_to_color(params->light_color->answer, &red, &grn, &blu) != 1) {
+ red = grn = blu = 255;
+ }
+ Nviz_set_light_color(&data, 1, red, grn, blu);
+ Nviz_set_light_ambient(&data, 1,
+ atof(params->light_ambient->answer) / 100.0);
+
+ /* define fringes */
+ if (params->fringe->answer) {
+ int nw, ne, sw, se;
+
+ i = 0;
+ nw = ne = sw = se = 0;
+ while(params->fringe->answers[i]) {
+ const char *edge = params->fringe->answers[i++];
+ if (strcmp(edge, "nw") == 0)
+ nw = 1;
+ else if (strcmp(edge, "ne") == 0)
+ ne = 1;
+ else if (strcmp(edge, "sw") == 0)
+ sw = 1;
+ else if (strcmp(edge, "se") == 0)
+ se = 1;
+ }
+ Nviz_new_fringe(&data, -1, Nviz_color_from_str(params->fringe_color->answer),
+ atof(params->fringe_elev->answer), nw, ne, sw, se);
+ }
+
GS_clear(data.bgcolor);
/* draw */
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/surface.c
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/surface.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/surface.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,17 @@
/*!
- \file surface.c
+ \file surface.c
+
+ \brief Surface subroutines
+
+ (C) 2008, 2010 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+*/
- \brief Surface subroutines
-
- (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
- */
-
#include <stdlib.h>
#include <string.h>
@@ -22,11 +20,11 @@
#include "local_proto.h"
/*!
- \brief Load raster maps/constants and set surface attributes
-
- \param params module parameters
- \param data nviz data
- */
+ \brief Load raster maps/constants and set surface attributes
+
+ \param params module parameters
+ \param data nviz data
+*/
int load_rasters(const struct GParams *params, nv_data * data)
{
char *mapset;
@@ -182,10 +180,10 @@
}
/*!
- \brief Set draw mode for loaded surfaces
-
- \param params module parameters
- */
+ \brief Set draw mode for loaded surfaces
+
+ \param params module parameters
+*/
void surface_set_draw_mode(const struct GParams *params)
{
int *surf_list, nsurfs;
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/vector.c
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/vector.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/vector.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,17 @@
/*!
- \file vector.c
+ \file vector.c
+
+ \brief Vector subroutines
+
+ (C) 2008, 2010 by the GRASS Development Team
- \brief Vector subroutines
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+*/
- (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
- */
-
#include <stdlib.h>
#include <string.h>
@@ -25,13 +23,13 @@
const struct Option *, const struct Option *, int, nv_data *);
/*!
- \brief Load vector maps (lines)
-
- \param params module parameters
- \param data nviz data
-
- \return number of loaded vectors
- */
+ \brief Load vector maps (lines)
+
+ \param params module parameters
+ \param data nviz data
+
+ \return number of loaded vectors
+*/
int load_vlines(const struct GParams *params, nv_data * data)
{
return load_vectors(params->elev_map, params->elev_const,
@@ -40,13 +38,13 @@
}
/*!
- \brief Load vector maps (points)
-
- \param params module parameters
- \param data nviz data
-
- \return number of loaded vectors
- */
+ \brief Load vector maps (points)
+
+ \param params module parameters
+ \param data nviz data
+
+ \return number of loaded vectors
+*/
int load_vpoints(const struct GParams *params, nv_data * data)
{
return load_vectors(params->elev_map, params->elev_const,
@@ -63,7 +61,7 @@
int nvects;
char *mapset;
-
+
double x, y, z;
if ((!elev_map->answer || elev_const->answer) && GS_num_surfs() == 0) { /* load base surface if no loaded */
@@ -103,13 +101,13 @@
}
/*!
- \brief Set vector lines mode
-
- \param params parameters
-
- \return 1 on success
- \return 0 on failure
- */
+ \brief Set vector lines mode
+
+ \param params parameters
+
+ \return 1 on success
+ \return 0 on failure
+*/
int vlines_set_attrb(const struct GParams *params)
{
int i, color, width, flat, height;
@@ -138,13 +136,13 @@
}
/*!
- \brief Set vector points mode
-
- \param params parameters
-
- \return 1 on success
- \return 0 on failure
- */
+ \brief Set vector points mode
+
+ \param params parameters
+
+ \return 1 on success
+ \return 0 on failure
+*/
int vpoints_set_attrb(const struct GParams *params)
{
int i;
@@ -179,9 +177,11 @@
marker = ST_HISTOGRAM;
else
G_fatal_error(_("Unknown icon marker"));
-
+
GP_set_sitemode(site_list[i], ST_ATT_NONE,
color, width, size, marker);
+
+ /* GP_set_style(site_list[i], color, width, size, marker); */
}
return 1;
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/volume.c
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/volume.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/volume.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,19 +1,17 @@
/*!
- \file volume.c
+ \file volume.c
+
+ \brief Volume subroutines
+
+ (C) 2008, 2010 by the GRASS Development Team
- \brief Volume subroutines
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+*/
- (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
- */
-
#include <stdlib.h>
#include <grass/G3d.h>
@@ -22,13 +20,13 @@
#include "local_proto.h"
/*!
- \brief Load 3d raster map layers -> volume
+ \brief Load 3d raster map layers -> volume
+
+ \param params module parameters
+ \param data nviz data
- \param params module parameters
- \param data nviz data
-
- \return number of loaded volumes
- */
+ \return number of loaded volumes
+*/
int load_rasters3d(const struct GParams *params, nv_data *data)
{
int i, nvol, id;
@@ -54,7 +52,7 @@
/*!
\brief Add isosurfaces and set their attributes
-
+
\param params module parameters
\param data nviz data
Modified: grass/branches/releasebranch_6_4/visualization/nviz2/cmd/write_img.c
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz2/cmd/write_img.c 2010-11-07 15:54:09 UTC (rev 44213)
+++ grass/branches/releasebranch_6_4/visualization/nviz2/cmd/write_img.c 2010-11-07 15:59:20 UTC (rev 44214)
@@ -1,35 +1,32 @@
/*!
- \file write_img.c
+ \file write_img.c
+
+ \brief Save current GL screen to image file.
+
+ (C) 2008, 2010 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ Based on visualization/nviz/src/anim_support.c
+
+ \author Updated/modified by Martin Landa <landa.martin gmail.com>
+*/
- \brief Save current GL screen to image file.
-
- (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- Based on visualization/nviz/src/anim_support.c
-
- \author Updated/modified by Martin Landa <landa.martin gmail.com>
-
- \date 2008
- */
-
#include "local_proto.h"
#include <grass/gsurf.h>
#include <grass/gstypes.h>
/*!
- \brief Save current GL screen to an ppm file.
-
- \param name filename
-
- \return 1 on success
- \return 0 on failure (unsupported format)
- */
-
+ \brief Save current GL screen to an ppm file.
+
+ \param name filename
+
+ \return 1 on success
+ \return 0 on failure (unsupported format)
+*/
int write_img(const char *name, int format)
{
if (format == FORMAT_PPM)
More information about the grass-commit
mailing list