00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <string.h>
00023 #include <ctype.h>
00024 #include <tcl.h>
00025
00026 #if defined(ARCH_AIX4)
00027 #include <strings.h>
00028 #endif
00029
00030 #include "config.h"
00031 #include "DisplayDevice.h"
00032 #include "Axes.h"
00033 #include "CommandQueue.h"
00034 #include "MoleculeList.h"
00035 #include "VMDApp.h"
00036 #include "Stage.h"
00037 #include "TclCommands.h"
00038 #include "Scene.h"
00039 #include "FPS.h"
00040
00041
00042
00043
00044
00045
00046
00047
00048
00052
00053
00054 #define TCL_RET(fmt, val) \
00055 sprintf(s, fmt, val); \
00056 Tcl_AppendElement(interp, s); \
00057 return TCL_OK
00058
00059 int text_cmd_display(ClientData cd, Tcl_Interp *interp, int argc,
00060 const char *argv[]) {
00061 VMDApp *app = (VMDApp *)cd;
00062
00063
00064 if (argc <= 1) {
00065 Tcl_SetResult(interp,
00066 (char *)
00067 "display get <eyesep | focallength | height | distance | antialias |\n"
00068 " depthcue | culling | size | \n"
00069 " stereo | stereomodes | stereoswap |\n"
00070 " cachemode | cachemodes | rendermode | rendermodes |\n"
00071 " projection | projections | nearclip | farclip |\n"
00072 " cuestart | cueend | cuedensity | cuemode |\n"
00073 " shadows | ambientocclusion | aoambient | aodirect |\n"
00074 " backgroundgradient>\n"
00075 "display <reshape | resetview | resize | reposition>\n"
00076 "display <eyesep | focallength | height | distance | antialias |\n"
00077 " depthcue | culling | cachemode | rendermode |\n"
00078 " stereo | stereoswap |\n"
00079 " shadows | ambientocclusion | backgroundgradient> newvalue\n"
00080 "display <nearclip | farclip> <set | add> newvalue\n"
00081 "display <cuestart | cueend | cuedensity | cuemode> newvalue\n"
00082 "display fps [on | off ]\n"
00083 "display update [on | off | status | ui]",
00084 TCL_STATIC);
00085 return TCL_ERROR;
00086 }
00087
00088
00089 if (argc == 3 && !strupncmp(argv[1], "get", CMDLEN)) {
00090 char s[128];
00091 if (!strupncmp(argv[2], "eyesep", CMDLEN)) {
00092 TCL_RET("%f", app->display->eyesep());
00093 #if 1
00094
00095
00096
00097
00098
00099 } else if (!strupncmp(argv[2], "eyepos", CMDLEN)) {
00100 float pos[3];
00101 app->display->get_eye_pos(&pos[0]);
00102 for (int i=0; i<3; i++) {
00103 sprintf(s, "%f", pos[i]);
00104 Tcl_AppendElement(interp, s);
00105 }
00106 return TCL_OK;
00107 } else if (!strupncmp(argv[2], "eyedir", CMDLEN)) {
00108 float dir[3];
00109 app->display->get_eye_dir(&dir[0]);
00110 for (int i=0; i<3; i++) {
00111 sprintf(s, "%f", dir[i]);
00112 Tcl_AppendElement(interp, s);
00113 }
00114 return TCL_OK;
00115 } else if (!strupncmp(argv[2], "eyeup", CMDLEN)) {
00116 float up[3];
00117 app->display->get_eye_up(&up[0]);
00118 for (int i=0; i<3; i++) {
00119 sprintf(s, "%f", up[i]);
00120 Tcl_AppendElement(interp, s);
00121 }
00122 return TCL_OK;
00123 #endif
00124 } else if (!strupncmp(argv[2], "focallength", CMDLEN)) {
00125 TCL_RET("%f", app->display->eye_dist());
00126 } else if (!strupncmp(argv[2], "height", CMDLEN)) {
00127 TCL_RET("%f", app->display->screen_height());
00128 } else if (!strupncmp(argv[2], "distance", CMDLEN)) {
00129 TCL_RET("%f", app->display->distance_to_screen());
00130 } else if (!strupncmp(argv[2], "ambientocclusion", CMDLEN)) {
00131 Tcl_AppendElement(interp,
00132 app->display->ao_enabled() ? "on" : "off");
00133 return TCL_OK;
00134 } else if (!strupncmp(argv[2], "aoambient", CMDLEN)) {
00135 TCL_RET("%f", app->display->get_ao_ambient());
00136 } else if (!strupncmp(argv[2], "aodirect", CMDLEN)) {
00137 TCL_RET("%f", app->display->get_ao_direct());
00138 } else if (!strupncmp(argv[2], "antialias", CMDLEN)) {
00139 Tcl_AppendElement(interp,
00140 app->display->aa_enabled() ? "on" : "off");
00141 return TCL_OK;
00142 } else if (!strupncmp(argv[2], "depthcue", CMDLEN)) {
00143 Tcl_AppendElement(interp,
00144 app->display->cueing_enabled() ? "on" : "off");
00145 return TCL_OK;
00146 } else if (!strupncmp(argv[2], "backgroundgradient", CMDLEN)) {
00147 Tcl_AppendElement(interp,
00148 app->scene->background_mode() ? "on" : "off");
00149 return TCL_OK;
00150 } else if (!strupncmp(argv[2], "culling", CMDLEN)) {
00151 Tcl_AppendElement(interp,
00152 app->display->culling_enabled() ? "on" : "off");
00153 return TCL_OK;
00154 } else if (!strupncmp(argv[2], "shadows", CMDLEN)) {
00155 Tcl_AppendElement(interp,
00156 app->display->shadows_enabled() ? "on" : "off");
00157 return TCL_OK;
00158 } else if (!strupncmp(argv[2], "size", CMDLEN)) {
00159 int w, h;
00160 app->display_get_size(&w, &h);
00161 sprintf(s, "%d", w);
00162 Tcl_AppendElement(interp, s);
00163 sprintf(s, "%d", h);
00164 Tcl_AppendElement(interp, s);
00165 return TCL_OK;
00166 } else if (!strupncmp(argv[2], "fps", CMDLEN)) {
00167 Tcl_AppendElement(interp, app->fps->displayed() ? "on" : "off");
00168 return TCL_OK;
00169 } else if (!strupncmp(argv[2], "stereo", CMDLEN)) {
00170 Tcl_AppendElement(interp,
00171 app->display->stereo_name(app->display->stereo_mode()));
00172 return TCL_OK;
00173 } else if (!strupncmp(argv[2], "stereoswap", CMDLEN)) {
00174 Tcl_AppendElement(interp, app->display->stereo_swap() ? "on" : "off");
00175 return TCL_OK;
00176 } else if (!strupncmp(argv[2], "stereomodes", CMDLEN)) {
00177 int i;
00178 for (i=0; i<app->display->num_stereo_modes(); i++) {
00179 Tcl_AppendElement(interp, app->display->stereo_name(i));
00180 }
00181 return TCL_OK;
00182 } else if (!strupncmp(argv[2], "cachemode", CMDLEN)) {
00183 Tcl_AppendElement(interp,
00184 app->display->cache_name(app->display->cache_mode()));
00185 return TCL_OK;
00186 } else if (!strupncmp(argv[2], "cachemodes", CMDLEN)) {
00187 int i;
00188 for (i=0; i<app->display->num_cache_modes(); i++) {
00189 Tcl_AppendElement(interp, app->display->cache_name(i));
00190 }
00191 return TCL_OK;
00192 } else if (!strupncmp(argv[2], "rendermode", CMDLEN)) {
00193 Tcl_AppendElement(interp,
00194 app->display->render_name(app->display->render_mode()));
00195 return TCL_OK;
00196 } else if (!strupncmp(argv[2], "rendermodes", CMDLEN)) {
00197 int i;
00198 for (i=0; i<app->display->num_render_modes(); i++) {
00199 Tcl_AppendElement(interp, app->display->render_name(i));
00200 }
00201 return TCL_OK;
00202 } else if (!strupncmp(argv[2], "projection", CMDLEN)) {
00203 Tcl_AppendResult(interp, app->display->get_projection(), NULL);
00204 return TCL_OK;
00205 } else if (!strupncmp(argv[2], "projections", CMDLEN)) {
00206 for (int i=0; i<app->display->num_projections(); i++)
00207 Tcl_AppendElement(interp, app->display->projection_name(i));
00208 return TCL_OK;
00209 } else if (!strupncmp(argv[2], "nearclip", CMDLEN)) {
00210 TCL_RET("%f", app->display->near_clip());
00211 } else if (!strupncmp(argv[2], "farclip", CMDLEN)) {
00212 TCL_RET("%f", app->display->far_clip());
00213 } else if (!strupncmp(argv[2], "cuestart", CMDLEN)) {
00214 TCL_RET("%f", app->display->get_cue_start());
00215 } else if (!strupncmp(argv[2], "cueend", CMDLEN)) {
00216 TCL_RET("%f", app->display->get_cue_end());
00217 } else if (!strupncmp(argv[2], "cuedensity", CMDLEN)) {
00218 TCL_RET("%f", app->display->get_cue_density());
00219 } else if (!strupncmp(argv[2], "cuemode", CMDLEN)) {
00220 Tcl_AppendResult(interp, app->display->get_cue_mode(), NULL);
00221 return TCL_OK;
00222 } else {
00223 Tcl_SetResult(interp,
00224 (char *)
00225 "possible parameters to 'display get' are:\n"
00226 "eyesep focallength height distance antialias depthcue culling\n"
00227 "stereo stereomodes stereoswap nearclip farclip\n"
00228 "cuestart cueend cuedensity cuemode\n"
00229 "shadows, ambientocclusion, aoambient, aodirect\n",
00230 TCL_STATIC);
00231 return TCL_ERROR;
00232 }
00234 }
00235
00236 if(argc == 2) {
00237 if(!strupncmp(argv[1],"resetview",CMDLEN)) {
00238 app->scene_resetview();
00239 return TCL_OK;
00240 } else if(!strupncmp(argv[1],"update",CMDLEN)) {
00241 app->display_update();
00242 return TCL_OK;
00243 } else
00244 return TCL_ERROR;
00245
00246 } else if(argc == 3) {
00247 if (!strupncmp(argv[1], "fps", CMDLEN)) {
00248 int on;
00249 if (Tcl_GetBoolean(interp, argv[2], &on) != TCL_OK) return TCL_ERROR;
00250 app->display_set_fps(on);
00251 #if 1
00252
00253
00254
00255
00256
00257 } else if (!strupncmp(argv[1], "eyepos", CMDLEN)) {
00258 float pos[3];
00259 if (tcl_get_vector(argv[2], &pos[0], interp) != TCL_OK) {
00260 return TCL_ERROR;
00261 }
00262 app->display->set_eye_pos(&pos[0]);
00263 return TCL_OK;
00264 } else if (!strupncmp(argv[1], "eyedir", CMDLEN)) {
00265 float dir[3];
00266 if (tcl_get_vector(argv[2], &dir[0], interp) != TCL_OK) {
00267 return TCL_ERROR;
00268 }
00269 app->display->set_eye_dir(&dir[0]);
00270 return TCL_OK;
00271 } else if (!strupncmp(argv[1], "eyeup", CMDLEN)) {
00272 float up[3];
00273 if (tcl_get_vector(argv[2], &up[0], interp) != TCL_OK) {
00274 return TCL_ERROR;
00275 }
00276 app->display->set_eye_up(&up[0]);
00277 return TCL_OK;
00278 #endif
00279 } else if(!strupncmp(argv[1],"eyesep",CMDLEN)) {
00280 app->display_set_eyesep((float)atof(argv[2]));
00281 } else if(!strupncmp(argv[1],"focallength",CMDLEN)) {
00282 app->display_set_focallen((float)atof(argv[2]));
00283 } else if(!strupncmp(argv[1],"height",CMDLEN)) {
00284 app->display_set_screen_height((float) atof(argv[2]));
00285 } else if(!strupncmp(argv[1],"distance",CMDLEN)) {
00286 app->display_set_screen_distance((float) atof(argv[2]));
00287 } else if(!strupncmp(argv[1],"ambientocclusion",CMDLEN)) {
00288 int onoff=0;
00289 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00290 app->display_set_ao(onoff);
00291 } else if(!strupncmp(argv[1],"aoambient",CMDLEN)) {
00292 double val=0;
00293 if (Tcl_GetDouble(interp, argv[2], &val) != TCL_OK) return TCL_ERROR;
00294 app->display_set_ao_ambient((float)val);
00295 } else if(!strupncmp(argv[1],"aodirect",CMDLEN)) {
00296 double val=0;
00297 if (Tcl_GetDouble(interp, argv[2], &val) != TCL_OK) return TCL_ERROR;
00298 app->display_set_ao_direct((float)val);
00299 } else if(!strupncmp(argv[1],"antialias",CMDLEN)) {
00300 int onoff=0;
00301 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00302 app->display_set_aa(onoff);
00303 } else if(!strupncmp(argv[1],"depthcue",CMDLEN)) {
00304 int onoff=0;
00305 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00306 app->display_set_depthcue(onoff);
00307 } else if(!strupncmp(argv[1],"backgroundgradient",CMDLEN)) {
00308 int onoff=0;
00309 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00310 app->display_set_background_mode(onoff);
00311 } else if(!strupncmp(argv[1],"culling",CMDLEN)) {
00312 int onoff=0;
00313 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00314 app->display_set_culling(onoff);
00315 } else if(!strupncmp(argv[1],"shadows",CMDLEN)) {
00316 int onoff=0;
00317 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00318 app->display_set_shadows(onoff);
00319 } else if(!strupncmp(argv[1],"stereo",CMDLEN)) {
00320 app->display_set_stereo(argv[2]);
00321 } else if(!strupncmp(argv[1],"stereoswap",CMDLEN)) {
00322 int onoff=0;
00323 if (Tcl_GetBoolean(interp, argv[2], &onoff) != TCL_OK) return TCL_ERROR;
00324 app->display_set_stereo_swap(onoff);
00325 } else if(!strupncmp(argv[1],"cachemode",CMDLEN)) {
00326 app->display_set_cachemode(argv[2]);
00327 } else if(!strupncmp(argv[1],"rendermode",CMDLEN)) {
00328 app->display_set_rendermode(argv[2]);
00329 } else if (!strupncmp(argv[1], "projection", CMDLEN) ||
00330 !strupncmp(argv[1], "proj", CMDLEN)) {
00331 if (!app->display_set_projection(argv[2])) {
00332 Tcl_AppendResult(interp, "Invalid projection: ", argv[2], NULL);
00333 return TCL_ERROR;
00334 }
00335 } else if(!strupncmp(argv[1],"update",CMDLEN)) {
00336 int booltmp;
00337 if (!strcmp(argv[2], "status")) {
00338 char s[20];
00339 TCL_RET("%d", app->display_update_status());
00340 } else if (!strcmp(argv[2], "ui")) {
00341 app->display_update_ui();
00342 return TCL_OK;
00343 } else if (Tcl_GetBoolean(interp, argv[2], &booltmp) == TCL_OK) {
00344 app->display_update_on(booltmp);
00345 return TCL_OK;
00346 } else {
00347 return TCL_ERROR;
00348 }
00349 } else if(!strupncmp(argv[1],"cuemode",CMDLEN)) {
00350 if (!app->depthcue_set_mode(argv[2])) {
00351 Tcl_AppendResult(interp, "Illegal cuemode: ", argv[2], NULL);
00352 return TCL_ERROR;
00353 }
00354 } else if(!strupncmp(argv[1],"cuestart",CMDLEN)) {
00355 double val=0;
00356 if (Tcl_GetDouble(interp, argv[2], &val) != TCL_OK) return TCL_ERROR;
00357 app->depthcue_set_start((float)val);
00358 } else if(!strupncmp(argv[1],"cueend",CMDLEN)) {
00359 double val=0;
00360 if (Tcl_GetDouble(interp, argv[2], &val) != TCL_OK) return TCL_ERROR;
00361 app->depthcue_set_end((float)val);
00362 } else if(!strupncmp(argv[1],"cuedensity",CMDLEN)) {
00363 double val=0;
00364 if (Tcl_GetDouble(interp, argv[2], &val) != TCL_OK) return TCL_ERROR;
00365 app->depthcue_set_density((float)val);
00366 } else
00367 return TCL_ERROR;
00368
00369 } else if(argc == 4) {
00370 if(!strupncmp(argv[1],"nearclip",CMDLEN)) {
00371 int isdelta = -1;
00372 if(!strupncmp(argv[2],"set",CMDLEN))
00373 isdelta = 0;
00374 else if(!strupncmp(argv[2],"add",CMDLEN))
00375 isdelta = 1;
00376 if (isdelta < 0) return TCL_ERROR;
00377 app->display_set_nearclip((float)atof(argv[3]), isdelta);
00378 } else if(!strupncmp(argv[1],"farclip",CMDLEN)) {
00379 int isdelta = -1;
00380 if(!strupncmp(argv[2],"set",CMDLEN))
00381 isdelta = 0;
00382 else if(!strupncmp(argv[2],"add",CMDLEN))
00383 isdelta = 1;
00384 if (isdelta < 0) return TCL_ERROR;
00385 app->display_set_farclip((float)atof(argv[3]), isdelta);
00386 } else if (!strupncmp(argv[1], "resize", CMDLEN)) {
00387 int w, h;
00388 if (Tcl_GetInt(interp, argv[2], &w) != TCL_OK ||
00389 Tcl_GetInt(interp, argv[3], &h) != TCL_OK)
00390 return TCL_ERROR;
00391 app->display_set_size(w, h);
00392 } else if (!strupncmp(argv[1], "reposition", CMDLEN)) {
00393 int x, y;
00394 if (Tcl_GetInt(interp, argv[2], &x) != TCL_OK ||
00395 Tcl_GetInt(interp, argv[3], &y) != TCL_OK)
00396 return TCL_ERROR;
00397 app->display_set_position(x, y);
00398 } else
00399 return TCL_ERROR;
00400 } else
00401 return TCL_ERROR;
00402
00403
00404 return TCL_OK;
00405 }
00406
00407
00408 int text_cmd_light(ClientData cd, Tcl_Interp *interp, int argc,
00409 const char *argv[]) {
00410
00411 VMDApp *app = (VMDApp *)cd;
00412 Scene *scene = app->scene;
00413
00414 if (argc <= 1) {
00415 Tcl_SetResult(interp,
00416 (char *)
00417 "light <number> [on|off|highlight|unhighlight|status]\n"
00418 "light <number> rot <axis> <deg>\n"
00419 "light <number> pos\n"
00420 "light <number> pos [{x y z} | default]\n"
00421 "light num\n",
00422 TCL_STATIC);
00423 return TCL_ERROR;
00424 }
00425 if ((argc == 3 || argc == 4) && !strupncmp(argv[2], "pos", CMDLEN)) {
00426 int num = atoi(argv[1]);
00427 if (argc == 4) {
00428 float pos[3];
00429 if (!strupncmp(argv[3], "default", 8)) {
00430 const float *def = scene->light_pos_default(num);
00431 if (!def) return TCL_ERROR;
00432 for (int i=0; i<3; i++) {
00433 char buf[20];
00434 sprintf(buf, "%f", def[i]);
00435 Tcl_AppendElement(interp, buf);
00436 }
00437 return TCL_OK;
00438
00439 } else if (tcl_get_vector(argv[3], pos, interp) != TCL_OK) {
00440 return TCL_ERROR;
00441 }
00442 app->light_move(num, pos);
00443 return TCL_OK;
00444 } else {
00445 const float *pos = scene->light_pos(num);
00446 if (!pos) return TCL_ERROR;
00447 for (int i=0; i<3; i++) {
00448 char buf[20];
00449 sprintf(buf, "%f", pos[i]);
00450 Tcl_AppendElement(interp, buf);
00451 }
00452 return TCL_OK;
00453 }
00454 }
00455 if (argc == 2 && !strupncmp(argv[1], "num", CMDLEN)) {
00456
00457 char tmpstring[64];
00458 sprintf(tmpstring, "%d", DISP_LIGHTS);
00459 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00460 return TCL_OK;
00461 }
00462 int n;
00463 if (Tcl_GetInt(interp, argv[1], &n) != TCL_OK) {
00464 Tcl_AppendResult(interp, " -- light <number> ...", NULL);
00465 return TCL_ERROR;
00466 }
00467 if(argc == 3) {
00468 if(!strupncmp(argv[2],"on",CMDLEN))
00469 app->light_on(n, 1);
00470 else if(!strupncmp(argv[2],"off",CMDLEN))
00471 app->light_on(n, 0);
00472 else if(!strupncmp(argv[2],"highlight",CMDLEN))
00473 app->light_highlight(n, 1);
00474 else if(!strupncmp(argv[2],"unhighlight",CMDLEN))
00475 app->light_highlight(n, 0);
00476 else if(!strupncmp(argv[2],"status",CMDLEN)) {
00477 char tmpstring[1024];
00478
00479
00480 if (n < 0 || n >= DISP_LIGHTS) {
00481 sprintf(tmpstring, "light value %d out of range", n);
00482 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00483 return TCL_ERROR;
00484 }
00485 sprintf(tmpstring, "%s %s",
00486 app->scene->light_active(n) ? "on" : "off",
00487 app->scene->light_highlighted(n) ?
00488 "highlight" : "unhighlight");
00489 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00490 return TCL_OK;
00491 } else
00492 return TCL_ERROR;
00493
00494 } else if(argc == 5 && !strupncmp(argv[2],"rot",CMDLEN)) {
00495 char axis = (char)(tolower(argv[3][0]));
00496 float deg = (float) atof(argv[4]);
00497 app->light_rotate(n, deg, axis);
00498
00499 } else
00500 return TCL_ERROR;
00501
00502
00503 return TCL_OK;
00504 }
00505
00506
00507 int text_cmd_point_light(ClientData cd, Tcl_Interp *interp, int argc,
00508 const char *argv[]) {
00509 VMDApp *app = (VMDApp *)cd;
00510 Scene *scene = app->scene;
00511
00512 if (argc <= 1) {
00513 Tcl_SetResult(interp,
00514 (char *)
00515 "pointlight <number> [on|off|highlight|unhighlight|status]\n"
00516
00517 "pointlight <number> pos\n"
00518 "pointlight <number> pos [{x y z} | default]\n"
00519 "pointlight <number> attenuation [{constant linear quadratic} | default]\n"
00520 "pointlight num\n",
00521 TCL_STATIC);
00522 return TCL_ERROR;
00523 }
00524 if ((argc == 3 || argc == 4) && !strupncmp(argv[2], "pos", CMDLEN)) {
00525 int num = atoi(argv[1]);
00526 if (argc == 4) {
00527 float pos[3];
00528 if (!strupncmp(argv[3], "default", 8)) {
00529 const float *def = scene->adv_light_pos_default(num);
00530 if (!def) return TCL_ERROR;
00531 for (int i=0; i<3; i++) {
00532 char buf[20];
00533 sprintf(buf, "%f", def[i]);
00534 Tcl_AppendElement(interp, buf);
00535 }
00536 return TCL_OK;
00537
00538 } else if (tcl_get_vector(argv[3], pos, interp) != TCL_OK) {
00539 return TCL_ERROR;
00540 }
00541
00542 #if 1
00543
00544
00545 scene->move_adv_light(num, pos);
00546 #else
00547
00548 scene->move_adv_light(num, pos);
00549 #endif
00550 return TCL_OK;
00551 } else {
00552 const float *pos = scene->adv_light_pos(num);
00553 if (!pos) return TCL_ERROR;
00554 for (int i=0; i<3; i++) {
00555 char buf[20];
00556 sprintf(buf, "%f", pos[i]);
00557 Tcl_AppendElement(interp, buf);
00558 }
00559 return TCL_OK;
00560 }
00561 }
00562
00563 if ((argc == 3 || argc == 4) && !strupncmp(argv[2], "attenuation", CMDLEN)) {
00564 int num = atoi(argv[1]);
00565 if (argc == 4) {
00566 float factors[3] = { 1.0f, 0.0f, 0.0f };
00567 if (!strupncmp(argv[3], "default", 8)) {
00568 scene->adv_light_attenuation(num, factors[0], factors[1], factors[2]);
00569 return TCL_OK;
00570
00571 } else if (tcl_get_vector(argv[3], factors, interp) != TCL_OK) {
00572 return TCL_ERROR;
00573 }
00574
00575 #if 1
00576 scene->adv_light_attenuation(num, factors[0], factors[1], factors[2]);
00577 #endif
00578 return TCL_OK;
00579 } else {
00580 float factors[3] = { 1.0f, 0.0f, 0.0f };
00581 scene->adv_light_get_attenuation(num, factors[0], factors[1], factors[2]);
00582 for (int i=0; i<3; i++) {
00583 char buf[20];
00584 sprintf(buf, "%f", factors[i]);
00585 Tcl_AppendElement(interp, buf);
00586 }
00587 return TCL_OK;
00588 }
00589 }
00590
00591 if (argc == 2 && !strupncmp(argv[1], "num", CMDLEN)) {
00592
00593 char tmpstring[64];
00594 sprintf(tmpstring, "%d", DISP_LIGHTS);
00595 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00596 return TCL_OK;
00597 }
00598 int n;
00599 if (Tcl_GetInt(interp, argv[1], &n) != TCL_OK) {
00600 Tcl_AppendResult(interp, " -- pointlight <number> ...", NULL);
00601 return TCL_ERROR;
00602 }
00603 if(argc == 3) {
00604 if(!strupncmp(argv[2],"on",CMDLEN))
00605 scene->activate_adv_light(n, 1);
00606 else if(!strupncmp(argv[2],"off",CMDLEN))
00607 scene->activate_adv_light(n, 0);
00608 else if(!strupncmp(argv[2],"highlight",CMDLEN))
00609 scene->highlight_adv_light(n, 1);
00610 else if(!strupncmp(argv[2],"unhighlight",CMDLEN))
00611 scene->highlight_adv_light(n, 0);
00612 else if(!strupncmp(argv[2],"status",CMDLEN)) {
00613 char tmpstring[1024];
00614
00615
00616 if (n < 0 || n >= DISP_LIGHTS) {
00617 sprintf(tmpstring, "light value %d out of range", n);
00618 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00619 return TCL_ERROR;
00620 }
00621 sprintf(tmpstring, "%s %s",
00622 app->scene->adv_light_active(n) ? "on" : "off",
00623 app->scene->adv_light_highlighted(n) ?
00624 "highlight" : "unhighlight");
00625 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00626 return TCL_OK;
00627 } else
00628 return TCL_ERROR;
00629 #if 0
00630 } else if(argc == 5 && !strupncmp(argv[2],"rot",CMDLEN)) {
00631 char axis = (char)(tolower(argv[3][0]));
00632 float deg = (float) atof(argv[4]);
00633 app->light_rotate(n, deg, axis);
00634 #endif
00635 } else
00636 return TCL_ERROR;
00637
00638
00639 return TCL_OK;
00640 }
00641
00642
00643 int text_cmd_axes(ClientData cd, Tcl_Interp *interp, int argc,
00644 const char *argv[]) {
00645
00646 VMDApp *app = (VMDApp *)cd;
00647
00648 if (app->axes && argc == 2) {
00649 if(!strupncmp(argv[1],"location",CMDLEN)) {
00650
00651 Tcl_SetResult(interp, app->axes->loc_description(app->axes->location()), TCL_VOLATILE);
00652 return TCL_OK;
00653 } else if(!strupncmp(argv[1],"locations",CMDLEN)) {
00654
00655 for (int ii=0; ii<app->axes->locations(); ii++) {
00656 Tcl_AppendElement(interp, app->axes->loc_description(ii));
00657 }
00658 return TCL_OK;
00659 }
00660
00661 Tcl_AppendResult(interp,
00662 "axes [location|locations]\n",
00663 "axes location [off|origin|lowerleft|lowerright|"
00664 "upperleft|upperright]",
00665 NULL
00666 );
00667 return TCL_ERROR;
00668
00669 }
00670 if(app->axes && argc == 3) {
00671 if(!strupncmp(argv[1],"location",CMDLEN)) {
00672 if (!app->axes_set_location(argv[2])) {
00673 Tcl_AppendResult(interp, "Invalid axes location: ", argv[2], NULL);
00674 return TCL_ERROR;
00675 }
00676 }
00677 } else
00678 return TCL_ERROR;
00679
00680
00681 return TCL_OK;
00682 }
00683
00684
00685 int text_cmd_stage(ClientData cd, Tcl_Interp *interp, int argc,
00686 const char *argv[]) {
00687
00688 VMDApp *app = (VMDApp *)cd;
00689 Stage *stage = app->stage;
00690 if (!stage)
00691 return TCL_ERROR;
00692
00693 if (argc < 2 || argc > 3) {
00694 int i;
00695 Tcl_AppendResult(interp, (char *) "stage location <", TCL_STATIC);
00696 for (i=0; i < stage->locations(); i++) {
00697 Tcl_AppendResult(interp, stage->loc_description(i), NULL);
00698 if (i < (stage->locations()-1))
00699 Tcl_AppendResult(interp, " | ", NULL);
00700 }
00701 Tcl_AppendResult(interp, (char *) ">\n", TCL_STATIC);
00702 Tcl_AppendResult(interp, (char *) "stage locations\n", TCL_STATIC);
00703 Tcl_AppendResult(interp, (char *) "stage panels [ numpanels ]\n", TCL_STATIC);
00704 Tcl_AppendResult(interp, (char *) "stage size [ value ]\n", TCL_STATIC);
00705 return TCL_ERROR;
00706 }
00707
00708 if (argc == 2) {
00709 if (!strupncmp(argv[1], "location", CMDLEN)) {
00710 Tcl_AppendElement(interp, stage->loc_description(stage->location()));
00711 return TCL_OK;
00712 } else if (!strupncmp(argv[1], "locations", CMDLEN)) {
00713 int i;
00714 for (i=0; i < stage->locations(); i++) {
00715 Tcl_AppendElement(interp, stage->loc_description(i));
00716 }
00717 return TCL_OK;
00718 } else if (!strupncmp(argv[1], "panels", CMDLEN)) {
00719 char s[20];
00720 sprintf(s, "%d", stage->panels());
00721 Tcl_AppendElement(interp, s);
00722 return TCL_OK;
00723 } else if (!strupncmp(argv[1], "size", CMDLEN)) {
00724 char s[20];
00725 sprintf(s, "%f", stage->size());
00726 Tcl_AppendElement(interp, s);
00727 return TCL_OK;
00728 } else {
00729 Tcl_AppendResult(interp, "possible commands are: location, locations, "
00730 "panels [value]", NULL);
00731 return TCL_ERROR;
00732 }
00733
00734 }
00735
00736 if (argc == 3) {
00737 int i;
00738 if (!strupncmp(argv[1],"location",CMDLEN)) {
00739 if (app->stage_set_location(argv[2])) return TCL_OK;
00740 Tcl_AppendResult(interp, "Possible locations are ", NULL);
00741 for (i=0; i<stage->locations(); i++)
00742 Tcl_AppendElement(interp, stage->loc_description(i));
00743 return TCL_ERROR;
00744 } else if(!strupncmp(argv[1],"panels",CMDLEN)) {
00745 int num=0;
00746 if (Tcl_GetInt(interp, argv[2], &num) != TCL_OK ||
00747 !app->stage_set_numpanels(num))
00748 return TCL_ERROR;
00749 } else if(!strupncmp(argv[1],"size",CMDLEN)) {
00750 double sz=1.0;
00751 if (Tcl_GetDouble(interp, argv[2], &sz) != TCL_OK ||
00752 !app->stage_set_size((float) sz))
00753 return TCL_ERROR;
00754 } else {
00755 return TCL_ERROR;
00756 }
00757 }
00758
00759
00760 return TCL_OK;
00761 }
00762
00763
00764