Skip to content

Commit

Permalink
Merge pull request #146 from ayenpure/globe_revision
Browse files Browse the repository at this point in the history
Adding updates to globe explorer
  • Loading branch information
jourdain authored Dec 18, 2024
2 parents fadccf2 + f1ff447 commit edc8c0e
Show file tree
Hide file tree
Showing 7 changed files with 737 additions and 29 deletions.
56 changes: 28 additions & 28 deletions pan3d/explorers/globe.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@

from pan3d.xarray.algorithm import vtkXArrayRectilinearSource

from pan3d.utils.convert import update_camera, to_image, to_float
from pan3d.utils.convert import update_camera, to_image
from pan3d.utils.presets import set_preset

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

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


@TrameApp()
Expand Down Expand Up @@ -98,6 +101,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 All @@ -118,6 +124,8 @@ def __init__(self, server=None, local_rendering=None):
# -------------------------------------------------------------------------

def _setup_vtk(self):
self.lut = vtkLookupTable()

self.renderer = vtkRenderer(background=(0.8, 0.8, 0.8))
self.interactor = vtkRenderWindowInteractor()
self.render_window = vtkRenderWindow(off_screen_rendering=1)
Expand All @@ -130,19 +138,9 @@ def _setup_vtk(self):

self.source = vtkXArrayRectilinearSource()

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

self.lut = vtkLookupTable()

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 @@ -307,7 +305,14 @@ def _on_color_by(self, color_by, **__):

@change("color_preset", "color_min", "color_max", "nan_color")
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,
**_,
):
color_min = float(color_min)
color_max = float(color_max)
Expand All @@ -321,21 +326,16 @@ def _on_color_preset(

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),
)

if self.state.import_pending:
return
@change("opacity")
def _on_change_opacity(self, opacity, **_):
opacity = float(opacity)
self.actor.GetProperty().SetOpacity(opacity)
self.ctrl.view_update()

if self.actor.visibility:
if self.local_rendering:
self.ctrl.view_update()
self.ctrl.view_reset_camera()
@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, **_):
Expand Down Expand Up @@ -432,7 +432,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 edc8c0e

Please sign in to comment.