CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxVector3DProperty.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 "cxVector3DProperty.h"
13 
14 #include <iostream>
15 #include <QDomElement>
16 #include <QStringList>
17 #include "cxTypeConversions.h"
18 
19 namespace cx
20 {
21 
25 Vector3DPropertyPtr Vector3DProperty::initialize(const QString& uid, QString name, QString help,
26  Vector3D value, DoubleRange range, int decimals, QDomNode root)
27 {
29  retval->mUid = uid;
30  retval->mName = name.isEmpty() ? uid : name;
31  retval->mHelp = help;
32  retval->mRange = range;
33  retval->mStore = XmlOptionItem(uid, root.toElement());
34  retval->mValue = Vector3D::fromString(retval->mStore.readValue(qstring_cast(Vector3D(0, 0, 0))));
35  retval->mDecimals = decimals;
36  return retval;
37 }
38 
39 Vector3DProperty::Vector3DProperty()
40 {
41  mFactor = 1.0;
42 }
43 
45 {
46  mFactor = factor;
47 }
48 
50 {
51  return mName;
52 }
53 
54 QString Vector3DProperty::getUid() const
55 {
56  return mUid;
57 }
58 
60 {
61  return mHelp;
62 }
63 
65 {
66  return mValue;
67 }
68 
70 {
71  if (similar(val, mValue))
72  return false;
73 
74  // std::cout << "set val " << " " << val << " , org=" << mValue << std::endl;
75 
76  mValue = val;
77  mStore.writeValue(qstring_cast(val));
78  emit
79  valueWasSet();
80  emit
81  changed();
82  return true;
83 }
84 
86 {
87  return mRange;
88 }
89 
91 {
92  mRange = range;
93  emit changed();
94 }
95 
97 {
98  return mDecimals;
99 }
100 
101 } // namespace cx
QString qstring_cast(const T &val)
virtual int getValueDecimals() const
number of relevant decimals in value
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
virtual bool setValue(const Vector3D &value)
set the data value.
Helper class for storing one string value in an xml document.
virtual Vector3D getValue() const
get the data value.
static Vector3DPropertyPtr initialize(const QString &uid, QString name, QString help, Vector3D value, DoubleRange range, int decimals, QDomNode root=QDomNode())
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual DoubleRange getValueRange() const
void changed()
emit when the underlying data value is changed: The user interface will be updated.
void writeValue(const QString &val)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
boost::shared_ptr< class Vector3DProperty > Vector3DPropertyPtr
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
void setInternal2Display(double factor)
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
virtual QString getUid() const
Represents one option of the double type.
virtual void setValueRange(DoubleRange range)
range of value. Use if data is constrained to a set.
Namespace for all CustusX production code.