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, ...@@ -1858,6 +1858,7 @@ boost::python::object cairo_draw(GraphInterface& gi,
vertex_scalar_vector_properties(), vertex_scalar_vector_properties(),
vorder_t())(pos, vorder); vorder_t())(pos, vorder);
} }
yield(boost::python::object(count));
}; };
return boost::python::object(CoroGenerator(dispatch)); return boost::python::object(CoroGenerator(dispatch));
} }
......
...@@ -594,9 +594,9 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None, ...@@ -594,9 +594,9 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None,
res : float (optional, default: ``0.``): res : float (optional, default: ``0.``):
If shape sizes fall below this value, simplified drawing is used. If shape sizes fall below this value, simplified drawing is used.
max_render_time : int (optional, default: ``-1``): max_render_time : int (optional, default: ``-1``):
Maximum allowed time (in milliseconds) for rendering. If exceeded, the If nonnegative, this function will return an iterator that will perform
rendering will return unfinished. If negative values are given, the part of the drawing at each step, so that each iteration takes at most
rendering will always complete. ``max_render_time`` milliseconds.
vertex_* : :class:`~graph_tool.PropertyMap` or arbitrary types (optional, default: ``None``) vertex_* : :class:`~graph_tool.PropertyMap` or arbitrary types (optional, default: ``None``)
Parameters following the pattern ``vertex_<prop-name>`` specify the Parameters following the pattern ``vertex_<prop-name>`` specify the
vertex property with name ``<prop-name>``, as an alternative to 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, ...@@ -608,9 +608,10 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None,
Returns Returns
------- -------
offset : int iterator :
The offset into the completed rendering. If this value is zero, the If ``max_render_time`` is nonnegative, this will be an iterator that will
rendering was complete. perform part of the drawing at each step, so that each iteration takes
at most ``max_render_time`` milliseconds.
""" """
if vorder is not None: if vorder is not None:
...@@ -687,8 +688,7 @@ def cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=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, nodesfirst, vattrs, eattrs, vdefs, edefs, res,
max_render_time, cr) max_render_time, cr)
if max_render_time >= 0: if max_render_time >= 0:
for count in generator: return generator
yield count
else: else:
for count in generator: for count in generator:
pass pass
......
...@@ -491,11 +491,13 @@ class GraphWidget(Gtk.DrawingArea): ...@@ -491,11 +491,13 @@ class GraphWidget(Gtk.DrawingArea):
max_render_time=mtime, **self.kwargs) max_render_time=mtime, **self.kwargs)
self.regenerate_generator = gen self.regenerate_generator = gen
self.regen_context = cr self.regen_context = cr
try:
next(self.regenerate_generator) if self.regenerate_generator is not None:
except StopIteration: try:
self.regenerate_generator = None next(self.regenerate_generator)
self.regen_context = None except StopIteration:
self.regenerate_generator = None
self.regen_context = None
self.lazy_regenerate = False self.lazy_regenerate = False
def draw(self, da, cr): def draw(self, da, cr):
......
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