23 ToolImpl(toolFileToolStructure->mUid, toolFileToolStructure->mUid),
26 mLastReceivedPositionTime(0),
27 mConfigFileToolStructure(configFileToolStructure),
28 mToolFileToolStructure(toolFileToolStructure),
29 mPrintedWarningAboutTimeStampMismatch(false)
34 connect(&mTpsTimer, &QTimer::timeout,
this, &OpenIGTLinkTool::calculateTpsSlot);
35 connect(&mTpsTimer, &QTimer::timeout,
this, &OpenIGTLinkTool::calculateVisible);
37 if(toolFileToolStructure->mIsProbe)
46 mProbe =
ProbeImpl::New(
"ProbeToReference",
"PlusDeviceSet_OpenIGTLinkCommandsTest");
47 connect(mProbe.get(), SIGNAL(sectorChanged()),
this, SIGNAL(
toolProbeSector()));
51 this->toolVisibleSlot(
true);
57 if(openIGTLinkId.compare(this->mConfigFileToolStructure.mOpenIGTLinkTransformId, Qt::CaseInsensitive) == 0)
59 else if(openIGTLinkId.compare(this->mConfigFileToolStructure.mOpenIGTLinkImageId, Qt::CaseInsensitive) == 0)
102 return this->
getProbe()->getProbeDefinition().getDepthStart();
118 bool calibrated = !
similar(sMt, identity);
119 CX_LOG_DEBUG() <<
"Checking if openiglink tool is calibratated: " << calibrated;
125 return mToolFileToolStructure->getCalibrationAsSSC();
131 CX_LOG_WARNING() <<
"OpenIGTLinkTool::setCalibration_sMt() Receiving calibration. Should file be updated, or should it be discarded and use calibration from file instead?";
132 CX_LOG_WARNING() <<
"Current implementation discards this received calibration. sMt: " << sMt;
138 void OpenIGTLinkTool::toolTransformAndTimestampSlot(
Transform3D prMs,
double timestampMS)
140 mTimestamp = timestampMS;
141 this->checkTimestampMismatch();
160 (*mPositionHistory)[mTimestamp] = prMt;
170 void OpenIGTLinkTool::checkTimestampMismatch()
172 mLastReceivedPositionTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
173 double diff = mLastReceivedPositionTime - mTimestamp;
176 if(fabs(diff) > 1000)
178 this->printWarningAboutTimestampMismatch(diff);
179 mTimestamp = mLastReceivedPositionTime;
183 void OpenIGTLinkTool::printWarningAboutTimestampMismatch(
double diff)
185 if (mPrintedWarningAboutTimeStampMismatch)
188 CX_LOG_WARNING() <<
"Difference between system time and received tool timestamp: " << diff
189 <<
" The reason for this may be incompatible timestamps. " 190 <<
" System time will be used instead of received timestamp.";
191 mPrintedWarningAboutTimeStampMismatch =
true;
194 void OpenIGTLinkTool::calculateTpsSlot()
198 if (numberOfTransformsToCheck <= 1)
205 double lastTransform = rit->first;
206 for (
size_t i = 0; i < numberOfTransformsToCheck-1; ++i)
210 double firstTransform = rit->first;
211 double secondsPassed = (lastTransform - firstTransform) / 1000;
213 if (!
similar(secondsPassed, 0))
214 tpsNr =
int(numberOfTransformsToCheck / secondsPassed);
218 void OpenIGTLinkTool::calculateVisible()
222 qint64 currentTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
223 double diff = currentTime - mLastReceivedPositionTime;
231 void OpenIGTLinkTool::toolVisibleSlot(
bool on)
234 mTpsTimer.start(1000);
247 return mToolFileToolStructure;
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< Probe > ProbePtr
static ProbeImplPtr New(QString instrumentUid, QString scannerUid, ProbeXmlConfigParserPtr xml=ProbeXmlConfigParserPtr())
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
Namespace for all CustusX production code.