CustusX  2023.01.05-dev+develop.0da12
An IGT application
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) 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 
13 #ifndef CXTOOLTRACER_H_
14 #define CXTOOLTRACER_H_
15 
16 #include "cxResourceVisualizationExport.h"
17 
18 #include <QObject>
19 #include <QSize>
20 #include "vtkSmartPointer.h"
21 typedef vtkSmartPointer<class vtkImageData> vtkImageDataPtr;
22 typedef vtkSmartPointer<class vtkPolyData> vtkPolyDataPtr;
23 #include "cxTransform3D.h"
24 
25 #include <boost/shared_ptr.hpp>
26 #include "vtkForwardDeclarations.h"
27 #include "cxForwardDeclarations.h"
28 #include "cxTool.h"
29 
30 class QColor;
31 
32 namespace cx
33 {
34 
35 typedef boost::shared_ptr<class ToolTracer> ToolTracerPtr;
36 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
37 typedef boost::shared_ptr<class SpaceListener> SpaceListenerPtr;
38 
47 class cxResourceVisualization_EXPORT ToolTracer : public QObject
48 {
49  Q_OBJECT
50 public:
51  static ToolTracerPtr create(SpaceProviderPtr spaceProvider);
52  void setTool(ToolPtr tool);
53  vtkPolyDataPtr getPolyData();
54  vtkActorPtr getActor();
55 
56  void setColor(QColor color);
57 
58  void start(); // start path tracking
59  void stop(); // stop tracking
60  void clear(); // erase stored tracking data.
61  bool isRunning() const; // true if started and not stopped.
62  void setMinDistance(double distance) { mMinDistance = distance; }
63  int getSkippedPoints() { return mSkippedPoints; }
64  void addManyPositions(TimedTransformMap trackerRecordedData_prMt);
65 
66 private slots:
67  void receiveTransforms(Transform3D prMt, double timestamp);
68 private:
69  ToolTracer(SpaceProviderPtr spaceProvider);
70  void connectTool();
71  void disconnectTool();
72  void onSpaceChanged();
73 
74  bool mRunning;
75  vtkPolyDataPtr mPolyData;
76  vtkActorPtr mActor;
77  ToolPtr mTool;
78  vtkPolyDataMapperPtr mPolyDataMapper;
79  vtkPropertyPtr mProperty;
80 
81  vtkPointsPtr mPoints;
82  vtkCellArrayPtr mLines;
83 
84  bool mFirstPoint;
85  int mSkippedPoints;
86  Vector3D mPreviousPoint;
87  double mMinDistance;
88 
89  SpaceProviderPtr mSpaceProvider;
90  SpaceListenerPtr mSpaceListener;
91 };
92 
93 } // namespace cx
94 
95 #endif /*CXTOOLTRACER_H_*/
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxToolTracer.h:21
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:22
vtkSmartPointer< vtkPoints > vtkPointsPtr
boost::shared_ptr< class ToolTracer > ToolTracerPtr
void setMinDistance(double distance)
Definition: cxToolTracer.h:62
3D Graphics class for displaying the trace path traversed by a tool.
Definition: cxToolTracer.h:47
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
boost::shared_ptr< class SpaceListener > SpaceListenerPtr
int getSkippedPoints()
Definition: cxToolTracer.h:63
std::map< double, Transform3D > TimedTransformMap
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr