Skip to content

Commit

Permalink
[#183] Re-exposes threshold levels and opacity controls. (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
dignojrteogalbo authored Apr 21, 2024
1 parent 48f57c8 commit af34ca4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 71 deletions.
30 changes: 1 addition & 29 deletions GoVizzy/.virtual_documents/GoVizzy.ipynb
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@



from widgets import form, test_slider
from GoVizzy import plotting, meshes
from UI import DisplayUI
import fileInput
import ipyvolume as ipv
import scipy
import numpy as np
from cube_viskit import Cube
import itertools




%run Main.py


# Load Cube File
cube: Cube = Cube()
cube.load_cube("data/rhopol.cube")
visualizer = plotting.Visualizer(cube)
# Display Cube File
visualizer.display_cell()
origin = (50, 50, 50)
radius = 10
meshes.plot_sphere_surface(origin, radius)


form


%matplotlib widget



Expand Down
86 changes: 46 additions & 40 deletions GoVizzy/gv_ui/gv_ui/DisplayUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# atom mesh globals
atom_meshes = []

# visualizer global
visualizer = None

def show_menu():
"""
Displays logo and hides the app output.
Expand Down Expand Up @@ -69,7 +72,7 @@ def display_cube(cube):
Displays the cube plot based on the value of the dropdown.
"""

global atom_meshes
global atom_meshes, visualizer
visualizer = plotting.Visualizer(cube)
with large_box: # Capture output within large_box
# Clear previous content
Expand Down Expand Up @@ -101,58 +104,61 @@ def display_app():
"""

# Containers for right menu
global atom_meshes

global atom_meshes, visualizer
top_container = HBox([dropdown, in_app_exit])

bottom_container = HBox([newCube_button, save_button])

# Combine the Output widgets with their descriptions
if selected_option == 'Slice Options':
#display slidersss TO DO
with selected_view_options:
selected_view_options.clear_output()
slice_box = VBox([slice_picker_descr, gvWidgets.slice_x_slider, gvWidgets.slice_x_check, gvWidgets.slice_y_slider, gvWidgets.slice_y_check, gvWidgets.slice_z_slider, gvWidgets.slice_z_check])
with selected_view_options:
selected_view_options.clear_output()
figure_controls = visualizer.figure.volumes[0].tf.control()
# Combine the Output widgets with their descriptions
if selected_option == 'Slice Options':
#display slidersss TO DO
slice_box = VBox([slice_picker_descr,
gvWidgets.slice_x_slider,
gvWidgets.slice_x_check,
gvWidgets.slice_y_slider,
gvWidgets.slice_y_check,
gvWidgets.slice_z_slider,
gvWidgets.slice_z_check,
figure_controls])
display(slice_box)






elif selected_option == 'Mesh Options':
#display Mesh TO DO
atom_controls = []
for mesh in atom_meshes:
controls = [mesh_visibility_toggle(mesh, 'Visible'),
atom_color_picker(mesh, 'Color'),
atom_scale_slider(mesh, 'Scale')]
atom_controls.append(VBox(children=controls))
titles = tuple(f'Atom {idx}' for idx in range(len(atom_controls)))

print(atom_controls)
print(titles)

with selected_view_options:
selected_view_options.clear_output()
elif selected_option == 'Mesh Options':
#display Mesh TO DO
atom_controls = []
for mesh in atom_meshes:
controls = [mesh_visibility_toggle(mesh, 'Visible'),
atom_color_picker(mesh, 'Color'),
atom_scale_slider(mesh, 'Scale')]
atom_controls.append(VBox(children=controls))
titles = tuple(f'Atom {idx}' for idx in range(len(atom_controls)))

accordion = Accordion(children=atom_controls, titles=titles)
mesh_box = VBox([accordion, gvWidgets.bond_visibility_toggle, gvWidgets.bond_color_picker, gvWidgets.bond_scale_slider])
mesh_box = VBox([accordion,
gvWidgets.bond_visibility_toggle,
gvWidgets.bond_color_picker,
gvWidgets.bond_scale_slider,
figure_controls])
display(mesh_box)






elif selected_option == 'Color Options':
#ADD color controls here
with selected_view_options:
selected_view_options.clear_output()





else:
elif selected_option == 'Color Options':
#ADD color controls here
pass




else:
print("Invalid option selected")

# Display the layout
view_bar = VBox([top_container, selected_view_options, bottom_container], layout=Layout(flex='1'))

Expand Down
6 changes: 4 additions & 2 deletions GoVizzy/gv_ui/gv_ui/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from IPython.display import display
from gv_ui import gvWidgets
import matplotlib.pyplot as plt
from ipyvolume import Figure

class Visualizer:
"""
Expand All @@ -15,6 +16,7 @@ class Visualizer:
"""

cube: Cube
figure: Figure

def __init__(self, cube: Cube):
self.cube = cube
Expand Down Expand Up @@ -96,7 +98,7 @@ def display_cell(self):
Displays the cube's data3D with the volshow() method.
"""
cube = self.cube
ipv.figure()
self.figure = ipv.figure()
transfer = ipv.pylab.transfer_function(level=[0.03, 0.5, 0.47], opacity=[0.05, 0.09, 0.1], level_width=0.1, controls=False)
ipv.style.background_color(gvWidgets.color.value)
ipv.pylab.volshow(cube.data3D, ambient_coefficient=0.8, lighting=True, tf=transfer, controls=False)
Expand All @@ -108,7 +110,7 @@ def display_cell_slices(self):
and attach slices with textures set to the volume data.
"""
cube = self.cube
fig = ipv.figure()
self.figure = ipv.figure()
transfer = ipv.pylab.transfer_function(level=[0.03, 0.5, 0.47], opacity=[0.05, 0.09, 0.1], level_width=0.1, controls=False)
ipv.style.background_color(gvWidgets.color.value)

Expand Down

0 comments on commit af34ca4

Please sign in to comment.