Skip to content

Commit edb2d49

Browse files
committed
add UI enhancements
1 parent 0def569 commit edb2d49

File tree

3 files changed

+75
-35
lines changed

3 files changed

+75
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import logging
2+
import omni.usd
3+
import omni.ui
4+
import omni.kit.window.property
25
from omni.kit.property.usd.custom_layout_helper import CustomLayoutFrame, CustomLayoutGroup, CustomLayoutProperty
36
from omni.kit.property.usd.usd_property_widget import SchemaPropertiesWidget
47
from cesium.usd.plugins.CesiumUsdSchemas import (
58
TileMapServiceRasterOverlay as CesiumTileMapServiceRasterOverlay,
69
)
710
from .cesium_properties_widget_builder import build_slider, build_common_raster_overlay_properties
11+
from pxr import Usd, Tf
812

913

1014
class CesiumTileMapServiceRasterOverlayAttributesWidget(SchemaPropertiesWidget):
@@ -17,31 +21,54 @@ def __init__(self):
1721

1822
self._logger = logging.getLogger(__name__)
1923

24+
self._listener = None
25+
self._props = None
26+
self._stage = omni.usd.get_context().get_stage()
27+
2028
def clean(self):
2129
super().clean()
2230

31+
def _on_usd_changed(self, notice, stage):
32+
window = omni.kit.window.property.get_window()
33+
window.request_rebuild()
34+
2335
def _customize_props_layout(self, props):
36+
if not self._listener:
37+
self._listener = Tf.Notice.Register(Usd.Notice.ObjectsChanged, self._on_usd_changed, self._stage)
38+
2439
frame = CustomLayoutFrame(hide_extra=True)
2540

41+
prim_path = self._payload.get_paths()[0]
42+
tileMapServiceRasterOverlay = CesiumTileMapServiceRasterOverlay.Get(self._stage, prim_path)
43+
specify_zoom_levels = tileMapServiceRasterOverlay.GetSpecifyZoomLevelsAttr().Get()
44+
2645
with frame:
2746
with CustomLayoutGroup("URL"):
2847
CustomLayoutProperty("cesium:url")
2948
with CustomLayoutGroup("Zoom Settings"):
49+
3050
CustomLayoutProperty(
3151
"cesium:specifyZoomLevels",
3252
)
33-
CustomLayoutProperty(
34-
"cesium:minimumZoomLevel",
35-
build_fn=build_slider(
36-
0, 30, type="int", constrain={"attr": "cesium:maximumZoomLevel", "type": "maximum"}
37-
),
38-
)
39-
CustomLayoutProperty(
40-
"cesium:maximumZoomLevel",
41-
build_fn=build_slider(
42-
0, 30, type="int", constrain={"attr": "cesium:minimumZoomLevel", "type": "minimum"}
43-
),
44-
)
53+
if specify_zoom_levels:
54+
CustomLayoutProperty(
55+
"cesium:minimumZoomLevel",
56+
build_fn=build_slider(
57+
0, 30, type="int", constrain={"attr": "cesium:maximumZoomLevel", "type": "maximum"}
58+
),
59+
)
60+
CustomLayoutProperty(
61+
"cesium:maximumZoomLevel",
62+
build_fn=build_slider(
63+
0, 30, type="int", constrain={"attr": "cesium:minimumZoomLevel", "type": "minimum"}
64+
),
65+
)
4566
build_common_raster_overlay_properties()
4667

4768
return frame.apply(props)
69+
70+
def reset(self):
71+
if self._listener:
72+
self._listener.Revoke()
73+
self._listener = None
74+
super().reset()

exts/cesium.omniverse/cesium/omniverse/ui/attributes/web_map_tile_service_raster_overlay_attributes_widget.py

+31-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
import omni.kit.window.property
3+
import omni.usd
24
from omni.kit.property.usd.custom_layout_helper import CustomLayoutFrame, CustomLayoutGroup, CustomLayoutProperty
35
from omni.kit.property.usd.usd_property_widget import SchemaPropertiesWidget
46
from cesium.usd.plugins.CesiumUsdSchemas import (
@@ -16,13 +18,22 @@ def __init__(self):
1618
)
1719

