Commit fc8ac1da authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

graph_draw(): Fix bug with interactive drawing

parent a00ea26a
Pipeline #230 failed with stage
in 174 minutes and 35 seconds
......@@ -1858,6 +1858,7 @@ boost::python::object cairo_draw(GraphInterface& gi,
vertex_scalar_vector_properties(),
vorder_t())(pos, vorder);
}
yield(boost::python::object(count));
};
return boost::python::object(CoroGenerator(dispatch));
}
......
......@@ -594,9 +594,9 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None,
res : float (optional, default: ``0.``):
If shape sizes fall below this value, simplified drawing is used.
max_render_time : int (optional, default: ``-1``):
Maximum allowed time (in milliseconds) for rendering. If exceeded, the
rendering will return unfinished. If negative values are given, the
rendering will always complete.
If nonnegative, this function will return an iterator that will perform
part of the drawing at each step, so that each iteration takes at most
``max_render_time`` milliseconds.
vertex_* : :class:`~graph_tool.PropertyMap` or arbitrary types (optional, default: ``None``)
Parameters following the pattern ``vertex_<prop-name>`` specify the
vertex property with name ``<prop-name>``, as an alternative to the
......@@ -608,9 +608,10 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None,
Returns
-------
offset : int
The offset into the completed rendering. If this value is zero, the
rendering was complete.
iterator :
If ``max_render_time`` is nonnegative, this will be an iterator that will
perform part of the drawing at each step, so that each iteration takes
at most ``max_render_time`` milliseconds.
"""
if vorder is not None:
......@@ -687,8 +688,7 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None,
nodesfirst, vattrs, eattrs, vdefs, edefs, res,
max_render_time, cr)
if max_render_time >= 0:
for count in generator:
yield count
return generator
else:
for count in generator:
pass
......
......@@ -491,6 +491,8 @@ class GraphWidget(Gtk.DrawingArea):
max_render_time=mtime, **self.kwargs)
self.regenerate_generator = gen
self.regen_context = cr
if self.regenerate_generator is not None:
try:
next(self.regenerate_generator)
except StopIteration:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment