NorMIT-nav  22.09
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
cx::DoublePairProperty::getUid
virtual QString getUid() const
Definition: cxDoublePairProperty.cpp:51
qstring_cast
QString qstring_cast(const T &val)
Definition: cxTypeConversions.h:46
cxDoublePairProperty.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::DoublePairProperty::getValue
virtual Eigen::Vector2d getValue() const
get the data value.
Definition: cxDoublePairProperty.cpp:61
cx::DoublePairProperty::initialize
static DoublePairPropertyPtr initialize(const QString &uid, QString name, QString help, DoubleRange range, int decimals, QDomNode root=QDomNode())
Definition: cxDoublePairProperty.cpp:22
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cx::DoublePairProperty::valueWasSet
void valueWasSet()
cxVector3D.h
cx::DoublePairProperty::setInternal2Display
void setInternal2Display(double factor)
Definition: cxDoublePairProperty.cpp:41
cx::DoublePairProperty::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxDoublePairProperty.cpp:46
cx::XmlOptionItem
Helper class for storing one string value in an xml document.
Definition: cxXmlOptionItem.h:38
cxTypeConversions.h
cx::DoublePairPropertyPtr
boost::shared_ptr< class DoublePairProperty > DoublePairPropertyPtr
Definition: cxForwardDeclarations.h:145
cx::DoublePairProperty::setValue
virtual bool setValue(const Eigen::Vector2d &value)
set the data value.
Definition: cxDoublePairProperty.cpp:66
cx::DoublePairProperty::setValueRange
virtual void setValueRange(DoubleRange range)
range of value. Use if data is constrained to a set.
Definition: cxDoublePairProperty.cpp:83
cx::DoublePairProperty
Implementation of DoublePairPropertyBase.
Definition: cxDoublePairProperty.h:40
cx::XmlOptionItem::writeValue
void writeValue(const QString &val)
Definition: cxXmlOptionItem.cpp:189
cx::DoubleRange
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
cx::DoublePairProperty::getValueRange
virtual DoubleRange getValueRange() const
Definition: cxDoublePairProperty.cpp:78
cx::DoublePairProperty::getValueDecimals
virtual int getValueDecimals() const
number of relevant decimals in value
Definition: cxDoublePairProperty.cpp:89
cx::DoublePairProperty::getHelp
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
Definition: cxDoublePairProperty.cpp:56
cx::fromString
Eigen::Vector2d fromString(const QString &text)
Definition: cxVector3D.cpp:106