Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkNavigationDataPlayerControlWidget.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_QmitkNavigationDataPlayerControlWidget.h"
19 
20 #include <QTimer>
21 
23  QWidget(parent),
24  m_UpdateTimer(new QTimer(this)),
26 {
27  ui->setupUi(this);
28 
29  connect(m_UpdateTimer, SIGNAL(timeout()), this, SLOT(OnUpdate()));
30 }
31 
33 {
34  delete ui;
35 }
36 
38 {
39  m_Player = player;
40 
41  ui->samplePositionHorizontalSlider->setMaximum(player->GetNumberOfSnapshots()-1);
42 }
43 
45 {
46  m_UpdateTimer->stop();
47  m_Player->StopPlaying();
48 
49  ui->playPushButton->setChecked(false);
50 
51  this->ResetPlayerDisplay();
52 }
53 
55 {
56  switch ( m_Player->GetCurrentPlayerState() )
57  {
59  {
60  m_Player->StartPlaying();
61  if ( ! m_UpdateTimer->isActive() ) { m_UpdateTimer->start(10); }
62  if ( ! ui->playPushButton->isChecked() ) { ui->playPushButton->setChecked(true); }
63  break;
64  }
66  {
67  m_Player->Resume();
68  break;
69  }
71  {
72  m_Player->Pause();
73  break;
74  }
75  }
76 }
77 
79 {
80  this->OnStop();
81  this->OnPlayPause();
82 }
83 
85 {
86  m_Player->Update();
87 
88  int msc = static_cast<int>(m_Player->GetTimeStampSinceStart());
89 
90  // calculation for playing time display
91  int ms = msc % 1000;
92  msc = (msc - ms) / 1000;
93  int s = msc % 60;
94  int min = (msc-s) / 60;
95 
96  // set lcd numbers
97  ui->msecLCDNumber->display(ms);
98  ui->secLCDNumber->display(s);
99  ui->minLCDNumber->display(min);
100 
101  ui->samplePositionHorizontalSlider->setValue(static_cast<int>(m_Player->GetCurrentSnapshotNumber()));
102 
103  emit SignalUpdate();
104 
105  if ( m_Player->GetCurrentPlayerState() == mitk::NavigationDataPlayer::PlayerStopped )
106  {
107  m_UpdateTimer->stop();
108  ui->playPushButton->setChecked(false);
109 
110  emit SignalEndReached();
111  }
112 }
113 
114 void QmitkNavigationDataPlayerControlWidget::ResetPlayerDisplay()
115 {
116  // set lcd numbers
117  ui->msecLCDNumber->display(0);
118  ui->secLCDNumber->display(0);
119  ui->minLCDNumber->display(0);
120 
121  ui->samplePositionHorizontalSlider->setValue(0);
122 }
void SetPlayer(mitk::NavigationDataPlayer::Pointer player)
itk::SmartPointer< Self > Pointer
static T min(T x, T y)
Definition: svm.cpp:67