2022-06-07 11:55:27 +00:00
|
|
|
// Copyright (C) 2015 The Qt Company Ltd.
|
2024-03-15 08:19:25 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include "globjwin.h"
|
|
|
|
#include "glbox.h"
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <QLayout>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
|
2017-08-21 11:23:48 +00:00
|
|
|
GLObjectWindow::GLObjectWindow(QWidget *parent)
|
2011-04-27 10:05:43 +00:00
|
|
|
: QWidget(parent)
|
|
|
|
{
|
|
|
|
// Create a menu
|
2017-08-21 11:23:48 +00:00
|
|
|
QMenu *file = new QMenu(this);
|
|
|
|
file->addAction(tr("Exit"), qApp, &QApplication::quit);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Create a menu bar
|
2017-08-21 11:23:48 +00:00
|
|
|
QMenuBar *m = new QMenuBar(this);
|
|
|
|
m->addMenu(file)->setText(tr("&File"));
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Create a nice frame to put around the OpenGL widget
|
2017-08-21 11:23:48 +00:00
|
|
|
QFrame *f = new QFrame(this);
|
|
|
|
f->setFrameStyle(QFrame::Sunken | QFrame::Panel);
|
|
|
|
f->setLineWidth(2);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Create our OpenGL widget
|
2017-08-21 11:23:48 +00:00
|
|
|
GLBox *c = new GLBox(f, "glbox");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Create the three sliders; one for each rotation axis
|
2017-08-21 11:23:48 +00:00
|
|
|
QSlider *x = new QSlider(Qt::Vertical, this);
|
2011-04-27 10:05:43 +00:00
|
|
|
x->setMaximum(360);
|
|
|
|
x->setPageStep(60);
|
2017-08-21 11:23:48 +00:00
|
|
|
x->setTickPosition(QSlider::TicksLeft);
|
|
|
|
connect(x, &QSlider::valueChanged, c, &GLBox::setXRotation);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2017-08-21 11:23:48 +00:00
|
|
|
QSlider *y = new QSlider(Qt::Vertical, this);
|
2011-04-27 10:05:43 +00:00
|
|
|
y->setMaximum(360);
|
|
|
|
y->setPageStep(60);
|
2017-08-21 11:23:48 +00:00
|
|
|
y->setTickPosition(QSlider::TicksLeft);
|
|
|
|
connect(y, &QSlider::valueChanged, c, &GLBox::setYRotation);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2017-08-21 11:23:48 +00:00
|
|
|
QSlider *z = new QSlider(Qt::Vertical, this);
|
2011-04-27 10:05:43 +00:00
|
|
|
z->setMaximum(360);
|
|
|
|
z->setPageStep(60);
|
2017-08-21 11:23:48 +00:00
|
|
|
z->setTickPosition(QSlider::TicksLeft);
|
|
|
|
connect(z, &QSlider::valueChanged, c, &GLBox::setZRotation);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Now that we have all the widgets, put them into a nice layout
|
|
|
|
|
|
|
|
// Top level layout, puts the sliders to the left of the frame/GL widget
|
2017-08-21 11:23:48 +00:00
|
|
|
QHBoxLayout *hlayout = new QHBoxLayout(this);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Put the sliders on top of each other
|
2017-08-21 11:23:48 +00:00
|
|
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
|
|
|
vlayout->addWidget(x);
|
|
|
|
vlayout->addWidget(y);
|
|
|
|
vlayout->addWidget(z);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Put the GL widget inside the frame
|
2017-08-21 11:23:48 +00:00
|
|
|
QHBoxLayout *flayout = new QHBoxLayout(f);
|
2020-05-04 11:31:26 +00:00
|
|
|
flayout->setContentsMargins(0, 0, 0, 0);
|
2017-08-21 11:23:48 +00:00
|
|
|
flayout->addWidget(c, 1);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2017-08-21 11:23:48 +00:00
|
|
|
hlayout->setMenuBar(m);
|
|
|
|
hlayout->addLayout(vlayout);
|
|
|
|
hlayout->addWidget(f, 1);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|