Esempio n. 1
0
 def create_application(self, argv):
     from python_qt_binding.QtCore import Qt
     from python_qt_binding.QtWidgets import QApplication
     QApplication.setAttribute(Qt.AA_X11InitThreads, True)
     app = QApplication(argv)
     app.setAttribute(Qt.AA_DontShowIconsInMenus, False)
     return app
Esempio n. 2
0
    def runGUI(self):
        app = QApplication(sys.argv)
        self.myWidget.show()
        while (0 == 0):
            rospy.sleep(1.)
            self.myWidget.updateLabel()

        sys.exit(app.exec_())
Esempio n. 3
0
    def updateLabel(self):
        # Tries self.gotParams every 3 function calls
        self.paramCounter = self.paramCounter + 1
        if self.gotParams is False and self.paramCounter >= 3:
            self.testParams()
            self.paramCounter = 0

        # Checks if battery_monitor.py is online, if not it sets that voltage to 0
        # otherwise ite formats the voltage data into an int to be shown in GUI
        try:
            stringMain = str(self.battery_voltage)
            stringMain = stringMain[5:]
            numMain = float(stringMain)
            numMain = int(numMain * 100)
            numMain = numMain / 100.0
        except:
            if self.warningCounter == 0:
                print("battery monitor is not online!!")
                self.warningCounter = 1
            numMain = 0.0

        self.setColors(numMain)

        # Turns all the voltages into strings and sets them as text in GUI boxes
        self.labelMain.setText("{}".format(numMain))
        try:
            numFL = (int(self.voltageFL * 100)) / 100
            stringFL = str(numFL)
            self.labelFL.setText("{}".format(stringFL))
        except:
            pass

        try:
            numFR = (int(self.voltageFR * 100)) / 100
            stringFR = str(numFR)
            self.labelFR.setText("{}".format(stringFR))
        except:
            pass

        try:
            numBL = (int(self.voltageBL * 100)) / 100
            stringBL = str(numBL)
            self.labelBL.setText("{}".format(stringBL))
        except:
            pass

        try:
            stringBR = float("{0:.2f}".format(self.voltageBR))
            self.labelBR.setText("{}".format(stringBR))
        except:
            pass

        QApplication.processEvents()
Esempio n. 4
0
 def _copy_text_to_clipboard(self):
     # Get tab indented text for all selected items
     def get_distance(item, ancestor, distance=0):
         parent = item.parent()
         if parent == None:
             return distance
         else:
             return get_distance(parent, ancestor, distance + 1)
     text = ''
     for i in self.get_all_items():
         if i in self.selectedItems():
             text += ('\t' * (get_distance(i, None))) + i.text(0) + '\n'
     # Copy the text to the clipboard
     clipboard = QApplication.clipboard()
     clipboard.setText(text)
Esempio n. 5
0
 def create_application(self, argv):
     from python_qt_binding.QtCore import Qt
     from python_qt_binding.QtWidgets import QApplication
     app = QApplication(argv)
     app.setAttribute(Qt.AA_DontShowIconsInMenus, False)
     return app
        self.title_label.show()

    def _update_title_label(self):
        if self.title_edit.text():
            self.title_label.setText(self.title_edit.text())
            self._dock_widget.setWindowTitle(self.title_edit.text())


if __name__ == '__main__':
    import sys
    from python_qt_binding.QtWidgets import QApplication
    from qt_gui.dockable_main_window import DockableMainWindow
    from ament_index_python.resources import get_resource

    _, qtgui_path = get_resource('packages', 'qt_gui')
    app = QApplication(sys.argv)

    win = DockableMainWindow()

    dock1 = QDockWidget('dockwidget1', win)
    win.addDockWidget(Qt.LeftDockWidgetArea, dock1)
    title_bar = DockWidgetTitleBar(dock1, qtgui_path)
    dock1.setTitleBarWidget(title_bar)

    dock2 = QDockWidget('dockwidget2')
    win.addDockWidget(Qt.RightDockWidgetArea, dock2)
    title_bar = DockWidgetTitleBar(dock2, qtgui_path)

    dock2.setTitleBarWidget(title_bar)

    win.resize(640, 480)
