2022-07-04 02:33:38 -04:00
|
|
|
#include "vector3edit.h"
|
|
|
|
|
2022-07-11 12:05:28 -04:00
|
|
|
#include <float.h>
|
2022-07-04 02:33:38 -04:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
Vector3Edit::Vector3Edit(QWidget *parent) :
|
|
|
|
QWidget{parent}
|
|
|
|
{
|
|
|
|
auto layout = new QHBoxLayout(this);
|
|
|
|
|
2022-07-21 20:39:13 -04:00
|
|
|
layout->addWidget(new QLabel(tr("X")));
|
2022-07-04 02:33:38 -04:00
|
|
|
|
|
|
|
x_edit_ = new QDoubleSpinBox();
|
|
|
|
x_edit_->setMinimum(DBL_MIN);
|
|
|
|
x_edit_->setMaximum(DBL_MAX);
|
|
|
|
layout->addWidget(x_edit_);
|
2022-07-21 20:39:13 -04:00
|
|
|
connect(x_edit_, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Vector3Edit::internalChanged);
|
2022-07-04 02:33:38 -04:00
|
|
|
|
|
|
|
layout->addStretch();
|
|
|
|
|
2022-07-21 20:39:13 -04:00
|
|
|
layout->addWidget(new QLabel(tr("Y")));
|
2022-07-04 02:33:38 -04:00
|
|
|
|
|
|
|
y_edit_ = new QDoubleSpinBox();
|
|
|
|
y_edit_->setMinimum(DBL_MIN);
|
|
|
|
y_edit_->setMaximum(DBL_MAX);
|
|
|
|
layout->addWidget(y_edit_);
|
2022-07-21 20:39:13 -04:00
|
|
|
connect(y_edit_, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Vector3Edit::internalChanged);
|
2022-07-04 02:33:38 -04:00
|
|
|
|
|
|
|
layout->addStretch();
|
|
|
|
|
2022-07-21 20:39:13 -04:00
|
|
|
layout->addWidget(new QLabel(tr("Z")));
|
2022-07-04 02:33:38 -04:00
|
|
|
|
|
|
|
z_edit_ = new QDoubleSpinBox();
|
|
|
|
z_edit_->setMinimum(DBL_MIN);
|
|
|
|
z_edit_->setMaximum(DBL_MAX);
|
|
|
|
layout->addWidget(z_edit_);
|
2022-07-21 20:39:13 -04:00
|
|
|
connect(z_edit_, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Vector3Edit::internalChanged);
|
2022-07-04 02:33:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
si::Vector3 Vector3Edit::GetValue() const
|
|
|
|
{
|
|
|
|
return si::Vector3(x_edit_->value(), y_edit_->value(), z_edit_->value());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Vector3Edit::SetValue(const si::Vector3 &xyz)
|
|
|
|
{
|
2022-07-21 20:39:13 -04:00
|
|
|
x_edit_->blockSignals(true);
|
|
|
|
y_edit_->blockSignals(true);
|
|
|
|
z_edit_->blockSignals(true);
|
|
|
|
|
2022-07-04 02:33:38 -04:00
|
|
|
x_edit_->setValue(xyz.x);
|
|
|
|
y_edit_->setValue(xyz.y);
|
|
|
|
z_edit_->setValue(xyz.z);
|
2022-07-21 20:39:13 -04:00
|
|
|
|
|
|
|
x_edit_->blockSignals(false);
|
|
|
|
y_edit_->blockSignals(false);
|
|
|
|
z_edit_->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Vector3Edit::internalChanged()
|
|
|
|
{
|
|
|
|
emit changed(si::Vector3(x_edit_->value(), y_edit_->value(), z_edit_->value()));
|
2022-07-04 02:33:38 -04:00
|
|
|
}
|