25 DataMetric(uid, name, dataManager, spaceProvider)
27 mUseSimpleVisualization =
false;
28 mArguments.reset(
new MetricReferenceArgumentList(QStringList() <<
"point 0" <<
"point 1" <<
"point 2" <<
"point 3"));
29 mArguments->setValidArgumentTypes(QStringList() <<
"pointMetric");
30 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SLOT(resetCachedValues()));
31 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SIGNAL(
transformChanged()));
46 mArguments->addXml(dataNode);
47 dataNode.toElement().setAttribute(
"useSimpleVisualization", QString::number(mUseSimpleVisualization));
54 mArguments->parseXml(dataNode, mDataManager->getDatas());
56 mUseSimpleVisualization = dataNode.toElement().attribute(
"useSimpleVisualization", QString::number(mUseSimpleVisualization)).toInt();
57 this->resetCachedValues();
60 void AngleMetric::resetCachedValues()
62 mCachedEndPoints.reset();
67 return !this->getEndpoints().empty();
72 if (!mCachedEndPoints.isValid())
74 mCachedEndPoints.set(mArguments->getRefCoords());
76 return mCachedEndPoints.get();
81 return this->boundingBox().center();
86 std::vector<Vector3D> p = this->getEndpoints();
91 Vector3D a = (p[0] - p[1]).normalized();
92 Vector3D b = (p[3] - p[2]).normalized();
94 double angle = acos(
dot(a, b) / a.length() / b.length());
100 return QString(
"%1*").arg(this->getAngle() /
M_PI * 180, 0,
'f', 1);
110 return mUseSimpleVisualization;
115 mUseSimpleVisualization = val;
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
virtual void parseXml(QDomNode &dataNode)
Use a XML node to load data.
static AngleMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
virtual void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
virtual Vector3D getRefCoord() const
boost::shared_ptr< class AngleMetric > AngleMetricPtr
virtual QString getValueAsString() const
static DoubleBoundingBox3D fromCloud(std::vector< Vector3D > cloud)
bool getUseSimpleVisualization() const
void parseXml(QDomNode &dataNode)
Use a XML node to load data.
virtual bool isValid() const
virtual DoubleBoundingBox3D boundingBox() const
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
double dot(const Vector3D &a, const Vector3D &b)
compute inner product (or dot product) of a and b.
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.
void setUseSimpleVisualization(bool val)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
std::vector< Vector3D > getEndpoints() const
Data class that represents an angle between two lines.
Namespace for all CustusX production code.