Esempio n. 7
0
    def _rightclick_menu(self, event):
        """
        Dynamically builds the rightclick menu based on the unique column data
        from the passed in datamodel and then launches it modally
        :param event: the mouse event object, ''QMouseEvent''
        """
        severities = {}
        for severity, label in Message.SEVERITY_LABELS.items():
            if severity in self._model.get_unique_severities():
                severities[severity] = label
        nodes = sorted(self._model.get_unique_nodes())
        topics = sorted(self._model.get_unique_topics())

        # menutext entries turned into
        menutext = []
        menutext.append([
            self.tr('Exclude'),
            [[self.tr('Severity'), severities], [self.tr('Node'), nodes],
             [self.tr('Topic'), topics], [self.tr('Selected Message(s)')]]
        ])
        menutext.append([
            self.tr('Highlight'),
            [[self.tr('Severity'), severities], [self.tr('Node'), nodes],
             [self.tr('Topic'), topics], [self.tr('Selected Message(s)')]]
        ])
        menutext.append([self.tr('Copy Selected')])
        menutext.append([self.tr('Browse Selected')])

        menu = QMenu()
        submenus = []
        subsubmenus = []
        for item in menutext:
            if len(item) > 1:
                submenus.append(QMenu(item[0], menu))
                for subitem in item[1]:
                    if len(subitem) > 1:
                        subsubmenus.append(QMenu(subitem[0], submenus[-1]))
                        if isinstance(subitem[1], dict):
                            for key in sorted(subitem[1].keys()):
                                action = subsubmenus[-1].addAction(
                                    subitem[1][key])
                                action.setData(key)
                        else:
                            for subsubitem in subitem[1]:
                                subsubmenus[-1].addAction(subsubitem)
                        submenus[-1].addMenu(subsubmenus[-1])
                    else:
                        submenus[-1].addAction(subitem[0])
                menu.addMenu(submenus[-1])
            else:
                menu.addAction(item[0])
        action = menu.exec_(event.globalPos())

        if action is None or action == 0:
            return
        elif action.text() == self.tr('Browse Selected'):
            self._show_browsers()
        elif action.text() == self.tr('Copy Selected'):
            rowlist = []
            for current in self.table_view.selectionModel().selectedIndexes():
                rowlist.append(self._proxy_model.mapToSource(current).row())
            copytext = self._model.get_selected_text(rowlist)
            if copytext is not None:
                clipboard = QApplication.clipboard()
                clipboard.setText(copytext)
        elif action.text() == self.tr('Selected Message(s)'):
            if action.parentWidget().title() == self.tr('Highlight'):
                self._process_highlight_exclude_filter(action.text(),
                                                       'Message', False)
            elif action.parentWidget().title() == self.tr('Exclude'):
                self._process_highlight_exclude_filter(action.text(),
                                                       'Message', True)
            else:
                raise RuntimeError(
                    "Menu format corruption in ConsoleWidget._rightclick_menu()"
                )
        else:
            # This processes the dynamic list entries (severity, node and topic)
            try:
                roottitle = action.parentWidget().parentWidget().title()
            except:
                raise RuntimeError(
                    "Menu format corruption in ConsoleWidget._rightclick_menu()"
                )

            if roottitle == self.tr('Highlight'):
                self._process_highlight_exclude_filter(
                    action.text(),
                    action.parentWidget().title(), False)
            elif roottitle == self.tr('Exclude'):
                self._process_highlight_exclude_filter(
                    action.text(),
                    action.parentWidget().title(), True)
            else:
                raise RuntimeError(
                    "Unknown Root Action %s selected in ConsoleWidget._rightclick_menu()"
                    % roottitle)
Esempio n. 8
0
 def __init__(self, *args):
     super(DotToQtGeneratorTest, self).__init__(*args)
     # needed for creation of QtGraphic items in NodeItem.__init__
     if DotToQtGeneratorTest._Q_APP is None:
         if check_x_server():
             DotToQtGeneratorTest._Q_APP = QApplication([])
