-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open usdview without specifying a file #3321
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
Closed
MishDivyAmzn
wants to merge
1
commit into
PixarAnimationStudios:dev
from
MishDivyAmzn:dev_usdview_no_file_path
+54
−16
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -403,7 +403,7 @@ def __init__(self, parserData, resolverContextFn): | |
| self._ui = Ui_MainWindow() | ||
| self._ui.setupUi(self._mainWindow) | ||
|
|
||
| self._mainWindow.setWindowTitle(parserData.usdFile) | ||
| self._mainWindow.setWindowTitle(parserData.usdFile or "Empty Stage") | ||
| self._statusBar = QtWidgets.QStatusBar(self._mainWindow) | ||
| self._mainWindow.setStatusBar(self._statusBar) | ||
|
|
||
|
|
@@ -1203,7 +1203,16 @@ def _MuteMatchingLayers(): | |
| # layers populated after loading | ||
| _MuteMatchingLayers() | ||
|
|
||
| def _openStage(self, usdFilePath, sessionFilePath, | ||
| def _getEmptyStage(self): | ||
|
|
||
| with self._makeTimer('create empty stage'): | ||
| stage = Usd.Stage.CreateInMemory() | ||
|
|
||
| if not stage: | ||
| sys.stderr.write('Error: Unable to create empty stage\n') | ||
| return stage | ||
|
|
||
| def _getStageForFile(self, usdFilePath, sessionFilePath, | ||
| populationMaskPaths, muteLayersRe): | ||
|
|
||
| def _GetFormattedError(reasons=None): | ||
|
|
@@ -1281,6 +1290,25 @@ def _GetFormattedError(reasons=None): | |
|
|
||
| return stage | ||
|
|
||
| def _openStage(self, usdFilePath, sessionFilePath, | ||
| populationMaskPaths, muteLayersRe): | ||
|
|
||
| if self._mallocTags != 'none': | ||
| Tf.MallocTag.Initialize() | ||
|
|
||
| if not usdFilePath: | ||
| stage = self._getEmptyStage() | ||
|
|
||
| else: | ||
| stage = self._getStageForFile(usdFilePath, sessionFilePath, | ||
| populationMaskPaths, muteLayersRe) | ||
| stage.SetEditTarget(stage.GetSessionLayer()) | ||
|
|
||
| if self._mallocTags == 'stage': | ||
| DumpMallocTags(stage, "stage-loading") | ||
|
|
||
| return stage | ||
|
|
||
| def _closeStage(self): | ||
| # Close the USD stage. | ||
| if self._stageView: | ||
|
|
@@ -2795,6 +2823,12 @@ def _cleanAndClose(self): | |
|
|
||
| # Start timer to measure Qt shutdown time | ||
| self._startQtShutdownTimer() | ||
|
|
||
|
|
||
| def _getRecommendedFilenamePrefix(self): | ||
| return (self._parserData.usdFile.rsplit('.', 1)[0] | ||
| if self._parserData.usdFile | ||
| else 'new_file') | ||
|
|
||
| def _openFile(self): | ||
| extensions = Sdf.FileFormat.FindAllFileFormatExtensions() | ||
|
|
@@ -2836,14 +2870,13 @@ def _getSaveFileName(self, caption, recommendedFilename): | |
| return saveName | ||
|
|
||
| def _saveOverridesAs(self): | ||
| recommendedFilename = self._parserData.usdFile.rsplit('.', 1)[0] | ||
| recommendedFilename += '_overrides.usd' | ||
| recommendedFilename = self._getRecommendedFilenamePrefix() + '_overrides.usd' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Below at With an empty stage, if we want to save overrides to an existing file, |
||
|
|
||
| saveName = self._getSaveFileName( | ||
| 'Save Overrides As', recommendedFilename) | ||
| if len(saveName) == 0: | ||
| return | ||
| elif (os.path.isfile(saveName) and | ||
| elif (os.path.isfile(saveName) and self._parserData.usdFile and | ||
| os.path.samefile(saveName, self._parserData.usdFile)): | ||
| msg = QtWidgets.QMessageBox() | ||
| msg.setIcon(QtWidgets.QMessageBox.Critical) | ||
|
|
@@ -2857,13 +2890,13 @@ def _saveOverridesAs(self): | |
| return | ||
|
|
||
| with BusyContext(): | ||
| # In the future, we may allow usdview to be brought up with no file, | ||
| # in which case it would create an in-memory root layer, to which | ||
| # all edits will be targeted. In order to future proof | ||
| # this, first fetch the root layer, and if it is anonymous, just | ||
| # export it to the given filename. If it isn't anonmyous (i.e., it | ||
| # is a regular usd file on disk), export the session layer and add | ||
| # the stage root file as a sublayer. | ||
| # usdview can be brought up with no file, in which case it | ||
| # creates an in-memory root layer, to which all edits are | ||
| # targeted. This first fetches the root layer, and if it is | ||
| # anonymous, just exports it to the given filename. If it | ||
| # isn't anonymous (i.e., it is a regular usd file on disk), | ||
| # exports the session layer and add the stage root file | ||
| # as a sublayer. | ||
| rootLayer = self._dataModel.stage.GetRootLayer() | ||
| if not rootLayer.anonymous: | ||
| self._dataModel.stage.GetSessionLayer().Export( | ||
|
|
@@ -2889,8 +2922,7 @@ def _saveOverridesAs(self): | |
| saveName, 'Created by UsdView') | ||
|
|
||
| def _saveFlattenedAs(self): | ||
| recommendedFilename = self._parserData.usdFile.rsplit('.', 1)[0] | ||
| recommendedFilename += '_flattened.usd' | ||
| recommendedFilename = self._getRecommendedFilenamePrefix() + '_flattened.usd' | ||
|
|
||
| saveName = self._getSaveFileName( | ||
| 'Save Flattened As', recommendedFilename) | ||
|
|
@@ -2905,7 +2937,7 @@ def _copyViewerImage(self): | |
|
|
||
| def _saveViewerImage(self): | ||
| recommendedFilename = "{}_{}{:04d}.png".format( | ||
| self._parserData.usdFile.rsplit('.', 1)[0], | ||
| self._getRecommendedFilenamePrefix(), | ||
| "" if not self.getActiveCamera() | ||
| else self.getActiveCamera().GetName() + "_", | ||
| int(self._dataModel.currentFrame.GetValue())) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks like this PR is missing a lot of logic from the
_openStagemethod, perhaps a bad merge? -OpenUSD/pxr/usdImaging/usdviewq/appController.py
Line 1206 in 43b8c71
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.
Thanks for the comment!
I renamed the old
_openStagefunction to_getStageForFileand now the_openStagecalls_getStageForFileor_getEmptyStagebased on whetherusdFilewas passed as an argument. This way the callers of_openStageare unaffected.Please let me know if there are any other concerns.
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.
ahh sorry, missed that. thanks!