src/addObjectDialog.cc

changeset 733
cc39df788660
parent 662
2f1bd9112408
child 739
152b33a6d51b
equal deleted inserted replaced
732:220cda74d6b7 733:cc39df788660
190 { 190 {
191 case LDObject::ELine: 191 case LDObject::ELine:
192 case LDObject::ECondLine: 192 case LDObject::ECondLine:
193 case LDObject::ETriangle: 193 case LDObject::ETriangle:
194 case LDObject::EQuad: 194 case LDObject::EQuad:
195
196 // Apply coordinates 195 // Apply coordinates
197 if (obj) 196 if (obj != null)
198 { 197 {
199 for (int i = 0; i < coordCount / 3; ++i) 198 for (int i = 0; i < coordCount / 3; ++i)
200 for (int j = 0; j < 3; ++j) 199 {
201 dsb_coords[ (i * 3) + j]->setValue (obj->vertex (i).getCoordinate (j)); 200 obj->vertex (i).apply ([&](Axis ax, double value)
202 } 201 {
203 202 dsb_coords[(i * 3) + ax]->setValue (value);
203 });
204 }
205 }
204 break; 206 break;
205 207
206 case LDObject::EComment: 208 case LDObject::EComment:
207 layout->addWidget (le_comment, 0, 1); 209 layout->addWidget (le_comment, 0, 1);
208 break; 210 break;
228 QLabel* lb_matrix = new QLabel ("Matrix:"); 230 QLabel* lb_matrix = new QLabel ("Matrix:");
229 le_matrix = new QLineEdit; 231 le_matrix = new QLineEdit;
230 // le_matrix->setValidator (new QDoubleValidator); 232 // le_matrix->setValidator (new QDoubleValidator);
231 Matrix defaultMatrix = g_identity; 233 Matrix defaultMatrix = g_identity;
232 234
233 if (mo) 235 if (mo != null)
234 { 236 {
235 for_axes (ax) 237 mo->position().apply ([&](Axis ax, double value)
236 dsb_coords[ax]->setValue (mo->position()[ax]); 238 {
239 dsb_coords[ax]->setValue (value);
240 });
237 241
238 defaultMatrix = mo->transform(); 242 defaultMatrix = mo->transform();
239 } 243 }
240 244
241 le_matrix->setText (defaultMatrix.toString()); 245 le_matrix->setText (defaultMatrix.toString());
378 382
379 for (int i = 0; i < obj->vertices(); ++i) 383 for (int i = 0; i < obj->vertices(); ++i)
380 { 384 {
381 Vertex v; 385 Vertex v;
382 386
383 for_axes (ax) 387 v.apply ([&](Axis ax, double& value)
384 v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); 388 {
389 value = dlg.dsb_coords[(i * 3) + ax]->value();
390 });
385 391
386 obj->setVertex (i, v); 392 obj->setVertex (i, v);
387 } 393 }
388 } break; 394 } break;
389 395
394 } break; 400 } break;
395 401
396 case LDObject::EVertex: 402 case LDObject::EVertex:
397 { 403 {
398 LDVertex* vert = initObj<LDVertex> (obj); 404 LDVertex* vert = initObj<LDVertex> (obj);
399 405 vert->pos.apply ([&](Axis ax, double& value) { value = dlg.dsb_coords[ax]->value(); });
400 for_axes (ax)
401 vert->pos[ax] = dlg.dsb_coords[ax]->value();
402 } 406 }
403 break; 407 break;
404 408
405 case LDObject::ESubfile: 409 case LDObject::ESubfile:
406 { 410 {

mercurial