fw4spl
src/fwGui/dialog/MultiSelectorDialog.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/MultiSelectorDialog.hpp"
8 
9 #include <fwServices/registry/ActiveWorkers.hpp>
10 
11 namespace fwGui
12 {
13 namespace dialog
14 {
15 //-----------------------------------------------------------------------------
16 
18 {
19  ::fwServices::registry::ActiveWorkers::getDefaultWorker()->postTask< void >(std::function< void() >(
20  [this] {
21  ::fwGui::GuiBaseObject::sptr guiObj = ::fwGui::factory::New(IMultiSelectorDialog::REGISTRY_KEY);
22  m_implementation = ::fwGui::dialog::IMultiSelectorDialog::dynamicCast(guiObj);
23  })).wait();
24 }
25 
26 //-----------------------------------------------------------------------------
27 
28 void MultiSelectorDialog::setTitle(std::string title)
29 {
31  [&] {
32  m_implementation->setTitle(title);
33  }).wait();
34 }
35 
36 //-----------------------------------------------------------------------------
37 
38 IMultiSelectorDialog::Selections MultiSelectorDialog::show()
39 {
40  typedef IMultiSelectorDialog::Selections R;
41  std::function< R() > func = std::bind( &IMultiSelectorDialog::show, m_implementation);
42  std::shared_future< R > f = ::fwServices::registry::ActiveWorkers::getDefaultWorker()->postTask< R >(func);
43 
44  f.wait();
45  return f.get();
46 }
47 
48 //-----------------------------------------------------------------------------
49 
50 void MultiSelectorDialog::setSelections(Selections _selections)
51 {
53  [&] {
54  m_implementation->setSelections( _selections );
55  }).wait();
56 }
57 
58 //-----------------------------------------------------------------------------
59 
60 void MultiSelectorDialog::setMessage(const std::string& msg)
61 {
63  [&] {
64  m_implementation->setMessage( msg );
65  }).wait();
66 }
67 
68 //-----------------------------------------------------------------------------
69 
70 } //namespace dialog
71 } //namespace fwGui
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
virtual FWGUI_API Selections show()=0
Show the selector and return the selection.
FWGUI_API void setTitle(std::string title) override
Sets the selector title.
FWGUI_API Selections show() override
Show the selector and return the selection.
static FWGUI_API const FactoryRegistryKeyType REGISTRY_KEY
this unique key should be used for all factory for specific Selector(qt,wx,...)
static FWSERVICES_API::fwThread::Worker::sptr getDefaultWorker()
Get the default registered worker.
FWGUI_API MultiSelectorDialog()
will instanciate the concrete implementation
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
virtual FWGUI_API void setSelections(Selections _selections) override
Set the string list that can be chosen by the selector.