|
GRASS Programmer's Manual
6.5.svn(2012)-r51648
|
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 } 00112 00119 int Nviz_get_focus(nv_data * data, float *x, float *y, float *z) 00120 { 00121 float realto[3]; 00122 00123 /* Get current center */ 00124 GS_get_focus(realto); 00125 *x = realto[0]; 00126 *y = realto[1]; 00127 *z = realto[2]; 00128 // old nviz code is more complicated and it doesn't work properly, 00129 // no idea why 00130 00131 return 1; 00132 00133 } 00134 00141 int Nviz_set_focus(nv_data * data, float x, float y, float z) 00142 { 00143 float realto[3]; 00144 00145 realto[0] = x; 00146 realto[1] = y; 00147 realto[2] = z; 00148 GS_set_focus(realto); 00149 // old nviz code is more complicated and it doesn't work properly, 00150 // no idea why 00151 00152 return 1; 00153 00154 } 00155 00161 int Nviz_has_focus(nv_data * data) 00162 { 00163 float realto[3]; 00164 00165 if (GS_get_focus(realto)) 00166 return 1; 00167 else 00168 return 0; 00169 } 00170 00176 float Nviz_get_xyrange(nv_data * data) 00177 { 00178 return data->xyrange; 00179 } 00180 00187 int Nviz_get_zrange(nv_data * data, float *min, float *max) 00188 { 00189 GS_get_zrange_nz(min, max); 00190 return 1; 00191 } 00192 00198 float Nviz_get_longdim(nv_data * data) 00199 { 00200 float dim; 00201 00202 GS_get_longdim(&dim); 00203 00204 return dim; 00205 }