Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 /*
35  * sscDoubleProperty.h
36  *
37  * Created on: Jun 23, 2010
38  * Author: christiana
39  */
40 #ifndef CXDOUBLEPROPERTYBASE_H_
41 #define CXDOUBLEPROPERTYBASE_H_
42 
43 #include "cxResourceExport.h"
44 
45 #include <boost/shared_ptr.hpp>
46 #include <QString>
47 #include <QObject>
48 #include "cxDoubleRange.h"
49 #include "cxProperty.h"
50 
51 namespace cx
52 {
53 
91 class cxResource_EXPORT DoublePropertyBase: public Property
92 {
93 Q_OBJECT
94 public:
95  DoublePropertyBase() : mGuiRepresentation(grSPINBOX){}
96  virtual ~DoublePropertyBase(){}
97 
98 public:
100  {
103  grDIAL
104  };
105 
106  // basic methods
107  virtual QString getDisplayName() const = 0;
108 
109  virtual QVariant getValueAsVariant() const
110  {
111  return QVariant(this->getValue());
112  }
113  virtual void setValueFromVariant(QVariant val)
114  {
115  this->setValue(val.toDouble());
116  }
117 
118 
119  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
120  virtual bool setValue(double value) = 0;
121  virtual double getValue() const = 0;
122 
123  virtual void setGuiRepresentation(GuiRepresentation type) { mGuiRepresentation = type; };
124  virtual GuiRepresentation getGuiRepresentation() { return mGuiRepresentation; };
125 
126 public:
127  // optional methods
128  virtual QString getHelp() const
129  {
130  return QString();
131  }
132  virtual DoubleRange getValueRange() const
133  {
134  return DoubleRange(0, 1, 0.01);
135  }
136  virtual double convertInternal2Display(double internal)
137  {
138  return internal;
139  }
140  virtual double convertDisplay2Internal(double display)
141  {
142  return display;
143  }
144  virtual int getValueDecimals() const
145  {
146  return 0;
147  }
148 
149 protected:
151 
152 };
153 typedef boost::shared_ptr<DoublePropertyBase> DoublePropertyBasePtr;
154 
156 class cxResource_EXPORT DoublePropertyNull: public DoublePropertyBase
157 {
158 Q_OBJECT
159 
160 public:
162  {
163  }
164  virtual QString getDisplayName() const
165  {
166  return "dummy";
167  }
168  virtual bool setValue(double value)
169  {
170  return false;
171  }
172  virtual double getValue() const
173  {
174  return 0;
175  }
176  virtual void connectValueSignals(bool on)
177  {
178  }
179 };
180 
181 }
182 
183 #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:53
Superclass for all data adapters.
Definition: cxProperty.h:64
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