144 CameraIcon* info = &m_cameraIcons[cam]; |
144 CameraIcon* info = &m_cameraIcons[cam]; |
145 info->img = new QPixmap (getIcon (iconname)); |
145 info->img = new QPixmap (getIcon (iconname)); |
146 info->cam = cam; |
146 info->cam = cam; |
147 } |
147 } |
148 |
148 |
|
149 calcCameraIcons(); |
|
150 } |
|
151 |
|
152 // ============================================================================= |
|
153 // ----------------------------------------------------------------------------- |
|
154 GLRenderer::~GLRenderer() |
|
155 { |
149 for (int i = 0; i < 6; ++i) |
156 for (int i = 0; i < 6; ++i) |
150 { |
157 delete currentDocumentData().overlays[i].img; |
151 m_overlays[i].img = null; |
|
152 m_depthValues[i] = 0.0f; |
|
153 } |
|
154 |
|
155 calcCameraIcons(); |
|
156 } |
|
157 |
|
158 // ============================================================================= |
|
159 // ----------------------------------------------------------------------------- |
|
160 GLRenderer::~GLRenderer() |
|
161 { |
|
162 for (int i = 0; i < 6; ++i) |
|
163 delete m_overlays[i].img; |
|
164 |
158 |
165 for (CameraIcon& info : m_cameraIcons) |
159 for (CameraIcon& info : m_cameraIcons) |
166 delete info.img; |
160 delete info.img; |
167 } |
161 } |
168 |
162 |
603 return; |
597 return; |
604 |
598 |
605 if (m_camera != EFreeCamera && !isPicking()) |
599 if (m_camera != EFreeCamera && !isPicking()) |
606 { |
600 { |
607 // Paint the overlay image if we have one |
601 // Paint the overlay image if we have one |
608 const LDGLOverlay& overlay = m_overlays[m_camera]; |
602 const LDGLOverlay& overlay = currentDocumentData().overlays[m_camera]; |
609 |
603 |
610 if (overlay.img != null) |
604 if (overlay.img != null) |
611 { |
605 { |
612 QPoint v0 = coordconv3_2 (m_overlays[m_camera].v0), |
606 QPoint v0 = coordconv3_2 (currentDocumentData().overlays[m_camera].v0), |
613 v1 = coordconv3_2 (m_overlays[m_camera].v1); |
607 v1 = coordconv3_2 (currentDocumentData().overlays[m_camera].v1); |
614 |
608 |
615 QRect targRect (v0.x(), v0.y(), abs (v1.x() - v0.x()), abs (v1.y() - v0.y())), |
609 QRect targRect (v0.x(), v0.y(), abs (v1.x() - v0.x()), abs (v1.y() - v0.y())), |
616 srcRect (0, 0, overlay.img->width(), overlay.img->height()); |
610 srcRect (0, 0, overlay.img->width(), overlay.img->height()); |
617 paint.drawImage (targRect, *overlay.img, srcRect); |
611 paint.drawImage (targRect, *overlay.img, srcRect); |
618 } |
612 } |
1475 |
1469 |
1476 g_win->updateEditModeActions(); |
1470 g_win->updateEditModeActions(); |
1477 update(); |
1471 update(); |
1478 } |
1472 } |
1479 |
1473 |
|
1474 // ============================================================================= |
|
1475 // |
1480 void GLRenderer::setFile (LDDocument* const& a) |
1476 void GLRenderer::setFile (LDDocument* const& a) |
1481 { |
1477 { |
1482 m_File = a; |
1478 m_File = a; |
1483 |
1479 |
1484 if (a != null) |
1480 if (a != null) |
|
1481 { |
1485 initOverlaysFromObjects(); |
1482 initOverlaysFromObjects(); |
1486 } |
1483 |
1487 |
1484 if (currentDocumentData().init == false) |
1488 // ============================================================================= |
1485 { |
1489 // ----------------------------------------------------------------------------- |
1486 resetAllAngles(); |
|
1487 currentDocumentData().init = true; |
|
1488 } |
|
1489 } |
|
1490 } |
|
1491 |
|
1492 // ============================================================================= |
|
1493 // |
1490 Matrix GLRenderer::getCircleDrawMatrix (double scale) |
1494 Matrix GLRenderer::getCircleDrawMatrix (double scale) |
1491 { |
1495 { |
1492 Matrix transform = g_circleDrawTransforms[camera() % 3]; |
1496 Matrix transform = g_circleDrawTransforms[camera() % 3]; |
1493 |
1497 |
1494 for (int i = 0; i < 9; ++i) |
1498 for (int i = 0; i < 9; ++i) |
1899 // ============================================================================= |
1903 // ============================================================================= |
1900 // ----------------------------------------------------------------------------- |
1904 // ----------------------------------------------------------------------------- |
1901 void GLRenderer::setDepthValue (double depth) |
1905 void GLRenderer::setDepthValue (double depth) |
1902 { |
1906 { |
1903 assert (camera() < EFreeCamera); |
1907 assert (camera() < EFreeCamera); |
1904 m_depthValues[camera()] = depth; |
1908 currentDocumentData().depthValues[camera()] = depth; |
1905 } |
1909 } |
1906 |
1910 |
1907 // ============================================================================= |
1911 // ============================================================================= |
1908 // ----------------------------------------------------------------------------- |
1912 // ----------------------------------------------------------------------------- |
1909 double GLRenderer::getDepthValue() const |
1913 double GLRenderer::getDepthValue() const |
1910 { |
1914 { |
1911 assert (camera() < EFreeCamera); |
1915 assert (camera() < EFreeCamera); |
1912 return m_depthValues[camera()]; |
1916 return currentDocumentData().depthValues[camera()]; |
1913 } |
1917 } |
1914 |
1918 |
1915 // ============================================================================= |
1919 // ============================================================================= |
1916 // ----------------------------------------------------------------------------- |
1920 // ----------------------------------------------------------------------------- |
1917 const char* GLRenderer::getCameraName() const |
1921 const char* GLRenderer::getCameraName() const |
1921 |
1925 |
1922 // ============================================================================= |
1926 // ============================================================================= |
1923 // ----------------------------------------------------------------------------- |
1927 // ----------------------------------------------------------------------------- |
1924 LDGLOverlay& GLRenderer::getOverlay (int newcam) |
1928 LDGLOverlay& GLRenderer::getOverlay (int newcam) |
1925 { |
1929 { |
1926 return m_overlays[newcam]; |
1930 return currentDocumentData().overlays[newcam]; |
1927 } |
1931 } |
1928 |
1932 |
1929 // ============================================================================= |
1933 // ============================================================================= |
1930 // ----------------------------------------------------------------------------- |
1934 // ----------------------------------------------------------------------------- |
1931 void GLRenderer::zoomNotch (bool inward) |
1935 void GLRenderer::zoomNotch (bool inward) |
2143 for (EFixedCamera cam : g_Cameras) |
2147 for (EFixedCamera cam : g_Cameras) |
2144 { |
2148 { |
2145 if (cam == EFreeCamera) |
2149 if (cam == EFreeCamera) |
2146 continue; |
2150 continue; |
2147 |
2151 |
2148 LDGLOverlay& meta = m_overlays[cam]; |
2152 LDGLOverlay& meta = currentDocumentData().overlays[cam]; |
2149 LDOverlay* ovlobj = findOverlayObject (cam); |
2153 LDOverlay* ovlobj = findOverlayObject (cam); |
2150 |
2154 |
2151 if (!meta.img && ovlobj) |
2155 if (!meta.img && ovlobj) |
2152 { |
2156 { |
2153 // If this is the last overlay image, we need to remove the empty space after it as well. |
2157 // If this is the last overlay image, we need to remove the empty space after it as well. |