Esempio n. 9
0
    def setUp(self):
        self.app = QApplication(sys.argv)

        global_dict = dict()
        self.rdp_gui = line_simpl.RDPGUI(global_dict)
import sys
from python_qt_binding.QtWidgets import QApplication, QWidget, QVBoxLayout
from python_qt_binding.QtCore import QFile, QIODevice, QObject
from rqt_graph.ros_graph import RosGraph


class FakePluginContext(QObject):
    def __init__(self):
        super(FakePluginContext, self).__init__()
        self.setObjectName('FakePluginContext')

    def serial_number(self):
        return 0

    def add_widget(self, widget):
        pass


if __name__ == "__main__":
    app = QApplication(sys.argv)
    fpc = FakePluginContext()
    r = RosGraph(fpc)

    handle = QFile(sys.argv[1])
    if not handle.open(QIODevice.WriteOnly | QIODevice.Text):
        exit(1)

    handle.write(r._generate_dotcode())
    handle.close()
Esempio n. 11
0
    def __init__(self,ns):
        description = get_param(ns+'/robot_description')
	#print('description=' + description)
        robot = xml.dom.minidom.parseString(description).getElementsByTagName('robot')[0]
        self.free_joints = {}
        self.joint_list = []  # for maintaining the original order of the joints
        self.dependent_joints = get_param("dependent_joints", {})
        use_mimic = get_param('use_mimic_tags', True)
        use_small = get_param('use_smallest_joint_limits', True)

        self.zeros = get_param("zeros")

        pub_def_positions = get_param("publish_default_positions", True)
        pub_def_vels = get_param("publish_default_velocities", False)
        pub_def_efforts = get_param("publish_default_efforts", False)

        # Find all non-fixed joints
        for child in robot.childNodes:
            if child.nodeType is child.TEXT_NODE:
                continue
            if child.localName == 'joint':
                jtype = child.getAttribute('type')
                if jtype == 'fixed' or jtype == 'floating':
                    continue
                name = child.getAttribute('name')
                self.joint_list.append(name)
                if jtype == 'continuous':
                    minval = -pi
                    maxval = pi
                else:
                    try:
                        limit = child.getElementsByTagName('limit')[0]
                        minval = float(limit.getAttribute('lower'))
                        maxval = float(limit.getAttribute('upper'))
                    except:
                        rospy.logwarn("%s is not fixed, nor continuous, but limits are not specified!" % name)
                        continue

                safety_tags = child.getElementsByTagName('safety_controller')
                if use_small and len(safety_tags) == 1:
                    tag = safety_tags[0]
                    if tag.hasAttribute('soft_lower_limit'):
                        minval = max(minval, float(tag.getAttribute('soft_lower_limit')))
                    if tag.hasAttribute('soft_upper_limit'):
                        maxval = min(maxval, float(tag.getAttribute('soft_upper_limit')))

                mimic_tags = child.getElementsByTagName('mimic')
                if use_mimic and len(mimic_tags) == 1:
                    tag = mimic_tags[0]
                    entry = {'parent': tag.getAttribute('joint')}
                    if tag.hasAttribute('multiplier'):
                        entry['factor'] = float(tag.getAttribute('multiplier'))
                    if tag.hasAttribute('offset'):
                        entry['offset'] = float(tag.getAttribute('offset'))

                    self.dependent_joints[name] = entry
                    continue

                if name in self.dependent_joints:
                    continue

                if self.zeros and name in self.zeros:
                    zeroval = self.zeros[name]
                elif minval > 0 or maxval < 0:
                    zeroval = (maxval + minval)/2
                else:
                    zeroval = 0

                joint = {'min': minval, 'max': maxval, 'zero': zeroval}
                if pub_def_positions:
                    joint['position'] = zeroval
                if pub_def_vels:
                    joint['velocity'] = 0.0
                if pub_def_efforts:
                    joint['effort'] = 0.0

                if jtype == 'continuous':
                    joint['continuous'] = True
                self.free_joints[name] = joint

        use_gui = get_param("use_gui", False)

        if use_gui:
            num_rows = get_param("num_rows", 0)
            self.app = QApplication(sys.argv)
            self.gui = JointStatePublisherGui("Joint State Publisher", self, num_rows)
            self.gui.show()
        else:
            self.gui = None

	# if you want to echo the current state of the controller 
	# the source list param 
        source_list = get_param(ns+"/source_list", [])
        self.sources = []
        for source in source_list:
            self.sources.append(rospy.Subscriber(source, JointState, self.source_cb))

        self.pub = rospy.Publisher(ns+'/gui/joint_states', JointState, queue_size=5)
