Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxDoublePairProperty.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 "cxDoublePairProperty.h"
13 #include "cxTypeConversions.h"
14 #include "cxVector3D.h"
15 
16 namespace cx
17 {
18 
22 DoublePairPropertyPtr DoublePairProperty::initialize(const QString& uid, QString name, QString help,
23  DoubleRange range, int decimals, QDomNode root)
24 {
26  retval->mUid = uid;
27  retval->mName = name.isEmpty() ? uid : name;
28  retval->mHelp = help;
29  retval->mRange = range;
30  retval->mStore = XmlOptionItem(uid, root.toElement());
31  retval->mValue = fromString(retval->mStore.readValue(qstring_cast(Eigen::Vector2d(0, 0))));
32  retval->mDecimals = decimals;
33  return retval;
34 }
35 
36 DoublePairProperty::DoublePairProperty()
37 {
38  mFactor = 1.0;
39 }
40 
42 {
43  mFactor = factor;
44 }
45 
47 {
48  return mName;
49 }
50 
52 {
53  return mUid;
54 }
55 
57 {
58  return mHelp;
59 }
60 
61 Eigen::Vector2d DoublePairProperty::getValue() const
62 {
63  return mValue;
64 }
65 
66 bool DoublePairProperty::setValue(const Eigen::Vector2d& val)
67 {
68  if (val == mValue)
69  return false;
70 
71  mValue = val;
72  mStore.writeValue(qstring_cast(val));
73  emit valueWasSet();
74  emit changed();
75  return true;
76 }
77 
79 {
80  return mRange;
81 }
82 
84 {
85  mRange = range;
86  emit changed();
87 }
88 
90 {
91  return mDecimals;
92 }
93 
94 } // namespace cx
QString qstring_cast(const T &val)
void setInternal2Display(double factor)
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual DoubleRange getValueRange() const
Eigen::Vector2d fromString(const QString &text)
Definition: cxVector3D.cpp:106
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
virtual Eigen::Vector2d getValue() const
get the data value.
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
virtual void setValueRange(DoubleRange range)
range of value. Use if data is constrained to a set.
Helper class for storing one string value in an xml document.
virtual int getValueDecimals() const
number of relevant decimals in value
Implementation of DoublePairPropertyBase.
virtual bool setValue(const Eigen::Vector2d &value)
set the data value.
virtual QString getUid() const
void changed()
emit when the underlying data value is changed: The user interface will be updated.
void writeValue(const QString &val)
boost::shared_ptr< class DoublePairProperty > DoublePairPropertyPtr
static DoublePairPropertyPtr initialize(const QString &uid, QString name, QString help, DoubleRange range, int decimals, QDomNode root=QDomNode())
Namespace for all CustusX production code.