00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <stdlib.h>
00035 #include <string.h>
00036
00037 #include <Domain.h>
00038 #include <Element.h>
00039 #include <ElementIter.h>
00040 #include <Node.h>
00041 #include <NodeIter.h>
00042
00043 #ifdef _WGL
00044 #include <OpenGLRenderer.h>
00045 #elif _GLX
00046 #include <OpenGLRenderer.h>
00047 #else
00048 #include <X11Renderer.h>
00049 #endif
00050
00051 #include <PlainMap.h>
00052
00053 #include "TclFeViewer.h"
00054
00055
00056
00057
00058
00059 static TclFeViewer *theTclFeViewer = 0;
00060
00061
00062
00063
00064
00065 int
00066 TclFeViewer_setVRP(ClientData clientData, Tcl_Interp *interp, int argc,
00067 TCL_Char **argv);
00068 int
00069 TclFeViewer_setVPN(ClientData clientData, Tcl_Interp *interp, int argc,
00070 TCL_Char **argv);
00071 int
00072 TclFeViewer_setVUP(ClientData clientData, Tcl_Interp *interp, int argc,
00073 TCL_Char **argv);
00074 int
00075 TclFeViewer_setViewWindow(ClientData clientData, Tcl_Interp *interp, int argc,
00076 TCL_Char **argv);
00077 int
00078 TclFeViewer_setPlaneDist(ClientData clientData, Tcl_Interp *interp, int argc,
00079 TCL_Char **argv);
00080 int
00081 TclFeViewer_setProjectionMode(ClientData clientData, Tcl_Interp *interp, int argc,
00082 TCL_Char **argv);
00083 int
00084 TclFeViewer_setFillMode(ClientData clientData, Tcl_Interp *interp, int argc,
00085 TCL_Char **argv);
00086 int
00087 TclFeViewer_setPRP(ClientData clientData, Tcl_Interp *interp, int argc,
00088 TCL_Char **argv);
00089 int
00090 TclFeViewer_setPortWindow(ClientData clientData, Tcl_Interp *interp, int argc,
00091 TCL_Char **argv);
00092 int
00093 TclFeViewer_displayModel(ClientData clientData, Tcl_Interp *interp, int argc,
00094 TCL_Char **argv);
00095 int
00096 TclFeViewer_saveImage(ClientData clientData, Tcl_Interp *interp, int argc,
00097 TCL_Char **argv);
00098 int
00099 TclFeViewer_clearImage(ClientData clientData, Tcl_Interp *interp, int argc,
00100 TCL_Char **argv);
00101
00102
00103
00104
00105 TclFeViewer::TclFeViewer(const char *title, int xLoc, int yLoc, int width, int height,
00106 Domain &_theDomain, int WipeFlag,
00107 Tcl_Interp *interp)
00108 :Recorder(RECORDER_TAGS_TclFeViewer),
00109 theMap(0),theRenderer(0), theDomain(&_theDomain),
00110 theEleMode(-1), theNodeMode(-1), theDisplayFact(1), wipeFlag(WipeFlag),
00111 vrpSet(0),vpwindowSet(0),clippingPlaneDistancesSet(0)
00112 {
00113
00114
00115 theTclFeViewer = this;
00116 theMap = new PlainMap();
00117
00118 #ifdef _WGL
00119 theRenderer = new OpenGLRenderer(title, xLoc, yLoc, width, height, *theMap);
00120 #elif _GLX
00121 theRenderer = new OpenGLRenderer(title, xLoc, yLoc, width, height, *theMap);
00122 #else
00123 theRenderer = new X11Renderer(title, xLoc, yLoc, width, height, *theMap);
00124 #endif
00125
00126
00127
00128 Tcl_CreateCommand(interp, "vrp", TclFeViewer_setVRP,
00129 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00130
00131 Tcl_CreateCommand(interp, "vpn", TclFeViewer_setVPN,
00132 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00133
00134 Tcl_CreateCommand(interp, "vup", TclFeViewer_setVUP,
00135 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00136
00137 Tcl_CreateCommand(interp, "viewWindow", TclFeViewer_setViewWindow,
00138 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00139
00140 Tcl_CreateCommand(interp, "plane", TclFeViewer_setPlaneDist,
00141 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00142
00143 Tcl_CreateCommand(interp, "projection", TclFeViewer_setProjectionMode,
00144 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00145
00146 Tcl_CreateCommand(interp, "fill", TclFeViewer_setFillMode,
00147 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00148
00149 Tcl_CreateCommand(interp, "prp", TclFeViewer_setPRP,
00150 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00151
00152 Tcl_CreateCommand(interp, "port", TclFeViewer_setPortWindow,
00153 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00154
00155 Tcl_CreateCommand(interp, "display", TclFeViewer_displayModel,
00156 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00157
00158 Tcl_CreateCommand(interp, "clearImage", TclFeViewer_clearImage,
00159 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00160
00161 Tcl_CreateCommand(interp, "saveImage", TclFeViewer_saveImage,
00162 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00163 }
00164
00165
00166
00167 TclFeViewer::TclFeViewer(const char *title, int xLoc, int yLoc, int width, int height,
00168 const char *fileName,
00169 Domain &_theDomain,
00170 Tcl_Interp *interp)
00171 :Recorder(RECORDER_TAGS_TclFeViewer),
00172 theMap(0),theRenderer(0), theDomain(&_theDomain),
00173 theEleMode(-1), theNodeMode(-1), theDisplayFact(1), wipeFlag(1),
00174 vrpSet(0),vpwindowSet(0),clippingPlaneDistancesSet(0)
00175 {
00176
00177
00178 theTclFeViewer = this;
00179 theMap = new PlainMap();
00180 #ifdef _WGL
00181 theRenderer = new OpenGLRenderer(title, xLoc, yLoc, width, height, *theMap, 0, fileName);
00182 #elif _GLX
00183 theRenderer = new OpenGLRenderer(title, xLoc, yLoc, width, height, *theMap, fileName, 0);
00184 #else
00185 theRenderer = new X11Renderer(title, xLoc, yLoc, width, height, *theMap, fileName);
00186 #endif
00187
00188 Tcl_CreateCommand(interp, "vrp", TclFeViewer_setVRP,
00189 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00190
00191 Tcl_CreateCommand(interp, "vpn", TclFeViewer_setVPN,
00192 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00193
00194 Tcl_CreateCommand(interp, "vup", TclFeViewer_setVUP,
00195 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00196
00197 Tcl_CreateCommand(interp, "viewWindow", TclFeViewer_setViewWindow,
00198 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00199
00200 Tcl_CreateCommand(interp, "plane", TclFeViewer_setPlaneDist,
00201 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00202
00203 Tcl_CreateCommand(interp, "projection", TclFeViewer_setProjectionMode,
00204 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00205
00206 Tcl_CreateCommand(interp, "fill", TclFeViewer_setFillMode,
00207 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00208
00209 Tcl_CreateCommand(interp, "prp", TclFeViewer_setPRP,
00210 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00211
00212 Tcl_CreateCommand(interp, "port", TclFeViewer_setPortWindow,
00213 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00214
00215 Tcl_CreateCommand(interp, "display", TclFeViewer_displayModel,
00216 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00217
00218 Tcl_CreateCommand(interp, "clearImage", TclFeViewer_clearImage,
00219 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00220
00221 Tcl_CreateCommand(interp, "saveImage", TclFeViewer_saveImage,
00222 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00223 }
00224
00225 TclFeViewer::~TclFeViewer()
00226 {
00227
00228
00229
00230 delete theMap;
00231 delete theRenderer;
00232 theTclFeViewer = 0;
00233 }
00234
00235 int
00236 TclFeViewer::record(int cTag, double timeStamp)
00237 {
00238
00239
00240
00241
00242
00243
00244 if (wipeFlag == 1)
00245 theRenderer->clearImage();
00246
00247
00248 if (vrpSet == 0 || vpwindowSet == 0 || clippingPlaneDistancesSet == 0) {
00249 const Vector &theBounds = theDomain->getPhysicalBounds();
00250 double xAvg = (theBounds(0) + theBounds(3))/2.0;
00251 double yAvg = (theBounds(1) + theBounds(4))/2.0;
00252 double zAvg = (theBounds(2) + theBounds(5))/2.0;
00253
00254 if (vrpSet == 0)
00255 this->setVRP(xAvg, yAvg, zAvg);
00256
00257 double diff, xDiff, yDiff, zDiff;
00258 xDiff = (theBounds(3) - theBounds(0));
00259 yDiff = (theBounds(4) - theBounds(1));
00260 zDiff = (theBounds(5) - theBounds(2));
00261 diff = xDiff;
00262 if (yDiff > diff)
00263 diff = yDiff;
00264 if (zDiff > diff)
00265 diff = zDiff;
00266
00267 diff *= 1.25 * 0.5;
00268
00269 if (vpwindowSet == 0)
00270 this->setViewWindow(-diff,diff,-diff,diff);
00271
00272 if (clippingPlaneDistancesSet == 0) {
00273 diff = sqrt(xDiff*xDiff + yDiff*yDiff + zDiff * zDiff);
00274 this->setPlaneDist(diff,-diff);
00275 }
00276 }
00277
00278 theRenderer->startImage();
00279 int res = 0;
00280
00281 if (theEleMode != 0) {
00282 ElementIter &theElements = theDomain->getElements();
00283 Element *theEle;
00284 while ((theEle = theElements()) != 0) {
00285 res = theEle->displaySelf(*theRenderer, theEleMode, theDisplayFact);
00286 if (res < 0) {
00287 opserr << "Renderer::displayModel() - Element: \n";
00288 opserr << theEle->getTag() << " failed to display itself\n";
00289 }
00290 }
00291 }
00292
00293 if (theNodeMode != 0) {
00294 NodeIter &theNodes = theDomain->getNodes();
00295 Node *theNode;
00296 while ((theNode = theNodes()) != 0) {
00297 res = theNode->displaySelf(*theRenderer, theNodeMode, theDisplayFact);
00298 if (res < 0) {
00299 opserr << "Renderer::displayModel() - Node: ";
00300 opserr << theNode->getTag() << " failed to display itself\n";
00301 }
00302 }
00303 }
00304
00305
00306 theRenderer->doneImage();
00307
00308 return res;
00309 }
00310
00311 int
00312 TclFeViewer::playback(int cTag)
00313 {
00314 return 0;
00315 }
00316
00317 int
00318 TclFeViewer::restart(void)
00319 {
00320 return 0;
00321 }
00322
00323
00324 int
00325 TclFeViewer::setVRP(float xLoc, float yLoc , float zLoc)
00326 {
00327 int ok = theRenderer->setVRP(xLoc, yLoc, zLoc);
00328 if (ok == 0)
00329 vrpSet = 1;
00330
00331 return ok;
00332
00333 }
00334
00335 int
00336 TclFeViewer::setVPN(float xdirn, float ydirn, float zdirn)
00337 {
00338
00339 return theRenderer->setVPN(xdirn, ydirn, zdirn);
00340 }
00341
00342 int
00343 TclFeViewer::setVUP(float xdirn, float ydirn, float zdirn)
00344 {
00345 return theRenderer->setVUP(xdirn, ydirn, zdirn);
00346 }
00347
00348 int
00349 TclFeViewer::setViewWindow(float uMin, float uMax, float vMin, float vMax)
00350 {
00351 int ok = theRenderer->setViewWindow(uMin, uMax, vMin, vMax);
00352 if (ok == 0)
00353 vpwindowSet = 1;
00354
00355 return ok;
00356 }
00357
00358 int
00359 TclFeViewer::setPlaneDist(float anear, float afar)
00360 {
00361 int ok = theRenderer->setPlaneDist(anear,afar);
00362 if (ok == 0)
00363 clippingPlaneDistancesSet = 1;
00364 return ok;
00365 }
00366
00367 int
00368 TclFeViewer::setProjectionMode(const char *mode)
00369 {
00370 return theRenderer->setProjectionMode(mode);
00371 }
00372
00373 int
00374 TclFeViewer::setFillMode(const char *mode)
00375 {
00376 return theRenderer->setFillMode(mode);
00377 }
00378
00379 int
00380 TclFeViewer::setPRP(float uLoc, float vLoc , float nLoc)
00381 {
00382 return theRenderer->setPRP(uLoc, vLoc, nLoc);
00383 }
00384
00385
00386 int
00387 TclFeViewer::setPortWindow(float left, float right, float bottom, float top)
00388 {
00389 return theRenderer->setPortWindow(left,right,bottom,top);
00390 }
00391
00392 int
00393 TclFeViewer::displayModel(int eleFlag, int nodeFlag, float displayFact)
00394 {
00395
00396 theEleMode = eleFlag;
00397 theNodeMode = nodeFlag;
00398 theDisplayFact = displayFact;
00399 return this->record(0, 0.0);
00400 }
00401
00402 int
00403 TclFeViewer::clearImage(void)
00404 {
00405 return theRenderer->clearImage();
00406 }
00407
00408 int
00409 TclFeViewer::saveImage(const char *fileName)
00410 {
00411 return theRenderer->saveImage(fileName);
00412 }
00413
00414 int
00415 TclFeViewer::saveImage(const char *imageName, const char *fileName)
00416 {
00417 return theRenderer->saveImage(imageName, fileName);
00418 }
00419
00420
00421
00422
00423 int
00424 TclFeViewer_setVRP(ClientData clientData, Tcl_Interp *interp, int argc,
00425 TCL_Char **argv)
00426 {
00427
00428 if (theTclFeViewer == 0)
00429 return TCL_OK;
00430
00431
00432 if (argc < 4) {
00433 opserr << "WARNING args incorrect - vrp xloc yloc zloc \n";
00434 return TCL_ERROR;
00435 }
00436
00437
00438 double xLoc, yLoc, zLoc;
00439 if (Tcl_GetDouble(interp, argv[1], &xLoc) != TCL_OK) {
00440 opserr << "WARNING invalid x_loc - vrp x_loc y_loc z_loc\n";
00441 return TCL_ERROR;
00442 }
00443 if (Tcl_GetDouble(interp, argv[2], &yLoc) != TCL_OK) {
00444 opserr << "WARNING invalid y_loc - vrp x_loc y_loc z_loc\n";
00445 return TCL_ERROR;
00446 }
00447 if (Tcl_GetDouble(interp, argv[3], &zLoc) != TCL_OK) {
00448 opserr << "WARNING invalid z_loc - vrp x_loc y_loc z_loc\n";
00449 return TCL_ERROR;
00450 }
00451
00452 theTclFeViewer->setVRP(xLoc,yLoc,zLoc);
00453 return TCL_OK;
00454 }
00455
00456 int
00457 TclFeViewer_setVPN(ClientData clientData, Tcl_Interp *interp, int argc,
00458 TCL_Char **argv)
00459 {
00460
00461 if (theTclFeViewer == 0)
00462 return TCL_OK;
00463
00464
00465 if (argc < 4) {
00466 opserr << "WARNING args incorrect - vpn xdirn ydirn zdirn \n";
00467 return TCL_ERROR;
00468 }
00469
00470
00471 double xDirn, yDirn, zDirn;
00472 if (Tcl_GetDouble(interp, argv[1], &xDirn) != TCL_OK) {
00473 opserr << "WARNING invalid x_dirn - vpn x_dirn y_dirn z_dirn\n";
00474 return TCL_ERROR;
00475 }
00476 if (Tcl_GetDouble(interp, argv[2], &yDirn) != TCL_OK) {
00477 opserr << "WARNING invalid y_dirn - vpn x_dirn y_dirn z_dirn\n";
00478 return TCL_ERROR;
00479 }
00480 if (Tcl_GetDouble(interp, argv[3], &zDirn) != TCL_OK) {
00481 opserr << "WARNING invalid z_dirn - vpn x_dirn y_dirn z_dirn\n";
00482 return TCL_ERROR;
00483 }
00484
00485 theTclFeViewer->setVPN(xDirn,yDirn,zDirn);
00486 return 0;
00487 }
00488
00489 int
00490 TclFeViewer_setVUP(ClientData clientData, Tcl_Interp *interp, int argc,
00491 TCL_Char **argv)
00492 {
00493
00494 if (theTclFeViewer == 0)
00495 return TCL_OK;
00496
00497
00498 if (argc < 4) {
00499 opserr << "WARNING args incorrect - vup xdirn ydirn zdirn \n";
00500 return TCL_ERROR;
00501 }
00502
00503
00504 double xDirn, yDirn, zDirn;
00505 if (Tcl_GetDouble(interp, argv[1], &xDirn) != TCL_OK) {
00506 opserr << "WARNING invalid x_dirn - vup x_dirn y_dirn z_dirn\n";
00507 return TCL_ERROR;
00508 }
00509 if (Tcl_GetDouble(interp, argv[2], &yDirn) != TCL_OK) {
00510 opserr << "WARNING invalid y_dirn - vup x_dirn y_dirn z_dirn\n";
00511 return TCL_ERROR;
00512 }
00513 if (Tcl_GetDouble(interp, argv[3], &zDirn) != TCL_OK) {
00514 opserr << "WARNING invalid z_dirn - vup x_dirn y_dirn z_dirn\n";
00515 return TCL_ERROR;
00516 }
00517
00518 theTclFeViewer->setVUP(xDirn,yDirn,zDirn);
00519 return TCL_OK;
00520 }
00521
00522 int
00523 TclFeViewer_setViewWindow(ClientData clientData, Tcl_Interp *interp, int argc,
00524 TCL_Char **argv)
00525 {
00526
00527 if (theTclFeViewer == 0)
00528 return TCL_OK;
00529
00530
00531 if (argc < 5) {
00532 opserr << "WARNING args incorrect - prp uMin uMax vMin vMax \n";
00533 return TCL_ERROR;
00534 }
00535
00536 double uMin, uMax, vMin, vMax;
00537 if (Tcl_GetDouble(interp, argv[1], &uMin) != TCL_OK) {
00538 opserr << "WARNING invalid uMin - vup uMin uMax vMin vMax\n";
00539 return TCL_ERROR;
00540 }
00541 if (Tcl_GetDouble(interp, argv[2], &uMax) != TCL_OK) {
00542 opserr << "WARNING invalid uMax - vup uMin uMax vMin vMax\n";
00543 return TCL_ERROR;
00544 }
00545 if (Tcl_GetDouble(interp, argv[3], &vMin) != TCL_OK) {
00546 opserr << "WARNING invalid vMin - vup uMin uMax vMin vMax\n";
00547 return TCL_ERROR;
00548 }
00549 if (Tcl_GetDouble(interp, argv[4], &vMax) != TCL_OK) {
00550 opserr << "WARNING invalid vMin - vup uMin uMax vMin vMax\n";
00551 return TCL_ERROR;
00552 }
00553
00554 theTclFeViewer->setViewWindow(uMin,uMax,vMin,vMax);
00555 return TCL_OK;
00556 }
00557 int
00558 TclFeViewer_setPlaneDist(ClientData clientData, Tcl_Interp *interp, int argc,
00559 TCL_Char **argv)
00560 {
00561
00562 if (theTclFeViewer == 0)
00563 return TCL_OK;
00564
00565
00566 if (argc < 3) {
00567 opserr << "WARNING args incorrect - dist near far \n";
00568 return TCL_ERROR;
00569 }
00570
00571 double anear, afar;
00572 if (Tcl_GetDouble(interp, argv[1], &anear) != TCL_OK) {
00573 opserr << "WARNING invalid near - vup near far\n";
00574 return TCL_ERROR;
00575 }
00576 if (Tcl_GetDouble(interp, argv[2], &afar) != TCL_OK) {
00577 opserr << "WARNING invalid far - vup near far\n";
00578 return TCL_ERROR;
00579 }
00580
00581 theTclFeViewer->setPlaneDist(anear, afar);
00582 return TCL_OK;
00583 }
00584
00585 int
00586 TclFeViewer_setProjectionMode(ClientData clientData, Tcl_Interp *interp, int argc,
00587 TCL_Char **argv)
00588 {
00589
00590 if (theTclFeViewer == 0)
00591 return TCL_OK;
00592
00593
00594 if (argc < 2) {
00595 opserr << "WARNING args incorrect - projection modeID \n";
00596 return TCL_ERROR;
00597 }
00598
00599
00600 theTclFeViewer->setProjectionMode(argv[1]);
00601 return TCL_OK;
00602 }
00603
00604 int
00605 TclFeViewer_setFillMode(ClientData clientData, Tcl_Interp *interp, int argc,
00606 TCL_Char **argv)
00607 {
00608
00609 if (theTclFeViewer == 0)
00610 return TCL_OK;
00611
00612
00613 if (argc < 2) {
00614 opserr << "WARNING args incorrect - fill modeID \n";
00615 return TCL_ERROR;
00616 }
00617
00618
00619 theTclFeViewer->setFillMode(argv[1]);
00620 return TCL_OK;
00621 }
00622
00623 int
00624 TclFeViewer_setPRP(ClientData clientData, Tcl_Interp *interp, int argc,
00625 TCL_Char **argv)
00626 {
00627
00628 if (theTclFeViewer == 0)
00629 return TCL_OK;
00630
00631
00632 if (argc < 4) {
00633 opserr << "WARNING args incorrect - cop xloc yloc zloc \n";
00634 return TCL_ERROR;
00635 }
00636
00637
00638 double xLoc, yLoc, zLoc;
00639 if (Tcl_GetDouble(interp, argv[1], &xLoc) != TCL_OK) {
00640 opserr << "WARNING invalid x_loc - cop x_loc y_loc z_loc\n";
00641 return TCL_ERROR;
00642 }
00643 if (Tcl_GetDouble(interp, argv[2], &yLoc) != TCL_OK) {
00644 opserr << "WARNING invalid y_loc - cop x_loc y_loc z_loc\n";
00645 return TCL_ERROR;
00646 }
00647 if (Tcl_GetDouble(interp, argv[3], &zLoc) != TCL_OK) {
00648 opserr << "WARNING invalid z_loc - cop x_loc y_loc z_loc\n";
00649 return TCL_ERROR;
00650 }
00651
00652 theTclFeViewer->setPRP(xLoc,yLoc,zLoc);
00653 return TCL_OK;
00654 }
00655
00656 int
00657 TclFeViewer_setPortWindow(ClientData clientData, Tcl_Interp *interp, int argc,
00658 TCL_Char **argv)
00659 {
00660
00661 if (theTclFeViewer == 0)
00662 return TCL_OK;
00663
00664
00665 if (argc < 5) {
00666 opserr << "WARNING args incorrect - prp uMin uMax vMin vMax \n";
00667 return TCL_ERROR;
00668 }
00669
00670 double uMin, uMax, vMin, vMax;
00671 if (Tcl_GetDouble(interp, argv[1], &uMin) != TCL_OK) {
00672 opserr << "WARNING invalid uMin - vup uMin uMax vMin vMax\n";
00673 return TCL_ERROR;
00674 }
00675 if (Tcl_GetDouble(interp, argv[2], &uMax) != TCL_OK) {
00676 opserr << "WARNING invalid uMax - vup uMin uMax vMin vMax\n";
00677 return TCL_ERROR;
00678 }
00679 if (Tcl_GetDouble(interp, argv[3], &vMin) != TCL_OK) {
00680 opserr << "WARNING invalid vMin - vup uMin uMax vMin vMax\n";
00681 return TCL_ERROR;
00682 }
00683 if (Tcl_GetDouble(interp, argv[4], &vMax) != TCL_OK) {
00684 opserr << "WARNING invalid vMin - vup uMin uMax vMin vMax\n";
00685 return TCL_ERROR;
00686 }
00687
00688 theTclFeViewer->setPortWindow(uMin,uMax,vMin,vMax);
00689 return TCL_OK;
00690 }
00691
00692 int
00693 TclFeViewer_displayModel(ClientData clientData, Tcl_Interp *interp, int argc,
00694 TCL_Char **argv)
00695 {
00696
00697 if (theTclFeViewer == 0)
00698 return TCL_OK;
00699
00700
00701 if (argc != 3 && argc != 4) {
00702 opserr << "WARNING args incorrect - display eleMode <nodeMode> fact\n";
00703 return TCL_ERROR;
00704 }
00705
00706 if (argc == 3) {
00707 int displayMode;
00708 double displayFact;
00709 if (Tcl_GetInt(interp, argv[1], &displayMode) != TCL_OK) {
00710 opserr << "WARNING invalid displayMode - display displayMode displayFact\n";
00711 return TCL_ERROR;
00712 }
00713 if (Tcl_GetDouble(interp, argv[2], &displayFact) != TCL_OK) {
00714 opserr << "WARNING invalid displayFact - display displayMode displayFact\n";
00715 return TCL_ERROR;
00716 }
00717
00718 theTclFeViewer->displayModel(displayMode, -1, displayFact);
00719 return TCL_OK;
00720 } else {
00721
00722 int eleFlag, nodeFlag;
00723 double displayFact;
00724 if (Tcl_GetInt(interp, argv[1], &eleFlag) != TCL_OK) {
00725 opserr << "WARNING invalid displayMode - display eleFlag nodeFlag displayFact\n";
00726 return TCL_ERROR;
00727 }
00728 if (Tcl_GetInt(interp, argv[2], &nodeFlag) != TCL_OK) {
00729 opserr << "WARNING invalid displayMode - display eleFlag nodeFlahg displayFact\n";
00730 return TCL_ERROR;
00731 }
00732 if (Tcl_GetDouble(interp, argv[3], &displayFact) != TCL_OK) {
00733 opserr << "WARNING invalid displayMode - display eleFlag nodeFlahg displayFact\n";
00734 return TCL_ERROR;
00735 }
00736
00737 theTclFeViewer->displayModel(eleFlag, nodeFlag, displayFact);
00738 return TCL_OK;
00739 }
00740 }
00741
00742
00743
00744 int
00745 TclFeViewer_clearImage(ClientData clientData, Tcl_Interp *interp, int argc,
00746 TCL_Char **argv)
00747 {
00748
00749 if (theTclFeViewer == 0)
00750 return TCL_OK;
00751
00752 theTclFeViewer->clearImage();
00753 return TCL_OK;
00754 }
00755
00756 int
00757 TclFeViewer_saveImage(ClientData clientData, Tcl_Interp *interp, int argc,
00758 TCL_Char **argv)
00759 {
00760
00761 if (theTclFeViewer == 0)
00762 return TCL_OK;
00763
00764
00765 if (argc != 3 && argc != 5) {
00766 opserr << "WARNING args incorrect - saveImage -image imageName? -file fileName?\n";
00767 return TCL_ERROR;
00768 }
00769
00770 int loc = 1;
00771 const char *imageName =0;
00772 const char *fileName =0;
00773 while (loc < argc) {
00774 if (strcmp(argv[loc], "-image") == 0)
00775 imageName = argv[loc+1];
00776 else if (strcmp(argv[loc], "-file") == 0)
00777 fileName = argv[loc+1];
00778 else {
00779 opserr << "WARNING invalid option: " << argv[loc] << " - saveImage -image imageName? -file fileName?\n";
00780 return TCL_ERROR;
00781 }
00782 loc+= 2;
00783 }
00784
00785 if (imageName == 0 && fileName != 0)
00786 theTclFeViewer->saveImage(fileName);
00787 else if (imageName != 0 && fileName != 0)
00788 theTclFeViewer->saveImage(imageName, fileName);
00789 else {
00790 opserr << "WARNING saveImage - need a fileName\n";
00791 return TCL_ERROR;
00792 }
00793
00794 return TCL_OK;
00795 }
00796
00797
00798
00799