zz_addObjectDialog.cpp

Wed, 08 May 2013 14:57:48 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 08 May 2013 14:57:48 +0300
changeset 182
9374fea8f77f
parent 181
a61f07b7965c
permissions
-rw-r--r--

Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.

39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <qgridlayout.h>
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
20 #include <qradiobutton.h>
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
21 #include <qcheckbox.h>
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "gui.h"
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "zz_addObjectDialog.h"
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "file.h"
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
25 #include "colors.h"
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
26 #include "zz_colorSelectDialog.h"
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
27 #include "history.h"
172
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
28 #include "zz_setContentsDialog.h"
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
30 #define APPLY_COORDS(OBJ, N) \
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
31 for (short i = 0; i < N; ++i) \
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
32 for (const Axis ax : g_Axes) \
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
33 OBJ->vaCoords[i][ax] = dlg.dsb_coords[(i * 3) + ax]->value ();
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
34
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 // =============================================================================
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
36 class SubfileListItem : public QTreeWidgetItem {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
37 public:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
38 SubfileListItem (QTreeWidgetItem* parent, int subfileID) :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
39 QTreeWidgetItem (parent), subfileID (subfileID) {}
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
40 SubfileListItem (QTreeWidget* parent, int subfileID) :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
41 QTreeWidgetItem (parent), subfileID (subfileID) {}
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
42
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
43 int subfileID;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
44 };
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
45
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
46 // =============================================================================
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 // =============================================================================
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
49 AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) :
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 QDialog (parent)
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 {
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
52 setlocale (LC_ALL, "C");
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
53
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
54 short coordCount = 0;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
56 switch (type) {
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
57 case LDObject::Comment:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
58 le_comment = new QLineEdit;
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
59 if (obj)
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
60 le_comment->setText (static_cast<LDComment*> (obj)->text);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
61 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
62
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
63 case LDObject::Line:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
64 coordCount = 6;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
65 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
66
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
67 case LDObject::Triangle:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
68 coordCount = 9;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
69 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
70
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
71 case LDObject::Quad:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
72 case LDObject::CondLine:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
73 coordCount = 12;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
74 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
75
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
76 case LDObject::Vertex:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
77 coordCount = 3;
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
78 break;
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
79
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
80 case LDObject::BFC:
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
81 rb_bfcType = new RadioBox ("Statement", {}, 0, Qt::Vertical);
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
82
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
83 for (int i = 0; i < LDBFC::NumStatements; ++i)
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
84 rb_bfcType->addButton (new QRadioButton (LDBFC::statements[i]));
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
85
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
86 if (obj)
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
87 rb_bfcType->setValue ((int) static_cast<LDBFC*> (obj)->type);
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
88 break;
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
89
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
90 case LDObject::Subfile:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
91 coordCount = 3;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
92
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
93 enum {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
94 Parts,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
95 Subparts,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
96 Primitives,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
97 HiRes,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
98 };
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
99
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
100 tw_subfileList = new QTreeWidget ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
101 for (int i : vector<int> ({Parts, Subparts, Primitives, HiRes})) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
102 SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, -1);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
103 parentItem->setText (0, (i == Parts) ? "Parts" :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
104 (i == Subparts) ? "Subparts" :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
105 (i == Primitives) ? "Primitives" :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
106 "Hi-Res");
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
107
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
108 ulong j = 0;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
109 for (partListEntry& part : g_PartList) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
110 QList<QTreeWidgetItem*> subfileItems;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
111
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
112 str fileName = part.sName;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
113 const bool isSubpart = fileName.substr (0, 2) == "s\\";
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
114 const bool isPrimitive = str (part.sTitle).substr (0, 9) == "Primitive";
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
115 const bool isHiRes = fileName.substr (0, 3) == "48\\";
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
116
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
117 if ((i == Subparts && isSubpart) ||
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
118 (i == Primitives && isPrimitive) ||
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
119 (i == HiRes && isHiRes) ||
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
120 (i == Parts && !isSubpart && !isPrimitive && !isHiRes))
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
121 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
122 SubfileListItem* item = new SubfileListItem (parentItem, j);
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
123 item->setText (0, fmt ("%s - %s", part.sName, part.sTitle));
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
124 subfileItems.append (item);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
125 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
126
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
127 j++;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
128 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
129
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
130 tw_subfileList->addTopLevelItem (parentItem);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
131 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
132
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
133 connect (tw_subfileList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_subfileTypeChanged ()));
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
134 lb_subfileName = new QLabel ("File:");
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
135 le_subfileName = new QLineEdit;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
136 le_subfileName->setFocus ();
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
137
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
138 if (obj) {
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
139 LDSubfile* ref = static_cast<LDSubfile*> (obj);
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
140 le_subfileName->setText (ref->zFileName);
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
141 }
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
142 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
143
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
144 case LDObject::Radial:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
145 coordCount = 3;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
146
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
147 lb_radType = new QLabel ("Type:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
148 lb_radResolution = new QLabel ("Resolution:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
149 lb_radSegments = new QLabel ("Segments:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
150 lb_radRingNum = new QLabel ("Ring number:");
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
151
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
152 rb_radType = new RadioBox ("Type", {}, 0, Qt::Vertical);
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
153
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
154 for (int i = 0; i < LDRadial::NumTypes; ++i) {
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
155 if (i % (LDRadial::NumTypes / 2) == 0)
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
156 rb_radType->rowBreak ();
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
157
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
158 rb_radType->addButton (new QRadioButton (LDRadial::radialTypeName ((LDRadial::Type) i)));
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
159 }
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
160
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
161 connect (rb_radType, SIGNAL (sig_buttonPressed (int)), this, SLOT (slot_radialTypeChanged (int)));
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
162
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
163 cb_radHiRes = new QCheckBox ("Hi-Res");
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
164
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
165 sb_radSegments = new QSpinBox;
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
166 sb_radSegments->setMinimum (1);
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
167
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
168 sb_radRingNum = new QSpinBox;
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
169 sb_radRingNum->setEnabled (false);
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
170
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
171 if (obj) {
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
172 LDRadial* rad = static_cast<LDRadial*> (obj);
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
173
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
174 rb_radType->setValue (rad->eRadialType);
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
175 sb_radSegments->setValue (rad->dSegments);
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
176 cb_radHiRes->setChecked ((rad->dDivisions == 48) ? Qt::Checked : Qt::Unchecked);
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
177 sb_radRingNum->setValue (rad->dRingNum);
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
178 }
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
179 break;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
180
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
181 default:
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
182 assert (false);
172
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
183 return;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
184 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
185
172
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
186 QPixmap icon = getIcon (fmt ("add-%s", g_saObjTypeIcons[type]));
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
187 LDObject* defaults = LDObject::getDefault (type);
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
188
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
189 lb_typeIcon = new QLabel;
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
190 lb_typeIcon->setPixmap (icon);
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
191
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
192 // Show a color edit dialog for the types that actually use the color
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
193 if (defaults->isColored ()) {
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
194 if (obj != null)
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
195 dColor = obj->dColor;
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
196 else
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
197 dColor = (type == LDObject::CondLine || type == LDObject::Line) ? edgecolor : maincolor;
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
198
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
199 pb_color = new QPushButton;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
200 setButtonBackground (pb_color, dColor);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
201 connect (pb_color, SIGNAL (clicked ()), this, SLOT (slot_colorButtonClicked ()));
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
202 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
203
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
204 for (short i = 0; i < coordCount; ++i) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
205 dsb_coords[i] = new QDoubleSpinBox;
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
206 dsb_coords[i]->setDecimals (5);
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
207 dsb_coords[i]->setMinimum (-10000.0);
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
208 dsb_coords[i]->setMaximum (10000.0);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
209 }
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 IMPLEMENT_DIALOG_BUTTONS
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
213 QGridLayout* const layout = new QGridLayout;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
214 layout->addWidget (lb_typeIcon, 0, 0);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
215
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
216 switch (type) {
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
217 case LDObject::Line:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
218 case LDObject::CondLine:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
219 case LDObject::Triangle:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
220 case LDObject::Quad:
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
221 // Apply coordinates
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
222 if (obj) {
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
223 for (short i = 0; i < coordCount / 3; ++i)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
224 for (short j = 0; j < 3; ++j)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
225 dsb_coords[(i * 3) + j]->setValue (obj->vaCoords[i].coord (j));
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
226 }
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
227 break;
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
228
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
229 case LDObject::Comment:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
230 layout->addWidget (le_comment, 0, 1);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
231 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
232
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
233 case LDObject::BFC:
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
234 layout->addWidget (rb_bfcType, 0, 1);
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
235 break;
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
236
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
237 case LDObject::Radial:
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
238 layout->addWidget (rb_radType, 1, 1, 3, 2);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
239 layout->addWidget (cb_radHiRes, 1, 3);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
240 layout->addWidget (lb_radSegments, 2, 3);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
241 layout->addWidget (sb_radSegments, 2, 4);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
242 layout->addWidget (lb_radRingNum, 3, 3);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
243 layout->addWidget (sb_radRingNum, 3, 4);
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
244
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
245 if (obj)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
246 for (short i = 0; i < 3; ++i)
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
247 dsb_coords[i]->setValue (static_cast<LDRadial*> (obj)->vPosition.coord (i));
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
248 break;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
249
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
250 case LDObject::Subfile:
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
251 layout->addWidget (tw_subfileList, 1, 1, 1, 2);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
252 layout->addWidget (lb_subfileName, 2, 1);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
253 layout->addWidget (le_subfileName, 2, 2);
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
254
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
255 if (obj)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
256 for (short i = 0; i < 3; ++i)
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
257 dsb_coords[i]->setValue (static_cast<LDSubfile*> (obj)->vPosition.coord (i));
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
258 break;
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
259
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
260 default:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
261 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
262 }
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
264 if (type == LDObject::Subfile || type == LDObject::Radial) {
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
265 QLabel* lb_matrix = new QLabel ("Matrix:");
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
266 le_matrix = new QLineEdit;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
267 // le_matrix->setValidator (new QDoubleValidator);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
268 matrix<3> defval = g_identity;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
269
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
270 if (obj) {
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
271 if (obj->getType () == LDObject::Subfile)
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
272 defval = static_cast<LDSubfile*> (obj)->mMatrix;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
273 else
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
274 defval = static_cast<LDRadial*> (obj)->mMatrix;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
275 }
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
276
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
277 le_matrix->setText (defval.stringRep ());
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
278 layout->addWidget (lb_matrix, 4, 1);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
279 layout->addWidget (le_matrix, 4, 2, 1, 3);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
280 }
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
281
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
282 if (defaults->isColored ())
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
283 layout->addWidget (pb_color, 1, 0);
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
284
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
285 if (coordCount > 0) {
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
286 QGridLayout* const qCoordLayout = new QGridLayout;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
287
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
288 for (short i = 0; i < coordCount; ++i)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
289 qCoordLayout->addWidget (dsb_coords[i], (i / 3), (i % 3));
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
290
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
291 layout->addLayout (qCoordLayout, 0, 1, (coordCount / 3), 3);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
292 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
293
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
294 layout->addWidget (bbx_buttons, 5, 0, 1, 4);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
295 setLayout (layout);
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
296 setWindowTitle (fmt (APPNAME ": New %s",
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 g_saObjTypeNames[type]).chars());
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298
158
499286fcbf37 Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents: 157
diff changeset
299 setWindowIcon (icon);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
300 delete defaults;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 }
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 // =============================================================================
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 // =============================================================================
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
306 void AddObjectDialog::setButtonBackground (QPushButton* button, short color) {
158
499286fcbf37 Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents: 157
diff changeset
307 button->setIcon (getIcon ("palette"));
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
308 button->setAutoFillBackground (true);
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
309 button->setStyleSheet (
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
310 fmt ("background-color: %s", getColor (color)->zColorString.chars()).chars()
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
311 );
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
312 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
313
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
314 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
316 // =============================================================================
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
317 char* AddObjectDialog::currentSubfileName() {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
318 SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem ());
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
319
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
320 if (item->subfileID == -1)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
321 return null; // selected a heading
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
322
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
323 return g_PartList[item->subfileID].sName;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
324 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
325
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
326 // =============================================================================
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
328 // =============================================================================
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
329 void AddObjectDialog::slot_colorButtonClicked () {
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
330 ColorSelectDialog::staticDialog (dColor, dColor, this);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
331 setButtonBackground (pb_color, dColor);
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
332 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
333
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
334 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
336 // =============================================================================
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
337 void AddObjectDialog::slot_radialTypeChanged (int dType) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
338 LDRadial::Type eType = (LDRadial::Type) dType;
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
339 sb_radRingNum->setEnabled (eType == LDRadial::Ring || eType == LDRadial::Cone);
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
340 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
341
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
342 // =============================================================================
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
344 // =============================================================================
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
345 void AddObjectDialog::slot_subfileTypeChanged () {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
346 char* name = currentSubfileName ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
347
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
348 if (name)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
349 le_subfileName->setText (name);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
350 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
351
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
352 // =============================================================================
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
353 template<class T> T* initObj (LDObject*& obj) {
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
354 if (obj == null)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
355 obj = new T;
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
356
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
357 return static_cast<T*> (obj);
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
358 }
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
359
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
360 // =============================================================================
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
362 // =============================================================================
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
363 void AddObjectDialog::staticDialog (const LDObject::Type type, LDObject* obj) {
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
364 setlocale (LC_ALL, "C");
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
365
172
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
366 // Redirect editing of gibberish to the set contents dialog
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
367 if (obj && obj->getType () == LDObject::Gibberish) {
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
368 SetContentsDialog::staticDialog (obj);
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
369 return;
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
370 }
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
371
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
372 if (type == LDObject::Empty)
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
373 return; // Nothing to edit with empties
a65547b84ef8 Restructured the shortcut configuration tab a little, allowing it to be sorted.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
374
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
375 const bool newObject = (obj == null);
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
376 AddObjectDialog dlg (type, obj);
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
377
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
378 if (obj)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
379 assert (obj->getType () == type);
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
381 if (dlg.exec () == false)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
382 return;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
383
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
384 LDObject* backup = null;
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
385 if (!newObject)
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
386 backup = obj->clone ();
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
387
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
388 matrix<3> transform = g_identity;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
389 if (type == LDObject::Subfile || type == LDObject::Radial) {
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
390 vector<str> matrixstrvals = str (dlg.le_matrix->text ()).split (" ", true);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
391
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
392 if (matrixstrvals.size () == 9) {
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
393 double matrixvals[9];
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
394 int i = 0;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
395
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
396 for (str val : matrixstrvals)
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
397 matrixvals[i++] = atof (val);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
398
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
399 transform = matrix<3> (matrixvals);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
400 }
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
401 }
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
402
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
403 switch (type) {
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
404 case LDObject::Comment:
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
405 {
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
406 LDComment* comm = initObj<LDComment> (obj);
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
407 comm->text = dlg.le_comment->text ();
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
408 }
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
409 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
410
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
411 case LDObject::Line:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
412 {
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
413 LDLine* line = initObj<LDLine> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
414 line->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
415 APPLY_COORDS (line, 2)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
416 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
417 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
418
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
419 case LDObject::Triangle:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
420 {
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
421 LDTriangle* tri = initObj<LDTriangle> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
422 tri->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
423 APPLY_COORDS (tri, 3)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
424 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
425 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
426
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
427 case LDObject::Quad:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
428 {
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
429 LDQuad* quad = initObj<LDQuad> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
430 quad->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
431 APPLY_COORDS (quad, 4)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
432 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
433 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
434
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
435 case LDObject::CondLine:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
436 {
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
437 LDCondLine* line = initObj<LDCondLine> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
438 line->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
439 APPLY_COORDS (line, 4)
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 }
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
441 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
442
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
443 case LDObject::BFC:
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
444 {
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
445 LDBFC* bfc = initObj<LDBFC> (obj);
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
446 bfc->type = (LDBFC::Type) dlg.rb_bfcType->value ();
150
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
447 }
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
448 break;
bcbbdc5454e6 Added new BFC dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
449
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
450 case LDObject::Vertex:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
451 {
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
452 LDVertex* vert = initObj<LDVertex> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
453 vert->dColor = dlg.dColor;
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
454
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
455 for (const Axis ax : g_Axes)
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
456 vert->vPosition[ax] = dlg.dsb_coords[ax]->value ();
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
457 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
458 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
459
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
460 case LDObject::Radial:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
461 {
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
462 LDRadial* pRad = initObj<LDRadial> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
463 pRad->dColor = dlg.dColor;
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
464
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
465 for (const Axis ax : g_Axes)
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
466 pRad->vPosition[ax] = dlg.dsb_coords[ax]->value ();
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
467
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
468 pRad->dDivisions = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
469 pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions);
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
470 pRad->eRadialType = (LDRadial::Type) dlg.rb_radType->value ();
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
471 pRad->dRingNum = dlg.sb_radRingNum->value ();
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
472 pRad->mMatrix = transform;
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
473 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
474 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
475
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
476 case LDObject::Subfile:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
477 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
478 str name = dlg.le_subfileName->text ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
479 if (~name == 0)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
480 return; // no subfile filename
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
481
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
482 OpenFile* file = loadSubfile (name);
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
483 if (!file)
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
484 return;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
485
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
486 LDSubfile* ref = initObj<LDSubfile> (obj);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
487 ref->dColor = dlg.dColor;
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
488
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
489 for (const Axis ax : g_Axes)
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
490 ref->vPosition[ax] = dlg.dsb_coords[ax]->value ();
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
491
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
492 ref->zFileName = name;
181
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
493 ref->mMatrix = transform;
a61f07b7965c Object editing dialog now can alter the matrix of subfiles and radials
Santeri Piippo <crimsondusk64@gmail.com>
parents: 172
diff changeset
494 ref->pFile = file;
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
495 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
496 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
497
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
498 default:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
499 break;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
500 }
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
501
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
502 if (newObject) {
160
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
503 ulong idx = g_win->getInsertionPoint ();
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
504 g_curfile->insertObj (idx, obj);
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
505 History::addEntry (new AddHistory ({(ulong) idx}, {obj->clone ()}));
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
506 } else {
160
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
507 History::addEntry (new EditHistory ({(ulong) obj->getIndex (g_curfile)}, {backup}, {obj->clone ()}));
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
508 }
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
509
160
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
510 g_win->refresh ();
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 }

mercurial