Skip to content
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

fix (explorer consistency): Making explorer name and constructor arguments consistent #154

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pan3d/explorers/globe.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


@TrameApp()
class GlobeViewer:
class GlobeExplorer:
"""
A Trame based pan3D explorer to visualize 3D geographic data projected onto a globe
representing the earth or projected using various cartographic projections.
Expand Down Expand Up @@ -591,7 +591,7 @@ def _ipython_display_(self):


def main():
app = GlobeViewer()
app = GlobeExplorer()
app.start()


Expand Down
26 changes: 22 additions & 4 deletions pan3d/explorers/slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


@TrameApp()
class XArraySlicer:
class SliceExplorer:
"""
A Trame based pan3D explorer to visualize 3D using slices along different dimensions

Expand All @@ -54,7 +54,7 @@ class XArraySlicer:
using VTK while interacting with the slice in 2D or 3D.
"""

def __init__(self, xarray=None, source=None, server=None):
def __init__(self, xarray=None, source=None, server=None, local_rendering=None):
# trame setup
self.server = get_server(server)
if self.server.hot_reload:
Expand All @@ -67,9 +67,26 @@ def __init__(self, xarray=None, source=None, server=None):
help="Pass a string with this argument to specify a startup configuration. This value must be a local path to a JSON file which adheres to the schema specified in the [Configuration Files documentation](../api/configuration.md).",
required=(source is None and xarray is None),
)
args, _ = parser.parse_known_args()
# Local rendering setup
parser.add_argument(
"--wasm",
help="Use WASM for local rendering",
action="store_true",
)
parser.add_argument(
"--vtkjs",
help="Use vtk.js for local rendering",
action="store_true",
)

args, _ = parser.parse_known_args()
self.local_rendering = local_rendering
if args.wasm:
self.local_rendering = "wasm"
if args.vtkjs:
self.local_rendering = "vtkjs"
# Check if we have what we need

config_file = Path(args.import_state) if args.import_state else None
if (
(config_file is None or not config_file.exists())
Expand Down Expand Up @@ -703,6 +720,7 @@ def _build_ui(self, *args, **kwargs):
# 3D view
Pan3DView(
self.render_window,
local_rendering=self.local_rendering,
axis_names="slice_axes",
style="position: absolute; left: 0; top: var(--v-layout-top); bottom: var(--v-layout-bottom); z-index: 0; width: 100%;",
)
Expand Down Expand Up @@ -801,7 +819,7 @@ def _ipython_display_(self):


def main():
app = XArraySlicer()
app = SliceExplorer()
app.start()


Expand Down
10 changes: 5 additions & 5 deletions pan3d/xarray/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ def preview(self):

@property
def slicer(self):
from pan3d.explorers.slicer import XArraySlicer
from pan3d.explorers.slicer import SliceExplorer

if self._viewer_slicer is None:
self._viewer_slicer = XArraySlicer(
self._viewer_slicer = SliceExplorer(
xarray=self.xarray,
server=self.next_id(),
# local_rendering=self._local_rendering, # FIXME Abhishek
local_rendering=self._local_rendering,
)

return self._viewer_slicer

@property
def globe(self):
from pan3d.explorers.globe import GlobeViewer
from pan3d.explorers.globe import GlobeExplorer

if self._viewer_globe is None:
self._viewer_globe = GlobeViewer(
self._viewer_globe = GlobeExplorer(
xarray=self.xarray,
server=self.next_id(),
local_rendering=self._local_rendering,
Expand Down
Loading