2 #include "model.h" |
2 #include "model.h" |
3 #include "modeleditcontext.h" |
3 #include "modeleditcontext.h" |
4 #include "linetypes/object.h" |
4 #include "linetypes/object.h" |
5 #include "transformtool.h" |
5 #include "transformtool.h" |
6 |
6 |
7 TransformTool::TransformTool(Model* model, QObject* parent) : |
7 TransformTool::TransformTool(Model* model, QWidget* parent) : |
8 BaseTool{model, parent}, |
8 BaseTool{model, parent}, |
9 model{model}, |
9 model{model}, |
10 button{new QPushButton{"Apply"}}, |
10 matrixEditor{new MatrixEditor{parent}}, |
11 widget{new QWidget} |
11 button{new QPushButton{"Apply", parent}}, |
|
12 widget{new QWidget{parent}} |
12 { |
13 { |
13 widget->setLayout(new QHBoxLayout{widget}); |
14 widget->setLayout(new QHBoxLayout{widget}); |
14 widget->layout()->addWidget(&this->matrixEditor); |
15 widget->layout()->addWidget(this->matrixEditor); |
15 widget->layout()->addWidget(button); |
16 widget->layout()->addWidget(button); |
16 connect(button, &QPushButton::clicked, this, &TransformTool::applyButtonClicked); |
17 connect(button, &QPushButton::clicked, this, &TransformTool::applyButtonClicked); |
17 } |
|
18 |
|
19 TransformTool::~TransformTool() |
|
20 { |
|
21 delete this->widget; |
|
22 delete this->button; |
|
23 } |
18 } |
24 |
19 |
25 QString TransformTool::name() const |
20 QString TransformTool::name() const |
26 { |
21 { |
27 return "Transform"; |
22 return "Transform"; |
43 } |
38 } |
44 |
39 |
45 void TransformTool::applyButtonClicked() |
40 void TransformTool::applyButtonClicked() |
46 { |
41 { |
47 Model::EditContext editcontext = this->model->edit(); |
42 Model::EditContext editcontext = this->model->edit(); |
48 const glm::mat4 matrix = this->matrixEditor.value(); |
43 const glm::mat4 matrix = this->matrixEditor->value(); |
49 for (ldraw::id_t id : this->selection) |
44 for (ldraw::id_t id : this->selection) |
50 { |
45 { |
51 const ldraw::Object* object = model->get(id); |
46 const ldraw::Object* object = model->get(id); |
52 for (int i = 0; i < object->numPoints(); i += 1) |
47 for (int i = 0; i < object->numPoints(); i += 1) |
53 { |
48 { |