src/ui/multiplyfactordialog.cpp

changeset 81
62373840e33a
child 88
14e51640c189
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ui/multiplyfactordialog.cpp	Tue Mar 17 23:13:29 2020 +0200
@@ -0,0 +1,39 @@
+#include "multiplyfactordialog.h"
+#include "ui_multiplyfactordialog.h"
+
+MultiplyFactorDialog::MultiplyFactorDialog(const glm::vec3& baseVector, QWidget* parent) :
+	QDialog{parent},
+	baseVector{baseVector},
+	preview{baseVector, parent, Vec3Editor::NoMultiplyButton}
+{
+	ui = std::make_unique<Ui::MultiplyFactorDialog>();
+	ui->setupUi(this);
+	this->preview.setEnabled(false);
+	this->ui->previewGroupBox->setLayout(new QVBoxLayout{parent});
+	this->ui->previewGroupBox->layout()->addWidget(&this->preview);
+	connect(this->ui->invert, &QCheckBox::clicked, this, &MultiplyFactorDialog::updatePreview);
+	connect(this->ui->factor, qOverload<double>(&DoubleSpinBox::valueChanged), this, &MultiplyFactorDialog::updatePreview);
+}
+
+MultiplyFactorDialog::~MultiplyFactorDialog()
+{
+}
+
+glm::vec3 MultiplyFactorDialog::value() const
+{
+	glm::vec3 result = baseVector;
+	if (this->ui->invert->isChecked())
+	{
+		result /= this->ui->factor->value();
+	}
+	else
+	{
+		result *= this->ui->factor->value();
+	}
+	return result;
+}
+
+void MultiplyFactorDialog::updatePreview()
+{
+	this->preview.setValue(this->value());
+}

mercurial