Esempio n. 12
0
def main():
    app = QApplication(["Metrics Refbox"])
    #['Breeze', 'Windows', 'GTK+', 'Fusion']
    app.setStyle('Fusion')
    trw = MetricsRefboxWidget()
    app.exec_()
Esempio n. 13
0
 def __init__(self):
     #sliderUpdateTrigger = Signal()
     rospy.init_node('uav_state_publisher_gui')
     self.app = QApplication()
     self.app.setApplicationDisplayName("Uav State Publisher")
     num_rows = 1#joint_state_publisher.get_param('num_rows', 0)
Esempio n. 14
0
    def _event(self, e):
        if e.type() == QEvent.MouseButtonPress and e.button() == Qt.LeftButton:
            qDebug('%spress, rel=%s, global=%s, diff=%s' % ((' - pseudo ' if self._releasing_and_repressing_while_dragging else ''), e.pos(), e.globalPos(), e.globalPos() - self.pos()))
        if e.type() == QEvent.MouseButtonRelease and e.button() == Qt.LeftButton:
            qDebug('%srelease, rel=%s, global=%s, diff=%s' % ((' - pseudo ' if self._releasing_and_repressing_while_dragging else ''), e.pos(), e.globalPos(), e.globalPos() - self.pos()))

        # store local position when pressing button before starting the custom drag'n'drop
        # only allow when layout is not frozen
        if self._dragging_parent is None and e.type() == QEvent.MouseButtonPress and e.button() == Qt.LeftButton and bool(self.features() & QDockWidget.DockWidgetMovable):
            self._dragging_local_pos = e.pos()

        if self._dragging_parent is None and self._dragging_local_pos is not None and e.type() == QEvent.Move and QApplication.mouseButtons() & Qt.LeftButton:
            if self._widget_at(e.pos()) is not None:
                qDebug('DockWidget._event() start drag, dockwidget=%s, parent=%s, floating=%s, pos=%s' % (str(self), str(self.parent()), str(self.isFloating()), str(self._dragging_local_pos)))
                self._dragging_parent = self.parent()
                # ignore further mouse events so that the widget behind this dock widget can be determined
                self.setAttribute(Qt.WA_TransparentForMouseEvents)

                # collect all main windows (except self.main_window) to re-implement QApplication.widgetAt() in self._widget_at()
                self._main_windows = [self._container_manager.get_root_main_window()]
                for container in self._container_manager.get_containers():
                    if container == self:
                        continue
                    self._main_windows.append(container.main_window)

        # unset local position when releasing button even when custom drag'n'drop has not been started
        if self._dragging_local_pos is not None and e.type() == QEvent.MouseButtonRelease and e.button() == Qt.LeftButton and not self._releasing_and_repressing_while_dragging:
            self._dragging_local_pos = None

        if self._dragging_parent is not None and e.type() == QEvent.MouseButtonRelease and e.button() == Qt.LeftButton and not self._releasing_and_repressing_while_dragging:
            qDebug('DockWidget._event() stop drag, dockwidget=%s, parent=%s\n' % (self, self.parent()))
            self._dragging_parent = None
            self.setAttribute(Qt.WA_TransparentForMouseEvents, False)
            self._main_windows = []

        if self._dragging_parent is not None and e.type() == QEvent.MouseMove and e.buttons() & Qt.LeftButton and not self._releasing_and_repressing_while_dragging:
            widget = self._widget_at(e.globalPos())
            new_parent = self._get_new_parent(widget)
            #print 'new_parent', new_parent, (new_parent.objectName() if new_parent else '')
            if new_parent is not None and new_parent != self.parent():
                self._releasing_and_repressing_while_dragging = True

                # schedule stop of pseudo drag'n'drop and let it complete
                mouse_release_event = QMouseEvent(QEvent.MouseButtonRelease, self._dragging_local_pos, e.globalPos(), Qt.LeftButton, Qt.NoButton, e.modifiers())
                QApplication.instance().postEvent(self, mouse_release_event)
                QApplication.sendPostedEvents()

                # schedule reparent to hovered main window and let it complete
                reparent_event = ReparentEvent(self, new_parent)
                QApplication.instance().postEvent(self._container_manager, reparent_event)
                QApplication.sendPostedEvents()

                # reenable mouse events to be able to receive upcoming pseudo mouse events
                self.setAttribute(Qt.WA_TransparentForMouseEvents, False)

                # schedule restart of pseudo drag'n'drop and let it complete
                mouse_repress_event = QMouseEvent(QEvent.MouseButtonPress, self._dragging_local_pos, e.globalPos(), Qt.LeftButton, Qt.LeftButton, e.modifiers())
                QApplication.instance().postEvent(self, mouse_repress_event)
                QApplication.sendPostedEvents()

                # schedule move to trigger dock widget drag'n'drop required for snapping and showing rubber band and let it complete
                # move forth...
                mouse_move_event = QMouseEvent(QEvent.MouseMove, self._dragging_local_pos, e.globalPos() + QPoint(QApplication.startDragDistance(), 1), Qt.NoButton, Qt.LeftButton, e.modifiers())
                QApplication.instance().postEvent(self, mouse_move_event)
                QApplication.sendPostedEvents()
                # ...and back
                mouse_move_event = QMouseEvent(QEvent.MouseMove, self._dragging_local_pos, e.globalPos(), Qt.NoButton, Qt.LeftButton, e.modifiers())
                QApplication.instance().postEvent(self, mouse_move_event)
                QApplication.sendPostedEvents()

                # restore attributes after repressing the button
                self.setAttribute(Qt.WA_TransparentForMouseEvents)

                self._releasing_and_repressing_while_dragging = False

        return super(DockWidget, self).event(e)
Esempio n. 15
0
    def _widget_at(self, global_point):
        #print '_widget_at()', global_point#, local_point
        widget = QApplication.widgetAt(global_point)
        #print '- widget', widget, (widget.objectName() if widget is not None else '')
        root_main_window = self._container_manager.get_root_main_window()

        # work around bug where root main window is detected when point is near but not inside it
        if widget == root_main_window and not self._widget_contains(root_main_window, global_point):
            #print '- work around to large root main window'
            widget = None

        # work around bug where dock widget is floating and no widget is found
        if widget is None and self.isFloating():
            # determine all main windows which match the point
            overlapping = {}
            for main_window in self._main_windows:
                if self._widget_contains(main_window, global_point):
                    parent = main_window.parent()
                    is_floating = parent is None or parent.isFloating()
                    overlapping[main_window] = is_floating
            #print 'overlapping', overlapping

            if len(overlapping) == 1:
                # only found one candidate so pick it
                widget, _ = overlapping.popitem()
            elif len(overlapping) > 1:
                # try to determine which main window is the right one
                # determined docked main windows
                overlapping_docked = [mw for mw, floating in overlapping.iteritems() if not floating]
                #print 'overlapping_docked', overlapping_docked

                # if at max one of the main windows is floating
                if len(overlapping_docked) >= len(overlapping) - 1:
                    # the floating main window is not considered because the docked ones are children of it

                    # consider all docked main windows and remove parent if both parent and child are in the list
                    #print 'considered docked main windows', overlapping_docked
                    parents = []
                    for mw1 in overlapping_docked:
                        # parent of the main window is a dock widget container
                        parent = mw1.parent()
                        if parent is None:
                            continue
                        # parent of the dock widget container is a main window
                        parent = parent.parent()
                        if parent is None:
                            continue
                        for mw2 in overlapping_docked:
                            if mw2 == parent:
                                parents.append(mw2)
                    for parent in parents:
                        overlapping_docked.remove(parent)
                    #print 'considered non-parent main windows', overlapping_docked

                    # if only one docked main window is found then pick it
                    if len(overlapping_docked) == 1:
                        #print '- pick single remaining main window'
                        widget = overlapping_docked[0]
                    else:
                        #print '- found multiple main windows - could not determine which one is on top'
                        pass
                # TODO any more heuristic possible?
                # if all remaining docked main windows have a most common ancestor use the order of children() to determine topmost
        return widget
