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 argc -= 2;
00508 argv += 2;
00509
00510 if (argc %2) {
00511 Tcl_SetResult(interp, (char *) "graphics: text has wrong number of options", TCL_STATIC);
00512 return TCL_ERROR;
00513 }
00514
00515 while (argc) {
00516 if (!strcmp(argv[0], "size")) {
00517 if (Tcl_GetDouble(interp, argv[1], &size) != TCL_OK) {
00518 return TCL_ERROR;
00519 }
00520 if (size <0) size = 0;
00521 argc -= 2;
00522 argv += 2;
00523 continue;
00524 }
00525
00526 Tcl_AppendResult(interp, "graphics: unknown option for text: ",
00527 argv[0], NULL);
00528 return TCL_ERROR;
00529 }
00530
00531
00532 char tmpstring[64];
00533 sprintf(tmpstring, "%d", gmol->add_text(vals+0, string, (float) size));
00534 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00535 return TCL_OK;
00536 }
00537
00538
00540
00541 static int tcl_graphics_delete(MoleculeGraphics *gmol, int argc, const char *argv[],
00542 Tcl_Interp *interp) {
00543 if (argc != 1) {
00544 Tcl_SetResult(interp, (char *) "graphics: delete takes one parameter (either an index or 'all')", TCL_STATIC);
00545 return TCL_ERROR;
00546 }
00547 if (!strcmp(argv[0], "all")) {
00548 gmol->delete_all();
00549 return TCL_OK;
00550 }
00551 int id;
00552 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00553 return TCL_ERROR;
00554 }
00555 gmol->delete_id(id);
00556 return TCL_OK;
00557 }
00558
00559
00560 static int tcl_graphics_replace(MoleculeGraphics *gmol, int argc, const char *argv[],
00561 Tcl_Interp *interp) {
00562 if (argc != 1) {
00563 Tcl_SetResult(interp, (char *) "graphics: replace takes one parameter, the index", TCL_STATIC);
00564 return TCL_ERROR;
00565 }
00566 int id;
00567 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00568 return TCL_ERROR;
00569 }
00570 gmol->replace_id(id);
00571 return TCL_OK;
00572 }
00573
00574
00575 static int tcl_graphics_exists(MoleculeGraphics *gmol, int argc, const char *argv[],
00576 Tcl_Interp *interp) {
00577 if (argc != 1) {
00578 Tcl_SetResult(interp, (char *) "graphics: exists takes one parameter, the index", TCL_STATIC);
00579 return TCL_ERROR;
00580 }
00581 int id;
00582 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00583 return TCL_ERROR;
00584 }
00585
00586 char tmpstring[64];
00587 sprintf(tmpstring, "%d", gmol->index_id(id) != -1);
00588 Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
00589 return TCL_OK;
00590 }
00591
00592
00593 static int tcl_graphics_info(MoleculeGraphics *gmol,
00594 int argc, const char *argv[],
00595 Tcl_Interp *interp)
00596 {
00597 if (argc != 1) {
00598 Tcl_SetResult(interp, (char *) "graphics: info takes one parameter, the index", TCL_STATIC);
00599 return TCL_ERROR;
00600 }
00601 int id;
00602 if (Tcl_GetInt(interp, argv[0], &id) != TCL_OK) {
00603 return TCL_ERROR;
00604 }
00605
00606 Tcl_AppendResult(interp, gmol->info_id(id), NULL);
00607 return TCL_OK;
00608 }
00609
00610
00611
00612
00613 static int tcl_graphics(VMDApp *app, int molid, int argc, const char *argv[],
00614 Tcl_Interp *interp)
00615 {
00616
00617 Molecule *mol = app->moleculeList->mol_from_id(molid);
00618 if (mol == NULL) {
00619 Tcl_SetResult(interp, (char *) "graphics: invalid graphics molecule", TCL_STATIC);
00620 return TCL_ERROR;
00621 }
00622 if (argc < 1) {
00623 Tcl_SetResult(interp, (char *) "graphics: not enough parameters", TCL_STATIC);
00624 return TCL_ERROR;
00625 }
00626 MoleculeGraphics *gmol = mol->moleculeGraphics();
00627
00628 if (!strcmp(argv[0], "list")) {
00629 if (argc != 1) {
00630 Tcl_SetResult(interp, (char *) "graphics: list takes no parameters", TCL_STATIC);
00631 return TCL_ERROR;
00632 }
00633 int num = gmol->num_elements();
00634 for (int i=0; i<num; i++) {
00635 int id = gmol->element_id(i);
00636 if (id >=0) {
00637 char s[10];
00638 sprintf(s, "%d", id);
00639 Tcl_AppendElement(interp, s);
00640 }
00641 }
00642 return TCL_OK;
00643 }
00644
00645 if (argc < 2) {
00646 Tcl_SetResult(interp, (char *) "graphics: not enough parameters", TCL_STATIC);
00647 return TCL_ERROR;
00648 }
00649 if (!strcmp(argv[0], "triangle")) {
00650 return tcl_graphics_triangle(gmol, argc-1, argv+1, interp);
00651 }
00652 if (!strcmp(argv[0], "trinorm")) {
00653 return tcl_graphics_trinorm(gmol, argc-1, argv+1, interp);
00654 }
00655 if (!strcmp(argv[0], "tricolor")) {
00656 return tcl_graphics_tricolor(gmol, argc-1, argv+1, interp);
00657 }
00658 if (!strcmp(argv[0], "point")) {
00659 return tcl_graphics_point(gmol, argc-1, argv+1, interp);
00660 }
00661 if (!strcmp(argv[0], "pickpoint")) {
00662 return tcl_graphics_pickpoint(gmol, argc-1, argv+1, interp);
00663 }
00664 if (!strcmp(argv[0], "line")) {
00665 return tcl_graphics_line(gmol, argc-1, argv+1, interp);
00666 }
00667 if (!strcmp(argv[0], "cylinder")) {
00668 return tcl_graphics_cylinder(gmol, argc-1, argv+1, interp);
00669 }
00670 if (!strcmp(argv[0], "cone")) {
00671 return tcl_graphics_cone(gmol, argc-1, argv+1, interp);
00672 }
00673 if (!strcmp(argv[0], "sphere")) {
00674 return tcl_graphics_sphere(gmol, argc-1, argv+1, interp);
00675 }
00676 if (!strcmp(argv[0], "text")) {
00677 return tcl_graphics_text(gmol, argc-1, argv+1, interp);
00678 }
00679 if (!strcmp(argv[0], "materials")) {
00680 return tcl_graphics_materials(gmol, argc-1, argv+1, interp);
00681 }
00682 if (!strcmp(argv[0], "material")) {
00683 return tcl_graphics_material(gmol, argc-1, argv+1, interp,
00684 app->materialList);
00685 }
00686 if (!strcmp(argv[0], "color") || !strcmp(argv[1], "colour")) {
00687 return tcl_graphics_color(app, gmol, argc-1, argv+1, interp);
00688 }
00689 if (!strcmp(argv[0], "delete")) {
00690 return tcl_graphics_delete(gmol, argc-1, argv+1, interp);
00691 }
00692 if (!strcmp(argv[0], "exists")) {
00693 return tcl_graphics_exists(gmol, argc-1, argv+1, interp);
00694 }
00695 if (!strcmp(argv[0], "replace")) {
00696 return tcl_graphics_replace(gmol, argc-1, argv+1, interp);
00697 }
00698 if (!strcmp(argv[0], "info")) {
00699 return tcl_graphics_info(gmol, argc-1, argv+1, interp);
00700 }
00701 Tcl_AppendResult(interp, "graphics: don't understand the command: ",
00702 argv[0], NULL);
00703 return TCL_ERROR;
00704 }
00705
00706
00707
00708 int graphics_tcl(ClientData cd, Tcl_Interp *interp, int argc, const char *argv[]) {
00709
00710 if (argc < 2) {
00711 Tcl_SetResult(interp, (char *) "graphics: not enough parameters", TCL_STATIC);
00712 return TCL_ERROR;
00713 }
00714
00715 VMDApp *app = (VMDApp *)cd;
00716
00717 int mol = -1;
00718 if (!strcmp(argv[1], "top")) {
00719 if (app->moleculeList->top()) {
00720 mol = app->moleculeList->top()->id();
00721 }
00722 } else {
00723 if (Tcl_GetInt(interp, argv[1], &mol) != TCL_OK) {
00724 return TCL_ERROR;
00725 }
00726 }
00727
00728 return tcl_graphics(app, mol, argc-2, argv+2, interp);
00729 }
00730
00731