NorMIT-nav  22.09
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_
cx::SpacePropertyBase::isReadOnly
virtual bool isReadOnly() const
Definition: cxSpacePropertyBase.h:58
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::SpacePropertyBase::getAllowOnlyValuesInRange
virtual bool getAllowOnlyValuesInRange() const
Definition: cxSpacePropertyBase.h:62
cx::SpacePropertyBasePtr
boost::shared_ptr< SpacePropertyBase > SpacePropertyBasePtr
Definition: cxSpacePropertyBase.h:83
cx::SpacePropertyBase::getValueAsVariant
virtual QVariant getValueAsVariant() const
Definition: cxSpacePropertyBase.h:41
cxCoordinateSystemHelpers.h
cxProperty.h
cx::SpacePropertyBase::getUid
virtual QString getUid() const
Definition: cxSpacePropertyBase.h:50
cx::SpacePropertyBase::SpacePropertyBase
SpacePropertyBase()
Definition: cxSpacePropertyBase.h:34
cx::SpacePropertyBase
Definition: cxSpacePropertyBase.h:30
cx::CoordinateSystem::fromString
static CoordinateSystem fromString(QString text)
Definition: cxCoordinateSystemHelpers.cpp:24
cx::SpacePropertyBase::convertRefObjectInternal2Display
virtual QString convertRefObjectInternal2Display(QString internal)
Definition: cxSpacePropertyBase.h:76
cx::Property
Superclass for all data adapters.
Definition: cxProperty.h:43
cx::SpacePropertyBase::getValueRange
virtual std::vector< Space > getValueRange() const
Definition: cxSpacePropertyBase.h:68
cx::SpacePropertyBase::setValueFromVariant
virtual void setValueFromVariant(QVariant val)
Definition: cxSpacePropertyBase.h:45
cx::SpacePropertyBase::~SpacePropertyBase
virtual ~SpacePropertyBase()
Definition: cxSpacePropertyBase.h:35
cx::CoordinateSystem
Identification of a Coordinate system.
Definition: cxCoordinateSystemHelpers.h:31