105 m_camera = (GL::Camera) gl_camera.value; |
105 m_camera = (GL::Camera) gl_camera.value; |
106 m_drawToolTip = false; |
106 m_drawToolTip = false; |
107 m_editMode = Select; |
107 m_editMode = Select; |
108 m_rectdraw = false; |
108 m_rectdraw = false; |
109 m_panning = false; |
109 m_panning = false; |
110 m_firstResize = true; |
|
111 setFile (null); |
110 setFile (null); |
112 setDrawOnly (false); |
111 setDrawOnly (false); |
113 setMessageLog (null); |
112 setMessageLog (null); |
|
113 m_width = m_height = -1; |
114 |
114 |
115 m_toolTipTimer = new QTimer (this); |
115 m_toolTipTimer = new QTimer (this); |
116 m_toolTipTimer->setSingleShot (true); |
116 m_toolTipTimer->setSingleShot (true); |
117 connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); |
117 connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); |
118 |
118 |
348 // ============================================================================= |
348 // ============================================================================= |
349 // ----------------------------------------------------------------------------- |
349 // ----------------------------------------------------------------------------- |
350 void GLRenderer::resizeGL (int w, int h) |
350 void GLRenderer::resizeGL (int w, int h) |
351 { m_width = w; |
351 { m_width = w; |
352 m_height = h; |
352 m_height = h; |
353 |
|
354 // If this is the first call to resizeGL, reset the angles. We cannot call |
|
355 // resetAngles() in the initializer because it does not know m_width or m_height, |
|
356 // which zoomToFit() must know. |
|
357 if (m_firstResize) |
|
358 { m_firstResize = false; |
|
359 resetAngles(); |
|
360 } |
|
361 |
353 |
362 calcCameraIcons(); |
354 calcCameraIcons(); |
363 |
355 |
364 glViewport (0, 0, w, h); |
356 glViewport (0, 0, w, h); |
365 glMatrixMode (GL_PROJECTION); |
357 glMatrixMode (GL_PROJECTION); |
799 // Compiling all is a big job, use a busy cursor |
791 // Compiling all is a big job, use a busy cursor |
800 setCursor (Qt::BusyCursor); |
792 setCursor (Qt::BusyCursor); |
801 |
793 |
802 m_knownVerts.clear(); |
794 m_knownVerts.clear(); |
803 |
795 |
804 for (LDObject * obj : file()->objects()) |
796 for (LDObject* obj : file()->objects()) |
805 compileObject (obj); |
797 compileObject (obj); |
806 |
798 |
807 // Compile axes |
799 // Compile axes |
808 glDeleteLists (m_axeslist, 1); |
800 glDeleteLists (m_axeslist, 1); |
809 m_axeslist = glGenLists (1); |
801 m_axeslist = glGenLists (1); |
810 glNewList (m_axeslist, GL_COMPILE); |
802 glNewList (m_axeslist, GL_COMPILE); |
811 glBegin (GL_LINES); |
803 glBegin (GL_LINES); |
812 |
804 |
813 for (const LDGLAxis & ax : g_GLAxes) |
805 for (const LDGLAxis& ax : g_GLAxes) |
814 { qglColor (ax.col); |
806 { qglColor (ax.col); |
815 compileVertex (ax.vert); |
807 compileVertex (ax.vert); |
816 compileVertex (-ax.vert); |
808 compileVertex (-ax.vert); |
817 } |
809 } |
818 |
810 |
825 // ============================================================================= |
817 // ============================================================================= |
826 // ----------------------------------------------------------------------------- |
818 // ----------------------------------------------------------------------------- |
827 void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) |
819 void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) |
828 { glBegin (gltype); |
820 { glBegin (gltype); |
829 |
821 |
830 const short numverts = (obj->getType() != LDObject::CndLine) ? obj->vertices() : 2; |
822 const int numverts = (obj->getType() != LDObject::CndLine) ? obj->vertices() : 2; |
831 |
823 |
832 if (g_glInvert == false) |
824 if (g_glInvert == false) |
833 for (short i = 0; i < numverts; ++i) |
825 for (int i = 0; i < numverts; ++i) |
834 compileVertex (obj->m_coords[i]); |
826 compileVertex (obj->getVertex (i)); |
835 else |
827 else |
836 for (short i = numverts - 1; i >= 0; --i) |
828 for (int i = numverts - 1; i >= 0; --i) |
837 compileVertex (obj->m_coords[i]); |
829 compileVertex (obj->getVertex (i)); |
838 |
830 |
839 glEnd(); |
831 glEnd(); |
840 } |
832 } |
841 |
833 |
842 // ============================================================================= |
834 // ============================================================================= |
1753 } |
1745 } |
1754 |
1746 |
1755 // ============================================================================= |
1747 // ============================================================================= |
1756 // ----------------------------------------------------------------------------- |
1748 // ----------------------------------------------------------------------------- |
1757 void GLRenderer::zoomToFit() |
1749 void GLRenderer::zoomToFit() |
1758 { if (file() == null) |
1750 { if (file() == null || m_width == -1 || m_height == -1) |
1759 { setZoom (30.0f); |
1751 { setZoom (30.0f); |
1760 return; |
1752 return; |
1761 } |
1753 } |
1762 |
1754 |
1763 bool lastfilled = false; |
1755 bool lastfilled = false; |