| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). | 
| 4 | ** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). | 
| 5 | ** Contact: https://www.qt.io/licensing/ | 
| 6 | ** | 
| 7 | ** This file is part of the Qt3D module of the Qt Toolkit. | 
| 8 | ** | 
| 9 | ** $QT_BEGIN_LICENSE:BSD$ | 
| 10 | ** Commercial License Usage | 
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 12 | ** accordance with the commercial license agreement provided with the | 
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 17 | ** | 
| 18 | ** BSD License Usage | 
| 19 | ** Alternatively, you may use this file under the terms of the BSD license | 
| 20 | ** as follows: | 
| 21 | ** | 
| 22 | ** "Redistribution and use in source and binary forms, with or without | 
| 23 | ** modification, are permitted provided that the following conditions are | 
| 24 | ** met: | 
| 25 | **   * Redistributions of source code must retain the above copyright | 
| 26 | **     notice, this list of conditions and the following disclaimer. | 
| 27 | **   * Redistributions in binary form must reproduce the above copyright | 
| 28 | **     notice, this list of conditions and the following disclaimer in | 
| 29 | **     the documentation and/or other materials provided with the | 
| 30 | **     distribution. | 
| 31 | **   * Neither the name of The Qt Company Ltd nor the names of its | 
| 32 | **     contributors may be used to endorse or promote products derived | 
| 33 | **     from this software without specific prior written permission. | 
| 34 | ** | 
| 35 | ** | 
| 36 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
| 37 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
| 38 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 
| 39 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
| 40 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 
| 41 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
| 42 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
| 43 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| 44 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 45 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 46 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | 
| 47 | ** | 
| 48 | ** $QT_END_LICENSE$ | 
| 49 | ** | 
| 50 | ****************************************************************************/ | 
| 51 |  | 
| 52 | #ifndef ORBITTRANSFORMCONTROLLER_H | 
| 53 | #define ORBITTRANSFORMCONTROLLER_H | 
| 54 |  | 
| 55 | #include <QObject> | 
| 56 | #include <QMatrix4x4> | 
| 57 |  | 
| 58 | QT_BEGIN_NAMESPACE | 
| 59 |  | 
| 60 | namespace Qt3DCore { | 
| 61 | class QTransform; | 
| 62 | } | 
| 63 |  | 
| 64 | class OrbitTransformController : public QObject | 
| 65 | { | 
| 66 |     Q_OBJECT | 
| 67 |     Q_PROPERTY(Qt3DCore::QTransform* target READ target WRITE setTarget NOTIFY targetChanged) | 
| 68 |     Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) | 
| 69 |     Q_PROPERTY(float angle READ angle WRITE setAngle NOTIFY angleChanged) | 
| 70 |  | 
| 71 | public: | 
| 72 |     OrbitTransformController(QObject *parent = 0); | 
| 73 |  | 
| 74 |     void setTarget(Qt3DCore::QTransform *target); | 
| 75 |     Qt3DCore::QTransform *target() const; | 
| 76 |  | 
| 77 |     void setRadius(float radius); | 
| 78 |     float radius() const; | 
| 79 |  | 
| 80 |     void setAngle(float angle); | 
| 81 |     float angle() const; | 
| 82 |  | 
| 83 | signals: | 
| 84 |     void targetChanged(); | 
| 85 |     void radiusChanged(); | 
| 86 |     void angleChanged(); | 
| 87 |  | 
| 88 | protected: | 
| 89 |     void updateMatrix(); | 
| 90 |  | 
| 91 | private: | 
| 92 |     Qt3DCore::QTransform *m_target; | 
| 93 |     QMatrix4x4 m_matrix; | 
| 94 |     float m_radius; | 
| 95 |     float m_angle; | 
| 96 | }; | 
| 97 |  | 
| 98 | QT_END_NAMESPACE | 
| 99 |  | 
| 100 | #endif // ORBITTRANSFORMCONTROLLER_H | 
| 101 |  |