src/dialogs/subfilereferenceeditor.cpp

Mon, 04 Jun 2018 23:12:40 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 04 Jun 2018 23:12:40 +0300
changeset 1391
5fa4bf1fc781
parent 1389
3fb8ad4d27b1
child 1392
0541d9b21968
permissions
-rw-r--r--

added work done on cylinders

1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
1 /*
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
2 * LDForge: LDraw parts authoring CAD
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
3 * Copyright (C) 2013 - 2018 Teemu Piippo
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
4 *
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
5 * This program is free software: you can redistribute it and/or modify
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
6 * it under the terms of the GNU General Public License as published by
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
8 * (at your option) any later version.
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
9 *
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
10 * This program is distributed in the hope that it will be useful,
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
13 * GNU General Public License for more details.
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
14 *
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
15 * You should have received a copy of the GNU General Public License
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
17 */
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1313
diff changeset
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},
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 reference {reference},
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 ui {*new Ui::SubfileReferenceEditor}
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
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1298
diff changeset
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 }

mercurial