COPASI API  4.16.103
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CQAnimationControls Class Reference

#include <CQAnimationControls.h>

Inheritance diagram for CQAnimationControls:
Inheritance graph
[legend]
Collaboration diagram for CQAnimationControls:
Collaboration graph
[legend]

Public Slots

void slotBack ()
 
void slotChangeInterval (int)
 
void slotForward ()
 
void slotShowStep (int)
 
void slotStepBack ()
 
void slotStepForward ()
 
void slotStop ()
 
void slotTogglePlayPause ()
 

Signals

void backward ()
 
void forward ()
 
void pause ()
 
void play ()
 
void showStep (int)
 
void step_backward ()
 
void step_forward ()
 
void stop ()
 

Public Member Functions

 CQAnimationControls (QWidget *parent=NULL)
 
bool isPlaying () const
 
void setCurrentStep (size_t currentStep)
 
void setNumSteps (size_t numSteps)
 
virtual ~CQAnimationControls ()
 

Protected Member Functions

void createActions ()
 
void updateActions ()
 
void updateButtons ()
 

Protected Attributes

size_t mCurrentStep
 
size_t mNumSteps
 
QTimer * mpTimer
 
bool mShouldLoop
 

Detailed Description

Definition at line 15 of file CQAnimationControls.h.

Constructor & Destructor Documentation

CQAnimationControls::CQAnimationControls ( QWidget *  parent = NULL)

Definition at line 11 of file CQAnimationControls.cpp.

References CQIconResource::backward, CQIconResource::forward, CQIconResource::icon(), mNumSteps, mpTimer, CQIconResource::play, CQIconResource::skipBackward, CQIconResource::skipForward, slotStepForward(), and CQIconResource::stop.

12  : QWidget(parent)
13  , mNumSteps(100)
14  , mCurrentStep(0)
15  , mShouldLoop(true)
16  , mpTimer(new QTimer(this))
17 {
18 
19  setupUi(this);
20 
23  cmdStepBack->setIcon(CQIconResource::icon(CQIconResource::backward));
24  cmdStepForward->setIcon(CQIconResource::icon(CQIconResource::forward));
25  cmdPlayPause->setIcon(CQIconResource::icon(CQIconResource::play));
26  cmdStop->setIcon(CQIconResource::icon(CQIconResource::stop));
27 
28  mpTimer->setInterval(1000 / 10); // 10fps default
29  lblDuration->setText(QString::number(mNumSteps));
30  connect(mpTimer, SIGNAL(timeout()), this, SLOT(slotStepForward()));
31 }
static const QIcon & icon(const IconID &id)
CQAnimationControls::~CQAnimationControls ( )
virtual

Definition at line 72 of file CQAnimationControls.cpp.

73 {
74 }

Member Function Documentation

void CQAnimationControls::backward ( )
signal

Referenced by slotBack().

void CQAnimationControls::createActions ( )
protected
void CQAnimationControls::forward ( )
signal

Referenced by slotForward().

bool CQAnimationControls::isPlaying ( ) const

Definition at line 67 of file CQAnimationControls.cpp.

References mpTimer.

Referenced by slotTogglePlayPause().

68 {
69  return mpTimer->isActive();
70 }
void CQAnimationControls::pause ( )
signal

Referenced by slotTogglePlayPause().

void CQAnimationControls::play ( )
signal

Referenced by slotTogglePlayPause().

void CQAnimationControls::setCurrentStep ( size_t  currentStep)

Definition at line 48 of file CQAnimationControls.cpp.

References mCurrentStep, mNumSteps, updateActions(), and updateButtons().

49 {
50  if (currentStep < mNumSteps)
51  {
52  mCurrentStep = currentStep;
53  }
54  else if (mNumSteps > 0)
55  {
56  mCurrentStep = mNumSteps - 1;
57  }
58  else
59  {
60  mCurrentStep = 0;
61  }
62 
63  updateButtons();
64  updateActions();
65 }
void CQAnimationControls::setNumSteps ( size_t  numSteps)

Definition at line 38 of file CQAnimationControls.cpp.

References mNumSteps.

39 {
40  if (mNumSteps == numSteps) return;
41 
42  mNumSteps = numSteps;
43  sldPosition->setMaximum(numSteps - 1);
44  lblCurrent->setText(QString::number(sldPosition->minimum() + 1));
45  lblDuration->setText(QString::number(numSteps));
46 }
void CQAnimationControls::showStep ( int  )
signal

