src/ui/multiplyfactordialog.cpp

Wed, 18 Mar 2020 15:52:16 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 18 Mar 2020 15:52:16 +0200
changeset 83
b8bd338eb602
parent 81
62373840e33a
child 88
14e51640c189
permissions
-rw-r--r--

refactor, added splitter

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

mercurial