itom
Loading...
Searching...
No Matches
valueProxy.h
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 VALUEPROXY_H
22#define VALUEPROXY_H
23
24// Qt includes
25#include <QObject>
26#include <QScopedPointer>
27
28#include "commonWidgets.h"
29
31
45class ITOMWIDGETS_EXPORT ValueProxy : public QObject
46{
47 Q_OBJECT
48
53 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged)
54
55
59 Q_PROPERTY(double proxyValue READ proxyValue WRITE setProxyValue NOTIFY proxyValueChanged)
60
61public:
62 typedef QObject Superclass;
63 explicit ValueProxy(QObject* parent = 0);
64 virtual ~ValueProxy();
65
66 virtual double proxyValueFromValue(double value) const = 0;
67 virtual double valueFromProxyValue(double proxyValue) const = 0;
68
69 double value() const;
70 virtual double proxyValue() const;
71
72public Q_SLOTS:
73 void setValue(double newValue);
74 void setProxyValue(double newProxyValue);
75
76Q_SIGNALS:
77 void valueChanged(double);
78 void proxyValueChanged(double);
79
80 void proxyAboutToBeModified();
81 void proxyModified();
82
83protected:
84 QScopedPointer<ValueProxyPrivate> d_ptr;
85
88 void updateProxyValue();
89 void updateValue();
90
91private:
92 Q_DECLARE_PRIVATE(ValueProxy);
93 Q_DISABLE_COPY(ValueProxy);
94};
95
96#endif
Base class for value proxies. Value proxy allows to decouple the displayed value from the values acce...
Definition valueProxy.h:46
Definition valueProxy.cpp:39