2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-28 17:50:05 -04:00
|
|
|
#include "vec3edit.h"
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
Vector3Edit::Vector3Edit(glm::vec3& vec, QWidget* parent) : QWidget(parent), vec(vec) {
|
|
|
|
QHBoxLayout* itemsLayout = new QHBoxLayout(this);
|
|
|
|
|
|
|
|
spinBoxes.x = new QDoubleSpinBox();
|
|
|
|
spinBoxes.y = new QDoubleSpinBox();
|
|
|
|
spinBoxes.z = new QDoubleSpinBox();
|
|
|
|
|
|
|
|
spinBoxes.x->setMinimum(-10000.0);
|
|
|
|
spinBoxes.x->setMaximum(10000.0);
|
|
|
|
|
|
|
|
spinBoxes.y->setMinimum(-10000.0);
|
|
|
|
spinBoxes.y->setMaximum(10000.0);
|
|
|
|
|
|
|
|
spinBoxes.z->setMinimum(-10000.0);
|
|
|
|
spinBoxes.z->setMaximum(10000.0);
|
|
|
|
|
|
|
|
itemsLayout->addWidget(spinBoxes.x);
|
|
|
|
itemsLayout->addWidget(spinBoxes.y);
|
|
|
|
itemsLayout->addWidget(spinBoxes.z);
|
|
|
|
|
|
|
|
spinBoxes.x->setValue(vec.x);
|
|
|
|
spinBoxes.y->setValue(vec.y);
|
|
|
|
spinBoxes.z->setValue(vec.z);
|
|
|
|
|
2023-07-07 16:16:21 -04:00
|
|
|
connect(
|
|
|
|
spinBoxes.x,
|
|
|
|
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
[this, &vec](double d) {
|
|
|
|
vec.x = d;
|
2023-09-26 00:37:55 -04:00
|
|
|
Q_EMIT onValueChanged();
|
2023-07-07 16:16:21 -04:00
|
|
|
});
|
|
|
|
connect(
|
|
|
|
spinBoxes.y,
|
|
|
|
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
[this, &vec](double d) {
|
|
|
|
vec.y = d;
|
2023-09-26 00:37:55 -04:00
|
|
|
Q_EMIT onValueChanged();
|
2023-07-07 16:16:21 -04:00
|
|
|
});
|
|
|
|
connect(
|
|
|
|
spinBoxes.z,
|
|
|
|
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
[this, &vec](double d) {
|
|
|
|
vec.z = d;
|
2023-09-26 00:37:55 -04:00
|
|
|
Q_EMIT onValueChanged();
|
2023-07-07 16:16:21 -04:00
|
|
|
});
|
2022-04-28 17:50:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Vector3Edit::~Vector3Edit() {
|
|
|
|
updateTimer->stop();
|
|
|
|
}
|
2023-07-06 17:37:31 -04:00
|
|
|
|
2023-07-07 16:16:21 -04:00
|
|
|
void Vector3Edit::setVector(glm::vec3& vec) {
|
2023-07-06 17:37:31 -04:00
|
|
|
this->vec = vec;
|
|
|
|
spinBoxes.x->setValue(vec.x);
|
|
|
|
spinBoxes.y->setValue(vec.y);
|
|
|
|
spinBoxes.z->setValue(vec.z);
|
|
|
|
}
|