void PlayerComponent::buttonClicked (Button* buttonThatWasClicked)
{
    if (buttonThatWasClicked == browseButton)
    {
        FileChooser fileChooser(T("Select an audio file to open..."),
                                _lastWorkingDirectory,
                                _audioFormatManager.getWildcardForAllFormats(),
                                false);

        if(fileChooser.browseForFileToOpen())
        {
            File audioFile(fileChooser.getResult());
            _lastWorkingDirectory = audioFile.getParentDirectory();

            AudioFormatReader *fileReader = _audioFormatManager.createReaderFor(audioFile);

            if(fileReader)
            {
                _transportSource.stop();
                _transportSource.setSource(0);

                filenameLabel->setText(audioFile.getFileName(), false);

                delete _fileReaderSource;
                _fileReaderSource = new AudioFormatReaderSource(fileReader, true);
                _fileReaderSource->setLooping(loopButton->getToggleState());
                _transportSource.setSource(_fileReaderSource, 32768, fileReader->sampleRate);
                _transportSource.setPosition(.0f);

                _totalTime = double(fileReader->lengthInSamples) / double(fileReader->sampleRate);
                timeSlider->setRange(.0, _totalTime, 1.);
                timeSlider->setValue(.0, false, false);

                setCurrentTime();
            }
        }
    }
    else if (buttonThatWasClicked == playButton)
    {
        if(_transportSource.isPlaying())
            _transportSource.stop();
        else
            _transportSource.start();
    }
    else if (buttonThatWasClicked == stopButton)
    {
        _transportSource.stop();
        _transportSource.setPosition(0);

        setCurrentTime();
    }
    else if (buttonThatWasClicked == loopButton)
    {
        if(_fileReaderSource)
            _fileReaderSource->setLooping(loopButton->getToggleState());
    }
}
Example #2
0
void AnimationPlayer::play()
{
    unpause();
    if (!m_content)
        return;
    double currentTime = this->currentTime();
    if (m_playbackRate > 0 && (currentTime < 0 || currentTime >= sourceEnd()))
        setCurrentTime(0);
    else if (m_playbackRate < 0 && (currentTime <= 0 || currentTime > sourceEnd()))
        setCurrentTime(sourceEnd());
}
Example #3
0
void AnimationPlayer::reverse()
{
    if (!m_playbackRate)
        return;
    if (m_content) {
        if (m_playbackRate > 0 && currentTime() > sourceEnd())
            setCurrentTime(sourceEnd());
        else if (m_playbackRate < 0 && currentTime() < 0)
            setCurrentTime(0);
    }
    setPlaybackRate(-m_playbackRate);
    unpause();
}
Example #4
0
void AnimationPlayer::finish(ExceptionState& exceptionState)
{
    if (!m_playbackRate)
        return;
    if (m_playbackRate < 0) {
        setCurrentTime(0);
    } else {
        if (sourceEnd() == std::numeric_limits<double>::infinity()) {
            exceptionState.throwDOMException(InvalidStateError, "AnimationPlayer has source content whose end time is infinity.");
            return;
        }
        setCurrentTime(sourceEnd());
    }
    ASSERT(finished());
}
Example #5
0
void
AudioOutput::seek( qint64 milliseconds )
{
    tDebug() << Q_FUNC_INFO;

    switch ( m_currentState )
    {
        case Playing:
        case Paused:
        case Loading:
        case Buffering:
            break;
        default:
            return;
    }

    if ( m_seekable )
    {

        //    tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking" << milliseconds << "msec";
        libvlc_media_player_set_time( m_vlcPlayer, milliseconds );
        setCurrentTime( milliseconds );
    }
    else
    {
        qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
        float position = float(float(milliseconds) / duration);
        libvlc_media_player_set_position(m_vlcPlayer, position);
        tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking via position" << position << "pos";
    }
    m_justSeeked = true;
}
Example #6
0
void JokerWindow::on_actionChange_timestamp_triggered()
{
	hideMediaPanel();
	setCurrentRate(0);
	PhTime time = _synchronizer.videoClock()->time();

#ifdef USE_VIDEO
	if(_synchronizer.videoClock()->time() < _videoEngine.timeIn())
		time = _videoEngine.timeIn();
	else if(_synchronizer.videoClock()->time() > _videoEngine.timeIn() + _videoEngine.length())
		time = _videoEngine.timeOut();

	PhTimeCodeDialog dlg(_doc->videoTimeCodeType(), time);
	if(dlg.exec() == QDialog::Accepted) {
		PhTime timeStamp = 0;
		if(_synchronizer.videoClock()->time() > _videoEngine.timeIn() + _videoEngine.length())
			timeStamp = dlg.time() - (_videoEngine.length() - PhTimeCode::timePerFrame(timeCodeType()));
		else if (_synchronizer.videoClock()->time() < _videoEngine.timeIn())
			timeStamp =  dlg.time();
		else
			timeStamp = _videoEngine.timeIn() + dlg.time() - _synchronizer.videoClock()->time();

		_videoEngine.setTimeIn(timeStamp);
		setCurrentTime(dlg.time());
		_doc->setVideoTimeIn(timeStamp, timeCodeType());
		_mediaPanel.setTimeIn(timeStamp);
		_doc->setModified(true);
	}
#endif

	fadeInMediaPanel();
}
Example #7
0
void MythUIAnimation::IncrementCurrentTime(void)
{
    if (!m_active)
        return;

    int time = currentTime();
    if (direction() == Forward)
        time += GetMythMainWindow()->GetDrawInterval();
    else
        time -= GetMythMainWindow()->GetDrawInterval();

    setCurrentTime(time);

    if (endValue() == currentValue())
    {
        if (direction() == Forward)
        {
            if (m_reversible)
                setDirection(Backward);
            else if (!m_looped)
                m_active = false;
        }
    }
    else if (startValue() == currentValue())
    {
        if (direction() == Backward)
        {
            if (m_reversible)
                setDirection(Forward);
            else if (!m_looped)
                m_active = false;
        }
    }
}
/** Update the timeline widget.
  *
  * \param dt seconds of real time elapsed since the last call to tick
  */
