1#!/pxrpythonsubst 2# 3# Copyright 2020 Pixar 4# 5# Licensed under the Apache License, Version 2.0 (the "Apache License") 6# with the following modification; you may not use this file except in 7# compliance with the Apache License and the following modification to it: 8# Section 6. Trademarks. is deleted and replaced with: 9# 10# 6. Trademarks. This License does not grant permission to use the trade 11# names, trademarks, service marks, or product names of the Licensor 12# and its affiliates, except as required to comply with Section 4(c) of 13# the License and to reproduce the content of the NOTICE file. 14# 15# You may obtain a copy of the Apache License at 16# 17# http://www.apache.org/licenses/LICENSE-2.0 18# 19# Unless required by applicable law or agreed to in writing, software 20# distributed under the Apache License with the above modification is 21# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 22# KIND, either express or implied. See the Apache License for the specific 23# language governing permissions and limitations under the Apache License. 24# 25 26 27from __future__ import print_function 28import sys 29from pxr.Usdviewq.qt import QtWidgets 30 31 32# Remove any unwanted visuals from the view. 33def _modifySettings(appController): 34 appController._dataModel.viewSettings.showBBoxes = False 35 appController._dataModel.viewSettings.showHUD = False 36 37# Turn off the Camera and Dome light. 38def _turnLightsOff(appController): 39 appController._ui.actionAmbient_Only.setChecked(False) 40 appController._ambientOnlyClicked(False) 41 42 appController._ui.actionDomeLight.setChecked(False) 43 appController._onDomeLightClicked(False) 44 45 appController._stageView.updateGL() 46 47# Select one or more prim paths, then set visible state of those prims. 48def _selectAndSetVisible(appController, visible, paths): 49 selection = appController._dataModel.selection 50 with selection.batchPrimChanges: 51 selection.clearPrims() 52 for path in paths: 53 selection.addPrimPath(path) 54 55 if visible: 56 appController.visSelectedPrims() 57 # We must processEvents after every call to activateSelectedPrims() so the 58 # activated PrimViewItems can repopulate. (See _primViewUpdateTimer in 59 # appController.py) 60 QtWidgets.QApplication.processEvents() 61 else: 62 appController.invisSelectedPrims() 63 64# Test making a single light invisible then make it visible. 65def _testSingleVisible(appController): 66 _selectAndSetVisible(appController, False, ["/lights/light1"]) 67 appController._takeShot("singleInvisible1.png") 68 _selectAndSetVisible(appController, True, ["/lights/light1"]) 69 70 _selectAndSetVisible(appController, False, ["/lights/light2"]) 71 appController._takeShot("singleInvisible2.png") 72 _selectAndSetVisible(appController, True, ["/lights/light2"]) 73 74# Test all lights visible/invisible. 75def _testAllVisible(appController): 76 _selectAndSetVisible(appController, False, ["/lights/light1"]) 77 _selectAndSetVisible(appController, False, ["/lights/light2"]) 78 79 appController._takeShot("allInvisible.png") 80 81 _selectAndSetVisible(appController, True, ["/lights/light1"]) 82 _selectAndSetVisible(appController, True, ["/lights/light2"]) 83 84 appController._takeShot("allVisible.png") 85 86 87# Test that the complexity setting works properly in usdview. 88def testUsdviewInputFunction(appController): 89 _modifySettings(appController) 90 _turnLightsOff(appController) 91 _testSingleVisible(appController) 92 _testAllVisible(appController) 93