Fraxinus  18.10
An IGT application
cxVector3DPropertyBase.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 
13 #ifndef CXVECTOR3DPROPERTYBASE_H_
14 #define CXVECTOR3DPROPERTYBASE_H_
15 
16 #include "cxResourceExport.h"
17 
18 #include <boost/shared_ptr.hpp>
19 #include <QString>
20 #include <QObject>
21 #include "cxDoubleRange.h"
22 #include "cxProperty.h"
23 #include "cxVector3D.h"
24 
25 namespace cx
26 {
27 
34 class cxResource_EXPORT Vector3DPropertyBase: public Property
35 {
36 Q_OBJECT
37 public:
39  {
40  }
41 
42 public:
43  // basic methods
44  virtual QString getDisplayName() const = 0;
45  virtual bool setValue(const Vector3D& value) = 0;
46  virtual Vector3D getValue() const = 0;
47 
48  virtual QVariant getValueAsVariant() const
49  {
50  QString val = prettyFormat(this->getValue(), this->getValueDecimals());
51  return QVariant(val);
52  // return QVariant(this->getValue());
53  }
54 
55  virtual void setValueFromVariant(QVariant value)
56  {
57  Vector3D val = Vector3D::fromString(value.toString());
58  this->setValue(val);
59  }
60 
61 public:
62  // optional methods
63  virtual QString getHelp() const
64  {
65  return QString();
66  }
67  virtual DoubleRange getValueRange() const
68  {
69  return DoubleRange(-1000, 1000, 0.1);
70  }
71  virtual double convertInternal2Display(double internal)
72  {
73  return internal;
74  }
75  virtual double convertDisplay2Internal(double display)
76  {
77  return display;
78  }
79  virtual int getValueDecimals() const
80  {
81  return 0;
82  }
83 };
84 typedef boost::shared_ptr<Vector3DPropertyBase> Vector3DPropertyBasePtr;
85 
87 class cxResource_EXPORT Vector3DPropertyNull: public Vector3DPropertyBase
88 {
89 Q_OBJECT
90 
91 public:
93  {
94  }
95  virtual QString getDisplayName() const
96  {
97  return "dummy";
98  }
99  virtual bool setValue(const Vector3D& value)
100  {
101  return false;
102  }
103  virtual Vector3D getValue() const
104  {
105  return Vector3D(0, 0, 0);
106  }
107  virtual void connectValueSignals(bool on)
108  {
109  }
110 };
111 
112 }
113 
114 #endif /* CXVECTOR3DPROPERTYBASE_H_ */
virtual int getValueDecimals() const
number of relevant decimals in value
virtual double convertDisplay2Internal(double display)
conversion from internal value to display value
virtual DoubleRange getValueRange() const
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
Superclass for all data adapters.
Definition: cxProperty.h:43
QString prettyFormat(Vector3D val, int decimals, int fieldWidth)
Definition: cxVector3D.cpp:98
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
virtual Vector3D getValue() const
get the data value.
virtual QString getDisplayName() const
name of data entity. Used for display to user.
boost::shared_ptr< Vector3DPropertyBase > Vector3DPropertyBasePtr
Abstract interface for interaction with internal Vector3D-valued data.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
virtual double convertInternal2Display(double internal)
range of value
virtual void connectValueSignals(bool on)
virtual bool setValue(const Vector3D &value)
set the data value.
virtual void setValueFromVariant(QVariant value)
virtual QVariant getValueAsVariant() const
Namespace for all CustusX production code.