25 double loadAttribute(QDomNode dataNode, QString name,
double defVal)
27 QString text = dataNode.toElement().attribute(name);
29 double val = text.toDouble(&ok);
42 mType(type), mDepthStart(0), mDepthEnd(0), mWidth(0),
43 mTemporalCalibration(0), mCenterOffset(0), mSoundSpeedCompensationFactor(1.0),
45 mOrigin_p(0, 0, 0), mSpacing(-1, -1, -1), mClipRect_p(0, 0, 0, 0), mSize(0, 0),
51 QDomElement elem = dataNode.toElement();
53 elem.setAttribute(
"depthStart",
qstring_cast(mDepthStart));
57 elem.setAttribute(
"temporalCalibration",
qstring_cast(mTemporalCalibration));
58 elem.setAttribute(
"centerOffset",
qstring_cast(mCenterOffset));
63 this->addImageXml(imageNode);
64 dataNode.appendChild(imageNode);
69 QDomElement elem = dataNode.toElement();
71 mType =
static_cast<TYPE>(elem.attribute(
"type").toInt());
72 mDepthStart = loadAttribute(elem,
"depthStart", 0);
73 mDepthEnd = loadAttribute(elem,
"depthEnd", 0);
74 mWidth = loadAttribute(elem,
"width", 0);
76 mTemporalCalibration = loadAttribute(elem,
"temporalCalibration", 0);
77 mCenterOffset = loadAttribute(elem,
"centerOffset", 0);
78 mUid = elem.attribute(
"uid");
81 this->parseImageXml(imageNode);
84 void ProbeDefinition::addImageXml(QDomNode dataNode)
const 86 QDomElement elem = dataNode.toElement();
90 elem.setAttribute(
"clipRect_p",
qstring_cast(mClipRect_p));
92 elem.setAttribute(
"height",
qstring_cast(mSize.height()));
95 void ProbeDefinition::parseImageXml(QDomNode dataNode)
97 QDomElement elem = dataNode.toElement();
99 mOrigin_p = Vector3D::fromString(elem.attribute(
"origin_p"));
100 mSpacing = Vector3D::fromString(elem.attribute(
"spacing"));
102 mSize.setWidth(loadAttribute(elem,
"width", 0));
103 mSize.setHeight(loadAttribute(elem,
"height", 0));
108 mTemporalCalibration = value;
118 mDepthStart=depthStart;
121 mCenterOffset=centerOffset;
146 return mTemporalCalibration;
151 return mCenterOffset;
159 Vector3D factor(
double(newSize.width())/mSize.width(), double(newSize.height())/mSize.height(), 1);
186 mClipRect_p[0] = mOrigin_p[0] - mWidth/2/mSpacing[0];
187 mClipRect_p[1] = mOrigin_p[0] + mWidth/2/mSpacing[0];
189 mClipRect_p[2] = mOrigin_p[1] + mDepthStart/mSpacing[1];
190 mClipRect_p[3] = mOrigin_p[1] + mDepthEnd/mSpacing[1];
199 mWidth = 2*std::max(fabs(mClipRect_p[0] - mOrigin_p[0]), fabs(mClipRect_p[1] - mOrigin_p[0])) * mSpacing[0];
200 mDepthStart = (mClipRect_p[2] - mOrigin_p[1]) * mSpacing[1];
201 mDepthEnd = (mClipRect_p[3] - mOrigin_p[1]) * mSpacing[1];
209 mSpacing[1] = mSpacing[1] * factor / mSoundSpeedCompensationFactor;
210 mSoundSpeedCompensationFactor = factor;
213 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));
218 return mSoundSpeedCompensationFactor;
224 Vector3D c(q_p[0],
double(mSize.height()) - q_p[1] - 1, -q_p[2]);
231 return this->transform_p_to_u(mOrigin_p);
263 mOrigin_p = origin_p;
273 mClipRect_p = clipRect_p;
293 mAdditionalVariables[variableName] = value;
298 if(!mAdditionalVariables.contains(variableName))
299 CX_LOG_ERROR(QString(
"Variable %1 don't exist in ProbeDefinition with uid %2").arg(variableName).arg(this->mUid));
300 return mAdditionalVariables[variableName];
QString qstring_cast(const T &val)
void addXml(QDomNode dataNode) const
Vector3D corner(int x, int y, int z) 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)
static QString getTypeName()
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
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
double getTemporalCalibration() const
void setVariable(QString variableName, QVariant value)
bool getUseDigitalVideo() const
DoubleBoundingBox3D getClipRect_p() const
Namespace for all CustusX production code.