Initial commit of ResInsight version 0.4.8

This commit is contained in:
Alf B. Rustad
2012-05-18 09:45:23 +02:00
parent a680bf941e
commit dfe97efb1b
657 changed files with 176690 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
cmake_minimum_required (VERSION 2.8)
project (cafAnimControl)
set( QOBJECT_HEADERS
cafFrameAnimationControl.h
cafAnimationToolBar.h
)
qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} )
# NOTE! Resources in this subfolder appends to the variable QRC_FILES in parent scope
# CMakeList.txt in the application folder (parent scope) must use the following syntax
# to make sure the QRC_FILES variable contains appended files in subfolders
# set( QRC_FILES
# ${QRC_FILES}
# Resources/MyaApplication.qrc
# )
set( QRC_FILES
${QRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/Resources/cafAnimControl.qrc
PARENT_SCOPE
)
add_library( ${PROJECT_NAME}
cafFrameAnimationControl.cpp
cafAnimationToolBar.cpp
${MOC_FILES_CPP}
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1020 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,16 @@
<RCC>
<qresource prefix="cafAnimControl">
<file>Play.png</file>
<file>Stop.png</file>
<file>Pause.png</file>
<file>StepFwd.png</file>
<file>StepBwd.png</file>
<file>SkipToEnd.png</file>
<file>SkipToStart.png</file>
<file>RepeatFromStart.png</file>
<file>RepeatFwdBwd.png</file>
<file>PlayBwd.png</file>
<file>Slow.png</file>
<file>Fast.png</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,319 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cafAnimationToolBar.h"
#include <QAction>
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
AnimationToolBar::AnimationToolBar(QWidget *parent /*= 0*/)
: QToolBar (parent)
{
setObjectName("AnimationToolBar");
init();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
AnimationToolBar::AnimationToolBar(const QString &title, QWidget *parent /*= 0*/)
: QToolBar(title, parent)
{
setObjectName(title);
init();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::init()
{
m_hasAutoTimeStepStrings = true;
m_slowFrameRate = 0.25;
m_fastFrameRate = 20;
// Create actions and widgets
m_animSkipToStartAction = new QAction(QIcon(":/cafAnimControl/SkipToStart.png"), tr("Skip to Start"), this);
m_animStepBackwardAction = new QAction(QIcon(":/cafAnimControl/StepBwd.png"), tr("Step Backward"), this);
m_animPlayBwdAction = new QAction(QIcon(":/cafAnimControl/PlayBwd.png"), tr("Play Backwards"), this);
m_animStopAction = new QAction(QIcon(":/cafAnimControl/Stop.png"), tr("Stop"), this);
m_animPauseAction = new QAction(QIcon(":/cafAnimControl/Pause.png"), tr("Pause"), this);
m_animPlayAction = new QAction(QIcon(":/cafAnimControl/Play.png"), tr("Play"), this);
m_animStepForwardAction = new QAction(QIcon(":/cafAnimControl/StepFwd.png"), tr("Step Forward"), this);
m_animSkipToEndAction = new QAction(QIcon(":/cafAnimControl/SkipToEnd.png"), tr("Skip to End"), this);
m_animRepeatFromStartAction = new QAction(QIcon(":/cafAnimControl/RepeatFromStart.png"), tr("Repeat From start"), this);
m_animRepeatFromStartAction->setCheckable(true);
m_animRepeatFwdBwdAction = new QAction(QIcon(":/cafAnimControl/RepeatFwdBwd.png"), tr("Repeat Forward/Backward"), this);
m_animRepeatFwdBwdAction->setCheckable(true);
m_timestepCombo = new QComboBox(this);
m_timestepCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
m_timestepCombo->setToolTip(tr("Current Time Step"));
QLabel* slowLabel = new QLabel ( this);
slowLabel->setPixmap(QPixmap(":/cafAnimControl/Slow.png"));
slowLabel->setToolTip(tr("Slow"));
QLabel* fastLabel = new QLabel(this);
fastLabel->setPixmap(QPixmap(":/cafAnimControl/Fast.png"));
fastLabel->setAlignment(Qt::AlignRight);
fastLabel->setToolTip(tr("Fast"));
m_frameRateSlider = new QSlider(Qt::Horizontal, this);
m_frameRateSlider->setMaximumWidth(75);
m_frameRateSlider->setToolTip(tr("Animation speed"));
QAction* separator1 = new QAction(this);
separator1->setSeparator(true);
QAction* separator2 = new QAction(this);
separator2->setSeparator(true);
QAction* separator3 = new QAction(this);
separator3->setSeparator(true);
// Add actions and widgets to animation toolbar
addAction(m_animSkipToStartAction);
addAction(m_animStepBackwardAction);
addAction(m_animPlayBwdAction );
addAction(m_animStopAction);
addAction(m_animPauseAction);
addAction(m_animPlayAction);
addAction(m_animStepForwardAction);
addAction(m_animSkipToEndAction);
addAction(separator1);
addAction(m_animRepeatFromStartAction );
addAction(m_animRepeatFwdBwdAction );
addAction(separator2);
addWidget(slowLabel);
addWidget(m_frameRateSlider);
addWidget(fastLabel);
addAction(separator3);
addWidget(m_timestepCombo);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::connectAnimationControl(caf::FrameAnimationControl* animationControl)
{
// Animation action connections
if (m_activeAnimationControl)
{
m_activeAnimationControl->disconnect(m_timestepCombo, SLOT(setCurrentIndex(int)));
}
m_activeAnimationControl = animationControl;
m_animSkipToStartAction->disconnect();
m_animStepBackwardAction->disconnect();
m_animStopAction->disconnect();
m_animPauseAction->disconnect();
m_animPlayAction->disconnect();
m_animStepForwardAction->disconnect();
m_animSkipToEndAction->disconnect();
m_animPlayBwdAction ->disconnect();
m_animRepeatFromStartAction->disconnect();
m_animRepeatFwdBwdAction ->disconnect();
m_timestepCombo->disconnect();
m_frameRateSlider->disconnect();
if (animationControl)
{
connect(m_animSkipToStartAction, SIGNAL(triggered()), animationControl, SLOT(slotSkipToStart()));
connect(m_animStepBackwardAction, SIGNAL(triggered()), animationControl, SLOT(slotStepBackward()));
connect(m_animStopAction, SIGNAL(triggered()), animationControl, SLOT(slotStop()));
connect(m_animPauseAction, SIGNAL(triggered()), animationControl, SLOT(slotPause()));
connect(m_animPlayAction, SIGNAL(triggered()), animationControl, SLOT(slotPlayFwd()));
connect(m_animStepForwardAction, SIGNAL(triggered()), animationControl, SLOT(slotStepForward()));
connect(m_animSkipToEndAction, SIGNAL(triggered()), animationControl, SLOT(slotSkipToEnd()));
connect(m_animPlayBwdAction ,SIGNAL(triggered()), animationControl, SLOT(slotPlayBwd()));
m_animRepeatFromStartAction->setChecked(animationControl->isRepeatingFromStart());
m_animRepeatFwdBwdAction->setChecked(animationControl->isRepeatingFwdBwd());
connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFromStart(bool)));
connect(m_animRepeatFwdBwdAction ,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFwdBwd(bool)));
connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), this, SLOT(slotFromStartModeToggled(bool)));
connect(m_animRepeatFwdBwdAction ,SIGNAL(triggered(bool)), this, SLOT(slotFwdBwdModeToggled(bool)));
connect(m_timestepCombo, SIGNAL(currentIndexChanged(int)), animationControl, SLOT(setCurrentFrame(int)));
connect(m_frameRateSlider, SIGNAL(valueChanged(int)), this, SLOT(slotFrameRateSliderChanged(int)));
connect(animationControl, SIGNAL(changeFrame(int)), m_timestepCombo, SLOT(setCurrentIndex (int)));
connect(animationControl, SIGNAL(frameCountChanged(int)), this, SLOT(slotUpdateTimestepList(int)));
int timeout = animationControl->timeout();
double initialFrameRate = 1000;
if (timeout > 0) initialFrameRate = 1000.0/timeout;
setFrameRate(initialFrameRate);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::setFrameRate(double frameRate)
{
float sliderRange = m_frameRateSlider->maximum() - m_frameRateSlider->minimum();
float frameRateRange = m_fastFrameRate - m_slowFrameRate;
float normalizedSliderPosition = (frameRate - m_slowFrameRate )/ frameRateRange ;
float sliderTickValue = sliderRange* normalizedSliderPosition ;
m_frameRateSlider->blockSignals(true);
m_frameRateSlider->setValue(static_cast<int>(sliderTickValue));
m_frameRateSlider->blockSignals(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::setTimeStepStrings(const QStringList& timeStepStrings)
{
if (timeStepStrings.empty())
{
m_hasAutoTimeStepStrings = true;
}
else
{
m_hasAutoTimeStepStrings = false;
}
m_timestepCombo->blockSignals(true);
m_timestepCombo->clear();
m_timestepCombo->addItems(timeStepStrings);
m_timestepCombo->blockSignals(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::setCurrentTimeStepIndex(int index)
{
m_timestepCombo->setCurrentIndex(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::slotFrameRateSliderChanged(int sliderTickValue)
{
float sliderRange = m_frameRateSlider->maximum() - m_frameRateSlider->minimum();
float normalizedSliderPosition = sliderTickValue / sliderRange;
float frameRateRange = m_fastFrameRate - m_slowFrameRate;
float newFrameRate = m_slowFrameRate + frameRateRange * normalizedSliderPosition;
if (newFrameRate > m_fastFrameRate)
{
newFrameRate = m_fastFrameRate;
}
if (newFrameRate < m_slowFrameRate)
{
newFrameRate = m_slowFrameRate;
}
setFrameRate(newFrameRate);
if(!m_activeAnimationControl.isNull()) m_activeAnimationControl->setTimeout((int)(1.0/newFrameRate * 1000));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::setSlowFrameRate(float frameRate)
{
m_slowFrameRate = frameRate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::setFastFrameRate(float frameRate)
{
m_fastFrameRate = frameRate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::slotUpdateTimestepList(int frameCount)
{
QStringList timeStepNames;
for (int vIdx = 0; vIdx < frameCount; ++vIdx)
{
timeStepNames.append(QString().setNum(vIdx));
}
m_timestepCombo->blockSignals(true);
m_timestepCombo->clear();
m_timestepCombo->addItems(timeStepNames);
m_timestepCombo->blockSignals(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::slotFromStartModeToggled(bool on)
{
if (on)
{
m_animRepeatFwdBwdAction->blockSignals(true);
m_animRepeatFwdBwdAction->setChecked(false);
m_animRepeatFwdBwdAction->blockSignals(false);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AnimationToolBar::slotFwdBwdModeToggled(bool on)
{
if (on)
{
m_animRepeatFromStartAction->blockSignals(true);
m_animRepeatFromStartAction->setChecked(false);
m_animRepeatFromStartAction->blockSignals(false);
}
}
} // End namespace caf

View File

@@ -0,0 +1,92 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <QToolBar>
#include <QPointer>
#include "cafFrameAnimationControl.h"
class QComboBox;
class QLabel;
class QLineEdit;
class QSlider;
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class AnimationToolBar : public QToolBar
{
Q_OBJECT
public:
AnimationToolBar(QWidget *parent = 0);
AnimationToolBar(const QString &title, QWidget *parent = 0);
void connectAnimationControl(caf::FrameAnimationControl* animationControl);
void setTimeStepStrings(const QStringList& timeStepStrings);
void setFrameRate(double frameRate);
void setSlowFrameRate(float frameRate);
void setFastFrameRate(float frameRate);
void setCurrentTimeStepIndex(int index);
public slots:
void slotUpdateTimestepList(int frameCount);
private slots:
void slotFrameRateSliderChanged(int value);
void slotFromStartModeToggled(bool on);
void slotFwdBwdModeToggled(bool on);
private:
void init();
private:
QAction* m_animSkipToStartAction;
QAction* m_animStepBackwardAction;
QAction* m_animPlayBwdAction;
QAction* m_animStopAction;
QAction* m_animPauseAction;
QAction* m_animPlayAction;
QAction* m_animStepForwardAction;
QAction* m_animSkipToEndAction;
QAction* m_animRepeatFromStartAction;
QAction* m_animRepeatFwdBwdAction;
QSlider* m_frameRateSlider;
QComboBox* m_timestepCombo;
QPointer<caf::FrameAnimationControl> m_activeAnimationControl;
float m_slowFrameRate;
float m_fastFrameRate;
bool m_hasAutoTimeStepStrings;
};
} // End namespace caf

View File

@@ -0,0 +1,385 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cafFrameAnimationControl.h"
#include "qtimer.h"
namespace caf
{
//==================================================================================================
///
/// \class RIAnimationControl
///
/// Animation control class
///
//==================================================================================================
// Default timeout 100 ms, 10 FPS
static const int TIMEOUT_DEFAULT = 100;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
FrameAnimationControl::FrameAnimationControl(QObject* parent)
: QObject(parent)
{
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), SLOT(slotTimerTriggered()));
setDefault();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setDefault()
{
setNumFrames(0);
setCurrentFrame(0);
setTimeout(TIMEOUT_DEFAULT);
setForward(true);
setRepeatFromStart(false);
setRepeatFwdBwd(false);
// m_lastTimeStamp = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::start()
{
m_timer->start(m_timeout);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::stop()
{
m_timer->stop();
emit endAnimation();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::pause()
{
m_timer->stop();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::stepForward()
{
if (m_currentFrame < m_numFrames - 1)
{
m_timer->stop();
setCurrentFrame(m_currentFrame + 1);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::stepBackward()
{
if (m_currentFrame >= 1)
{
m_timer->stop();
setCurrentFrame(m_currentFrame - 1);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool FrameAnimationControl::isActive() const
{
return m_timer->isActive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setCurrentFrame(int frameIndex)
{
if (frameIndex >= 0)
{
m_currentFrame = frameIndex;
emit changeFrame(m_currentFrame);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FrameAnimationControl::currentFrame() const
{
return m_currentFrame;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setNumFrames(int numFrames)
{
m_numFrames = numFrames < 0 ? 0 : numFrames;
emit frameCountChanged(m_numFrames);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FrameAnimationControl::numFrames() const
{
return m_numFrames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setTimeout(int milliSeconds)
{
m_timeout = milliSeconds < 0 ? 0 : milliSeconds;
if (isActive()) start();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FrameAnimationControl::timeout() const
{
return m_timeout;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setForward(bool forward)
{
m_forward = forward;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool FrameAnimationControl::forward() const
{
return m_forward;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setRepeatFromStart(bool turnRepeatOn)
{
m_repeatFromStart = turnRepeatOn;
if (turnRepeatOn) m_repeatFwdBwd = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool FrameAnimationControl::isRepeatingFromStart() const
{
return m_repeatFromStart;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::setRepeatFwdBwd(bool turnRepeatOn)
{
m_repeatFwdBwd = turnRepeatOn;
if (turnRepeatOn) m_repeatFromStart = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool FrameAnimationControl::isRepeatingFwdBwd() const
{
return m_repeatFwdBwd;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotPlayFwd()
{
setForward(true);
start();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotPlayBwd()
{
setForward(false);
start();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotStop()
{
stop();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotPause()
{
pause();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotStepForward()
{
stepForward();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotStepBackward()
{
stepBackward();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotTimerTriggered()
{
// Update current frame according to settings
if (m_forward)
{
if (m_currentFrame + 1 >= m_numFrames)
{
if (m_repeatFromStart)
{
m_currentFrame = 0;
}
else if (m_repeatFwdBwd)
{
setForward(false);
m_currentFrame--;
}
else
{
stop();
m_currentFrame = m_numFrames - 1;
}
}
else
{
m_currentFrame++;
}
}
else
{
if (m_currentFrame - 1 < 0)
{
if (m_repeatFromStart)
{
m_currentFrame = m_numFrames - 1;
}
else if (m_repeatFwdBwd)
{
setForward(true);
m_currentFrame++; // Ends up as 1 (second frame) makes 2 1 0 1 2 and not 2 1 0 0 1 2
}
else
{
stop();
m_currentFrame = 0;
}
}
else
{
m_currentFrame--;
}
}
// Emit signal with updated frame index
emit changeFrame(m_currentFrame);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::skipToEnd()
{
m_timer->stop();
setCurrentFrame(m_numFrames-1);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::skipToStart()
{
m_timer->stop();
setCurrentFrame(0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotSkipToEnd()
{
skipToEnd();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotSkipToStart()
{
skipToStart();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotRepeatFromStart(bool turnRepeatOn)
{
setRepeatFromStart(turnRepeatOn);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FrameAnimationControl::slotRepeatFwdBwd(bool turnRepeatOn)
{
setRepeatFwdBwd(turnRepeatOn);
}
} // End namespace caf

View File

@@ -0,0 +1,104 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <QObject>
class QTimer;
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class FrameAnimationControl : public QObject
{
Q_OBJECT
public:
FrameAnimationControl(QObject* parent = 0);
void setNumFrames(int numFrames);
int numFrames() const;
int currentFrame() const;
bool isActive() const;
void setTimeout(int milliSeconds);
int timeout() const;
bool isRepeatingFromStart() const;
bool isRepeatingFwdBwd() const;
public slots:
void slotPlayFwd();
void slotPlayBwd();
void slotStop();
void slotPause();
void slotStepForward();
void slotStepBackward();
void setCurrentFrame(int frameIndex);
void slotSkipToEnd();
void slotSkipToStart();
void slotRepeatFromStart(bool turnRepeatOn);
void slotRepeatFwdBwd(bool turnRepeatOn);
signals:
void changeFrame(int frameIndex);
void endAnimation();
void frameCountChanged(int frameCount);
private slots:
void slotTimerTriggered();
private:
void start();
void stop();
void pause();
void stepForward();
void stepBackward();
void skipToEnd();
void skipToStart();
void setForward(bool forward);
bool forward() const;
void setRepeatFromStart(bool repeat);
void setRepeatFwdBwd(bool repeat);
void setDefault();
private:
QTimer* m_timer;
int m_numFrames;
int m_currentFrame;
int m_timeout;
int m_lastTimeStamp;
bool m_forward;
bool m_repeatOn;
bool m_repeatFromStart;
bool m_repeatFwdBwd;
};
} // End namespace caf