36 #include "vtkImageData.h" 37 #include <vtkPointData.h> 38 #include <vtkUnsignedCharArray.h> 39 #include <vtkPolyData.h> 40 #include <vtkPolyDataMapper.h> 42 #include <vtkCellArray.h> 43 #include <vtkFloatArray.h> 44 #include <vtkProperty.h> 46 #include <vtkMatrix4x4.h> 66 mSpaceProvider = spaceProvider;
68 mPolyData = vtkPolyDataPtr::New();
69 mActor = vtkActorPtr::New();
70 mPolyDataMapper = vtkPolyDataMapperPtr::New();
72 mPolyDataMapper->SetInputData(mPolyData);
73 mActor->SetMapper(mPolyDataMapper);
75 mProperty = vtkPropertyPtr::New();
76 mActor->SetProperty( mProperty );
77 mProperty->SetPointSize(4);
81 mPoints = vtkPointsPtr::New();
82 mLines = vtkCellArrayPtr::New();
84 mPolyData->SetPoints(mPoints);
85 mPolyData->SetLines(mLines);
86 mPolyData->SetVerts(mLines);
91 mSpaceListener = mSpaceProvider->createListener();
94 this->onSpaceChanged();
111 this->disconnectTool();
119 mPolyData->Modified();
122 void ToolTracer::connectTool()
124 if (mTool && mRunning)
126 connect(mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this, SLOT(receiveTransforms(
Transform3D,
double)));
131 void ToolTracer::disconnectTool()
133 if (mTool && mRunning)
135 disconnect(mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this, SLOT(receiveTransforms(
Transform3D,
double)));
142 mActor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
147 this->disconnectTool();
162 void ToolTracer::onSpaceChanged()
166 mActor->SetUserMatrix(rMpr.getVtkMatrix());
174 void ToolTracer::receiveTransforms(
Transform3D prMt,
double timestamp)
178 if (mMinDistance > 0.0)
180 if (!mFirstPoint && (mPreviousPoint - p).
length() < mMinDistance)
188 mPoints->InsertNextPoint(p.begin());
190 if (mPoints->GetNumberOfPoints() > 1)
194 mLines->Initialize();
195 std::vector<vtkIdType> ids(mPoints->GetNumberOfPoints());
196 for (
unsigned i=0; i<ids.size(); ++i)
198 mLines->InsertNextCell(ids.size(), &(*ids.begin()));
201 mPolyData->Modified();
207 for(TimedTransformMap::iterator iter=trackerRecordedData_prMt.begin(); iter!=trackerRecordedData_prMt.end(); ++iter)
209 double timestamp = iter->first;
211 this->receiveTransforms(prMt, timestamp);
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkActor > vtkActorPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class ToolTracer > ToolTracerPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
RealScalar length() const
static CoordinateSystem patientReference()
std::map< double, Transform3D > TimedTransformMap
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr