timeline_pane.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 # Author: Isaac Saito, Ze'ev Klapow, Austin Hendrix
34 
35 import os
36 
37 from python_qt_binding import loadUi
38 from python_qt_binding.QtCore import Signal, Slot
39 from python_qt_binding.QtWidgets import QWidget
40 import rospy
41 import rospkg
42 
43 from rqt_robot_monitor.timeline import Timeline
44 
45 
46 class TimelinePane(QWidget):
47  """
48  This class defines the pane where timeline and its related components
49  are displayed.
50  """
51  status_updated = Signal(list)
52  pause_changed = Signal(bool)
53  position_changed = Signal(int)
54  redraw = Signal()
55 
56  def __init__(self, parent, paused=False):
57  """
58  Because this class is intended to be instantiated via Qt's .ui file,
59  taking argument other than parent widget is not possible, which is
60  ported to set_timeline_data method. That said, set_timeline_data must
61  be called (soon) after an object of this is instantiated.
62  """
63  super(TimelinePane, self).__init__(parent=parent)
64 
65  rp = rospkg.RosPack()
66  ui_file = os.path.join(rp.get_path('rqt_robot_monitor'),
67  'resource',
68  'timelinepane.ui')
69  loadUi(ui_file, self)
70 
71  self._timeline_view.show()
72  self._timeline_view.position_changed.connect(self._signal_position_changed)
73 
74  # connect pause button
75  self._pause_button.clicked[bool].connect(self._signal_pause_changed)
76 
77  # bootstrap initial state
78  self._pause_button.setChecked(paused)
79 
80  self.redraw.connect(self._signal_redraw)
81 
82  def _signal_pause_changed(self, paused):
83  self.pause_changed.emit(paused)
84 
85  def _signal_position_changed(self, position):
86  self.position_changed.emit(position)
87 
88  @Slot(bool)
89  def set_paused(self, paused):
90  self._pause_button.setChecked(paused)
91 
92  @Slot(list)
93  def set_levels(self, levels):
94  '''
95  :param levels: List of status levels
96  '''
97  self._timeline_view.set_levels(levels)
98 
99  @Slot(int)
100  def set_position(self, position):
101  self._timeline_view.set_marker_pos(position)
102 
103  @Slot()
104  def _signal_redraw(self):
105  self._timeline_view.redraw.emit()
def __init__(self, parent, paused=False)


rqt_robot_monitor
Author(s): Austin Hendrix, Isaac Saito, Ze'ev Klapow, Kevin Watts, Josh Faust
autogenerated on Thu Jun 4 2020 03:46:53