Skip to content

Commit

Permalink
[ENH] All pyvista interactions running again!
Browse files Browse the repository at this point in the history
  • Loading branch information
Leguark committed May 17, 2020
1 parent 94f0002 commit ebb0ea4
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 4,359 deletions.
1 change: 0 additions & 1 deletion gempy/plot/_vista.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,6 @@ def zcallback(normal, origin):
self.p.view_xy()
self.p.disable()


def _callback_surface_points(self, pos, index, widget):
i = index
x, y, z = pos
Expand Down
36 changes: 22 additions & 14 deletions gempy/plot/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .visualization_3d import GemPyvtkInteract
from gempy.plot.vista import GemPyToVista
from functools import wraps


Expand All @@ -8,8 +9,9 @@ def pasp(*args, **kwargs):
plot_object = kwargs.pop('plot_object') if 'plot_object' in kwargs else None
surface_points, idx = func(*args, **kwargs)
if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_add_surface_points(idx)
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_add_surface_points(idx)
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return surface_points
Expand All @@ -22,8 +24,9 @@ def pdsp(*args, **kwargs):
plot_object = kwargs.pop('plot_object') if 'plot_object' in kwargs else None
surface_points = func(*args, **kwargs)
if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_delete_surface_points(args[1])
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_delete_surface_points(args[1])
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return surface_points
Expand All @@ -43,8 +46,9 @@ def pmsp(*args, **kwargs):
plot_object = kwargs.pop('plot_object') if 'plot_object' in kwargs else None
surface_points = func(*args, **kwargs)
if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_move_surface_points(indices)
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_move_surface_points(indices)
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return surface_points
Expand All @@ -57,8 +61,9 @@ def pao(*args, **kwargs):
plot_object = kwargs.pop('plot_object') if 'plot_object' in kwargs else None
orientation, idx = func(*args, **kwargs)
if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_add_orientations(idx)
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_add_orientations(idx)
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return orientation
Expand All @@ -71,8 +76,9 @@ def pdo(*args, **kwargs):
plot_object = kwargs.pop('plot_object') if 'plot_object' in kwargs else None
orientations = func(*args, **kwargs)
if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_delete_orientations(args[1])
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_delete_orientations(args[1])
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return orientations
Expand All @@ -86,8 +92,9 @@ def pmo(*args, **kwargs):
orientations = func(*args, **kwargs)

if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_move_orientations(args[1])
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_move_orientations(args[1])
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return orientations
Expand All @@ -101,8 +108,9 @@ def pst(*args, **kwargs):
topography = func(*args, **kwargs)

if plot_object is not None:
if isinstance(plot_object, GemPyvtkInteract):
plot_object.render_topography()
if isinstance(plot_object, GemPyToVista):
if plot_object.live_updating is True:
plot_object.render_topography()
else:
raise AttributeError('plot_object must be one GemPy compatible plot')
return topography
Expand Down
27 changes: 27 additions & 0 deletions gempy/plot/plot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,33 @@ def plot_3d(model, plotter_type='basic',
return gpv


def plot_interactive_3d(
geo_model,
scalar_field: str = 'all',
series=None,
render_topography: bool = False,
**kwargs,
):
"""Plot interactive 3-D geomodel with three cross sections in subplots.
Args:
geo_model: Geomodel object with solutions.
name (str): Can be either one of the following
'lith' - Lithology id block.
'scalar' - Scalar field block.
'values' - Values matrix block.
render_topography: Render topography. Defaults to False.
**kwargs:
Returns:
:class:`gempy.plot.vista.GemPyToVista`
"""
gpv = GemPyToVista(geo_model, show_results=False, plotter_type='background', shape="1|3")
gpv.plot_structured_grid_interactive(scalar_field=scalar_field, series=series,
render_topography=render_topography, **kwargs)

return gpv


def plot_section_traces(model):
"""Plot section traces of section grid in 2-D topview (xy).
Expand Down
Loading

0 comments on commit ebb0ea4

Please sign in to comment.