NorMIT-nav  22.09
An IGT application
cxDoublePairPropertyBase.h
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 #ifndef CXDOUBLEPAIRPROPERTYBASE_H_
13 #define CXDOUBLEPAIRPROPERTYBASE_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include "cxProperty.h"
18 #include "cxDoubleRange.h"
19 #include "cxMathBase.h"
20 #include "cxTypeConversions.h"
21 #include "cxVector3D.h"
22 
23 namespace cx
24 {
33 class cxResource_EXPORT DoublePairPropertyBase : public Property
34 {
35 Q_OBJECT
36 public:
38 // DoubleSpanSliderAdapter();
39 
40 public:
41  // basic methods
42  virtual QString getDisplayName() const = 0;
43 // virtual bool setValue(const std::pair<double,double>& value) = 0; ///< set the data value.
44  virtual bool setValue(const Eigen::Vector2d& value) = 0;
45 // virtual std::pair<double,double> getValue() const = 0; ///< get the data value.
46  virtual Eigen::Vector2d getValue() const = 0;
47 
48  virtual void setValueRange(DoubleRange range) = 0;
49 
50  virtual QVariant getValueAsVariant() const
51  {
52  QString val = qstring_cast(this->getValue());
53  return QVariant(val);
54  }
55 
56  virtual void setValueFromVariant(QVariant value)
57  {
58  Eigen::Vector2d val = fromString(value.toString());
59  this->setValue(val);
60  }
61 
62 public:
63  // optional methods
64  virtual QString getHelp() const
65  {
66  return QString();
67  }
68  virtual DoubleRange getValueRange() const
69  {
70  return DoubleRange(-1000, 1000, 0.1);
71  }
72  virtual double convertInternal2Display(double internal)
73  {
74  return internal;
75  }
76  virtual double convertDisplay2Internal(double display)
77  {
78  return display;
79  }
80  virtual int getValueDecimals() const
81  {
82  return 0;
83  }
84 
85 };
86 typedef boost::shared_ptr<DoublePairPropertyBase> DoublePairPropertyBasePtr;
87 
89 class cxResource_EXPORT DoubleSpanSliderAdapterNull: public DoublePairPropertyBase
90 {
91 Q_OBJECT
92 
93 public:
95  {
96  }
97  virtual QString getDisplayName() const
98  {
99  return "dummy";
100  }
101 // virtual bool setValue(const std::pair<double,double>& value)
102  virtual bool setValue(const Eigen::Vector2d& value)
103  {
104  return false;
105  }
106 // virtual std::pair<double,double> getValue() const
107  virtual Eigen::Vector2d getValue() const
108  {
109 // return std::make_pair(0,0);
110  return Eigen::Vector2d(0, 0);
111  }
112  virtual void connectValueSignals(bool on)
113  {
114  }
115 };
116 
117 } // namespace cx
118 #endif // CXDOUBLEPAIRPROPERTYBASE_H_
cx::DoublePairPropertyBasePtr
boost::shared_ptr< DoublePairPropertyBase > DoublePairPropertyBasePtr
Definition: cxDoublePairPropertyBase.h:86
qstring_cast
QString qstring_cast(const T &val)
Definition: cxTypeConversions.h:46
cx::DoublePairPropertyBase::setValueFromVariant
virtual void setValueFromVariant(QVariant value)
Definition: cxDoublePairPropertyBase.h:56
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxDoubleRange.h
cx::DoubleSpanSliderAdapterNull::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxDoublePairPropertyBase.h:97
cx::DoubleSpanSliderAdapterNull::getValue
virtual Eigen::Vector2d getValue() const
get the data value.
Definition: cxDoublePairPropertyBase.h:107
cxVector3D.h
cx::DoublePairPropertyBase::getValueRange
virtual DoubleRange getValueRange() const
Definition: cxDoublePairPropertyBase.h:68
cx::DoublePairPropertyBase::~DoublePairPropertyBase
virtual ~DoublePairPropertyBase()
Definition: cxDoublePairPropertyBase.h:37
cx::DoublePairPropertyBase
Abstract interface for interaction with internal data structure: A pair of doubles.
Definition: cxDoublePairPropertyBase.h:33
cx::DoubleSpanSliderAdapterNull::setValue
virtual bool setValue(const Eigen::Vector2d &value)
set the data value.
Definition: cxDoublePairPropertyBase.h:102
cxTypeConversions.h
cxProperty.h
cx::DoublePairPropertyBase::getValueAsVariant
virtual QVariant getValueAsVariant() const
Definition: cxDoublePairPropertyBase.h:50
cx::Property
Superclass for all data adapters.
Definition: cxProperty.h:43
cx::DoubleSpanSliderAdapterNull::~DoubleSpanSliderAdapterNull
virtual ~DoubleSpanSliderAdapterNull()
Definition: cxDoublePairPropertyBase.h:94
cx::DoubleRange
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
cx::DoubleSpanSliderAdapterNull::connectValueSignals
virtual void connectValueSignals(bool on)
Definition: cxDoublePairPropertyBase.h:112
cxMathBase.h
cx::fromString
Eigen::Vector2d fromString(const QString &text)
Definition: cxVector3D.cpp:106
cx::DoubleSpanSliderAdapterNull
Definition: cxDoublePairPropertyBase.h:89