MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / drawData

Method drawData

app/src/UI/Widgets/Plot3D.cpp:620–687  ·  view source on GitHub ↗

* @brief Renders the 3D plot foreground. */

Source from the content-addressed store, hash-verified

618 * @brief Renders the 3D plot foreground.
619 */
620void Widgets::Plot3D::drawData()
621{
622 const auto& data = UI::Dashboard::instance().plotData3D(m_index);
623 if (data.size() <= 0)
624 return;
625
626 QVector3D min = data.front();
627 QVector3D max = data.front();
628 for (const auto& p : data) {
629 min.setX(qMin(min.x(), p.x()));
630 min.setY(qMin(min.y(), p.y()));
631 min.setZ(qMin(min.z(), p.z()));
632 max.setX(qMax(max.x(), p.x()));
633 max.setY(qMax(max.y(), p.y()));
634 max.setZ(qMax(max.z(), p.z()));
635 }
636
637 if (m_minPoint != min || m_maxPoint != max) {
638 m_minPoint = min;
639 m_maxPoint = max;
640 m_targetCenter = (min + max) * 0.5f;
641 Q_EMIT rangeChanged();
642 }
643
644 if (!m_centerInitialized) {
645 m_centerPoint = m_targetCenter;
646 m_worldScale = m_targetWorldScale;
647 m_centerInitialized = true;
648 }
649
650 else if (m_autoCenter)
651 m_centerPoint += (m_targetCenter - m_centerPoint) * 0.08f;
652
653 QMatrix4x4 matrix;
654 matrix.perspective(45.0f, float(width()) / height(), 0.1f, 100.0f);
655 matrix.translate(m_cameraOffsetX, m_cameraOffsetY, m_cameraOffsetZ);
656
657 if (anaglyphEnabled()) {
658 auto eyes = eyeTransformations(matrix);
659
660 eyes.first.rotate(m_cameraAngleX, 1, 0, 0);
661 eyes.first.rotate(m_cameraAngleY, 0, 1, 0);
662 eyes.first.rotate(m_cameraAngleZ, 0, 0, 1);
663 eyes.first.scale(m_worldScale);
664 eyes.first.translate(-m_centerPoint);
665
666 eyes.second.rotate(m_cameraAngleX, 1, 0, 0);
667 eyes.second.rotate(m_cameraAngleY, 0, 1, 0);
668 eyes.second.rotate(m_cameraAngleZ, 0, 0, 1);
669 eyes.second.scale(m_worldScale);
670 eyes.second.translate(-m_centerPoint);
671
672 m_plotImg[0] = renderData(eyes.first, data);
673 m_plotImg[1] = renderData(eyes.second, data);
674 }
675
676 else {
677 matrix.rotate(m_cameraAngleX, 1, 0, 0);

Callers

nothing calls this directly

Calls 5

xMethod · 0.80
translateMethod · 0.80
scaleMethod · 0.80
sizeMethod · 0.45
rotateMethod · 0.45

Tested by

no test coverage detected