46 DataMetric(uid, name, dataManager, spaceProvider)
48 mUseSimpleVisualization =
false;
49 mArguments.reset(
new MetricReferenceArgumentList(QStringList() <<
"point 0" <<
"point 1" <<
"point 2" <<
"point 3"));
50 mArguments->setValidArgumentTypes(QStringList() <<
"pointMetric");
51 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SLOT(resetCachedValues()));
52 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SIGNAL(
transformChanged()));
67 mArguments->addXml(dataNode);
68 dataNode.toElement().setAttribute(
"useSimpleVisualization", QString::number(mUseSimpleVisualization));
75 mArguments->parseXml(dataNode, mDataManager->getDatas());
77 mUseSimpleVisualization = dataNode.toElement().attribute(
"useSimpleVisualization", QString::number(mUseSimpleVisualization)).toInt();
78 this->resetCachedValues();
81 void AngleMetric::resetCachedValues()
83 mCachedEndPoints.reset();
88 return !this->getEndpoints().empty();
93 if (!mCachedEndPoints.isValid())
95 mCachedEndPoints.set(mArguments->getRefCoords());
97 return mCachedEndPoints.get();
102 return this->boundingBox().center();
107 std::vector<Vector3D> p = this->getEndpoints();
112 Vector3D a = (p[0] - p[1]).normalized();
113 Vector3D b = (p[3] - p[2]).normalized();
115 double angle = acos(
dot(a, b) / a.length() / b.length());
121 return QString(
"%1*").arg(this->getAngle() /
M_PI * 180, 0,
'f', 1);
131 return mUseSimpleVisualization;
136 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.