62 ConfigOption (bool HighlightObjectBelowCursor = true) |
62 ConfigOption (bool HighlightObjectBelowCursor = true) |
63 ConfigOption (bool DrawSurfaces = true) |
63 ConfigOption (bool DrawSurfaces = true) |
64 ConfigOption (bool DrawEdgeLines = true) |
64 ConfigOption (bool DrawEdgeLines = true) |
65 ConfigOption (bool DrawConditionalLines = true) |
65 ConfigOption (bool DrawConditionalLines = true) |
66 |
66 |
|
67 const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; |
|
68 |
67 // ============================================================================= |
69 // ============================================================================= |
68 // |
70 // |
69 GLRenderer::GLRenderer(Model* model, QWidget* parent) : |
71 GLRenderer::GLRenderer(Model* model, QWidget* parent) : |
70 QGLWidget {parent}, |
72 QGLWidget {parent}, |
71 HierarchyElement {parent}, |
73 HierarchyElement {parent}, |
73 { |
75 { |
74 m_camera = (Camera) m_config->camera(); |
76 m_camera = (Camera) m_config->camera(); |
75 m_compiler = new GLCompiler (this); |
77 m_compiler = new GLCompiler (this); |
76 m_toolTipTimer = new QTimer (this); |
78 m_toolTipTimer = new QTimer (this); |
77 m_toolTipTimer->setSingleShot (true); |
79 m_toolTipTimer->setSingleShot (true); |
78 m_thinBorderPen = QPen (QColor (0, 0, 0, 208), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
|
79 m_thinBorderPen.setWidth (1); |
|
80 setAcceptDrops (true); |
80 setAcceptDrops (true); |
81 connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); |
81 connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); |
82 resetAllAngles(); |
82 resetAllAngles(); |
83 m_needZoomToFit = true; |
83 m_needZoomToFit = true; |
84 |
84 |
309 // The picking scene requires a black background. |
309 // The picking scene requires a black background. |
310 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
310 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
311 } |
311 } |
312 } |
312 } |
313 |
313 |
|
314 QColor GLRenderer::backgroundColor() const |
|
315 { |
|
316 return m_backgroundColor; |
|
317 } |
|
318 |
314 // ============================================================================= |
319 // ============================================================================= |
315 // |
320 // |
316 void GLRenderer::refresh() |
321 void GLRenderer::refresh() |
317 { |
322 { |
318 update(); |
323 update(); |
591 } |
588 } |
592 |
589 |
593 void GLRenderer::overpaint(QPainter &painter) |
590 void GLRenderer::overpaint(QPainter &painter) |
594 { |
591 { |
595 // Draw a background for the selected camera |
592 // Draw a background for the selected camera |
596 painter.setPen(m_thinBorderPen); |
593 painter.setPen(thinBorderPen); |
597 painter.setBrush(QBrush {QColor {0, 128, 160, 128}}); |
594 painter.setBrush(QBrush {QColor {0, 128, 160, 128}}); |
598 painter.drawRect(m_cameraIcons[camera()].hitRect); |
595 painter.drawRect(m_cameraIcons[camera()].hitRect); |
599 |
596 |
600 // Draw the camera icons |
597 // Draw the camera icons |
601 for (const CameraIcon& info : m_cameraIcons) |
598 for (const CameraIcon& info : m_cameraIcons) |
621 QFontMetrics metrics {QFont {}}; |
618 QFontMetrics metrics {QFont {}}; |
622 int margin = 4; |
619 int margin = 4; |
623 painter.setPen(textPen()); |
620 painter.setPen(textPen()); |
624 painter.drawText(QPoint {margin, height() - margin - metrics.descent()}, currentCameraName()); |
621 painter.drawText(QPoint {margin, height() - margin - metrics.descent()}, currentCameraName()); |
625 } |
622 } |
626 } |
|
627 |
|
628 // ============================================================================= |
|
629 // |
|
630 void GLRenderer::drawPoint(QPainter& painter, QPointF pos, QColor color) const |
|
631 { |
|
632 int pointSize = 8; |
|
633 QPen pen = m_thinBorderPen; |
|
634 pen.setWidth(1); |
|
635 painter.setPen(pen); |
|
636 painter.setBrush(color); |
|
637 painter.drawEllipse(pos.x() - pointSize / 2, pos.y() - pointSize / 2, pointSize, pointSize); |
|
638 } |
|
639 |
|
640 void GLRenderer::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d) |
|
641 { |
|
642 drawBlipCoordinates (painter, pos3d, convert3dTo2d (pos3d)); |
|
643 } |
|
644 |
|
645 void GLRenderer::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) |
|
646 { |
|
647 painter.setPen (textPen()); |
|
648 painter.drawText (pos.x(), pos.y() - 8, pos3d.toString (true)); |
|
649 } |
623 } |
650 |
624 |
651 // ============================================================================= |
625 // ============================================================================= |
652 // |
626 // |
653 void GLRenderer::mouseReleaseEvent(QMouseEvent* event) |
627 void GLRenderer::mouseReleaseEvent(QMouseEvent* event) |