46 double loadAttribute(QDomNode dataNode, QString name,
double defVal)
48 QString text = dataNode.toElement().attribute(name);
50 double val = text.toDouble(&ok);
63 mType(type), mDepthStart(0), mDepthEnd(0), mWidth(0),
64 mTemporalCalibration(0), mCenterOffset(0), mSoundSpeedCompensationFactor(1.0),
66 mOrigin_p(0, 0, 0), mSpacing(-1, -1, -1), mClipRect_p(0, 0, 0, 0), mSize(0, 0),
72 QDomElement elem = dataNode.toElement();
74 elem.setAttribute(
"depthStart",
qstring_cast(mDepthStart));
78 elem.setAttribute(
"temporalCalibration",
qstring_cast(mTemporalCalibration));
79 elem.setAttribute(
"centerOffset",
qstring_cast(mCenterOffset));
83 QDomElement imageNode = dataNode.ownerDocument().createElement(
"image");
84 this->addImageXml(imageNode);
85 dataNode.appendChild(imageNode);
90 QDomElement elem = dataNode.toElement();
92 mType =
static_cast<TYPE>(elem.attribute(
"type").toInt());
93 mDepthStart = loadAttribute(elem,
"depthStart", 0);
94 mDepthEnd = loadAttribute(elem,
"depthEnd", 0);
95 mWidth = loadAttribute(elem,
"width", 0);
97 mTemporalCalibration = loadAttribute(elem,
"temporalCalibration", 0);
98 mCenterOffset = loadAttribute(elem,
"centerOffset", 0);
99 mUid = elem.attribute(
"uid");
101 QDomNode imageNode = dataNode.namedItem(
"image");
102 this->parseImageXml(imageNode);
105 void ProbeDefinition::addImageXml(QDomNode dataNode)
const
107 QDomElement elem = dataNode.toElement();
111 elem.setAttribute(
"clipRect_p",
qstring_cast(mClipRect_p));
112 elem.setAttribute(
"width",
qstring_cast(mSize.width()));
113 elem.setAttribute(
"height",
qstring_cast(mSize.height()));
116 void ProbeDefinition::parseImageXml(QDomNode dataNode)
118 QDomElement elem = dataNode.toElement();
120 mOrigin_p = Vector3D::fromString(elem.attribute(
"origin_p"));
121 mSpacing = Vector3D::fromString(elem.attribute(
"spacing"));
123 mSize.setWidth(loadAttribute(elem,
"width", 0));
124 mSize.setHeight(loadAttribute(elem,
"height", 0));
129 mTemporalCalibration = value;
139 mDepthStart=depthStart;
142 mCenterOffset=centerOffset;
167 return mTemporalCalibration;
172 return mCenterOffset;
180 Vector3D factor(
double(newSize.width())/mSize.width(), double(newSize.height())/mSize.height(), 1);
207 mClipRect_p[0] = mOrigin_p[0] - mWidth/2/mSpacing[0];
208 mClipRect_p[1] = mOrigin_p[0] + mWidth/2/mSpacing[0];
210 mClipRect_p[2] = mOrigin_p[1] + mDepthStart/mSpacing[1];
211 mClipRect_p[3] = mOrigin_p[1] + mDepthEnd/mSpacing[1];
220 mWidth = 2*std::max(fabs(mClipRect_p[0] - mOrigin_p[0]), fabs(mClipRect_p[1] - mOrigin_p[0])) * mSpacing[0];
221 mDepthStart = (mClipRect_p[2] - mOrigin_p[1]) * mSpacing[1];
222 mDepthEnd = (mClipRect_p[3] - mOrigin_p[1]) * mSpacing[1];
228 mSpacing[1] = mSpacing[1] * factor / mSoundSpeedCompensationFactor;
229 mSoundSpeedCompensationFactor = factor;
232 reportWarning(
"Sound speed compensation is applied to spacing[1], i.e. it is correct for linear probes and approxomate for other probes. Factor: " +
qstring_cast(factor));
237 return mSoundSpeedCompensationFactor;
243 Vector3D c(q_p[0],
double(mSize.height()) - q_p[1] - 1, -q_p[2]);
250 return this->transform_p_to_u(mOrigin_p);
255 Vector3D p0 = transform_p_to_u(mClipRect_p.corner(0,0,0));
256 Vector3D p1 = transform_p_to_u(mClipRect_p.corner(1,1,1));
282 mOrigin_p = origin_p;
292 mClipRect_p = clipRect_p;
312 mAdditionalVariables[variableName] = value;
317 if(!mAdditionalVariables.contains(variableName))
318 CX_LOG_ERROR(QString(
"Variable %1 don't exist in ProbeDefinition with uid %2").arg(variableName).arg(this->mUid));
319 return mAdditionalVariables[variableName];
QString qstring_cast(const T &val)
void addXml(QDomNode dataNode) const
Vector3D divide_elems(const Vector3D &a, const Vector3D &b)
perform element-wise division of a and b.
void setSpacing(Vector3D spacing)
double getCenterOffset() const
QVariant getVariable(QString variableName)
US beam is emitted straight forward.
static DoubleBoundingBox3D fromString(const QString &text)
construct a bb from a string containing 6 whitespace-separated numbers
void resample(QSize mSize)
Set a new image size. Resample all other parameters to match this new image size, keeping sizes in mi...
double getSoundSpeedCompensationFactor() const
void setSector(double depthStart, double depthEnd, double width, double centerOffset=0)
void updateSectorFromClipRect()
double getDepthStart() const
void parseXml(QDomNode dataNode)
double getDepthEnd() const
Vector3D getOrigin_p() const
void updateClipRectFromSector()
void setOrigin_p(Vector3D origin_p)
void reportWarning(QString msg)
void setTemporalCalibration(double value)
void setUseDigitalVideo(bool val)
RTSource is digital (eg. US sector is set digitally, not read from .xml file)
void setClipRect_p(DoubleBoundingBox3D clipRect_p)
DoubleBoundingBox3D getClipRect_u() const
sector clipping rect in image space u. (lower-left corner origin)
void applySoundSpeedCompensationFactor(double factor)
Compensate for soundspeed for linear probes.
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.
ProbeDefinition(TYPE type=tNONE)
Vector3D getOrigin_u() const
probe origin in image space u. (lower-left corner origin)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Vector3D multiply_elems(const Vector3D &a, const Vector3D &b)
perform element-wise multiplication of a and b.
Vector3D getSpacing() const
double getTemporalCalibration() const
void setVariable(QString variableName, QVariant value)
bool getUseDigitalVideo() const
DoubleBoundingBox3D getClipRect_p() const