Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkPrimitiveMovieNavigatorWidget.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
16  : QWidget(parent, fl)
17 {
18  m_Controls.setupUi(this);
19 
20  // signals and slots connections
21  connect(m_Controls.m_SpinBox, SIGNAL(valueChanged(int)), this, SLOT(spinBoxValueChanged(int)));
22  connect(m_Controls.m_StopButton, SIGNAL(clicked()), this, SLOT(stopButton_clicked()));
23  connect(m_Controls.m_GoButton, SIGNAL(clicked()), this, SLOT(goButton_clicked()));
24  connect(m_Controls.m_TimerInterval, SIGNAL(valueChanged(int)), this, SLOT(setTimerInterval(int)));
25 
26  m_InRefetch = true; // this avoids trying to use m_Stepper until it is set to something != nullptr (additionally to the
27  // avoiding recursions during refetching)
28  m_Timer = new QTimer(this);
29  m_TimerIntervalInMS = 120;
30  connect(m_Timer, SIGNAL(timeout()), SLOT(next()));
31 }
32 
33 /*
34  * Destroys the object and frees any allocated resources
35  */
37 {
38  // no need to delete child widgets, Qt does it all for us
39 }
40 
42 {
43  if (!m_InRefetch)
44  {
45  m_InRefetch = true;
46  m_Controls.m_SpinBox->setMinimum(0);
47  m_Controls.m_SpinBox->setMaximum(m_Stepper->GetSteps() - 1);
48  m_Controls.m_SpinBox->setValue(m_Stepper->GetPos());
49  m_InRefetch = false;
50  }
51 }
52 
54 {
55  m_Stepper = stepper;
56  m_InRefetch = (stepper == nullptr); // this avoids trying to use m_Stepper until it is set to something != nullptr
57  // (additionally to the avoiding recursions during refetching)
58 }
59 
61 {
62  if (!m_InRefetch &&
63  m_Stepper->GetSteps() >
64  0) // this step shall only be used if the dataset is 3D+t. If it is not, nothing happens :-)
65  {
66  if (m_Timer->isActive() == false)
67  {
69  }
70  }
71 }
72 
74 {
75  m_Timer->stop();
76 }
77 
78 void QmitkPrimitiveMovieNavigatorWidget::next()
79 {
80  if (!m_InRefetch)
81  {
82  if (m_Stepper->GetPos() == m_Stepper->GetSteps() - 1)
83  m_Stepper->First();
84  else
85  m_Stepper->Next();
86  }
87 }
88 
90 {
91  if (!m_InRefetch)
92  {
93  m_Stepper->SetPos(m_Controls.m_SpinBox->value());
94  }
95 }
96 
98 {
99  return m_TimerIntervalInMS;
100 }
101 
103 {
104  if (timerIntervalInMS != m_TimerIntervalInMS)
105  {
106  m_TimerIntervalInMS = timerIntervalInMS;
107  if (m_Timer->isActive())
108  {
109  m_Timer->setInterval(m_TimerIntervalInMS);
110  }
111  }
112 }
virtual void setTimerInterval(int timerIntervalInMS)
QmitkPrimitiveMovieNavigatorWidget(QWidget *parent=nullptr, Qt::WindowFlags fl=nullptr)
Helper class to step through a list.
Definition: mitkStepper.h:47
virtual void SetStepper(mitk::Stepper *stepper)