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

add a display_name attribute #62

Merged
merged 1 commit into from
Jun 6, 2023
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
2 changes: 2 additions & 0 deletions examples/amr_volume_rendering_with_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
curved = CurveData()
curved.add_data(streamlines.streamlines[0])
curve_render = CurveRendering(data=curved, curve_rgba=(1.0, 0.0, 0.0, 1.0))
curve_render.display_name = "single streamline"
rc.scene.data_objects.append(curved)
rc.scene.components.append(curve_render)

Expand All @@ -52,6 +53,7 @@
curve_collection.add_data() # call add_data() after done adding curves

cc_render = CurveCollectionRendering(data=curve_collection)
cc_render.display_name = "multiple streamlines"
rc.scene.data_objects.append(curve_collection)
rc.scene.components.append(cc_render)

Expand Down
2 changes: 1 addition & 1 deletion examples/octree_volume_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

odata = OctreeBlockCollection(data_source=dd)
odata.add_data("density")
oren = OctreeBlockRendering(data=odata)
oren = OctreeBlockRendering(data=odata, display_name="density")

sg.data_objects.append(odata)
sg.components.append(oren)
Expand Down
6 changes: 6 additions & 0 deletions yt_idv/scene_components/base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class SceneComponent(traitlets.HasTraits):
_program2_invalid = True
_cmap_bounds_invalid = True

display_name = traitlets.Unicode(allow_none=True)

# These attributes are
cmap_min = traitlets.CFloat(None, allow_none=True)
cmap_max = traitlets.CFloat(None, allow_none=True)
Expand Down Expand Up @@ -119,6 +121,10 @@ def render_gui(self, imgui, renderer, scene):

return changed

@traitlets.default("display_name")
def _default_display_name(self):
return self.name

@traitlets.default("render_method")
def _default_render_method(self):
return default_shader_combos[self.name]
Expand Down
2 changes: 1 addition & 1 deletion yt_idv/simple_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def render(self, scene):
changed = changed or _
# imgui.show_style_editor()
for i, element in enumerate(scene):
if imgui.tree_node(f"element {i + 1}: {element.name}"):
if imgui.tree_node(f"element {i + 1}: {element.display_name}"):
changed = changed or element.render_gui(imgui, self.renderer, scene)
imgui.tree_pop()
self.window._do_update = self.window._do_update or changed
Expand Down