NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 #ifndef CXSPACEPROPERTYBASE_H_
33 #define CXSPACEPROPERTYBASE_H_
34 
35 #include "cxResourceExport.h"
36 
37 #include <boost/shared_ptr.hpp>
38 #include <QObject>
39 #include <QString>
40 #include <QStringList>
41 #include <QComboBox>
42 #include "cxProperty.h"
44 
45 namespace cx
46 {
47 
51 class cxResource_EXPORT SpacePropertyBase: public Property
52 {
53  Q_OBJECT
54 public:
56  virtual ~SpacePropertyBase(){}
57 
58 public:
59  // basic methods
60  virtual QString getDisplayName() const = 0;
61 
62  virtual QVariant getValueAsVariant() const
63  {
64  return QVariant(this->getValue().toString());
65  }
66  virtual void setValueFromVariant(QVariant val)
67  {
68  this->setValue(Space::fromString(val.toString()));
69  }
70 
71  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
72  virtual bool setValue(const Space& value) = 0;
73  virtual Space getValue() const = 0;
74 
75 public:
76  /*
77  * If set: setValue will always fail. Adapter is used for display only.
78  */
79  virtual bool isReadOnly() const { return false; }
80  /*
81  * If true: value will always be within range. setValue using other values will fail.
82  */
83  virtual bool getAllowOnlyValuesInRange() const { return true; }
84  // optional methods
85  virtual QString getHelp() const
86  {
87  return QString();
88  }
89  virtual std::vector<Space> getValueRange() const
90  {
91  return std::vector<Space>();
92  }
93  virtual QString convertInternal2Display(Space internal)
94  {
95  return internal.toString();
96  }
97  virtual QString convertRefObjectInternal2Display(QString internal)
98  {
99  return internal;
100  }
101 
102 
103 };
104 typedef boost::shared_ptr<SpacePropertyBase> SpacePropertyBasePtr;
105 
106 } // namespace cx
107 
108 #endif // CXSPACEPROPERTYBASE_H_
virtual bool isReadOnly() const
virtual bool getAllowOnlyValuesInRange() const
virtual QVariant getValueAsVariant() const
Superclass for all data adapters.
Definition: cxProperty.h:64
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)