Skip to content

impact

ImpactEntity #

Bases: QEntity

QEntity used to visualize to points detected by sensors.

It is represented with QSphereMesh, its radius and color are configurable in the constructor.

Source code in cogip/entities/impact.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class ImpactEntity(Qt3DCore.QEntity):
    """
    `QEntity` used to visualize to points detected by sensors.

    It is represented with [`QSphereMesh`](https://doc.qt.io/qtforpython-6/PySide6/Qt3DExtras/QSphereMesh.html),
    its radius and color are configurable in the constructor.
    """

    def __init__(self, radius: float = 50, color: QtCore.Qt.GlobalColor = QtCore.Qt.red):
        """
        Class constructor.

        Arguments:
            radius: Radius of the sphere
            color: Color of the sphere
        """
        super().__init__()

        self.mesh = Qt3DExtras.QSphereMesh()
        self.mesh.setRadius(radius)
        self.addComponent(self.mesh)

        self.material = Qt3DExtras.QPhongMaterial()
        self.material.setDiffuse(QtGui.QColor(color))
        self.addComponent(self.material)

        self.transform = Qt3DCore.QTransform()
        self.addComponent(self.transform)
        self.setEnabled(False)

__init__(radius=50, color=QtCore.Qt.red) #

Class constructor.

Parameters:

Name Type Description Default
radius float

Radius of the sphere

50
color GlobalColor

Color of the sphere

red
Source code in cogip/entities/impact.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(self, radius: float = 50, color: QtCore.Qt.GlobalColor = QtCore.Qt.red):
    """
    Class constructor.

    Arguments:
        radius: Radius of the sphere
        color: Color of the sphere
    """
    super().__init__()

    self.mesh = Qt3DExtras.QSphereMesh()
    self.mesh.setRadius(radius)
    self.addComponent(self.mesh)

    self.material = Qt3DExtras.QPhongMaterial()
    self.material.setDiffuse(QtGui.QColor(color))
    self.addComponent(self.material)

    self.transform = Qt3DCore.QTransform()
    self.addComponent(self.transform)
    self.setEnabled(False)