src/primitives.cc

changeset 840
d077dd19bf9a
parent 806
4240f47aa2d4
child 844
11587d419d2f
equal deleted inserted replaced
839:5f822ad61875 840:d077dd19bf9a
304 int colon; 304 int colon;
305 305
306 if (line.endsWith ("\n")) 306 if (line.endsWith ("\n"))
307 line.chop (1); 307 line.chop (1);
308 308
309 if (line.length() == 0 || line[0] == '#') 309 if (line.length() == 0 or line[0] == '#')
310 continue; 310 continue;
311 311
312 if ((colon = line.indexOf (":")) == -1) 312 if ((colon = line.indexOf (":")) == -1)
313 { 313 {
314 if (cat && cat->isValidToInclude()) 314 if (cat and cat->isValidToInclude())
315 g_PrimitiveCategories << cat; 315 g_PrimitiveCategories << cat;
316 316
317 cat = new PrimitiveCategory (line); 317 cat = new PrimitiveCategory (line);
318 } 318 }
319 elif (cat != null) 319 elif (cat != null)
473 if (type == Cylinder) 473 if (type == Cylinder)
474 quad->invert(); 474 quad->invert();
475 475
476 objs << quad; 476 objs << quad;
477 477
478 if (type == Cylinder || type == Cone) 478 if (type == Cylinder or type == Cone)
479 condLineSegs << i; 479 condLineSegs << i;
480 } break; 480 } break;
481 481
482 case Disc: 482 case Disc:
483 case DiscNeg: 483 case DiscNeg:
508 } 508 }
509 } 509 }
510 510
511 // If this is not a full circle, we need a conditional line at the other 511 // If this is not a full circle, we need a conditional line at the other
512 // end, too. 512 // end, too.
513 if (segs < divs && condLineSegs.size() != 0) 513 if (segs < divs and condLineSegs.size() != 0)
514 condLineSegs << segs; 514 condLineSegs << segs;
515 515
516 for (int i : condLineSegs) 516 for (int i : condLineSegs)
517 { 517 {
518 Vertex v0 (radialPoint (i, divs, cos), 0.0f, radialPoint (i, divs, sin)), 518 Vertex v0 (radialPoint (i, divs, cos), 0.0f, radialPoint (i, divs, sin)),
575 575
576 // Compose some general information: prefix, fraction, root, ring number 576 // Compose some general information: prefix, fraction, root, ring number
577 QString prefix = (divs == g_lores) ? "" : format ("%1/", divs); 577 QString prefix = (divs == g_lores) ? "" : format ("%1/", divs);
578 QString frac = format ("%1-%2", numer, denom); 578 QString frac = format ("%1-%2", numer, denom);
579 QString root = g_radialNameRoots[type]; 579 QString root = g_radialNameRoots[type];
580 QString numstr = (type == Ring || type == Cone) ? format ("%1", num) : ""; 580 QString numstr = (type == Ring or type == Cone) ? format ("%1", num) : "";
581 581
582 // Truncate the root if necessary (7-16rin4.dat for instance). 582 // Truncate the root if necessary (7-16rin4.dat for instance).
583 // However, always keep the root at least 2 characters. 583 // However, always keep the root at least 2 characters.
584 int extra = (frac.length() + numstr.length() + root.length()) - 8; 584 int extra = (frac.length() + numstr.length() + root.length()) - 8;
585 root.chop (clamp (extra, 0, 2)); 585 root.chop (clamp (extra, 0, 2));
599 599
600 // Ensure that there's decimals, even if they're 0. 600 // Ensure that there's decimals, even if they're 0.
601 if (frac.indexOf (".") == -1) 601 if (frac.indexOf (".") == -1)
602 frac += ".0"; 602 frac += ".0";
603 603
604 if (type == Ring || type == Cone) 604 if (type == Ring or type == Cone)
605 { 605 {
606 QString spacing = 606 QString spacing =
607 (num < 10) ? " " : 607 (num < 10) ? " " :
608 (num < 100) ? " " : ""; 608 (num < 100) ? " " : "";
609 609
680 { 680 {
681 ui->sb_segs->setMaximum (on ? g_hires : g_lores); 681 ui->sb_segs->setMaximum (on ? g_hires : g_lores);
682 682
683 // If the current value is 16 and we switch to hi-res, default the 683 // If the current value is 16 and we switch to hi-res, default the
684 // spinbox to 48. 684 // spinbox to 48.
685 if (on && ui->sb_segs->value() == g_lores) 685 if (on and ui->sb_segs->value() == g_lores)
686 ui->sb_segs->setValue (g_hires); 686 ui->sb_segs->setValue (g_hires);
687 } 687 }
688 688
689 // ============================================================================= 689 // =============================================================================
690 // 690 //

mercurial