-
Notifications
You must be signed in to change notification settings - Fork 7
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
Raster overlay UI/UX enhancements #649
Conversation
…nto raster-overlay-ui-enhancements
exts/cesium.omniverse/cesium/omniverse/ui/attributes/ion_raster_overlay_attributes_widget.py
Outdated
Show resolved
Hide resolved
def _build_slider( | ||
stage, | ||
attr_name, | ||
metadata, | ||
property_type, | ||
prim_paths: List[Sdf.Path], | ||
additional_label_kwargs={}, | ||
additional_widget_kwargs={}, | ||
): | ||
from omni.kit.window.property.templates import HORIZONTAL_SPACING | ||
from omni.kit.property.usd.usd_attribute_model import UsdAttributeModel | ||
from omni.kit.property.usd.usd_property_widget import UsdPropertiesWidgetBuilder | ||
|
||
if not attr_name or not property_type: | ||
return | ||
|
||
with ui.HStack(spacing=HORIZONTAL_SPACING): | ||
model_kwargs = UsdPropertiesWidgetBuilder.get_attr_value_range_kwargs(metadata) | ||
model = UsdAttributeModel( | ||
stage, | ||
[path.AppendProperty(attr_name) for path in prim_paths], | ||
False, | ||
metadata, | ||
**model_kwargs, | ||
) | ||
UsdPropertiesWidgetBuilder.create_label(attr_name, metadata, additional_label_kwargs) | ||
widget_kwargs = {"model": model, "min": 0.0, "max": 1.0} | ||
widget_kwargs.update(UsdPropertiesWidgetBuilder.get_attr_value_soft_range_kwargs(metadata)) | ||
|
||
if additional_widget_kwargs: | ||
widget_kwargs.update(additional_widget_kwargs) | ||
with ui.ZStack(): | ||
value_widget = UsdPropertiesWidgetBuilder.create_drag_or_slider( | ||
ui.FloatDrag, ui.FloatSlider, **widget_kwargs | ||
) | ||
mixed_overlay = UsdPropertiesWidgetBuilder.create_mixed_text_overlay() | ||
UsdPropertiesWidgetBuilder.create_control_state( | ||
value_widget=value_widget, mixed_overlay=mixed_overlay, **widget_kwargs | ||
) | ||
model.add_value_changed_fn(lambda m, s=stage, p=prim_paths: update_range(s, p)) | ||
|
||
return model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make this more generic and put in a helper file so it's not duplicated across files? E.g. I imagine the min/max values would be provided as options instead of hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Pushed. You can now call CustomLayoutProperty("cesium:alpha", build_fn=build_slider(0, 1))
with whichever values you want.
There might be a more Pythonic way to do this (with partial
?) but this feels OK. I'm not yet fluently Pythonic, and some of my Python I've been told is like transliterated game-engine C++. This is literally transliterated game-engine C# code: [Range(0,1)]
.
We don't have control over it right now, but it's not a major lift. I created a ticket for it. #652 |
You should be able to test the invert issue with the following zip |
Thanks, invert issues appear resolved now! |
I added |
def _update_range(stage, prim_paths): | ||
for path in prim_paths: | ||
rasterOverlay = CesiumRasterOverlay.Get(stage, path) | ||
attr = rasterOverlay.GetAlphaAttr() | ||
current_value = attr.Get() | ||
new_value = max(0, min(current_value, 1.0)) | ||
attr.Set(new_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to not hardcode CesiumRasterOverlay
? I imagine we'll want to use this widget for other prim types.
Also it's not clear to me how the min/max options that are passed to build_slider
are getting set. Seems like 0 and 1 are still hardcoded in a couple places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I'd left 0 and 1 in widget_kwargs
. Gone now.
I was able to remove the dependency on CesiumRasterOverlay
.
Note: There were issues operating on generic prims. For some reason, only class functions to access attributes would work (e.g., GetAlphaAttr
) in event handlers. Fortunately, we don't need update_range
anyways. It's cruft from an example where bounds
and its associated attributes needed to be updated. We might possible run into this in the future if we want to do something like update bounds on generic prims.
…nto raster-overlay-ui-enhancements
…esiumGS/cesium-omniverse into raster-overlay-ui-enhancements
CesiumPolygonRasterOverlayPrim
andCesiumIonRasterOverlayPrim
CesiumPolygonRasterOverlayPrim
CesiumPolygonRasterOverlayPrim
andCesiumIonRasterOverlayPrim
"alpha" attribute a sliderBasisCurves
created via Quick-Add menu have appropriate settings fortype
,wrap
, andpoints
attributes.BasisCurves
Resolves #633
Resolves #618
Resolves #631