fw4spl
fwData/include/fwData/Landmarks.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 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_LANDMARKS_HPP__
8 #define __FWDATA_LANDMARKS_HPP__
9 
10 #include "fwData/config.hpp"
11 #include "fwData/factory/new.hpp"
12 #include "fwData/Object.hpp"
13 
14 #include <array>
15 #include <map>
16 #include <vector>
17 
18 fwCampAutoDeclareDataMacro((fwData)(Landmarks), FWDATA_API);
19 
20 namespace fwData
21 {
25 class FWDATA_CLASS_API Landmarks : public Object
26 {
27 
28 public:
29 
30  typedef std::array< float, 4 > ColorType;
31  typedef std::array< double, 3 > PointType;
32  typedef float SizeType;
33  typedef std::vector< PointType > PointContainer;
34  typedef std::vector< std::string > GroupNameContainer;
35 
36  enum class Shape
37  {
38  SPHERE,
39  CUBE
40  };
41 
43  {
44  LandmarksGroup(ColorType color, SizeType size, Shape shape, bool visibility) :
45  m_color(color),
46  m_size(size),
47  m_shape(shape),
48  m_visibility(visibility)
49  {
50  }
51 
52  ColorType m_color;
53  SizeType m_size;
54  Shape m_shape;
55  bool m_visibility;
56  PointContainer m_points;
57  };
58 
59  fwCoreClassDefinitionsWithFactoryMacro( (Landmarks)(::fwData::Object), (()), ::fwData::factory::New< Landmarks > );
60 
61  fwCampMakeFriendDataMacro((fwData)(Landmarks));
62 
67  FWDATA_API Landmarks(::fwData::Object::Key key);
68 
70  FWDATA_API virtual ~Landmarks();
71 
73  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
74 
76  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
77 
83  FWDATA_API void addGroup(const std::string& name, const ColorType& color = {{1.0f, 1.0f, 1.0f, 1.0f}},
84  const SizeType size = 1.0f, const Shape shape = Shape::SPHERE,
85  const bool visibility = true);
86 
88  FWDATA_API const GroupNameContainer getGroupNames() const;
89 
95  FWDATA_API const LandmarksGroup& getGroup(const std::string& name) const;
96 
102  FWDATA_API LandmarksGroup& getGroup(const std::string& name);
103 
109  FWDATA_API void renameGroup(const std::string& oldName, const std::string& newName);
110 
116  FWDATA_API void removeGroup(const std::string& name);
117 
125  FWDATA_API void setGroupColor(const std::string& name, const ColorType& color);
126 
132  FWDATA_API void setGroupSize(const std::string& name, const SizeType size);
133 
139  FWDATA_API void setGroupShape(const std::string& name, const Shape shape);
140 
146  FWDATA_API void setGroupVisibility(const std::string& name, const bool visibility);
147 
153  FWDATA_API void addPoint(const std::string& name, const PointType& point);
154 
160  FWDATA_API void insertPoint(const std::string& name, const size_t index, const PointType& point);
161 
167  FWDATA_API const PointType& getPoint(const std::string& name, size_t index) const;
168 
174  FWDATA_API PointType& getPoint(const std::string& name, size_t index);
175 
181  FWDATA_API const PointContainer& getPoints(const std::string& name) const;
182 
188  FWDATA_API void removePoint(const std::string& name, size_t index);
189 
195  FWDATA_API void clearPoints(const std::string& name);
196 
198  size_t getNumberOfGroups() const;
199 
201  FWDATA_API size_t getNumberOfPoints() const;
202 
204  FWDATA_API size_t getNumberOfPoints(const std::string& name) const;
205 
210  typedef ::fwCom::Signal< void (std::string name) > GroupAddedSignalType;
212  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_GROUP_ADDED_SIG;
213 
215  typedef ::fwCom::Signal< void (std::string name) > GroupRemovedSignalType;
216  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_GROUP_REMOVED_SIG;
217 
219  typedef ::fwCom::Signal< void (std::string name) > PointAddedSignalType;
220  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_ADDED_SIG;
221 
223  typedef ::fwCom::Signal< void (std::string name, size_t index) > PointRemovedSignalType;
224  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG;
225 
227  typedef ::fwCom::Signal< void (std::string name, size_t index) > PointInsertedSignalType;
228  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_INSERTED_SIG;
229 
231  typedef ::fwCom::Signal< void (std::string name, size_t index) > PointModifiedSigType;
232  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_MODIFIED_SIG;
233 
235  typedef ::fwCom::Signal< void (std::string name) > GroupModifiedSignalType;
236  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_GROUP_MODIFIED_SIG;
237 
239  typedef ::fwCom::Signal< void (std::string oldName, std::string newName) > GroupRenamedSignalType;
240  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_GROUP_RENAMED_SIG;
241 
243  typedef ::fwCom::Signal< void (std::string name, size_t index) > PointSelectedSignalType;
244  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_SELECTED_SIG;
245 
247  typedef ::fwCom::Signal< void (std::string name, size_t index) > PointDeselectedSignalType;
248  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_DESELECTED_SIG;
249 
254 private:
255 
256  typedef std::map< std::string, LandmarksGroup > LandmarksContainer;
257  LandmarksContainer m_landmarks;
258 }; // end class Landmarks
259 
260 //------------------------------------------------------------------------------
261 
262 inline size_t Landmarks::getNumberOfGroups() const
263 {
264  return m_landmarks.size();
265 }
266 
267 } // end namespace fwData
268 
269 #endif // __FWDATA_LANDMARKS_HPP__
270 
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_INSERTED_SIG
Type of signal when a group is added.
This class defines a list of 3D points inside groups.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_DESELECTED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_ADDED_SIG
Type of signal when a group is added.
::fwCom::Signal< void(std::string name) > GroupRemovedSignalType
Type of signal when a group is removed.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_REMOVED_SIG
Type of signal when a group is added.
::fwCom::Signal< void(std::string oldName, std::string newName) > GroupRenamedSignalType
Type of signal when a group is renamed.
::fwCom::Signal< void(std::string name) > GroupModifiedSignalType
Type of signal when group properties changed.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_SELECTED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_ADDED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_RENAMED_SIG
Type of signal when a group is added.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
::fwCom::Signal< void(std::string name, size_t index) > PointInsertedSignalType
Type of signal when a point is inserted.
Base class for each data object.
::fwCom::Signal< void(std::string name, size_t index) > PointSelectedSignalType
Type of signal when point is selected.
Contains the representation of the data objects used in the framework.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_MODIFIED_SIG
Type of signal when a group is added.
::fwCom::Signal< void(std::string name) > PointAddedSignalType
Type of signal when a point is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_MODIFIED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG
Type of signal when a group is added.
size_t getNumberOfGroups() const
Return the number of groups.
::fwCom::Signal< void(std::string name, size_t index) > PointDeselectedSignalType
Type of signal when point is deselected.
::fwCom::Signal< void(std::string name, size_t index) > PointRemovedSignalType
Type of signal when a point is removed.
::fwCom::Signal< void(std::string name, size_t index) > PointModifiedSigType
Type of signal when a point is modified.