454 if (col == null) |
454 if (col == null) |
455 return; |
455 return; |
456 |
456 |
457 short newColor = col->index; |
457 short newColor = col->index; |
458 |
458 |
459 for (LDObject * obj : m_sel) |
459 for (LDObject * obj : m_sel) |
460 { if (obj->isColored() == false) |
460 { if (obj->isColored() == false) |
461 continue; // uncolored object |
461 continue; // uncolored object |
462 |
462 |
463 obj->setColor (newColor); |
463 obj->setColor (newColor); |
464 R()->compileObject (obj); |
464 R()->compileObject (obj); |
468 endAction(); |
468 endAction(); |
469 } |
469 } |
470 |
470 |
471 // ============================================================================= |
471 // ============================================================================= |
472 // ----------------------------------------------------------------------------- |
472 // ----------------------------------------------------------------------------- |
473 ulong ForgeWindow::getInsertionPoint() |
473 int ForgeWindow::getInsertionPoint() |
474 { if (m_sel.size() > 0) |
474 { if (m_sel.size() > 0) |
475 { // If we have a selection, put the item after it. |
475 { // If we have a selection, put the item after it. |
476 return (m_sel[m_sel.size() - 1]->getIndex()) + 1; |
476 return (m_sel[m_sel.size() - 1]->getIndex()) + 1; |
477 } |
477 } |
478 |
478 |
663 AddObjectDialog::staticDialog (obj->getType(), obj); |
663 AddObjectDialog::staticDialog (obj->getType(), obj); |
664 } |
664 } |
665 |
665 |
666 // ============================================================================= |
666 // ============================================================================= |
667 // ----------------------------------------------------------------------------- |
667 // ----------------------------------------------------------------------------- |
668 void ForgeWindow::primitiveLoaderStart (ulong max) |
668 void ForgeWindow::primitiveLoaderStart (int max) |
669 { m_primLoaderWidget->show(); |
669 { m_primLoaderWidget->show(); |
670 m_primLoaderBar->setRange (0, max); |
670 m_primLoaderBar->setRange (0, max); |
671 m_primLoaderBar->setValue (0); |
671 m_primLoaderBar->setValue (0); |
672 m_primLoaderBar->setFormat ("%p%"); |
672 m_primLoaderBar->setFormat ("%p%"); |
673 } |
673 } |
674 |
674 |
675 // ============================================================================= |
675 // ============================================================================= |
676 // ----------------------------------------------------------------------------- |
676 // ----------------------------------------------------------------------------- |
677 void ForgeWindow::primitiveLoaderUpdate (ulong prog) |
677 void ForgeWindow::primitiveLoaderUpdate (int prog) |
678 { m_primLoaderBar->setValue (prog); |
678 { m_primLoaderBar->setValue (prog); |
679 } |
679 } |
680 |
680 |
681 // ============================================================================= |
681 // ============================================================================= |
682 // ----------------------------------------------------------------------------- |
682 // ----------------------------------------------------------------------------- |
763 { QMessageBox::critical (g_win, ForgeWindow::tr ("Error"), msg, |
763 { QMessageBox::critical (g_win, ForgeWindow::tr ("Error"), msg, |
764 (QMessageBox::Close), QMessageBox::Close); |
764 (QMessageBox::Close), QMessageBox::Close); |
765 } |
765 } |
766 |
766 |
767 // ============================================================================= |
767 // ============================================================================= |
768 QIcon makeColorIcon (LDColor* colinfo, const ushort size) |
768 QIcon makeColorIcon (LDColor* colinfo, const int size) |
769 { // Create an image object and link a painter to it. |
769 { // Create an image object and link a painter to it. |
770 QImage img (size, size, QImage::Format_ARGB32); |
770 QImage img (size, size, QImage::Format_ARGB32); |
771 QPainter paint (&img); |
771 QPainter paint (&img); |
772 |
772 |
773 QColor col = colinfo->faceColor; |
773 QColor col = colinfo->faceColor; |
785 return QIcon (QPixmap::fromImage (img)); |
785 return QIcon (QPixmap::fromImage (img)); |
786 } |
786 } |
787 |
787 |
788 // ============================================================================= |
788 // ============================================================================= |
789 void makeColorSelector (QComboBox* box) |
789 void makeColorSelector (QComboBox* box) |
790 { std::map<short, ulong> counts; |
790 { std::map<int, int> counts; |
791 |
791 |
792 for (LDObject * obj : LDFile::current()->objects()) |
792 for (LDObject * obj : LDFile::current()->objects()) |
793 { if (!obj->isColored()) |
793 { if (!obj->isColored()) |
794 continue; |
794 continue; |
795 |
795 |
796 if (counts.find (obj->color()) == counts.end()) |
796 if (counts.find (obj->color()) == counts.end()) |
797 counts[obj->color()] = 1; |
797 counts[obj->color()] = 1; |
798 else |
798 else |
799 counts[obj->color()]++; |
799 counts[obj->color()]++; |
800 } |
800 } |
801 |
801 |
802 box->clear(); |
802 box->clear(); |
803 ulong row = 0; |
803 int row = 0; |
804 |
804 |
805 for (const auto & pair : counts) |
805 for (const auto & pair : counts) |
806 { LDColor* col = getColor (pair.first); |
806 { LDColor* col = getColor (pair.first); |
807 assert (col != null); |
807 assert (col != null); |
808 |
808 |
809 QIcon ico = makeColorIcon (col, 16); |
809 QIcon ico = makeColorIcon (col, 16); |
810 box->addItem (ico, fmt ("[%1] %2 (%3 object%4)", |
810 box->addItem (ico, fmt ("[%1] %2 (%3 object%4)", |
922 #endif |
922 #endif |
923 |
923 |
924 buildObjList(); |
924 buildObjList(); |
925 } |
925 } |
926 |
926 |
927 QImage imageFromScreencap (uchar* data, ushort w, ushort h) |
927 QImage imageFromScreencap (uchar* data, int w, int h) |
928 { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
928 { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
929 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
929 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
930 } |
930 } |
931 |
931 |
932 // ============================================================================= |
932 // ============================================================================= |