예제 #1
0
YsVisual::YsVisual(Element *theEle, const char *title, double scale,
                   int xLoc, int yLoc, int width, int height)
  :Recorder(RECORDER_TAGS_YsVisual),
   pView(0), theMap(0), displayMode(0)
{
  const char *argv[1] = {"ysVisual"};
  Information eleInfo(1);
  Response *theResponse = 0;
  
  ysEle = theEle;
  
  theResponse = theEle->setResponse(argv, 1, eleInfo);
  
  if(theResponse)
    displayMode = theResponse->getResponse();
  else
    opserr << "YsVisual only works on elements derived from InelasticYS2DGNL\n";
  
#ifdef _GLX
  theMap = new PlainMap();
  pView =  new OpenGLRenderer(title, xLoc, yLoc, width, height, *theMap);
#endif
  
#ifdef _X11
  if(!pView) //_GLX and _X11 both defined
    {
      theMap = new PlainMap();
      pView =  new X11Renderer(title, xLoc, yLoc, width, height, *theMap);
    }
#endif	
  
  if(pView)
    {
      pView->setVRP(0.0, 0.0, 0.0);
      pView->setVPN(0.0, 0.0, 1.0);
      pView->setVUP(0.0, 1.0, 0.0);
      pView->setFillMode("wire");             // wire mode
      pView->setPlaneDist(1.0, -1.0);
      pView->setPRP(0.0, 0.0, 10.0);
      pView->setPortWindow(-1, 1, -1, 1);  // use the whole window
      
      pView->setViewWindow(-scale, scale, -scale, scale);
      
		pView->clearImage();
		pView->doneImage();
	}
	else
		opserr << "WARNING: YsVisual::createView - Renderer not available\n";

}
예제 #2
0
파일: ElementRecorder.cpp 프로젝트: lcpt/xc
int XC::ElementRecorder::initialize(void)
  {
    const int numEle= eleID.Size();
    if(numEle == 0 || theDomain == 0)
      {
        if(!theDomain)
	  std::cerr << getClassName() << "::" << __FUNCTION__
	            << "; undefined domain." << std::endl;
        if(numEle == 0)
	  std::cerr << getClassName() << "::" << __FUNCTION__
	            << "; there is no elements." << std::endl;
        return -1;
      }

    // Set the response objects:
    //   1. create an array of pointers for them
    //   2. iterate over the elements invoking setResponse() to get the new objects & determine size of data
    //

    int numDbColumns = 0;
    if(echoTimeFlag == true) 
      numDbColumns = 1;  // 1 for the pseudo-time

    theResponses= std::vector<Response *>(numEle,static_cast<Response *>(nullptr));

    Information eleInfo(1.0);
    int i;
    for(i=0; i<numEle; i++)
      {
        Element *theEle = theDomain->getElement(eleID(i));
        if(theEle == 0)
          { theResponses[i]= 0; }
        else
          {
            theResponses[i] = theEle->setResponse(responseArgs, eleInfo);
            if(theResponses[i] != 0)
              {
	        // from the response type determine no of cols for each
	        Information &eleInfo = theResponses[i]->getInformation();
	        const Vector &eleData = eleInfo.getData();
	        numDbColumns += eleData.Size();
              }
          }
      }

    //
    // now create the columns strings for the data description
    // for each element do a getResponse() 
    //
    std::vector<std::string> dbColumns(numDbColumns);
    static std::string aColumn;

    int counter = 0;
    if(echoTimeFlag == true)
      {
        dbColumns[0] = "time";
        counter = 1;
      }
    
    std::string dataToStore= "";
    const size_t numArgs= getNumArgs();
    for(size_t j=0; j<numArgs; j++)
      {
        dataToStore+= responseArgs[j];
        if(j<(numArgs-1))
          dataToStore+= " ";
      }
    
    for(i=0; i<eleID.Size(); i++)
      {
        int eleTag = eleID(i);
        int numVariables = 0;
        if(theResponses[i]!=nullptr)
          {
            const XC::Information &eleInfo = theResponses[i]->getInformation();
            if(eleInfo.theType == IntType || eleInfo.theType == DoubleType)
              {
	      // create column heading for single data item for element
	      numVariables = 0;
	      //sprintf(aColumn, "Element%d_%s", eleTag, dataToStore);
                aColumn= "Element" + boost::lexical_cast<std::string>(eleTag) + "_" 
		+ dataToStore;
                dbColumns[counter] = aColumn;
	      counter++;
              }
            else if(eleInfo.theType == VectorType) 
	    numVariables = eleInfo.theVector->Size();
            else if(eleInfo.theType == IdType) 
	    numVariables = eleInfo.theID->Size();
            else if(eleInfo.theType == MatrixType) 
	    numVariables = eleInfo.theMatrix->noRows()* eleInfo.theMatrix->noCols();

            // create the column headings for multiple data for the element
            for(int j=1; j<=numVariables; j++)
              {
	      //sprintf(aColumn, "Element%d_%s_%d",eleTag, dataToStore, j);
                aColumn= "Element" + boost::lexical_cast<std::string>(eleTag) + "_" 
		                 + dataToStore + "_"
                                   + boost::lexical_cast<std::string>(j);
                dbColumns[counter] = aColumn;
	      counter++;
              }
          }
      }

    // replace spaces with undescore for tables
    for(int kk=0; kk<numDbColumns; kk++)
      replace(dbColumns[kk],' ','_');

    //
    // call open in the handler with the data description
    //

    theHandler->open(dbColumns);

    // create the vector to hold the data
    data= Vector(numDbColumns);

    initializationDone = true;
    return 0;
  }