CustusX  22.04-rc5
An IGT application
cxSpacePropertyBase.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 #ifndef CXSPACEPROPERTYBASE_H_
12 #define CXSPACEPROPERTYBASE_H_
13 
14 #include "cxResourceExport.h"
15 
16 #include <boost/shared_ptr.hpp>
17 #include <QObject>
18 #include <QString>
19 #include <QStringList>
20 #include <QComboBox>
21 #include "cxProperty.h"
23 
24 namespace cx
25 {
26 
30 class cxResource_EXPORT SpacePropertyBase: public Property
31 {
32  Q_OBJECT
33 public:
35  virtual ~SpacePropertyBase(){}
36 
37 public:
38  // basic methods
39  virtual QString getDisplayName() const = 0;
40 
41  virtual QVariant getValueAsVariant() const
42  {
43  return QVariant(this->getValue().toString());
44  }
45  virtual void setValueFromVariant(QVariant val)
46  {
47  this->setValue(Space::fromString(val.toString()));
48  }
49 
50  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
51  virtual bool setValue(const Space& value) = 0;
52  virtual Space getValue() const = 0;
53 
54 public:
55  /*
56  * If set: setValue will always fail. Adapter is used for display only.
57  */
58  virtual bool isReadOnly() const { return false; }
59  /*
60  * If true: value will always be within range. setValue using other values will fail.
61  */
62  virtual bool getAllowOnlyValuesInRange() const { return true; }
63  // optional methods
64  virtual QString getHelp() const
65  {
66  return QString();
67  }
68  virtual std::vector<Space> getValueRange() const
69  {
70  return std::vector<Space>();
71  }
72  virtual QString convertInternal2Display(Space internal)
73  {
74  return internal.toString();
75  }
76  virtual QString convertRefObjectInternal2Display(QString internal)
77  {
78  return internal;
79  }
80 
81 
82 };
83 typedef boost::shared_ptr<SpacePropertyBase> SpacePropertyBasePtr;
84 
85 } // namespace cx
86 
87 #endif // CXSPACEPROPERTYBASE_H_
virtual bool isReadOnly() const
virtual bool getAllowOnlyValuesInRange() const
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:755
virtual QVariant getValueAsVariant() const
Superclass for all data adapters.
Definition: cxProperty.h:43
boost::shared_ptr< SpacePropertyBase > SpacePropertyBasePtr
virtual QString convertInternal2Display(Space internal)
range of value. Use if data is constrained to a set.
virtual void setValueFromVariant(QVariant val)
virtual QString convertRefObjectInternal2Display(QString internal)
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
Identification of a Coordinate system.
virtual QString getUid() const
virtual std::vector< Space > getValueRange() const
static CoordinateSystem fromString(QString text)
Namespace for all CustusX production code.