76 HierarchyElement (parent), |
76 HierarchyElement (parent), |
77 m_document (nullptr), |
77 m_document (nullptr), |
78 m_initialized (false) |
78 m_initialized (false) |
79 { |
79 { |
80 m_isPicking = false; |
80 m_isPicking = false; |
81 m_camera = (ECamera) m_config->camera(); |
81 m_camera = (ECamera) Config->camera(); |
82 m_drawToolTip = false; |
82 m_drawToolTip = false; |
83 m_currentEditMode = AbstractEditMode::createByType (this, EditModeType::Select); |
83 m_currentEditMode = AbstractEditMode::createByType (this, EditModeType::Select); |
84 m_panning = false; |
84 m_panning = false; |
85 m_compiler = new GLCompiler (this); |
85 m_compiler = new GLCompiler (this); |
86 m_objectAtCursor = nullptr; |
86 m_objectAtCursor = nullptr; |
172 glPolygonOffset (1.0f, 1.0f); |
172 glPolygonOffset (1.0f, 1.0f); |
173 glEnable (GL_DEPTH_TEST); |
173 glEnable (GL_DEPTH_TEST); |
174 glShadeModel (GL_SMOOTH); |
174 glShadeModel (GL_SMOOTH); |
175 glEnable (GL_MULTISAMPLE); |
175 glEnable (GL_MULTISAMPLE); |
176 |
176 |
177 if (m_config->antiAliasedLines()) |
177 if (Config->antiAliasedLines()) |
178 { |
178 { |
179 glEnable (GL_LINE_SMOOTH); |
179 glEnable (GL_LINE_SMOOTH); |
180 glEnable (GL_POLYGON_SMOOTH); |
180 glEnable (GL_POLYGON_SMOOTH); |
181 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
181 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
182 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); |
182 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); |
262 { |
262 { |
263 #ifdef USE_QT5 |
263 #ifdef USE_QT5 |
264 initializeOpenGLFunctions(); |
264 initializeOpenGLFunctions(); |
265 #endif |
265 #endif |
266 setBackground(); |
266 setBackground(); |
267 glLineWidth (m_config->lineThickness()); |
267 glLineWidth (Config->lineThickness()); |
268 glLineStipple (1, 0x6666); |
268 glLineStipple (1, 0x6666); |
269 setAutoFillBackground (false); |
269 setAutoFillBackground (false); |
270 setMouseTracking (true); |
270 setMouseTracking (true); |
271 setFocusPolicy (Qt::WheelFocus); |
271 setFocusPolicy (Qt::WheelFocus); |
272 compiler()->initialize(); |
272 compiler()->initialize(); |
329 { |
329 { |
330 glClearColor (0.0f, 0.0f, 0.0f, 1.0f); |
330 glClearColor (0.0f, 0.0f, 0.0f, 1.0f); |
331 return; |
331 return; |
332 } |
332 } |
333 |
333 |
334 QColor color = m_config->backgroundColor(); |
334 QColor color = Config->backgroundColor(); |
335 |
335 |
336 if (not color.isValid()) |
336 if (not color.isValid()) |
337 return; |
337 return; |
338 |
338 |
339 color.setAlpha (255); |
339 color.setAlpha (255); |
390 { |
390 { |
391 currentDocumentData().needZoomToFit = false; |
391 currentDocumentData().needZoomToFit = false; |
392 zoomAllToFit(); |
392 zoomAllToFit(); |
393 } |
393 } |
394 |
394 |
395 if (m_config->drawWireframe() and not isPicking()) |
395 if (Config->drawWireframe() and not isPicking()) |
396 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
396 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
397 |
397 |
398 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
398 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
399 glEnable (GL_DEPTH_TEST); |
399 glEnable (GL_DEPTH_TEST); |
400 |
400 |
444 drawVbos (LinesVbo, PickColorsVboComplement, GL_LINES); |
444 drawVbos (LinesVbo, PickColorsVboComplement, GL_LINES); |
445 drawVbos (ConditionalLinesVbo, PickColorsVboComplement, GL_LINES); |
445 drawVbos (ConditionalLinesVbo, PickColorsVboComplement, GL_LINES); |
446 } |
446 } |
447 else |
447 else |
448 { |
448 { |
449 if (m_config->bfcRedGreenView()) |
449 if (Config->bfcRedGreenView()) |
450 { |
450 { |
451 glEnable (GL_CULL_FACE); |
451 glEnable (GL_CULL_FACE); |
452 glCullFace (GL_BACK); |
452 glCullFace (GL_BACK); |
453 drawVbos (TrianglesVbo, BfcFrontColorsVboComplement, GL_TRIANGLES); |
453 drawVbos (TrianglesVbo, BfcFrontColorsVboComplement, GL_TRIANGLES); |
454 drawVbos (QuadsVbo, BfcFrontColorsVboComplement, GL_QUADS); |
454 drawVbos (QuadsVbo, BfcFrontColorsVboComplement, GL_QUADS); |
459 } |
459 } |
460 else |
460 else |
461 { |
461 { |
462 ComplementVboType colors; |
462 ComplementVboType colors; |
463 |
463 |
464 if (m_config->randomColors()) |
464 if (Config->randomColors()) |
465 colors = RandomColorsVboComplement; |
465 colors = RandomColorsVboComplement; |
466 else |
466 else |
467 colors = NormalColorsVboComplement; |
467 colors = NormalColorsVboComplement; |
468 |
468 |
469 drawVbos (TrianglesVbo, colors, GL_TRIANGLES); |
469 drawVbos (TrianglesVbo, colors, GL_TRIANGLES); |
473 drawVbos (LinesVbo, NormalColorsVboComplement, GL_LINES); |
473 drawVbos (LinesVbo, NormalColorsVboComplement, GL_LINES); |
474 glEnable (GL_LINE_STIPPLE); |
474 glEnable (GL_LINE_STIPPLE); |
475 drawVbos (ConditionalLinesVbo, NormalColorsVboComplement, GL_LINES); |
475 drawVbos (ConditionalLinesVbo, NormalColorsVboComplement, GL_LINES); |
476 glDisable (GL_LINE_STIPPLE); |
476 glDisable (GL_LINE_STIPPLE); |
477 |
477 |
478 if (m_config->drawAxes()) |
478 if (Config->drawAxes()) |
479 { |
479 { |
480 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); |
480 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); |
481 glVertexPointer (3, GL_FLOAT, 0, NULL); |
481 glVertexPointer (3, GL_FLOAT, 0, NULL); |
482 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); |
482 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); |
483 glColorPointer (3, GL_FLOAT, 0, NULL); |
483 glColorPointer (3, GL_FLOAT, 0, NULL); |
499 // ============================================================================= |
499 // ============================================================================= |
500 // |
500 // |
501 void GLRenderer::drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type) |
501 void GLRenderer::drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type) |
502 { |
502 { |
503 // Filter this through some configuration options |
503 // Filter this through some configuration options |
504 if ((isOneOf (surface, QuadsVbo, TrianglesVbo) and m_config->drawSurfaces() == false) |
504 if ((isOneOf (surface, QuadsVbo, TrianglesVbo) and Config->drawSurfaces() == false) |
505 or (surface == LinesVbo and m_config->drawEdgeLines() == false) |
505 or (surface == LinesVbo and Config->drawEdgeLines() == false) |
506 or (surface == ConditionalLinesVbo and m_config->drawConditionalLines() == false)) |
506 or (surface == ConditionalLinesVbo and Config->drawConditionalLines() == false)) |
507 { |
507 { |
508 return; |
508 return; |
509 } |
509 } |
510 |
510 |
511 int surfacenum = m_compiler->vboNumber (surface, SurfacesVboComplement); |
511 int surfacenum = m_compiler->vboNumber (surface, SurfacesVboComplement); |
912 // The edit mode may forbid the free camera. |
912 // The edit mode may forbid the free camera. |
913 if (cam == EFreeCamera and not m_currentEditMode->allowFreeCamera()) |
913 if (cam == EFreeCamera and not m_currentEditMode->allowFreeCamera()) |
914 return; |
914 return; |
915 |
915 |
916 m_camera = cam; |
916 m_camera = cam; |
917 m_config->setCamera ((int) cam); |
917 Config->setCamera ((int) cam); |
918 m_window->updateEditModeActions(); |
918 m_window->updateEditModeActions(); |
919 } |
919 } |
920 |
920 |
921 // ============================================================================= |
921 // ============================================================================= |
922 // |
922 // |
1094 if (isPicking()) |
1094 if (isPicking()) |
1095 { |
1095 { |
1096 glDisable (GL_DITHER); |
1096 glDisable (GL_DITHER); |
1097 |
1097 |
1098 // Use particularly thick lines while picking ease up selecting lines. |
1098 // Use particularly thick lines while picking ease up selecting lines. |
1099 glLineWidth (qMax<double> (m_config->lineThickness(), 6.5)); |
1099 glLineWidth (qMax<double> (Config->lineThickness(), 6.5)); |
1100 } |
1100 } |
1101 else |
1101 else |
1102 { |
1102 { |
1103 glEnable (GL_DITHER); |
1103 glEnable (GL_DITHER); |
1104 |
1104 |
1105 // Restore line thickness |
1105 // Restore line thickness |
1106 glLineWidth (m_config->lineThickness()); |
1106 glLineWidth (Config->lineThickness()); |
1107 } |
1107 } |
1108 } |
1108 } |
1109 |
1109 |
1110 // ============================================================================= |
1110 // ============================================================================= |
1111 // |
1111 // |
1538 |
1538 |
1539 // ============================================================================= |
1539 // ============================================================================= |
1540 // |
1540 // |
1541 void GLRenderer::highlightCursorObject() |
1541 void GLRenderer::highlightCursorObject() |
1542 { |
1542 { |
1543 if (not m_config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) |
1543 if (not Config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) |
1544 return; |
1544 return; |
1545 |
1545 |
1546 LDObject* newObject = nullptr; |
1546 LDObject* newObject = nullptr; |
1547 LDObject* oldObject = objectAtCursor(); |
1547 LDObject* oldObject = objectAtCursor(); |
1548 qint32 newIndex; |
1548 qint32 newIndex; |
1549 |
1549 |
1550 if (m_isCameraMoving or not m_config->highlightObjectBelowCursor()) |
1550 if (m_isCameraMoving or not Config->highlightObjectBelowCursor()) |
1551 { |
1551 { |
1552 newIndex = 0; |
1552 newIndex = 0; |
1553 } |
1553 } |
1554 else |
1554 else |
1555 { |
1555 { |