itom 2.2.1
|
00001 /*========================================================================= 00002 00003 Library: CTK 00004 00005 Copyright (c) Kitware Inc. 00006 00007 Licensed under the Apache License, Version 2.0 (the "License"); 00008 you may not use this file except in compliance with the License. 00009 You may obtain a copy of the License at 00010 00011 http://www.apache.org/licenses/LICENSE-2.0.txt 00012 00013 Unless required by applicable law or agreed to in writing, software 00014 distributed under the License is distributed on an "AS IS" BASIS, 00015 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 See the License for the specific language governing permissions and 00017 limitations under the License. 00018 00019 =========================================================================*/ 00020 00021 #ifndef VALUEPROXY_H 00022 #define VALUEPROXY_H 00023 00024 // Qt includes 00025 #include <QObject> 00026 #include <QScopedPointer> 00027 00028 #include "commonWidgets.h" 00029 00030 class ValueProxyPrivate; 00031 00045 class ITOMWIDGETS_EXPORT ValueProxy : public QObject 00046 { 00047 Q_OBJECT 00048 00053 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged) 00054 00055 00056 00057 00058 00059 Q_PROPERTY(double proxyValue READ proxyValue WRITE setProxyValue NOTIFY proxyValueChanged) 00060 00061 public: 00062 typedef QObject Superclass; 00063 explicit ValueProxy(QObject* parent = 0); 00064 virtual ~ValueProxy(); 00065 00066 virtual double proxyValueFromValue(double value) const = 0; 00067 virtual double valueFromProxyValue(double proxyValue) const = 0; 00068 00069 double value() const; 00070 virtual double proxyValue() const; 00071 00072 public Q_SLOTS: 00073 void setValue(double newValue); 00074 void setProxyValue(double newProxyValue); 00075 00076 Q_SIGNALS: 00077 void valueChanged(double); 00078 void proxyValueChanged(double); 00079 00080 void proxyAboutToBeModified(); 00081 void proxyModified(); 00082 00083 protected: 00084 QScopedPointer<ValueProxyPrivate> d_ptr; 00085 00088 void updateProxyValue(); 00089 void updateValue(); 00090 00091 private: 00092 Q_DECLARE_PRIVATE(ValueProxy); 00093 Q_DISABLE_COPY(ValueProxy); 00094 }; 00095 00096 #endif