Thu, 03 Oct 2013 20:56:20 +0300
last code reformatting i swear
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
4 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
9 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
14 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
19 | #include <QGridLayout> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
20 | #include <QCheckBox> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
21 | #include <QDialogButtonBox> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
22 | #include <QSpinBox> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
23 | #include <QLabel> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
24 | #include <QListWidget> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
25 | #include <QTreeWidget> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
26 | #include <QLineEdit> |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
27 | #include <QPushButton> |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "gui.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "addObjectDialog.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "file.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "colors.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "colorSelectDialog.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "history.h" |
202
a027f6fc6141
Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
199
diff
changeset
|
34 | #include "widgets.h" |
286
7a562bf3d829
Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
279
diff
changeset
|
35 | #include "misc.h" |
292
4779ca562d5e
Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
290
diff
changeset
|
36 | #include "primitives.h" |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
38 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
39 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
40 | class SubfileListItem : public QTreeWidgetItem |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
41 | { PROPERTY (Primitive*, primInfo, setPrimInfo) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
42 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
43 | public: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
44 | SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
45 | QTreeWidgetItem (parent), m_primInfo (info) {} |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
46 | SubfileListItem (QTreeWidget* parent, Primitive* info) : |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
47 | QTreeWidgetItem (parent), m_primInfo (info) {} |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
51 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
52 | AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : QDialog (parent) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
53 | { setlocale (LC_ALL, "C"); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
54 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | short coordCount = 0; |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
56 | str typeName = LDObject::typeName (type); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
57 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
58 | switch (type) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
59 | { case LDObject::Comment: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
60 | le_comment = new QLineEdit; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
61 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
62 | if (obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
63 | le_comment->setText (static_cast<LDComment*> (obj)->text); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
64 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
65 | le_comment->setMinimumWidth (384); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
66 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
67 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
68 | case LDObject::Line: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
69 | coordCount = 6; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
70 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
71 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
72 | case LDObject::Triangle: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
73 | coordCount = 9; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
74 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
75 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
76 | case LDObject::Quad: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
77 | case LDObject::CndLine: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
78 | coordCount = 12; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
79 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
80 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
81 | case LDObject::Vertex: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
82 | coordCount = 3; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
83 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
84 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
85 | case LDObject::BFC: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
86 | rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
87 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
88 | for (int i = 0; i < LDBFC::NumStatements; ++i) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
89 | { // Separate these in two columns |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
90 | if (i == LDBFC::NumStatements / 2) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
91 | rb_bfcType->rowBreak(); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
92 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
93 | rb_bfcType->addButton (LDBFC::statements[i]); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
95 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
96 | if (obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
97 | rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->type); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
98 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
99 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
100 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
101 | case LDObject::Subfile: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
102 | coordCount = 3; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
103 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
104 | // If the primitive lister is busy writing data, we have to wait |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
105 | // for that to happen first. This should be quite considerably rare. |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
106 | while (primitiveLoaderBusy()) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
107 | ; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
108 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
109 | tw_subfileList = new QTreeWidget(); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
110 | tw_subfileList->setHeaderLabel (tr ("Primitives")); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
111 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
112 | for (PrimitiveCategory & cat : g_PrimitiveCategories) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
113 | { SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
114 | parentItem->setText (0, cat.name()); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
115 | QList<QTreeWidgetItem*> subfileItems; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
116 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
117 | for (Primitive & prim : cat.prims) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
118 | { SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
119 | item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
120 | subfileItems << item; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
121 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
122 | // If this primitive is the one the current object points to, |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
123 | // select it by default |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
124 | if (obj && static_cast<LDSubfile*> (obj)->fileInfo()->name() == prim.name) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
125 | tw_subfileList->setCurrentItem (item); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
126 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
127 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
128 | tw_subfileList->addTopLevelItem (parentItem); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
129 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
130 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
131 | connect (tw_subfileList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_subfileTypeChanged())); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
132 | lb_subfileName = new QLabel ("File:"); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
133 | le_subfileName = new QLineEdit; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
134 | le_subfileName->setFocus(); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
135 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
136 | if (obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
137 | { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
138 | le_subfileName->setText (ref->fileInfo()->name()); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
139 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
140 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
141 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
142 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
143 | default: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
144 | critical (fmt ("Unhandled LDObject type %1 (%2) in AddObjectDialog", (int) type, typeName)); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
145 | return; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
147 | |
357
9c954c222996
Removed the two string arrays containing object types and icon names, moved these as LDObjects' virtual functions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
327
diff
changeset
|
148 | QPixmap icon = getIcon (fmt ("add-%1", typeName)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | LDObject* defaults = LDObject::getDefault (type); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
150 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | lb_typeIcon = new QLabel; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | lb_typeIcon->setPixmap (icon); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
153 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | // Show a color edit dialog for the types that actually use the color |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
155 | if (defaults->isColored()) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
156 | { if (obj != null) |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
157 | colnum = obj->color(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | else |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
159 | colnum = (type == LDObject::CndLine || type == LDObject::Line) ? edgecolor : maincolor; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
160 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | pb_color = new QPushButton; |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
162 | setButtonBackground (pb_color, colnum); |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
163 | connect (pb_color, SIGNAL (clicked()), this, SLOT (slot_colorButtonClicked())); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
165 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
166 | for (short i = 0; i < coordCount; ++i) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
167 | { dsb_coords[i] = new QDoubleSpinBox; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | dsb_coords[i]->setDecimals (5); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | dsb_coords[i]->setMinimum (-10000.0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | dsb_coords[i]->setMaximum (10000.0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
172 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | QGridLayout* const layout = new QGridLayout; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | layout->addWidget (lb_typeIcon, 0, 0); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
175 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
176 | switch (type) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
177 | { case LDObject::Line: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
178 | case LDObject::CndLine: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
179 | case LDObject::Triangle: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
180 | case LDObject::Quad: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
181 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
182 | // Apply coordinates |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
183 | if (obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
184 | { for (short i = 0; i < coordCount / 3; ++i) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
185 | for (short j = 0; j < 3; ++j) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
186 | dsb_coords[ (i * 3) + j]->setValue (obj->getVertex (i).coord (j)); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
187 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
188 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
189 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
190 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
191 | case LDObject::Comment: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
192 | layout->addWidget (le_comment, 0, 1); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
193 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
194 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
195 | case LDObject::BFC: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
196 | layout->addWidget (rb_bfcType, 0, 1); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
197 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
198 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
199 | case LDObject::Subfile: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
200 | layout->addWidget (tw_subfileList, 1, 1, 1, 2); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
201 | layout->addWidget (lb_subfileName, 2, 1); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
202 | layout->addWidget (le_subfileName, 2, 2); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
203 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
204 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
205 | default: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
206 | break; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
208 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
209 | if (defaults->hasMatrix()) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
210 | { LDMatrixObject* mo = obj ? dynamic_cast<LDMatrixObject*> (obj) : null; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
211 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | QLabel* lb_matrix = new QLabel ("Matrix:"); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | le_matrix = new QLineEdit; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | // le_matrix->setValidator (new QDoubleValidator); |
268
778eed342ee4
Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents:
267
diff
changeset
|
215 | matrix defaultMatrix = g_identity; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
216 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
217 | if (mo) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
218 | { for (const Axis ax : g_Axes) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
219 | dsb_coords[ax]->setValue (mo->position() [ax]); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
220 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
221 | defaultMatrix = mo->transform(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
223 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
224 | le_matrix->setText (defaultMatrix.stringRep()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | layout->addWidget (lb_matrix, 4, 1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | layout->addWidget (le_matrix, 4, 2, 1, 3); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
228 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
229 | if (defaults->isColored()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | layout->addWidget (pb_color, 1, 0); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
231 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
232 | if (coordCount > 0) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
233 | { QGridLayout* const qCoordLayout = new QGridLayout; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
234 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | for (short i = 0; i < coordCount; ++i) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | qCoordLayout->addWidget (dsb_coords[i], (i / 3), (i % 3)); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
237 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | layout->addLayout (qCoordLayout, 0, 1, (coordCount / 3), 3); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
240 | |
384
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
241 | QDialogButtonBox* bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
242 | QWidget::connect (bbx_buttons, SIGNAL (accepted()), this, SLOT (accept())); |
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
243 | QWidget::connect (bbx_buttons, SIGNAL (rejected()), this, SLOT (reject())); |
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
244 | layout->addWidget (bbx_buttons, 5, 0, 1, 4); |
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
245 | setLayout (layout); |
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
246 | setWindowTitle (fmt (tr ("Edit %1"), typeName)); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
247 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | setWindowIcon (icon); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | delete defaults; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
253 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
254 | void AddObjectDialog::setButtonBackground (QPushButton* button, short colnum) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
255 | { LDColor* col = getColor (colnum); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
256 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | button->setIcon (getIcon ("palette")); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | button->setAutoFillBackground (true); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
259 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
260 | if (col) |
363
75583c9f289d
primitive generator: add conditional lines to cylinders; improved bad color handling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
261 | button->setStyleSheet (fmt ("background-color: %1", col->hexcode)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
265 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
266 | str AddObjectDialog::currentSubfileName() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
267 | { SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
268 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
269 | if (item->primInfo() == null) |
290
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
270 | return ""; // selected a heading |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
271 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
272 | return item->primInfo()->name; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
276 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
277 | void AddObjectDialog::slot_colorButtonClicked() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
278 | { ColorSelector::getColor (colnum, colnum, this); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
279 | setButtonBackground (pb_color, colnum); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
283 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
284 | void AddObjectDialog::slot_subfileTypeChanged() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
285 | { str name = currentSubfileName(); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
286 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
287 | if (name.length() > 0) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | le_subfileName->setText (name); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
292 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
293 | template<class T> static T* initObj (LDObject*& obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
294 | { if (obj == null) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | obj = new T; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
296 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | return static_cast<T*> (obj); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
301 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
302 | void AddObjectDialog::staticDialog (const LDObject::Type type, LDObject* obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
303 | { setlocale (LC_ALL, "C"); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
304 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
305 | // FIXME: Redirect to Edit Raw |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
306 | if (obj && obj->getType() == LDObject::Error) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
308 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | if (type == LDObject::Empty) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | return; // Nothing to edit with empties |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
311 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | const bool newObject = (obj == null); |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
313 | matrix transform = g_identity; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | AddObjectDialog dlg (type, obj); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
315 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | if (obj) |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
317 | assert (obj->getType() == type); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
318 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
319 | if (dlg.exec() == false) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
321 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
322 | if (type == LDObject::Subfile) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
323 | { QStringList matrixstrvals = dlg.le_matrix->text().split (" "); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
324 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
325 | if (matrixstrvals.size() == 9) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
326 | { double matrixvals[9]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | int i = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
328 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
329 | for (str val : matrixstrvals) |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
330 | matrixvals[i++] = val.toFloat(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
331 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
332 | transform = matrix (matrixvals); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
335 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
336 | switch (type) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
337 | { case LDObject::Comment: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
338 | { LDComment* comm = initObj<LDComment> (obj); |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
339 | comm->text = dlg.le_comment->text(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | break; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
342 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
343 | case LDObject::Line: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
344 | case LDObject::Triangle: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
345 | case LDObject::Quad: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
346 | case LDObject::CndLine: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
347 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
348 | if (!obj) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
349 | obj = LDObject::getDefault (type); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
350 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
351 | for (short i = 0; i < obj->vertices(); ++i) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
352 | { vertex v; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
353 | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
354 | for (const Axis ax : g_Axes) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
355 | v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
356 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
357 | obj->setVertex (i, v); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
358 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
359 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
360 | break; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
361 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
362 | case LDObject::BFC: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
363 | { LDBFC* bfc = initObj<LDBFC> (obj); |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
364 | bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | break; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
367 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
368 | case LDObject::Vertex: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
369 | { LDVertex* vert = initObj<LDVertex> (obj); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
370 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
371 | for (const Axis ax : g_Axes) |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
372 | vert->pos[ax] = dlg.dsb_coords[ax]->value(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | break; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
375 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
376 | case LDObject::Subfile: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
377 | { str name = dlg.le_subfileName->text(); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
378 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
379 | if (name.length() == 0) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | return; // no subfile filename |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
381 | |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
382 | LDFile* file = getFile (name); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
383 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
384 | if (!file) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
385 | { critical (fmt ("Couldn't open `%1': %2", name, strerror (errno))); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
386 | return; |
213
a4113545242c
Look for LDraw files in the part's directory first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
202
diff
changeset
|
387 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
388 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
389 | LDSubfile* ref = initObj<LDSubfile> (obj); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
390 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
391 | for (const Axis ax : g_Axes) |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
392 | ref->setCoordinate (ax, dlg.dsb_coords[ax]->value()); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
393 | |
268
778eed342ee4
Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents:
267
diff
changeset
|
394 | ref->setTransform (transform); |
269
2d71227f35cb
Refactor LDSubfile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
268
diff
changeset
|
395 | ref->setFileInfo (file); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | break; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
398 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
399 | default: |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
400 | break; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
402 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
403 | if (obj->isColored()) |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
404 | obj->setColor (dlg.colnum); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
405 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
406 | if (newObject) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
407 | { ulong idx = g_win->getInsertionPoint(); |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
408 | LDFile::current()->insertObj (idx, obj); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
491
diff
changeset
|
410 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
411 | g_win->fullRefresh(); |
491
7d1b5ecd76c0
it's LDForge's 1st birthday!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
479
diff
changeset
|
412 | } |
7d1b5ecd76c0
it's LDForge's 1st birthday!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
479
diff
changeset
|
413 | #include "moc_addObjectDialog.cpp" |