| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the demonstration applications of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef SCENE_H
|
|---|
| 43 | #define SCENE_H
|
|---|
| 44 |
|
|---|
| 45 | //#include <GL/glew.h>
|
|---|
| 46 | #include "glextensions.h"
|
|---|
| 47 |
|
|---|
| 48 | #include <QtGui>
|
|---|
| 49 | #include <QtOpenGL>
|
|---|
| 50 |
|
|---|
| 51 | #include "roundedbox.h"
|
|---|
| 52 | #include "gltrianglemesh.h"
|
|---|
| 53 | #include "trackball.h"
|
|---|
| 54 | #include "glbuffers.h"
|
|---|
| 55 | #include "qtbox.h"
|
|---|
| 56 |
|
|---|
| 57 | #define PI 3.14159265358979
|
|---|
| 58 |
|
|---|
| 59 | QT_BEGIN_NAMESPACE
|
|---|
| 60 | class QMatrix4x4;
|
|---|
| 61 | QT_END_NAMESPACE
|
|---|
| 62 |
|
|---|
| 63 | class ParameterEdit : public QWidget
|
|---|
| 64 | {
|
|---|
| 65 | public:
|
|---|
| 66 | virtual void emitChange() = 0;
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | class ColorEdit : public ParameterEdit
|
|---|
| 70 | {
|
|---|
| 71 | Q_OBJECT
|
|---|
| 72 | public:
|
|---|
| 73 | ColorEdit(QRgb initialColor, int id);
|
|---|
| 74 | QRgb color() const {return m_color;}
|
|---|
| 75 | virtual void emitChange() {emit colorChanged(m_color, m_id);}
|
|---|
| 76 | public slots:
|
|---|
| 77 | void editDone();
|
|---|
| 78 | signals:
|
|---|
| 79 | void colorChanged(QRgb color, int id);
|
|---|
| 80 | protected:
|
|---|
| 81 | virtual void mousePressEvent(QMouseEvent *event);
|
|---|
| 82 | void setColor(QRgb color); // also emits colorChanged()
|
|---|
| 83 | private:
|
|---|
| 84 | QGraphicsScene *m_dialogParentScene;
|
|---|
| 85 | QLineEdit *m_lineEdit;
|
|---|
| 86 | QFrame *m_button;
|
|---|
| 87 | QRgb m_color;
|
|---|
| 88 | int m_id;
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | class FloatEdit : public ParameterEdit
|
|---|
| 92 | {
|
|---|
| 93 | Q_OBJECT
|
|---|
| 94 | public:
|
|---|
| 95 | FloatEdit(float initialValue, int id);
|
|---|
| 96 | float value() const {return m_value;}
|
|---|
| 97 | virtual void emitChange() {emit valueChanged(m_value, m_id);}
|
|---|
| 98 | public slots:
|
|---|
| 99 | void editDone();
|
|---|
| 100 | signals:
|
|---|
| 101 | void valueChanged(float value, int id);
|
|---|
| 102 | private:
|
|---|
| 103 | QGraphicsScene *m_dialogParentScene;
|
|---|
| 104 | QLineEdit *m_lineEdit;
|
|---|
| 105 | float m_value;
|
|---|
| 106 | int m_id;
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | class GraphicsWidget : public QGraphicsProxyWidget
|
|---|
| 110 | {
|
|---|
| 111 | public:
|
|---|
| 112 | GraphicsWidget() : QGraphicsProxyWidget(0, Qt::Window) {}
|
|---|
| 113 | protected:
|
|---|
| 114 | virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
|---|
| 115 | virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
|---|
|
|---|