def paintSection(self, painter, rect, logicalIndex):
        '''
        The method paint the robot or capability images in the backgroud of the cell.
        :see: U{QtGui.QHeaderView.paintSection()<https://srinikom.github.io/pyside-docs/PySide/QtGui/QHeaderView.html#PySide.QtGui.PySide.QtGui.QHeaderView.paintSection>}
        '''
        painter.save()
        QHeaderView.paintSection(self, painter, rect, logicalIndex)
        painter.restore()

        if logicalIndex in range(len(
                self._data)) and self._data[logicalIndex]['images']:
            if len(self._data[logicalIndex]['images']) == 1:
                pix = self._data[logicalIndex]['images'][0]
                pix = pix.scaled(rect.width(),
                                 rect.height() - 20, Qt.KeepAspectRatio,
                                 Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, rect, 5, pix)
            elif len(self._data[logicalIndex]['images']) > 1:
                new_rect = QRect(rect.left(), rect.top(), rect.width(),
                                 (rect.height() - 20) / 2.)
                pix = self._data[logicalIndex]['images'][0]
                pix = pix.scaled(new_rect.width(), new_rect.height(),
                                 Qt.KeepAspectRatio, Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, new_rect, 5, pix)
                new_rect = QRect(rect.left(),
                                 rect.top() + new_rect.height(), rect.width(),
                                 new_rect.height())
                pix = self._data[logicalIndex]['images'][1]
                pix = pix.scaled(new_rect.width(), new_rect.height(),
                                 Qt.KeepAspectRatio, Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, new_rect, 5, pix)
 def __init__(self, orientation, parent=None):
     QHeaderView.__init__(self, orientation, parent)
     self._data = []
     '''@ivar: a list with dictionaries C{dict('cfgs': [], 'name': str, 'displayed_name': str, 'type': str, 'description': str, 'images': [QtGui.QPixmap])}'''
     if orientation == Qt.Horizontal:
         self.setDefaultAlignment(Qt.AlignHCenter | Qt.AlignBottom)
     elif orientation == Qt.Vertical:
         self.setDefaultAlignment(Qt.AlignLeft | Qt.AlignBottom)
     self.controlWidget = []
 def __init__(self, orientation, parent=None):
     QHeaderView.__init__(self, orientation, parent)
     self._data = []
     '''@ivar: a list with dictionaries C{dict('cfgs': [], 'name': str, 'displayed_name': str, 'type': str, 'description': str, 'images': [QtGui.QPixmap])}'''
     if orientation == Qt.Horizontal:
         self.setDefaultAlignment(Qt.AlignHCenter | Qt.AlignBottom)
     elif orientation == Qt.Vertical:
         self.setDefaultAlignment(Qt.AlignLeft | Qt.AlignBottom)
     self.controlWidget = []
 def mousePressEvent(self, event):
     '''
     Interpret the mouse events to send the description of a robot or capability
     if the user click on the header.
     '''
     QHeaderView.mousePressEvent(self, event)
     index = self.logicalIndexAt(event.pos())
     if index in range(len(self._data)):
         suffix = 'Capability'
         if self.orientation() == Qt.Horizontal:
             suffix = 'Robot'
         title = ' - '.join([self._data[index]['name'], suffix])
         text = self._data[index]['description']
         try:
             from docutils import examples
             text = examples.html_body(text)
         except:
             import traceback
             rospy.logwarn("Error while generate description for %s: %s", self._data[index]['name'], traceback.format_exc(1))
         self.description_requested_signal.emit(title, text)
    def paintSection(self, painter, rect, logicalIndex):
        '''
        The method paint the robot or capability images in the backgroud of the cell.
        @see: U{QtGui.QHeaderView.paintSection()<https://srinikom.github.io/pyside-docs/PySide/QtGui/QHeaderView.html#PySide.QtGui.PySide.QtGui.QHeaderView.paintSection>}
        '''
        painter.save()
        QHeaderView.paintSection(self, painter, rect, logicalIndex)
        painter.restore()

        if logicalIndex in range(len(self._data)) and self._data[logicalIndex]['images']:
            if len(self._data[logicalIndex]['images']) == 1:
                pix = self._data[logicalIndex]['images'][0]
                pix = pix.scaled(rect.width(), rect.height() - 20, Qt.KeepAspectRatio, Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, rect, 5, pix)
            elif len(self._data[logicalIndex]['images']) > 1:
                new_rect = QRect(rect.left(), rect.top(), rect.width(), (rect.height() - 20) / 2.)
                pix = self._data[logicalIndex]['images'][0]
                pix = pix.scaled(new_rect.width(), new_rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, new_rect, 5, pix)
                new_rect = QRect(rect.left(), rect.top() + new_rect.height(), rect.width(), new_rect.height())
                pix = self._data[logicalIndex]['images'][1]
                pix = pix.scaled(new_rect.width(), new_rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, new_rect, 5, pix)