fw4spl
visu/visuVTKAdaptor/include/visuVTKAdaptor/SLandmarks.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 __VISUVTKADAPTOR_SLANDMARKS_HPP__
8 #define __VISUVTKADAPTOR_SLANDMARKS_HPP__
9 
10 #include "visuVTKAdaptor/config.hpp"
11 
12 #include <fwData/Landmarks.hpp>
13 
14 #include <fwRenderVTK/IAdaptor.hpp>
15 #include <fwRenderVTK/vtk/fwHandleRepresentation3D.hpp>
16 
17 #include <fwThread/Timer.hpp>
18 
19 #include <vtkHandleWidget.h>
20 #include <vtkSmartPointer.h>
21 
22 class vtkCommand;
23 class vtkActor2D;
24 
25 namespace visuVTKAdaptor
26 {
27 
64 class VISUVTKADAPTOR_CLASS_API SLandmarks : public ::fwRenderVTK::IAdaptor
65 {
66 
67 public:
68 
71 
73  typedef vtkSmartPointer< vtkHandleWidget > LandmarkWidgetType;
74 
75  VISUVTKADAPTOR_API SLandmarks() noexcept;
76 
77  VISUVTKADAPTOR_API virtual ~SLandmarks() noexcept;
78 
79  VISUVTKADAPTOR_API virtual void show(bool b = true);
80 
82  void deselect();
83 
84 protected:
85 
86  VISUVTKADAPTOR_API void configuring() override;
87  VISUVTKADAPTOR_API void starting() override;
88  VISUVTKADAPTOR_API void updating() override;
89  VISUVTKADAPTOR_API void stopping() override;
90 
99  VISUVTKADAPTOR_API virtual KeyConnectionsMap getAutoConnections() const override;
100 
101 private:
102 
104  typedef std::vector< LandmarkWidgetType > LandmarksWidgetContainerType;
105 
107  typedef std::map< std::string, LandmarksWidgetContainerType > GroupWidgetsMapType;
108 
110  typedef std::map< LandmarkWidgetType, vtkActor2D* > WidgetLabelMapType;
111 
113  typedef std::map< LandmarkWidgetType, vtkCommand* > WidgetCommandMapType;
114 
115  typedef std::pair< std::string, size_t > PointPairType;
116 
118  void addPoint(std::string groupName);
119 
121  void insertPoint(std::string groupName, size_t index);
122 
124  void removePoint(std::string groupName, size_t index);
125 
127  void modifyGroup(std::string groupName);
128 
130  void removeGroup(std::string groupName);
131 
133  void addGroup(std::string groupName);
134 
136  void modifyPoint(std::string groupName, size_t index);
137 
139  void renameGroup(std::string oldName, std::string newName);
140 
142  void selectPoint(std::string groupName, size_t index);
143 
145  void deselectPoint(std::string groupName, size_t index);
146 
148  void changeColor(const vtkSmartPointer< ::fwRenderVTK::vtk::fwHandleRepresentation3D >& rep,
149  const std::array<double, 3>& color1, const std::array<double, 3>& color2);
150 
152  void clearLandmarks();
153 
155  vtkSmartPointer<vtkHandleWidget> newHandle(const ::fwData::Landmarks::sptr& landmarks,
156  const std::string& groupName,
157  size_t pointIndex);
158 
160  vtkCommand* m_noSelectionCommand;
161 
163  GroupWidgetsMapType m_handles;
164 
166  WidgetLabelMapType m_labels;
167 
169  WidgetCommandMapType m_commands;
170 
172  ::fwThread::Timer::sptr m_timer;
173 
175  PointPairType m_selectedPoint;
176 
178  size_t m_count;
179 
181  bool m_interaction;
182 
183 };
184 
185 } //namespace visuVTKAdaptor
186 
187 #endif // __VISUVTKADAPTOR_SLANDMARKS_HPP__
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
The namespace visuVTKAdaptor contains the list of adaptors available for the generic scene...
STL namespace.
#define fwCoreAllowSharedFromThis()
Generate getSptr and getConstSptr methods.
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
vtkSmartPointer< vtkHandleWidget > LandmarkWidgetType
Widget used to display and interact with landmarks.
The namespace fwRenderVTK contains classes for rendering with VTK.
Contains the representation of the data objects used in the framework.
This namespace fwThread provides few tools to execute asynchronous tasks on different threads...
Adaptor for landmarks in the field of an image.