46 DataMetric(uid, name, dataManager, spaceProvider)
48 mArguments.reset(
new MetricReferenceArgumentList(QStringList() <<
"line endpoint 0" <<
"line endpoint 1"));
49 mArguments->setValidArgumentTypes(QStringList() <<
"pointMetric" <<
"planeMetric");
51 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SLOT(resetCachedValues()));
52 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SIGNAL(transformChanged()));
77 mArguments->addXml(dataNode);
85 this->resetCachedValues();
88 void DistanceMetric::resetCachedValues()
90 mCachedEndPoints.
reset();
95 if (!mCachedEndPoints.
isValid())
97 mCachedEndPoints.
set(this->getEndpointsUncached());
99 return mCachedEndPoints.
get();
102 std::vector<Vector3D> DistanceMetric::getEndpointsUncached()
const
104 DataPtr a0 = mArguments->get(0);
105 DataPtr a1 = mArguments->get(1);
108 return std::vector<Vector3D>();
109 std::vector<Vector3D> retval(2);
115 if ((a0->getType() ==
"pointMetric") && (a1->getType() ==
"pointMetric"))
120 else if ((a0->getType() ==
"planeMetric") && (a1->getType() ==
"pointMetric"))
122 Plane3D plane = boost::dynamic_pointer_cast<PlaneMetric>(a0)->getRefPlane();
125 retval[0] = plane.projection(p);
128 else if ((a0->getType() ==
"pointMetric") && (a1->getType() ==
"planeMetric"))
130 Plane3D plane = boost::dynamic_pointer_cast<PlaneMetric>(a1)->getRefPlane();
133 retval[1] = plane.projection(p);
138 return std::vector<Vector3D>();
147 if (endpoints.size() != 2)
150 return (endpoints[1] - endpoints[0]).length();
155 return QString(
"%1 mm").arg(this->
getDistance(), 0,
'f', 1);
165 return QString(
"%1 %2")
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
QString qstring_cast(const T &val)
virtual ~DistanceMetric()
static DistanceMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
virtual DoubleBoundingBox3D boundingBox() const
PatientModelServicePtr mDataManager
virtual QString getValueAsString() const
static DoubleBoundingBox3D fromCloud(std::vector< Vector3D > cloud)
boost::shared_ptr< class Data > DataPtr
void parseXml(QDomNode &dataNode)
Use a XML node to load data.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
virtual Vector3D getRefCoord() const
QString getSingleLineHeader() const
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
Data class that represents a distance between two points, or a point and a plane. ...
double getDistance() const
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::Hyperplane< double, 3 > Plane3D
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
std::vector< Vector3D > getEndpoints() const
return the two endpoints in reference space. None if invalid.
Data class that represents a single point.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
virtual void parseXml(QDomNode &dataNode)
Use a XML node to load data.
virtual void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
virtual QString getAsSingleLineString() const
virtual bool isValid() const