Fraxinus  22.04
An IGT application
cxSphereMetric.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxSphereMetric.h"
13 
14 #include "cxBoundingBox3D.h"
15 #include "cxTypeConversions.h"
16 #include "cxPatientModelService.h"
17 
18 namespace cx
19 {
20 
21 SphereMetric::SphereMetric(const QString& uid, const QString& name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider) :
22  DataMetric(uid, name, dataManager, spaceProvider)
23 {
24  mArguments.reset(new MetricReferenceArgumentList(QStringList() << "position"));
25  connect(mArguments.get(), SIGNAL(argumentsChanged()), this, SIGNAL(transformChanged()));
26  mRadius = 5;
27 }
28 
29 SphereMetricPtr SphereMetric::create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
30 {
31  return SphereMetricPtr(new SphereMetric(uid, name, dataManager, spaceProvider));
32 }
33 
35 {
36 }
37 
38 void SphereMetric::addXml(QDomNode& dataNode)
39 {
40  DataMetric::addXml(dataNode);
41  mArguments->addXml(dataNode);
42  dataNode.toElement().setAttribute("radius", mRadius);
43 }
44 
45 void SphereMetric::parseXml(QDomNode& dataNode)
46 {
47  DataMetric::parseXml(dataNode);
48 
49  mArguments->parseXml(dataNode, mDataManager->getDatas());
50  mRadius = dataNode.toElement().attribute("radius", qstring_cast(mRadius)).toDouble();
51 }
52 
54 {
55  return !mArguments->getRefCoords().empty();
56 }
57 
59 {
60  return this->boundingBox().center();
61 }
62 
64 {
65  return DoubleBoundingBox3D::fromCloud(mArguments->getRefCoords());
66 }
67 
68 void SphereMetric::setRadius(double val)
69 {
70  mRadius = val;
71  emit propertiesChanged();
72 }
73 
75 {
76  return mRadius;
77 }
78 
80 {
81  return QString("%1").arg(this->getRadius(), 0, 'f', 1);
82 }
83 
84 }
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
QString qstring_cast(const T &val)
virtual DoubleBoundingBox3D boundingBox() const
void setRadius(double val)
virtual QString getValueAsString() const
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
void propertiesChanged()
emitted when one of the metadata properties (uid, name etc) changes
void transformChanged()
emitted when transform is changed
boost::shared_ptr< class SphereMetric > SphereMetricPtr
PatientModelServicePtr mDataManager
Definition: cxDataMetric.h:67
static DoubleBoundingBox3D fromCloud(std::vector< Vector3D > cloud)
virtual DoubleBoundingBox3D boundingBox() const
Data class that represents a donut.
double getRadius() const
static SphereMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
void parseXml(QDomNode &dataNode)
Use a XML node to load data.
virtual void parseXml(QDomNode &dataNode)
Use a XML node to load data.
virtual ~SphereMetric()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
virtual bool isValid() 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::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
Vector3D center() const
double getRadius() const
virtual Vector3D getRefCoord() const
virtual void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
Namespace for all CustusX production code.