Mon, 04 Jun 2018 23:22:52 +0300
fix compiler warnings
1326 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2018 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | #include "subfilereferenceeditor.h" |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | #include "ui_subfilereferenceeditor.h" |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | #include "../linetypes/modelobject.h" |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | #include "../primitives.h" |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | #include "../guiutilities.h" |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
24 | #include "../dialogs/colorselector.h" |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
25 | |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | SubfileReferenceEditor::SubfileReferenceEditor(LDSubfileReference* reference, QWidget* parent) : |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | QDialog {parent}, |
1392 | 28 | ui {*new Ui::SubfileReferenceEditor}, |
29 | reference {reference} | |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | this->ui.setupUi(this); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
32 | this->ui.referenceName->setText(reference->referenceName()); |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1389
diff
changeset
|
33 | this->ui.matrixEditor->setPosition(reference->position()); |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1389
diff
changeset
|
34 | this->ui.matrixEditor->setMatrix(reference->transformationMatrix()); |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
35 | this->color = reference->color(); |
1299 | 36 | ::setColorButton(this->ui.colorButton, this->color); |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
37 | connect( |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
38 | this->ui.colorButton, |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
39 | &QPushButton::clicked, |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
40 | [&]() |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
41 | { |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
42 | if (ColorSelector::selectColor(this, this->color, this->color)) |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
43 | ::setColorButton(this->ui.colorButton, this->color); |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
44 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
45 | ); |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
46 | connect( |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
47 | this->ui.primitivesTreeView, |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
48 | &QTreeView::clicked, |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
49 | [&](const QModelIndex& index) |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
50 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
51 | QAbstractItemModel* model = this->ui.primitivesTreeView->model(); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
52 | QVariant primitiveName = model->data(index, PrimitiveManager::PrimitiveNameRole); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
53 | |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
54 | if (primitiveName.isValid()) |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
55 | this->ui.referenceName->setText(primitiveName.toString()); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
56 | } |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
57 | ); |
1386
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
58 | } |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
59 | |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
60 | SubfileReferenceEditor::~SubfileReferenceEditor() |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
61 | { |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
62 | delete &this->ui; |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
63 | } |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
64 | |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
65 | void SubfileReferenceEditor::accept() |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
66 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
67 | this->reference->setReferenceName(this->ui.referenceName->text()); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
68 | this->reference->setColor(this->color); |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1389
diff
changeset
|
69 | this->reference->setTransformationMatrix(this->ui.matrixEditor->matrix()); |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1389
diff
changeset
|
70 | this->reference->setPosition(this->ui.matrixEditor->position()); |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
71 | QDialog::accept(); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
72 | } |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
73 | |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
74 | void SubfileReferenceEditor::setPrimitivesTree(PrimitiveManager* primitives) |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
75 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
76 | this->ui.primitivesTreeView->setModel(primitives); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
77 | } |