YsVisual.cpp

Go to the documentation of this file.
00001 // YsVisual.cpp: implementation
00002 //
00004 #include "YsVisual.h"
00005 #include <InelasticYS2DGNL.h>
00006 
00007 #ifdef _GLX
00008 #include <OpenGLRenderer.h>
00009 #endif
00010 #ifdef _X11
00011 #include <X11Renderer.h>
00012 #endif
00013 
00014 #include <Renderer.h>
00015 #include <PlainMap.h>
00016 
00018 // Construction/Destruction
00020 
00021 YsVisual::YsVisual(Element *theEle, const char *title, double scale,
00022                    int xLoc, int yLoc, int width, int height)
00023   :Recorder(RECORDER_TAGS_YsVisual),
00024    pView(0), theMap(0), displayMode(0)
00025 {
00026   const char *argv[1] = {"ysVisual"};
00027   Information eleInfo(1);
00028   Response *theResponse = 0;
00029   
00030   ysEle = theEle;
00031   
00032   theResponse = theEle->setResponse(argv, 1, eleInfo);
00033   
00034   if(theResponse)
00035     displayMode = theResponse->getResponse();
00036   else
00037     opserr << "YsVisual only works on elements derived from InelasticYS2DGNL\n";
00038   
00039 #ifdef _GLX
00040   theMap = new PlainMap();
00041   pView =  new OpenGLRenderer(title, xLoc, yLoc, width, height, *theMap);
00042 #endif
00043   
00044 #ifdef _X11
00045   if(!pView) //_GLX and _X11 both defined
00046     {
00047       theMap = new PlainMap();
00048       pView =  new X11Renderer(title, xLoc, yLoc, width, height, *theMap);
00049     }
00050 #endif  
00051   
00052   if(pView)
00053     {
00054       pView->setVRP(0.0, 0.0, 0.0);
00055       pView->setVPN(0.0, 0.0, 1.0);
00056       pView->setVUP(0.0, 1.0, 0.0);
00057       pView->setFillMode("wire");             // wire mode
00058       pView->setPlaneDist(1.0, -1.0);
00059       pView->setPRP(0.0, 0.0, 10.0);
00060       pView->setPortWindow(-1, 1, -1, 1);  // use the whole window
00061       
00062       pView->setViewWindow(-scale, scale, -scale, scale);
00063       
00064                 pView->clearImage();
00065                 pView->doneImage();
00066         }
00067         else
00068                 opserr << "WARNING: YsVisual::createView - Renderer not available\n";
00069 
00070 }
00071 
00072 YsVisual::~YsVisual()
00073 {
00074         if(theMap)
00075                 delete theMap;
00076         if(pView)
00077                 delete pView;
00078 }
00079 
00080 int  YsVisual::record(int cTag, double d)
00081 {
00082 int res = 0;
00083 
00084         if(pView)
00085         {
00086         pView->clearImage();
00087         pView->startImage();
00088         ysEle->displaySelf(*pView, displayMode, 1);
00089         pView->doneImage();
00090         }
00091         else 
00092                 res = -1;
00093 
00094         return res;
00095 }
00096 
00097 int YsVisual::playback(int cTag)
00098 {
00099   return 0;
00100 }
00101 
00102 int 
00103 YsVisual::restart(void)
00104 {
00105   return 0;
00106 }

Generated on Mon Oct 23 15:05:25 2006 for OpenSees by doxygen 1.5.0