Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXGRAPHICALPRIMITIVES_H_
34 #define CXGRAPHICALPRIMITIVES_H_
35 
36 #include "cxResourceVisualizationExport.h"
37 
38 #include <boost/shared_ptr.hpp>
39 #include "vtkForwardDeclarations.h"
40 #include "cxTransform3D.h"
41 #include "cxViewportListener.h"
42 #include <vtkPolyDataAlgorithm.h>
43 #include <vtkGlyph3DMapper.h>
44 #include <vtkColorSeries.h>
45 #include <vtkLookupTable.h>
46 #include <vtkMapper.h>
47 
48 class QColor;
49 typedef vtkSmartPointer<class vtkPolyDataAlgorithm> vtkPolyDataAlgorithmPtr;
50 typedef vtkSmartPointer<class vtkArcSource> vtkArcSourcePtr;
51 typedef vtkSmartPointer<class vtkArrowSource> vtkArrowSourcePtr;
52 
53 namespace cx
54 {
55 
56 
57 class cxResourceVisualization_EXPORT GraphicalGeometricBase
58 {
59 public:
61  vtkRendererPtr renderer = vtkRendererPtr());
63 
64  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
65  void setSource(vtkPolyDataAlgorithmPtr source);
66  void setBackfaceCulling(bool val);
67  void setVisibility(bool visible);
68  void setFrontfaceCulling(bool val);
69  void setRepresentation();
70  void setColor(double red, double green, double blue);
71  void setColor(Vector3D color);
72  void setPosition(Vector3D point);
73 
74 
75  void setOpacity(double val);
76  void setUserMatrix(vtkMatrix4x4 *matrix);
77  void setPointSize(int pointSize);
78  void setScalarVisibility(bool show);
79 
80  vtkActorPtr getActor();
81  vtkPolyDataPtr getPolyData();
82  Vector3D getPosition() const;
83  vtkPolyDataAlgorithmPtr getSource();
84 
85 protected:
91  virtual vtkMapperPtr getMapper()=0;
92 };
93 
94 
102 class cxResourceVisualization_EXPORT GraphicalPolyData3D : public GraphicalGeometricBase
103 {
104 public:
106  vtkRendererPtr renderer = vtkRendererPtr());
107  void setIsWireFrame(bool val);
108  void setRepresentation();
109  void setData(vtkPolyDataPtr data);
110  vtkMapperPtr getMapper();
111 
112 private:
113  vtkPolyDataMapperPtr mMapper;
114  bool mIsWireFrame;
115 };
116 typedef boost::shared_ptr<GraphicalPolyData3D> GraphicalPolyData3DPtr;
117 
118 
126 class cxResourceVisualization_EXPORT GraphicalGlyph3DData : public GraphicalGeometricBase
127 {
128 public:
130  vtkRendererPtr renderer = vtkRendererPtr());
131  void setData(vtkPolyDataPtr data);
132  void setOrientationArray(const char* orientationArray);
133  void setColorArray(const char* colorArray);
134  void setLUT(const char* lut);
135  void setScaleFactor(double scaleFactor);
136  vtkMapperPtr getMapper();
137 
138 private:
139  vtkGlyph3DMapperPtr mMapper;
140 };
141 typedef boost::shared_ptr<GraphicalGlyph3DData> GraphicalGlyph3DDataPtr;
142 
143 
144 
145 
146 
147 
150 class cxResourceVisualization_EXPORT GraphicalPoint3D
151 {
152  public:
154  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
155  ~GraphicalPoint3D();
156  void setRadius(double radius);
157 // void setColor(Vector3D color);
158  void setColor(QColor color);
159  void setValue(Vector3D point);
160  Vector3D getValue() const;
161  vtkActorPtr getActor();
162  vtkPolyDataPtr getPolyData();
163 
164  private:
165  vtkSphereSourcePtr source;
166  vtkPolyDataMapperPtr mapper;
167  vtkActorPtr actor;
168  vtkRendererPtr mRenderer;
169 };
170 typedef boost::shared_ptr<GraphicalPoint3D> GraphicalPoint3DPtr;
171 
174 class cxResourceVisualization_EXPORT GraphicalLine3D
175 {
176  public:
178  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
179  ~GraphicalLine3D();
180  void setColor(QColor color);
181  void setValue(Vector3D point1, Vector3D point2);
182  void setStipple(int stipple);
183  vtkActorPtr getActor();
184 
185  private:
186  vtkPolyDataMapperPtr mapper;
187  vtkActorPtr actor;
188  vtkRendererPtr mRenderer;
189  vtkLineSourcePtr source;
190 };
191 typedef boost::shared_ptr<GraphicalLine3D> GraphicalLine3DPtr;
192 
195 class cxResourceVisualization_EXPORT GraphicalArc3D
196 {
197  public:
199  ~GraphicalArc3D();
200  void setColor(QColor color);
201  void setValue(Vector3D point1, Vector3D point2, Vector3D center);
202  void setStipple(int stipple);
203  vtkActorPtr getActor();
204 
205  private:
206  vtkPolyDataMapperPtr mapper;
207  vtkActorPtr actor;
208  vtkRendererPtr mRenderer;
209  vtkArcSourcePtr source;
210 };
211 typedef boost::shared_ptr<GraphicalArc3D> GraphicalArc3DPtr;
212 
215 class cxResourceVisualization_EXPORT GraphicalArrow3D
216 {
217  public:
219  ~GraphicalArrow3D();
220  void setColor(QColor color);
221  void setValue(Vector3D base, Vector3D normal, double length);
222 
223  private:
224  vtkPolyDataMapperPtr mapper;
225  vtkActorPtr actor;
226  vtkRendererPtr mRenderer;
227  vtkArrowSourcePtr source;
228 };
229 typedef boost::shared_ptr<GraphicalArrow3D> GraphicalArrow3DPtr;
230 
233 class cxResourceVisualization_EXPORT Rect3D
234 {
235 public:
236  Rect3D(vtkRendererPtr renderer, QColor color);
237  ~Rect3D();
238  void setColor(QColor color);
239  void updatePosition(const DoubleBoundingBox3D bb, const Transform3D& M);
240  void setLine(bool on, int width);
241  void setSurface(bool on);
242 
243 private:
244  vtkPolyDataMapperPtr mapper;
245  vtkActorPtr actor;
246  vtkRendererPtr mRenderer;
247  vtkPolyDataPtr mPolyData;
248  vtkPointsPtr mPoints;
249  vtkCellArrayPtr mSide;
250 };
251 typedef boost::shared_ptr<class Rect3D> Rect3DPtr;
252 
256 class cxResourceVisualization_EXPORT FollowerText3D
257 {
258  public:
260  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
261 
262  ~FollowerText3D();
263  void setColor(QColor color);
264  void setText(QString text);
265  void setPosition(Vector3D pos);
266 
267  void setSize(double val);
268  void setSizeInNormalizedViewport(bool on, double size);
269  vtkFollowerPtr getActor();
270 
271  void scaleText();
272 
273  private:
274  vtkVectorTextPtr mText;
275  vtkFollowerPtr mFollower;
276  vtkRendererPtr mRenderer;
277  double mSize;
278 
279  ViewportListenerPtr mViewportListener;
280 };
281 typedef boost::shared_ptr<FollowerText3D> FollowerText3DPtr;
282 
286 class cxResourceVisualization_EXPORT CaptionText3D
287 {
288 public:
290  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
291 
292  ~CaptionText3D();
293  void setColor(QColor color);
294  void setText(QString text);
295  void setPosition(Vector3D pos);
296 
297  void setSize(double val);
298  // void setSizeInNormalizedViewport(bool on, double size);
299  vtkCaptionActor2DPtr getActor();
300 
301  // void scaleText(); ///< internal method
302 
303 private:
304  vtkCaptionActor2DPtr mText;
305  // vtkFollowerPtr mFollower;
306  vtkRendererPtr mRenderer;
307 
308  // ViewportListenerPtr mViewportListener;
309 };
310 typedef boost::shared_ptr<CaptionText3D> CaptionText3DPtr;
311 
316 }
317 
318 #endif /*CXGRAPHICALPRIMITIVES_H_*/
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.
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 vtkPolyData > vtkPolyDataPtr
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< class vtkVectorText > vtkVectorTextPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
vtkSmartPointer< class vtkGlyph3DMapper > vtkGlyph3DMapperPtr
boost::shared_ptr< FollowerText3D > FollowerText3DPtr
vtkSmartPointer< class vtkArcSource > vtkArcSourcePtr
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
Definition: cxViewWrapper.h:47
RealScalar length() const
boost::shared_ptr< GraphicalPolyData3D > GraphicalPolyData3DPtr
boost::shared_ptr< class GraphicalLine3D > GraphicalLine3DPtr
vtkPolyDataAlgorithmPtr mSource
vtkSmartPointer< class vtkArrowSource > vtkArrowSourcePtr
Helper for rendering a a glyph in 3D.
boost::shared_ptr< CaptionText3D > CaptionText3DPtr
boost::shared_ptr< class Rect3D > Rect3DPtr
boost::shared_ptr< GraphicalArrow3D > GraphicalArrow3DPtr
vtkSmartPointer< class vtkPoints > vtkPointsPtr
Helper for drawing a rectangle in 3D.