33 Defines a raw view: a TopicMessageView that displays the message contents in a tree. 
   40 from python_qt_binding.QtCore 
import Qt
 
   41 from python_qt_binding.QtWidgets 
import QApplication, QAbstractItemView, QSizePolicy, QTreeWidget, QTreeWidgetItem, QWidget
 
   42 from .topic_message_view 
import TopicMessageView
 
   51         return codecs.utf_8_decode(str(x).encode(), 
'ignore')[0]
 
   57     Plugin to view a message in a treeview window 
   58     The message is loaded into a custum treewidget 
   63         :param timeline: timeline data object, ''BagTimeline'' 
   64         :param parent: widget that will be added to the ros_gui context, ''QWidget'' 
   66         super(RawView, self).
__init__(timeline, parent, topic)
 
   74         _, msg, t = msg_details  
 
   81         TopicMessageView.message_cleared(self)
 
   88         super(MessageTree, self).
__init__(parent)
 
   89         self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
 
   90         self.setHeaderHidden(
False)
 
   91         self.setHeaderLabel(
'')
 
   92         self.setSelectionMode(QAbstractItemView.ExtendedSelection)
 
  104         Clears the tree view and displays the new message 
  105         :param msg: message object to display in the treeview, ''msg'' 
  111                 if item.isExpanded():
 
  117             self.setHeaderLabel(msg._type)
 
  130                         item.setExpanded(
True)
 
  132                         item.setExpanded(
False)
 
  138         if event.modifiers() & Qt.ControlModifier:
 
  140             if key == ord(
'C') 
or key == ord(
'c'):
 
  144             elif key == ord(
'A') 
or key == ord(
'a'):
 
  151         def get_distance(item, ancestor, distance=0):
 
  152             parent = item.parent()
 
  156                 return get_distance(parent, ancestor, distance + 1)
 
  159             if i 
in self.selectedItems():
 
  160                 text += (
'\t' * (get_distance(i, 
None))) + i.text(0) + 
'\n' 
  162         clipboard = QApplication.clipboard()
 
  163         clipboard.setText(text)
 
  166         return item.data(0, Qt.UserRole)[0].replace(
' ', 
'')  
 
  171             root = self.invisibleRootItem()
 
  179         for i 
in range(root.childCount()):
 
  180             child = root.child(i)
 
  187         if hasattr(obj, 
'__slots__'):
 
  188             subobjs = [(slot, getattr(obj, slot)) 
for slot 
in obj.__slots__]
 
  189         elif type(obj) 
in [list, tuple, array.array]:
 
  194                 w = int(math.ceil(math.log10(len_obj)))
 
  195                 subobjs = [(
'[%*d]' % (w, i), subobj) 
for (i, subobj) 
in enumerate(obj)]
 
  199         if type(obj) 
in [int, long, float]:
 
  200             if type(obj) == float:
 
  201                 obj_repr = 
'%.6f' % obj
 
  205             if obj_repr[0] == 
'-':
 
  206                 label += 
': %s' % obj_repr
 
  208                 label += 
':  %s' % obj_repr
 
  210         elif type(obj) 
in [str, bool, int, long, float, complex, rospy.Time]:
 
  215             if len(obj_repr) >= 50:
 
  216                 obj_repr = obj_repr[:50] + 
'...' 
  218             label += 
': ' + obj_repr
 
  219         item = QTreeWidgetItem([label])
 
  222         elif path.find(
'.') == -1 
and path.find(
'[') == -1:
 
  223             self.addTopLevelItem(item)
 
  225             parent.addChild(item)
 
  226         item.setData(0, Qt.UserRole, (path, obj_type))
 
  228         for subobj_name, subobj 
in subobjs:
 
  233                 subpath = subobj_name  
 
  234             elif subobj_name.startswith(
'['):
 
  235                 subpath = 
'%s%s' % (path, subobj_name)  
 
  237                 subpath = 
'%s.%s' % (path, subobj_name)  
 
  239             if hasattr(subobj, 
'_type'):
 
  240                 subobj_type = subobj._type
 
  242                 subobj_type = type(subobj).__name__