// SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later #include "vec3edit.h" #include #include 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); connect( spinBoxes.x, static_cast(&QDoubleSpinBox::valueChanged), [this, &vec](double d) { vec.x = d; Q_EMIT onValueChanged(); }); connect( spinBoxes.y, static_cast(&QDoubleSpinBox::valueChanged), [this, &vec](double d) { vec.y = d; Q_EMIT onValueChanged(); }); connect( spinBoxes.z, static_cast(&QDoubleSpinBox::valueChanged), [this, &vec](double d) { vec.z = d; Q_EMIT onValueChanged(); }); } Vector3Edit::~Vector3Edit() { updateTimer->stop(); } void Vector3Edit::setVector(glm::vec3& vec) { this->vec = vec; spinBoxes.x->setValue(vec.x); spinBoxes.y->setValue(vec.y); spinBoxes.z->setValue(vec.z); }