nav_view_dash_widget.py
Go to the documentation of this file.
1 # Software License Agreement (BSD License)
2 #
3 # Copyright (c) 2012, Willow Garage, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
16 # * Neither the name of Willow Garage, Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 # POSSIBILITY OF SUCH DAMAGE.
32 
33 from python_qt_binding.QtCore import QMutex, QMutexLocker, QSize
34 from rqt_nav_view.nav_view import NavViewWidget
35 
36 from .icon_tool_button import IconToolButton
37 
38 
40  """
41  A widget which launches a nav_view widget in order to view and interact with the ROS nav stack
42 
43  :param context: The plugin context in which to dsiplay the nav_view, ''qt_gui.plugin_context.PluginContext''
44  :param name: The widgets name, ''str''
45  """
46  def __init__(self, context, name='NavView', icon_paths=None):
47  self._icons = [['bg-grey.svg', 'ic-navigation.svg']]
48  super(NavViewDashWidget, self).__init__(name, icons=self._icons, suppress_overlays=True, icon_paths=icon_paths)
49  self.context = context
50  self.update_state(0)
51  self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
52 
53  self._navview = None
54  self._navview_shown = False
55  self.clicked.connect(self._show_navview)
56  self._show_mutex = QMutex()
57 
58  def _show_navview(self):
59  with QMutexLocker(self._show_mutex):
60  if self._navview is None:
61  self._navview = NavViewWidget()
62  try:
63  if self._navview_shown:
64  self.context.remove_widget(self._navview)
65  self._navview_shown = not self._navview_shown
66  else:
67  self.context.add_widget(self._navview)
68  self._navview_shown = not self._navview_shown
69  except Exception:
70  self._navview_shown = not self._navview_shown
71  self._show_navview()
72 
73  def shutdown_widget(self):
74  if self._navview:
75  self._navview.close()
76 
77  def save_settings(self, plugin_settings, instance_settings):
78  self._navview.save_settings(plugin_settings, instance_settings)
79 
80  def restore_settings(self, plugin_settings, instance_settings):
81  self._navview.restore_settings(plugin_settings, instance_settings)
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget._show_mutex
_show_mutex
Definition: nav_view_dash_widget.py:56
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget.context
context
Definition: nav_view_dash_widget.py:49
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget.__init__
def __init__(self, context, name='NavView', icon_paths=None)
Definition: nav_view_dash_widget.py:46
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget.restore_settings
def restore_settings(self, plugin_settings, instance_settings)
Definition: nav_view_dash_widget.py:80
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget._navview_shown
_navview_shown
Definition: nav_view_dash_widget.py:54
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget.shutdown_widget
def shutdown_widget(self)
Definition: nav_view_dash_widget.py:73
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget._navview
_navview
Definition: nav_view_dash_widget.py:53
rqt_robot_dashboard.icon_tool_button.IconToolButton.update_state
def update_state(self, state)
Definition: icon_tool_button.py:92
rqt_nav_view::nav_view
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget.save_settings
def save_settings(self, plugin_settings, instance_settings)
Definition: nav_view_dash_widget.py:77
rqt_robot_dashboard.icon_tool_button.IconToolButton._icons
_icons
Definition: icon_tool_button.py:84
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget
Definition: nav_view_dash_widget.py:39
rqt_robot_dashboard.nav_view_dash_widget.NavViewDashWidget._show_navview
def _show_navview(self)
Definition: nav_view_dash_widget.py:58
rqt_nav_view::nav_view::NavViewWidget
rqt_robot_dashboard.icon_tool_button.IconToolButton
Definition: icon_tool_button.py:42


rqt_robot_dashboard
Author(s): Ze'ev Klapow
autogenerated on Wed Mar 2 2022 00:58:48