fw4spl
fwHandleRepresentation3D.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 __FWRENDERVTK_VTK_FWHANDLEREPRESENTATION3D_HPP__
8 #define __FWRENDERVTK_VTK_FWHANDLEREPRESENTATION3D_HPP__
9 
10 #include "fwRenderVTK/config.hpp"
11 
12 #include <vtkPolygonalHandleRepresentation3D.h>
13 #include <vtkSmartPointer.h>
14 
15 class vtkCubeSource;
16 class vtkSphereSource;
17 class vtkCleanPolyData;
18 class vtkPolyDataAlgorithm;
19 
20 namespace fwRenderVTK
21 {
22 
23 namespace vtk
24 {
25 
29 class FWRENDERVTK_CLASS_API fwHandleRepresentation3D : public vtkPolygonalHandleRepresentation3D
30 {
31 public:
32 
33  enum Shape
34  {
35  SPHERE,
36  CUBE
37  };
38 
39  // Description:
40  // Instantiate this class.
41  FWRENDERVTK_API static fwHandleRepresentation3D* New();
42 
43  // Description:
44  // Standard vtk methods
45  vtkTypeMacro(fwHandleRepresentation3D,
46  vtkPolygonalHandleRepresentation3D);
47  FWRENDERVTK_API void PrintSelf(ostream& os, vtkIndent indent) override;
48 
49  // Description:
50  // Set the position of the point in world and display coordinates.
51  FWRENDERVTK_API virtual void SetWorldPosition(double p[3]) override;
52 
53  // Description:
54  // Set/Get the radius factor of the marker (must be > 1 to be visible)
55  FWRENDERVTK_API vtkSetMacro( MarkerRadiusFactor, double );
56  FWRENDERVTK_API vtkGetMacro( MarkerRadiusFactor, double );
57 
58  // Description:
59  // Define the shape of the representation (SPHERE or CUBE)
60  FWRENDERVTK_API void SetShapeRepresentation( Shape shape);
61  FWRENDERVTK_API vtkGetMacro( ShapeRepresentation, Shape );
62 
63  // Description:
64  // Set/Get the handle properties for marker.
65  FWRENDERVTK_API void SetMarkerProperty(vtkProperty*);
66  FWRENDERVTK_API vtkGetObjectMacro(MarkerProperty, vtkProperty);
67 
68  // Description:
69  // For some exporters and other other operations we must be
70  // able to collect all the actors or volumes. These methods
71  // are used in that process.
72  FWRENDERVTK_API virtual void GetActors(vtkPropCollection*) override;
73 
74  // Description:
75  // Release any graphics resources that are being consumed by this actor.
76  // The parameter window could be used to determine which graphic
77  // resources to release.
78  FWRENDERVTK_API virtual void ReleaseGraphicsResources(vtkWindow*) override;
79 
80  // Description:
81  // Support the standard render methods.
82  FWRENDERVTK_API virtual int RenderOpaqueGeometry(vtkViewport* viewport) override;
83  FWRENDERVTK_API virtual int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
84 
85  // Description:
86  // Does this prop have some translucent polygonal geometry?
87  FWRENDERVTK_API virtual int HasTranslucentPolygonalGeometry() override;
88 
89 protected:
92 
93  // Description:
94  // Recomputes the handle world size based on the set display size.
95  virtual void BuildRepresentation() override;
96 
97  // Create default properties for markers
98  void CreateDefaultProperties();
99 
100  vtkSmartPointer<vtkCubeSource> CubeSource;
101  vtkSmartPointer<vtkSphereSource> SphereSource;
102  Shape ShapeRepresentation;
103 
104  // the cursor3D
105  vtkSmartPointer<vtkFollower> Follower;
106  vtkSmartPointer<vtkCleanPolyData> CleanPolyData;
107  vtkSmartPointer<vtkPolyDataMapper> MarkerMapper;
108  vtkSmartPointer<vtkPolyDataAlgorithm> Marker;
109 
110  double MarkerRadiusFactor;
111 
112  // Properties used to control the appearance of selected objects and
113  // the manipulator in general.
114  vtkProperty* MarkerProperty;
115 
116 private:
117  fwHandleRepresentation3D(const fwHandleRepresentation3D&); //Not implemented
118  void operator=(const fwHandleRepresentation3D&); //Not implemented
119 };
120 
121 } // namespace vtk
122 
123 } // namespace fwRenderVTK
124 
125 #endif //__FWRENDERVTK_VTK_FWHANDLEREPRESENTATION3D_HPP__
126 
3D Representation to be used with vtkHandleWidget (represents a cube or a sphere).
The namespace fwRenderVTK contains classes for rendering with VTK.