fw4spl
SProgressBarController.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "ioPacs/SProgressBarController.hpp"
8 
9 #include <fwCom/Slot.hpp>
10 #include <fwCom/Slot.hxx>
11 #include <fwCom/Slots.hpp>
12 #include <fwCom/Slots.hxx>
13 #include <fwData/Composite.hpp>
14 #include <fwGuiQt/container/QtContainer.hpp>
15 #include <fwGuiQt/dialog/ProgressDialog.hpp>
16 #include <fwServices/macros.hpp>
17 #include <fwServices/registry/ActiveWorkers.hpp>
18 
19 #include <boost/foreach.hpp>
20 
21 namespace ioPacs
22 {
23 
25 
26 static const ::fwCom::Slots::SlotKeyType s_START_PROGRESS_SLOT = "startProgress";
27 static const ::fwCom::Slots::SlotKeyType s_UPDATE_PROGRESS_SLOT = "updateProgress";
28 static const ::fwCom::Slots::SlotKeyType s_STOP_PROGRESS_SLOT = "stopProgress";
29 
30 //------------------------------------------------------------------------------
31 
33 {
34  newSlot(s_START_PROGRESS_SLOT, &SProgressBarController::startProgress, this);
35  newSlot(s_UPDATE_PROGRESS_SLOT, &SProgressBarController::updateProgress, this);
36  newSlot(s_STOP_PROGRESS_SLOT, &SProgressBarController::stopProgress, this);
37 }
38 //------------------------------------------------------------------------------
39 
41 {
42 }
43 
44 //------------------------------------------------------------------------------
45 
46 void SProgressBarController::info(std::ostream& _sstream )
47 {
48  _sstream << "SProgressBarController::info";
49 }
50 
51 //------------------------------------------------------------------------------
52 
54 {
56 }
57 
58 //------------------------------------------------------------------------------
59 
61 {
63 }
64 
65 //------------------------------------------------------------------------------
66 
68 {
70 }
71 
72 //------------------------------------------------------------------------------
73 
75 {
77 }
78 
79 //------------------------------------------------------------------------------
80 
81 void SProgressBarController::startProgress(std::string id)
82 {
83  ::fwCore::mt::ScopedLock lock(m_mutex);
84  m_progressDialogs[id] = ::fwGui::dialog::ProgressDialog::New();
85 }
86 
87 //------------------------------------------------------------------------------
88 
89 void SProgressBarController::updateProgress(std::string id, float percentage, std::string message)
90 {
91  ::fwCore::mt::ScopedLock lock(m_mutex);
92  if(m_progressDialogs.find(id) != m_progressDialogs.end())
93  {
94  (*m_progressDialogs[id])(percentage, message);
95  m_progressDialogs[id]->setMessage(message);
96  }
97  else
98  {
99  SLM_WARN("Trying to update a progress bar which is not started !");
100  }
101 
102 }
103 
104 //------------------------------------------------------------------------------
105 
106 void SProgressBarController::stopProgress(std::string id)
107 {
108  ::fwCore::mt::ScopedLock lock(m_mutex);
109  m_progressDialogs.erase(id);
110 }
111 
112 //------------------------------------------------------------------------------
113 
114 } // namespace ioPacs
This editor service is used to display a progress bar.
virtual IOPACS_API ~SProgressBarController() noexcept
destructor
IOPACS_API void updating() override
Override.
ioPacs contains services use to deal with PACS using DCMTK library.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
IOPACS_API void info(std::ostream &_sstream) override
Override.
::fwCore::mt::Mutex m_mutex
mutex for progress dialog access
IOPACS_API SProgressBarController() noexcept
constructor
#define SLM_WARN(message)
Definition: spyLog.hpp:261
virtual IOPACS_API void configuring() override
Configuring method. This method is used to configure the service.
This interface defines control service API. Does nothing particularly, can be considered as a default...
Definition: IController.hpp:23
ProgressDialogContainerType m_progressDialogs
Progress Dialog.
This class defines a composite object.
virtual IOPACS_API void starting() override
Override.
virtual IOPACS_API void stopping() override
Override.