CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkValueProxy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkValueProxy_h
22 #define __ctkValueProxy_h
23 
24 // Qt includes
25 #include <QObject>
26 #include <QScopedPointer>
27 
28 // CTK includes
29 #include "ctkCoreExport.h"
30 
31 class ctkValueProxyPrivate;
32 
46 class CTK_CORE_EXPORT ctkValueProxy : public QObject
47 {
48  Q_OBJECT
49 
54  Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged)
55 
56 
60  Q_PROPERTY(double proxyValue READ proxyValue WRITE setProxyValue NOTIFY proxyValueChanged)
61 
62 public:
63  typedef QObject Superclass;
64  explicit ctkValueProxy(QObject* parent = 0);
65  virtual ~ctkValueProxy();
66 
67  virtual double proxyValueFromValue(double value) const = 0;
68  virtual double valueFromProxyValue(double proxyValue) const = 0;
69 
70  double value() const;
71  virtual double proxyValue() const;
72 
73 public Q_SLOTS:
74  void setValue(double newValue);
75  void setProxyValue(double newProxyValue);
76 
77 Q_SIGNALS:
78  void valueChanged(double);
79  void proxyValueChanged(double);
80 
82  void proxyModified();
83 
84 protected:
85  QScopedPointer<ctkValueProxyPrivate> d_ptr;
86 
90  void updateValue();
91 
92 private:
93  Q_DECLARE_PRIVATE(ctkValueProxy);
94  Q_DISABLE_COPY(ctkValueProxy);
95 };
96 
97 #endif
Base class for value proxies. Value proxy allows to decouple the displayed value from the values acce...
Definition: ctkValueProxy.h:47
virtual ~ctkValueProxy()
ctkValueProxy(QObject *parent=0)
void proxyAboutToBeModified()
void setProxyValue(double newProxyValue)
virtual double proxyValueFromValue(double value) const =0
virtual double valueFromProxyValue(double proxyValue) const =0
void setValue(double newValue)
double value() const
void proxyValueChanged(double)
QScopedPointer< ctkValueProxyPrivate > d_ptr
Definition: ctkValueProxy.h:85
void valueChanged(double)
virtual double proxyValue() const
void updateProxyValue()
void updateValue()
void proxyModified()
QObject Superclass
Definition: ctkValueProxy.h:63