Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 from python_qt_binding.QtCore import QMutex, QMutexLocker, QSize
00034 from rqt_nav_view.nav_view import NavViewWidget
00035
00036 from .icon_tool_button import IconToolButton
00037
00038
00039 class NavViewDashWidget(IconToolButton):
00040 """
00041 A widget which launches a nav_view widget in order to view and interact with the ROS nav stack
00042
00043 :param context: The plugin context in which to dsiplay the nav_view, ''qt_gui.plugin_context.PluginContext''
00044 :param name: The widgets name, ''str''
00045 """
00046 def __init__(self, context, name='NavView', icon_paths=None):
00047 self._icons = [['bg-grey.svg', 'ic-navigation.svg']]
00048 super(NavViewDashWidget, self).__init__(name, icons=self._icons, suppress_overlays=True, icon_paths=icon_paths)
00049 self.context = context
00050 self.update_state(0)
00051 self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
00052
00053 self._navview = None
00054 self._navview_shown = False
00055 self.clicked.connect(self._show_navview)
00056 self._show_mutex = QMutex()
00057
00058 def _show_navview(self):
00059 with QMutexLocker(self._show_mutex):
00060 if self._navview is None:
00061 self._navview = NavViewWidget()
00062 try:
00063 if self._navview_shown:
00064 self.context.remove_widget(self._navview)
00065 self._navview_shown = not self._navview_shown
00066 else:
00067 self.context.add_widget(self._navview)
00068 self._navview_shown = not self._navview_shown
00069 except Exception:
00070 self._navview_shown = not self._navview_shown
00071 self._show_navview()
00072
00073 def shutdown_widget(self):
00074 if self._navview:
00075 self._navview.close()
00076
00077 def save_settings(self, plugin_settings, instance_settings):
00078 self._navview.save_settings(plugin_settings, instance_settings)
00079
00080 def restore_settings(self, plugin_settings, instance_settings):
00081 self._navview.restore_settings(plugin_settings, instance_settings)