Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkProgressBar.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 
13 #include "QmitkProgressBar.h"
14 
15 #include "mitkProgressBar.h"
16 #include "mitkRenderingManager.h"
17 
18 #include <qapplication.h>
19 #include <qprogressbar.h>
20 
24 void QmitkProgressBar::Reset()
25 {
26  this->reset();
27  this->hide();
28  m_TotalSteps = 0;
29  m_Progress = 0;
30 }
31 
36 {
37  emit SignalSetPercentageVisible(visible);
38 }
39 
44 void QmitkProgressBar::AddStepsToDo(unsigned int steps)
45 {
46  emit SignalAddStepsToDo(steps);
47 }
48 
54 void QmitkProgressBar::Progress(unsigned int steps)
55 {
56  emit SignalProgress(steps);
57 }
58 
59 QmitkProgressBar::QmitkProgressBar(QWidget *parent, const char * /*name*/)
60  : QProgressBar(parent), ProgressBarImplementation()
61 {
62  m_TotalSteps = 0;
63  m_Progress = 0;
64  this->hide();
65  this->SetPercentageVisible(true);
66 
67  connect(this, SIGNAL(SignalAddStepsToDo(unsigned int)), this, SLOT(SlotAddStepsToDo(unsigned int)));
68  connect(this, SIGNAL(SignalProgress(unsigned int)), this, SLOT(SlotProgress(unsigned int)));
69  connect(this, SIGNAL(SignalSetPercentageVisible(bool)), this, SLOT(SlotSetPercentageVisible(bool)));
70 
72 }
73 
75 {
77 }
78 
79 void QmitkProgressBar::SlotProgress(unsigned int steps)
80 {
81  m_Progress += steps;
82  this->setValue(m_Progress);
83 
84  if (m_Progress >= m_TotalSteps)
85  Reset();
86  else
87  {
88  this->show();
89  }
90 
91  // Update views if repaint has been requested in the meanwhile
92  // (because Qt event loop is not reached while progress bar is updating,
93  // unless the application is threaded)
94  // qApp->processEvents();
96 }
97 
98 void QmitkProgressBar::SlotAddStepsToDo(unsigned int steps)
99 {
100  m_TotalSteps += steps;
101  this->setMaximum(m_TotalSteps);
102  this->setValue(m_Progress);
103  if (m_TotalSteps > 0)
104  {
105  this->show();
106  }
107 
108  // Update views if repaint has been requested in the meanwhile
109  // (because Qt event loop is not reached while progress bar is updating,
110  // unless the application is threaded)
112 }
113 
115 {
116  this->setTextVisible(visible);
117 }
void SetPercentageVisible(bool visible) override
Sets whether the current progress value is displayed.
void SignalSetPercentageVisible(bool visible)
void RegisterImplementationInstance(ProgressBarImplementation *implementation)
Supply a GUI- dependent ProgressBar. Has to be set by the application to connect the application depe...
void Progress(unsigned int steps) override
Sets the current amount of progress to current progress + steps.
virtual void SlotAddStepsToDo(unsigned int steps)
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
QmitkProgressBar(QWidget *parent=nullptr, const char *name=nullptr)
Constructor; holds param instance internally and connects this to the mitkProgressBar.
void SignalAddStepsToDo(unsigned int steps)
static RenderingManager * GetInstance()
~QmitkProgressBar() override
Destructor.
void UnregisterImplementationInstance(ProgressBarImplementation *implementation)
void AddStepsToDo(unsigned int steps) override
Adds steps to totalSteps.
virtual void SlotProgress(unsigned int steps)
wbAdvisor reset(new berry::WorkbenchAdvisor)
virtual void SlotSetPercentageVisible(bool visible)
void SignalProgress(unsigned int steps)