fw4spl
src/fwGui/dialog/PulseProgressDialog.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 "fwGui/dialog/PulseProgressDialog.hpp"
8 
9 #include <fwServices/registry/ActiveWorkers.hpp>
10 
11 namespace fwGui
12 {
13 namespace dialog
14 {
15 //-----------------------------------------------------------------------------
16 
18  const std::string& title,
19  ::fwGui::dialog::IPulseProgressDialog::Stuff stuff,
20  const std::string& msg,
21  ::fwGui::dialog::IPulseProgressDialog::MilliSecond frequenceRefresh )
22 {
23 
24  ::fwServices::registry::ActiveWorkers::getDefaultWorker()->postTask<void>(std::function<void()>(
25  [&] {
26  ::fwGui::GuiBaseObject::sptr guiObj = ::fwGui::factory::New(IPulseProgressDialog::REGISTRY_KEY);
27  m_implementation = ::fwGui::dialog::IPulseProgressDialog::dynamicCast(guiObj);
28  if (m_implementation)
29  {
30  m_implementation->setStuff(stuff);
31  m_implementation->setTitle(title);
32  m_implementation->setMessage(msg);
33  m_implementation->setFrequence(frequenceRefresh);
34  }
35  else
36  {
37  this->setStuff(stuff);
38  }
39  } )).wait();
40 }
41 
42 //-----------------------------------------------------------------------------
43 
44 void PulseProgressDialog::setTitle(const std::string& title)
45 {
46  if (m_implementation)
47  {
48  m_implementation->setTitle(title);
49  }
50 }
51 
52 //-----------------------------------------------------------------------------
53 
54 void PulseProgressDialog::setMessage(const std::string& msg)
55 {
56  if (m_implementation)
57  {
58  m_implementation->setMessage(msg);
59  }
60 }
61 
62 //-----------------------------------------------------------------------------
63 
65 {
66  if (m_implementation)
67  {
69  std::bind(&IPulseProgressDialog::show, m_implementation)).wait();
70  }
71  else
72  {
73  m_stuff();
74  }
75 }
76 
77 //-----------------------------------------------------------------------------
78 
79 } //namespace dialog
80 } //namespace fwGui
virtual FWGUI_API void show()=0
show the pulse progress dialog
FWGUI_API PulseProgressDialog(const std::string &title, Stuff stuff, const std::string &msg=std::string(),::fwGui::dialog::IPulseProgressDialog::MilliSecond frequenceRefresh=100)
will instantiate the concrete implementation
FWGUI_API void setMessage(const std::string &message) override
set the message for the dialog
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
virtual FWGUI_API void show() override
show the pulse progress dialog
FWGUI_API void setTitle(const std::string &title) override
set the title for the dialog
virtual FWGUI_API void setStuff(Stuff stuff)
set the stuff
static FWGUI_API const FactoryRegistryKeyType REGISTRY_KEY
this unique key should be used for all factory for specific LocationDialog(qt,wx,...)
static FWSERVICES_API::fwThread::Worker::sptr getDefaultWorker()
Get the default registered worker.