GRASS Programmer's Manual  6.4.2(2012)
position.c
Go to the documentation of this file.
00001 
00015 #include <grass/glocale.h>
00016 #include <grass/nviz.h>
00017 
00023 void Nviz_init_view(nv_data *data)
00024 {
00025     GS_init_view();
00026     Nviz_set_focus_state(1);    /* center of view */
00027     
00028     /* set default lights (1 & 2) */
00029     Nviz_set_light_position(data, 1, 0.68, -0.68, 0.80, 0.0);
00030     Nviz_set_light_bright(data,   1, 0.8);
00031     Nviz_set_light_color(data,    1, 255, 255, 255);
00032     Nviz_set_light_ambient(data,  1, 0.2);
00033     Nviz_set_light_position(data, 2, 0.0, 0.0, 1.0, 0.0);
00034     Nviz_set_light_bright(data,   2, 0.5);
00035     Nviz_set_light_color(data,    2, 255, 255, 255);
00036     Nviz_set_light_ambient(data,  2, 0.3);
00037     
00038     return;
00039 }
00040 
00049 int Nviz_set_focus_state(int state_flag)
00050 {
00051     if (state_flag == 1)
00052         GS_set_infocus();       /* return center of view */
00053     else if (state_flag == 0)
00054         GS_set_nofocus();       /* no center of view -- use viewdir */
00055     else {
00056         G_warning(_("Unable to set focus"));
00057         return 0;
00058     }
00059 
00060     return 1;
00061 }
00062 
00075 int Nviz_set_focus_map(int type, int id)
00076 {
00077     if (GS_num_surfs() < 0 && GVL_num_vols() < 0) {
00078         GS_set_nofocus();
00079         return 0;
00080     }
00081 
00082     if (type == MAP_OBJ_UNDEFINED) {
00083         int *surf_list, num_surfs, *vol_list;
00084 
00085         if (GS_num_surfs() > 0) {
00086             surf_list = GS_get_surf_list(&num_surfs);
00087             id = surf_list[0];
00088             G_free(surf_list);
00089 
00090             GS_set_focus_center_map(id);
00091         }
00092 
00093         if (GVL_num_vols() > 0) {
00094             vol_list = GVL_get_vol_list(&num_surfs);
00095             id = vol_list[0];
00096             G_free(vol_list);
00097 
00098             GVL_set_focus_center_map(id);
00099         }
00100         return id;
00101     }
00102 
00103     if (type == MAP_OBJ_SURF) {
00104         GS_set_focus_center_map(id);
00105     }
00106     else if (type == MAP_OBJ_VOL) {
00107         GVL_set_focus_center_map(id);
00108     }
00109 
00110     return id;
00111 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines