topic_message_view.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 from .message_view import MessageView
00033 
00034 from python_qt_binding.QtGui import QIcon
00035 from python_qt_binding.QtWidgets import QAction, QToolBar
00036 
00037 
00038 class TopicMessageView(MessageView):
00039 
00040     """
00041     A message view with a toolbar for navigating messages in a single topic.
00042     """
00043 
00044     def __init__(self, timeline, parent, topic):
00045         MessageView.__init__(self, timeline, topic)
00046 
00047         self._parent = parent
00048         self._stamp = None
00049         self._name = parent.objectName()
00050 
00051         self.toolbar = QToolBar()
00052         self._first_action = QAction(QIcon.fromTheme('go-first'), '', self.toolbar)
00053         self._first_action.triggered.connect(self.navigate_first)
00054         self.toolbar.addAction(self._first_action)
00055         self._prev_action = QAction(QIcon.fromTheme('go-previous'), '', self.toolbar)
00056         self._prev_action.triggered.connect(self.navigate_previous)
00057         self.toolbar.addAction(self._prev_action)
00058         self._next_action = QAction(QIcon.fromTheme('go-next'), '', self.toolbar)
00059         self._next_action.triggered.connect(self.navigate_next)
00060         self.toolbar.addAction(self._next_action)
00061         self._last_action = QAction(QIcon.fromTheme('go-last'), '', self.toolbar)
00062         self._last_action.triggered.connect(self.navigate_last)
00063         self.toolbar.addAction(self._last_action)
00064         parent.layout().addWidget(self.toolbar)
00065 
00066     @property
00067     def parent(self):
00068         return self._parent
00069 
00070     @property
00071     def stamp(self):
00072         return self._stamp
00073 
00074     # MessageView implementation
00075 
00076     def message_viewed(self, bag, msg_details):
00077         _, _, self._stamp = msg_details[:3]
00078 
00079     # Events
00080     def navigate_first(self):
00081         for entry in self.timeline.get_entries([self.topic], *self.timeline._timeline_frame.play_region):
00082             self.timeline._timeline_frame.playhead = entry.time
00083             break
00084 
00085     def navigate_previous(self):
00086         last_entry = None
00087         for entry in self.timeline.get_entries([self.topic], self.timeline._timeline_frame.start_stamp, self.timeline._timeline_frame.playhead):
00088             if entry.time < self.timeline._timeline_frame.playhead:
00089                 last_entry = entry
00090 
00091         if last_entry:
00092             self.timeline._timeline_frame.playhead = last_entry.time
00093 
00094     def navigate_next(self):
00095         for entry in self.timeline.get_entries([self.topic], self.timeline._timeline_frame.playhead, self.timeline._timeline_frame.end_stamp):
00096             if entry.time > self.timeline._timeline_frame.playhead:
00097                 self.timeline._timeline_frame.playhead = entry.time
00098                 break
00099 
00100     def navigate_last(self):
00101         last_entry = None
00102         for entry in self.timeline.get_entries([self.topic], *self.timeline._timeline_frame.play_region):
00103             last_entry = entry
00104 
00105         if last_entry:
00106             self.timeline._timeline_frame.playhead = last_entry.time


rqt_bag
Author(s): Aaron Blasdel, Tim Field
autogenerated on Thu Jun 6 2019 18:52:48