src/glrenderer.cpp

changeset 1192
317f4ce38f3f
parent 1186
eae8b3bce545
child 1201
a3455a81c5c9
equal deleted inserted replaced
1191:26b3f1e80a9c 1192:317f4ce38f3f
63 {"Back camera", {backCameraMatrix, X, Y, true, true, true}}, // back 63 {"Back camera", {backCameraMatrix, X, Y, true, true, true}}, // back
64 {"Right camera", {rightCameraMatrix, Z, Y, false, true, true}}, // right 64 {"Right camera", {rightCameraMatrix, Z, Y, false, true, true}}, // right
65 {"Free camera", GLCamera::FreeCamera}, // free 65 {"Free camera", GLCamera::FreeCamera}, // free
66 } 66 }
67 { 67 {
68 m_camera = (Camera) m_config->camera(); 68 m_camera = (Camera) configuration().camera();
69 m_compiler = new GLCompiler (this); 69 m_compiler = new GLCompiler (this);
70 m_toolTipTimer = new QTimer (this); 70 m_toolTipTimer = new QTimer (this);
71 m_toolTipTimer->setSingleShot (true); 71 m_toolTipTimer->setSingleShot (true);
72 setAcceptDrops (true); 72 setAcceptDrops (true);
73 connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (showCameraIconTooltip())); 73 connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (showCameraIconTooltip()));
175 glPolygonOffset (1.0f, 1.0f); 175 glPolygonOffset (1.0f, 1.0f);
176 glEnable (GL_DEPTH_TEST); 176 glEnable (GL_DEPTH_TEST);
177 glShadeModel (GL_SMOOTH); 177 glShadeModel (GL_SMOOTH);
178 glEnable (GL_MULTISAMPLE); 178 glEnable (GL_MULTISAMPLE);
179 179
180 if (m_config->antiAliasedLines()) 180 if (configuration().antiAliasedLines())
181 { 181 {
182 glEnable (GL_LINE_SMOOTH); 182 glEnable (GL_LINE_SMOOTH);
183 glEnable (GL_POLYGON_SMOOTH); 183 glEnable (GL_POLYGON_SMOOTH);
184 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); 184 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
185 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); 185 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
244 // 244 //
245 void GLRenderer::initializeGL() 245 void GLRenderer::initializeGL()
246 { 246 {
247 initializeOpenGLFunctions(); 247 initializeOpenGLFunctions();
248 setBackground(); 248 setBackground();
249 glLineWidth (m_config->lineThickness()); 249 glLineWidth (configuration().lineThickness());
250 glLineStipple (1, 0x6666); 250 glLineStipple (1, 0x6666);
251 setAutoFillBackground (false); 251 setAutoFillBackground (false);
252 setMouseTracking (true); 252 setMouseTracking (true);
253 setFocusPolicy (Qt::WheelFocus); 253 setFocusPolicy (Qt::WheelFocus);
254 m_compiler->initialize(); 254 m_compiler->initialize();
313 void GLRenderer::setBackground() 313 void GLRenderer::setBackground()
314 { 314 {
315 if (not m_isDrawingSelectionScene) 315 if (not m_isDrawingSelectionScene)
316 { 316 {
317 // Otherwise use the background that the user wants. 317 // Otherwise use the background that the user wants.
318 QColor color = m_config->backgroundColor(); 318 QColor color = configuration().backgroundColor();
319 319
320 if (color.isValid()) 320 if (color.isValid())
321 { 321 {
322 color.setAlpha(255); 322 color.setAlpha(255);
323 m_useDarkBackground = luma(color) < 80; 323 m_useDarkBackground = luma(color) < 80;
361 { 361 {
362 m_needZoomToFit = false; 362 m_needZoomToFit = false;
363 zoomAllToFit(); 363 zoomAllToFit();
364 } 364 }
365 365
366 if (m_config->drawWireframe() and not m_isDrawingSelectionScene) 366 if (configuration().drawWireframe() and not m_isDrawingSelectionScene)
367 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 367 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
368 368
369 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 369 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
370 glEnable(GL_DEPTH_TEST); 370 glEnable(GL_DEPTH_TEST);
371 371
372 if (m_config->lighting()) 372 if (configuration().lighting())
373 glEnable(GL_LIGHTING); 373 glEnable(GL_LIGHTING);
374 else 374 else
375 glDisable(GL_LIGHTING); 375 glDisable(GL_LIGHTING);
376 376
377 if (camera() != Camera::Free) 377 if (camera() != Camera::Free)
408 drawVbos (VboClass::Lines, VboSubclass::PickColors); 408 drawVbos (VboClass::Lines, VboSubclass::PickColors);
409 drawVbos (VboClass::ConditionalLines, VboSubclass::PickColors); 409 drawVbos (VboClass::ConditionalLines, VboSubclass::PickColors);
410 } 410 }
411 else 411 else
412 { 412 {
413 if (m_config->bfcRedGreenView()) 413 if (configuration().bfcRedGreenView())
414 { 414 {
415 glEnable (GL_CULL_FACE); 415 glEnable (GL_CULL_FACE);
416 glCullFace (GL_BACK); 416 glCullFace (GL_BACK);
417 drawVbos (VboClass::Triangles, VboSubclass::BfcFrontColors); 417 drawVbos (VboClass::Triangles, VboSubclass::BfcFrontColors);
418 drawVbos (VboClass::Quads, VboSubclass::BfcFrontColors); 418 drawVbos (VboClass::Quads, VboSubclass::BfcFrontColors);
423 } 423 }
424 else 424 else
425 { 425 {
426 VboSubclass colors; 426 VboSubclass colors;
427 427
428 if (m_config->randomColors()) 428 if (configuration().randomColors())
429 colors = VboSubclass::RandomColors; 429 colors = VboSubclass::RandomColors;
430 else 430 else
431 colors = VboSubclass::RegularColors; 431 colors = VboSubclass::RegularColors;
432 432
433 drawVbos (VboClass::Triangles, colors); 433 drawVbos (VboClass::Triangles, colors);
437 drawVbos (VboClass::Lines, VboSubclass::RegularColors); 437 drawVbos (VboClass::Lines, VboSubclass::RegularColors);
438 glEnable (GL_LINE_STIPPLE); 438 glEnable (GL_LINE_STIPPLE);
439 drawVbos (VboClass::ConditionalLines, VboSubclass::RegularColors); 439 drawVbos (VboClass::ConditionalLines, VboSubclass::RegularColors);
440 glDisable (GL_LINE_STIPPLE); 440 glDisable (GL_LINE_STIPPLE);
441 441
442 if (m_config->drawAxes()) 442 if (configuration().drawAxes())
443 { 443 {
444 glDisableClientState (GL_NORMAL_ARRAY); 444 glDisableClientState (GL_NORMAL_ARRAY);
445 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); 445 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo);
446 glVertexPointer (3, GL_FLOAT, 0, NULL); 446 glVertexPointer (3, GL_FLOAT, 0, NULL);
447 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); 447 glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo);
471 * - colors determines what VBO subclass to use for colors 471 * - colors determines what VBO subclass to use for colors
472 */ 472 */
473 void GLRenderer::drawVbos(VboClass surface, VboSubclass colors) 473 void GLRenderer::drawVbos(VboClass surface, VboSubclass colors)
474 { 474 {
475 // Filter this through some configuration options 475 // Filter this through some configuration options
476 if ((isOneOf(surface, VboClass::Quads, VboClass::Triangles) and m_config->drawSurfaces() == false) 476 if ((isOneOf(surface, VboClass::Quads, VboClass::Triangles) and configuration().drawSurfaces() == false)
477 or (surface == VboClass::Lines and m_config->drawEdgeLines() == false) 477 or (surface == VboClass::Lines and configuration().drawEdgeLines() == false)
478 or (surface == VboClass::ConditionalLines and m_config->drawConditionalLines() == false)) 478 or (surface == VboClass::ConditionalLines and configuration().drawConditionalLines() == false))
479 { 479 {
480 return; 480 return;
481 } 481 }
482 482
483 GLenum type; 483 GLenum type;
694 { 694 {
695 // The edit mode may forbid the free camera. 695 // The edit mode may forbid the free camera.
696 if (freeCameraAllowed() or camera != Camera::Free) 696 if (freeCameraAllowed() or camera != Camera::Free)
697 { 697 {
698 m_camera = camera; 698 m_camera = camera;
699 m_config->setCamera(static_cast<int>(camera)); 699 configuration().setCamera(static_cast<int>(camera));
700 } 700 }
701 } 701 }
702 702
703 /* 703 /*
704 * Returns the set of objects found in the specified pixel area. 704 * Returns the set of objects found in the specified pixel area.
785 if (m_isDrawingSelectionScene) 785 if (m_isDrawingSelectionScene)
786 { 786 {
787 glDisable(GL_DITHER); 787 glDisable(GL_DITHER);
788 788
789 // Use particularly thick lines while picking ease up selecting lines. 789 // Use particularly thick lines while picking ease up selecting lines.
790 glLineWidth(qMax<double>(m_config->lineThickness(), 6.5)); 790 glLineWidth(qMax<double>(configuration().lineThickness(), 6.5));
791 } 791 }
792 else 792 else
793 { 793 {
794 glEnable(GL_DITHER); 794 glEnable(GL_DITHER);
795 795
796 // Restore line thickness 796 // Restore line thickness
797 glLineWidth(m_config->lineThickness()); 797 glLineWidth(configuration().lineThickness());
798 } 798 }
799 } 799 }
800 800
801 // ============================================================================= 801 // =============================================================================
802 // 802 //
934 934
935 // ============================================================================= 935 // =============================================================================
936 // 936 //
937 void GLRenderer::highlightCursorObject() 937 void GLRenderer::highlightCursorObject()
938 { 938 {
939 if (not m_config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) 939 if (not configuration().highlightObjectBelowCursor() and objectAtCursor() == nullptr)
940 return; 940 return;
941 941
942 LDObject* newObject = nullptr; 942 LDObject* newObject = nullptr;
943 LDObject* oldObject = objectAtCursor(); 943 LDObject* oldObject = objectAtCursor();
944 qint32 newIndex; 944 qint32 newIndex;
945 945
946 if (m_isCameraMoving or not m_config->highlightObjectBelowCursor()) 946 if (m_isCameraMoving or not configuration().highlightObjectBelowCursor())
947 { 947 {
948 newIndex = 0; 948 newIndex = 0;
949 } 949 }
950 else 950 else
951 { 951 {

mercurial