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 <QApplication> |
33 | #include <QWidget> |
34 | #include <QHBoxLayout> |
35 | #include <QVBoxLayout> |
36 | #include <QPushButton> |
37 | #include <QCheckBox> |
38 | #include <QComboBox> |
39 | #include <QFontComboBox> |
40 | #include <QLabel> |
41 | #include <QScreen> |
42 | #include <QFontDatabase> |
43 | |
44 | int 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 | QSize screenSize = graph->screen()->size(); |
51 | container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5)); |
52 | container->setMaximumSize(screenSize); |
53 | container->setSizePolicy(hor: QSizePolicy::Expanding, ver: QSizePolicy::Expanding); |
54 | container->setFocusPolicy(Qt::StrongFocus); |
55 | |
56 | QWidget *widget = new QWidget; |
57 | QHBoxLayout *hLayout = new QHBoxLayout(widget); |
58 | QVBoxLayout *vLayout = new QVBoxLayout(); |
59 | hLayout->addWidget(container, stretch: 1); |
60 | hLayout->addLayout(layout: vLayout); |
61 | |
62 | widget->setWindowTitle(QStringLiteral("Directional scatter" )); |
63 | |
64 | QComboBox *themeList = new QComboBox(widget); |
65 | themeList->addItem(QStringLiteral("Qt" )); |
66 | themeList->addItem(QStringLiteral("Primary Colors" )); |
67 | themeList->addItem(QStringLiteral("Digia" )); |
68 | themeList->addItem(QStringLiteral("Stone Moss" )); |
69 | themeList->addItem(QStringLiteral("Army Blue" )); |
70 | themeList->addItem(QStringLiteral("Retro" )); |
71 | themeList->addItem(QStringLiteral("Ebony" )); |
72 | themeList->addItem(QStringLiteral("Isabelle" )); |
73 | themeList->setCurrentIndex(6); |
74 | |
75 | QPushButton *labelButton = new QPushButton(widget); |
76 | labelButton->setText(QStringLiteral("Change label style" )); |
77 | |
78 | QComboBox *itemStyleList = new QComboBox(widget); |
79 | itemStyleList->addItem(QStringLiteral("Arrow" ), auserData: int(QAbstract3DSeries::MeshArrow)); |
80 | itemStyleList->addItem(QStringLiteral("Cube" ), auserData: int(QAbstract3DSeries::MeshCube)); |
81 | itemStyleList->addItem(QStringLiteral("Minimal" ), auserData: int(QAbstract3DSeries::MeshMinimal)); |
82 | itemStyleList->setCurrentIndex(-1); |
83 | |
84 | QPushButton *cameraButton = new QPushButton(widget); |
85 | cameraButton->setText(QStringLiteral("Change camera preset" )); |
86 | |
87 | QPushButton *toggleRotationButton = new QPushButton(widget); |
88 | toggleRotationButton->setText(QStringLiteral("Toggle animation" )); |
89 | |
90 | QCheckBox *backgroundCheckBox = new QCheckBox(widget); |
91 | backgroundCheckBox->setText(QStringLiteral("Show background" )); |
92 | backgroundCheckBox->setChecked(true); |
93 | |
94 | QCheckBox *optimizationCheckBox = new QCheckBox(widget); |
95 | optimizationCheckBox->setText(QStringLiteral("Optimization static" )); |
96 | |
97 | QCheckBox *gridCheckBox = new QCheckBox(widget); |
98 | gridCheckBox->setText(QStringLiteral("Show grid" )); |
99 | gridCheckBox->setChecked(true); |
100 | |
101 | QComboBox *shadowQuality = new QComboBox(widget); |
102 | shadowQuality->addItem(QStringLiteral("None" )); |
103 | shadowQuality->addItem(QStringLiteral("Low" )); |
104 | shadowQuality->addItem(QStringLiteral("Medium" )); |
105 | shadowQuality->addItem(QStringLiteral("High" )); |
106 | shadowQuality->addItem(QStringLiteral("Low Soft" )); |
107 | shadowQuality->addItem(QStringLiteral("Medium Soft" )); |
108 | shadowQuality->addItem(QStringLiteral("High Soft" )); |
109 | shadowQuality->setCurrentIndex(4); |
110 | |
111 | QFontComboBox *fontList = new QFontComboBox(widget); |
112 | fontList->setCurrentFont(QFont("Arial" )); |
113 | |
114 | vLayout->addWidget(labelButton, stretch: 0, alignment: Qt::AlignTop); |
115 | vLayout->addWidget(cameraButton, stretch: 0, alignment: Qt::AlignTop); |
116 | vLayout->addWidget(toggleRotationButton, stretch: 0, alignment: Qt::AlignTop); |
117 | vLayout->addWidget(optimizationCheckBox); |
118 | vLayout->addWidget(backgroundCheckBox); |
119 | vLayout->addWidget(gridCheckBox); |
120 | vLayout->addWidget(new QLabel(QStringLiteral("Change dot style" ))); |
121 | vLayout->addWidget(itemStyleList); |
122 | vLayout->addWidget(new QLabel(QStringLiteral("Change theme" ))); |
123 | vLayout->addWidget(themeList); |
124 | vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality" ))); |
125 | vLayout->addWidget(shadowQuality); |
126 | vLayout->addWidget(new QLabel(QStringLiteral("Change font" ))); |
127 | vLayout->addWidget(fontList, stretch: 1, alignment: Qt::AlignTop); |
128 | |
129 | ScatterDataModifier *modifier = new ScatterDataModifier(graph); |
130 | |
131 | QObject::connect(sender: cameraButton, signal: &QPushButton::clicked, receiver: modifier, |
132 | slot: &ScatterDataModifier::changePresetCamera); |
133 | QObject::connect(sender: toggleRotationButton, signal: &QPushButton::clicked, receiver: modifier, |
134 | slot: &ScatterDataModifier::toggleRotation); |
135 | QObject::connect(sender: labelButton, signal: &QPushButton::clicked, receiver: modifier, |
136 | slot: &ScatterDataModifier::changeLabelStyle); |
137 | |
138 | QObject::connect(sender: backgroundCheckBox, signal: &QCheckBox::stateChanged, receiver: modifier, |
139 | slot: &ScatterDataModifier::setBackgroundEnabled); |
140 | QObject::connect(sender: gridCheckBox, signal: &QCheckBox::stateChanged, receiver: modifier, |
141 | slot: &ScatterDataModifier::setGridEnabled); |
142 | |
143 | QObject::connect(sender: modifier, signal: &ScatterDataModifier::backgroundEnabledChanged, |
144 | receiver: backgroundCheckBox, slot: &QCheckBox::setChecked); |
145 | QObject::connect(sender: optimizationCheckBox, signal: &QCheckBox::stateChanged, |
146 | receiver: modifier, slot: &ScatterDataModifier::enableOptimization); |
147 | QObject::connect(sender: modifier, signal: &ScatterDataModifier::gridEnabledChanged, |
148 | receiver: gridCheckBox, slot: &QCheckBox::setChecked); |
149 | QObject::connect(sender: itemStyleList, SIGNAL(currentIndexChanged(int)), receiver: modifier, |
150 | SLOT(changeStyle(int))); |
151 | |
152 | QObject::connect(sender: themeList, SIGNAL(currentIndexChanged(int)), receiver: modifier, |
153 | SLOT(changeTheme(int))); |
154 | |
155 | QObject::connect(sender: shadowQuality, SIGNAL(currentIndexChanged(int)), receiver: modifier, |
156 | SLOT(changeShadowQuality(int))); |
157 | |
158 | QObject::connect(sender: modifier, signal: &ScatterDataModifier::shadowQualityChanged, receiver: shadowQuality, |
159 | slot: &QComboBox::setCurrentIndex); |
160 | QObject::connect(sender: graph, signal: &Q3DScatter::shadowQualityChanged, receiver: modifier, |
161 | slot: &ScatterDataModifier::shadowQualityUpdatedByVisual); |
162 | |
163 | QObject::connect(sender: fontList, signal: &QFontComboBox::currentFontChanged, receiver: modifier, |
164 | slot: &ScatterDataModifier::changeFont); |
165 | |
166 | QObject::connect(sender: modifier, signal: &ScatterDataModifier::fontChanged, receiver: fontList, |
167 | slot: &QFontComboBox::setCurrentFont); |
168 | |
169 | itemStyleList->setCurrentIndex(0); |
170 | optimizationCheckBox->setChecked(true); |
171 | |
172 | widget->show(); |
173 | return app.exec(); |
174 | } |
175 | |