src/gui.cpp

changeset 188
4e686b771996
parent 187
ee42f4442566
child 189
ac2d3e8dd110
equal deleted inserted replaced
187:ee42f4442566 188:4e686b771996
555 555
556 case LDObject::Line: 556 case LDObject::Line:
557 { 557 {
558 LDLine* line = static_cast<LDLine*> (obj); 558 LDLine* line = static_cast<LDLine*> (obj);
559 descr.format ("%s, %s", 559 descr.format ("%s, %s",
560 line->vaCoords[0].stringRep (true).chars(), 560 line->coords[0].stringRep (true).chars(),
561 line->vaCoords[1].stringRep (true).chars()); 561 line->coords[1].stringRep (true).chars());
562 } 562 }
563 break; 563 break;
564 564
565 case LDObject::Triangle: 565 case LDObject::Triangle:
566 { 566 {
567 LDTriangle* triangle = static_cast<LDTriangle*> (obj); 567 LDTriangle* triangle = static_cast<LDTriangle*> (obj);
568 descr.format ("%s, %s, %s", 568 descr.format ("%s, %s, %s",
569 triangle->vaCoords[0].stringRep (true).chars(), 569 triangle->coords[0].stringRep (true).chars(),
570 triangle->vaCoords[1].stringRep (true).chars(), 570 triangle->coords[1].stringRep (true).chars(),
571 triangle->vaCoords[2].stringRep (true).chars()); 571 triangle->coords[2].stringRep (true).chars());
572 } 572 }
573 break; 573 break;
574 574
575 case LDObject::Quad: 575 case LDObject::Quad:
576 { 576 {
577 LDQuad* quad = static_cast<LDQuad*> (obj); 577 LDQuad* quad = static_cast<LDQuad*> (obj);
578 descr.format ("%s, %s, %s, %s", 578 descr.format ("%s, %s, %s, %s",
579 quad->vaCoords[0].stringRep (true).chars(), 579 quad->coords[0].stringRep (true).chars(),
580 quad->vaCoords[1].stringRep (true).chars(), 580 quad->coords[1].stringRep (true).chars(),
581 quad->vaCoords[2].stringRep (true).chars(), 581 quad->coords[2].stringRep (true).chars(),
582 quad->vaCoords[3].stringRep (true).chars()); 582 quad->coords[3].stringRep (true).chars());
583 } 583 }
584 break; 584 break;
585 585
586 case LDObject::CondLine: 586 case LDObject::CondLine:
587 { 587 {
588 LDCondLine* line = static_cast<LDCondLine*> (obj); 588 LDCondLine* line = static_cast<LDCondLine*> (obj);
589 descr.format ("%s, %s, %s, %s", 589 descr.format ("%s, %s, %s, %s",
590 line->vaCoords[0].stringRep (true).chars(), 590 line->coords[0].stringRep (true).chars(),
591 line->vaCoords[1].stringRep (true).chars(), 591 line->coords[1].stringRep (true).chars(),
592 line->vaCoords[2].stringRep (true).chars(), 592 line->coords[2].stringRep (true).chars(),
593 line->vaCoords[3].stringRep (true).chars()); 593 line->coords[3].stringRep (true).chars());
594 } 594 }
595 break; 595 break;
596 596
597 case LDObject::Gibberish: 597 case LDObject::Gibberish:
598 descr.format ("ERROR: %s", 598 descr.format ("ERROR: %s",
599 static_cast<LDGibberish*> (obj)->zContents.chars()); 599 static_cast<LDGibberish*> (obj)->contents.chars());
600 break; 600 break;
601 601
602 case LDObject::Vertex: 602 case LDObject::Vertex:
603 descr.format ("%s", static_cast<LDVertex*> (obj)->vPosition.stringRep (true).chars()); 603 descr.format ("%s", static_cast<LDVertex*> (obj)->pos.stringRep (true).chars());
604 break; 604 break;
605 605
606 case LDObject::Subfile: 606 case LDObject::Subfile:
607 { 607 {
608 LDSubfile* ref = static_cast<LDSubfile*> (obj); 608 LDSubfile* ref = static_cast<LDSubfile*> (obj);
609 609
610 descr.format ("%s %s, (", 610 descr.format ("%s %s, (",
611 ref->zFileName.chars(), ref->vPosition.stringRep (true).chars()); 611 ref->fileName.chars(), ref->pos.stringRep (true).chars());
612 612
613 for (short i = 0; i < 9; ++i) 613 for (short i = 0; i < 9; ++i)
614 descr.appendformat ("%s%s", 614 descr.appendformat ("%s%s",
615 ftoa (ref->mMatrix[i]).chars(), 615 ftoa (ref->transform[i]).chars(),
616 (i != 8) ? " " : ""); 616 (i != 8) ? " " : "");
617 617
618 descr += ')'; 618 descr += ')';
619 } 619 }
620 break; 620 break;
627 break; 627 break;
628 628
629 case LDObject::Radial: 629 case LDObject::Radial:
630 { 630 {
631 LDRadial* pRad = static_cast<LDRadial*> (obj); 631 LDRadial* pRad = static_cast<LDRadial*> (obj);
632 descr.format ("%d / %d %s", pRad->dSegments, pRad->dDivisions, pRad->radialTypeName()); 632 descr.format ("%d / %d %s", pRad->segs, pRad->divs, pRad->radialTypeName());
633 633
634 if (pRad->eRadialType == LDRadial::Ring || pRad->eRadialType == LDRadial::Cone) 634 if (pRad->radType == LDRadial::Ring || pRad->radType == LDRadial::Cone)
635 descr.appendformat (" %d", pRad->dRingNum); 635 descr.appendformat (" %d", pRad->ringNum);
636 636
637 descr.appendformat (" %s", pRad->vPosition.stringRep (true).chars ()); 637 descr.appendformat (" %s", pRad->pos.stringRep (true).chars ());
638 } 638 }
639 break; 639 break;
640 640
641 default: 641 default:
642 descr = g_saObjTypeNames[obj->getType ()]; 642 descr = g_saObjTypeNames[obj->getType ()];
655 // Color gibberish orange on red so it stands out. 655 // Color gibberish orange on red so it stands out.
656 if (obj->getType() == LDObject::Gibberish) { 656 if (obj->getType() == LDObject::Gibberish) {
657 item->setBackground (QColor ("#AA0000")); 657 item->setBackground (QColor ("#AA0000"));
658 item->setForeground (QColor ("#FFAA00")); 658 item->setForeground (QColor ("#FFAA00"));
659 } else if (lv_colorize && obj->isColored () && 659 } else if (lv_colorize && obj->isColored () &&
660 obj->dColor != maincolor && obj->dColor != edgecolor) 660 obj->color != maincolor && obj->color != edgecolor)
661 { 661 {
662 // If the object isn't in the main or edge color, draw this 662 // If the object isn't in the main or edge color, draw this
663 // list entry in said color. 663 // list entry in said color.
664 color* col = getColor (obj->dColor); 664 color* col = getColor (obj->color);
665 if (col) 665 if (col)
666 item->setForeground (col->qColor); 666 item->setForeground (col->qColor);
667 } 667 }
668 668
669 obj->qObjListEntry = item; 669 obj->qObjListEntry = item;
757 std::vector<ulong> indices; 757 std::vector<ulong> indices;
758 std::vector<short> colors; 758 std::vector<short> colors;
759 short newColor = col->index (); 759 short newColor = col->index ();
760 760
761 for (LDObject* obj : m_sel) { 761 for (LDObject* obj : m_sel) {
762 if (obj->dColor == -1) 762 if (obj->color == -1)
763 continue; // uncolored object 763 continue; // uncolored object
764 764
765 indices.push_back (obj->getIndex (g_curfile)); 765 indices.push_back (obj->getIndex (g_curfile));
766 colors.push_back (obj->dColor); 766 colors.push_back (obj->color);
767 767
768 obj->dColor = newColor; 768 obj->color = newColor;
769 } 769 }
770 770
771 History::addEntry (new SetColorHistory (indices, colors, newColor)); 771 History::addEntry (new SetColorHistory (indices, colors, newColor));
772 refresh (); 772 refresh ();
773 } 773 }
830 830
831 short ForgeWindow::getSelectedColor() { 831 short ForgeWindow::getSelectedColor() {
832 short result = -1; 832 short result = -1;
833 833
834 for (LDObject* obj : m_sel) { 834 for (LDObject* obj : m_sel) {
835 if (obj->dColor == -1) 835 if (obj->color == -1)
836 continue; // doesn't use color 836 continue; // doesn't use color
837 837
838 if (result != -1 && obj->dColor != result) 838 if (result != -1 && obj->color != result)
839 return -1; // No consensus in object color 839 return -1; // No consensus in object color
840 840
841 if (result == -1) 841 if (result == -1)
842 result = obj->dColor; 842 result = obj->color;
843 } 843 }
844 844
845 return result; 845 return result;
846 } 846 }
847 847
850 // ============================================================================= 850 // =============================================================================
851 LDObject::Type ForgeWindow::uniformSelectedType () { 851 LDObject::Type ForgeWindow::uniformSelectedType () {
852 LDObject::Type eResult = LDObject::Unidentified; 852 LDObject::Type eResult = LDObject::Unidentified;
853 853
854 for (LDObject* obj : m_sel) { 854 for (LDObject* obj : m_sel) {
855 if (eResult != LDObject::Unidentified && obj->dColor != eResult) 855 if (eResult != LDObject::Unidentified && obj->color != eResult)
856 return LDObject::Unidentified; 856 return LDObject::Unidentified;
857 857
858 if (eResult == LDObject::Unidentified) 858 if (eResult == LDObject::Unidentified)
859 eResult = obj->getType (); 859 eResult = obj->getType ();
860 } 860 }
934 934
935 // ======================================================================================================================================== 935 // ========================================================================================================================================
936 DelHistory* ForgeWindow::deleteByColor (const short colnum) { 936 DelHistory* ForgeWindow::deleteByColor (const short colnum) {
937 vector<LDObject*> objs; 937 vector<LDObject*> objs;
938 for (LDObject* obj : g_curfile->m_objs) { 938 for (LDObject* obj : g_curfile->m_objs) {
939 if (!obj->isColored () || obj->dColor != colnum) 939 if (!obj->isColored () || obj->color != colnum)
940 continue; 940 continue;
941 941
942 objs.push_back (obj); 942 objs.push_back (obj);
943 } 943 }
944 944
1023 1023
1024 for (LDObject* obj : g_curfile->m_objs) { 1024 for (LDObject* obj : g_curfile->m_objs) {
1025 if (!obj->isColored ()) 1025 if (!obj->isColored ())
1026 continue; 1026 continue;
1027 1027
1028 if (counts.find (obj->dColor) == counts.end ()) 1028 if (counts.find (obj->color) == counts.end ())
1029 counts[obj->dColor] = 1; 1029 counts[obj->color] = 1;
1030 else 1030 else
1031 counts[obj->dColor]++; 1031 counts[obj->color]++;
1032 } 1032 }
1033 1033
1034 box->clear (); 1034 box->clear ();
1035 ulong row = 0; 1035 ulong row = 0;
1036 for (const auto& pair : counts) { 1036 for (const auto& pair : counts) {

mercurial