zz_addObjectDialog.cpp

changeset 111
125e8031dbf1
parent 104
6e29bb0e83c5
child 113
bbaa40226ec9
equal deleted inserted replaced
110:a62ab18d1b80 111:125e8031dbf1
45 45
46 switch (type) { 46 switch (type) {
47 case OBJ_Comment: 47 case OBJ_Comment:
48 qCommentLine = new QLineEdit; 48 qCommentLine = new QLineEdit;
49 break; 49 break;
50
50 case OBJ_Line: 51 case OBJ_Line:
51 dCoordCount = 6; 52 dCoordCount = 6;
52 break; 53 break;
54
53 case OBJ_Triangle: 55 case OBJ_Triangle:
54 dCoordCount = 9; 56 dCoordCount = 9;
55 break; 57 break;
58
56 case OBJ_Quad: 59 case OBJ_Quad:
57 case OBJ_CondLine: 60 case OBJ_CondLine:
58 dCoordCount = 12; 61 dCoordCount = 12;
59 break; 62 break;
63
60 case OBJ_Vertex: 64 case OBJ_Vertex:
61 dCoordCount = 3; 65 dCoordCount = 3;
66
67 case OBJ_Radial:
68 dCoordCount = 3;
69
70 qRadialTypeLabel = new QLabel ("Type:");
71 qRadialResolutionLabel = new QLabel ("Resolution:");
72 qRadialSegmentsLabel = new QLabel ("Segments:");
73 qRadialRingNumLabel = new QLabel ("Ring number:");
74
75 qRadialType = new QComboBox;
76
77 for (int i = 0; i < LDRadial::NumTypes; ++i)
78 qRadialType->addItem (g_saRadialTypeNames[i]);
79
80 connect (qRadialType, SIGNAL (currentIndexChanged (int)), this, SLOT (slot_radialTypeChanged (int)));
81
82 qRadialResolution = new QComboBox;
83 qRadialResolution->addItems ({"Normal (16)", "Hi-Res (48)"});
84
85 qRadialSegments = new QSpinBox;
86 qRadialSegments->setMinimum (1);
87
88 qRadialRingNum = new QSpinBox;
89 qRadialRingNum->setEnabled (false);
90 break;
91
62 default: 92 default:
63 break; 93 break;
64 } 94 }
65 95
66 // Show a color edit dialog for the types that actually use the color 96 // Show a color edit dialog for the types that actually use the color
70 case OBJ_Line: 100 case OBJ_Line:
71 case OBJ_Quad: 101 case OBJ_Quad:
72 case OBJ_Triangle: 102 case OBJ_Triangle:
73 case OBJ_Vertex: 103 case OBJ_Vertex:
74 case OBJ_Subfile: 104 case OBJ_Subfile:
105 case OBJ_Radial:
75 bUsesColor = true; 106 bUsesColor = true;
76 break; 107 break;
77 default: 108 default:
78 break; 109 break;
79 } 110 }
100 131
101 switch (type) { 132 switch (type) {
102 case OBJ_Comment: 133 case OBJ_Comment:
103 qLayout->addWidget (qCommentLine, 0, 1); 134 qLayout->addWidget (qCommentLine, 0, 1);
104 break; 135 break;
136
137 case OBJ_Radial:
138 qLayout->addWidget (qRadialTypeLabel, 1, 1);
139 qLayout->addWidget (qRadialType, 1, 2);
140 qLayout->addWidget (qRadialResolutionLabel, 2, 1);
141 qLayout->addWidget (qRadialResolution, 2, 2);
142 qLayout->addWidget (qRadialSegmentsLabel, 3, 1);
143 qLayout->addWidget (qRadialSegments, 3, 2);
144 qLayout->addWidget (qRadialRingNumLabel, 4, 1);
145 qLayout->addWidget (qRadialRingNum, 4, 2);
146 break;
147
105 default: 148 default:
106 break; 149 break;
107 } 150 }
108 151
109 if (bUsesColor) 152 if (bUsesColor)
113 QGridLayout* const qCoordLayout = new QGridLayout; 156 QGridLayout* const qCoordLayout = new QGridLayout;
114 157
115 for (short i = 0; i < dCoordCount; ++i) 158 for (short i = 0; i < dCoordCount; ++i)
116 qCoordLayout->addWidget (qaCoordinates[i], (i / 3), (i % 3)); 159 qCoordLayout->addWidget (qaCoordinates[i], (i / 3), (i % 3));
117 160
118 qLayout->addLayout (qCoordLayout, 0, 1, 2, 1); 161 qLayout->addLayout (qCoordLayout, 0, 1, 2, 2);
119 } 162 }
120 163
121 qLayout->addWidget (qButtons, 2, 1); 164 qLayout->addWidget (qButtons, 5, 1);
122 setLayout (qLayout); 165 setLayout (qLayout);
123 setWindowTitle (str::mkfmt (APPNAME_DISPLAY " - new %s", 166 setWindowTitle (str::mkfmt (APPNAME_DISPLAY " - new %s",
124 g_saObjTypeNames[type]).chars()); 167 g_saObjTypeNames[type]).chars());
125 168
126 setWindowIcon (QIcon (zIconName.chars ())); 169 setWindowIcon (QIcon (zIconName.chars ()));
146 } 189 }
147 190
148 // ============================================================================= 191 // =============================================================================
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
150 // ============================================================================= 193 // =============================================================================
194 void AddObjectDialog::slot_radialTypeChanged (int dType) {
195 LDRadial::Type eType = (LDRadial::Type) dType;
196 qRadialRingNum->setEnabled (eType == LDRadial::Ring || eType == LDRadial::Cone);
197 }
198
199 // =============================================================================
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
201 // =============================================================================
151 void AddObjectDialog::staticDialog (const LDObjectType_e type, ForgeWindow* window) { 202 void AddObjectDialog::staticDialog (const LDObjectType_e type, ForgeWindow* window) {
152 AddObjectDialog dlg (type, window); 203 AddObjectDialog dlg (type, window);
153 LDObject* obj = null; 204 LDObject* obj = null;
154 205
155 if (dlg.exec ()) { 206 if (dlg.exec ()) {
203 vert->vPosition.z = dlg.qaCoordinates[2]->value (); 254 vert->vPosition.z = dlg.qaCoordinates[2]->value ();
204 obj = vert; 255 obj = vert;
205 } 256 }
206 break; 257 break;
207 258
259 case OBJ_Radial:
260 {
261 LDRadial* pRad = new LDRadial;
262 pRad->dColor = dlg.dColor;
263 pRad->vPosition.x = dlg.qaCoordinates[0]->value ();
264 pRad->vPosition.y = dlg.qaCoordinates[1]->value ();
265 pRad->vPosition.z = dlg.qaCoordinates[2]->value ();
266 pRad->dDivisions = (dlg.qRadialResolution->currentIndex () == 0) ? 16 : 48;
267 pRad->dSegments = min<short> (dlg.qRadialSegments->value (), pRad->dDivisions);
268 pRad->eRadialType = (LDRadial::Type) dlg.qRadialType->currentIndex ();
269 pRad->dRingNum = dlg.qRadialRingNum->value ();
270 pRad->mMatrix = g_mIdentity;
271
272 obj = pRad;
273 }
274 break;
275
208 default: 276 default:
209 break; 277 break;
210 } 278 }
211 279
212 ulong idx = g_CurrentFile->addObject (obj); 280 ulong idx = g_CurrentFile->addObject (obj);

mercurial