Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
20  : QWidget(parent, fl)
21 {
22  m_Controls.setupUi(this);
23 
24  // signals and slots connections
25  connect(m_Controls.m_SpinBox, SIGNAL(valueChanged(int)), this, SLOT(spinBoxValueChanged(int)));
26  connect(m_Controls.m_StopButton, SIGNAL(clicked()), this, SLOT(stopButton_clicked()));
27  connect(m_Controls.m_GoButton, SIGNAL(clicked()), this, SLOT(goButton_clicked()));
28  connect(m_Controls.m_TimerInterval, SIGNAL(valueChanged(int)), this, SLOT(setTimerInterval(int)));
29 
30  m_InRefetch = true; // this avoids trying to use m_Stepper until it is set to something != NULL (additionally to the
31  // avoiding recursions during refetching)
32  m_Timer = new QTimer(this);
33  m_TimerIntervalInMS = 120;
34  connect(m_Timer, SIGNAL(timeout()), SLOT(next()));
35 }
36 
37 /*
38  * Destroys the object and frees any allocated resources
39  */
41 {
42  // no need to delete child widgets, Qt does it all for us
43 }
44 
46 {
47  if (!m_InRefetch)
48  {
49  m_InRefetch = true;
50  m_Controls.m_SpinBox->setMinimum(0);
51  m_Controls.m_SpinBox->setMaximum(m_Stepper->GetSteps() - 1);
52  m_Controls.m_SpinBox->setValue(m_Stepper->GetPos());
53  m_InRefetch = false;
54  }
55 }
56 
58 {
59  m_Stepper = stepper;
60  m_InRefetch = (stepper == nullptr); // this avoids trying to use m_Stepper until it is set to something != NULL
61  // (additionally to the avoiding recursions during refetching)
62 }
63 
65 {
66  if (!m_InRefetch &&
67  m_Stepper->GetSteps() >
68  0) // this step shall only be used if the dataset is 3D+t. If it is not, nothing happens :-)
69  {
70  if (m_Timer->isActive() == false)
71  {
73  }
74  }
75 }
76 
78 {
79  m_Timer->stop();
80 }
81 
82 void QmitkPrimitiveMovieNavigatorWidget::next()
83 {
84  if (!m_InRefetch)
85  {
86  if (m_Stepper->GetPos() == m_Stepper->GetSteps() - 1)
87  m_Stepper->First();
88  else
89  m_Stepper->Next();
90  }
91 }
92 
94 {
95  if (!m_InRefetch)
96  {
97  m_Stepper->SetPos(m_Controls.m_SpinBox->value());
98  }
99 }
100 
102 {
103  return m_TimerIntervalInMS;
104 }
105 
107 {
108  if (timerIntervalInMS != m_TimerIntervalInMS)
109  {
110  m_TimerIntervalInMS = timerIntervalInMS;
111  if (m_Timer->isActive())
112  {
113  m_Timer->setInterval(m_TimerIntervalInMS);
114  }
115  }
116 }
virtual void setTimerInterval(int timerIntervalInMS)
QmitkPrimitiveMovieNavigatorWidget(QWidget *parent=nullptr, Qt::WindowFlags fl=nullptr)
Helper class to step through a list.
Definition: mitkStepper.h:51
virtual void SetStepper(mitk::Stepper *stepper)