Esempio n. 16
0
    def update_spectrogram(self):
        if self.spectrogram is not None:

            yticks = [
                0, self.highcut_freq / 2 / self.stft_freq -
                self.lowcut_freq * 2 / self.stft_freq,
                self.highcut_freq / self.stft_freq -
                self.lowcut_freq * 2 / self.stft_freq,
                self.highcut_freq / 2 * 3 / self.stft_freq -
                self.lowcut_freq * 2 / self.stft_freq,
                self.highcut_freq * 2 / self.stft_freq -
                self.lowcut_freq * 2 / self.stft_freq
            ]
            yticks_label = [
                self.lowcut_freq, self.highcut_freq / 4, self.highcut_freq / 2,
                self.highcut_freq / 4 * 3, self.highcut_freq
            ]

            xticks = [
                0, self.frame_length / 4 - 1, self.frame_length / 2 - 1,
                self.frame_length * 3 / 4 - 1, self.frame_length - 1
            ]
            xticks_label = [
                -self.frame_time * 2, -self.frame_time / 2 * 3,
                -self.frame_time, -self.frame_time / 2, 0
            ]

            font_size = 13

            if self.cnt_fig % 40 == 0:

                self.ax.clear()
                #self.im = self.ax.imshow(self.spectrogram[int(self.lowcut_freq*100/self.overlap/self.stft_freq):int(self.highcut_freq*100/self.overlap/self.stft_freq)+1,:,0], aspect="auto", origin="lower", cmap="winter", interpolation='none', vmin=self.v_min, vmax=self.v_max)
                self.im = self.ax.imshow(self.spectrogram[
                    int(self.lowcut_freq * 100 / self.overlap /
                        self.stft_freq):int(self.highcut_freq * 100 /
                                            self.overlap / self.stft_freq) +
                    1, :, 0],
                                         aspect="auto",
                                         origin="lower",
                                         cmap="jet",
                                         interpolation='none',
                                         vmin=12,
                                         vmax=16)
                self.ax.grid(None)
                self.ax.set_ylabel("Freq. [Hz]",
                                   fontsize=font_size,
                                   fontname='serif')
                self.ax.set_yticks(yticks)
                self.ax.set_yticklabels(["$%.1f$" % y for y in yticks_label],
                                        fontsize=font_size)
                self.ax.set_xticks(xticks)
                self.ax.set_xticklabels(["$%.1f$" % x for x in xticks_label],
                                        fontsize=font_size)
                self.ax.set_xlabel("Time [s]",
                                   fontsize=font_size,
                                   fontname='serif')

                if self.colorbarflag == 0:
                    self.colorbarflag = 1
                    self.cb = self.fig.colorbar(self.im)
                elif self.colorbarflag == 1:
                    self.cb.update_bruteforce(self.im)

                self.canvas.draw()

            self.cnt_fig += 1

        QApplication.processEvents()
    def _rightclick_menu(self, event):
        """
        Dynamically builds the rightclick menu based on the unique column data
        from the passed in datamodel and then launches it modally
        :param event: the mouse event object, ''QMouseEvent''
        """
        severities = {}
        for severity, label in Message.SEVERITY_LABELS.items():
            if severity in self._model.get_unique_severities():
                severities[severity] = label
        nodes = sorted(self._model.get_unique_nodes())
        topics = sorted(self._model.get_unique_topics())

        # menutext entries turned into
        menutext = []
        menutext.append([self.tr('Exclude'), [[self.tr('Severity'), severities], [self.tr('Node'), nodes], [self.tr('Topic'), topics], [self.tr('Selected Message(s)')]]])
        menutext.append([self.tr('Highlight'), [[self.tr('Severity'), severities], [self.tr('Node'), nodes], [self.tr('Topic'), topics], [self.tr('Selected Message(s)')]]])
        menutext.append([self.tr('Copy Selected')])
        menutext.append([self.tr('Browse Selected')])

        menu = QMenu()
        submenus = []
        subsubmenus = []
        for item in menutext:
            if len(item) > 1:
                submenus.append(QMenu(item[0], menu))
                for subitem in item[1]:
                    if len(subitem) > 1:
                        subsubmenus.append(QMenu(subitem[0], submenus[-1]))
                        if isinstance(subitem[1], dict):
                            for key in sorted(subitem[1].keys()):
                                action = subsubmenus[-1].addAction(subitem[1][key])
                                action.setData(key)
                        else:
                            for subsubitem in subitem[1]:
                                subsubmenus[-1].addAction(subsubitem)
                        submenus[-1].addMenu(subsubmenus[-1])
                    else:
                        submenus[-1].addAction(subitem[0])
                menu.addMenu(submenus[-1])
            else:
                menu.addAction(item[0])
        action = menu.exec_(event.globalPos())

        if action is None or action == 0:
            return
        elif action.text() == self.tr('Browse Selected'):
            self._show_browsers()
        elif action.text() == self.tr('Copy Selected'):
            rowlist = []
            for current in self.table_view.selectionModel().selectedIndexes():
                rowlist.append(self._proxy_model.mapToSource(current).row())
            copytext = self._model.get_selected_text(rowlist)
            if copytext is not None:
                clipboard = QApplication.clipboard()
                clipboard.setText(copytext)
        elif action.text() == self.tr('Selected Message(s)'):
            if action.parentWidget().title() == self.tr('Highlight'):
                self._process_highlight_exclude_filter(action.text(), 'Message', False)
            elif action.parentWidget().title() == self.tr('Exclude'):
                self._process_highlight_exclude_filter(action.text(), 'Message', True)
            else:
                raise RuntimeError("Menu format corruption in ConsoleWidget._rightclick_menu()")
        else:
            # This processes the dynamic list entries (severity, node and topic)
            try:
                roottitle = action.parentWidget().parentWidget().title()
            except:
                raise RuntimeError("Menu format corruption in ConsoleWidget._rightclick_menu()")

            if roottitle == self.tr('Highlight'):
                self._process_highlight_exclude_filter(action.text(), action.parentWidget().title(), False)
            elif roottitle == self.tr('Exclude'):
                self._process_highlight_exclude_filter(action.text(), action.parentWidget().title(), True)
            else:
                raise RuntimeError("Unknown Root Action %s selected in ConsoleWidget._rightclick_menu()" % roottitle)
