33 #define _USE_MATH_DEFINES
36 #include <vtkPolyData.h>
37 #include <vtkConeSource.h>
38 #include <vtkSTLReader.h>
41 #include <QStringList>
42 #include <QTextStream>
55 mTool(igstkTool), mPolyData(NULL),
56 mValid(false), mConfigured(false), mTracked(false)
59 Tool::mUid = mTool->getInternalStructure().mUid;
61 mValid = igstkTool->isValid();
63 this->createPolyData();
66 &ToolUsingIGSTK::toolTransformAndTimestampSlot);
68 connect(mTool.get(), SIGNAL(
toolVisible(
bool)),
this, SLOT(toolVisibleSlot(
bool)));
70 connect(&mTpsTimer, SIGNAL(timeout()),
this, SLOT(calculateTpsSlot()));
72 if (mTool->getInternalStructure().mIsProbe)
74 mProbe =
ProbeImpl::New(mTool->getInternalStructure().mInstrumentId,
75 mTool->getInternalStructure().mInstrumentScannerId);
76 connect(mProbe.get(), SIGNAL(sectorChanged()),
this, SIGNAL(
toolProbeSector()));
86 std::set<Type> retval;
88 if (mTool->getInternalStructure().mIsReference)
90 if (mTool->getInternalStructure().mIsPointer)
92 if (mTool->getInternalStructure().mIsProbe)
110 return mTool->isVisible();
115 return mTool->isInitialized();
131 return this->
getProbe()->getProbeDefinition().getDepthStart();
147 void ToolUsingIGSTK::createPolyData()
150 if (!mTool->getInternalStructure().mGraphicsFileName.isEmpty()
151 && dir.exists(mTool->getInternalStructure().mGraphicsFileName))
154 reader->SetFileName(
cstring_cast(mTool->getInternalStructure().mGraphicsFileName));
156 mPolyData = reader->GetOutput();
167 Transform3D sMt = mTool->getInternalStructure().getCalibrationAsSSC();
168 return !
similar(sMt, identity);
173 Transform3D sMt = mTool->getInternalStructure().getCalibrationAsSSC();
180 mTool->updateCalibration(calibration);
185 return mTool->getInternalStructure().mCalibrationFilename;
190 return mTool->getInternalStructure().mTrackerType;
193 void ToolUsingIGSTK::printInternalStructure()
195 mTool->printInternalStructure();
200 return mTool->getInternalStructure().mReferencePoints;
210 QDomDocument doc = dataNode.ownerDocument();
212 if (mProbe && mProbe->isValid())
214 QDomElement probeNode = doc.createElement(
"probe");
215 mProbe->addXml(probeNode);
216 dataNode.appendChild(probeNode);
222 if (dataNode.isNull())
226 QDomNode probeNode = dataNode.namedItem(
"probe");
227 mProbe->parseXml(probeNode);
241 mTimestamp = timestamp;
246 (*mPositionHistory)[timestamp] = matrix;
253 void ToolUsingIGSTK::calculateTpsSlot()
258 if ( numberOfTransformsToCheck <= 1)
265 double lastTransform = it->first;
266 for (
int i = 0; i < numberOfTransformsToCheck; ++i)
268 double firstTransform = it->first;
269 double secondsPassed = (lastTransform - firstTransform) / 1000;
271 if (!
similar(secondsPassed, 0))
272 tpsNr = (
int) (numberOfTransformsToCheck / secondsPassed);
277 void ToolUsingIGSTK::toolVisibleSlot(
bool on)
280 mTpsTimer.start(1000);
QString qstring_cast(const T &val)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class IgstkTool > IgstkToolPtr
cstring_cast_Placeholder cstring_cast(const T &val)
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
boost::shared_ptr< Probe > ProbePtr
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
vtkSmartPointer< class vtkSTLReader > vtkSTLReaderPtr
static ProbeImplPtr New(QString instrumentUid, QString scannerUid, ProbeXmlConfigParserPtr xml=ProbeXmlConfigParserPtr())