Skip to content

Commit

Permalink
Merge pull request #12 from Carifio24/sphere-size
Browse files Browse the repository at this point in the history
Improve calculation for scatter sphere sizes
  • Loading branch information
Carifio24 authored Dec 25, 2023
2 parents 00be69b + f77309e commit 983604d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions glue_ar/scatter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pyvista as pv
from glue_ar.utils import layer_color, xyz_for_layer
from glue_ar.utils import layer_color, xyz_bounds, xyz_for_layer


# For the 3D scatter viewer
Expand Down Expand Up @@ -38,7 +38,10 @@ def scatter_layer_as_multiblock(viewer_state, layer_state,
phi_resolution=8,
scaled=True):
data = xyz_for_layer(viewer_state, layer_state, scaled=scaled)
spheres = [pv.Sphere(center=p, radius=layer_state.size_scaling * layer_state.size / 600, phi_resolution=phi_resolution, theta_resolution=theta_resolution) for p in data]
bounds = xyz_bounds(viewer_state)
factor = max((abs(b[1] - b[0]) for b in bounds))
radius = layer_state.size_scaling * layer_state.size / factor
spheres = [pv.Sphere(center=p, radius=radius, phi_resolution=phi_resolution, theta_resolution=theta_resolution) for p in data]
blocks = pv.MultiBlock(spheres)
geometry = blocks.extract_geometry()
info = {
Expand Down
2 changes: 1 addition & 1 deletion glue_ar/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def activate(self):
layer_states = [layer.state for layer in self.viewer.layers if layer.enabled and layer.state.visible]
for layer_state in layer_states:
layer_info = dialog.state_dictionary[layer_state.layer.label].as_dict()
mesh_info = scatter_layer_as_multiblock(self.viewer.state, layer_state, **layer_info)
mesh_info = scatter_layer_as_multiblock(self.viewer.state, layer_state, **layer_info, scaled=True)
data = mesh_info.pop("data")
plotter.add_mesh(data, **mesh_info)

Expand Down

0 comments on commit 983604d

Please sign in to comment.