CustusX  15.4.0-beta
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 
44 class QColor;
45 typedef vtkSmartPointer<class vtkPolyDataAlgorithm> vtkPolyDataAlgorithmPtr;
46 typedef vtkSmartPointer<class vtkArcSource> vtkArcSourcePtr;
47 typedef vtkSmartPointer<class vtkArrowSource> vtkArrowSourcePtr;
48 
49 namespace cx
50 {
51 
59 class cxResourceVisualization_EXPORT GraphicalPolyData3D
60 {
61 public:
64  vtkRendererPtr renderer = vtkRendererPtr());
65  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
66  void setSource(vtkPolyDataAlgorithmPtr source);
67  void setData(vtkPolyDataPtr data);
69  void setColor(Vector3D color);
70  void setPosition(Vector3D point);
71  Vector3D getPosition() const;
72 
73  vtkActorPtr getActor();
74  vtkPolyDataPtr getPolyData();
75  vtkPolyDataAlgorithmPtr getSource();
76 
77 private:
79  vtkPolyDataPtr mData;
80  vtkPolyDataMapperPtr mMapper;
81  vtkActorPtr mActor;
82  vtkRendererPtr mRenderer;
83 };
84 typedef boost::shared_ptr<GraphicalPolyData3D> GraphicalPolyData3DPtr;
85 
86 
89 class cxResourceVisualization_EXPORT GraphicalPoint3D
90 {
91  public:
93  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
95  void setRadius(double radius);
96 // void setColor(Vector3D color);
97  void setColor(QColor color);
98  void setValue(Vector3D point);
99  Vector3D getValue() const;
100  vtkActorPtr getActor();
101  vtkPolyDataPtr getPolyData();
102 
103  private:
104  vtkSphereSourcePtr source;
105  vtkPolyDataMapperPtr mapper;
106  vtkActorPtr actor;
107  vtkRendererPtr mRenderer;
108 };
109 typedef boost::shared_ptr<GraphicalPoint3D> GraphicalPoint3DPtr;
110 
113 class cxResourceVisualization_EXPORT GraphicalLine3D
114 {
115  public:
117  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
118  ~GraphicalLine3D();
119  void setColor(QColor color);
120  void setValue(Vector3D point1, Vector3D point2);
121  void setStipple(int stipple);
122  vtkActorPtr getActor();
123 
124  private:
125  vtkPolyDataMapperPtr mapper;
126  vtkActorPtr actor;
127  vtkRendererPtr mRenderer;
128  vtkLineSourcePtr source;
129 };
130 typedef boost::shared_ptr<GraphicalLine3D> GraphicalLine3DPtr;
131 
134 class cxResourceVisualization_EXPORT GraphicalArc3D
135 {
136  public:
138  ~GraphicalArc3D();
139  void setColor(QColor color);
140  void setValue(Vector3D point1, Vector3D point2, Vector3D center);
141  void setStipple(int stipple);
142  vtkActorPtr getActor();
143 
144  private:
145  vtkPolyDataMapperPtr mapper;
146  vtkActorPtr actor;
147  vtkRendererPtr mRenderer;
148  vtkArcSourcePtr source;
149 };
150 typedef boost::shared_ptr<GraphicalArc3D> GraphicalArc3DPtr;
151 
154 class cxResourceVisualization_EXPORT GraphicalArrow3D
155 {
156  public:
158  ~GraphicalArrow3D();
159  void setColor(QColor color);
160  void setValue(Vector3D base, Vector3D normal, double length);
161 
162  private:
163  vtkPolyDataMapperPtr mapper;
164  vtkActorPtr actor;
165  vtkRendererPtr mRenderer;
166  vtkArrowSourcePtr source;
167 };
168 typedef boost::shared_ptr<GraphicalArrow3D> GraphicalArrow3DPtr;
169 
172 class cxResourceVisualization_EXPORT Rect3D
173 {
174 public:
175  Rect3D(vtkRendererPtr renderer, QColor color);
176  ~Rect3D();
177  void setColor(QColor color);
178  void updatePosition(const DoubleBoundingBox3D bb, const Transform3D& M);
179  void setLine(bool on, int width);
180  void setSurface(bool on);
181 
182 private:
183  vtkPolyDataMapperPtr mapper;
184  vtkActorPtr actor;
185  vtkRendererPtr mRenderer;
186  vtkPolyDataPtr mPolyData;
187  vtkPointsPtr mPoints;
188  vtkCellArrayPtr mSide;
189 };
190 typedef boost::shared_ptr<class Rect3D> Rect3DPtr;
191 
195 class cxResourceVisualization_EXPORT FollowerText3D
196 {
197  public:
199  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
200 
201  ~FollowerText3D();
202  void setColor(QColor color);
203  void setText(QString text);
204  void setPosition(Vector3D pos);
205 
206  void setSize(double val);
207  void setSizeInNormalizedViewport(bool on, double size);
208  vtkFollowerPtr getActor();
209 
210  void scaleText();
211 
212  private:
213  vtkVectorTextPtr mText;
214  vtkFollowerPtr mFollower;
215  vtkRendererPtr mRenderer;
216  double mSize;
217 
218  ViewportListenerPtr mViewportListener;
219 };
220 typedef boost::shared_ptr<FollowerText3D> FollowerText3DPtr;
221 
225 class cxResourceVisualization_EXPORT CaptionText3D
226 {
227 public:
229  void setRenderer(vtkRendererPtr renderer = vtkRendererPtr());
230 
231  ~CaptionText3D();
232  void setColor(QColor color);
233  void setText(QString text);
234  void setPosition(Vector3D pos);
235 
236  void setSize(double val);
237  // void setSizeInNormalizedViewport(bool on, double size);
238  vtkCaptionActor2DPtr getActor();
239 
240  // void scaleText(); ///< internal method
241 
242 private:
243  vtkCaptionActor2DPtr mText;
244  // vtkFollowerPtr mFollower;
245  vtkRendererPtr mRenderer;
246 
247  // ViewportListenerPtr mViewportListener;
248 };
249 typedef boost::shared_ptr<CaptionText3D> CaptionText3DPtr;
250 
255 }
256 
257 #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
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkCellArray > vtkCellArrayPtr
Helper for rendering a line in 3D.
boost::shared_ptr< GraphicalArc3D > GraphicalArc3DPtr
vtkSmartPointer< class vtkLineSource > vtkLineSourcePtr
Helper for rendering a point in 3D.
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
Definition: cxProbeSector.h:47
Helper for rendering an arrow in 3D.
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
vtkSmartPointer< class vtkFollower > vtkFollowerPtr
Helper for rendering a a polydata in 3D.
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
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
vtkSmartPointer< class vtkArrowSource > vtkArrowSourcePtr
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.