Mon, 25 Mar 2013 01:04:20 +0200
57181.dat (Philo's model of the XL-motor) showcased a new problem.. there was no handling of unknown colors which led into crashes. Added stdout warnings, also added mid and dark stone colors
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 |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri `arezey` Piippo |
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" |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
26 | #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
|
27 | 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
|
28 | 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
|
29 | 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
|
30 | 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
|
31 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
32 | |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | // ============================================================================= |
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 | 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
|
37 | QDialog (parent) |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | { |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
39 | short dCoordCount = 0; |
42
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
40 | 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
|
41 | |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | qTypeIcon = new QLabel; |
42
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
43 | qTypeIcon->setPixmap (QPixmap (zIconName.chars ())); |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
45 | switch (type) { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
46 | case OBJ_Comment: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
47 | qCommentLine = new QLineEdit; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
48 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
49 | case OBJ_Line: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
50 | dCoordCount = 6; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
51 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
52 | case OBJ_Triangle: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
53 | dCoordCount = 9; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
54 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
55 | case OBJ_Quad: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
56 | case OBJ_CondLine: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
57 | dCoordCount = 12; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
58 | break; |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
59 | case OBJ_Vertex: |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
60 | dCoordCount = 3; |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
61 | default: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
62 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
63 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
64 | |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
65 | // 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
|
66 | bool bUsesColor = false; |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
67 | switch (type) { |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
68 | case OBJ_CondLine: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
69 | case OBJ_Line: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
70 | case OBJ_Quad: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
71 | case OBJ_Triangle: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
72 | case OBJ_Vertex: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
73 | case OBJ_Subfile: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
74 | bUsesColor = true; |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
75 | break; |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
76 | default: |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
77 | break; |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
78 | } |
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 | if (bUsesColor) { |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
81 | 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
|
82 | |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
83 | qColorButton = new QPushButton; |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
84 | setButtonBackground (qColorButton, g_LDColors[dColor]->zColor); |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
85 | 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
|
86 | } |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
87 | |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
88 | 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
|
89 | qaCoordinates[i] = new QDoubleSpinBox; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
90 | qaCoordinates[i]->setMaximumWidth (96); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
91 | qaCoordinates[i]->setMinimum (-fMaxCoord); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
92 | qaCoordinates[i]->setMaximum (fMaxCoord); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
93 | } |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | IMPLEMENT_DIALOG_BUTTONS |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
97 | 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
|
98 | 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
|
99 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
100 | switch (type) { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
101 | case OBJ_Comment: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
102 | 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
|
103 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
104 | default: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
105 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
106 | } |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
108 | if (bUsesColor) |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
109 | qLayout->addWidget (qColorButton, 1, 0); |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
110 | |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
111 | if (dCoordCount > 0) { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
112 | 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
|
113 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
114 | 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
|
115 | 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
|
116 | |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
117 | 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
|
118 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
119 | |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
120 | 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
|
121 | setLayout (qLayout); |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | 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
|
123 | g_saObjTypeNames[type]).chars()); |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | |
42
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
125 | setWindowIcon (QIcon (zIconName.chars ())); |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | } |
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 | // ============================================================================= |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
131 | void AddObjectDialog::setButtonBackground (QPushButton* qButton, str zValue) { |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
132 | qButton->setIcon (QIcon ("icons/palette.png")); |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
133 | qButton->setAutoFillBackground (true); |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
134 | qButton->setStyleSheet ( |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
135 | str::mkfmt ("background-color: %s", zValue.chars()).chars() |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
136 | ); |
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 | void AddObjectDialog::slot_colorButtonClicked () { |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
143 | ColorSelectDialog::staticDialog (dColor, dColor, this); |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
144 | setButtonBackground (qColorButton, g_LDColors[dColor]->zColor); |
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
145 | } |
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 | // ============================================================================= |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | 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
|
151 | AddObjectDialog dlg (type, window); |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | if (dlg.exec ()) { |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | switch (type) { |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | case OBJ_Comment: |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | { |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | LDComment* comm = new LDComment; |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | comm->zText = dlg.qCommentLine->text (); |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | g_CurrentFile->addObject (comm); |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | window->refresh (); |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
161 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
162 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
163 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
164 | case OBJ_Line: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
165 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
166 | LDLine* line = new LDLine; |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
167 | 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
|
168 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
169 | APPLY_COORDS (line, 2) |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
170 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
171 | g_CurrentFile->addObject (line); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
172 | window->refresh (); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
173 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
174 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
175 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
176 | case OBJ_Triangle: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
177 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
178 | LDTriangle* tri = new LDTriangle; |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
179 | 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
|
180 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
181 | APPLY_COORDS (tri, 3) |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
182 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
183 | g_CurrentFile->addObject (tri); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
184 | window->refresh (); |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | } |
40
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_Quad: |
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 | LDQuad* quad = new LDQuad; |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
191 | 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
|
192 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
193 | APPLY_COORDS (quad, 4) |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
194 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
195 | g_CurrentFile->addObject (quad); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
196 | window->refresh (); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
197 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
198 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
199 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
200 | case OBJ_CondLine: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
201 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
202 | LDCondLine* line = new LDCondLine; |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
203 | 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
|
204 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
205 | APPLY_COORDS (line, 4) |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
206 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
207 | g_CurrentFile->addObject (line); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
208 | window->refresh (); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
209 | } |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
210 | break; |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
211 | |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
212 | case OBJ_Vertex: |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
213 | { |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
214 | LDVertex* vert = new LDVertex; |
51
94c434a56961
Added color selectors for the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
215 | vert->dColor = dlg.dColor; |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
216 | 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
|
217 | 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
|
218 | vert->vPosition.z = dlg.qaCoordinates[2]->value (); |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
219 | |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
220 | g_CurrentFile->addObject (vert); |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
221 | window->refresh (); |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
222 | } |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
223 | break; |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
224 | |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | default: |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | break; |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | } |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | } |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | } |