Example #1
0
    def __append_element_to_item(self, parent_item, debug_data):
        """
        Append an elements debug_data to a QStandardItem.

        :type parent_item: python_qt_binding.QtGui.QStandardItem
        :type debug_data: dict or list or int or float or str or bool
        :rtype: python_qt_binding.QtGui.QStandardItem
        """
        if type(debug_data) is list:
            for i, data in enumerate(debug_data):
                child_item = QStandardItem()
                child_item.setText(str(i) + ": ")
                child_item.setEditable(False)
                self.__append_element_to_item(child_item, data)
                parent_item.appendRow(child_item)
        elif type(debug_data) is dict:
            for label, data in debug_data.items():
                child_item = QStandardItem()
                child_item.setText(str(label) + ": ")
                child_item.setEditable(False)
                self.__append_element_to_item(child_item, data)
                parent_item.appendRow(child_item)
        elif type(debug_data) is str or type(debug_data) is int \
                or type(debug_data) is float or type(debug_data) is bool\
                or type(debug_data) is unicode:
            parent_item.setText(parent_item.text() + str(debug_data))
    def update_connect_to_list(self, infer_name):
        self.connect_from_listmodel.clear()
        self.connect_to_listmodel.clear()

        for node in self.dotgraph.get_node_list():
            
            pipeline_item = QStandardItem()
            pipeline_item.setText(node.get_name())
            pipeline_item.setCheckable(True)
            pipeline_item.setCheckState(False)

            if node.get_name() == infer_name.encode('utf-8'):
                continue
            if node.get('nodetype') == 'input':

                self.connect_from_listmodel.appendRow(pipeline_item)

                # self.connect_from_listview.addItem(node.get_name())
            elif node.get('nodetype') == 'output':
                self.connect_to_listmodel.appendRow(pipeline_item)
                # self.connect_to_listview.addItem(node.get_name())
            elif node.get('nodetype') == 'infer':
                if  infer_name in self.get_infer_desc(infer_name)['connect_from']:
                    self.connect_from_listmodel.appendRow(pipeline_item)
                elif  infer_name in self.get_infer_desc(infer_name)['connect_to']:
                    self.connect_to_listmodel.appendRow(pipeline_item)

            
        self.connect_from_listview.setModel(self.connect_from_listmodel)
        self.connect_to_listview.setModel(self.connect_to_listmodel)
Example #3
0
    def _get_result_cb(self, status, res):
        rospy.loginfo("got result!")
        self._blocks_model.setRowCount(0)
        self._blocks_model.setRowCount(len(res.blocks))

        for (i, block) in zip(range(len(res.blocks)), res.blocks):

            # Store in dict
            self.blocks[block.name] = block

            cb = QStandardItem(True)
            cb.setCheckable(True)
            cb.setCheckState(Qt.Checked if block.state.value == conman_msgs.
                             msg.TaskState.RUNNING else Qt.Unchecked)
            cb.setTextAlignment(Qt.AlignHCenter)
            cb.setTristate(True)

            action = QStandardItem(True)
            action.setText("")

            state = QStandardItem(True)
            state.setText(state_map[block.state.value])

            name = QStandardItem(True)
            name.setText(str(block.name))

            self._blocks_model.setItem(i, 0, cb)
            self._blocks_model.setItem(i, 1, action)
            self._blocks_model.setItem(i, 2, state)
            self._blocks_model.setItem(i, 3, name)

        for (i, group) in zip(range(len(res.groups)), res.groups):

            self.groups[group.name] = group

            cb = QStandardItem(True)
            cb.setCheckable(True)
            cb.setCheckState(Qt.Checked)
            cb.setTextAlignment(Qt.AlignHCenter)
            cb.setEnabled(False)

            name = QStandardItem(True)
            name.setText(str(group.name))

            self._groups_model.setItem(i, 0, cb)
            self._groups_model.setItem(i, 3, name)

        self._update_groups()
        self._update_blocks()

        self._widget.blocks_table.resizeColumnsToContents()
        self._widget.blocks_table.horizontalHeader().setStretchLastSection(
            True)
        self._widget.groups_table.resizeColumnsToContents()
        self._widget.groups_table.horizontalHeader().setStretchLastSection(
            True)
Example #4
0
    def _get_result_cb(self, status, res):
        rospy.loginfo("got result!")
        self._blocks_model.setRowCount(0)
        self._blocks_model.setRowCount(len(res.blocks))

        for (i,block) in zip(range(len(res.blocks)),res.blocks):

            # Store in dict
            self.blocks[block.name] = block

            cb = QStandardItem(True)
            cb.setCheckable(True)
            cb.setCheckState(Qt.Checked if block.state.value == conman_msgs.msg.TaskState.RUNNING else Qt.Unchecked)
            cb.setTextAlignment(Qt.AlignHCenter)
            cb.setTristate(True)

            action = QStandardItem(True)
            action.setText("")

            state = QStandardItem(True)
            state.setText(state_map[block.state.value])

            name = QStandardItem(True)
            name.setText(str(block.name))

            self._blocks_model.setItem(i,0,cb)
            self._blocks_model.setItem(i,1,action)
            self._blocks_model.setItem(i,2,state)
            self._blocks_model.setItem(i,3,name)

        for (i,group) in zip(range(len(res.groups)),res.groups):

            self.groups[group.name] = group

            cb = QStandardItem(True)
            cb.setCheckable(True)
            cb.setCheckState(Qt.Checked)
            cb.setTextAlignment(Qt.AlignHCenter)
            cb.setEnabled(False)

            name = QStandardItem(True)
            name.setText(str(group.name))

            self._groups_model.setItem(i,0,cb)
            self._groups_model.setItem(i,3,name)

        self._update_groups()
        self._update_blocks()

        self._widget.blocks_table.resizeColumnsToContents()
        self._widget.blocks_table.horizontalHeader().setStretchLastSection(True)
        self._widget.groups_table.resizeColumnsToContents()
        self._widget.groups_table.horizontalHeader().setStretchLastSection(True)