1820
self._logger = logging.getLogger(__name__)
21+
self._stage = omni.usd.get_context().get_stage()
1922

2023
def clean(self):
2124
super().clean()
2225

26+
def _on_usd_changed(self, notice, stage):
27+
window = omni.kit.window.property.get_window()
28+
window.request_rebuild()
29+
2330
def _customize_props_layout(self, props):
2431
frame = CustomLayoutFrame(hide_extra=True)
2532

33+
prim_path = self._payload.get_paths()[0]
34+
webMapTileServiceRasterOverlay = CesiumWebMapTileServiceRasterOverlay.Get(self._stage, prim_path)
35+
specify_zoom_levels = webMapTileServiceRasterOverlay.GetSpecifyZoomLevelsAttr().Get()
36+
2637
with frame:
2738
with CustomLayoutGroup("WMTS Settings"):
2839
CustomLayoutProperty("cesium:url")
@@ -35,18 +46,26 @@ def _customize_props_layout(self, props):
3546
CustomLayoutProperty("cesium:tileMatrixSetLabelPrefix")
3647
CustomLayoutProperty("cesium:useWebMercatorProjection")
3748
with CustomLayoutGroup("Zoom Settings"):
38-
CustomLayoutProperty(
39-
"cesium:minimumZoomLevel",
40-
build_fn=build_slider(
41-
0, 30, type="int", constrain={"attr": "cesium:maximumLevel", "type": "maximum"}
42-
),
43-
)
44-
CustomLayoutProperty(
45-
"cesium:maximumZoomLevel",
46-
build_fn=build_slider(
47-
0, 30, type="int", constrain={"attr": "cesium:minimumLevel", "type": "minimum"}
48-
),
49-
)
49+
CustomLayoutProperty("cesium:specifyZoomLevels")
50+
if specify_zoom_levels:
51+
CustomLayoutProperty(
52+
"cesium:minimumZoomLevel",
53+
build_fn=build_slider(
54+
0, 30, type="int", constrain={"attr": "cesium:maximumZoomLevel", "type": "maximum"}
55+
),
56+
)
57+
CustomLayoutProperty(
58+
"cesium:maximumZoomLevel",
59+
build_fn=build_slider(
60+
0, 30, type="int", constrain={"attr": "cesium:minimumZoomLevel", "type": "minimum"}
61+
),
62+
)
5063
build_common_raster_overlay_properties()
5164

5265
return frame.apply(props)
66+
67+
def reset(self):
68+
if self._listener:
69+
self._listener.Revoke()
70+
self._listener = None
71+
super().reset()

src/core/src/OmniTileMapServiceRasterOverlay.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,11 @@ void OmniTileMapServiceRasterOverlay::reload() {
7979
};
8080

8181
CesiumRasterOverlays::TileMapServiceRasterOverlayOptions tmsOptions;
82-
const auto bSpecifyZoomLevels = getSpecifyZoomLevels();
83-
// std::string layers = getLayers();
84-
85-
if (bSpecifyZoomLevels) {
86-
const auto minimumLevel = getMinimumZoomLevel();
87-
const auto maximumLevel = getMaximumZoomLevel();
88-
// TODO: push to UI check
89-
if (maximumLevel > minimumLevel) {
90-
tmsOptions.minimumLevel = minimumLevel;
91-
tmsOptions.maximumLevel = maximumLevel;
92-
}
82+
const auto specifyZoomLevels = getSpecifyZoomLevels();
83+
84+
if (specifyZoomLevels) {
85+
tmsOptions.minimumLevel = getMinimumZoomLevel();
86+
tmsOptions.maximumLevel = getMaximumZoomLevel();
9387
}
9488

9589
_pTileMapServiceRasterOverlay = new CesiumRasterOverlays::TileMapServiceRasterOverlay(

0 commit comments

Comments
 (0)