Fraxinus  16.5.0-fx-rc8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 #ifndef CXDOUBLEPAIRPROPERTYBASE_H_
34 #define CXDOUBLEPAIRPROPERTYBASE_H_
35 
36 #include "cxResourceExport.h"
37 
38 #include "cxProperty.h"
39 #include "cxDoubleRange.h"
40 #include "cxMathBase.h"
41 #include "cxTypeConversions.h"
42 #include "cxVector3D.h"
43 
44 namespace cx
45 {
54 class cxResource_EXPORT DoublePairPropertyBase : public Property
55 {
56 Q_OBJECT
57 public:
59 // DoubleSpanSliderAdapter();
60 
61 public:
62  // basic methods
63  virtual QString getDisplayName() const = 0;
64 // virtual bool setValue(const std::pair<double,double>& value) = 0; ///< set the data value.
65  virtual bool setValue(const Eigen::Vector2d& value) = 0;
66 // virtual std::pair<double,double> getValue() const = 0; ///< get the data value.
67  virtual Eigen::Vector2d getValue() const = 0;
68 
69  virtual void setValueRange(DoubleRange range) = 0;
70 
71  virtual QVariant getValueAsVariant() const
72  {
73  QString val = qstring_cast(this->getValue());
74  return QVariant(val);
75  }
76 
77  virtual void setValueFromVariant(QVariant value)
78  {
79  Eigen::Vector2d val = fromString(value.toString());
80  this->setValue(val);
81  }
82 
83 public:
84  // optional methods
85  virtual QString getHelp() const
86  {
87  return QString();
88  }
89  virtual DoubleRange getValueRange() const
90  {
91  return DoubleRange(-1000, 1000, 0.1);
92  }
93  virtual double convertInternal2Display(double internal)
94  {
95  return internal;
96  }
97  virtual double convertDisplay2Internal(double display)
98  {
99  return display;
100  }
101  virtual int getValueDecimals() const
102  {
103  return 0;
104  }
105 
106 };
107 typedef boost::shared_ptr<DoublePairPropertyBase> DoublePairPropertyBasePtr;
108 
111 {
112 Q_OBJECT
113 
114 public:
116  {
117  }
118  virtual QString getDisplayName() const
119  {
120  return "dummy";
121  }
122 // virtual bool setValue(const std::pair<double,double>& value)
123  virtual bool setValue(const Eigen::Vector2d& value)
124  {
125  return false;
126  }
127 // virtual std::pair<double,double> getValue() const
128  virtual Eigen::Vector2d getValue() const
129  {
130 // return std::make_pair(0,0);
131  return Eigen::Vector2d(0, 0);
132  }
133  virtual void connectValueSignals(bool on)
134  {
135  }
136 };
137 
138 } // namespace cx
139 #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:127
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:53
virtual QVariant getValueAsVariant() const
Superclass for all data adapters.
Definition: cxProperty.h:64
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.