nav_view_dash_widget.py
Go to the documentation of this file.
00001 # Software License Agreement (BSD License)
00002 #
00003 # Copyright (c) 2012, Willow Garage, Inc.
00004 # All rights reserved.
00005 #
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions
00008 # are met:
00009 #
00010 #  * Redistributions of source code must retain the above copyright
00011 #    notice, this list of conditions and the following disclaimer.
00012 #  * Redistributions in binary form must reproduce the above
00013 #    copyright notice, this list of conditions and the following
00014 #    disclaimer in the documentation and/or other materials provided
00015 #    with the distribution.
00016 #  * Neither the name of Willow Garage, Inc. nor the names of its
00017 #    contributors may be used to endorse or promote products derived
00018 #    from this software without specific prior written permission.
00019 #
00020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 # POSSIBILITY OF SUCH DAMAGE.
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)


rqt_robot_dashboard
Author(s): Ze'ev Klapow
autogenerated on Sat Jun 8 2019 20:02:45