Esempio n. 18
0
        '''
        self.roll_line_edit.setText(str('{:+.2f}'.format(roll)))
        self.pitch_line_edit.setText(str('{:+.2f}'.format(pitch)))
        self.yaw_line_edit.setText(str('{:+.2f}'.format(yaw)))

    def display_angular_velocity(self, x, y, z):
        '''
        Display the angular velocity data (in rad/s) of the robot

        Parameters:
            x: angular x velocity in rad/s
            y: angular y velocity in rad/s
            z: angular z velocity in rad/s
        Returns:
            N/A
        '''
        self.ang_vel_x_line_edit.setText(str('{:+.2f}'.format(x)))
        self.ang_vel_y_line_edit.setText(str('{:+.2f}'.format(y)))
        self.ang_vel_z_line_edit.setText(str('{:+.2f}'.format(z)))

if __name__ == "__main__":
    import sys
    app = QApplication([])
    odometry_display_widget = Odometry_Display_Widget()
    odometry_display_widget.show()
    odometry_display_widget.display_pose(10.1, 11, 124.12)
    odometry_display_widget.display_linear_velocity(-16.454, 1204.12, 0.0)
    odometry_display_widget.display_orientation(-5.64, 320, 491.892)
    odometry_display_widget.display_angular_velocity(-16.454, 1204.12, 0.0)
    sys.exit(app.exec_())