src/primitives.cpp

changeset 1346
c4cb7dc850aa
parent 1345
1e345ed80a1d
child 1347
7dd217202126
equal deleted inserted replaced
1345:1e345ed80a1d 1346:c4cb7dc850aa
321 Vertex v0 = {x0, y0, z0}; 321 Vertex v0 = {x0, y0, z0};
322 Vertex v1 = {x1, y1, z1}; 322 Vertex v1 = {x1, y1, z1};
323 Vertex v2 = {x2, y2, z2}; 323 Vertex v2 = {x2, y2, z2};
324 Vertex v3 = {x3, y3, z3}; 324 Vertex v3 = {x3, y3, z3};
325 325
326 if (type == Cylinder) 326 if (type == Cylinder || type == Ring)
327 qSwap(v1, v3); 327 qSwap(v1, v3);
328 328
329 LDQuadrilateral* quad = model.emplace<LDQuadrilateral>(v0, v1, v2, v3); 329 LDQuadrilateral* quad = model.emplace<LDQuadrilateral>(v0, v1, v2, v3);
330 quad->setColor(MainColor); 330 quad->setColor(MainColor);
331 331
371 conditionalLineSegments << segments; 371 conditionalLineSegments << segments;
372 372
373 for (int i : conditionalLineSegments) 373 for (int i : conditionalLineSegments)
374 { 374 {
375 QPointF p0 = ::pointOnLDrawCircumference(i, divisions); 375 QPointF p0 = ::pointOnLDrawCircumference(i, divisions);
376 QPointF p2 = ::pointOnLDrawCircumference(i + 1, divisions); 376 QPointF p2 = ::pointOnLDrawCircumference(i - 1, divisions);
377 QPointF p3 = ::pointOnLDrawCircumference(i - 1, divisions); 377 QPointF p3 = ::pointOnLDrawCircumference(i + 1, divisions);
378 Vertex v0 = {p0.x(), 0.0, p0.y()}; 378 Vertex v0 = {p0.x(), 0.0, p0.y()};
379 Vertex v1; 379 Vertex v1;
380 Vertex v2 = {p2.x(), 0.0, p2.y()}; 380 Vertex v2 = {p2.x(), 0.0, p2.y()};
381 Vertex v3 = {p3.x(), 0.0, p3.y()}; 381 Vertex v3 = {p3.x(), 0.0, p3.y()};
382 382
386 } 386 }
387 else if (type == Cone) 387 else if (type == Cone)
388 { 388 {
389 v1 = {v0.x * (ringNumber + 1), 0.0, v0.z * (ringNumber + 1)}; 389 v1 = {v0.x * (ringNumber + 1), 0.0, v0.z * (ringNumber + 1)};
390 v0 = {v0.x * ringNumber, 1.0, v0.z * ringNumber}; 390 v0 = {v0.x * ringNumber, 1.0, v0.z * ringNumber};
391 v2 *= ringNumber;
392 v3 *= ringNumber;
393 v2.y = v3.y = 1.0;
391 } 394 }
392 395
393 LDConditionalEdge* line = model.emplace<LDConditionalEdge>(); 396 LDConditionalEdge* line = model.emplace<LDConditionalEdge>();
394 line->setColor(EdgeColor); 397 line->setColor(EdgeColor);
395 line->setVertex(0, v0); 398 line->setVertex(0, v0);
464 if (fraction.indexOf(".") == -1) 467 if (fraction.indexOf(".") == -1)
465 fraction += ".0"; 468 fraction += ".0";
466 469
467 if (spec.type == PrimitiveModel::Ring or spec.type == PrimitiveModel::Cone) 470 if (spec.type == PrimitiveModel::Ring or spec.type == PrimitiveModel::Cone)
468 { 471 {
469 QString spacing = 472 QString spacing = (spec.ringNumber < 10) ? " " : "";
470 (spec.ringNumber < 10) ? " " :
471 (spec.ringNumber < 100) ? " " : "";
472 description = format("%1 %2%3 x %4", PrimitiveModel::typeName(spec.type), spacing, spec.ringNumber, fraction); 473 description = format("%1 %2%3 x %4", PrimitiveModel::typeName(spec.type), spacing, spec.ringNumber, fraction);
473 } 474 }
474 else 475 else
476 {
475 description = format("%1 %2", PrimitiveModel::typeName(spec.type), fraction); 477 description = format("%1 %2", PrimitiveModel::typeName(spec.type), fraction);
478 }
476 479
477 // Prepend "Hi-Res" or "Lo-Res" as appropriate. 480 // Prepend "Hi-Res" or "Lo-Res" as appropriate.
478 if (spec.divisions == HighResolution) 481 if (spec.divisions == HighResolution)
479 description.insert (0, "Hi-Res "); 482 description.insert (0, "Hi-Res ");
480 else if (spec.divisions == LowResolution) 483 else if (spec.divisions == LowResolution)

mercurial