Changeset 426
- Timestamp:
- May 2, 2006, 12:54:02 PM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/Camera.cpp
r425 r426 45 45 46 46 void Camera::activate(){ 47 fprintf(stderr, "camera: %d, %d\n", width, height);47 //fprintf(stderr, "camera: %d, %d\n", width, height); 48 48 glViewport(0, 0, width, height); 49 49 glMatrixMode(GL_PROJECTION); -
trunk/gui/vizservers/nanovis/nanovis.cpp
r425 r426 105 105 static Tcl_Interp *interp; 106 106 107 static int CameraCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));108 static int CutCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));109 static int HelloCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));110 static int LoadCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));111 static int RefreshCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));112 static int MoveCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));113 static int TransferFunctionCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));114 static int ScreenSizeCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));115 116 107 //Tcl callback functions 117 108 static int … … 120 111 121 112 fprintf(stderr, "camera cmd\n"); 122 double x, y,z;123 124 if (argc != 4) {113 double angle_x, angle_y, angle_z, aim_x, aim_y, aim_z; 114 115 if (argc != 7) { 125 116 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 126 " x_angle y_angle z_angle \"", (char*)NULL);117 " x_angle y_angle z_angle aim_x aim_y aim_z\"", (char*)NULL); 127 118 return TCL_ERROR; 128 119 } 129 if (Tcl_GetDouble(interp, argv[1], & x) != TCL_OK) {120 if (Tcl_GetDouble(interp, argv[1], &angle_x) != TCL_OK) { 130 121 return TCL_ERROR; 131 122 } 132 if (Tcl_GetDouble(interp, argv[2], & y) != TCL_OK) {123 if (Tcl_GetDouble(interp, argv[2], &angle_y) != TCL_OK) { 133 124 return TCL_ERROR; 134 125 } 135 if (Tcl_GetDouble(interp, argv[3], & z) != TCL_OK) {126 if (Tcl_GetDouble(interp, argv[3], &angle_z) != TCL_OK) { 136 127 return TCL_ERROR; 137 128 } 138 set_camera(x, y, z); 129 if (Tcl_GetDouble(interp, argv[4], &aim_x) != TCL_OK) { 130 return TCL_ERROR; 131 } 132 if (Tcl_GetDouble(interp, argv[5], &aim_y) != TCL_OK) { 133 return TCL_ERROR; 134 } 135 if (Tcl_GetDouble(interp, argv[6], &aim_z) != TCL_OK) { 136 return TCL_ERROR; 137 } 138 139 //set_camera(x, y, z); 140 cam->rotate(angle_x, angle_y, angle_z); 141 cam->aim(aim_x, aim_y, aim_z); 139 142 return TCL_OK; 140 143 } … … 145 148 //change screen size 146 149 static int 147 Screen SizeCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])150 ScreenResizeCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 148 151 { 149 152 … … 177 180 void update_transfer_function(int index, float* data); 178 181 179 //The client sends the Transfer function command to tellthe index of the transfer function182 //The client sends the first sends the index of the transfer function 180 183 //to modify. Then the client sends a chunck of binary floats. 181 184 static int 182 TransferFunction Cmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])185 TransferFunctionUpdateCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 183 186 { 184 fprintf(stderr, "transfer function cmd\n"); 185 186 double index_d; 187 int index; 187 fprintf(stderr, "update transfer function cmd\n"); 188 189 double index; 188 190 189 191 if (argc != 2) { … … 192 194 return TCL_ERROR; 193 195 } 194 if (Tcl_GetDouble(interp, argv[1], &index _d) != TCL_OK) {196 if (Tcl_GetDouble(interp, argv[1], &index) != TCL_OK) { 195 197 return TCL_ERROR; 196 198 } 197 198 index = int(index_d);199 199 200 200 //Now read 256*4*4 bytes. The server expects the transfer function to be 256 units of (RGBA) floats … … 206 206 } 207 207 208 update_transfer_function(index, (float*)tmp); 208 update_transfer_function((int)index, (float*)tmp); 209 return TCL_OK; 210 } 211 212 213 //The client sends the index of the index of the transfer function 214 //to create. Then the client sends a chunck of binary floats. 215 static int 216 TransferFunctionNewCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 217 { 218 fprintf(stderr, "update transfer function cmd\n"); 219 220 double index; 221 222 if (argc != 2) { 223 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 224 " tf_index\"", (char*)NULL); 225 return TCL_ERROR; 226 } 227 if (Tcl_GetDouble(interp, argv[1], &index) != TCL_OK) { 228 return TCL_ERROR; 229 } 230 231 //Now read 256*4*4 bytes. The server expects the transfer function to be 256 units of (RGBA) floats 232 char tmp[256*4*4]; 233 bzero(tmp, 256*4*4); 234 int status = read(0, tmp, 256*4*4); 235 if (status <= 0) { 236 exit(0); 237 } 238 239 tf[(int)index] = new TransferFunction(256, (float*)tmp); 209 240 return TCL_OK; 210 241 } … … 217 248 } 218 249 250 static int 251 VolumeLinkCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 252 { 253 fprintf(stderr, "link volume command\n"); 254 255 double volume_index, tf_index; 256 257 if (argc != 3) { 258 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 259 " volume_index tf_index \"", (char*)NULL); 260 return TCL_ERROR; 261 } 262 if (Tcl_GetDouble(interp, argv[1], &volume_index) != TCL_OK) { 263 return TCL_ERROR; 264 } 265 if (Tcl_GetDouble(interp, argv[2], &tf_index) != TCL_OK) { 266 return TCL_ERROR; 267 } 268 269 vol_render->add_volume(volume[(int)volume_index], tf[(int)tf_index]); 270 271 return TCL_OK; 272 } 273 274 275 static int 276 VolumeEnableCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 277 { 278 fprintf(stderr, "link volume command\n"); 279 280 double volume_index, mode; 281 282 if (argc != 3) { 283 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 284 " volume_index tf_index \"", (char*)NULL); 285 return TCL_ERROR; 286 } 287 if (Tcl_GetDouble(interp, argv[1], &volume_index) != TCL_OK) { 288 return TCL_ERROR; 289 } 290 if (Tcl_GetDouble(interp, argv[2], &mode) != TCL_OK) { 291 return TCL_ERROR; 292 } 293 294 if(mode==0) 295 volume[(int)volume_index]->disable(); 296 else 297 volume[(int)volume_index]->enable(); 298 299 return TCL_OK; 300 } 301 302 219 303 void load_volume(int index, int width, int height, int depth, int n_component, float* data); 220 304 221 305 //The client sends the load data command to tell the index of the volume, and the dimensions of the data 222 //Then the client sends a chunck of binary floats. 306 //Then the client sends a chunck of binary floats. This call creates a NEW volume 223 307 static int 224 LoadCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])308 VolumeNewCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 225 309 { 226 310 fprintf(stderr, "load data command\n"); … … 230 314 if (argc != 5) { 231 315 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 232 " volume_index x y z\"", (char*)NULL);316 " volume_index w h d \"", (char*)NULL); 233 317 return TCL_ERROR; 234 318 } … … 255 339 256 340 load_volume(int(index), int(w), int(h), int(d), 4, (float*) tmp); 341 257 342 delete[] tmp; 258 259 343 return TCL_OK; 260 344 } 261 345 262 //move the volume object in space so its starting corner is at (x, y, z)263 void move_volume(int index, float x, float y, float z){264 volume[index]->move(Vector3(x, y, z));265 }266 267 346 268 347 static int 269 MoveCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])348 VolumeMoveCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 270 349 { 271 350 272 fprintf(stderr, "move cmd\n");273 double index _d, x, y, z;351 fprintf(stderr, "move volume cmd\n"); 352 double index, x, y, z; 274 353 275 354 if (argc != 5) { … … 278 357 return TCL_ERROR; 279 358 } 280 if (Tcl_GetDouble(interp, argv[1], &index _d) != TCL_OK) {359 if (Tcl_GetDouble(interp, argv[1], &index) != TCL_OK) { 281 360 return TCL_ERROR; 282 361 } … … 292 371 293 372 //set_object(x, y, z); 294 move_volume((int)index_d, x, y, z);373 volume[(int)index]->move(Vector3(x, y, z)); 295 374 return TCL_OK; 296 375 } 297 376 377 378 static int 379 CutMoveCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 380 { 381 382 fprintf(stderr, "move cutplane cmd\n"); 383 double volume_index, cut_index, location; 384 385 if (argc != 4) { 386 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 387 " vol_index cut_index cut_location\"", (char*)NULL); 388 return TCL_ERROR; 389 } 390 if (Tcl_GetDouble(interp, argv[1], &volume_index) != TCL_OK) { 391 return TCL_ERROR; 392 } 393 if (Tcl_GetDouble(interp, argv[2], &cut_index) != TCL_OK) { 394 return TCL_ERROR; 395 } 396 if (Tcl_GetDouble(interp, argv[3], &location) != TCL_OK) { 397 return TCL_ERROR; 398 } 399 400 volume[(int)volume_index]->move_cutplane((int)cut_index, (float)location); 401 return TCL_OK; 402 } 403 404 405 static int 406 CutEnableCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 407 { 408 fprintf(stderr, "cutplane enable/disable command\n"); 409 410 double volume_index, cut_index, mode; 411 412 if (argc != 4) { 413 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 414 " volume_index cut_index mode\"", (char*)NULL); 415 return TCL_ERROR; 416 } 417 if (Tcl_GetDouble(interp, argv[1], &volume_index) != TCL_OK) { 418 return TCL_ERROR; 419 } 420 if (Tcl_GetDouble(interp, argv[2], &cut_index) != TCL_OK) { 421 return TCL_ERROR; 422 } 423 if (Tcl_GetDouble(interp, argv[3], &mode) != TCL_OK) { 424 return TCL_ERROR; 425 } 426 427 if(mode==0) 428 volume[(int)volume_index]->disable_cutplane((int)cut_index); 429 else 430 volume[(int)volume_index]->enable_cutplane((int)cut_index); 431 432 return TCL_OK; 433 } 298 434 299 435 static int … … 1088 1224 Tcl_MakeSafe(interp); 1089 1225 1226 //hello test 1090 1227 Tcl_CreateCommand(interp, "hello", HelloCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1228 1229 //set camera (viewing) 1091 1230 Tcl_CreateCommand(interp, "camera", CameraCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1092 Tcl_CreateCommand(interp, "move", MoveCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1093 Tcl_CreateCommand(interp, "transferfunction", TransferFunctionCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1231 1232 //resize the width and height of render screen 1233 Tcl_CreateCommand(interp, "screen", ScreenResizeCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1234 1235 //create new transfer function 1236 Tcl_CreateCommand(interp, "tf_new", TransferFunctionNewCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1237 //update an existing transfer function 1238 Tcl_CreateCommand(interp, "tf_update", TransferFunctionUpdateCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1239 1240 //create new volume 1241 Tcl_CreateCommand(interp, "volume_new", VolumeNewCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1242 //link an EXISTING volume and transfer function to the volume renderer. 1243 //Only after being added, can a volume be rendered. This command does not create a volume nor a transfer function 1244 Tcl_CreateCommand(interp, "volume_link", VolumeLinkCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1245 //move an volume 1246 Tcl_CreateCommand(interp, "volume_move", VolumeMoveCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1247 //enable or disable an existing volume 1248 Tcl_CreateCommand(interp, "volume_enable", VolumeEnableCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1249 1250 //move a cut plane 1251 Tcl_CreateCommand(interp, "cut_move", CutMoveCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1252 //enable or disable a cut plane 1253 Tcl_CreateCommand(interp, "cut_enable", CutEnableCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1254 1255 //refresh the screen (render again) 1094 1256 Tcl_CreateCommand(interp, "refresh", RefreshCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL); 1095 //Tcl_CreateCommand(interp, "cut", CutCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);1096 Tcl_CreateCommand(interp, "load", LoadCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);1097 Tcl_CreateCommand(interp, "screen", ScreenSizeCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);1098 1257 } 1099 1258
Note: See TracChangeset
for help on using the changeset viewer.