Example #5
0
    def _create_pipeline(self):

        pipeline_name, okPressed = QInputDialog.getText(
            self._widget, "Create a new pipeline", "new pipeline name:",
            QLineEdit.Normal, "")

        if okPressed != True or pipeline_name == '':
            #Empty name
            return

        pipeline_item = QStandardItem()
        pipeline_item.setText(pipeline_name)
        self._listmodel.appendRow(pipeline_item)

        new_dotgraph = dotparser.generate_dotcode_from_empty(
            self.dotcode_factory, pipeline_name)
        self._dotgraphs.update(new_dotgraph)
        self._current_pipeline_name = pipeline_name
        self._refresh_rosgraph()
Example #6
0
    def _load_pipeline(self):
        self._dotgraphs.clear()
        self._listmodel.clear()

        file_path, _ = QFileDialog.getOpenFileName(
            self._widget, "QFileDialog.getOpenFileName()", "", "*.yaml")

        self._dotgraphs = generate_dotcode_from_yaml_file(
            self.dotcode_factory, self.param_manager, str(file_path))

        for pipeline_name, pipeline_dotgraph in self._dotgraphs.items():

            pipeline_item = QStandardItem()
            pipeline_item.setText(pipeline_name)
            self._listmodel.appendRow(pipeline_item)

        self._current_pipeline_name = self._dotgraphs.iterkeys().next()

        self._refresh_rosgraph()
Example #7
0
    def to_QItemModel(self):
        """
        Represent the DSDs debug data as QITemModel
        """
        # Return cached result if available
        if self.__cached_item_model is not None:
            return self.__cached_item_model

        # Return empty model when no dsd data was received yet
        if self.__cached_msg is None:
            return self.__empty_item_model()

        # Construct a new item-model
        model = QStandardItemModel()
        for i in range(len(self.stack)):
            elem, _ = self.stack[i]
            elem_item = QStandardItem()
            elem_item.setEditable(False)

            if isinstance(elem, SequenceTreeElement):
                elem_item.setText('Sequence: ' + ', '.join(
                    str(e) for e in elem.action_elements))
                sequence = True
            else:
                elem_item.setText(str(elem))
                sequence = False

            self.__append_element_to_item(elem_item, elem.debug_data)

            model.invisibleRootItem().appendRow(elem_item)

            # Add a spacer if this is not the last item
            if elem != self.stack[-1][0]:
                spacer = QStandardItem()
                spacer.setEditable(False)
                model.invisibleRootItem().appendRow(spacer)

            if sequence:
                break

        self.__cached_item_model = model
        return self.__cached_item_model
Example #8
0
    def update_connect_to_list(self, output_name):

        self.connect_from_listmodel.clear()

        for node in self.dotgraph.get_node_list():
            if node.get('nodetype') == 'input':
                pass
            elif node.get('nodetype') == 'output':
                pass
            elif node.get('nodetype') == 'infer':
                if output_name in self.get_infer_desc(
                        node.get_name())['connect_to']:

                    pipeline_item = QStandardItem()
                    pipeline_item.setText(node.get_name())
                    pipeline_item.setCheckable(True)
                    pipeline_item.setCheckState(False)

                    self.connect_from_listmodel.appendRow(pipeline_item)

        self.connect_from_listview.setModel(self.connect_from_listmodel)
Example #9
0
    def _append_element_to_item(self, parent_item, debug_data):
        """
        Append an elements debug_data to a QStandardItem.

        :type parent_item: python_qt_binding.QtGui.QStandardItem
        :type debug_data: dict or list or int or float or str or bool
        :rtype: python_qt_binding.QtGui.QStandardItem
        """
        if isinstance(debug_data, list):
            for i, data in enumerate(debug_data):
                child_item = QStandardItem()
                child_item.setText(str(i) + ": ")
                child_item.setEditable(False)
                self._append_element_to_item(child_item, data)
                parent_item.appendRow(child_item)
        elif isinstance(debug_data, dict):
            for label, data in debug_data.items():
                child_item = QStandardItem()
                child_item.setText(str(label) + ": ")
                child_item.setEditable(False)
                self._append_element_to_item(child_item, data)
                parent_item.appendRow(child_item)
        elif isinstance(debug_data, (bool, float, int, str, bytes)):
            parent_item.setText(parent_item.text() + str(debug_data))