Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkNavigationDataSequentialPlayerControlWidget.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 #include "ui_QmitkNavigationDataSequentialPlayerControlWidget.h"
19 
20 #include <QTimer>
21 
23  QWidget(parent),
25 {
26  ui->setupUi(this);
27  m_UpdateTimer = new QTimer();
28  connect( m_UpdateTimer, SIGNAL(timeout()), this, SLOT(OnUpdate()) );
29 }
30 
32 {
33  delete ui;
34 }
35 
37 {
38  m_Player = player;
39 
40  ui->samplePositionHorizontalSlider->setMaximum(player->GetNumberOfSnapshots());
41 }
42 
44 {
45  m_UpdateTimer->stop();
46  m_Player->GoToSnapshot(0);
47 
48  this->UpdatePlayerDisplay();
49 
50  // make sure that the play/pause button is not checked after stopping
51  ui->playPushButton->setChecked(false);
52 }
53 
55 {
56  if ( m_UpdateTimer->isActive() )
57  {
58  m_UpdateTimer->stop();
59  }
60  else
61  {
62  if ( m_Player->IsAtEnd() ) { m_Player->GoToSnapshot(0); }
63 
64  m_UpdateTimer->start(ui->updateIntervalSpinBox->value());
65  if ( ! ui->playPushButton->isChecked() ) { ui->playPushButton->setChecked(true); }
66  }
67 }
68 
70 {
71  this->OnStop();
72  this->OnPlayPause();
73 }
74 
76 {
77  // if the last snapshot was reached
78  if ( ! m_Player->GoToNextSnapshot() )
79  {
80  m_UpdateTimer->stop();
81  ui->playPushButton->setChecked(false);
82 
83  emit SignalEndReached();
84  }
85 
86  m_Player->Update();
87 
88  this->UpdatePlayerDisplay();
89 
90  emit SignalUpdate();
91 }
92 
94 {
95  m_UpdateTimer->setInterval(value);
96 }
97 
99 {
100  int currentSnapshotNumber = static_cast<int>(m_Player->GetCurrentSnapshotNumber());
101 
102  ui->sampleLCDNumber->display(currentSnapshotNumber);
103 
104  ui->samplePositionHorizontalSlider->setValue(currentSnapshotNumber);
105 }
itk::SmartPointer< Self > Pointer
void SetPlayer(mitk::NavigationDataSequentialPlayer::Pointer player)