src/ui/multiplyfactordialog.cpp

changeset 81
62373840e33a
child 88
14e51640c189
equal deleted inserted replaced
80:764381756899 81:62373840e33a
1 #include "multiplyfactordialog.h"
2 #include "ui_multiplyfactordialog.h"
3
4 MultiplyFactorDialog::MultiplyFactorDialog(const glm::vec3& baseVector, QWidget* parent) :
5 QDialog{parent},
6 baseVector{baseVector},
7 preview{baseVector, parent, Vec3Editor::NoMultiplyButton}
8 {
9 ui = std::make_unique<Ui::MultiplyFactorDialog>();
10 ui->setupUi(this);
11 this->preview.setEnabled(false);
12 this->ui->previewGroupBox->setLayout(new QVBoxLayout{parent});
13 this->ui->previewGroupBox->layout()->addWidget(&this->preview);
14 connect(this->ui->invert, &QCheckBox::clicked, this, &MultiplyFactorDialog::updatePreview);
15 connect(this->ui->factor, qOverload<double>(&DoubleSpinBox::valueChanged), this, &MultiplyFactorDialog::updatePreview);
16 }
17
18 MultiplyFactorDialog::~MultiplyFactorDialog()
19 {
20 }
21
22 glm::vec3 MultiplyFactorDialog::value() const
23 {
24 glm::vec3 result = baseVector;
25 if (this->ui->invert->isChecked())
26 {
27 result /= this->ui->factor->value();
28 }
29 else
30 {
31 result *= this->ui->factor->value();
32 }
33 return result;
34 }
35
36 void MultiplyFactorDialog::updatePreview()
37 {
38 this->preview.setValue(this->value());
39 }

mercurial