Fraxinus  18.10
An IGT application
cxDoublePropertyBase.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 /*
14  * sscDoubleProperty.h
15  *
16  * Created on: Jun 23, 2010
17  * Author: christiana
18  */
19 #ifndef CXDOUBLEPROPERTYBASE_H_
20 #define CXDOUBLEPROPERTYBASE_H_
21 
22 #include "cxResourceExport.h"
23 
24 #include <boost/shared_ptr.hpp>
25 #include <QString>
26 #include <QObject>
27 #include "cxDoubleRange.h"
28 #include "cxProperty.h"
29 
30 namespace cx
31 {
32 
70 class cxResource_EXPORT DoublePropertyBase: public Property
71 {
72 Q_OBJECT
73 public:
74  DoublePropertyBase() : mGuiRepresentation(grSPINBOX){}
75  virtual ~DoublePropertyBase(){}
76 
77 public:
79  {
82  grDIAL
83  };
84 
85  // basic methods
86  virtual QString getDisplayName() const = 0;
87 
88  virtual QVariant getValueAsVariant() const
89  {
90  return QVariant(this->getValue());
91  }
92  virtual void setValueFromVariant(QVariant val)
93  {
94  this->setValue(val.toDouble());
95  }
96 
97 
98  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
99  virtual bool setValue(double value) = 0;
100  virtual double getValue() const = 0;
101 
102  virtual void setGuiRepresentation(GuiRepresentation type) { mGuiRepresentation = type; };
103  virtual GuiRepresentation getGuiRepresentation() { return mGuiRepresentation; };
104 
105 public:
106  // optional methods
107  virtual QString getHelp() const
108  {
109  return QString();
110  }
111  virtual DoubleRange getValueRange() const
112  {
113  return DoubleRange(0, 1, 0.01);
114  }
115  virtual double convertInternal2Display(double internal)
116  {
117  return internal;
118  }
119  virtual double convertDisplay2Internal(double display)
120  {
121  return display;
122  }
123  virtual int getValueDecimals() const
124  {
125  return 0;
126  }
127 
128 protected:
130 
131 };
132 typedef boost::shared_ptr<DoublePropertyBase> DoublePropertyBasePtr;
133 
135 class cxResource_EXPORT DoublePropertyNull: public DoublePropertyBase
136 {
137 Q_OBJECT
138 
139 public:
141  {
142  }
143  virtual QString getDisplayName() const
144  {
145  return "dummy";
146  }
147  virtual bool setValue(double value)
148  {
149  return false;
150  }
151  virtual double getValue() const
152  {
153  return 0;
154  }
155  virtual void connectValueSignals(bool on)
156  {
157  }
158 };
159 
160 }
161 
162 #endif /* CXDOUBLEPROPERTYBASE_H_ */
virtual void connectValueSignals(bool on)
virtual void setGuiRepresentation(GuiRepresentation type)
virtual void setValueFromVariant(QVariant val)
virtual DoubleRange getValueRange() const
virtual GuiRepresentation getGuiRepresentation()
virtual QVariant getValueAsVariant() const
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
Superclass for all data adapters.
Definition: cxProperty.h:43
virtual double 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 double convertInternal2Display(double internal)
range of value
virtual int getValueDecimals() const
number of relevant decimals in value
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
GuiRepresentation mGuiRepresentation
virtual bool setValue(double value)
set the data value.
virtual double convertDisplay2Internal(double display)
conversion from internal value to display value
virtual QString getUid() const
Namespace for all CustusX production code.