NorMIT-nav  2023.01.05-dev+develop.0da12
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_ */
cx::DoublePropertyBase::getUid
virtual QString getUid() const
Definition: cxDoublePropertyBase.h:98
cx::DoublePropertyBase::getValueRange
virtual DoubleRange getValueRange() const
Definition: cxDoublePropertyBase.h:111
cx::DoublePropertyBase::setValueFromVariant
virtual void setValueFromVariant(QVariant val)
Definition: cxDoublePropertyBase.h:92
cx::DoublePropertyNull::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxDoublePropertyBase.h:143
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::DoublePropertyNull
Definition: cxDoublePropertyBase.h:135
cxDoubleRange.h
cx::DoublePropertyBase::setGuiRepresentation
virtual void setGuiRepresentation(GuiRepresentation type)
Definition: cxDoublePropertyBase.h:102
cx::DoublePropertyNull::~DoublePropertyNull
virtual ~DoublePropertyNull()
Definition: cxDoublePropertyBase.h:140
cx::DoublePropertyBase::~DoublePropertyBase
virtual ~DoublePropertyBase()
Definition: cxDoublePropertyBase.h:75
cx::DoublePropertyBase::GuiRepresentation
GuiRepresentation
Definition: cxDoublePropertyBase.h:78
cx::DoublePropertyBase::grSLIDER
@ grSLIDER
Definition: cxDoublePropertyBase.h:81
cx::DoublePropertyBase::DoublePropertyBase
DoublePropertyBase()
Definition: cxDoublePropertyBase.h:74
cx::DoublePropertyNull::getValue
virtual double getValue() const
get the data value.
Definition: cxDoublePropertyBase.h:151
cx::DoublePropertyNull::connectValueSignals
virtual void connectValueSignals(bool on)
Definition: cxDoublePropertyBase.h:155
cx::DoublePropertyBase::mGuiRepresentation
GuiRepresentation mGuiRepresentation
Definition: cxDoublePropertyBase.h:129
cxProperty.h
cx::DoublePropertyBase
Definition: cxDoublePropertyBase.h:70
cx::DoublePropertyNull::setValue
virtual bool setValue(double value)
set the data value.
Definition: cxDoublePropertyBase.h:147
cx::DoublePropertyBasePtr
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
Definition: cxIGTLinkStreamerService.h:21
cx::Property
Superclass for all data adapters.
Definition: cxProperty.h:43
cx::DoublePropertyBase::getValueAsVariant
virtual QVariant getValueAsVariant() const
Definition: cxDoublePropertyBase.h:88
cx::DoubleRange
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
cx::DoublePropertyBase::grSPINBOX
@ grSPINBOX
Definition: cxDoublePropertyBase.h:80
cx::DoublePropertyBase::getGuiRepresentation
virtual GuiRepresentation getGuiRepresentation()
Definition: cxDoublePropertyBase.h:103