void
TimelineWidget::tick(double dt)
{
    if (!m_paused && m_timeRate != 0.0)
    {
        setCurrentTime(currentTime() + sta::secsToDays(dt) * m_timeRate);
    }
}
	//----------------------------------------------------------------------
	void WorldTime::frameStarted(const FrameEvent& _evt)
	{
		// Advance the current world time.
		double t = _evt.timeSinceLastFrame;
		if(!mPaused && mTimeSpeed != 0)
		{
			setCurrentTime(getCurrentTime() + t * mTimeSpeed);
		}
	}
void PlayerComponent::sliderValueChanged (Slider* slider)
{
    if (slider == timeSlider)
    {
        _transportSource.setPosition(slider->getValue());

        if(!_transportSource.isPlaying())
            setCurrentTime();
    }
}
Example #11
0
// Sets the timer value
bool Timer::setSlotTimerValue(const Time* const msg)
{
    bool ok = false;
    if (msg != 0) {
      double sec = Seconds::convertStatic(*msg);
      ok = setTimerValue(sec);
      if (ok) setCurrentTime(sec);
   }
   return ok;
}
Example #12
0
MyTime::MyTime(){
    this->resize(400,300);
    res=new QLabel("current time",this);
    gettime=new QPushButton("gettime",this);
    res->move(100,50);
    gettime->move(100,240);
    /*连接按钮和槽函数*/
    connect(gettime,SIGNAL(clicked()),this,
            SLOT(setCurrentTime()));  
}
Example #13
0
void JokerWindow::on_actionTimecode_triggered()
{
	hideMediaPanel();

	PhTimeCodeDialog dlg(timeCodeType(), currentTime());
	if(dlg.exec() == QDialog::Accepted)
		setCurrentTime(dlg.time());

	fadeInMediaPanel();
}
Example #14
0
	WorldTime::WorldTime()
	{
		registerFrameListener();

		// Measured Gothic I value:
		// twenty-four hours in game / 100 minutes in real life = 
		// 24 * 60 / 100 = 14.4 game minutes per one real minute.
		mDefaultTimeSpeed = 14.4f;
		mTimeSpeed = mDefaultTimeSpeed;
		mPaused = false;
		setCurrentTime(Time(1, 8, 0, 0)); // Day 1, 8:00
	}
