Skip to content

Commit

Permalink
Consistently return actors (pyvista#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan authored Feb 4, 2020
1 parent 24a2bca commit c73ea2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
28 changes: 15 additions & 13 deletions pyvista/plotting/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,8 @@ def add_scalar_bar(self, title=None, n_labels=5, italic=False,

self.add_actor(self.scalar_bar, reset_camera=False, pickable=False)

return self.scalar_bar # return the actor

def update_scalars(self, scalars, mesh=None, render=True):
"""Update scalars of an object in the plotter.
Expand Down Expand Up @@ -2840,17 +2842,17 @@ def add_lines(self, lines, color=(1, 1, 1), width=5, label=None, name=None):
self._labels.append([lines, label, rgb_color])

# Create actor
self.scalar_bar = vtk.vtkActor()
self.scalar_bar.SetMapper(mapper)
self.scalar_bar.GetProperty().SetLineWidth(width)
self.scalar_bar.GetProperty().EdgeVisibilityOn()
self.scalar_bar.GetProperty().SetEdgeColor(rgb_color)
self.scalar_bar.GetProperty().SetColor(rgb_color)
self.scalar_bar.GetProperty().LightingOff()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetLineWidth(width)
actor.GetProperty().EdgeVisibilityOn()
actor.GetProperty().SetEdgeColor(rgb_color)
actor.GetProperty().SetColor(rgb_color)
actor.GetProperty().LightingOff()

# Add to renderer
self.add_actor(self.scalar_bar, reset_camera=False, name=name, pickable=False)
return self.scalar_bar
self.add_actor(actor, reset_camera=False, name=name, pickable=False)
return actor

def remove_scalar_bar(self):
"""Remove the scalar bar."""
Expand Down Expand Up @@ -2944,8 +2946,8 @@ def add_point_labels(self, points, labels, italic=False, bold=True,
Return
------
labelMapper : vtk.vtkvtkLabeledDataMapper
VTK label mapper. Can be used to change properties of the labels.
labelActor : vtk.vtkActor2D
VTK label actor. Can be used to change properties of the labels.
"""
if font_family is None:
Expand Down Expand Up @@ -3037,7 +3039,7 @@ def add_point_labels(self, points, labels, italic=False, bold=True,
self.add_actor(labelActor, reset_camera=False,
name='{}-labels'.format(name), pickable=False)

return labelMapper
return labelActor


def add_point_scalar_labels(self, points, labels, fmt=None, preamble='', **kwargs):
Expand Down Expand Up @@ -3074,7 +3076,7 @@ def add_point_scalar_labels(self, points, labels, fmt=None, preamble='', **kwarg
def add_points(self, points, **kwargs):
"""Add points to a mesh."""
kwargs['style'] = 'points'
self.add_mesh(points, **kwargs)
return self.add_mesh(points, **kwargs)

def add_arrows(self, cent, direction, mag=1, **kwargs):
"""Add arrows to plotting object."""
Expand Down
3 changes: 2 additions & 1 deletion pyvista/plotting/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def add_border(self, color=[1, 1, 1], width=2.0):
actor.GetProperty().SetLineWidth(width)

self.AddViewProp(actor)
return actor


def add_actor(self, uinput, reset_camera=False, name=None, culling=False,
Expand Down Expand Up @@ -444,7 +445,7 @@ def add_axes(self, interactive=None, line_width=2,
self.axes_widget.SetEnabled(1)
self.axes_widget.SetInteractive(interactive)
self.axes_widget.SetCurrentRenderer(self)
return
return self.axes_actor


def hide_axes(self):
Expand Down

0 comments on commit c73ea2a

Please sign in to comment.