예제 #1
0
// put out flagged header entries: event ID, timestamps, comment prefix ...
int AMAcqScanOutput::startRecord( acqKey_t key, int eventno)
{
	AMAcqScanOutput *to = (AMAcqScanOutput *)key;
	acqOutputEvent_t *event;
	struct timeval curTime;

	const char *prefix = "";


	to->dataDelayList_.clear();
	to->dataDelay_ = true;

	// flag that some output is occuring
	to->outputState = TOH_HAS_CONTENT;
	event = to->find_event_number(eventno);
	if( event == NULL || ! to->isReady() )
		return -1;
	eventPrivate *evpr;
	evpr = (eventPrivate *)event->private_data;
	if( evpr == NULL)
		return 0;

	gettimeofday( &curTime, 0);

	if( evpr->commentPrefix)
	{
		to->sendOutputLine( "# ");
	}
	if( evpr->putEventID)
	{
		to->sendOutputLine( "%s%d", prefix, eventno);
		prefix = to->delimiter.c_str();
	}
	if( evpr->timeStamp)
	{
		to->sendOutputLine( "%s%.6f", prefix, doubleTime(curTime));
		prefix = to->delimiter.c_str();
	}
	if( evpr->rel0TimeStamp)
	{
		to->sendOutputLine( "%s%.6f", prefix, timeDiff(curTime, evpr->startTime) );
		prefix = to->delimiter.c_str();
	}
	if( evpr->relTimeStamp)
	{
		to->sendOutputLine( "%s%.6f", prefix, timeDiff(curTime, evpr->prevTime) );
		prefix = to->delimiter.c_str();
	}
	evpr->prevTime = curTime;
	if( *prefix)
		to->needDelimiter = TRUE;
	return 1;
}
void RemoteBombShot::draw() {
   // Don't draw the bomb again if it already exploded.
   if (isExploded) {
      return;
   }

   glPushMatrix();
      // This is not very efficient.
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glDisable(GL_LIGHTING);
      position->glTranslate();
      
      double amountDone = (doubleTime() - timeFired) / timeToExplode;
      
      double animationPoint = fmod(pow(10, 0.4 + amountDone), 2);
      pulseSize = (sin(animationPoint * M_PI) * 0.25) + 0.5 ;

      if (animationPoint < 1) {
         glColor3d(0.4, 0.4, 0.8);
      } else {
         glColor3d(1.0, 1.0, 0.4);
      }
      
      gluSphere(quadric, pulseSize, 10, 10);
      glColor4d(0.4, 0.8, 1, 1);
      gluSphere(quadric, .3, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, .4, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, .5, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, .6, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, .7, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, .8, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, .9, 10, 10);
      glColor4d(0.4, 0.8, 0.4, .1);
      gluSphere(quadric, 1, 10, 10);
      
      // Radius 0.5, 5 slices, 5 stacks.
      
      glEnable(GL_LIGHTING);
   glPopMatrix();
}
void RemoteBombShot::update(double timeDiff) {
   ExplosiveShot::update(timeDiff);

   /* If the bomb has already blown up and we're back here again,
    * then we've already gone through a cycle of hit detection, so it's time
    * for the bomb to be removed.
    */
   if (isExploded) {
      shouldRemove = true;
   }

   // If the bomb should explode this frame and has not already, then explode.
   if (shouldExplode && !isExploded) {
      explode();
   }
   // If more time has passed than the bomb's timeToExplode, blow it up.
   if (!isExploded && (doubleTime() - timeFired > timeToExplode)) {
      explode();
   }
}
TimelineWidget::TimelineWidget(QWidget* parent) :
    QWidget(parent),
    m_timelineView(NULL),
    m_timeRate(1.0),
    m_paused(true)
{
    m_timelineView = new TimelineView(this);
    connect(m_timelineView, SIGNAL(currentTimeChanged(double)), this, SIGNAL(currentTimeChanged(double)));
    
    QWidget* controls = new QWidget(this);
    controls->setContentsMargins(0, 0, 0, 0);
    QHBoxLayout* controlsLayout = new QHBoxLayout(controls);
    
    QLabel* zoomLabel = new QLabel(controls);
    zoomLabel->setText("Zoom: "
                       "<a href=\"0.04167\">1h</a> "
                       "<a href=\"0.08333\">6h</a> "
                       "<a href=\"0.5\">12h</a> "
                       "<a href=\"1\">1d</a> "
                       "<a href=\"5\">5d</a> "
                       "<a href=\"10\">10d</a> "
                       "<a href=\"30\">1m</a> "
                       "<a href=\"180\">6m</a> "
                       "<a href=\"365\">1y</a> "
                       "<a href=\"all\">all</a>");

    QToolBar* toolbar = new QToolBar(controls);
    toolbar->setIconSize(QSize(24, 24));
    toolbar->setMaximumHeight(24);
    toolbar->setMovable(false);
    toolbar->setFloatable(false);
    toolbar->setContentsMargins(0, 0, 0, 0);
    
    QAction* reverseTimeAction = new QAction(QIcon(":/icons/timeline-reverse.png"),
                                             tr("Reverse time"), toolbar);
    QAction* slowTimeAction = new QAction(QIcon(":/icons/timeline-slower.png"),
                                          tr("10x slower"), toolbar);
    QAction* halfTimeAction = new QAction(QIcon(":/icons/timeline-half.png"),
                                          tr("2x slower"), toolbar);
    QAction* pauseAction = new QAction(QIcon(":/icons/timeline-pause.png"),
                                       tr("Pause time"), toolbar);
    QAction* realTimeAction = new QAction(QIcon(":/icons/timeline-realtime.png"),
                                          tr("Real time"), toolbar);
    QAction* doubleTimeAction = new QAction(QIcon(":/icons/timeline-double.png"),
                                            tr("2x faster"), toolbar);
    QAction* fastTimeAction = new QAction(QIcon(":/icons/timeline-faster.png"),
                                          tr("10x faster"), toolbar);
    
    connect(reverseTimeAction, SIGNAL(triggered()), this, SLOT(reverseTime()));
    toolbar->addAction(reverseTimeAction);
    
    connect(slowTimeAction, SIGNAL(triggered()), this, SLOT(slowerTime()));
    toolbar->addAction(slowTimeAction);
    
    connect(halfTimeAction, SIGNAL(triggered()), this, SLOT(halfTime()));
    toolbar->addAction(halfTimeAction);
    
    connect(pauseAction, SIGNAL(triggered()), this, SLOT(togglePaused()));
    toolbar->addAction(pauseAction);
    
    connect(realTimeAction, SIGNAL(triggered()), this, SLOT(realTime()));
    toolbar->addAction(realTimeAction);
    
    connect(doubleTimeAction, SIGNAL(triggered()), this, SLOT(doubleTime()));
    toolbar->addAction(doubleTimeAction);
    
    connect(fastTimeAction, SIGNAL(triggered()), this, SLOT(fasterTime()));
    toolbar->addAction(fastTimeAction);
    
    
    controlsLayout->addWidget(toolbar);
    
    controlsLayout->addStretch(1);
    controlsLayout->addWidget(zoomLabel);
    controls->setLayout(controlsLayout);
    
    connect(zoomLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(setZoom(const QString&)));
    
    QVBoxLayout* layout = new QVBoxLayout(this);
    
    layout->addWidget(m_timelineView);
    layout->addWidget(controls);
    //layout->addLayout(controlsLayout);
    layout->setContentsMargins(0, 0, 0, 0);
    
    this->setLayout(layout);
    this->show();
    
    m_timelineView->setTimeRange(0.0, 5.0);
}