00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdlib.h>
00024 #include "VMDApp.h"
00025 #include "Molecule.h"
00026 #include "MoleculeList.h"
00027 #include "MaterialList.h"
00028 #include "tcl.h"
00029 #include "TclCommands.h"
00030 #include "Scene.h"
00031 #include "MoleculeGraphics.h"
00032
00033
00034 #define AT_LEAST(n, s) \
00035 { \
00036 if (argc < n) { \
00037 Tcl_SetResult(interp, \
00038 (char *) "graphics: " s ": not enough parameters", \
00039 TCL_STATIC); \
00040 return TCL_ERROR; \
00041 } \
00042 }
00043
00044
00045 #define MUST_HAVE(n, s) \
00046 { \
00047 if (argc != n) { \
00048 Tcl_SetResult(interp, \
00049 (char *) "graphics: " s ": incorrect number of parameters", \
00050 TCL_STATIC); \
00051 return TCL_ERROR; \
00052 } \
00053 }
00054
00055
00056 static int tcl_graphics_triangle(MoleculeGraphics *gmol,
00057 int argc, const char *argv[],
00058 Tcl_Interp *interp)
00059 {
00060
00061 MUST_HAVE(3, "triangle");
00062 float vals[9];
00063 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
00064 tcl_get_vector(argv[1], vals+3, interp) != TCL_OK ||
00065 tcl_get_vector(argv[2], vals+6, interp) != TCL_OK ) {
00066 return TCL_ERROR;
00067 }
00068
00069
00070 char tmpstring[64];
00071 sprintf(tmpstring, "%d", gmol->add_triangle(vals+0, vals+3, vals+6));
00072 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00073 return TCL_OK;
00074 }
00075
00076
00077 static int tcl_graphics_trinorm(MoleculeGraphics *gmol,
00078 int argc, const char *argv[],
00079 Tcl_Interp *interp)
00080 {
00081
00082
00083 MUST_HAVE(6, "trinorm");
00084 float vals[19];
00085 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
00086 tcl_get_vector(argv[1], vals+3, interp) != TCL_OK ||
00087 tcl_get_vector(argv[2], vals+6, interp) != TCL_OK ||
00088 tcl_get_vector(argv[3], vals+9, interp) != TCL_OK ||
00089 tcl_get_vector(argv[4], vals+12, interp) != TCL_OK ||
00090 tcl_get_vector(argv[5], vals+15, interp) != TCL_OK ) {
00091 return TCL_ERROR;
00092 }
00093
00094
00095 char tmpstring[64];
00096 sprintf(tmpstring, "%d",
00097 gmol->add_trinorm(vals+0, vals+3, vals+6,
00098 vals+9, vals+12, vals+15));
00099 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00100 return TCL_OK;
00101 }
00102
00103
00104 static int tcl_graphics_tricolor(MoleculeGraphics *gmol,
00105 int argc, const char *argv[],
00106 Tcl_Interp *interp)
00107 {
00108
00109
00110 MUST_HAVE(9, "tricolor");
00111 float vals[19];
00112 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
00113 tcl_get_vector(argv[1], vals+3, interp) != TCL_OK ||
00114 tcl_get_vector(argv[2], vals+6, interp) != TCL_OK ||
00115 tcl_get_vector(argv[3], vals+9, interp) != TCL_OK ||
00116 tcl_get_vector(argv[4], vals+12, interp) != TCL_OK ||
00117 tcl_get_vector(argv[5], vals+15, interp) != TCL_OK ) {
00118 return TCL_ERROR;
00119 }
00120 int c1, c2, c3;
00121 if (Tcl_GetInt(interp, argv[6], &c1) != TCL_OK ||
00122 Tcl_GetInt(interp, argv[7], &c2) != TCL_OK ||
00123 Tcl_GetInt(interp, argv[8], &c3) != TCL_OK) {
00124 return TCL_ERROR;
00125 }
00126
00127
00128 char tmpstring[64];
00129 sprintf(tmpstring, "%d",
00130 gmol->add_tricolor(vals+0, vals+3, vals+6,
00131 vals+9, vals+12, vals+15, c1, c2, c3));
00132 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00133 return TCL_OK;
00134 }
00135
00136
00137 static int tcl_graphics_cylinder(MoleculeGraphics *gmol,
00138 int argc, const char *argv[],
00139 Tcl_Interp *interp)
00140 {
00141
00142 AT_LEAST(2, "cylinder");
00143 float vals[6];
00144 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
00145 tcl_get_vector(argv[1], vals+3, interp) != TCL_OK) {
00146 return TCL_ERROR;
00147 }
00148
00149
00150 double radius = 1.0;
00151 int resolution = 6;
00152 int filled = 0;
00153 argc -= 2;
00154 argv += 2;
00155 if (argc %2) {
00156 Tcl_SetResult(interp, (char *) "graphics: cylinder has wrong number of options", TCL_STATIC);
00157 return TCL_ERROR;
00158 }
00159 while (argc) {
00160 if (!strcmp(argv[0], "radius")) {
00161 if (Tcl_GetDouble(interp, argv[1], &radius) != TCL_OK) {
00162 return TCL_ERROR;
00163 }
00164 if (radius <0) radius = 0;
00165 argc -= 2;
00166 argv += 2;
00167 continue;
00168 }
00169 if (!strcmp(argv[0], "resolution")) {
00170 if (Tcl_GetInt(interp, argv[1], &resolution) != TCL_OK) {
00171 return TCL_ERROR;
00172 }
00173 if (resolution < 0) resolution = 0;
00174 if (resolution > 30) resolution = 30;
00175 argc -= 2;
00176 argv += 2;
00177 continue;
00178 }
00179 if (!strcmp(argv[0], "filled")) {
00180 if (Tcl_GetBoolean(interp, argv[1], &filled) != TCL_OK) {
00181 return TCL_ERROR;
00182 }
00183 argc -= 2;
00184 argv += 2;
00185 continue;
00186 }
00187
00188 Tcl_AppendResult(interp, "graphics: unknown option for cylinder: ",
00189 argv[0], NULL);
00190 return TCL_ERROR;
00191 }
00192
00193
00194 char tmpstring[64];
00195 sprintf(tmpstring, "%d",
00196 gmol->add_cylinder(vals+0, vals+3, (float) radius, resolution, filled));
00197 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00198 return TCL_OK;
00199 }
00200
00201
00202 static int tcl_graphics_point(MoleculeGraphics *gmol,
00203 int argc, const char *argv[],
00204 Tcl_Interp *interp)
00205 {
00206 MUST_HAVE(1, "point");
00207 float vals[3];
00208 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK) {
00209 return TCL_ERROR;
00210 }
00211
00212
00213 char tmpstring[64];
00214 sprintf(tmpstring, "%d", gmol->add_point(vals+0));
00215 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00216 return TCL_OK;
00217 }
00218
00219
00220 static int tcl_graphics_pickpoint(MoleculeGraphics *gmol,
00221 int argc, const char *argv[],
00222 Tcl_Interp *interp)
00223 {
00224 MUST_HAVE(1, "pickpoint");
00225 float vals[3];
00226 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK) {
00227 return TCL_ERROR;
00228 }
00229
00230
00231 char tmpstring[64];
00232 sprintf(tmpstring, "%d", gmol->add_pickpoint(vals+0));
00233 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00234 return TCL_OK;
00235 }
00236
00237
00238
00239 static int tcl_graphics_line(MoleculeGraphics *gmol,
00240 int argc, const char *argv[],
00241 Tcl_Interp *interp)
00242 {
00243
00244 AT_LEAST(2, "line");
00245 float vals[6];
00246 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
00247 tcl_get_vector(argv[1], vals+3, interp) != TCL_OK) {
00248 return TCL_ERROR;
00249 }
00250
00251
00252
00253 int line_style = ::SOLIDLINE;
00254 int width = 1;
00255 argc -= 2;
00256 argv += 2;
00257 if (argc %2) {
00258 Tcl_SetResult(interp, (char *) "graphics: line has wrong number of options", TCL_STATIC);
00259 return TCL_ERROR;
00260 }
00261 while (argc) {
00262 if (!strcmp(argv[0], "style")) {
00263 if (!strcmp(argv[1], "solid")) {
00264 line_style = ::SOLIDLINE;
00265 } else if (!strcmp(argv[1], "dashed")) {
00266 line_style = ::DASHEDLINE;
00267 } else {
00268 Tcl_AppendResult(interp, "graphics: don't understand the line style ",
00269 argv[1], NULL);
00270 return TCL_ERROR;
00271 }
00272 } else if (!strcmp(argv[0], "width")) {
00273 if (Tcl_GetInt(interp, argv[1], &width) != TCL_OK) {
00274 return TCL_ERROR;
00275 }
00276 if (width > 255) width = 255;
00277 if (width < 0) width = 0;
00278 } else {
00279 Tcl_AppendResult(interp, "graphics: don't understand the line option ",
00280 argv[0], NULL);
00281 return TCL_ERROR;
00282 }
00283 argc -= 2;
00284 argv += 2;
00285 }
00286
00287
00288 char tmpstring[64];
00289 sprintf(tmpstring, "%d", gmol->add_line(vals+0, vals+3, line_style, width));
00290 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00291 return TCL_OK;
00292 }
00293
00294
00295 static int tcl_graphics_materials(MoleculeGraphics *gmol,
00296 int argc, const char *argv[],
00297 Tcl_Interp *interp)
00298 {
00299 MUST_HAVE(1, "materials");
00300 int val;
00301 if (Tcl_GetBoolean(interp, argv[0], &val) != TCL_OK) {
00302 return TCL_ERROR;
00303 }
00304
00305
00306 char tmpstring[64];
00307 sprintf(tmpstring, "%d", gmol->use_materials(val));
00308 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00309 return TCL_OK;
00310 }
00311
00312
00313 static int tcl_graphics_material(MoleculeGraphics *gmol,
00314 int argc, const char *argv[],
00315 Tcl_Interp *interp, MaterialList *mlist)
00316 {
00317 MUST_HAVE(1, "material");
00318 int val = mlist->material_index(argv[0]);
00319 if (val < 0) {
00320 char tmpstring[1024];
00321 sprintf(tmpstring, "graphics: invalid material: %s", argv[0]);
00322 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00323 return TCL_ERROR;
00324 }
00325 const Material *mat = mlist->material(val);
00326 char tmpstring[64];
00327 sprintf(tmpstring, "%d", gmol->use_material(mat));
00328 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00329 return TCL_OK;
00330 }
00331
00332
00333
00334
00335 static int tcl_graphics_color(VMDApp *app, MoleculeGraphics *gmol,
00336 int argc, const char *argv[],
00337 Tcl_Interp *interp)
00338 {
00339 MUST_HAVE(1, "color");
00340
00341 int id;
00342 Tcl_ResetResult(interp);
00343 if (Tcl_GetInt(interp, argv[0], &id) == TCL_OK) {
00344
00345 if (id >=0 && id < MAXCOLORS) {
00346 char tmpstring[64];
00347 sprintf(tmpstring, "%d", gmol->use_color(id));
00348 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00349 return TCL_OK;
00350 } else {
00351 char tmpstring[64];
00352 sprintf(tmpstring, "graphics: color index value '%d' out of range", id);
00353 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00354 return TCL_ERROR;
00355 }
00356 }
00357
00358 Tcl_ResetResult(interp);
00359 id = app->color_index(argv[0]);
00360 if (id >= 0) {
00361 char tmpstring[64];
00362 sprintf(tmpstring, "%d", gmol->use_color(id));
00363 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00364 return TCL_OK;
00365 }
00366
00367 Tcl_AppendResult(interp, "graphics: unknown color: ", argv[0], NULL);
00368 return TCL_ERROR;
00369 }
00370
00371
00372 static int tcl_graphics_cone(MoleculeGraphics *gmol,
00373 int argc, const char *argv[],
00374 Tcl_Interp *interp)
00375 {
00376
00377 AT_LEAST(2, "cone");
00378 float vals[6];
00379 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
00380 tcl_get_vector(argv[1], vals+3, interp) != TCL_OK) {
00381 return TCL_ERROR;
00382 }
00383
00384
00385 double radius = 1.0;
00386 double radius2 = 0.0;
00387 int resolution = 6;
00388 argc -= 2;
00389 argv += 2;
00390 if (argc %2) {
00391 Tcl_SetResult(interp, (char *) "graphics: cone has wrong number of options", TCL_STATIC);
00392 return TCL_ERROR;
00393 }
00394 while (argc) {
00395 if (!strcmp(argv[0], "radius2")) {
00396 if (Tcl_GetDouble(interp, argv[1], &radius2) != TCL_OK) {
00397 return TCL_ERROR;
00398 }
00399 if (radius2 <0) radius2 = 0;
00400 argc -= 2;
00401 argv += 2;
00402 continue;
00403 }
00404 if (!strcmp(argv[0], "radius")) {
00405 if (Tcl_GetDouble(interp, argv[1], &radius) != TCL_OK) {
00406 return TCL_ERROR;
00407 }
00408 if (radius <0) radius = 0;
00409 argc -= 2;
00410 argv += 2;
00411 continue;
00412 }
00413 if (!strcmp(argv[0], "resolution")) {
00414 if (Tcl_GetInt(interp, argv[1], &resolution) != TCL_OK) {
00415 return TCL_ERROR;
00416 }
00417 if (resolution < 0) resolution = 0;
00418 if (resolution > 300) resolution = 300;
00419 argc -= 2;
00420 argv += 2;
00421 continue;
00422 }
00423
00424
00425 Tcl_AppendResult(interp, "graphics: unknown option for cone: ",
00426 argv[0], NULL);
00427 return TCL_ERROR;
00428 }
00429
00430
00431 char tmpstring[64];
00432 sprintf(tmpstring, "%d",
00433 gmol->add_cone(vals+0, vals+3, (float) radius, (float) radius2, resolution));
00434 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00435 return TCL_OK;
00436 }
00437
00438
00439
00440 static int tcl_graphics_sphere(MoleculeGraphics *gmol,
00441 int argc, const char *argv[],
00442 Tcl_Interp *interp)
00443 {
00444
00445 AT_LEAST(1, "sphere");
00446 float vals[3];
00447 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK) {
00448 return TCL_ERROR;
00449 }
00450
00451
00452 double radius = 1.0;
00453 int resolution = 6;
00454 argc -= 1;
00455 argv += 1;
00456 if (argc %2) {
00457 Tcl_SetResult(interp, (char *) "graphics: sphere has wrong number of options", TCL_STATIC);
00458 return TCL_ERROR;
00459 }
00460 while (argc) {
00461 if (!strcmp(argv[0], "radius")) {
00462 if (Tcl_GetDouble(interp, argv[1], &radius) != TCL_OK) {
00463 return TCL_ERROR;
00464 }
00465 if (radius <0) radius = 0;
00466 argc -= 2;
00467 argv += 2;
00468 continue;
00469 }
00470 if (!strcmp(argv[0], "resolution")) {
00471 if (Tcl_GetInt(interp, argv[1], &resolution) != TCL_OK) {
00472 return TCL_ERROR;
00473 }
00474 if (resolution < 0) resolution = 0;
00475 if (resolution > 30) resolution = 30;
00476 argc -= 2;
00477 argv += 2;
00478 continue;
00479 }
00480
00481 Tcl_AppendResult(interp, "graphics: unknown option for sphere: ",
00482 argv[0], NULL);
00483 return TCL_ERROR;
00484 }
00485
00486
00487 char tmpstring[64];
00488 sprintf(tmpstring, "%d",
00489 gmol->add_sphere(vals+0, (float) radius, resolution));
00490 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00491 return TCL_OK;
00492 }
00493
00494
00495 static int tcl_graphics_text(MoleculeGraphics *gmol, int argc, const char *argv[],
00496 Tcl_Interp *interp) {
00497
00498 AT_LEAST(2, "text");
00499 float vals[3];
00500 if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK) {
00501 return TCL_ERROR;
00502 }
00503
00504
00505 const char* string = argv[1];
00506 double size = 1.0;
00507 double thickness = 1.0;
00508 argc -= 2;
00509 argv += 2;
00510
00511 if (argc %2) {
00512 Tcl_SetResult(interp, (char *) "graphics: text has wrong number of options", TCL_STATIC);
00513 return TCL_ERROR;
00514 }
00515
00516 while (argc) {
00517 if (!strcmp(argv[0], "size")) {
00518 if (Tcl_GetDouble(interp, argv[1], &size) != TCL_OK) {
00519 return TCL_ERROR;
00520 }
00521 if (size <0) size = 0;
00522 argc -= 2;
00523 argv += 2;
00524 continue;
00525 }
00526
00527 if (!strcmp(argv[0], "thickness")) {
00528 if (Tcl_GetDouble(interp, argv[1], &thickness) != TCL_OK) {
00529 return TCL_ERROR;
00530 }
00531 if (thickness <0) thickness = 0;
00532 argc -= 2;
00533 argv += 2;
00534 continue;
00535 }
00536
00537
00538 Tcl_AppendResult(interp, "graphics: unknown option for text: ",
00539 argv[0], NULL);
00540 return TCL_ERROR;
00541 }
00542
00543
00544 char tmpstring[64];
00545 sprintf(tmpstring, "%d", gmol->add_text(vals+0, string, (float) size, (float) thickness));
00546 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00547 return TCL_OK;
00548 }
00549
00550
00552
00553 static int tcl_graphics_delete(MoleculeGraphics *gmol, int argc, const char *argv[],
00554 Tcl_Interp *interp) {
00555 if (argc != 1) {
00556 Tcl_SetResult(interp, (char *) "graphics: delete takes one parameter (either an index or 'all')", TCL_STATIC);
00557 return TCL_ERROR;
00558 }
00559 if (!strcmp(argv[0], "all")) {
00560 gmol->delete_all();
00561 return TCL_OK;
00562 }
00563 int id;
00564 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00565 return TCL_ERROR;
00566 }
00567 gmol->delete_id(id);
00568 return TCL_OK;
00569 }
00570
00571
00572 static int tcl_graphics_replace(MoleculeGraphics *gmol, int argc, const char *argv[],
00573 Tcl_Interp *interp) {
00574 if (argc != 1) {
00575 Tcl_SetResult(interp, (char *) "graphics: replace takes one parameter, the index", TCL_STATIC);
00576 return TCL_ERROR;
00577 }
00578 int id;
00579 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00580 return TCL_ERROR;
00581 }
00582 gmol->replace_id(id);
00583 return TCL_OK;
00584 }
00585
00586
00587 static int tcl_graphics_exists(MoleculeGraphics *gmol, int argc, const char *argv[],
00588 Tcl_Interp *interp) {
00589 if (argc != 1) {
00590 Tcl_SetResult(interp, (char *) "graphics: exists takes one parameter, the index", TCL_STATIC);
00591 return TCL_ERROR;
00592 }
00593 int id;
00594 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00595 return TCL_ERROR;
00596 }
00597
00598 char tmpstring[64];
00599 sprintf(tmpstring, "%d", gmol->index_id(id) != -1);
00600 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00601 return TCL_OK;
00602 }
00603
00604
00605 static int tcl_graphics_info(MoleculeGraphics *gmol,
00606 int argc, const char *argv[],
00607 Tcl_Interp *interp)
00608 {
00609 if (argc != 1) {
00610 Tcl_SetResult(interp, (char *) "graphics: info takes one parameter, the index", TCL_STATIC);
00611 return TCL_ERROR;
00612 }
00613 int id;
00614 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00615 return TCL_ERROR;
00616 }
00617
00618 Tcl_AppendResult(interp, gmol->info_id(id), NULL);
00619 return TCL_OK;
00620 }
00621
00622
00623
00624
00625 static int tcl_graphics(VMDApp *app, int molid, int argc, const char *argv[],
00626 Tcl_Interp *interp)
00627 {
00628
00629 Molecule *mol = app->moleculeList->mol_from_id(molid);
00630 if (mol == NULL) {
00631 Tcl_SetResult(interp, (char *) "graphics: invalid graphics molecule", TCL_STATIC);
00632 return TCL_ERROR;
00633 }
00634 if (argc < 1) {
00635 Tcl_SetResult(interp, (char *) "graphics: not enough parameters", TCL_STATIC);
00636 return TCL_ERROR;
00637 }
00638 MoleculeGraphics *gmol = mol->moleculeGraphics();
00639
00640 if (!strcmp(argv[0], "list")) {
00641 if (argc != 1) {
00642 Tcl_SetResult(interp, (char *) "graphics: list takes no parameters", TCL_STATIC);
00643 return TCL_ERROR;
00644 }
00645 int num = gmol->num_elements();
00646 for (int i=0; i<num; i++) {
00647 int id = gmol->element_id(i);
00648 if (id >=0) {
00649 char s[10];
00650 sprintf(s, "%d", id);
00651 Tcl_AppendElement(interp, s);
00652 }
00653 }
00654 return TCL_OK;
00655 }
00656
00657 if (argc < 2) {
00658 Tcl_SetResult(interp, (char *) "graphics: not enough parameters", TCL_STATIC);
00659 return TCL_ERROR;
00660 }
00661 if (!strcmp(argv[0], "triangle")) {
00662 return tcl_graphics_triangle(gmol, argc-1, argv+1, interp);
00663 }
00664 if (!strcmp(argv[0], "trinorm")) {
00665 return tcl_graphics_trinorm(gmol, argc-1, argv+1, interp);
00666 }
00667 if (!strcmp(argv[0], "tricolor")) {
00668 return tcl_graphics_tricolor(gmol, argc-1, argv+1, interp);
00669 }
00670 if (!strcmp(argv[0], "point")) {
00671 return tcl_graphics_point(gmol, argc-1, argv+1, interp);
00672 }
00673 if (!strcmp(argv[0], "pickpoint")) {
00674 return tcl_graphics_pickpoint(gmol, argc-1, argv+1, interp);
00675 }
00676 if (!strcmp(argv[0], "line")) {
00677 return tcl_graphics_line(gmol, argc-1, argv+1, interp);
00678 }
00679 if (!strcmp(argv[0], "cylinder")) {
00680 return tcl_graphics_cylinder(gmol, argc-1, argv+1, interp);
00681 }
00682 if (!strcmp(argv[0], "cone")) {
00683 return tcl_graphics_cone(gmol, argc-1, argv+1, interp);
00684 }
00685 if (!strcmp(argv[0], "sphere")) {
00686 return tcl_graphics_sphere(gmol, argc-1, argv+1, interp);
00687 }
00688 if (!strcmp(argv[0], "text")) {
00689 return tcl_graphics_text(gmol, argc-1, argv+1, interp);
00690 }
00691 if (!strcmp(argv[0], "materials")) {
00692 return tcl_graphics_materials(gmol, argc-1, argv+1, interp);
00693 }
00694 if (!strcmp(argv[0], "material")) {
00695 return tcl_graphics_material(gmol, argc-1, argv+1, interp,
00696 app->materialList);
00697 }
00698 if (!strcmp(argv[0], "color") || !strcmp(argv[1], "colour")) {
00699 return tcl_graphics_color(app, gmol, argc-1, argv+1, interp);
00700 }
00701 if (!strcmp(argv[0], "delete")) {
00702 return tcl_graphics_delete(gmol, argc-1, argv+1, interp);
00703 }
00704 if (!strcmp(argv[0], "exists")) {
00705 return tcl_graphics_exists(gmol, argc-1, argv+1, interp);
00706 }
00707 if (!strcmp(argv[0], "replace")) {
00708 return tcl_graphics_replace(gmol, argc-1, argv+1, interp);
00709 }
00710 if (!strcmp(argv[0], "info")) {
00711 return tcl_graphics_info(gmol, argc-1, argv+1, interp);
00712 }
00713 Tcl_AppendResult(interp, "graphics: don't understand the command: ",
00714 argv[0], NULL);
00715 return TCL_ERROR;
00716 }
00717
00718
00719
00720 int graphics_tcl(ClientData cd, Tcl_Interp *interp, int argc, const char *argv[]) {
00721
00722 if (argc < 2) {
00723 Tcl_SetResult(interp, (char *) "graphics: not enough parameters", TCL_STATIC);
00724 return TCL_ERROR;
00725 }
00726
00727 VMDApp *app = (VMDApp *)cd;
00728
00729 int mol = -1;
00730 if (!strcmp(argv[1], "top")) {
00731 if (app->moleculeList->top()) {
00732 mol = app->moleculeList->top()->id();
00733 }
00734 } else {
00735 if (Tcl_GetInt(interp, argv[1], &mol) != TCL_OK) {
00736 return TCL_ERROR;
00737 }
00738 }
00739
00740 return tcl_graphics(app, mol, argc-2, argv+2, interp);
00741 }
00742
00743