fw4spl
core/fwData/include/fwData/Image.hpp
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 #ifndef __FWDATA_IMAGE_HPP__
8 #define __FWDATA_IMAGE_HPP__
9 
10 #include "fwData/Array.hpp"
11 #include "fwData/factory/new.hpp"
12 #include "fwData/Object.hpp"
13 
14 #include <fwCom/Signal.hpp>
15 #include <fwCom/Signals.hpp>
16 
17 #include <fwTools/DynamicType.hpp>
18 #include <fwTools/Type.hpp>
19 
20 #include <boost/filesystem/path.hpp>
21 #include <boost/shared_array.hpp>
22 
23 #include <vector>
24 
25 fwCampAutoDeclareDataMacro((fwData)(Image), FWDATA_API);
26 
27 namespace fwData
28 {
29 
30 class Point;
31 class PointList;
32 
38 class FWDATA_CLASS_API Image : public Object
39 {
40 public:
41  fwCoreClassDefinitionsWithFactoryMacro( (Image)(::fwData::Object), (()), ::fwData::factory::New< Image > );
43  fwCampMakeFriendDataMacro((fwData)(Image));
44 
48  typedef ::fwData::Array::SizeType SizeType;
49 
53  typedef std::vector< double > SpacingType;
54 
58  typedef std::vector< double > OriginType;
59 
60  typedef SizeType::value_type IndexType;
61  typedef size_t BufferIndexType;
62  typedef std::uint8_t BufferType;
63  typedef ::boost::shared_array< BufferType > SharedArray;
64 
69  FWDATA_API Image(::fwData::Object::Key key);
70 
74  FWDATA_API virtual ~Image() noexcept;
75 
77  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
78 
80  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
81 
83  FWDATA_API void copyInformation( Image::csptr _source );
84 
86  FWDATA_API size_t getNumberOfDimensions() const;
87 
92  FWDATA_API const SpacingType& getSpacing() const;
93  FWDATA_API void setSpacing(const SpacingType& spacing);
95 
99  FWDATA_API const OriginType& getOrigin() const;
100  FWDATA_API void setOrigin(const OriginType& origin);
102 
106  FWDATA_API const SizeType& getSize() const;
107  FWDATA_API void setSize(const SizeType& size);
109 
113  double getWindowCenter () const;
114 
115  void setWindowCenter (double val);
117 
121  double getWindowWidth () const;
122  void setWindowWidth (double val);
124 
128  size_t getNumberOfComponents() const;
129 
130  void setNumberOfComponents(size_t val);
132 
140  FWDATA_API void setDataArray(::fwData::Array::sptr array, bool copyArrayInfo = true);
141 
143  FWDATA_API ::fwData::Array::sptr getDataArray() const;
144 
148  FWDATA_API void setType(::fwTools::Type type);
149  FWDATA_API void setType(const std::string& type);
150  FWDATA_API ::fwTools::Type getType() const;
152 
154  FWDATA_API ::fwTools::DynamicType getPixelType() const;
155 
166  FWDATA_API size_t allocate();
167  FWDATA_API size_t allocate(SizeType::value_type x, SizeType::value_type y, SizeType::value_type z,
168  const ::fwTools::Type& type, size_t numberOfComponents = 1);
169  FWDATA_API size_t allocate(const SizeType& size, const ::fwTools::Type& type, size_t numberOfComponents = 1);
171 
173  FWDATA_API size_t getSizeInBytes() const;
175  FWDATA_API size_t getAllocatedSizeInBytes() const;
176 
181  typedef ::fwCom::Signal< void () > BufferModifiedSignalType;
183  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_BUFFER_MODIFIED_SIG;
184 
186  typedef ::fwCom::Signal< void (SPTR(::fwData::Point)) > LandmarkAddedSignalType;
187  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_LANDMARK_ADDED_SIG;
188 
190  typedef ::fwCom::Signal< void (SPTR(::fwData::Point)) > LandmarkRemovedSignalType;
191  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_LANDMARK_REMOVED_SIG;
192 
194  typedef ::fwCom::Signal< void (bool) > LandmarkDisplayedSignalType;
195  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_LANDMARK_DISPLAYED_SIG;
196 
198  typedef ::fwCom::Signal< void (bool) > DistanceDisplayedSignalType;
199  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_DISTANCE_DISPLAYED_SIG;
200 
202  typedef ::fwCom::Signal< void (SPTR(::fwData::PointList)) > DistanceAddedSignalType;
203  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_DISTANCE_ADDED_SIG;
204 
206  typedef ::fwCom::Signal< void (CSPTR(::fwData::PointList)) > DistanceRemovedSignalType;
207  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_DISTANCE_REMOVED_SIG;
208 
210  typedef ::fwCom::Signal< void (int, int, int) > SliceIndexModifiedSignalType;
211  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_SLICE_INDEX_MODIFIED_SIG;
212 
214  typedef ::fwCom::Signal< void (int, int) > SliceTypeModifiedSignalType;
215  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_SLICE_TYPE_MODIFIED_SIG;
216 
218  typedef ::fwCom::Signal< void (bool) > VisibilityModifiedSignalType;
219  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_VISIBILITY_MODIFIED_SIG;
220 
222  typedef ::fwCom::Signal< void () > TransparencyModifiedSignalType;
223  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_TRANSPARENCY_MODIFIED_SIG;
224 
229 protected:
230 
232  SizeType m_size;
233 
235  ::fwTools::Type m_type;
236 
238  SpacingType m_spacing;
239 
241  OriginType m_origin;
242 
245  double m_windowCenter;
246  double m_windowWidth;
248 
250  size_t m_numberOfComponents;
251 
253  ::fwData::Array::sptr m_dataArray;
254 };
255 
256 //-----------------------------------------------------------------------------
257 
258 inline double Image::getWindowCenter () const
259 {
260  return m_windowCenter;
261 }
262 
263 //-----------------------------------------------------------------------------
264 
265 inline void Image::setWindowCenter (double val)
266 {
267  m_windowCenter = val;
268 }
269 
270 //-----------------------------------------------------------------------------
271 
272 inline double Image::getWindowWidth () const
273 {
274  return m_windowWidth;
275 }
276 
277 //-----------------------------------------------------------------------------
278 
279 inline void Image::setWindowWidth (double val)
280 {
281  m_windowWidth = val;
282 }
283 
284 //-----------------------------------------------------------------------------
285 
286 inline size_t Image::getNumberOfComponents() const
287 {
288  return m_numberOfComponents;
289 }
290 
291 //-----------------------------------------------------------------------------
292 
293 inline void Image::setNumberOfComponents(size_t val)
294 {
295  m_numberOfComponents = val;
296 }
297 
298 //-----------------------------------------------------------------------------
299 
300 } // namespace fwData
301 
302 #endif // __FWDATA_IMAGE_HPP__
303 
#define SPTR(_cls_)
#define CSPTR(_cls_)
The namespace fwTools contains several tools like UUID, factory, dispatche, stringizer, macros, helper.
void setWindowWidth(double val)
Get/set preferred window width.
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
This class define a 3D point.
Definition: Point.hpp:22
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
STL namespace.
size_t getNumberOfComponents() const
Get/set preferred window center.
Provides a way to manage a view on a multidimentionnal array.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
double getWindowWidth() const
Get/set preferred window width.
void setNumberOfComponents(size_t val)
Get/set preferred window center.
Base class for each data object.
This class defines a list of points.
#define fwCoreAllowSharedFromThis()
Generate getSptr and getConstSptr methods.
std::vector< double > SpacingType
Image spacing type.
Contains the representation of the data objects used in the framework.
This class defines an image.
void setWindowCenter(double val)
Get/set preferred window center.
::fwData::Array::SizeType SizeType
Image size type.
std::vector< double > OriginType
Image origin type.