Skip to content

lidartablemodel

LidarTableModel #

Bases: QAbstractTableModel

Model class providing access to data to update the table view.

Source code in cogip/utils/lidartablemodel.py
 4
 5
 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class LidarTableModel(QtCore.QAbstractTableModel):
    """
    Model class providing access to data to update the table view.
    """

    headers = ["Angle", "Distance", "Intensity"]

    def __init__(
        self,
        angle_values: list[float],
        distance_values: list[int],
        intensity_values: list[int],
        distance_color: QtGui.QColor,
        intensity_color: QtGui.QColor,
        nb_angles: int = 360,
    ):
        """Class constructor

        Arguments:
            angle_values: angle values list
            distance_values: distance values list
            intensity_values: intensity values list
            distance_color: distance color
            intensity_color: intensity color
            nb_angles: number of angles
        """
        super().__init__()
        self.angle_values = angle_values
        self.distance_values = distance_values
        self.intensity_values = intensity_values
        self.distance_color = distance_color
        self.intensity_color = intensity_color
        self.nb_angles = nb_angles

    def rowCount(self, parent):
        return self.nb_angles

    def columnCount(self, parent):
        return 3

    def data(self, index, role):
        row, column = index.row(), index.column()

        if role == QtCore.Qt.BackgroundRole:
            if column == 0:
                return QtGui.QColor("lightgray")
            if column == 1:
                return self.distance_color
            if column == 2:
                return self.intensity_color
            return None

        if role == QtCore.Qt.TextAlignmentRole:
            return QtCore.Qt.AlignRight

        if role == QtCore.Qt.DisplayRole:
            if column == 0:
                return self.angle_values[row]
            if column == 1:
                return self.distance_values[row]
            if column == 2:
                return self.intensity_values[row]
            return None

        return None

    def headerData(self, section, orientation, role):
        if role == QtCore.Qt.BackgroundRole:
            return QtGui.QColor("lightgray")

        if role == QtCore.Qt.FontRole:
            font = QtWidgets.QApplication.font()
            font.setPointSize(font.pointSize() - 2)
            return font

        if role != QtCore.Qt.DisplayRole or orientation != QtCore.Qt.Horizontal:
            return None
        return self.headers[section]

__init__(angle_values, distance_values, intensity_values, distance_color, intensity_color, nb_angles=360) #

Class constructor

Parameters:

Name Type Description Default
angle_values list[float]

angle values list

required
distance_values list[int]

distance values list

required
intensity_values list[int]

intensity values list

required
distance_color QColor

distance color

required
intensity_color QColor

intensity color

required
nb_angles int

number of angles

360
Source code in cogip/utils/lidartablemodel.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(
    self,
    angle_values: list[float],
    distance_values: list[int],
    intensity_values: list[int],
    distance_color: QtGui.QColor,
    intensity_color: QtGui.QColor,
    nb_angles: int = 360,
):
    """Class constructor

    Arguments:
        angle_values: angle values list
        distance_values: distance values list
        intensity_values: intensity values list
        distance_color: distance color
        intensity_color: intensity color
        nb_angles: number of angles
    """
    super().__init__()
    self.angle_values = angle_values
    self.distance_values = distance_values
    self.intensity_values = intensity_values
    self.distance_color = distance_color
    self.intensity_color = intensity_color
    self.nb_angles = nb_angles