fw4spl
CrossTypeAction.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 "uiVisu/action/CrossTypeAction.hpp"
8 
9 #include <fwCom/Signal.hpp>
10 #include <fwCom/Signal.hxx>
11 #include <fwCom/Signals.hpp>
12 
13 #include <fwCore/base.hpp>
14 
15 #include <fwData/Float.hpp>
16 #include <fwData/Image.hpp>
17 
18 #include <fwRuntime/ConfigurationElement.hpp>
19 #include <fwRuntime/operations.hpp>
20 
21 #include <fwServices/IService.hpp>
22 #include <fwServices/macros.hpp>
23 #include <fwServices/op/Get.hpp>
24 
25 #include <boost/algorithm/string.hpp>
26 #include <boost/algorithm/string/trim.hpp>
27 
28 #include <boost/assign/list_of.hpp>
29 
30 
31 namespace uiVisu
32 {
33 namespace action
34 {
35 
36 fwServicesRegisterMacro( ::fwGui::IActionSrv, ::uiVisu::action::CrossTypeAction, ::fwData::Image );
37 
38 static const ::fwCom::Signals::SignalKeyType s_CROSS_TYPE_MODIFIED_SIG = "crossTypeModified";
39 
40 std::map< std::string, float >
41 CrossTypeAction::m_scaleConversion
42  = ::boost::assign::map_list_of(std::string("full"),1.0)
43  (std::string("half"),0.5)
44  (std::string("hide"),0.0);
45 
47 {
48  m_sigCrossTypeModified = newSignal< CrossTypeModifiedSignalType >(s_CROSS_TYPE_MODIFIED_SIG);
49 }
50 
51 //------------------------------------------------------------------------------
52 
54 {
55 }
56 
57 //------------------------------------------------------------------------------
58 
60 {
63 }
64 
65 //------------------------------------------------------------------------------
66 
68 {
71 }
72 
73 //------------------------------------------------------------------------------
74 
76 {
79 
80  if( this->m_configuration->size() > 0 )
81  {
82  std::vector < ConfigurationType > vectConfig = this->m_configuration->find("crossType");
83  SLM_ASSERT("Missing <crossType> tag!", !vectConfig.empty());
84  m_crossType = vectConfig.at(0)->getValue();
85  ::boost::algorithm::trim(m_crossType);
86  ::boost::algorithm::to_lower(m_crossType);
87  SLM_ASSERT("Unknown crossType", m_scaleConversion.find(m_crossType) != m_scaleConversion.end());
88  }
89 }
90 
91 //------------------------------------------------------------------------------
92 
94 {
95  m_sigCrossTypeModified->asyncEmit(m_scaleConversion[m_crossType]);
96 }
97 
98 //------------------------------------------------------------------------------
99 
101 {
102 
103 }
104 
105 //------------------------------------------------------------------------------
106 
107 void CrossTypeAction::info( std::ostream &_sstream )
108 {
109 }
110 
111 
112 //------------------------------------------------------------------------------
113 
114 } // action
115 } // uiVisu
116 
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
Definition: IActionSrv.cpp:160
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
virtual void starting() override
Starts action.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Definition: IActionSrv.cpp:153
void updating() override
Notifies message to change cross type.
UIVISU_API CrossTypeAction() noexcept
Constructor. Do nothing.
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
The namespace uiVisu contains action to modifies cross type and 3D camera orientation.
virtual UIVISU_API ~CrossTypeAction() noexcept
Destructor. Do nothing.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
FWGUI_API void initialize()
Initialize the action.
Definition: IActionSrv.cpp:69
void swapping() override
Does nothing.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
Definition: IService.hpp:670
This action allows change the cross type.
virtual void info(std::ostream &_sstream) override
Write information in a stream.
void configuring() override
Configure action.
This class defines an image.
virtual void stopping() override
Stops action.