zz_addObjectDialog.cpp

Mon, 15 Apr 2013 01:51:53 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 15 Apr 2013 01:51:53 +0300
changeset 106
46e4202a44fc
parent 104
6e29bb0e83c5
child 111
125e8031dbf1
permissions
-rw-r--r--

Added additive selection blending, with a toggable flash effect. :P

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>
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "gui.h"
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "zz_addObjectDialog.h"
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "file.h"
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
23 #include "colors.h"
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
24 #include "zz_colorSelectDialog.h"
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
25 #include "history.h"
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
27 #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
28 for (short i = 0; i < N; ++i) { \
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
29 OBJ->vaCoords[i].x = dlg.qaCoordinates[(i * 3) + 0]->value (); \
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
30 OBJ->vaCoords[i].y = dlg.qaCoordinates[(i * 3) + 1]->value (); \
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
31 OBJ->vaCoords[i].z = dlg.qaCoordinates[(i * 3) + 2]->value (); \
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
32 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
33
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 // =============================================================================
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 // =============================================================================
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 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
38 QDialog (parent)
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 {
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
40 short dCoordCount = 0;
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 41
diff changeset
41 str zIconName = str::mkfmt ("icons/add-%s.png", g_saObjTypeIcons[type]);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
42
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 qTypeIcon = new QLabel;
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 41
diff changeset
44 qTypeIcon->setPixmap (QPixmap (zIconName.chars ()));
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
46 switch (type) {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
47 case OBJ_Comment:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
48 qCommentLine = new QLineEdit;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
49 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
50 case OBJ_Line:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
51 dCoordCount = 6;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
52 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
53 case OBJ_Triangle:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
54 dCoordCount = 9;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
55 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
56 case OBJ_Quad:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
57 case OBJ_CondLine:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
58 dCoordCount = 12;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
59 break;
41
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
60 case OBJ_Vertex:
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
61 dCoordCount = 3;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
62 default:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
63 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
64 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
65
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
66 // Show a color edit dialog for the types that actually use the color
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
67 bool bUsesColor = false;
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
68 switch (type) {
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
69 case OBJ_CondLine:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
70 case OBJ_Line:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
71 case OBJ_Quad:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
72 case OBJ_Triangle:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
73 case OBJ_Vertex:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
74 case OBJ_Subfile:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
75 bUsesColor = true;
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
76 break;
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
77 default:
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
78 break;
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
79 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
80
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
81 if (bUsesColor) {
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
82 dColor = (type == OBJ_CondLine || type == OBJ_Line) ? dEdgeColor : dMainColor;
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
83
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
84 qColorButton = new QPushButton;
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
85 setButtonBackground (qColorButton, dColor);
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
86 connect (qColorButton, SIGNAL (clicked ()), this, SLOT (slot_colorButtonClicked ()));
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
87 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
88
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
89 for (short i = 0; i < dCoordCount; ++i) {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
90 qaCoordinates[i] = new QDoubleSpinBox;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
91 qaCoordinates[i]->setMaximumWidth (96);
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
92 qaCoordinates[i]->setMinimum (-fMaxCoord);
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
93 qaCoordinates[i]->setMaximum (fMaxCoord);
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
94 }
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 IMPLEMENT_DIALOG_BUTTONS
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
98 QGridLayout* const qLayout = new QGridLayout;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
99 qLayout->addWidget (qTypeIcon, 0, 0);
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
100
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
101 switch (type) {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
102 case OBJ_Comment:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
103 qLayout->addWidget (qCommentLine, 0, 1);
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
104 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
105 default:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
106 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
107 }
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
109 if (bUsesColor)
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
110 qLayout->addWidget (qColorButton, 1, 0);
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
111
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
112 if (dCoordCount > 0) {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
113 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
114
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
115 for (short i = 0; i < dCoordCount; ++i)
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
116 qCoordLayout->addWidget (qaCoordinates[i], (i / 3), (i % 3));
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
117
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
118 qLayout->addLayout (qCoordLayout, 0, 1, 2, 1);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
119 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
120
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
121 qLayout->addWidget (qButtons, 2, 1);
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
122 setLayout (qLayout);
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 setWindowTitle (str::mkfmt (APPNAME_DISPLAY " - new %s",
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 g_saObjTypeNames[type]).chars());
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 41
diff changeset
126 setWindowIcon (QIcon (zIconName.chars ()));
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 }
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 // =============================================================================
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 // =============================================================================
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
132 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
133 qButton->setIcon (QIcon ("icons/palette.png"));
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
134 qButton->setAutoFillBackground (true);
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
135 qButton->setStyleSheet (
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
136 str::mkfmt ("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
137 );
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
138 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
139
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
140 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
142 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
143 void AddObjectDialog::slot_colorButtonClicked () {
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
144 ColorSelectDialog::staticDialog (dColor, dColor, this);
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
145 setButtonBackground (qColorButton, dColor);
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
146 }
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
147
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
148 // =============================================================================
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
150 // =============================================================================
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 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
152 AddObjectDialog dlg (type, window);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
153 LDObject* obj = null;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 if (dlg.exec ()) {
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 switch (type) {
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 case OBJ_Comment:
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
158 obj = new LDComment (dlg.qCommentLine->text ());
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
159 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
160
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
161 case OBJ_Line:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
162 {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
163 LDLine* line = new LDLine;
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
164 line->dColor = dlg.dColor;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
165 APPLY_COORDS (line, 2)
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
166 obj = line;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
167 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
168 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
169
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
170 case OBJ_Triangle:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
171 {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
172 LDTriangle* tri = new LDTriangle;
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
173 tri->dColor = dlg.dColor;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
174 APPLY_COORDS (tri, 3)
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
175 obj = tri;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 }
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
177 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
178
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
179 case OBJ_Quad:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
180 {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
181 LDQuad* quad = new LDQuad;
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
182 quad->dColor = dlg.dColor;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
183 APPLY_COORDS (quad, 4)
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
184 obj = quad;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
185 }
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
186 break;
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
187
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
188 case OBJ_CondLine:
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
189 {
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
190 LDCondLine* line = new LDCondLine;
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
191 line->dColor = dlg.dColor;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
192 APPLY_COORDS (line, 4)
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
193 obj = line;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
194 }
41
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
195 break;
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
196
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
197 case OBJ_Vertex:
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
198 {
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
199 LDVertex* vert = new LDVertex;
51
94c434a56961 Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
200 vert->dColor = dlg.dColor;
41
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
201 vert->vPosition.x = dlg.qaCoordinates[0]->value ();
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
202 vert->vPosition.y = dlg.qaCoordinates[1]->value ();
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
203 vert->vPosition.z = dlg.qaCoordinates[2]->value ();
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
204 obj = vert;
41
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
205 }
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
206 break;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
207
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 default:
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 break;
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 }
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
211
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
212 ulong idx = g_CurrentFile->addObject (obj);
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 95
diff changeset
213 History::addEntry (new AddHistory ({idx}, {obj->clone ()}));
95
0a8ad4e3e7c1 Added history support for adding objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
214 window->refresh ();
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 }
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 }

mercurial