Fraxinus  18.10
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 
59  vtkActorPtr getActor();
60  vtkPropertyPtr getProperty();
61  vtkPolyDataPtr getPolyData();
62  Vector3D getPosition() const;
63  vtkPolyDataAlgorithmPtr getSource();
64 
65 protected:
71  virtual vtkMapperPtr getMapper()=0;
72 };
73 
74 
82 class cxResourceVisualization_EXPORT GraphicalPolyData3D : public GraphicalGeometricBase
83 {
84 public:
86  vtkRendererPtr renderer = vtkRendererPtr());
87  void setIsWireFrame(bool val);
88  // void setRepresentation();
89  void setData(vtkPolyDataPtr data);
90  void setTexture(vtkTexturePtr texture);
91  vtkMapperPtr getMapper();
92 
93 private:
94  vtkPolyDataMapperPtr mMapper;
95 };
96 typedef boost::shared_ptr<GraphicalPolyData3D> GraphicalPolyData3DPtr;
97 
98 
101 class cxResourceVisualization_EXPORT GraphicalGlyph3DData : public GraphicalGeometricBase
102 {
103 public:
105  vtkRendererPtr renderer = vtkRendererPtr());
106  void setData(vtkPolyDataPtr data);
107  void setOrientationArray(const char* orientationArray);
108  void setColorArray(const char* colorArray);
109  void setLUT(const char* lut);
110  void setScaleFactor(double scaleFactor);
111  vtkMapperPtr getMapper();
112 
113 private:
114  vtkGlyph3DMapperPtr mMapper;
115 };
116 typedef boost::shared_ptr<GraphicalGlyph3DData> GraphicalGlyph3DDataPtr;
117 
118 
121 class cxResourceVisualization_EXPORT GraphicalPoint3D
122 {
123 public:
125  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
126  ~GraphicalPoint3D();
127  void setRadius(double radius);
128  // void setColor(Vector3D color);
129  void setColor(QColor color);
130  void setValue(Vector3D point);
131  Vector3D getValue() const;
132  vtkActorPtr getActor();
133  vtkPolyDataPtr getPolyData();
134 
135 private:
136  vtkSphereSourcePtr source;
137  vtkPolyDataMapperPtr mapper;
138  vtkActorPtr actor;
139  vtkRendererPtr mRenderer;
140 };
141 typedef boost::shared_ptr<GraphicalPoint3D> GraphicalPoint3DPtr;
142 
145 class cxResourceVisualization_EXPORT GraphicalLine3D
146 {
147 public:
149  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
150  ~GraphicalLine3D();
151  void setColor(QColor color);
152  void setValue(Vector3D point1, Vector3D point2);
153  void setStipple(int stipple);
154  vtkActorPtr getActor();
155 
156 private:
157  vtkPolyDataMapperPtr mapper;
158  vtkActorPtr actor;
159  vtkRendererPtr mRenderer;
160  vtkLineSourcePtr source;
161 };
162 typedef boost::shared_ptr<GraphicalLine3D> GraphicalLine3DPtr;
163 
166 class cxResourceVisualization_EXPORT GraphicalArc3D
167 {
168 public:
170  ~GraphicalArc3D();
171  void setColor(QColor color);
172  void setValue(Vector3D point1, Vector3D point2, Vector3D center);
173  void setStipple(int stipple);
174  vtkActorPtr getActor();
175 
176 private:
177  vtkPolyDataMapperPtr mapper;
178  vtkActorPtr actor;
179  vtkRendererPtr mRenderer;
180  vtkArcSourcePtr source;
181 };
182 typedef boost::shared_ptr<GraphicalArc3D> GraphicalArc3DPtr;
183 
186 class cxResourceVisualization_EXPORT GraphicalArrow3D
187 {
188 public:
190  ~GraphicalArrow3D();
191  void setColor(QColor color);
192  void setValue(Vector3D base, Vector3D normal, double length);
193 
194 private:
195  vtkPolyDataMapperPtr mapper;
196  vtkActorPtr actor;
197  vtkRendererPtr mRenderer;
198  vtkArrowSourcePtr source;
199 };
200 typedef boost::shared_ptr<GraphicalArrow3D> GraphicalArrow3DPtr;
201 
204 class cxResourceVisualization_EXPORT Rect3D
205 {
206 public:
207  Rect3D(vtkRendererPtr renderer, QColor color);
208  ~Rect3D();
209  void setColor(QColor color);
210  void updatePosition(const DoubleBoundingBox3D bb, const Transform3D& M);
211  void setLine(bool on, int width);
212  void setSurface(bool on);
213 
214 private:
215  vtkPolyDataMapperPtr mapper;
216  vtkActorPtr actor;
217  vtkRendererPtr mRenderer;
218  vtkPolyDataPtr mPolyData;
219  vtkPointsPtr mPoints;
220  vtkCellArrayPtr mSide;
221 };
222 typedef boost::shared_ptr<class Rect3D> Rect3DPtr;
223 
227 class cxResourceVisualization_EXPORT FollowerText3D
228 {
229 public:
231  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
232 
233  ~FollowerText3D();
234  void setColor(QColor color);
235  void setText(QString text);
236  void setPosition(Vector3D pos);
237 
238  void setSize(double val);
239  void setSizeInNormalizedViewport(bool on, double size);
240  vtkFollowerPtr getActor();
241 
242  void scaleText();
243 
244 private:
245  vtkVectorTextPtr mText;
246  vtkFollowerPtr mFollower;
247  vtkRendererPtr mRenderer;
248  double mSize;
249 
250  ViewportListenerPtr mViewportListener;
251 };
252 typedef boost::shared_ptr<FollowerText3D> FollowerText3DPtr;
253 
257 class cxResourceVisualization_EXPORT CaptionText3D
258 {
259 public:
261  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
262 
263  ~CaptionText3D();
264  void setColor(QColor color);
265  void setText(QString text);
266  void setPosition(Vector3D pos);
267 
268  void setSize(double val);
269  // void setSizeInNormalizedViewport(bool on, double size);
270  vtkCaptionActor2DPtr getActor();
271 
272  // void scaleText(); ///< internal method
273 
274  void placeBelowCenter();
275  void placeAboveCenter();
276  void setVisibility(bool visible);
277  Vector3D getPosition() const;
278 private:
279  vtkCaptionActor2DPtr mText;
280  // vtkFollowerPtr mFollower;
281  vtkRendererPtr mRenderer;
282  Vector3D mPos;
283 
284  // ViewportListenerPtr mViewportListener;
285 };
286 typedef boost::shared_ptr<CaptionText3D> CaptionText3DPtr;
287 
292 }
293 
294 #endif /*CXGRAPHICALPRIMITIVES_H_*/
vtkSmartPointer< class vtkTexture > vtkTexturePtr
vtkSmartPointer< class vtkActor > vtkActorPtr
boost::shared_ptr< class GraphicalPoint3D > GraphicalPoint3DPtr
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
PlainObject normal() const
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
boost::shared_ptr< class ViewportListener > ViewportListenerPtr
vtkSmartPointer< class vtkProperty > vtkPropertyPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkCellArray > vtkCellArrayPtr
boost::shared_ptr< GraphicalGlyph3DData > GraphicalGlyph3DDataPtr
Helper for rendering a line in 3D.
vtkSmartPointer< vtkPoints > vtkPointsPtr
boost::shared_ptr< GraphicalArc3D > GraphicalArc3DPtr
vtkSmartPointer< class vtkLineSource > vtkLineSourcePtr
Helper for rendering a point in 3D.
Helper for rendering an arrow in 3D.
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
vtkSmartPointer< class vtkFollower > vtkFollowerPtr
Helper for rendering a a polydata in 3D.
vtkSmartPointer< class vtkMapper > vtkMapperPtr
Helper for rendering a line in 3D.
vtkSmartPointer< class vtkCaptionActor2D > vtkCaptionActor2DPtr
Helper for rendering 3D text that faces the camera and has a constant viewed size, always on top.
vtkSmartPointer< class vtkSphereSource > vtkSphereSourcePtr
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Helper for rendering 3D text that faces the camera and has a constant viewed size.
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
vtkSmartPointer< class vtkVectorText > vtkVectorTextPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
vtkSmartPointer< class vtkGlyph3DMapper > vtkGlyph3DMapperPtr
boost::shared_ptr< FollowerText3D > FollowerText3DPtr
vtkSmartPointer< class vtkArcSource > vtkArcSourcePtr
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
Definition: cxViewWrapper.h:29
RealScalar length() const
boost::shared_ptr< GraphicalPolyData3D > GraphicalPolyData3DPtr
boost::shared_ptr< class GraphicalLine3D > GraphicalLine3DPtr
vtkSmartPointer< class vtkArrowSource > vtkArrowSourcePtr
Helper for rendering a a glyph in 3D.
boost::shared_ptr< CaptionText3D > CaptionText3DPtr
vtkPolyDataAlgorithmPtr mSource
boost::shared_ptr< class Rect3D > Rect3DPtr
boost::shared_ptr< GraphicalArrow3D > GraphicalArrow3DPtr
Helper for drawing a rectangle in 3D.
Namespace for all CustusX production code.