1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#include "scatterdatamodifier.h"
31
32#include <QtWidgets/QApplication>
33#include <QtWidgets/QWidget>
34#include <QtWidgets/QHBoxLayout>
35#include <QtWidgets/QVBoxLayout>
36#include <QtWidgets/QPushButton>
37#include <QtWidgets/QCheckBox>
38#include <QtWidgets/QComboBox>
39#include <QtWidgets/QLabel>
40#include <QtWidgets/QMessageBox>
41#include <QtGui/QScreen>
42#include <QtGui/QFontDatabase>
43
44int main(int argc, char **argv)
45{
46 QApplication app(argc, argv);
47 Q3DScatter *graph = new Q3DScatter();
48 QWidget *container = QWidget::createWindowContainer(window: graph);
49
50 if (!graph->hasContext()) {
51 QMessageBox msgBox;
52 msgBox.setText("Couldn't initialize the OpenGL context.");
53 msgBox.exec();
54 return -1;
55 }
56
57 QSize screenSize = graph->screen()->size();
58 container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5));
59 container->setMaximumSize(screenSize);
60 container->setSizePolicy(hor: QSizePolicy::Expanding, ver: QSizePolicy::Expanding);
61 container->setFocusPolicy(Qt::StrongFocus);
62
63 QWidget *widget = new QWidget;
64 QHBoxLayout *hLayout = new QHBoxLayout(widget);
65 QVBoxLayout *vLayout = new QVBoxLayout();
66 hLayout->addWidget(container, stretch: 1);
67 hLayout->addLayout(layout: vLayout);
68
69 widget->setWindowTitle(QStringLiteral("Custom Input Handling"));
70
71 QPushButton *cameraButton = new QPushButton(widget);
72 cameraButton->setText(QStringLiteral("Toggle Camera Animation"));
73
74 QComboBox *shadowQuality = new QComboBox(widget);
75 shadowQuality->addItem(QStringLiteral("None"));
76 shadowQuality->addItem(QStringLiteral("Low"));
77 shadowQuality->addItem(QStringLiteral("Medium"));
78 shadowQuality->addItem(QStringLiteral("High"));
79 shadowQuality->addItem(QStringLiteral("Low Soft"));
80 shadowQuality->addItem(QStringLiteral("Medium Soft"));
81 shadowQuality->addItem(QStringLiteral("High Soft"));
82 shadowQuality->setCurrentIndex(2);
83
84 vLayout->addWidget(cameraButton, stretch: 0, alignment: Qt::AlignTop);
85 vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")), stretch: 0, alignment: Qt::AlignTop);
86 vLayout->addWidget(shadowQuality, stretch: 1, alignment: Qt::AlignTop);
87
88 ScatterDataModifier *modifier = new ScatterDataModifier(graph);
89
90 QObject::connect(sender: cameraButton, signal: &QPushButton::clicked, receiver: modifier,
91 slot: &ScatterDataModifier::toggleCameraAnimation);
92
93 QObject::connect(sender: shadowQuality, SIGNAL(currentIndexChanged(int)), receiver: modifier,
94 SLOT(changeShadowQuality(int)));
95
96 QObject::connect(sender: modifier, signal: &ScatterDataModifier::shadowQualityChanged, receiver: shadowQuality,
97 slot: &QComboBox::setCurrentIndex);
98
99 widget->show();
100 modifier->start();
101 return app.exec();
102}
103

source code of qtdatavis3d/examples/datavisualization/custominput/main.cpp