CustusX  22.04-rc5
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_
QString qstring_cast(const T &val)
virtual double convertDisplay2Internal(double display)
conversion from internal value to display value
virtual int getValueDecimals() const
number of relevant decimals in value
virtual double convertInternal2Display(double internal)
range of value
Eigen::Vector2d fromString(const QString &text)
Definition: cxVector3D.cpp:106
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
virtual QVariant getValueAsVariant() const
Superclass for all data adapters.
Definition: cxProperty.h:43
boost::shared_ptr< DoublePairPropertyBase > DoublePairPropertyBasePtr
virtual void setValueFromVariant(QVariant value)
virtual bool setValue(const Eigen::Vector2d &value)
set the data value.
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
virtual DoubleRange getValueRange() const
virtual Eigen::Vector2d getValue() const
get the data value.
Abstract interface for interaction with internal data structure: A pair of doubles.
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Namespace for all CustusX production code.