src/gldraw.cpp

changeset 550
d97594e3fc54
parent 544
a52cfa218780
child 551
0efe5dbcef07
equal deleted inserted replaced
549:715d9a7f6598 550:d97594e3fc54
57 cfg (String, gl_bgcolor, "#CCCCD9"); 57 cfg (String, gl_bgcolor, "#CCCCD9");
58 cfg (String, gl_maincolor, "#707078"); 58 cfg (String, gl_maincolor, "#707078");
59 cfg (Float, gl_maincolor_alpha, 1.0); 59 cfg (Float, gl_maincolor_alpha, 1.0);
60 cfg (Int, gl_linethickness, 2); 60 cfg (Int, gl_linethickness, 2);
61 cfg (Bool, gl_colorbfc, false); 61 cfg (Bool, gl_colorbfc, false);
62 cfg (Int, gl_camera, GLRenderer::Free); 62 cfg (Int, gl_camera, GLRenderer::EFreeCamera);
63 cfg (Bool, gl_blackedges, false); 63 cfg (Bool, gl_blackedges, false);
64 cfg (Bool, gl_axes, false); 64 cfg (Bool, gl_axes, false);
65 cfg (Bool, gl_wireframe, false); 65 cfg (Bool, gl_wireframe, false);
66 cfg (Bool, gl_logostuds, false); 66 cfg (Bool, gl_logostuds, false);
67 cfg (Bool, gl_aa, true); 67 cfg (Bool, gl_aa, true);
75 QT_TRANSLATE_NOOP ("GLRenderer", "Back"), 75 QT_TRANSLATE_NOOP ("GLRenderer", "Back"),
76 QT_TRANSLATE_NOOP ("GLRenderer", "Right"), 76 QT_TRANSLATE_NOOP ("GLRenderer", "Right"),
77 QT_TRANSLATE_NOOP ("GLRenderer", "Free") 77 QT_TRANSLATE_NOOP ("GLRenderer", "Free")
78 }; 78 };
79 79
80 const GL::Camera g_Cameras[7] = 80 const GL::EFixedCamera g_Cameras[7] =
81 { GL::Top, 81 { GL::ETopCamera,
82 GL::Front, 82 GL::EFrontCamera,
83 GL::Left, 83 GL::ELeftCamera,
84 GL::Bottom, 84 GL::EBottomCamera,
85 GL::Back, 85 GL::EBackCamera,
86 GL::Right, 86 GL::ERightCamera,
87 GL::Free 87 GL::EFreeCamera
88 }; 88 };
89 89
90 const struct LDGLAxis 90 const struct LDGLAxis
91 { const QColor col; 91 { const QColor col;
92 const vertex vert; 92 const vertex vert;
101 101
102 // ============================================================================= 102 // =============================================================================
103 // ----------------------------------------------------------------------------- 103 // -----------------------------------------------------------------------------
104 GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) 104 GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent)
105 { m_Picking = m_rangepick = false; 105 { m_Picking = m_rangepick = false;
106 m_camera = (GL::Camera) gl_camera.value; 106 m_camera = (GL::EFixedCamera) gl_camera.value;
107 m_drawToolTip = false; 107 m_drawToolTip = false;
108 m_EditMode = Select; 108 m_EditMode = ESelectMode;
109 m_rectdraw = false; 109 m_rectdraw = false;
110 m_panning = false; 110 m_panning = false;
111 setFile (null); 111 setFile (null);
112 setDrawOnly (false); 112 setDrawOnly (false);
113 setMessageLog (null); 113 setMessageLog (null);
121 m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); 121 m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
122 m_thinBorderPen = m_thickBorderPen; 122 m_thinBorderPen = m_thickBorderPen;
123 m_thinBorderPen.setWidth (1); 123 m_thinBorderPen.setWidth (1);
124 124
125 // Init camera icons 125 // Init camera icons
126 for (const GL::Camera cam : g_Cameras) 126 for (const GL::EFixedCamera cam : g_Cameras)
127 { str iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower()); 127 { str iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower());
128 128
129 CameraIcon* info = &m_cameraIcons[cam]; 129 CameraIcon* info = &m_cameraIcons[cam];
130 info->img = new QPixmap (getIcon (iconname)); 130 info->img = new QPixmap (getIcon (iconname));
131 info->cam = cam; 131 info->cam = cam;
156 void GLRenderer::calcCameraIcons() 156 void GLRenderer::calcCameraIcons()
157 { int i = 0; 157 { int i = 0;
158 158
159 for (CameraIcon& info : m_cameraIcons) 159 for (CameraIcon& info : m_cameraIcons)
160 { // MATH 160 { // MATH
161 const long x1 = (m_width - (info.cam != Free ? 48 : 16)) + ((i % 3) * 16) - 1, 161 const long x1 = (m_width - (info.cam != EFreeCamera ? 48 : 16)) + ((i % 3) * 16) - 1,
162 y1 = ((i / 3) * 16) + 1; 162 y1 = ((i / 3) * 16) + 1;
163 163
164 info.srcRect = QRect (0, 0, 16, 16); 164 info.srcRect = QRect (0, 0, 16, 16);
165 info.destRect = QRect (x1, y1, 16, 16); 165 info.destRect = QRect (x1, y1, 16, 16);
166 info.selRect = QRect ( 166 info.selRect = QRect (
207 } 207 }
208 208
209 // ============================================================================= 209 // =============================================================================
210 // ----------------------------------------------------------------------------- 210 // -----------------------------------------------------------------------------
211 void GLRenderer::resetAllAngles() 211 void GLRenderer::resetAllAngles()
212 { Camera oldcam = camera(); 212 { EFixedCamera oldcam = camera();
213 213
214 for (int i = 0; i < 7; ++i) 214 for (int i = 0; i < 7; ++i)
215 { setCamera ((Camera) i); 215 { setCamera ((EFixedCamera) i);
216 resetAngles(); 216 resetAngles();
217 } 217 }
218 218
219 setCamera (oldcam); 219 setCamera (oldcam);
220 } 220 }
390 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 390 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
391 391
392 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 392 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
393 glEnable (GL_DEPTH_TEST); 393 glEnable (GL_DEPTH_TEST);
394 394
395 if (m_camera != Free) 395 if (m_camera != EFreeCamera)
396 { glMatrixMode (GL_PROJECTION); 396 { glMatrixMode (GL_PROJECTION);
397 glPushMatrix(); 397 glPushMatrix();
398 398
399 glLoadIdentity(); 399 glLoadIdentity();
400 glOrtho (-m_virtWidth, m_virtWidth, -m_virtHeight, m_virtHeight, -100.0f, 100.0f); 400 glOrtho (-m_virtWidth, m_virtWidth, -m_virtHeight, m_virtHeight, -100.0f, 100.0f);
401 glTranslatef (pan (X), pan (Y), 0.0f); 401 glTranslatef (pan (X), pan (Y), 0.0f);
402 402
403 if (m_camera != Front && m_camera != Back) 403 if (m_camera != EFrontCamera && m_camera != EBackCamera)
404 { glRotatef (90.0f, g_FixedCameras[camera()].glrotate[0], 404 { glRotatef (90.0f, g_FixedCameras[camera()].glrotate[0],
405 g_FixedCameras[camera()].glrotate[1], 405 g_FixedCameras[camera()].glrotate[1],
406 g_FixedCameras[camera()].glrotate[2]); 406 g_FixedCameras[camera()].glrotate[2]);
407 } 407 }
408 408
409 // Back camera needs to be handled differently 409 // Back camera needs to be handled differently
410 if (m_camera == GLRenderer::Back) 410 if (m_camera == GLRenderer::EBackCamera)
411 { glRotatef (180.0f, 1.0f, 0.0f, 0.0f); 411 { glRotatef (180.0f, 1.0f, 0.0f, 0.0f);
412 glRotatef (180.0f, 0.0f, 0.0f, 1.0f); 412 glRotatef (180.0f, 0.0f, 0.0f, 1.0f);
413 } 413 }
414 } 414 }
415 else 415 else
463 // ----------------------------------------------------------------------------- 463 // -----------------------------------------------------------------------------
464 // This converts a 2D point on the screen to a 3D point in the model. If 'snap' 464 // This converts a 2D point on the screen to a 3D point in the model. If 'snap'
465 // is true, the 3D point will snap to the current grid. 465 // is true, the 3D point will snap to the current grid.
466 // ----------------------------------------------------------------------------- 466 // -----------------------------------------------------------------------------
467 vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const 467 vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const
468 { assert (camera() != Free); 468 { assert (camera() != EFreeCamera);
469 469
470 vertex pos3d; 470 vertex pos3d;
471 const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera]; 471 const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera];
472 const Axis axisX = cam->axisX; 472 const Axis axisX = cam->axisX;
473 const Axis axisY = cam->axisY; 473 const Axis axisY = cam->axisY;
544 544
545 // If we wish to only draw the brick, stop here 545 // If we wish to only draw the brick, stop here
546 if (isDrawOnly()) 546 if (isDrawOnly())
547 return; 547 return;
548 548
549 if (m_camera != Free && !isPicking()) 549 if (m_camera != EFreeCamera && !isPicking())
550 { // Paint the overlay image if we have one 550 { // Paint the overlay image if we have one
551 const LDGLOverlay& overlay = m_overlays[m_camera]; 551 const LDGLOverlay& overlay = m_overlays[m_camera];
552 552
553 if (overlay.img != null) 553 if (overlay.img != null)
554 { QPoint v0 = coordconv3_2 (m_overlays[m_camera].v0), 554 { QPoint v0 = coordconv3_2 (m_overlays[m_camera].v0),
572 QPen linepen = m_thinBorderPen; 572 QPen linepen = m_thinBorderPen;
573 linepen.setWidth (2); 573 linepen.setWidth (2);
574 linepen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black); 574 linepen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black);
575 575
576 // If we're drawing, draw the vertices onto the screen. 576 // If we're drawing, draw the vertices onto the screen.
577 if (getEditMode() == Draw) 577 if (getEditMode() == EDrawMode)
578 { int numverts = 4; 578 { int numverts = 4;
579 579
580 if (!m_rectdraw) 580 if (!m_rectdraw)
581 numverts = m_drawedVerts.size() + 1; 581 numverts = m_drawedVerts.size() + 1;
582 582
629 // Draw their coordinates 629 // Draw their coordinates
630 paint.drawText (blip.x(), blip.y() - 8, polyverts[i].stringRep (true)); 630 paint.drawText (blip.x(), blip.y() - 8, polyverts[i].stringRep (true));
631 } 631 }
632 } 632 }
633 } 633 }
634 elif (getEditMode() == CircleMode) 634 elif (getEditMode() == ECircleMode)
635 { // If we have not specified the center point of the circle yet, preview it on the screen. 635 { // If we have not specified the center point of the circle yet, preview it on the screen.
636 if (m_drawedVerts.isEmpty()) 636 if (m_drawedVerts.isEmpty())
637 drawBlip (paint, coordconv3_2 (m_hoverpos)); 637 drawBlip (paint, coordconv3_2 (m_hoverpos));
638 else 638 else
639 { QVector<vertex> verts, verts2; 639 { QVector<vertex> verts, verts2;
724 paint.drawRect (m_cameraIcons[camera()].selRect); 724 paint.drawRect (m_cameraIcons[camera()].selRect);
725 725
726 // Draw the actual icons 726 // Draw the actual icons
727 for (CameraIcon& info : m_cameraIcons) 727 for (CameraIcon& info : m_cameraIcons)
728 { // Don't draw the free camera icon when in draw mode 728 { // Don't draw the free camera icon when in draw mode
729 if (&info == &m_cameraIcons[GL::Free] && getEditMode() != Select) 729 if (&info == &m_cameraIcons[GL::EFreeCamera] && getEditMode() != ESelectMode)
730 continue; 730 continue;
731 731
732 paint.drawPixmap (info.destRect, *info.img, info.srcRect); 732 paint.drawPixmap (info.destRect, *info.img, info.srcRect);
733 } 733 }
734 734
933 933
934 // ============================================================================= 934 // =============================================================================
935 // ----------------------------------------------------------------------------- 935 // -----------------------------------------------------------------------------
936 void GLRenderer::addDrawnVertex (vertex pos) 936 void GLRenderer::addDrawnVertex (vertex pos)
937 { // If we picked an already-existing vertex, stop drawing 937 { // If we picked an already-existing vertex, stop drawing
938 if (getEditMode() != CircleMode) 938 if (getEditMode() != ECircleMode)
939 { for (vertex& vert : m_drawedVerts) 939 { for (vertex& vert : m_drawedVerts)
940 { if (vert == pos) 940 { if (vert == pos)
941 { endDraw (true); 941 { endDraw (true);
942 return; 942 return;
943 } 943 }
967 } 967 }
968 } 968 }
969 } 969 }
970 970
971 switch (getEditMode()) 971 switch (getEditMode())
972 { case Draw: 972 { case EDrawMode:
973 { if (m_rectdraw) 973 { if (m_rectdraw)
974 { if (m_drawedVerts.size() == 2) 974 { if (m_drawedVerts.size() == 2)
975 { endDraw (true); 975 { endDraw (true);
976 return; 976 return;
977 } 977 }
989 } 989 }
990 990
991 addDrawnVertex (m_hoverpos); 991 addDrawnVertex (m_hoverpos);
992 } break; 992 } break;
993 993
994 case CircleMode: 994 case ECircleMode:
995 { if (m_drawedVerts.size() == 3) 995 { if (m_drawedVerts.size() == 3)
996 { endDraw (true); 996 { endDraw (true);
997 return; 997 return;
998 } 998 }
999 999
1000 addDrawnVertex (m_hoverpos); 1000 addDrawnVertex (m_hoverpos);
1001 } break; 1001 } break;
1002 1002
1003 case Select: 1003 case ESelectMode:
1004 { if (!isDrawOnly()) 1004 { if (!isDrawOnly())
1005 { if (m_totalmove < 10) 1005 { if (m_totalmove < 10)
1006 m_rangepick = false; 1006 m_rangepick = false;
1007 1007
1008 if (!m_rangepick) 1008 if (!m_rangepick)
1015 } 1015 }
1016 1016
1017 m_rangepick = false; 1017 m_rangepick = false;
1018 } 1018 }
1019 1019
1020 if (wasMid && getEditMode() != Select && m_drawedVerts.size() < 4 && m_totalmove < 10) 1020 if (wasMid && getEditMode() != ESelectMode && m_drawedVerts.size() < 4 && m_totalmove < 10)
1021 { // Find the closest vertex to our cursor 1021 { // Find the closest vertex to our cursor
1022 double mindist = 1024.0f; 1022 double mindist = 1024.0f;
1023 vertex closest; 1023 vertex closest;
1024 bool valid = false; 1024 bool valid = false;
1025 1025
1094 1094
1095 if (mid || (left && shift)) 1095 if (mid || (left && shift))
1096 { pan (X) += 0.03f * dx * (zoom() / 7.5f); 1096 { pan (X) += 0.03f * dx * (zoom() / 7.5f);
1097 pan (Y) -= 0.03f * dy * (zoom() / 7.5f); 1097 pan (Y) -= 0.03f * dy * (zoom() / 7.5f);
1098 m_panning = true; 1098 m_panning = true;
1099 } elif (left && !m_rangepick && camera() == Free) 1099 } elif (left && !m_rangepick && camera() == EFreeCamera)
1100 { rot (X) = rot (X) + dy; 1100 { rot (X) = rot (X) + dy;
1101 rot (Y) = rot (Y) + dx; 1101 rot (Y) = rot (Y) + dx;
1102 1102
1103 clampAngle (rot (X)); 1103 clampAngle (rot (X));
1104 clampAngle (rot (Y)); 1104 clampAngle (rot (Y));
1111 // Update 2d position 1111 // Update 2d position
1112 m_pos = ev->pos(); 1112 m_pos = ev->pos();
1113 m_globalpos = ev->globalPos(); 1113 m_globalpos = ev->globalPos();
1114 1114
1115 // Calculate 3d position of the cursor 1115 // Calculate 3d position of the cursor
1116 m_hoverpos = (camera() != Free) ? coordconv2_3 (m_pos, true) : g_origin; 1116 m_hoverpos = (camera() != EFreeCamera) ? coordconv2_3 (m_pos, true) : g_origin;
1117 1117
1118 // Update rect vertices since m_hoverpos may have changed 1118 // Update rect vertices since m_hoverpos may have changed
1119 updateRectVerts(); 1119 updateRectVerts();
1120 1120
1121 update(); 1121 update();
1160 { g_win->spawnContextMenu (ev->globalPos()); 1160 { g_win->spawnContextMenu (ev->globalPos());
1161 } 1161 }
1162 1162
1163 // ============================================================================= 1163 // =============================================================================
1164 // ----------------------------------------------------------------------------- 1164 // -----------------------------------------------------------------------------
1165 void GLRenderer::setCamera (const GL::Camera cam) 1165 void GLRenderer::setCamera (const GLRenderer::EFixedCamera cam)
1166 { m_camera = cam; 1166 { m_camera = cam;
1167 gl_camera = (int) cam; 1167 gl_camera = (int) cam;
1168 g_win->updateEditModeActions(); 1168 g_win->updateEditModeActions();
1169 } 1169 }
1170 1170
1292 // ----------------------------------------------------------------------------- 1292 // -----------------------------------------------------------------------------
1293 void GLRenderer::setEditMode (EditMode const& a) 1293 void GLRenderer::setEditMode (EditMode const& a)
1294 { m_EditMode = a; 1294 { m_EditMode = a;
1295 1295
1296 switch (a) 1296 switch (a)
1297 { case Select: 1297 { case ESelectMode:
1298 { unsetCursor(); 1298 { unsetCursor();
1299 setContextMenuPolicy (Qt::DefaultContextMenu); 1299 setContextMenuPolicy (Qt::DefaultContextMenu);
1300 } break; 1300 } break;
1301 1301
1302 case Draw: 1302 case EDrawMode:
1303 case CircleMode: 1303 case ECircleMode:
1304 { // Cannot draw into the free camera - use top instead. 1304 { // Cannot draw into the free camera - use top instead.
1305 if (m_camera == Free) 1305 if (m_camera == EFreeCamera)
1306 setCamera (Top); 1306 setCamera (ETopCamera);
1307 1307
1308 // Disable the context menu - we need the right mouse button 1308 // Disable the context menu - we need the right mouse button
1309 // for removing vertices. 1309 // for removing vertices.
1310 setContextMenuPolicy (Qt::NoContextMenu); 1310 setContextMenuPolicy (Qt::NoContextMenu);
1311 1311
1358 // Clean the selection and create the object 1358 // Clean the selection and create the object
1359 QList<vertex>& verts = m_drawedVerts; 1359 QList<vertex>& verts = m_drawedVerts;
1360 QList<LDObject*> objs; 1360 QList<LDObject*> objs;
1361 1361
1362 switch (getEditMode()) 1362 switch (getEditMode())
1363 { case Draw: 1363 { case EDrawMode:
1364 { if (m_rectdraw) 1364 { if (m_rectdraw)
1365 { LDQuad* quad = new LDQuad; 1365 { LDQuad* quad = new LDQuad;
1366 1366
1367 // Copy the vertices from m_rectverts 1367 // Copy the vertices from m_rectverts
1368 updateRectVerts(); 1368 updateRectVerts();
1405 } break; 1405 } break;
1406 } 1406 }
1407 } 1407 }
1408 } break; 1408 } break;
1409 1409
1410 case CircleMode: 1410 case ECircleMode:
1411 { const int segs = lores, divs = lores; // TODO: make customizable 1411 { const int segs = lores, divs = lores; // TODO: make customizable
1412 double dist0 = getCircleDrawDist (0), 1412 double dist0 = getCircleDrawDist (0),
1413 dist1 = getCircleDrawDist (1); 1413 dist1 = getCircleDrawDist (1);
1414 LDFile* refFile = null; 1414 LDFile* refFile = null;
1415 matrix transform; 1415 matrix transform;
1497 ref->setColor (maincolor); 1497 ref->setColor (maincolor);
1498 objs << ref; 1498 objs << ref;
1499 } 1499 }
1500 } break; 1500 } break;
1501 1501
1502 case Select: 1502 case ESelectMode:
1503 { // this shouldn't happen 1503 { // this shouldn't happen
1504 assert (false); 1504 assert (false);
1505 return; 1505 return;
1506 } break; 1506 } break;
1507 } 1507 }
1636 obj->m_glinit = false; 1636 obj->m_glinit = false;
1637 } 1637 }
1638 1638
1639 // ============================================================================= 1639 // =============================================================================
1640 // ----------------------------------------------------------------------------- 1640 // -----------------------------------------------------------------------------
1641 Axis GLRenderer::getCameraAxis (bool y, GL::Camera camid) 1641 Axis GLRenderer::getCameraAxis (bool y, GLRenderer::EFixedCamera camid)
1642 { if (camid == (GL::Camera) - 1) 1642 { if (camid == (GL::EFixedCamera) - 1)
1643 camid = m_camera; 1643 camid = m_camera;
1644 1644
1645 const LDFixedCameraInfo* cam = &g_FixedCameras[camid]; 1645 const LDFixedCameraInfo* cam = &g_FixedCameras[camid];
1646 return (y) ? cam->axisY : cam->axisX; 1646 return (y) ? cam->axisY : cam->axisX;
1647 } 1647 }
1648 1648
1649 // ============================================================================= 1649 // =============================================================================
1650 // ----------------------------------------------------------------------------- 1650 // -----------------------------------------------------------------------------
1651 bool GLRenderer::setupOverlay (GL::Camera cam, str file, int x, int y, int w, int h) 1651 bool GLRenderer::setupOverlay (EFixedCamera cam, str file, int x, int y, int w, int h)
1652 { QImage* img = new QImage (file); 1652 { QImage* img = new QImage (file);
1653 LDGLOverlay& info = getOverlay (cam); 1653 LDGLOverlay& info = getOverlay (cam);
1654 1654
1655 if (img->isNull()) 1655 if (img->isNull())
1656 { critical (tr ("Failed to load overlay image!")); 1656 { critical (tr ("Failed to load overlay image!"));
1695 } 1695 }
1696 1696
1697 // ============================================================================= 1697 // =============================================================================
1698 // ----------------------------------------------------------------------------- 1698 // -----------------------------------------------------------------------------
1699 void GLRenderer::clearOverlay() 1699 void GLRenderer::clearOverlay()
1700 { if (camera() == Free) 1700 { if (camera() == EFreeCamera)
1701 return; 1701 return;
1702 1702
1703 LDGLOverlay& info = m_overlays[camera()]; 1703 LDGLOverlay& info = m_overlays[camera()];
1704 delete info.img; 1704 delete info.img;
1705 info.img = null; 1705 info.img = null;
1708 } 1708 }
1709 1709
1710 // ============================================================================= 1710 // =============================================================================
1711 // ----------------------------------------------------------------------------- 1711 // -----------------------------------------------------------------------------
1712 void GLRenderer::setDepthValue (double depth) 1712 void GLRenderer::setDepthValue (double depth)
1713 { assert (camera() < Free); 1713 { assert (camera() < EFreeCamera);
1714 m_depthValues[camera()] = depth; 1714 m_depthValues[camera()] = depth;
1715 } 1715 }
1716 1716
1717 // ============================================================================= 1717 // =============================================================================
1718 // ----------------------------------------------------------------------------- 1718 // -----------------------------------------------------------------------------
1719 double GLRenderer::getDepthValue() const 1719 double GLRenderer::getDepthValue() const
1720 { assert (camera() < Free); 1720 { assert (camera() < EFreeCamera);
1721 return m_depthValues[camera()]; 1721 return m_depthValues[camera()];
1722 } 1722 }
1723 1723
1724 // ============================================================================= 1724 // =============================================================================
1725 // ----------------------------------------------------------------------------- 1725 // -----------------------------------------------------------------------------
1822 } 1822 }
1823 1823
1824 // ============================================================================= 1824 // =============================================================================
1825 // ----------------------------------------------------------------------------- 1825 // -----------------------------------------------------------------------------
1826 void GLRenderer::zoomAllToFit() 1826 void GLRenderer::zoomAllToFit()
1827 { Camera oldcam = camera(); 1827 { EFixedCamera oldcam = camera();
1828 1828
1829 for (int i = 0; i < 7; ++i) 1829 for (int i = 0; i < 7; ++i)
1830 { setCamera ((Camera) i); 1830 { setCamera ((EFixedCamera) i);
1831 zoomToFit(); 1831 zoomToFit();
1832 } 1832 }
1833 1833
1834 setCamera (oldcam); 1834 setCamera (oldcam);
1835 } 1835 }
1868 } 1868 }
1869 1869
1870 // ============================================================================= 1870 // =============================================================================
1871 // ----------------------------------------------------------------------------- 1871 // -----------------------------------------------------------------------------
1872 void GLRenderer::mouseDoubleClickEvent (QMouseEvent* ev) 1872 void GLRenderer::mouseDoubleClickEvent (QMouseEvent* ev)
1873 { if (!(ev->buttons() & Qt::LeftButton) || getEditMode() != Select) 1873 { if (!(ev->buttons() & Qt::LeftButton) || getEditMode() != ESelectMode)
1874 return; 1874 return;
1875 1875
1876 pick (ev->x(), ev->y()); 1876 pick (ev->x(), ev->y());
1877 1877
1878 if (selection().isEmpty()) 1878 if (selection().isEmpty())
1885 ev->accept(); 1885 ev->accept();
1886 } 1886 }
1887 1887
1888 // ============================================================================= 1888 // =============================================================================
1889 // ----------------------------------------------------------------------------- 1889 // -----------------------------------------------------------------------------
1890 LDOverlay* GLRenderer::findOverlayObject (GLRenderer::Camera cam) 1890 LDOverlay* GLRenderer::findOverlayObject (EFixedCamera cam)
1891 { LDOverlay* ovlobj = null; 1891 { LDOverlay* ovlobj = null;
1892 1892
1893 for (LDObject * obj : getFile()->getObjects()) 1893 for (LDObject * obj : getFile()->getObjects())
1894 { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) 1894 { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->getCamera() == cam)
1895 { ovlobj = static_cast<LDOverlay*> (obj); 1895 { ovlobj = static_cast<LDOverlay*> (obj);
1903 // ============================================================================= 1903 // =============================================================================
1904 // ----------------------------------------------------------------------------- 1904 // -----------------------------------------------------------------------------
1905 // Read in overlays from the current file and update overlay info accordingly. 1905 // Read in overlays from the current file and update overlay info accordingly.
1906 // ----------------------------------------------------------------------------- 1906 // -----------------------------------------------------------------------------
1907 void GLRenderer::initOverlaysFromObjects() 1907 void GLRenderer::initOverlaysFromObjects()
1908 { for (Camera cam : g_Cameras) 1908 { for (EFixedCamera cam : g_Cameras)
1909 { if (cam == Free) 1909 { if (cam == EFreeCamera)
1910 continue; 1910 continue;
1911 1911
1912 LDGLOverlay& meta = m_overlays[cam]; 1912 LDGLOverlay& meta = m_overlays[cam];
1913 LDOverlay* ovlobj = findOverlayObject (cam); 1913 LDOverlay* ovlobj = findOverlayObject (cam);
1914 1914
1922 } 1922 }
1923 1923
1924 // ============================================================================= 1924 // =============================================================================
1925 // ----------------------------------------------------------------------------- 1925 // -----------------------------------------------------------------------------
1926 void GLRenderer::updateOverlayObjects() 1926 void GLRenderer::updateOverlayObjects()
1927 { for (Camera cam : g_Cameras) 1927 { for (EFixedCamera cam : g_Cameras)
1928 { if (cam == Free) 1928 { if (cam == EFreeCamera)
1929 continue; 1929 continue;
1930 1930
1931 LDGLOverlay& meta = m_overlays[cam]; 1931 LDGLOverlay& meta = m_overlays[cam];
1932 LDOverlay* ovlobj = findOverlayObject (cam); 1932 LDOverlay* ovlobj = findOverlayObject (cam);
1933 1933

mercurial