CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxToolMetric.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 "cxToolMetric.h"
13 #include "cxTool.h"
14 #include "cxTypeConversions.h"
15 
16 namespace cx
17 {
18 
19 //DataPtr ToolMetricReader::load(const QString& uid, const QString& filename)
20 //{
21 // return DataPtr(new ToolMetric(uid, filename));
22 //}
23 
24 ToolMetricPtr ToolMetric::create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
25 {
26  return ToolMetricPtr(new ToolMetric(uid, name, dataManager, spaceProvider));
27 }
28 
29 //ToolMetricPtr ToolMetric::create(QDomNode node)
30 //{
31 // ToolMetricPtr retval = ToolMetric::create("");
32 // retval->parseXml(node);
33 // return retval;
34 //}
35 
36 ToolMetric::ToolMetric(const QString& uid, const QString& name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider) :
37  cx::FrameMetricBase(uid, name, dataManager, spaceProvider),
38  mToolOffset(0.0)
39 {
40 }
41 
43 {
44 }
45 
47 {
48  return mToolOffset;
49 }
50 
51 void ToolMetric::setToolOffset(double val)
52 {
53  mToolOffset = val;
54  emit propertiesChanged();
55 }
56 
57 QString ToolMetric::getToolName() const
58 {
59  return mToolName;
60 }
61 
62 void ToolMetric::setToolName(const QString& val)
63 {
64  mToolName = val;
65  emit propertiesChanged();
66 }
67 
68 void ToolMetric::addXml(QDomNode& dataNode)
69 {
70  DataMetric::addXml(dataNode);
71 
72  dataNode.toElement().setAttribute("space", mSpace.toString());
73  dataNode.toElement().setAttribute("frame", qstring_cast(mFrame));
74 
75  dataNode.toElement().setAttribute("toolname", mToolName);
76  dataNode.toElement().setAttribute("tooloffset", qstring_cast(mToolOffset));
77 }
78 
79 void ToolMetric::parseXml(QDomNode& dataNode)
80 {
81  DataMetric::parseXml(dataNode);
82 
83  this->setSpace(CoordinateSystem::fromString(dataNode.toElement().attribute("space", mSpace.toString())));
84  this->setFrame(Transform3D::fromString(dataNode.toElement().attribute("frame", qstring_cast(mFrame))));
85  this->setToolName(dataNode.toElement().attribute("toolname", mToolName));
86  this->setToolOffset(dataNode.toElement().attribute("tooloffset", qstring_cast(mToolOffset)).toDouble());
87 }
88 
89 
90 } //namespace cx
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
QString qstring_cast(const T &val)
virtual void setFrame(const Transform3D &qMt)
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
boost::shared_ptr< class ToolMetric > ToolMetricPtr
Definition: cxToolMetric.h:24
CoordinateSystem mSpace
void propertiesChanged()
emitted when one of the metadata properties (uid, name etc) changes
QString getToolName() const
virtual void setSpace(CoordinateSystem space)
virtual void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
static ToolMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
void parseXml(QDomNode &dataNode)
Use a XML node to load data.
Abstract base class for frame metric.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
virtual void parseXml(QDomNode &dataNode)
Use a XML node to load data.
void setToolName(const QString &val)
virtual ~ToolMetric()
double getToolOffset() const
void setToolOffset(double val)
static CoordinateSystem fromString(QString text)
Namespace for all CustusX production code.
Transform3D mFrame
frame qFt described in local space q = mSpace