-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added recursive subgraph parsing, box3d shape, graphics items now immediately parented #87
Added recursive subgraph parsing, box3d shape, graphics items now immediately parented #87
Conversation
…ediately parented
With #72 being merged can you please update this PR to be based on the current default branch. Thank you. |
@fmauch, it appears we implemented recursive subgraph parsing in parallel with each other. Since your implementation is a bit cleaner, I fixed my code to use yours, and both the unit test and my pull request for rqt_graph are functioning correctly with these changes. I'd like for you and @dirk-thomas to look at my pull request as it is now and provide feedback as necessary. |
return node_item | ||
|
||
def addEdgeItem(self, edge, nodes, edges, highlight_level, same_label_siblings=False): | ||
def addEdgeItem(self, edge, nodes, edges, highlight_level, scene=None, same_label_siblings=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the new keyword argument scene
at the end of the signature. That will avoid breaking any code using the current signature without specifying the keyword explicitly.
Same below for dotcode_to_qt_items
.
return nodes, edges | ||
|
||
def parse_nodes(self, graph, highlight_level): | ||
def parse_nodes(self, graph, highlight_level, scene): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the new argument be an optional keyword argument (for the same compatibility reason mentioned above).
All callers should pass the keyword argument by explicitly passing the keyword.
Same for parse_edges
below.
@@ -127,6 +127,7 @@ def __init__(self, highlight_level, spline, label_center, label, from_node, to_n | |||
self._arrow.setAcceptHoverEvents(True) | |||
|
|||
self._path = QGraphicsPathItem() | |||
self._path = QGraphicsPathItem(parent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the line before be removed?
elif shape == 'box3d': | ||
self._graphics_item = QGraphicsBox3dItem(bounding_box) | ||
else: | ||
#raise ValueError("Invalid shape '"+shape+"'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the commented code line.
self._graphics_item = QGraphicsBox3dItem(bounding_box) | ||
else: | ||
#raise ValueError("Invalid shape '"+shape+"'") | ||
print("Invalid shape '"+shape+"', defaulting to ellipse") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use print("Invalid shape '%s', defaulting to ellipse" % shape)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also print the error message to stderr
:
print('...', file=sys.stderr)
This will require the following at the top of the file:
from __future__ import print_function
import sys
painter.drawLine(self._bounding_box.topRight().x(), | ||
self._bounding_box.topRight().y(), | ||
self._bounding_box.topRight().x(), | ||
self._bounding_box.bottomRight().y() - self._bounding_box.height() * 0.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use four space indentation and a newline at the end of the file to match the code style of the existing code.
@dirk-thomas I have made the requested changes. I'll start work on splitting the related ros-visualization/rqt_graph#9 |
@mastereric This comment is still pending. |
@dirk-thomas Sorry for the delay in resolving the issues in your comment. The changes have been completed, please review them when you have time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside a few nitpicks this looks good to be merged.
@@ -0,0 +1,44 @@ | |||
from python_qt_binding.QtCore import QRectF | |||
from python_qt_binding.QtGui import QColor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import not used.
rectangle = QRectF(self._bounding_box.topLeft().x(), | ||
self._bounding_box.topLeft().y() + self._bounding_box.height() * 0.1, | ||
self._bounding_box.width() - self._bounding_box.height() * 0.1, | ||
self._bounding_box.height() - self._bounding_box.height() * 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation doesn't align with parenthesis.
"""Recursively searches all nodes inside the graph and all subgraphs.""" | ||
# let pydot imitate pygraphviz api | ||
graph.nodes_iter = graph.get_node_list | ||
graph.subgraphs_iter = graph.get_subgraph_list | ||
|
||
nodes = {} | ||
edges = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigned but never used?
@@ -75,6 +77,17 @@ def __init__(self, highlight_level, bounding_box, label, shape, color=None, pare | |||
|
|||
self.hovershape = None | |||
|
|||
def parse_shape(self, shape, bounding_box): | |||
if shape == 'box' or shape == 'rect' or shape == 'rectangle': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead: if shape in ('box', 'rect', 'rectangle'):
Similar below.
Hey @dirk-thomas, I've posted revisions to your latest set of nitpicks, and hope this code can be merged soon. After that, I'll look into pushing these revisions to lunar-devel as well. P.S. It was cool meeting you back at ROSCon 2017! |
self._graphics_item = QGraphicsRectItem(bounding_box) | ||
elif shape in ('ellipse', 'oval', 'circle'): | ||
self._graphics_item = QGraphicsEllipseItem(bounding_box) | ||
elif shape in ('box3d'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a bit tricky. With a single item in the parenthesis Python doesn't interpret that as a list. So share='box'
would match. It needs to be: elif shape in ('box3d', ):
. I will apply the change directly.
I just committed a minor logic fix in 8180a48 Once CI has passed I will merge this. Thank you for your effort on this nice feature!
This repo doesn't have a Lunar-specific branch. Kinetic and Lunar are using the same code from the For the pending PR downstream you might want to make sure to add a minimum version for the dependency on
It is always great to add a face to the GitHub username 😉 |
Looks like I misread one of your comments; the changes here need to be backported (to a new branch ros-visualization/qt_gui_core:indigo-devel), not forward-ported, right? |
Oh right, since the plugin using this actually has a single branch across all ROS distros. The only downside is that we won't be able to specify a version dependency then since |
Specifying a version dependency seems important, since the new version of rqt_graph depends on this new version of qt_gui_core. Could we branch the current repo from where the last indigo version was made and create an |
The branch in this repo used for Indigo is As a next step it would be good if you create a branch from the |
@dirk-thomas Sorry for the delay in this, I cherry picked my commit to the |
This commit includes several features: