Fraxinus  16.5.0-fx-rc8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxToolTracer.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 
34 #ifndef CXTOOLTRACER_H_
35 #define CXTOOLTRACER_H_
36 
37 #include "cxResourceVisualizationExport.h"
38 
39 #include <QObject>
40 #include <QSize>
41 #include "vtkSmartPointer.h"
42 typedef vtkSmartPointer<class vtkImageData> vtkImageDataPtr;
43 typedef vtkSmartPointer<class vtkPolyData> vtkPolyDataPtr;
44 #include "cxTransform3D.h"
45 
46 #include <boost/shared_ptr.hpp>
47 #include "vtkForwardDeclarations.h"
48 #include "cxForwardDeclarations.h"
49 #include "cxTool.h"
50 
51 class QColor;
52 
53 namespace cx
54 {
55 
56 typedef boost::shared_ptr<class ToolTracer> ToolTracerPtr;
57 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
58 typedef boost::shared_ptr<class SpaceListener> SpaceListenerPtr;
59 
68 class cxResourceVisualization_EXPORT ToolTracer : public QObject
69 {
70  Q_OBJECT
71 public:
73  void setTool(ToolPtr tool);
74  vtkPolyDataPtr getPolyData();
75  vtkActorPtr getActor();
76 
77  void setColor(QColor color);
78 
79  void start(); // start path tracking
80  void stop(); // stop tracking
81  void clear(); // erase stored tracking data.
82  bool isRunning() const; // true if started and not stopped.
83  void setMinDistance(double distance) { mMinDistance = distance; }
84  int getSkippedPoints() { return mSkippedPoints; }
85  void addManyPositions(TimedTransformMap trackerRecordedData_prMt);
86 
87 private slots:
88  void receiveTransforms(Transform3D prMt, double timestamp);
89 private:
90  ToolTracer(SpaceProviderPtr spaceProvider);
91  void connectTool();
92  void disconnectTool();
93  void onSpaceChanged();
94 
95  bool mRunning;
96  vtkPolyDataPtr mPolyData;
97  vtkActorPtr mActor;
98  ToolPtr mTool;
99  vtkPolyDataMapperPtr mPolyDataMapper;
100  vtkPropertyPtr mProperty;
101 
102  vtkPointsPtr mPoints;
103  vtkCellArrayPtr mLines;
104 
105  bool mFirstPoint;
106  int mSkippedPoints;
107  Vector3D mPreviousPoint;
108  double mMinDistance;
109 
110  SpaceProviderPtr mSpaceProvider;
111  SpaceListenerPtr mSpaceListener;
112 };
113 
114 } // namespace cx
115 
116 #endif /*CXTOOLTRACER_H_*/
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxToolTracer.h:42
vtkSmartPointer< class vtkActor > vtkActorPtr
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
vtkSmartPointer< class vtkProperty > vtkPropertyPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkCellArray > vtkCellArrayPtr
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
Definition: cxToolTracer.h:43
boost::shared_ptr< class ToolTracer > ToolTracerPtr
void setMinDistance(double distance)
Definition: cxToolTracer.h:83
3D Graphics class for displaying the trace path traversed by a tool.
Definition: cxToolTracer.h:68
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
boost::shared_ptr< class SpaceListener > SpaceListenerPtr
int getSkippedPoints()
Definition: cxToolTracer.h:84
std::map< double, Transform3D > TimedTransformMap
vtkSmartPointer< class vtkPoints > vtkPointsPtr
boost::shared_ptr< class Tool > ToolPtr