Fri, 22 Jun 2018 15:03:50 +0300
removed a duplicate member
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->setMatrix(reference->transformationMatrix()); |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
34 | this->color = reference->color(); |
1299 | 35 | ::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
|
36 | connect( |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
37 | this->ui.colorButton, |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
38 | &QPushButton::clicked, |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
39 | [&]() |
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 | 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
|
42 | ::setColorButton(this->ui.colorButton, this->color); |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
43 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1297
diff
changeset
|
44 | ); |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
45 | connect( |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
46 | this->ui.primitivesTreeView, |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
47 | &QTreeView::clicked, |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
48 | [&](const QModelIndex& index) |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
49 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
50 | QAbstractItemModel* model = this->ui.primitivesTreeView->model(); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
51 | QVariant primitiveName = model->data(index, PrimitiveManager::PrimitiveNameRole); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
52 | |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
53 | if (primitiveName.isValid()) |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
54 | this->ui.referenceName->setText(primitiveName.toString()); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
55 | } |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
56 | ); |
1386
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
57 | } |
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 | SubfileReferenceEditor::~SubfileReferenceEditor() |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
60 | { |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
61 | delete &this->ui; |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
62 | } |
c59dac18b06b
added scaling vector editing into the subfile editing dialog
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
63 | |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
64 | void SubfileReferenceEditor::accept() |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
65 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
66 | this->reference->setReferenceName(this->ui.referenceName->text()); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
67 | this->reference->setColor(this->color); |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1389
diff
changeset
|
68 | this->reference->setTransformationMatrix(this->ui.matrixEditor->matrix()); |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
69 | QDialog::accept(); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
70 | } |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
71 | |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
72 | void SubfileReferenceEditor::setPrimitivesTree(PrimitiveManager* primitives) |
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 | this->ui.primitivesTreeView->setModel(primitives); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
75 | } |