def updateCapabilities(self, masteruri, cfg_name, description): ''' Updates the capabilities view. @param masteruri: the ROS master URI of updated ROS master. @type masteruri: C{str} @param cfg_name: The name of the node provided the capabilities description. @type cfg_name: C{str} @param description: The capabilities description object. @type description: U{multimaster_msgs_fkie.srv.ListDescription<http://docs.ros.org/api/multimaster_msgs_fkie/html/srv/ListDescription.html>} Response ''' # if it is a new masteruri add a new column robot_index = self._robotHeader.index(masteruri) robot_name = description.robot_name if description.robot_name else nm.nameres().mastername(masteruri) # append a new robot new_robot = False if robot_index == -1: robot_index = self._robotHeader.insertSortedItem(masteruri, robot_name) self.insertColumn(robot_index) # robot_index = self.columnCount()-1 # self._robotHeader.insertItem(robot_index) self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, description.robot_descr.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), description.robot_images) item = QTableWidgetItem() item.setSizeHint(QSize(96, 96)) self.setHorizontalHeaderItem(robot_index, item) self.horizontalHeaderItem(robot_index).setText(robot_name) new_robot = True else: # update self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, description.robot_descr.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), description.robot_images) # set the capabilities for c in description.capabilities: cap_index = self._capabilityHeader.index(c.name.decode(sys.getfilesystemencoding())) if cap_index == -1 or new_robot: if cap_index == -1: # append a new capability cap_index = self._capabilityHeader.insertSortedItem(c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding())) self.insertRow(cap_index) self.setRowHeight(cap_index, 96) self._capabilityHeader.setDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images) item = QTableWidgetItem() item.setSizeHint(QSize(96, 96)) self.setVerticalHeaderItem(cap_index, item) self.verticalHeaderItem(cap_index).setText(c.name.decode(sys.getfilesystemencoding())) else: self._capabilityHeader.setDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images) # add the capability control widget controlWidget = CapabilityControlWidget(masteruri, cfg_name, c.namespace, c.nodes) controlWidget.start_nodes_signal.connect(self._start_nodes) controlWidget.stop_nodes_signal.connect(self._stop_nodes) self.setCellWidget(cap_index, robot_index, controlWidget) self._capabilityHeader.controlWidget.insert(cap_index, controlWidget) else: self._capabilityHeader.updateDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images) try: self.cellWidget(cap_index, robot_index).updateNodes(cfg_name, c.namespace, c.nodes) except: import traceback print traceback.format_exc()
def cb_points(self, p): for i in range(len(p.ids)): self.tracks[p.ids[i]].append( (int(p.x[i]),int(p.y[i])) ) if p.ids[i] not in self.ids: row = self.id_table.rowCount() self.id_table.insertRow(row) i0 = QTableWidgetItem() i1 = QTableWidgetItem() i0.setData(Qt.DisplayRole,p.ids[i]) i1.setData(Qt.DisplayRole,0) i0.setFlags(i0.flags() ^ Qt.ItemIsEditable) self.id_table.setItem(row,0,i0) self.id_table.setItem(row,1,i1) self.ids[p.ids[i]] = [i0,i1]
def updateCapabilities(self, masteruri, cfg_name, description): ''' Updates the capabilities view. :param str masteruri: the ROS master URI of updated ROS master. :param str cfg_name: The name of the node provided the capabilities description. :param description: The capabilities description object. :type description: fkie_node_manager_daemon.launch_description.LaunchDescription ''' # if it is a new masteruri add a new column robot_name = description.robot_name robot_index = self._robotHeader.index(masteruri) # append a new robot descr_utf8 = utf8(description.robot_descr.replace("\\n ", "\n")) if robot_index == -1: robot_index = self._robotHeader.insertSortedItem( masteruri, robot_name) self.insertColumn(robot_index) self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, descr_utf8, description.robot_images) item = QTableWidgetItem() item.setSizeHint(QSize(96, 96)) self.setHorizontalHeaderItem(robot_index, item) if robot_name: self.horizontalHeaderItem(robot_index).setText(robot_name) else: # update self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, descr_utf8, description.robot_images) # set the capabilities for c in description.capabilities: cname = utf8(c.name) cdescription = utf8(c.description.replace("\\n ", "\n")) cap_index = self._capabilityHeader.index(cname) if cap_index == -1 or self.cellWidget(cap_index, robot_index) is None: if cap_index == -1: # append a new capability cap_index = self._capabilityHeader.insertSortedItem( cname, cname) self.insertRow(cap_index) self.setRowHeight(cap_index, 96) self._capabilityHeader.setDescription( cap_index, cfg_name, cname, cname, c.type, cdescription, c.images) item = QTableWidgetItem() item.setSizeHint(QSize(96, 96)) self.setVerticalHeaderItem(cap_index, item) self.verticalHeaderItem(cap_index).setText(cname) else: self._capabilityHeader.setDescription( cap_index, cfg_name, cname, cname, c.type, cdescription, c.images) # add the capability control widget controlWidget = CapabilityControlWidget( masteruri, cfg_name, c.namespace, c.nodes) controlWidget.start_nodes_signal.connect(self._start_nodes) controlWidget.stop_nodes_signal.connect(self._stop_nodes) self.setCellWidget(cap_index, robot_index, controlWidget) self._capabilityHeader.controlWidget.insert( cap_index, controlWidget) else: self._capabilityHeader.update_description( cap_index, cfg_name, cname, cname, c.type, cdescription, c.images) try: self.cellWidget(cap_index, robot_index).updateNodes( cfg_name, c.namespace, c.nodes) except Exception: import traceback print(traceback.format_exc())
def _update_item(self, row, col, color, string): item = QTableWidgetItem(string) item.setBackground(color) self._widget.findChild(QTableWidget, 'killTable').setItem(row, col, item)
def cb_points(self, p): for i in range(len(p.ids)): self.tracks[p.ids[i]].append((int(p.x[i]), int(p.y[i]))) if p.ids[i] not in self.ids: row = self.id_table.rowCount() self.id_table.insertRow(row) i0 = QTableWidgetItem() i1 = QTableWidgetItem() i0.setData(Qt.DisplayRole, p.ids[i]) i1.setData(Qt.DisplayRole, 0) i0.setFlags(i0.flags() ^ Qt.ItemIsEditable) self.id_table.setItem(row, 0, i0) self.id_table.setItem(row, 1, i1) self.ids[p.ids[i]] = [i0, i1]