Skip to content

Commit

Permalink
Move "show usd text" to under "show materialx text" assuming PrismPip…
Browse files Browse the repository at this point in the history
…eline#55 goes through.
  • Loading branch information
kwokcb committed Feb 6, 2024
1 parent f4df67f commit 485e237
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plugins/pluginQuiltX.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, parent=None):

# Create a web view.
self.web_view = QWebEngineView()
self.web_view.setUrl(QtCore.QUrl('https://kwokcb.github.io/MaterialX_Learn/documents/sampleViewer.html'))
self.web_view.setUrl(QtCore.QUrl('https://materialx.nanmucreative.com/documents/sampleViewer.html'))
# e.g. Set to local host if you want to run a local page
#self.web_view.setUrl(QtCore.QUrl('http://localhost:8000/gltfViewer_simple.html'))

Expand Down Expand Up @@ -132,12 +132,13 @@ def __init__(self, editor, haveGLTF, haveJson):
if not haveGLTF and not haveJson:
logger.error('Neither materialxjson nor materialxgltf modules are installed. glTF/JSON support will not be available.')

self.editor.file_menu.addSeparator()
gltfMenu = self.editor.file_menu.addMenu("USD")
# Show USD Stage .
show_usd_text = QAction("Show USD Stage...", self.editor)
show_usd_text.triggered.connect(self.show_usd_triggered)
gltfMenu.addAction(show_usd_text)
# Show USD Stage -- add here if not added to core
showUSDExists = True
if not showUSDExists:
self.editor.file_menu.addSeparator()
show_usd_text = QAction("Show USD Stage...", self.editor)
show_usd_text.triggered.connect(self.show_usd_triggered)
self.editor.file_menu.addAction(show_usd_text)

if haveJson:
# JSON menu items
Expand Down
25 changes: 25 additions & 0 deletions src/QuiltiX/quiltix.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def init_menu_bar(self):
show_mx_text.triggered.connect(self.show_mx_text_triggered)
self.file_menu.addAction(show_mx_text)

show_usd_text = QAction("Show USD as text...", self)
show_usd_text.triggered.connect(self.show_usd_text_triggered)
self.file_menu.addAction(show_usd_text)

self.file_menu.addSeparator()

show_mx_view = QAction("Open in MaterialX View...", self)
Expand Down Expand Up @@ -537,6 +541,27 @@ def show_mx_text_triggered(self):
te_text.resize(1000, 800)
te_text.show()

def print_usd_prim(self, prim):
assert isinstance(prim, Usd.Prim)
prim_stage = prim.GetStage()
prim_stage_id = prim_stage.GetRootLayer().identifier
stage = Usd.Stage.CreateInMemory()
target = stage.DefinePrim("/{}".format(prim.GetName()))
target.GetReferences().AddReference(prim_stage_id, prim.GetPath())
return stage.ExportToString()

def show_usd_text_triggered(self):
usdstage = self.stage_ctrl.stage
materials = usdstage.GetPrimAtPath("/MaterialX")
text = self.print_usd_prim(materials)
te_text = QTextEdit()
te_text.setText(text)
te_text.setReadOnly(True)
te_text.setParent(self, QtCore.Qt.Window)
te_text.setWindowTitle("USD text preview")
te_text.resize(1000, 800)
te_text.show()

def show_mx_view_triggered(self):
exe = os.getenv("MATERIALX_VIEW", "")
if not os.path.exists(exe):
Expand Down

0 comments on commit 485e237

Please sign in to comment.