fw4spl
MedicalImageSrv.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 "ctrlSelection/MedicalImageSrv.hpp"
8 
9 #include <fwCom/Signal.hxx>
10 #include <fwCom/Slots.hxx>
11 
12 #include <fwData/Image.hpp>
13 
14 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp>
15 #include <fwDataTools/helper/Image.hpp>
16 
17 #include <fwServices/macros.hpp>
18 
19 namespace ctrlSelection
20 {
21 
22 //-----------------------------------------------------------------------------
23 
25 
26 //-----------------------------------------------------------------------------
27 
28 MedicalImageSrv::MedicalImageSrv() noexcept
29 {
30 }
31 
32 //-----------------------------------------------------------------------------
33 
34 MedicalImageSrv::~MedicalImageSrv() noexcept
35 {
36 }
37 
38 //-----------------------------------------------------------------------------
39 
40 void MedicalImageSrv::convertImage()
41 {
42  ::fwData::Image::sptr pImg = this->getInOut< ::fwData::Image >("image");
44  {
45  ::fwDataTools::helper::Image helper( pImg );
46 
47  bool isModified = false;
48  isModified |= helper.createLandmarks();
49  isModified |= helper.createTransferFunctionPool();
50  isModified |= helper.createImageSliceIndex();
51 
52  if (isModified)
53  {
55  ::fwCom::Connection::Blocker block(sig->getConnection(m_slotUpdate));
56  helper.notify();
57  }
58  }
59 }
60 
61 //-----------------------------------------------------------------------------
62 
64 {
65  this->convertImage();
66 }
67 
68 //-----------------------------------------------------------------------------
69 
71 {
72 }
73 
74 //-----------------------------------------------------------------------------
75 
77 {
78  this->convertImage();
79 }
80 
81 //-----------------------------------------------------------------------------
82 
84 {
85 }
86 
87 //-----------------------------------------------------------------------------
88 
90 {
91 }
92 
93 //-----------------------------------------------------------------------------
94 
96 {
97  this->convertImage();
98 }
99 
100 //-----------------------------------------------------------------------------
101 
102 void MedicalImageSrv::info( std::ostream& )
103 {
104 }
105 
106 //-----------------------------------------------------------------------------
107 
109 {
110  KeyConnectionsMap connections;
111  connections.push("image", ::fwData::Image::s_MODIFIED_SIG, s_UPDATE_SLOT);
112  connections.push("image", ::fwData::Image::s_BUFFER_MODIFIED_SIG, s_UPDATE_SLOT);
113 
114  return connections;
115 }
116 
117 //-----------------------------------------------------------------------------
118 
119 } // ctrlSelection
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
Class allowing to block a Connection.
Definition: Connection.hpp:20
virtual CTRLSELECTION_API void reconfiguring() override
Implements reconfiguring method derived from IService. Do nothing.
virtual CTRLSELECTION_API void configuring() override
Implements configuring method derived from IService. Do nothing.
virtual CTRLSELECTION_API void info(std::ostream &_sstream) override
Implements info method derived from IService. Print classname.
UpdateSlotType::sptr m_slotUpdate
Slot to call update method.
Definition: IService.hpp:690
Defines an helper to modify an fwData::Image by adding few medical fields and create in parallel the ...
This interface defines control service API. Does nothing particularly, can be considered as a default...
Definition: IController.hpp:23
virtual CTRLSELECTION_API void stopping() override
Implements stopping method derived from IService. Do nothing.
virtual CTRLSELECTION_API void updating() override
Implements updating method derived from IService. Do nothing.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_BUFFER_MODIFIED_SIG
Type of signal when image&#39;s buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
static FWDATATOOLS_API bool checkImageValidity(::fwData::Image::csptr _pImg)
Check if the image is valid.
This class defines an image.
virtual CTRLSELECTION_API void swapping() override
Implements swapping method derived from IService. Convert the image.
virtual CTRLSELECTION_API void starting() override
Implements starting method derived from IService. Convert the image.
The namespace ctrlSelection contains several interfaces for manager, updater and wrapper.
Definition: BookmarkSrv.hpp:15
virtual CTRLSELECTION_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
Definition: IService.hpp:177
This service convert its attached image to a medical image by adding specific fields.