Skip to content

Commit

Permalink
Adding updates to globe explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
ayenpure committed Dec 16, 2024
1 parent a6b7769 commit 4e58c35
Show file tree
Hide file tree
Showing 7 changed files with 949 additions and 24 deletions.
52 changes: 29 additions & 23 deletions pan3d/explorers/globe.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
from pan3d.utils.presets import apply_preset

from pan3d.ui.vtk_view import Pan3DView, Pan3DScalarBar
from pan3d.ui.preview import SummaryToolbar, ControlPanel
from pan3d.ui.globe import SummaryToolbar, ControlPanel

from pan3d.utils.globe import get_globe, get_globe_textures, get_continent_outlines


@TrameApp()
Expand Down Expand Up @@ -97,6 +99,9 @@ def __init__(self, server=None, local_rendering=None):
# Process CLI
self.ctrl.on_server_ready.add(self._process_cli)

self.textures = get_globe_textures()
self.state.textures = list(self.textures.keys())

self.state.nan_colors = [
[0, 0, 0, 1],
[0.99, 0.99, 0.99, 1],
Expand Down Expand Up @@ -129,17 +134,9 @@ def _setup_vtk(self):

self.source = vtkXArrayRectilinearSource()

from pan3d.utils.globe import (
get_globe,
get_globe_texture,
get_continent_outlines,
)

self.globe = get_globe()
self.texture = get_globe_texture()
self.gmapper = vtkPolyDataMapper(input_data_object=self.globe)
self.gactor = vtkActor(mapper=self.gmapper, visibility=1)
self.gactor.SetTexture(self.texture)

self.continents = get_continent_outlines()
self.cmapper = vtkPolyDataMapper(input_data_object=self.continents)
Expand Down Expand Up @@ -300,34 +297,43 @@ def _on_color_by(self, color_by, **__):
self.state.color_min = 0
self.state.color_max = 1

@change("color_preset", "color_min", "color_max", "nan_color")
@change("color_preset", "color_min", "color_max", "nan_color", "opacity", "texture")
def _on_color_preset(
self, nan_color, nan_colors, color_preset, color_min, color_max, **_
self,
nan_color,
nan_colors,
color_preset,
color_min,
color_max,
opacity,
texture,
**_,
):
color_min = float(color_min)
color_max = float(color_max)
color = nan_colors[nan_color]
opacity = float(opacity)

self.gactor.SetTexture(self.textures[texture])

self.mapper.SetScalarRange(color_min, color_max)
self.actor.GetProperty().SetOpacity(opacity)
apply_preset(self.actor, [color_min, color_max], color_preset, color)
self.state.preset_img = to_image(self.actor.mapper.lookup_table, 255)

self.ctrl.view_update()

@change("scale_x", "scale_y", "scale_z")
def _on_scale_change(self, scale_x, scale_y, scale_z, **_):
self.actor.SetScale(
to_float(scale_x),
to_float(scale_y),
to_float(scale_z),
)
@change("texture")
def _on_texture_preset(self, texture, **_):
self.gactor.SetTexture(self.textures[texture])
self.ctrl.view_update()

@change("data_origin_order")
def _on_order_change(self, **_):
if self.state.import_pending:
return

if self.actor.visibility:
if self.local_rendering:
self.ctrl.view_update()
self.ctrl.view_reset_camera()
self.state.load_button_text = "Load"

@change("data_origin_order")
def _on_order_change(self, **_):
Expand Down Expand Up @@ -424,7 +430,7 @@ def _update_rendering(self, reset_camera=False):
self.state.dirty_data = False

self.gactor.visibility = 1
self.gactor.SetTexture(self.texture)
self.gactor.SetTexture(self.textures[self.state.texture])
self.renderer.AddActor(self.gactor)

self.cactor.visibility = 1
Expand Down
Loading

0 comments on commit 4e58c35

Please sign in to comment.