35 from __future__
import division
37 from python_qt_binding.QtCore
import Qt
48 @deprecated: Not completed.
50 Create full path format of GRN (Graph Resource Names, see
51 http://www.ros.org/wiki/Names). Build GRN by recursively transcending
52 parents & children of a given QModelIndex instance.
54 A complete example of GRN: /wide_stereo/left/image_color/compressed
56 Upon its very 1st call, the argument is the index where user clicks on
57 on the view object (here QTreeView is used but should work with other
58 View too. Not tested yet though). str_grn can be 0-length string.
60 :type model_index: QModelIndex
62 :param str_grn: This could be an incomplete or a complete GRN format.
66 children_grn_list = RqtRosGraph.get_lower_grn_dfs(model_index)
67 parent_data = model_index.data()
68 rospy.logdebug(
'parent_data={}'.format(parent_data))
69 if parent_data ==
None:
70 upper_grn = RqtRosGraph.get_upper_grn(model_index,
'')
72 for child_grn
in children_grn_list:
73 grn_full = upper_grn + child_grn
74 rospy.logdebug(
'grn_full={} upper_grn={} child_grn={}'.format(
75 grn_full, upper_grn, child_grn))
76 grn_list.append(grn_full)
78 grn_list = children_grn_list
83 grn += RqtRosGraph.DELIM_GRN + s
90 Traverse all children treenodes and returns a list of "partial"
91 GRNs. Partial means that this method returns names under current level.
93 Ex. Consider a tree like this:
106 Re-formatted in GRN (omitting root):
113 Might not be obvious from tree representation but there are 4 nodes as
118 :type model_index: QModelIndex
123 list_grn_children_all = []
125 grn_curr = grn_prev + RqtRosGraph.DELIM_GRN + \
126 str(model_index.data())
127 child_qmindex = model_index.child(i_child, 0)
129 if (
not child_qmindex.isValid()):
130 rospy.logdebug(
'!! DEADEND i_child=#{} grn_curr={}'.format(
135 list_grn_children_all.append(grn_curr)
136 return list_grn_children_all
138 rospy.logdebug(
'Child#{} grn_curr={}'.format(i_child, grn_curr))
140 list_grn_children = RqtRosGraph.get_lower_grn_dfs(child_qmindex,
142 for child_grn
in list_grn_children:
143 child_grn = (grn_prev +
144 (RqtRosGraph.DELIM_GRN + grn_curr) +
145 (RqtRosGraph.DELIM_GRN + child_grn))
147 list_grn_children_all = list_grn_children_all + list_grn_children
148 rospy.logdebug(
'111 lennodes={} list_grn_children={}'.format(
149 len(list_grn_children_all), list_grn_children))
150 rospy.logdebug(
'122 list_grn_children_all={}'.format(
151 list_grn_children_all))
153 return list_grn_children_all
157 if model_index.data(Qt.DisplayRole) ==
None:
159 str_grn = (RqtRosGraph.DELIM_GRN +
160 str(model_index.data(Qt.DisplayRole)) +
162 rospy.logdebug(
'get_full_grn_recur out str=%s', str_grn)
163 return RqtRosGraph.get_upper_grn(model_index.parent(), str_grn)