src/gldraw.cc

changeset 619
8bfe34c6ab1a
parent 617
f5059d144438
child 620
ce4f42dcf0c3
equal deleted inserted replaced
618:de0d51349f6c 619:8bfe34c6ab1a
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 }
1432 setBackground(); 1426 setBackground();
1433 repaint(); 1427 repaint();
1434 } 1428 }
1435 1429
1436 // ============================================================================= 1430 // =============================================================================
1437 // ----------------------------------------------------------------------------- 1431 //
1438 void GLRenderer::setEditMode (EditMode const& a) 1432 void GLRenderer::setEditMode (EditMode const& a)
1439 { 1433 {
1440 m_EditMode = a; 1434 m_EditMode = a;
1441 1435
1442 switch (a) 1436 switch (a)
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)
1501 1505
1502 return transform; 1506 return transform;
1503 } 1507 }
1504 1508
1505 // ============================================================================= 1509 // =============================================================================
1506 // ----------------------------------------------------------------------------- 1510 //
1507 void GLRenderer::endDraw (bool accept) 1511 void GLRenderer::endDraw (bool accept)
1508 { 1512 {
1509 (void) accept; 1513 (void) accept;
1510 1514
1511 // Clean the selection and create the object 1515 // Clean the selection and create the object
1887 void GLRenderer::clearOverlay() 1891 void GLRenderer::clearOverlay()
1888 { 1892 {
1889 if (camera() == EFreeCamera) 1893 if (camera() == EFreeCamera)
1890 return; 1894 return;
1891 1895
1892 LDGLOverlay& info = m_overlays[camera()]; 1896 LDGLOverlay& info = currentDocumentData().overlays[camera()];
1893 delete info.img; 1897 delete info.img;
1894 info.img = null; 1898 info.img = null;
1895 1899
1896 updateOverlayObjects(); 1900 updateOverlayObjects();
1897 } 1901 }
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)
2121 for (EFixedCamera cam : g_Cameras) 2125 for (EFixedCamera cam : g_Cameras)
2122 { 2126 {
2123 if (cam == EFreeCamera) 2127 if (cam == EFreeCamera)
2124 continue; 2128 continue;
2125 2129
2126 LDGLOverlay& meta = m_overlays[cam]; 2130 LDGLOverlay& meta = currentDocumentData().overlays[cam];
2127 LDOverlay* ovlobj = findOverlayObject (cam); 2131 LDOverlay* ovlobj = findOverlayObject (cam);
2128 2132
2129 if (!ovlobj && meta.img) 2133 if (!ovlobj && meta.img)
2130 { 2134 {
2131 delete meta.img; 2135 delete meta.img;
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.

mercurial