NorMIT-nav  22.09
An IGT application
cxGraphicalPrimitives.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXGRAPHICALPRIMITIVES_H_
13 #define CXGRAPHICALPRIMITIVES_H_
14 
15 #include "cxResourceVisualizationExport.h"
16 
17 #include <boost/shared_ptr.hpp>
18 #include "vtkForwardDeclarations.h"
19 #include "cxTransform3D.h"
20 #include "cxViewportListener.h"
21 #include <vtkPolyDataAlgorithm.h>
22 #include <vtkGlyph3DMapper.h>
23 #include <vtkColorSeries.h>
24 #include <vtkLookupTable.h>
25 #include <vtkMapper.h>
26 
27 class QColor;
28 typedef vtkSmartPointer<class vtkPolyDataAlgorithm> vtkPolyDataAlgorithmPtr;
29 typedef vtkSmartPointer<class vtkArcSource> vtkArcSourcePtr;
30 typedef vtkSmartPointer<class vtkArrowSource> vtkArrowSourcePtr;
31 
32 namespace cx
33 {
34 
35 
36 class cxResourceVisualization_EXPORT GraphicalGeometricBase
37 {
38 public:
40  vtkRendererPtr renderer = vtkRendererPtr());
42 
43  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
44  void setSource(vtkPolyDataAlgorithmPtr source);
45  void setBackfaceCulling(bool val);
46  void setVisibility(bool visible);
47  void setFrontfaceCulling(bool val);
48  // void setRepresentation();
49  void setColor(double red, double green, double blue);
50  void setColor(Vector3D color);
51  void setPosition(Vector3D point);
52 
53 
54  void setOpacity(double val);
55  void setUserMatrix(vtkMatrix4x4 *matrix);
56  void setPointSize(int pointSize);
57  void setScalarVisibility(bool show);
58  void setScalarModeToUseCellData();
59 
60  vtkActorPtr getActor();
61  vtkPropertyPtr getProperty();
62  vtkPolyDataPtr getPolyData();
63  Vector3D getPosition() const;
64  vtkPolyDataAlgorithmPtr getSource();
65 
66 protected:
72  virtual vtkMapperPtr getMapper()=0;
73 };
74 
75 
83 class cxResourceVisualization_EXPORT GraphicalPolyData3D : public GraphicalGeometricBase
84 {
85 public:
87  vtkRendererPtr renderer = vtkRendererPtr());
88  void setIsWireFrame(bool val);
89  // void setRepresentation();
90  void setData(vtkPolyDataPtr data);
91  void setTexture(vtkTexturePtr texture);
92  vtkMapperPtr getMapper();
93 
94 private:
95  vtkPolyDataMapperPtr mMapper;
96 };
97 typedef boost::shared_ptr<GraphicalPolyData3D> GraphicalPolyData3DPtr;
98 
99 
102 class cxResourceVisualization_EXPORT GraphicalGlyph3DData : public GraphicalGeometricBase
103 {
104 public:
106  vtkRendererPtr renderer = vtkRendererPtr());
107  void setData(vtkPolyDataPtr data);
108  void setOrientationArray(const char* orientationArray);
109  void setColorArray(const char* colorArray);
110  void setLUT(const char* lut);
111  void setScaleFactor(double scaleFactor);
112  vtkMapperPtr getMapper();
113 
114 private:
115  vtkGlyph3DMapperPtr mMapper;
116 };
117 typedef boost::shared_ptr<GraphicalGlyph3DData> GraphicalGlyph3DDataPtr;
118 
119 
122 class cxResourceVisualization_EXPORT GraphicalPoint3D
123 {
124 public:
126  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
127  ~GraphicalPoint3D();
128  void setRadius(double radius);
129  // void setColor(Vector3D color);
130  void setColor(QColor color);
131  void setValue(Vector3D point);
132  Vector3D getValue() const;
133  vtkActorPtr getActor();
134  vtkPolyDataPtr getPolyData();
135 
136 private:
137  vtkSphereSourcePtr source;
138  vtkPolyDataMapperPtr mapper;
139  vtkActorPtr actor;
140  vtkRendererPtr mRenderer;
141 };
142 typedef boost::shared_ptr<GraphicalPoint3D> GraphicalPoint3DPtr;
143 
146 class cxResourceVisualization_EXPORT GraphicalLine3D
147 {
148 public:
150  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
151  ~GraphicalLine3D();
152  void setColor(QColor color);
153  void setValue(Vector3D point1, Vector3D point2);
154  void setStipple(int stipple);
155  vtkActorPtr getActor();
156 
157 private:
158  vtkPolyDataMapperPtr mapper;
159  vtkActorPtr actor;
160  vtkRendererPtr mRenderer;
161  vtkLineSourcePtr source;
162 };
163 typedef boost::shared_ptr<GraphicalLine3D> GraphicalLine3DPtr;
164 
167 class cxResourceVisualization_EXPORT GraphicalArc3D
168 {
169 public:
171  ~GraphicalArc3D();
172  void setColor(QColor color);
173  void setValue(Vector3D point1, Vector3D point2, Vector3D center);
174  void setStipple(int stipple);
175  vtkActorPtr getActor();
176 
177 private:
178  vtkPolyDataMapperPtr mapper;
179  vtkActorPtr actor;
180  vtkRendererPtr mRenderer;
181  vtkArcSourcePtr source;
182 };
183 typedef boost::shared_ptr<GraphicalArc3D> GraphicalArc3DPtr;
184 
187 class cxResourceVisualization_EXPORT GraphicalArrow3D
188 {
189 public:
191  ~GraphicalArrow3D();
192  void setColor(QColor color);
193  void setValue(Vector3D base, Vector3D normal, double length);
194 
195 private:
196  vtkPolyDataMapperPtr mapper;
197  vtkActorPtr actor;
198  vtkRendererPtr mRenderer;
199  vtkArrowSourcePtr source;
200 };
201 typedef boost::shared_ptr<GraphicalArrow3D> GraphicalArrow3DPtr;
202 
205 class cxResourceVisualization_EXPORT Rect3D
206 {
207 public:
208  Rect3D(vtkRendererPtr renderer, QColor color);
209  ~Rect3D();
210  void setColor(QColor color);
211  void updatePosition(const DoubleBoundingBox3D bb, const Transform3D& M);
212  void setLine(bool on, int width);
213  void setSurface(bool on);
214 
215 private:
216  vtkPolyDataMapperPtr mapper;
217  vtkActorPtr actor;
218  vtkRendererPtr mRenderer;
219  vtkPolyDataPtr mPolyData;
220  vtkPointsPtr mPoints;
221  vtkCellArrayPtr mSide;
222 };
223 typedef boost::shared_ptr<class Rect3D> Rect3DPtr;
224 
228 class cxResourceVisualization_EXPORT FollowerText3D
229 {
230 public:
232  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
233 
234  ~FollowerText3D();
235  void setColor(QColor color);
236  void setText(QString text);
237  void setPosition(Vector3D pos);
238 
239  void setSize(double val);
240  void setSizeInNormalizedViewport(bool on, double size);
241  vtkFollowerPtr getActor();
242 
243  void scaleText();
244 
245 private:
246  vtkVectorTextPtr mText;
247  vtkFollowerPtr mFollower;
248  vtkRendererPtr mRenderer;
249  double mSize;
250 
251  ViewportListenerPtr mViewportListener;
252 };
253 typedef boost::shared_ptr<FollowerText3D> FollowerText3DPtr;
254 
258 class cxResourceVisualization_EXPORT CaptionText3D
259 {
260 public:
262  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
263 
264  ~CaptionText3D();
265  void setColor(QColor color);
266  void setText(QString text);
267  void setPosition(Vector3D pos);
268 
269  void setSize(double val);
270  // void setSizeInNormalizedViewport(bool on, double size);
271  vtkCaptionActor2DPtr getActor();
272 
273  // void scaleText(); ///< internal method
274 
275  void placeBelowCenter();
276  void placeAboveCenter();
277  void setVisibility(bool visible);
278  Vector3D getPosition() const;
279 private:
280  vtkCaptionActor2DPtr mText;
281  // vtkFollowerPtr mFollower;
282  vtkRendererPtr mRenderer;
283  Vector3D mPos;
284 
285  // ViewportListenerPtr mViewportListener;
286 };
287 typedef boost::shared_ptr<CaptionText3D> CaptionText3DPtr;
288 
293 }
294 
295 #endif /*CXGRAPHICALPRIMITIVES_H_*/
vtkCellArrayPtr
vtkSmartPointer< class vtkCellArray > vtkCellArrayPtr
Definition: vtkForwardDeclarations.h:41
cx::GraphicalPoint3DPtr
boost::shared_ptr< class GraphicalPoint3D > GraphicalPoint3DPtr
Definition: cxForwardDeclarations.h:74
cx::GraphicalGeometricBase::mSource
vtkPolyDataAlgorithmPtr mSource
Definition: cxGraphicalPrimitives.h:67
cx::CaptionText3D
Helper for rendering 3D text that faces the camera and has a constant viewed size,...
Definition: cxGraphicalPrimitives.h:258
cx::DoubleBoundingBox3D
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,...
Definition: cxBoundingBox3D.h:63
cx::FollowerText3D
Helper for rendering 3D text that faces the camera and has a constant viewed size.
Definition: cxGraphicalPrimitives.h:228
vtkMapperPtr
vtkSmartPointer< class vtkMapper > vtkMapperPtr
Definition: vtkForwardDeclarations.h:89
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
vtkFollowerPtr
vtkSmartPointer< class vtkFollower > vtkFollowerPtr
Definition: vtkForwardDeclarations.h:58
cx::GraphicalLine3D
Helper for rendering a line in 3D.
Definition: cxGraphicalPrimitives.h:146
cx::GraphicalGlyph3DDataPtr
boost::shared_ptr< GraphicalGlyph3DData > GraphicalGlyph3DDataPtr
Definition: cxGraphicalPrimitives.h:117
vtkCaptionActor2DPtr
vtkSmartPointer< class vtkCaptionActor2D > vtkCaptionActor2DPtr
Definition: vtkForwardDeclarations.h:40
vtkPolyDataMapperPtr
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
Definition: vtkForwardDeclarations.h:112
cx::CaptionText3DPtr
boost::shared_ptr< CaptionText3D > CaptionText3DPtr
Definition: cxGraphicalPrimitives.h:287
cx::GraphicalGeometricBase::mRenderer
vtkRendererPtr mRenderer
Definition: cxGraphicalPrimitives.h:71
cx::GraphicalGeometricBase::mActor
vtkActorPtr mActor
Definition: cxGraphicalPrimitives.h:69
cx::ViewportListenerPtr
boost::shared_ptr< class ViewportListener > ViewportListenerPtr
Definition: cxForwardDeclarations.h:170
length
RealScalar length() const
Definition: cxMatrixBaseEigenAddons.h:35
cx::GraphicalGeometricBase
Definition: cxGraphicalPrimitives.h:36
cx::Rect3DPtr
boost::shared_ptr< class Rect3D > Rect3DPtr
Definition: cxForwardDeclarations.h:87
cx::GraphicalGlyph3DData
Helper for rendering a a glyph in 3D.
Definition: cxGraphicalPrimitives.h:102
cx::Rect3D
Helper for drawing a rectangle in 3D.
Definition: cxGraphicalPrimitives.h:205
cx::GraphicalArrow3D
Helper for rendering an arrow in 3D.
Definition: cxGraphicalPrimitives.h:187
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxViewportListener.h
cx::vtkPointsPtr
vtkSmartPointer< vtkPoints > vtkPointsPtr
Definition: cxCenterlineRegistration.h:41
vtkForwardDeclarations.h
cx::GraphicalArrow3DPtr
boost::shared_ptr< GraphicalArrow3D > GraphicalArrow3DPtr
Definition: cxGraphicalPrimitives.h:201
vtkGlyph3DMapperPtr
vtkSmartPointer< class vtkGlyph3DMapper > vtkGlyph3DMapperPtr
Definition: vtkForwardDeclarations.h:61
vtkPropertyPtr
vtkSmartPointer< class vtkProperty > vtkPropertyPtr
Definition: vtkForwardDeclarations.h:120
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::GraphicalPoint3D
Helper for rendering a point in 3D.
Definition: cxGraphicalPrimitives.h:122
vtkActorPtr
vtkSmartPointer< class vtkActor > vtkActorPtr
Definition: vtkForwardDeclarations.h:31
cx::GraphicalGeometricBase::mData
vtkPolyDataPtr mData
Definition: cxGraphicalPrimitives.h:70
vtkPolyDataAlgorithmPtr
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
Definition: cxViewWrapper.h:29
cx::FollowerText3DPtr
boost::shared_ptr< FollowerText3D > FollowerText3DPtr
Definition: cxGraphicalPrimitives.h:253
normal
PlainObject normal() const
Definition: cxMatrixBaseEigenAddons.h:27
vtkTexturePtr
vtkSmartPointer< class vtkTexture > vtkTexturePtr
Definition: vtkForwardDeclarations.h:140
cx::GraphicalLine3DPtr
boost::shared_ptr< class GraphicalLine3D > GraphicalLine3DPtr
Definition: cxForwardDeclarations.h:73
cx::GraphicalPolyData3D
Helper for rendering a a polydata in 3D.
Definition: cxGraphicalPrimitives.h:83
vtkArrowSourcePtr
vtkSmartPointer< class vtkArrowSource > vtkArrowSourcePtr
Definition: cxGraphicalPrimitives.h:30
cx::GraphicalPolyData3DPtr
boost::shared_ptr< GraphicalPolyData3D > GraphicalPolyData3DPtr
Definition: cxGraphicalPrimitives.h:97
vtkVectorTextPtr
vtkSmartPointer< class vtkVectorText > vtkVectorTextPtr
Definition: vtkForwardDeclarations.h:149
cxTransform3D.h
vtkSphereSourcePtr
vtkSmartPointer< class vtkSphereSource > vtkSphereSourcePtr
Definition: vtkForwardDeclarations.h:130
cx::GraphicalArc3D
Helper for rendering a line in 3D.
Definition: cxGraphicalPrimitives.h:167
cx::GraphicalArc3DPtr
boost::shared_ptr< GraphicalArc3D > GraphicalArc3DPtr
Definition: cxGraphicalPrimitives.h:183
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
vtkArcSourcePtr
vtkSmartPointer< class vtkArcSource > vtkArcSourcePtr
Definition: cxGraphicalPrimitives.h:29
vtkRendererPtr
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
Definition: vtkForwardDeclarations.h:122
vtkLineSourcePtr
vtkSmartPointer< class vtkLineSource > vtkLineSourcePtr
Definition: vtkForwardDeclarations.h:87
cx::GraphicalGeometricBase::mProperty
vtkPropertyPtr mProperty
Definition: cxGraphicalPrimitives.h:68
vtkPolyDataAlgorithmPtr
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
Definition: cxGraphicalPrimitives.h:27