11 mCalibrationKeyword(
"CalibrationTo"),
12 mProbeToTrackerName(
"ProbeToTracker"),
13 mLastKnownOriginalTimestamp(-1),
14 mLastKnownLocalTimestamp(-1)
23 igtltool_M_custustool = Transform3D::Identity();
24 igtltool_M_custustool.matrix() = Eigen::Matrix4d::Constant(0);
25 igtltool_M_custustool(2, 0) = 1;
26 igtltool_M_custustool(0, 1) = 1;
27 igtltool_M_custustool(1, 2) = 1;
28 igtltool_M_custustool(3,3) = 1;
39 QString deviceName = body->GetDeviceName();
40 this->registerTransformDeviceName(deviceName);
45 if(this->isCalibration(deviceName))
48 Transform3D s_M_custustool = s_M_igtltool * igtltool_M_custustool;
50 QString calibrationBelongsToDeviceName = this->findDeviceForCalibration(deviceName);
51 if(calibrationBelongsToDeviceName !=
"NOT_FOUND")
53 emit
calibration(calibrationBelongsToDeviceName, sMt);
59 double timestamp_ms = baseConverter.
decode_timestamp(body).toMSecsSinceEpoch();
60 timestamp_ms = this->getSyncedTimestampForTransformsAndImages(timestamp_ms);
62 emit
transform(deviceName, prMs, timestamp_ms);
86 body->GetDimensions(dimensions_p);
88 body->GetSpacing(spacing);
90 extent_p[x] = dimensions_p[x]-1;
91 extent_p[y] = dimensions_p[y]-1;
92 extent_p[z] = dimensions_p[z]-1;
99 double timestamp_ms = baseConverter.
decode_timestamp(body).toMSecsSinceEpoch();
100 timestamp_ms = this->getSyncedTimestampForTransformsAndImages(timestamp_ms);
101 theImage->setAcquisitionTime(QDateTime::fromMSecsSinceEpoch(timestamp_ms));
102 emit
image(theImage);
106 definition->setUseDigitalVideo(
true);
108 definition->setSpacing(
Vector3D(spacing[x], spacing[y], spacing[z]));
109 definition->setSize(QSize(dimensions_p[x], dimensions_p[y]));
110 definition->setOrigin_p(
Vector3D(dimensions_p[x]/2, 0, 0));
111 double depthstart_mm = 0;
112 double depthend_mm = extent_p[y]*spacing[y];
113 double width_mm = extent_p[x]*spacing[x];
114 definition->setSector(depthstart_mm, depthend_mm, width_mm);
115 definition->setClipRect_p(
DoubleBoundingBox3D(0, extent_p[x], 0, extent_p[y], 0, extent_p[z]));
123 QString
string = converter.
decode(body);
124 if(
string.
contains(
"CommandReply", Qt::CaseInsensitive))
130 double PlusProtocol::getCurrentTimestamp()
const 132 double current_timestamp_ms = QDateTime::currentDateTime().toMSecsSinceEpoch();
133 return current_timestamp_ms;
135 double PlusProtocol::getSyncedTimestampForTransformsAndImages(
double currentOriginalTimestamp)
139 if(currentOriginalTimestamp != mLastKnownOriginalTimestamp)
141 double currentLocalTimestamp = this->getCurrentTimestamp();
149 mLastKnownOriginalTimestamp = currentOriginalTimestamp;
150 mLastKnownLocalTimestamp = currentLocalTimestamp;
152 retval = mLastKnownLocalTimestamp;
156 void PlusProtocol::registerTransformDeviceName(QString deviceName)
158 if(!mKnownTransformDeviceNames.contains(deviceName))
159 mKnownTransformDeviceNames << deviceName;
162 bool PlusProtocol::isCalibration(QString deviceName)
const 164 if(deviceName.contains(mCalibrationKeyword))
170 QString PlusProtocol::findDeviceForCalibration(QString calibrationDeviceName)
const 172 QString partialDeviceName = this->extractDeviceNameFromCalibrationDeviceName(calibrationDeviceName);
173 QString calibrationBelongsToDeviceName = this->findRegisteredTransformDeviceNameThatContains(partialDeviceName);
174 return calibrationBelongsToDeviceName;
177 QString PlusProtocol::extractDeviceNameFromCalibrationDeviceName(QString calibrationDeviceName)
const 179 QString retval = calibrationDeviceName.remove(mCalibrationKeyword);
183 QString PlusProtocol::findRegisteredTransformDeviceNameThatContains(QString deviceName)
const 185 QString retval(
"NOT_FOUND");
186 deviceName.remove(
"X");
187 QRegExp rx(deviceName+
"*");
188 rx.setPatternSyntax(QRegExp::Wildcard);
189 int foundAtIndex = mKnownTransformDeviceNames.indexOf(rx);
190 if(foundAtIndex != -1)
191 retval = mKnownTransformDeviceNames[foundAtIndex];
#define CX_LOG_CHANNEL_INFO(channel)
void calibration(QString devicename, Transform3D calibration)
QDateTime decode_timestamp(igtl::MessageBase *msg)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void transform(QString devicename, Transform3D transform, double timestamp)
US beam is emitted straight forward.
boost::shared_ptr< class Image > ImagePtr
void image(ImagePtr image)
QString decode(igtl::StringMessage::Pointer msg)
virtual QString getName() const
#define CX_OPENIGTLINK_CHANNEL_NAME
StreamedTimestampSynchronizerPtr mStreamSynchronizer
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition of characteristics for an Ultrasound Probe Sector.
void probedefinition(QString devicename, ProbeDefinitionPtr definition)
bool contains(std::string const &s, std::string const &infix)
virtual void translate(const igtl::TransformMessage::Pointer body)
boost::shared_ptr< class ProbeDefinition > ProbeDefinitionPtr
Namespace for all CustusX production code.