Example #15
0
const bool PriorityMuxer::clearInput(const uint8_t priority)
{
	if (priority < PriorityMuxer::LOWEST_PRIORITY && _activeInputs.remove(priority))
	{
		Debug(_log,"Removed source priority %d",priority);
		// on clear success update _currentPriority
		setCurrentTime();
		emit priorityChanged(priority, false);
		emit prioritiesChanged();
		return true;
	}
	return false;
}
int QTimeLine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 10)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 10;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = duration(); break;
        case 1: *reinterpret_cast< int*>(_v) = updateInterval(); break;
        case 2: *reinterpret_cast< int*>(_v) = currentTime(); break;
        case 3: *reinterpret_cast< Direction*>(_v) = direction(); break;
        case 4: *reinterpret_cast< int*>(_v) = loopCount(); break;
        case 5: *reinterpret_cast< CurveShape*>(_v) = curveShape(); break;
        case 6: *reinterpret_cast< QEasingCurve*>(_v) = easingCurve(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDuration(*reinterpret_cast< int*>(_v)); break;
        case 1: setUpdateInterval(*reinterpret_cast< int*>(_v)); break;
        case 2: setCurrentTime(*reinterpret_cast< int*>(_v)); break;
        case 3: setDirection(*reinterpret_cast< Direction*>(_v)); break;
        case 4: setLoopCount(*reinterpret_cast< int*>(_v)); break;
        case 5: setCurveShape(*reinterpret_cast< CurveShape*>(_v)); break;
        case 6: setEasingCurve(*reinterpret_cast< QEasingCurve*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #17
0
void Simulator::clear()
{
    RTC::Manager* manager = &RTC::Manager::instance();
    for (unsigned int i=0; i<numBodies(); i++){
        BodyRTC *bodyrtc = dynamic_cast<BodyRTC *>(body(i).get());
        bodyrtc->exit();
    }
    manager->cleanupComponents();
    clearBodies();
    constraintForceSolver.clearCollisionCheckLinkPairs();
    setCurrentTime(0.0);
    pairs.clear();
    receivers.clear();
}
Example #18
0
void
AudioOutput::onVlcEvent( const libvlc_event_t* event )
{
    switch ( event->type )
    {
        case libvlc_MediaPlayerTimeChanged:
            setCurrentTime( event->u.media_player_time_changed.new_time );
            break;
        case libvlc_MediaPlayerPositionChanged:
            setCurrentPosition( event->u.media_player_position_changed.new_position );
            break;
        case libvlc_MediaPlayerSeekableChanged:
         //   tDebug() << Q_FUNC_INFO << " : seekable changed : " << event->u.media_player_seekable_changed.new_seekable;
            break;
        case libvlc_MediaDurationChanged:
            setTotalTime( event->u.media_duration_changed.new_duration );
            break;
        case libvlc_MediaPlayerLengthChanged:
        //    tDebug() << Q_FUNC_INFO << " : length changed : " << event->u.media_player_length_changed.new_length;
            break;
        case libvlc_MediaPlayerPlaying:
            setState( Playing );
            break;
        case libvlc_MediaPlayerPaused:
            setState( Paused );
            break;
        case libvlc_MediaPlayerEndReached:
            setState( Stopped );
            break;
        case libvlc_MediaPlayerEncounteredError:
            tDebug() << Q_FUNC_INFO << "LibVLC error: MediaPlayerEncounteredError. Stopping";
            // Don't call stop() here - it will deadlock libvlc
            setState( Error );
            break;
        case libvlc_MediaPlayerNothingSpecial:
        case libvlc_MediaPlayerOpening:
        case libvlc_MediaPlayerBuffering:
        case libvlc_MediaPlayerStopped:
        case libvlc_MediaPlayerVout:
        case libvlc_MediaPlayerMediaChanged:
        case libvlc_MediaPlayerForward:
        case libvlc_MediaPlayerBackward:
        case libvlc_MediaPlayerPausableChanged:
        case libvlc_MediaPlayerTitleChanged:
        case libvlc_MediaPlayerSnapshotTaken:
        default:
            break;
    }
}
Example #19
0
int QwtAnalogClock::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QwtDial::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: setCurrentTime(); break;
        case 1: setTime((*reinterpret_cast< const QTime(*)>(_a[1]))); break;
        case 2: setTime(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
int QAbstractAnimation::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 11)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 11;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< State*>(_v) = state(); break;
        case 1: *reinterpret_cast< int*>(_v) = loopCount(); break;
        case 2: *reinterpret_cast< int*>(_v) = currentTime(); break;
        case 3: *reinterpret_cast< int*>(_v) = currentLoop(); break;
        case 4: *reinterpret_cast< Direction*>(_v) = direction(); break;
        case 5: *reinterpret_cast< int*>(_v) = duration(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 1: setLoopCount(*reinterpret_cast< int*>(_v)); break;
        case 2: setCurrentTime(*reinterpret_cast< int*>(_v)); break;
        case 4: setDirection(*reinterpret_cast< Direction*>(_v)); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 6;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #21
0
bool JokerWindow::openDocument(const QString &fileName)
{
	QFileInfo info(fileName);
	if(_settings->videoFileType().contains(info.suffix().toLower())) {
#ifdef USE_VIDEO
		return openVideoFile(fileName);
#else
		return false;
#endif
	}

	/// Clear the selected people name list (except for the first document).
	if(!_firstDoc)
		_settings->setSelectedPeopleNameList(QStringList());
	else
		_firstDoc = false;

	if(!_doc->openStripFile(fileName))
		return false;

	/// If the document is opened successfully :
	/// - Update the current document name (settings, windows title)
	PhEditableDocumentWindow::openDocument(fileName);
	_watcher.addPath(_doc->filePath());

#ifdef USE_VIDEO
	/// - Load the deinterlace settings
	on_actionDeinterlace_video_triggered(_doc->videoDeinterlace());
	/// - Open the corresponding video file if it exists.
	if(openVideoFile(_doc->videoFilePath())) {
		_videoEngine.setTimeIn(_doc->videoTimeIn());
		_mediaPanel.setTimeIn(_doc->videoTimeIn());
	}
	else
		_videoEngine.close();
#endif

	/// - Set the video aspect ratio.
	ui->actionForce_16_9_ratio->setChecked(_doc->forceRatio169());

	/// - Goto to the document last position.
	setCurrentTime(_doc->lastTime());
	/// - Disable the need to save flag.

	return true;
}
Example #22
0
void RDORuntime::copyFrom(const LPRDORuntime& pOther)
{
    ASSERT(pOther);
    ASSERT(m_resourceTypeList.empty());

    LPRDORuntime pThis(const_cast<RDORuntime*>(this));

    for (const LPRDOResourceTypeList& pRTP: pOther->m_resourceTypeList)
    {
        pRTP->clone(pThis);
    }

    m_constantList         = pOther->m_constantList;
    m_patternParameterList = pOther->m_patternParameterList;
    m_resultList           = pOther->m_resultList;
    m_pThreadProxy         = pOther->m_pThreadProxy;
    setCurrentTime(pOther->getCurrentTime());

    parent_type::copyFrom(pOther.object_parent_cast<parent_type>());
}
Example #23
0
void JokerWindow::on_actionOpen_Video_triggered()
{
#ifdef USE_VIDEO
	hideMediaPanel();

	QString lastFolder = _settings->lastVideoFolder();
	QString filter = tr("Movie files") + " (";
	foreach(QString type, _settings->videoFileType())
		filter += "*." + type + " ";
	filter += ");;";

	QFileDialog dlg(this, tr("Open a video..."), lastFolder, filter);
	if(dlg.exec()) {
		QString videoFile = dlg.selectedFiles()[0];
		if(openVideoFile(videoFile))
			setCurrentTime(_doc->videoTimeIn());
	}

	fadeInMediaPanel();
#endif
}
Example #24
0
KFFOpt_datetime::KFFOpt_datetime( QWidget *parent )
		: KFFOpt_skeleton( parent )
{
	QString img = Settings::data_dir() + "/clouds.svg";
	QString img2 = Settings::data_dir() + "/x29.svg";

	ui_widget.setupUi ( this );
	ui_widget.widgetLogo->load ( img );
	ui_widget.widgetLogo2->load ( img2 );

	m_grp = new QButtonGroup( this );
	m_grp->addButton( ui_widget.RB_Real_Time, 0 );
	m_grp->addButton( ui_widget.RB_TimeOfDay, 1 );
	m_grp->addButton( ui_widget.RB_Fixed_Time, 2 );

	connect( m_grp, SIGNAL( buttonClicked( int ) ), SLOT( enableWidget( int ) ) );
	connect( ui_widget.btn_current,
	         SIGNAL( clicked() ),
	         SLOT( setCurrentTime() )
	       );
}
Example #25
0
const bool PriorityMuxer::setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms)
{
	if(!_activeInputs.contains(priority))
	{
		Error(_log,"setInputImage() used without registerInput() for priority '%d', probably the priority reached timeout",priority);
		return false;
	}

	// calc final timeout
	if(timeout_ms > 0)
		timeout_ms = QDateTime::currentMSecsSinceEpoch() + timeout_ms;

	InputInfo& input     = _activeInputs[priority];
	// detect active <-> inactive changes
	bool activeChange = false;
	bool active = true;
	if(input.timeoutTime_ms == -100 && timeout_ms != -100)
	{
		activeChange = true;
	}
	else if(timeout_ms == -100 && input.timeoutTime_ms != -100)
	{
		active = false;
		activeChange = true;
	}
	// update input
	input.timeoutTime_ms = timeout_ms;
	input.image          = image;

	// emit active change
	if(activeChange)
	{
		Debug(_log, "Priority %d is now %s", priority, active ? "active" : "inactive");
		emit activeStateChanged(priority, active);
		setCurrentTime();
	}
	return true;
}
Example #26
0
bool PriorityMuxer::setSourceAutoSelectEnabled(const bool& enable, const bool& update)
{
	if(_sourceAutoSelectEnabled != enable)
	{
		// on disable we need to make sure the last priority call to setPriority is still valid
		if(!enable && !_activeInputs.contains(_manualSelectedPriority))
		{
			Warning(_log, "Can't disable auto selection, as the last manual selected priority (%d) is no longer available", _manualSelectedPriority);
			return false;
		}

		_sourceAutoSelectEnabled = enable;
		Debug(_log, "Source auto select is now %s", enable ? "enabled" : "disabled");

		// update _currentPriority if called from external
		if(update)
			setCurrentTime();

		emit autoSelectChanged(enable);
		return true;
	}
	return false;
}
Example #27
0
void WallClockPrivate::update() {
    if (m_enabled) {
        QTime current = QTime::currentTime();
        int initDelay = 0;
        switch (m_updateFreq) {
        case WallClock::Day:
            initDelay = (23 - current.hour()) * 3600 * 1000;
            initDelay += (59 - current.minute()) * 60 * 1000;
            // fall through
        case WallClock::Minute:
            initDelay += (59 - current.second()) * 1000;
            // fall through
        case WallClock::Second:
            initDelay += 1000 - current.msec();
        }

        setCurrentTime(0);
        setDuration(initDelay+8); // animation timer can fire slightly before our target
        if (state() != Running)
            start();
    } else {
        stop();
    }
}
Example #28
0
//-----------------------------------------------------------------------------
//    Class:			CTime
//	  Method:			CTime::CTime(void)
//	  Description:		default constructor for CTime objects  
//    Calls:            setCurrentTime()
//    Called By:		main()
//    Parameters:		void
//    Returns:          n/a 
//    History Log:
//                           4/28/15  KG  completed version 1.0
// ----------------------------------------------------------------------------
	CTime::CTime(void)
	{
		setCurrentTime();
	}
Example #29
0
RTC::ReturnCode_t ArmControlCartesian::onExecute(RTC::UniqueId ec_id)
{
  //
  // asigned part index
  //
  int aid = m_assignedPartIndex;


  //
  // get data from in port & update robot model
  //
  if(m_jointDatIn.isNew ()) {
    m_jointDatIn.read();
    for(unsigned int i = 0; i < m_partMembers.size (); i++) {
      for(unsigned int j = 0; j < m_partMembers[i].size (); j++) {
	hrp::Link * l = m_robot->joint((int) m_partMembers[i][j]);
	if(l != NULL)
	  l->q = m_jointDat.qState[i][j];
      }
    }
    m_robot->calcForwardKinematics ();
  }
  else
    return RTC::RTC_OK;


  //
  // check reference data
  //
  if( isEmpty() )
    return RTC::RTC_OK;


  //
  // set data for not asigined part
  //
  for(int i=0; i<m_jointDat.id.length(); i++) {
    if(i != aid) {
      m_jointDat.id[i] = CMD_IDLE;
      m_jointDat.cmd[i].sec = 0;
      m_jointDat.cmd[i].nsec = 0;
    }
  }


  //
  // clear motion
  //
  if (  m_jointDat.id[aid] == CMD_GO_ACTUAL
	|| m_jointDat.id[aid] == CMD_PROTECTIVE_STOP
	|| m_cmdTimes[aid].sec  <  m_jointDat.cmd[aid].sec
	|| (m_cmdTimes[aid].sec  == m_jointDat.cmd[aid].sec &&
	    m_cmdTimes[aid].nsec <  m_jointDat.cmd[aid].nsec))
    {
      emergencyStop();
      m_jointDat.id[aid] = CMD_PROTECTIVE_STOP;
      m_jointDat.cmd[aid].sec  = m_cmdTimes[aid].sec;
      m_jointDat.cmd[aid].nsec = m_cmdTimes[aid].nsec;
      m_jointDatOut.write ();
      return RTC::RTC_OK;
    }

  //
  // write to out port
  //
  else
    {
      // calc inverse kinematics
      hrp::Vector3  ref_p;   m_pos_interpolator->get(&ref_p[0]);
      hrp::Matrix33 ref_R0;  m_rot_interpolator->get(ref_R0);
      hrp::Matrix33 ref_R1 = m_jointPath->endLink()->calcRfromAttitude(ref_R0);
      if( !m_jointPath->calcInverseKinematics(ref_p, ref_R1) ) {
	emergencyStop();
	return RTC::RTC_OK;
      }

      // update port dat
      for(int i = 0; i < m_jointPath->numJoints(); i++)
	m_jointDat.qCommand[aid][i] = m_jointPath->joint(i)->q;

      m_jointDat.id[aid]       = m_cmdId;
      m_jointDat.cmd[aid].sec  = m_cmdTimes[aid].sec;
      m_jointDat.cmd[aid].nsec = m_cmdTimes[aid].nsec;

      setCurrentTime (m_jointDat.tm);
      m_jointDatOut.write ();
      return RTC::RTC_OK;
    }


  return RTC::RTC_OK;
}
Example #30
0
QwtDial *CockpitGrid::createDial( int pos )
{
    QwtDial *dial = NULL;
    switch( pos )
    {
        case 0:
        {
            d_clock = new QwtAnalogClock( this );
#if 0
            // disable minor ticks
            d_clock->scaleDraw()->setTickLength( QwtScaleDiv::MinorTick, 0 );
#endif

            const QColor knobColor = QColor( Qt::gray ).light( 130 );

            for ( int i = 0; i < QwtAnalogClock::NHands; i++ )
            {
                QColor handColor = QColor( Qt::gray ).light( 150 );
                int width = 8;

                if ( i == QwtAnalogClock::SecondHand )
                {
                    handColor = Qt::gray;
                    width = 5;
                }

                QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
                    QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
                hand->setWidth( width );

                d_clock->setHand( static_cast<QwtAnalogClock::Hand>( i ), hand );
            }

            QTimer *timer = new QTimer( d_clock );
            timer->connect( timer, SIGNAL( timeout() ),
                d_clock, SLOT( setCurrentTime() ) );
            timer->start( 1000 );

            dial = d_clock;
            break;
        }
        case 1:
        {
            d_speedo = new SpeedoMeter( this );
            d_speedo->setScaleStepSize( 20.0 );
            d_speedo->setScale( 0.0, 240.0 );
            d_speedo->scaleDraw()->setPenWidth( 2 );

            QTimer *timer = new QTimer( d_speedo );
            timer->connect( timer, SIGNAL( timeout() ),
                this, SLOT( changeSpeed() ) );
            timer->start( 50 );

            dial = d_speedo;
            break;
        }
        case 2:
        {
            d_ai = new AttitudeIndicator( this );
            d_ai->scaleDraw()->setPenWidth( 3 );

            QTimer *gradientTimer = new QTimer( d_ai );
            gradientTimer->connect( gradientTimer, SIGNAL( timeout() ),
                this, SLOT( changeGradient() ) );
            gradientTimer->start( 100 );

            QTimer *angleTimer = new QTimer( d_ai );
            angleTimer->connect( angleTimer, SIGNAL( timeout() ),
                this, SLOT( changeAngle() ) );
            angleTimer->start( 100 );

            dial = d_ai;
            break;
        }

    }

    if ( dial )
    {
        dial->setReadOnly( true );
        dial->setLineWidth( 4 );
        dial->setFrameShadow( QwtDial::Sunken );
    }
    return dial;
}