src/gldraw.cc

changeset 560
39085791128f
parent 557
04e140bdeb0b
child 564
79b23e02dcf1
equal deleted inserted replaced
559:5a31f6c14451 560:39085791128f
856 void GLRenderer::compileList (LDObject* obj, const GLRenderer::ListType list) 856 void GLRenderer::compileList (LDObject* obj, const GLRenderer::ListType list)
857 { setObjectColor (obj, list); 857 { setObjectColor (obj, list);
858 858
859 switch (obj->getType()) 859 switch (obj->getType())
860 { case LDObject::Line: 860 { case LDObject::Line:
861 compileSubObject (obj, GL_LINES); 861 { compileSubObject (obj, GL_LINES);
862 break; 862 } break;
863 863
864 case LDObject::CondLine: 864 case LDObject::CondLine:
865 865 { // Draw conditional lines with a dash pattern - however, use a full
866 // Draw conditional lines with a dash pattern - however, use a full
867 // line when drawing a pick list to make selecting them easier. 866 // line when drawing a pick list to make selecting them easier.
868 if (list != GL::PickList) 867 if (list != GL::PickList)
869 { glLineStipple (1, 0x6666); 868 { glLineStipple (1, 0x6666);
870 glEnable (GL_LINE_STIPPLE); 869 glEnable (GL_LINE_STIPPLE);
871 } 870 }
872 871
873 compileSubObject (obj, GL_LINES); 872 compileSubObject (obj, GL_LINES);
874 873
875 glDisable (GL_LINE_STIPPLE); 874 glDisable (GL_LINE_STIPPLE);
876 break; 875 } break;
877 876
878 case LDObject::Triangle: 877 case LDObject::Triangle:
879 compileSubObject (obj, GL_TRIANGLES); 878 { compileSubObject (obj, GL_TRIANGLES);
880 break; 879 } break;
881 880
882 case LDObject::Quad: 881 case LDObject::Quad:
883 compileSubObject (obj, GL_QUADS); 882 { compileSubObject (obj, GL_QUADS);
884 break; 883 } break;
885 884
886 case LDObject::Subfile: 885 case LDObject::Subfile:
887 { LDSubfile* ref = static_cast<LDSubfile*> (obj); 886 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
888 QList<LDObject*> objs; 887 QList<LDObject*> objs;
889 888
899 LDObject* prev = ref->prev(); 898 LDObject* prev = ref->prev();
900 899
901 if (prev && prev->getType() == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) 900 if (prev && prev->getType() == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext)
902 g_glInvert = !g_glInvert; 901 g_glInvert = !g_glInvert;
903 902
904 for (LDObject * obj : objs) 903 for (LDObject* obj : objs)
905 { compileList (obj, list); 904 { compileList (obj, list);
906 delete obj; 905 obj->deleteSelf();
907 } 906 }
908 907
909 g_glInvert = oldinvert; 908 g_glInvert = oldinvert;
910 } 909 } break;
911 break;
912 910
913 default: 911 default:
914 break; 912 break;
915 } 913 }
916 } 914 }
1248 pixelptr += 4; 1246 pixelptr += 4;
1249 1247
1250 if (idx == 0xFFFFFF) 1248 if (idx == 0xFFFFFF)
1251 continue; // White is background; skip 1249 continue; // White is background; skip
1252 1250
1251 dlog ("idx: %1", idx);
1253 LDObject* obj = LDObject::fromID (idx); 1252 LDObject* obj = LDObject::fromID (idx);
1254 1253
1255 // If this is an additive single pick and the object is currently selected, 1254 // If this is an additive single pick and the object is currently selected,
1256 // we remove it from selection instead. 1255 // we remove it from selection instead.
1257 if (!m_rangepick && m_addpick) 1256 if (!m_rangepick && m_addpick)
1555 { LDSubfile* ref = static_cast<LDSubfile*> (obj); 1554 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
1556 QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline); 1555 QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline);
1557 1556
1558 for (LDObject* obj : objs) 1557 for (LDObject* obj : objs)
1559 { verts << getVertices (obj); 1558 { verts << getVertices (obj);
1560 delete obj; 1559 obj->deleteSelf();
1561 } 1560 }
1562 } 1561 }
1563 1562
1564 return verts; 1563 return verts;
1565 } 1564 }
1585 // Mark in known vertices of this object 1584 // Mark in known vertices of this object
1586 QList<vertex> verts = getVertices (obj); 1585 QList<vertex> verts = getVertices (obj);
1587 m_knownVerts << verts; 1586 m_knownVerts << verts;
1588 removeDuplicates (m_knownVerts); 1587 removeDuplicates (m_knownVerts);
1589 1588
1590 obj->m_glinit = true; 1589 obj->setGLInit (true);
1591 } 1590 }
1592 1591
1593 // ============================================================================= 1592 // =============================================================================
1594 // ----------------------------------------------------------------------------- 1593 // -----------------------------------------------------------------------------
1595 uchar* GLRenderer::getScreencap (int& w, int& h) 1594 uchar* GLRenderer::getScreencap (int& w, int& h)
1625 1624
1626 // ============================================================================= 1625 // =============================================================================
1627 // ----------------------------------------------------------------------------- 1626 // -----------------------------------------------------------------------------
1628 void GLRenderer::deleteLists (LDObject* obj) 1627 void GLRenderer::deleteLists (LDObject* obj)
1629 { // Delete the lists but only if they have been initialized 1628 { // Delete the lists but only if they have been initialized
1630 if (!obj->m_glinit) 1629 if (!obj->isGLInit())
1631 return; 1630 return;
1632 1631
1633 for (const GL::ListType listType : g_glListTypes) 1632 for (const GL::ListType listType : g_glListTypes)
1634 glDeleteLists (obj->glLists[listType], 1); 1633 glDeleteLists (obj->glLists[listType], 1);
1635 1634
1636 obj->m_glinit = false; 1635 obj->setGLInit (false);
1637 } 1636 }
1638 1637
1639 // ============================================================================= 1638 // =============================================================================
1640 // ----------------------------------------------------------------------------- 1639 // -----------------------------------------------------------------------------
1641 Axis GLRenderer::getCameraAxis (bool y, GLRenderer::EFixedCamera camid) 1640 Axis GLRenderer::getCameraAxis (bool y, GLRenderer::EFixedCamera camid)
1888 // ============================================================================= 1887 // =============================================================================
1889 // ----------------------------------------------------------------------------- 1888 // -----------------------------------------------------------------------------
1890 LDOverlay* GLRenderer::findOverlayObject (EFixedCamera cam) 1889 LDOverlay* GLRenderer::findOverlayObject (EFixedCamera cam)
1891 { LDOverlay* ovlobj = null; 1890 { LDOverlay* ovlobj = null;
1892 1891
1893 for (LDObject * obj : getFile()->getObjects()) 1892 for (LDObject* obj : getFile()->getObjects())
1894 { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) 1893 { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->getCamera() == cam)
1895 { ovlobj = static_cast<LDOverlay*> (obj); 1894 { ovlobj = static_cast<LDOverlay*> (obj);
1896 break; 1895 break;
1897 } 1896 }
1898 } 1897 }
1934 if (!meta.img && ovlobj) 1933 if (!meta.img && ovlobj)
1935 { // If this is the last overlay image, we need to remove the empty space after it as well. 1934 { // If this is the last overlay image, we need to remove the empty space after it as well.
1936 LDObject* nextobj = ovlobj->next(); 1935 LDObject* nextobj = ovlobj->next();
1937 1936
1938 if (nextobj && nextobj->getType() == LDObject::Empty) 1937 if (nextobj && nextobj->getType() == LDObject::Empty)
1939 { getFile()->forgetObject (nextobj); 1938 nextobj->deleteSelf();
1940 delete nextobj;
1941 }
1942 1939
1943 // If the overlay object was there and the overlay itself is 1940 // If the overlay object was there and the overlay itself is
1944 // not, remove the object. 1941 // not, remove the object.
1945 getFile()->forgetObject (ovlobj); 1942 ovlobj->deleteSelf();
1946 delete ovlobj;
1947 } elif (meta.img && !ovlobj) 1943 } elif (meta.img && !ovlobj)
1948 { // Inverse case: image is there but the overlay object is 1944 { // Inverse case: image is there but the overlay object is
1949 // not, thus create the object. 1945 // not, thus create the object.
1950 ovlobj = new LDOverlay; 1946 ovlobj = new LDOverlay;
1951 1947

mercurial