Referenced by slotShowStep().

void CQAnimationControls::slotBack ( )
slot

Definition at line 76 of file CQAnimationControls.cpp.

References backward().

77 {
78  emit backward();
79  sldPosition->setValue(0);
80 }
void CQAnimationControls::slotChangeInterval ( int  interval)
slot

Definition at line 33 of file CQAnimationControls.cpp.

References mpTimer.

34 {
35  mpTimer->setInterval(interval);
36 }
void CQAnimationControls::slotForward ( )
slot

Definition at line 82 of file CQAnimationControls.cpp.

References forward(), and mNumSteps.

83 {
84  emit forward();
85  sldPosition->setValue(mNumSteps - 1);
86 }
void CQAnimationControls::slotShowStep ( int  step)
slot

Definition at line 146 of file CQAnimationControls.cpp.

References mCurrentStep, showStep(), updateActions(), and updateButtons().

147 {
148  mCurrentStep = step;
149  lblCurrent->setText(QString::number(step + 1));
150  updateButtons();
151  updateActions();
152  emit showStep(step);
153 }
void CQAnimationControls::slotStepBack ( )
slot

Definition at line 106 of file CQAnimationControls.cpp.

References mCurrentStep, and step_backward().

107 {
108  emit step_backward();
109  sldPosition->setValue(mCurrentStep < 2 ? 0 : --mCurrentStep);
110 }
void CQAnimationControls::slotStepForward ( )
slot

Definition at line 112 of file CQAnimationControls.cpp.

References mCurrentStep, mNumSteps, mShouldLoop, slotStop(), and step_forward().

Referenced by CQAnimationControls().

113 {
114  emit step_forward();
115 
116  int next;
117 
118  if (mCurrentStep >= mNumSteps - 1)
119  {
120  if (mShouldLoop)
121  {
122  next = 0;
123  }
124  else
125  {
126  slotStop();
127  return;
128  }
129  }
130  else
131  {
132  next = ++mCurrentStep;
133  }
134 
135  sldPosition->setValue(next);
136 }
void CQAnimationControls::slotStop ( )
slot

Definition at line 138 of file CQAnimationControls.cpp.

References CQIconResource::icon(), mpTimer, CQIconResource::play, and stop().

Referenced by slotStepForward().

139 {
140  mpTimer->stop();
141  cmdPlayPause->setIcon(CQIconResource::icon(CQIconResource::play));
142  emit stop();
143  sldPosition->setValue(0);
144 }
static const QIcon & icon(const IconID &id)
void CQAnimationControls::slotTogglePlayPause ( )
slot

Definition at line 88 of file CQAnimationControls.cpp.

References CQIconResource::icon(), isPlaying(), mpTimer, pause(), CQIconResource::pause, play(), and CQIconResource::play.

89 {
90  bool playing = isPlaying();
91 
92  if (playing)
93  {
94  mpTimer->stop();
95  emit pause();
96  cmdPlayPause->setIcon(CQIconResource::icon(CQIconResource::play));
97  }
98  else
99  {
100  mpTimer->start();
101  emit play();
102  cmdPlayPause->setIcon(CQIconResource::icon(CQIconResource::pause));
103  }
104 }
static const QIcon & icon(const IconID &id)
void CQAnimationControls::step_backward ( )
signal

Referenced by slotStepBack().

void CQAnimationControls::step_forward ( )
signal

Referenced by slotStepForward().

void CQAnimationControls::stop ( )
signal

Referenced by slotStop().

void CQAnimationControls::updateActions ( )
protected

Definition at line 158 of file CQAnimationControls.cpp.

Referenced by setCurrentStep(), and slotShowStep().

159 {
160 }
void CQAnimationControls::updateButtons ( )
protected

Definition at line 155 of file CQAnimationControls.cpp.

Referenced by setCurrentStep(), and slotShowStep().

156 {
157 }

Member Data Documentation

size_t CQAnimationControls::mCurrentStep
protected

Definition at line 48 of file CQAnimationControls.h.

Referenced by setCurrentStep(), slotShowStep(), slotStepBack(), and slotStepForward().

size_t CQAnimationControls::mNumSteps
protected
QTimer* CQAnimationControls::mpTimer
protected
bool CQAnimationControls::mShouldLoop
protected

Definition at line 49 of file CQAnimationControls.h.

Referenced by slotStepForward().


The documentation for this class was generated from the following files: