1
1
import logging
2
+ import omni .usd
3
+ import omni .ui
4
+ import omni .kit .window .property
2
5
from omni .kit .property .usd .custom_layout_helper import CustomLayoutFrame , CustomLayoutGroup , CustomLayoutProperty
3
6
from omni .kit .property .usd .usd_property_widget import SchemaPropertiesWidget
4
7
from cesium .usd .plugins .CesiumUsdSchemas import (
5
8
TileMapServiceRasterOverlay as CesiumTileMapServiceRasterOverlay ,
6
9
)
7
10
from .cesium_properties_widget_builder import build_slider , build_common_raster_overlay_properties
11
+ from pxr import Usd , Tf
8
12
9
13
10
14
class CesiumTileMapServiceRasterOverlayAttributesWidget (SchemaPropertiesWidget ):
@@ -17,31 +21,54 @@ def __init__(self):
17
21
18
22
self ._logger = logging .getLogger (__name__ )
19
23
24
+ self ._listener = None
25
+ self ._props = None
26
+ self ._stage = omni .usd .get_context ().get_stage ()
27
+
20
28
def clean (self ):
21
29
super ().clean ()
22
30
31
+ def _on_usd_changed (self , notice , stage ):
32
+ window = omni .kit .window .property .get_window ()
33
+ window .request_rebuild ()
34
+
23
35
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
+
24
39
frame = CustomLayoutFrame (hide_extra = True )
25
40
41
+ prim_path = self ._payload .get_paths ()[0 ]
42
+ tileMapServiceRasterOverlay = CesiumTileMapServiceRasterOverlay .Get (self ._stage , prim_path )
43
+ specify_zoom_levels = tileMapServiceRasterOverlay .GetSpecifyZoomLevelsAttr ().Get ()
44
+
26
45
with frame :
27
46
with CustomLayoutGroup ("URL" ):
28
47
CustomLayoutProperty ("cesium:url" )
29
48
with CustomLayoutGroup ("Zoom Settings" ):
49
+
30
50
CustomLayoutProperty (
31
51
"cesium:specifyZoomLevels" ,
32
52
)
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
+ )
45
66
build_common_raster_overlay_properties ()
46
67
47
68
return frame .apply (props )
69
+
70
+ def reset (self ):
71
+ if self ._listener :
72
+ self ._listener .Revoke ()
73
+ self ._listener = None
74
+ super ().reset ()
0 commit comments