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 "volumetrictest.h"
31#include <QtWidgets/QApplication>
32#include <QtWidgets/QWidget>
33#include <QtWidgets/QHBoxLayout>
34#include <QtWidgets/QVBoxLayout>
35#include <QtWidgets/QRadioButton>
36#include <QtWidgets/QSlider>
37#include <QtWidgets/QCheckBox>
38#include <QtWidgets/QLabel>
39#include <QtWidgets/QPushButton>
40#include <QtGui/QScreen>
41
42int main(int argc, char **argv)
43{
44 QApplication app(argc, argv);
45 //Q3DScatter *graph = new Q3DScatter();
46 //Q3DSurface *graph = new Q3DSurface();
47 Q3DBars *graph = new Q3DBars();
48 QWidget *container = QWidget::createWindowContainer(window: graph);
49
50 QSize screenSize = graph->screen()->size();
51 container->setMinimumSize(QSize(screenSize.width() / 4, screenSize.height() / 4));
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("Volumetric TEST"));
63 widget->resize(QSize(screenSize.width() / 1.5, screenSize.height() / 1.5));
64
65 QCheckBox *sliceXCheckBox = new QCheckBox(widget);
66 sliceXCheckBox->setText(QStringLiteral("Slice volume on X axis"));
67 sliceXCheckBox->setChecked(false);
68 QCheckBox *sliceYCheckBox = new QCheckBox(widget);
69 sliceYCheckBox->setText(QStringLiteral("Slice volume on Y axis"));
70 sliceYCheckBox->setChecked(false);
71 QCheckBox *sliceZCheckBox = new QCheckBox(widget);
72 sliceZCheckBox->setText(QStringLiteral("Slice volume on Z axis"));
73 sliceZCheckBox->setChecked(false);
74
75 QSlider *sliceXSlider = new QSlider(Qt::Horizontal, widget);
76 sliceXSlider->setMinimum(0);
77 sliceXSlider->setMaximum(1024);
78 sliceXSlider->setValue(512);
79 sliceXSlider->setEnabled(true);
80 QSlider *sliceYSlider = new QSlider(Qt::Horizontal, widget);
81 sliceYSlider->setMinimum(0);
82 sliceYSlider->setMaximum(1024);
83 sliceYSlider->setValue(512);
84 sliceYSlider->setEnabled(true);
85 QSlider *sliceZSlider = new QSlider(Qt::Horizontal, widget);
86 sliceZSlider->setMinimum(0);
87 sliceZSlider->setMaximum(1024);
88 sliceZSlider->setValue(512);
89 sliceZSlider->setEnabled(true);
90
91 QLabel *fpsLabel = new QLabel(QStringLiteral("Fps: "), widget);
92
93 QLabel *sliceImageXLabel = new QLabel(widget);
94 QLabel *sliceImageYLabel = new QLabel(widget);
95 QLabel *sliceImageZLabel = new QLabel(widget);
96 sliceImageXLabel->setMinimumSize(QSize(200, 100));
97 sliceImageYLabel->setMinimumSize(QSize(200, 200));
98 sliceImageZLabel->setMinimumSize(QSize(200, 100));
99 sliceImageXLabel->setMaximumSize(QSize(200, 100));
100 sliceImageYLabel->setMaximumSize(QSize(200, 200));
101 sliceImageZLabel->setMaximumSize(QSize(200, 100));
102 sliceImageXLabel->setFrameShape(QFrame::Box);
103 sliceImageYLabel->setFrameShape(QFrame::Box);
104 sliceImageZLabel->setFrameShape(QFrame::Box);
105 sliceImageXLabel->setScaledContents(true);
106 sliceImageYLabel->setScaledContents(true);
107 sliceImageZLabel->setScaledContents(true);
108
109 QPushButton *testSubTextureSetting = new QPushButton(widget);
110 testSubTextureSetting->setText(QStringLiteral("Test subtexture settings"));
111
112 QLabel *rangeSliderLabel = new QLabel(QStringLiteral("Adjust ranges:"), widget);
113
114 QSlider *rangeXSlider = new QSlider(Qt::Horizontal, widget);
115 rangeXSlider->setMinimum(0);
116 rangeXSlider->setMaximum(1024);
117 rangeXSlider->setValue(512);
118 rangeXSlider->setEnabled(true);
119 QSlider *rangeYSlider = new QSlider(Qt::Horizontal, widget);
120 rangeYSlider->setMinimum(0);
121 rangeYSlider->setMaximum(1024);
122 rangeYSlider->setValue(512);
123 rangeYSlider->setEnabled(true);
124 QSlider *rangeZSlider = new QSlider(Qt::Horizontal, widget);
125 rangeZSlider->setMinimum(0);
126 rangeZSlider->setMaximum(1024);
127 rangeZSlider->setValue(512);
128 rangeZSlider->setEnabled(true);
129
130 QPushButton *testBoundsSetting = new QPushButton(widget);
131 testBoundsSetting->setText(QStringLiteral("Test data bounds"));
132
133 vLayout->addWidget(fpsLabel);
134 vLayout->addWidget(sliceXCheckBox);
135 vLayout->addWidget(sliceXSlider);
136 vLayout->addWidget(sliceImageXLabel);
137 vLayout->addWidget(sliceYCheckBox);
138 vLayout->addWidget(sliceYSlider);
139 vLayout->addWidget(sliceImageYLabel);
140 vLayout->addWidget(sliceZCheckBox);
141 vLayout->addWidget(sliceZSlider);
142 vLayout->addWidget(sliceImageZLabel);
143 vLayout->addWidget(rangeSliderLabel);
144 vLayout->addWidget(rangeXSlider);
145 vLayout->addWidget(rangeYSlider);
146 vLayout->addWidget(rangeZSlider);
147 vLayout->addWidget(testBoundsSetting);
148 vLayout->addWidget(testSubTextureSetting, stretch: 1, alignment: Qt::AlignTop);
149
150 VolumetricModifier *modifier = new VolumetricModifier(graph);
151 modifier->setFpsLabel(fpsLabel);
152 modifier->setSliceLabels(xLabel: sliceImageXLabel, yLabel: sliceImageYLabel, zLabel: sliceImageZLabel);
153
154 QObject::connect(sender: sliceXCheckBox, signal: &QCheckBox::stateChanged, receiver: modifier,
155 slot: &VolumetricModifier::sliceX);
156 QObject::connect(sender: sliceYCheckBox, signal: &QCheckBox::stateChanged, receiver: modifier,
157 slot: &VolumetricModifier::sliceY);
158 QObject::connect(sender: sliceZCheckBox, signal: &QCheckBox::stateChanged, receiver: modifier,
159 slot: &VolumetricModifier::sliceZ);
160 QObject::connect(sender: sliceXSlider, signal: &QSlider::valueChanged, receiver: modifier,
161 slot: &VolumetricModifier::adjustSliceX);
162 QObject::connect(sender: sliceYSlider, signal: &QSlider::valueChanged, receiver: modifier,
163 slot: &VolumetricModifier::adjustSliceY);
164 QObject::connect(sender: sliceZSlider, signal: &QSlider::valueChanged, receiver: modifier,
165 slot: &VolumetricModifier::adjustSliceZ);
166 QObject::connect(sender: testSubTextureSetting, signal: &QPushButton::clicked, receiver: modifier,
167 slot: &VolumetricModifier::testSubtextureSetting);
168 QObject::connect(sender: rangeXSlider, signal: &QSlider::valueChanged, receiver: modifier,
169 slot: &VolumetricModifier::adjustRangeX);
170 QObject::connect(sender: rangeYSlider, signal: &QSlider::valueChanged, receiver: modifier,
171 slot: &VolumetricModifier::adjustRangeY);
172 QObject::connect(sender: rangeZSlider, signal: &QSlider::valueChanged, receiver: modifier,
173 slot: &VolumetricModifier::adjustRangeZ);
174 QObject::connect(sender: testBoundsSetting, signal: &QPushButton::clicked, receiver: modifier,
175 slot: &VolumetricModifier::testBoundsSetting);
176
177 widget->show();
178 return app.exec();
179}
180

source code of qtdatavis3d/tests/manual/volumetrictest/main.cpp