zz_addObjectDialog.cpp

Fri, 26 Apr 2013 03:44:34 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 26 Apr 2013 03:44:34 +0300
changeset 139
5e31a96adaa2
parent 138
d22d5c1d9e8a
child 140
2e8c1626aef7
permissions
-rw-r--r--

Insertion point calculations fixed, make pasting objects cause the new objects be selected.

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"
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
29 #define APPLY_COORDS(OBJ, N) \
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
30 for (short i = 0; i < N; ++i) { \
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
31 OBJ->vaCoords[i].x = dlg.dsb_coords[(i * 3) + 0]->value (); \
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
32 OBJ->vaCoords[i].y = dlg.dsb_coords[(i * 3) + 1]->value (); \
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
33 OBJ->vaCoords[i].z = dlg.dsb_coords[(i * 3) + 2]->value (); \
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
34 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
35
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 // =============================================================================
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
37 class SubfileListItem : public QTreeWidgetItem {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
38 public:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
39 SubfileListItem (QTreeWidgetItem* parent, int subfileID) :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
40 QTreeWidgetItem (parent), subfileID (subfileID) {}
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
41 SubfileListItem (QTreeWidget* parent, int subfileID) :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
42 QTreeWidgetItem (parent), subfileID (subfileID) {}
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
43
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
44 int subfileID;
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
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
47 // =============================================================================
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 // =============================================================================
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 AddObjectDialog::AddObjectDialog (const LDObjectType_e type, QWidget* parent) :
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 QDialog (parent)
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 {
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
53 short coordCount = 0;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
54 str iconName = format ("icons/add-%s.png", g_saObjTypeIcons[type]);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
55 LDObject* defaults = LDObject::getDefault (type);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
56
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
57 lb_typeIcon = new QLabel;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
58 lb_typeIcon->setPixmap (QPixmap (iconName.chars ()));
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
60 switch (type) {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
61 case OBJ_Comment:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
62 le_comment = new QLineEdit;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
63 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
64
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
65 case OBJ_Line:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
66 coordCount = 6;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
67 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
68
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
69 case OBJ_Triangle:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
70 coordCount = 9;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
71 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
72
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
73 case OBJ_Quad:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
74 case OBJ_CondLine:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
75 coordCount = 12;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
76 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
77
41
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
78 case OBJ_Vertex:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
79 coordCount = 3;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
80
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
81 case OBJ_Subfile:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
82 coordCount = 3;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
83
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
84 enum {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
85 Parts,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
86 Subparts,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
87 Primitives,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
88 HiRes,
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
89 };
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
90
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
91 tw_subfileList = new QTreeWidget ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
92 for (int i : vector<int> ({Parts, Subparts, Primitives, HiRes})) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
93 SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, -1);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
94 parentItem->setText (0, (i == Parts) ? "Parts" :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
95 (i == Subparts) ? "Subparts" :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
96 (i == Primitives) ? "Primitives" :
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
97 "Hi-Res");
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 ulong j = 0;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
100 for (partListEntry& part : g_PartList) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
101 QList<QTreeWidgetItem*> subfileItems;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
102
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
103 str fileName = part.sName;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
104 const bool isSubpart = fileName.substr (0, 2) == "s\\";
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
105 const bool isPrimitive = str (part.sTitle).substr (0, 9) == "Primitive";
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
106 const bool isHiRes = fileName.substr (0, 3) == "48\\";
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 if ((i == Subparts && isSubpart) ||
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
109 (i == Primitives && isPrimitive) ||
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
110 (i == HiRes && isHiRes) ||
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
111 (i == Parts && !isSubpart && !isPrimitive && !isHiRes))
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
112 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
113 SubfileListItem* item = new SubfileListItem (parentItem, j);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
114 item->setText (0, format ("%s - %s", part.sName, part.sTitle));
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
115 subfileItems.append (item);
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
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
118 j++;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
119 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
120
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
121 tw_subfileList->addTopLevelItem (parentItem);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
122 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
123
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
124 connect (tw_subfileList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_subfileTypeChanged ()));
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
125 le_subfileName = new QLineEdit ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
126 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
127
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
128 case OBJ_Radial:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
129 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
130
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
131 lb_radType = new QLabel ("Type:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
132 lb_radResolution = new QLabel ("Resolution:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
133 lb_radSegments = new QLabel ("Segments:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
134 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
135
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
136 bb_radType = new ButtonBox<QRadioButton> ("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
137
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
138 for (int i = 0; i < LDRadial::NumTypes; ++i) {
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
139 if (i % (LDRadial::NumTypes / 2) == 0)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
140 bb_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
141
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
142 bb_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
143 }
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
144
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
145 connect (bb_radType->buttonGroup, SIGNAL (buttonPressed (int)), this, SLOT (slot_radialTypeChanged (int)));
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
146
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
147 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
148
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
149 sb_radSegments = new QSpinBox;
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
150 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
151
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
152 sb_radRingNum = new QSpinBox;
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
153 sb_radRingNum->setEnabled (false);
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
154 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
155
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
156 default:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
157 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
158 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
159
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
160 // 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
161 if (defaults->isColored ()) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
162 dColor = (type == OBJ_CondLine || type == OBJ_Line) ? dEdgeColor : dMainColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
163
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
164 pb_color = new QPushButton;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
165 setButtonBackground (pb_color, dColor);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
166 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
167 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
168
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
169 for (short i = 0; i < coordCount; ++i) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
170 dsb_coords[i] = new QDoubleSpinBox;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
171 dsb_coords[i]->setMinimum (-fMaxCoord);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
172 dsb_coords[i]->setMaximum (fMaxCoord);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
173 }
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 IMPLEMENT_DIALOG_BUTTONS
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
177 QGridLayout* const layout = new QGridLayout;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
178 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
179
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
180 switch (type) {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
181 case OBJ_Comment:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
182 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
183 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
184
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
185 case OBJ_Radial:
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
186 layout->addWidget (bb_radType, 1, 1, 3, 1);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
187 layout->addWidget (cb_radHiRes, 1, 2);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
188 layout->addWidget (lb_radSegments, 2, 2);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
189 layout->addWidget (sb_radSegments, 2, 3);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
190 layout->addWidget (lb_radRingNum, 3, 2);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
191 layout->addWidget (sb_radRingNum, 3, 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
192 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
193
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
194 case OBJ_Subfile:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
195 layout->addWidget (tw_subfileList, 1, 1);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
196 layout->addWidget (le_subfileName, 2, 1);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
197
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
198 default:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
199 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
200 }
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
202 if (defaults->isColored ())
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
203 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
204
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
205 if (coordCount > 0) {
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
206 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
207
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
208 for (short i = 0; i < coordCount; ++i)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
209 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
210
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
211 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
212 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
213
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
214 layout->addWidget (bbx_buttons, 5, 0, 1, 4);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
215 setLayout (layout);
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
216 setWindowTitle (format (APPNAME_DISPLAY " - new %s",
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 g_saObjTypeNames[type]).chars());
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
219 setWindowIcon (QIcon (iconName.chars ()));
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
220 delete defaults;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 }
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 // =============================================================================
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 // =============================================================================
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 68
diff changeset
226 void AddObjectDialog::setButtonBackground (QPushButton* qButton, short dColor) {
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
227 qButton->setIcon (QIcon ("icons/palette.png"));
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
228 qButton->setAutoFillBackground (true);
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
229 qButton->setStyleSheet (
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
230 format ("background-color: %s", getColor (dColor)->zColorString.chars()).chars()
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
231 );
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
232 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
233
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
234 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
236 // =============================================================================
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
237 char* AddObjectDialog::currentSubfileName() {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
238 SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem ());
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
239
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
240 if (item->subfileID == -1)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
241 return null; // selected a heading
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
242
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
243 return g_PartList[item->subfileID].sName;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
244 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
245
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
246 // =============================================================================
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
248 // =============================================================================
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
249 void AddObjectDialog::slot_colorButtonClicked () {
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
250 ColorSelectDialog::staticDialog (dColor, dColor, this);
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
251 setButtonBackground (pb_color, dColor);
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
252 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
253
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
254 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
256 // =============================================================================
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
257 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
258 LDRadial::Type eType = (LDRadial::Type) dType;
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
259 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
260 }
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
261
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
262 // =============================================================================
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
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
264 // =============================================================================
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
265 void AddObjectDialog::slot_subfileTypeChanged () {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
266 char* name = currentSubfileName ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
267
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
268 if (name)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
269 le_subfileName->setText (name);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
270 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
271
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
272 // =============================================================================
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
274 // =============================================================================
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 void AddObjectDialog::staticDialog (const LDObjectType_e type, ForgeWindow* window) {
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 AddObjectDialog dlg (type, window);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
277 LDObject* obj = null;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
279 if (dlg.exec () == false)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
280 return;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
281
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
282 switch (type) {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
283 case OBJ_Comment:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
284 obj = new LDComment (dlg.le_comment->text ());
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
285 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
286
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
287 case OBJ_Line:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
288 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
289 LDLine* line = new LDLine;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
290 line->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
291 APPLY_COORDS (line, 2)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
292 obj = line;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
293 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
294 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
295
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
296 case OBJ_Triangle:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
297 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
298 LDTriangle* tri = new LDTriangle;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
299 tri->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
300 APPLY_COORDS (tri, 3)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
301 obj = tri;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
302 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
303 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
304
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
305 case OBJ_Quad:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
306 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
307 LDQuad* quad = new LDQuad;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
308 quad->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
309 APPLY_COORDS (quad, 4)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
310 obj = quad;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
311 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
312 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
313
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
314 case OBJ_CondLine:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
315 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
316 LDCondLine* line = new LDCondLine;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
317 line->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
318 APPLY_COORDS (line, 4)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
319 obj = line;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 }
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
321 break;
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 case OBJ_Vertex:
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 LDVertex* vert = new LDVertex;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
326 vert->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
327 vert->vPosition.x = dlg.dsb_coords[0]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
328 vert->vPosition.y = dlg.dsb_coords[1]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
329 vert->vPosition.z = dlg.dsb_coords[2]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
330 obj = vert;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
331 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
332 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
333
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
334 case OBJ_Radial:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
335 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
336 LDRadial* pRad = new LDRadial;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
337 pRad->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
338 pRad->vPosition.x = dlg.dsb_coords[0]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
339 pRad->vPosition.y = dlg.dsb_coords[1]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
340 pRad->vPosition.z = dlg.dsb_coords[2]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
341 pRad->dDivisions = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
342 pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
343 pRad->eRadialType = (LDRadial::Type) dlg.bb_radType->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
344 pRad->dRingNum = dlg.sb_radRingNum->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
345 pRad->mMatrix = g_mIdentity;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
346
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
347 obj = pRad;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
348 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
349 break;
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 case OBJ_Subfile:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
352 {
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
353 str name = dlg.le_subfileName->text ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
354 if (~name == 0)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
355 return; // no subfile filename
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
356
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
357 LDSubfile* ref = new LDSubfile;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
358 ref->dColor = dlg.dColor;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
359 ref->vPosition.x = dlg.dsb_coords[0]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
360 ref->vPosition.y = dlg.dsb_coords[1]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
361 ref->vPosition.z = dlg.dsb_coords[2]->value ();
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
362 ref->zFileName = name;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
363 ref->mMatrix = g_mIdentity;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
364 ref->pFile = loadSubfile (name);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
365
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
366 obj = ref;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
367 }
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
368 break;
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
369
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
370 default:
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
371 break;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 }
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
373
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
374 ulong idx = g_CurrentFile->addObject (obj);
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
375 History::addEntry (new AddHistory ({idx}, {obj->clone ()}));
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
376 window->refresh ();
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 }

mercurial