Fraxinus  16.5.0-fx-rc1
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 #ifndef CXVECTOR3DPROPERTYBASE_H_
35 #define CXVECTOR3DPROPERTYBASE_H_
36 
37 #include "cxResourceExport.h"
38 
39 #include <boost/shared_ptr.hpp>
40 #include <QString>
41 #include <QObject>
42 #include "cxDoubleRange.h"
43 #include "cxProperty.h"
44 #include "cxVector3D.h"
45 
46 namespace cx
47 {
48 
55 class cxResource_EXPORT Vector3DPropertyBase: public Property
56 {
57 Q_OBJECT
58 public:
60  {
61  }
62 
63 public:
64  // basic methods
65  virtual QString getDisplayName() const = 0;
66  virtual bool setValue(const Vector3D& value) = 0;
67  virtual Vector3D getValue() const = 0;
68 
69  virtual QVariant getValueAsVariant() const
70  {
71  QString val = prettyFormat(this->getValue(), this->getValueDecimals());
72  return QVariant(val);
73  // return QVariant(this->getValue());
74  }
75 
76  virtual void setValueFromVariant(QVariant value)
77  {
78  Vector3D val = Vector3D::fromString(value.toString());
79  this->setValue(val);
80  }
81 
82 public:
83  // optional methods
84  virtual QString getHelp() const
85  {
86  return QString();
87  }
88  virtual DoubleRange getValueRange() const
89  {
90  return DoubleRange(-1000, 1000, 0.1);
91  }
92  virtual double convertInternal2Display(double internal)
93  {
94  return internal;
95  }
96  virtual double convertDisplay2Internal(double display)
97  {
98  return display;
99  }
100  virtual int getValueDecimals() const
101  {
102  return 0;
103  }
104 };
105 typedef boost::shared_ptr<Vector3DPropertyBase> Vector3DPropertyBasePtr;
106 
108 class cxResource_EXPORT Vector3DPropertyNull: public Vector3DPropertyBase
109 {
110 Q_OBJECT
111 
112 public:
114  {
115  }
116  virtual QString getDisplayName() const
117  {
118  return "dummy";
119  }
120  virtual bool setValue(const Vector3D& value)
121  {
122  return false;
123  }
124  virtual Vector3D getValue() const
125  {
126  return Vector3D(0, 0, 0);
127  }
128  virtual void connectValueSignals(bool on)
129  {
130  }
131 };
132 
133 }
134 
135 #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:53
Superclass for all data adapters.
Definition: cxProperty.h:64
QString prettyFormat(Vector3D val, int decimals, int fieldWidth)
Definition: cxVector3D.cpp:119
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:63
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