src/gldraw.cpp

changeset 460
b230ae09c8e5
parent 458
cb360f4d8979
child 461
fbcc91ae1dd2
equal deleted inserted replaced
459:51cca3ce540d 460:b230ae09c8e5
252 return; 252 return;
253 } 253 }
254 254
255 if ((list == BFCFrontList || list == BFCBackList) && 255 if ((list == BFCFrontList || list == BFCBackList) &&
256 obj->getType() != LDObject::Line && 256 obj->getType() != LDObject::Line &&
257 obj->getType() != LDObject::CondLine) { 257 obj->getType() != LDObject::CndLine) {
258 258
259 if (list == GL::BFCFrontList) 259 if (list == GL::BFCFrontList)
260 qcol = QColor (40, 192, 0); 260 qcol = QColor (40, 192, 0);
261 else 261 else
262 qcol = QColor (224, 0, 0); 262 qcol = QColor (224, 0, 0);
706 // ============================================================================= 706 // =============================================================================
707 // ----------------------------------------------------------------------------- 707 // -----------------------------------------------------------------------------
708 void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) { 708 void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) {
709 glBegin (gltype); 709 glBegin (gltype);
710 710
711 const short numverts = (obj->getType() != LDObject::CondLine) ? obj->vertices() : 2; 711 const short numverts = (obj->getType() != LDObject::CndLine) ? obj->vertices() : 2;
712 712
713 if (g_glInvert == false) 713 if (g_glInvert == false)
714 for (short i = 0; i < numverts; ++i) 714 for (short i = 0; i < numverts; ++i)
715 compileVertex (obj->m_coords[i]); 715 compileVertex (obj->m_coords[i]);
716 else 716 else
728 switch (obj->getType()) { 728 switch (obj->getType()) {
729 case LDObject::Line: 729 case LDObject::Line:
730 compileSubObject (obj, GL_LINES); 730 compileSubObject (obj, GL_LINES);
731 break; 731 break;
732 732
733 case LDObject::CondLine: 733 case LDObject::CndLine:
734 // Draw conditional lines with a dash pattern - however, use a full 734 // Draw conditional lines with a dash pattern - however, use a full
735 // line when drawing a pick list to make selecting them easier. 735 // line when drawing a pick list to make selecting them easier.
736 if (list != GL::PickList) { 736 if (list != GL::PickList) {
737 glLineStipple (1, 0x6666); 737 glLineStipple (1, 0x6666);
738 glEnable (GL_LINE_STIPPLE); 738 glEnable (GL_LINE_STIPPLE);
750 case LDObject::Quad: 750 case LDObject::Quad:
751 compileSubObject (obj, GL_QUADS); 751 compileSubObject (obj, GL_QUADS);
752 break; 752 break;
753 753
754 case LDObject::Subfile: { 754 case LDObject::Subfile: {
755 LDSubfileObject* ref = static_cast<LDSubfileObject*> (obj); 755 LDSubfile* ref = static_cast<LDSubfile*> (obj);
756 List<LDObject*> objs; 756 List<LDObject*> objs;
757 757
758 objs = ref->inlineContents ( 758 objs = ref->inlineContents (
759 LDSubfileObject::DeepInline | 759 LDSubfile::DeepInline |
760 LDSubfileObject::CacheInline | 760 LDSubfile::CacheInline |
761 LDSubfileObject::RendererInline); 761 LDSubfile::RendererInline);
762 bool oldinvert = g_glInvert; 762 bool oldinvert = g_glInvert;
763 763
764 if (ref->transform().determinant() < 0) 764 if (ref->transform().determinant() < 0)
765 g_glInvert = !g_glInvert; 765 g_glInvert = !g_glInvert;
766 766
767 LDObject* prev = ref->prev(); 767 LDObject* prev = ref->prev();
768 if (prev && prev->getType() == LDObject::BFC && static_cast<LDBFCObject*> (prev)->type == LDBFCObject::InvertNext) 768 if (prev && prev->getType() == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext)
769 g_glInvert = !g_glInvert; 769 g_glInvert = !g_glInvert;
770 770
771 for (LDObject* obj : objs) { 771 for (LDObject* obj : objs) {
772 compileList (obj, list); 772 compileList (obj, list);
773 delete obj; 773 delete obj;
1221 // Clean the selection and create the object 1221 // Clean the selection and create the object
1222 List<vertex>& verts = m_drawedVerts; 1222 List<vertex>& verts = m_drawedVerts;
1223 LDObject* obj = null; 1223 LDObject* obj = null;
1224 1224
1225 if (m_rectdraw) { 1225 if (m_rectdraw) {
1226 LDQuadObject* quad = new LDQuadObject; 1226 LDQuad* quad = new LDQuad;
1227 1227
1228 // Copy the vertices from m_rectverts 1228 // Copy the vertices from m_rectverts
1229 updateRectVerts(); 1229 updateRectVerts();
1230 1230
1231 for (int i = 0; i < quad->vertices(); ++i) 1231 for (int i = 0; i < quad->vertices(); ++i)
1235 obj = quad; 1235 obj = quad;
1236 } else { 1236 } else {
1237 switch (verts.size()) { 1237 switch (verts.size()) {
1238 case 1: 1238 case 1:
1239 // 1 vertex - add a vertex object 1239 // 1 vertex - add a vertex object
1240 obj = new LDVertexObject; 1240 obj = new LDVertex;
1241 static_cast<LDVertexObject*> (obj)->pos = verts[0]; 1241 static_cast<LDVertex*> (obj)->pos = verts[0];
1242 obj->setColor (maincolor); 1242 obj->setColor (maincolor);
1243 break; 1243 break;
1244 1244
1245 case 2: 1245 case 2:
1246 // 2 verts - make a line 1246 // 2 verts - make a line
1247 obj = new LDLineObject (verts[0], verts[1]); 1247 obj = new LDLine (verts[0], verts[1]);
1248 obj->setColor (edgecolor); 1248 obj->setColor (edgecolor);
1249 break; 1249 break;
1250 1250
1251 case 3: 1251 case 3:
1252 case 4: 1252 case 4:
1253 obj = (verts.size() == 3) ? 1253 obj = (verts.size() == 3) ?
1254 static_cast<LDObject*> (new LDTriangleObject) : 1254 static_cast<LDObject*> (new LDTriangle) :
1255 static_cast<LDObject*> (new LDQuadObject); 1255 static_cast<LDObject*> (new LDQuad);
1256 1256
1257 obj->setColor (maincolor); 1257 obj->setColor (maincolor);
1258 for (ushort i = 0; i < obj->vertices(); ++i) 1258 for (ushort i = 0; i < obj->vertices(); ++i)
1259 obj->setVertex (i, verts[i]); 1259 obj->setVertex (i, verts[i]);
1260 break; 1260 break;
1280 1280
1281 if (obj->vertices() >= 2) { 1281 if (obj->vertices() >= 2) {
1282 for (int i = 0; i < obj->vertices(); ++i) 1282 for (int i = 0; i < obj->vertices(); ++i)
1283 verts << obj->getVertex (i); 1283 verts << obj->getVertex (i);
1284 } elif (obj->getType() == LDObject::Subfile) { 1284 } elif (obj->getType() == LDObject::Subfile) {
1285 LDSubfileObject* ref = static_cast<LDSubfileObject*> (obj); 1285 LDSubfile* ref = static_cast<LDSubfile*> (obj);
1286 List<LDObject*> objs = ref->inlineContents (LDSubfileObject::DeepCacheInline); 1286 List<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline);
1287 1287
1288 for(LDObject* obj : objs) { 1288 for(LDObject* obj : objs) {
1289 verts << getVertices (obj); 1289 verts << getVertices (obj);
1290 delete obj; 1290 delete obj;
1291 } 1291 }
1603 ev->accept(); 1603 ev->accept();
1604 } 1604 }
1605 1605
1606 // ============================================================================= 1606 // =============================================================================
1607 // ----------------------------------------------------------------------------- 1607 // -----------------------------------------------------------------------------
1608 LDOverlayObject* GLRenderer::findOverlayObject (GLRenderer::Camera cam) { 1608 LDOverlay* GLRenderer::findOverlayObject (GLRenderer::Camera cam) {
1609 LDOverlayObject* ovlobj = null; 1609 LDOverlay* ovlobj = null;
1610 1610
1611 for (LDObject * obj : *file()) { 1611 for (LDObject * obj : *file()) {
1612 if (obj->getType() == LDObject::Overlay && static_cast<LDOverlayObject*> (obj)->camera() == cam) { 1612 if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->camera() == cam) {
1613 ovlobj = static_cast<LDOverlayObject*> (obj); 1613 ovlobj = static_cast<LDOverlay*> (obj);
1614 break; 1614 break;
1615 } 1615 }
1616 } 1616 }
1617 1617
1618 return ovlobj; 1618 return ovlobj;
1626 for (Camera cam : g_Cameras) { 1626 for (Camera cam : g_Cameras) {
1627 if (cam == Free) 1627 if (cam == Free)
1628 continue; 1628 continue;
1629 1629
1630 overlayMeta& meta = m_overlays[cam]; 1630 overlayMeta& meta = m_overlays[cam];
1631 LDOverlayObject* ovlobj = findOverlayObject (cam); 1631 LDOverlay* ovlobj = findOverlayObject (cam);
1632 1632
1633 if (!ovlobj && meta.img) { 1633 if (!ovlobj && meta.img) {
1634 delete meta.img; 1634 delete meta.img;
1635 meta.img = null; 1635 meta.img = null;
1636 } elif (ovlobj && (!meta.img || meta.fname != ovlobj->filename())) 1636 } elif (ovlobj && (!meta.img || meta.fname != ovlobj->filename()))
1644 for (Camera cam : g_Cameras) { 1644 for (Camera cam : g_Cameras) {
1645 if (cam == Free) 1645 if (cam == Free)
1646 continue; 1646 continue;
1647 1647
1648 overlayMeta& meta = m_overlays[cam]; 1648 overlayMeta& meta = m_overlays[cam];
1649 LDOverlayObject* ovlobj = findOverlayObject (cam); 1649 LDOverlay* ovlobj = findOverlayObject (cam);
1650 1650
1651 if (!meta.img && ovlobj) { 1651 if (!meta.img && ovlobj) {
1652 // If this is the last overlay image, we need to remove the empty space after it as well. 1652 // If this is the last overlay image, we need to remove the empty space after it as well.
1653 LDObject* nextobj = ovlobj->next(); 1653 LDObject* nextobj = ovlobj->next();
1654 1654
1662 m_file->forgetObject (ovlobj); 1662 m_file->forgetObject (ovlobj);
1663 delete ovlobj; 1663 delete ovlobj;
1664 } elif (meta.img && !ovlobj) { 1664 } elif (meta.img && !ovlobj) {
1665 // Inverse case: image is there but the overlay object is 1665 // Inverse case: image is there but the overlay object is
1666 // not, thus create the object. 1666 // not, thus create the object.
1667 ovlobj = new LDOverlayObject; 1667 ovlobj = new LDOverlay;
1668 1668
1669 // Find a suitable position to place this object. We want to place 1669 // Find a suitable position to place this object. We want to place
1670 // this into the header, which is everything up to the first scemantic 1670 // this into the header, which is everything up to the first scemantic
1671 // object. If we find another overlay object, place this object after 1671 // object. If we find another overlay object, place this object after
1672 // the last one found. Otherwise, place it before the first schemantic 1672 // the last one found. Otherwise, place it before the first schemantic
1691 file()->insertObj (lastOverlay + 1, ovlobj); 1691 file()->insertObj (lastOverlay + 1, ovlobj);
1692 else { 1692 else {
1693 file()->insertObj (i, ovlobj); 1693 file()->insertObj (i, ovlobj);
1694 1694
1695 if (found) 1695 if (found)
1696 file()->insertObj (i + 1, new LDEmptyObject); 1696 file()->insertObj (i + 1, new LDEmpty);
1697 } 1697 }
1698 } 1698 }
1699 1699
1700 if (meta.img && ovlobj) { 1700 if (meta.img && ovlobj) {
1701 ovlobj->setCamera (cam); 1701 ovlobj->setCamera (cam);

mercurial