src/dialogs/subfilereferenceeditor.cpp

Fri, 22 Jun 2018 15:03:50 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 22 Jun 2018 15:03:50 +0300
changeset 1424
737df8e904af
parent 1403
7a2d84112983
permissions
-rw-r--r--

removed a duplicate member

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},
1392
0541d9b21968 fix compiler warnings
Teemu Piippo <teemu@hecknology.net>
parents: 1391
diff changeset
28 ui {*new Ui::SubfileReferenceEditor},
0541d9b21968 fix compiler warnings
Teemu Piippo <teemu@hecknology.net>
parents: 1391
diff changeset
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
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1298
diff changeset
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 }

mercurial