This repository was archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
OpenRV integration #4839
Closed
Closed
OpenRV integration #4839
Changes from all commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
3e743ac
openrv integration
4ec6643
Code cosmetics
BigRoy 25669f8
Code cosmetics + cleanup
BigRoy 7bae5de
Re-use method from host
BigRoy ee5944d
Remove unused function which likely came from Fusion or Clarisse inte…
BigRoy a37ddad
Cleanup comments
BigRoy 751005d
Cosmetics
BigRoy 8250f5e
Fix missing import, not sure if there was a reason it had no top import
BigRoy 18be311
Fix typo
BigRoy 26d6f60
Shush hound
BigRoy 8d563b0
Remove unused `show_env`
BigRoy 289fea4
Cleanup code
BigRoy b376efb
Remove debug files
BigRoy d10b2de
More cleanup
BigRoy fed5549
Return if there's no current workfile
BigRoy aa9766c
Cosmetics
BigRoy 3c636d6
Cosmetics + Shush hound
BigRoy 8d0d2bf
Remove unused function
BigRoy 6092fa5
Merge remote-tracking branch 'upstream/develop' into openrv-integration
BigRoy de715e7
Cosmetics
BigRoy 97b9c99
added missing schema
7a69fa5
added missing schema
6f50488
Cosmetics
BigRoy 3e79ff1
Add `openrv` to hosts enum since it registers a host
BigRoy 2310252
Use FusionPreLaunchOCIO hook as global hook for re-use with `openrv`
BigRoy 4523416
Remove pre config hook in favor of global OCIO hook
BigRoy f4d69f8
Cleanup code
BigRoy dbec91d
Don't add to sys.path, don't clear PYTHONPATH
BigRoy 028e85f
More specific imports
BigRoy d716d04
Clean up imports
BigRoy df7ee57
Merge branch 'develop' into openrv-integration
BigRoy 86cc3b6
proper menu file
12c21e1
Cleanup file again.
BigRoy 265d12c
Hound
BigRoy 552c2f6
Match menu labels of other integrations + clarify arguments to `init`
BigRoy 8303faa
Shush hound
BigRoy a336e1b
Remove unused variable
BigRoy c8df2ee
Hound
BigRoy bf2188f
Update menu name
BigRoy 850cb21
Fix workfile saving with correct extension
BigRoy aa303b9
Hack: For now "auto-deploy" and load packages
BigRoy f3e357b
Update python files on deployment
BigRoy 492ed6a
Avoid errors when no currently loaded content
BigRoy 97a83f1
No need for default environment overrides
BigRoy cd34df7
Shush hound
BigRoy 9bf9667
Fix line length
BigRoy f1ba2be
Shush hound
BigRoy 0ec4afa
Shush hound
BigRoy a85ffd3
Shush hound
BigRoy 48bf981
Shush hound
BigRoy 763d4f7
Cleanup
BigRoy 3377f32
Fix line length
BigRoy 6503152
Hound
BigRoy 0e1e23a
Cleanup
BigRoy fbea68a
Comment out unused lines which end up doing nothing
BigRoy 759152b
Returned value was unused
BigRoy 69a9436
Comment import + add todo
BigRoy ab3568d
Hound
BigRoy c2d156f
Cleanup cycle annotate frames logic
BigRoy 1134aa2
Comment import + add todo
BigRoy 189bf5e
Comment to explain we require the sorting
BigRoy 54ea549
Don't pass emtpy list as parent
BigRoy fa8a964
Create dock widget only on first 'review' click and toggle view other…
BigRoy d734b90
Parent the OpenPype tools to RV window
BigRoy b079095
Cosmetics
BigRoy 09fdae3
Cleanup imports
BigRoy 4092069
Merge branch 'develop' into openrv-integration
BigRoy eb74f7e
Do nothing if there are no annotations
BigRoy dbcc9cc
Remove debugging method
BigRoy ee86ab6
Always return the session window live because there can be multiple s…
BigRoy dff3997
Add todo
BigRoy abbcca4
Only install once, not per session window
BigRoy ab8b0a1
Remove unused import
BigRoy 28d352d
Works fine for multiple session windows since it initializes a class …
BigRoy 12b17b2
Do not force show the RV console
BigRoy 5c69925
Support loading image sequences
BigRoy b312019
Allow any mov or mp4 extension
BigRoy 95aedf9
Allow loading more image extensions
BigRoy 9887404
Add temporary hack to avoid clash with `PyOpenColorIO` in OpenPype
BigRoy 3766241
Add todo
BigRoy de683b3
Do not force show review tool on launch
BigRoy cead75f
Simplify lib clash workaround
BigRoy bdde431
Add init sorted order to make "Review" the last entry in the menu.
BigRoy da2d988
Add OpenPype script editor (python interpreter widget) package to hel…
BigRoy bb8932c
Tweak organization
BigRoy 0fd51b2
Remove forcing of asset fps/frames + support removal of containers
BigRoy 28e27fd
Fix RV Project Settings + remove unused redundant settings
BigRoy 267f5d5
Use OCIO schemas like other hosts
BigRoy e3cf566
Allow import even when OpenPype hasn't initialized/installed
BigRoy f38e24e
Fix typo
BigRoy 859217f
Add checkbox active state to "review" menu entry
BigRoy 86ee0de
Add separators to menu
BigRoy 41c72e8
Ignore namespace attribute if it does not exist
BigRoy 371ec04
Cleanup, move import to top + improve docstring
BigRoy fe1e776
Implement draft functionality to set OCIO colorspace on file load and…
BigRoy d1ceeff
Add active state to the menu
BigRoy b097044
Remove redundant check, it's already checked in other if statement
BigRoy 1b26835
Hound
BigRoy 262147d
Add support for open last workfile
BigRoy 85483c5
Refactor to using new publisher
BigRoy 367884e
Expose library loader
BigRoy db24d5b
Add todo
BigRoy 8dec68b
Merge remote-tracking branch 'upstream/develop' into openrv-integration
BigRoy d7c4630
Define subset name correctly using templates
BigRoy dd664c8
Nicer label + docstring
BigRoy 81d5d16
Add comment about a workaround
BigRoy fce4e7d
Cleanup `reset_frame_range` logic. Remove old `edit_in` and `edit_out`
BigRoy 1da142c
Remove redundant adding of vendor/python
BigRoy 26c8f29
Merge branch 'develop' into openrv-integration
BigRoy 74779ce
Merge branch 'develop' into openrv-integration
BigRoy a2b37e9
Preserve predefined RV_SUPPORT_PATH paths
BigRoy aa74663
Install OpenPype packages to temp folder on launch + preserve predefi…
BigRoy 4e41b48
Remove unused import
BigRoy 0dda77b
Force `rvpkg` just to be sure it's not trying to be used interactively
BigRoy 3493817
Merge branch 'develop' into openrv-integration
antirotor 305efbb
:recycle: update color management settings
antirotor 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 |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ class OCIOEnvHook(PreLaunchHook): | |
| "nuke", | ||
| "hiero", | ||
| "resolve", | ||
| "openrv", | ||
| } | ||
| launch_types = set() | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from .addon import ( | ||
| OpenRVAddon, | ||
| OPENRV_ROOT_DIR | ||
| ) | ||
|
|
||
|
|
||
| __all__ = ( | ||
| "OpenRVAddon", | ||
| "OPENRV_ROOT_DIR" | ||
| ) |
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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import os | ||
| from openpype.modules import OpenPypeModule | ||
| from openpype.modules.interfaces import IHostAddon | ||
|
|
||
| OPENRV_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
|
|
||
| class OpenRVAddon(OpenPypeModule, IHostAddon): | ||
| name = "openrv" | ||
| host_name = "openrv" | ||
|
|
||
| def initialize(self, module_settings): | ||
| self.enabled = True | ||
|
|
||
| def add_implementation_envs(self, env, app): | ||
| """Modify environments to contain all required for implementation.""" | ||
| # Set default environments if are not set via settings | ||
| defaults = { | ||
| "OPENPYPE_LOG_NO_COLORS": "True" | ||
| } | ||
| for key, value in defaults.items(): | ||
| if not env.get(key): | ||
| env[key] = value | ||
|
|
||
| def get_launch_hook_paths(self, app): | ||
| if app.host_name != self.host_name: | ||
| return [] | ||
| return [ | ||
| os.path.join(OPENRV_ROOT_DIR, "hooks") | ||
| ] | ||
|
|
||
| def get_workfile_extensions(self): | ||
| return [".rv"] |
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """OpenRV OpenPype host API.""" | ||
|
|
||
| from .pipeline import ( | ||
| OpenRVHost | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "OpenRVHost" | ||
| ] |
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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import logging | ||
|
|
||
| import rv | ||
| from openpype.pipeline.context_tools import get_current_project_asset | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def reset_frame_range(): | ||
| """ Set timeline frame range. | ||
| """ | ||
| asset_doc = get_current_project_asset() | ||
| asset_name = asset_doc["name"] | ||
| asset_data = asset_doc["data"] | ||
|
|
||
| frame_start = asset_data.get("frameStart") | ||
| frame_end = asset_data.get("frameEnd") | ||
|
|
||
| if frame_start is None or frame_end is None: | ||
| log.warning("No edit information found for {}".format(asset_name)) | ||
| return | ||
|
|
||
| rv.commands.setFrameStart(frame_start) | ||
| rv.commands.setFrameEnd(frame_end) | ||
| rv.commands.setFrame(frame_start) | ||
|
|
||
|
|
||
| def set_session_fps(): | ||
| """ Set session fps. | ||
| """ | ||
| asset_doc = get_current_project_asset() | ||
| asset_data = asset_doc["data"] | ||
| fps = float(asset_data.get("fps", 25)) | ||
| rv.commands.setFPS(fps) |
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import contextlib | ||
|
|
||
| import rv | ||
|
|
||
|
|
||
| @contextlib.contextmanager | ||
| def maintained_view(): | ||
| """Reset to original view node after context""" | ||
| original = rv.commands.viewNode() | ||
| try: | ||
| yield | ||
| finally: | ||
| rv.commands.setViewNode(original) | ||
|
|
||
|
|
||
| @contextlib.contextmanager | ||
| def active_view(node): | ||
| """Set active view during context""" | ||
| with maintained_view(): | ||
| rv.commands.setViewNode(node) | ||
| yield | ||
|
|
||
|
|
||
| def group_member_of_type(group_node, member_type): | ||
| """Return first member of group that is of the given node type. | ||
|
|
||
| This is similar to `rv.extra_commands.nodesInGroupOfType` but only | ||
| returns the first entry directly if it has any match. | ||
|
|
||
| Args: | ||
| group_node (str): The group node to search in. | ||
| member_type (str): The node type to search for. | ||
|
|
||
| Returns: | ||
| str or None: The first member found of given type or None | ||
| """ | ||
| for node in rv.commands.nodesInGroup(group_node): | ||
| if rv.commands.nodeType(node) == member_type: | ||
| return node |
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 |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| """Helper functions to apply OCIO colorspace settings on groups. | ||
|
|
||
| This tries to set the relevant OCIO settings on the group's look and render | ||
| pipeline similar to what the OpenColorIO Basic Color Management package does in | ||
| OpenRV through its `ocio_source_setup` python file. | ||
|
|
||
| This assumes that the OpenColorIO Basic Color Management package of RV is both | ||
| installed and loaded. | ||
|
|
||
| """ | ||
| import rv.commands | ||
| import rv.qtutils | ||
|
|
||
| from .lib import ( | ||
| group_member_of_type, | ||
| active_view | ||
| ) | ||
|
|
||
|
|
||
| class OCIONotActiveForGroup(RuntimeError): | ||
| """Error raised when OCIO is not enabled on the group node.""" | ||
|
|
||
|
|
||
| def get_group_ocio_look_node(group): | ||
| """Return OCIOLook node from source group""" | ||
| pipeline = group_member_of_type(group, "RVLookPipelineGroup") | ||
| if pipeline: | ||
| return group_member_of_type(pipeline, "OCIOLook") | ||
|
|
||
|
|
||
| def get_group_ocio_file_node(group): | ||
| """Return OCIOFile node from source group""" | ||
| pipeline = group_member_of_type(group, "RVLinearizePipelineGroup") | ||
| if pipeline: | ||
| return group_member_of_type(pipeline, "OCIOFile") | ||
|
|
||
|
|
||
| def set_group_ocio_colorspace(group, colorspace): | ||
| """Set the group's OCIOFile node ocio.inColorSpace property. | ||
|
|
||
| This only works if OCIO is already 'active' for the group. T | ||
|
|
||
| """ | ||
| import ocio_source_setup # noqa, RV OCIO package | ||
| node = get_group_ocio_file_node(group) | ||
|
|
||
| if not node: | ||
| raise OCIONotActiveForGroup( | ||
| "Unable to find OCIOFile node for {}".format(group) | ||
| ) | ||
|
|
||
| rv.commands.setStringProperty( | ||
| f"{node}.ocio.inColorSpace", [colorspace], True | ||
| ) | ||
|
|
||
|
|
||
| def set_current_ocio_active_state(state): | ||
| """Set the OCIO state for the currently active source. | ||
|
|
||
| This is a hacky workaround to enable/disable the OCIO active state for | ||
| a source since it appears to be that there's no way to explicitly trigger | ||
| this callback from the `ocio_source_setup.OCIOSourceSetupMode` instance | ||
| which does these changes. | ||
|
|
||
| """ | ||
| # TODO: Make this logic less hacky | ||
| # See: https://community.shotgridsoftware.com/t/how-to-enable-disable-ocio-and-set-ocio-colorspace-for-group-using-python/17178 # noqa | ||
|
|
||
| group = rv.commands.viewNode() | ||
| ocio_node = get_group_ocio_file_node(group) | ||
| if state == bool(ocio_node): | ||
| # Already in correct state | ||
| return | ||
|
|
||
| window = rv.qtutils.sessionWindow() | ||
| menu_bar = window.menuBar() | ||
| for action in menu_bar.actions(): | ||
| if action.text() != "OCIO" or action.toolTip() != "OCIO": | ||
| continue | ||
|
|
||
| ocio_menu = action.menu() | ||
|
|
||
| for ocio_action in ocio_menu.actions(): | ||
| if ocio_action.toolTip() == "File Color Space": | ||
| # The first entry is for "current source" instead | ||
| # of all sources so we need to break the for loop | ||
| # The first action of the file color space menu | ||
| # is the "Active" action. So lets take that one | ||
| active_action = ocio_action.menu().actions()[0] | ||
|
|
||
| active_action.trigger() | ||
| return | ||
|
|
||
| raise RuntimeError( | ||
| "Unable to set active state for current source. Make " | ||
| "sure the OCIO package is installed and loaded." | ||
| ) | ||
|
|
||
|
|
||
| def set_group_ocio_active_state(group, state): | ||
| """Set the OCIO state for the 'currently active source'. | ||
|
|
||
| This is a hacky workaround to enable/disable the OCIO active state for | ||
| a source since it appears to be that there's no way to explicitly trigger | ||
| this callback from the `ocio_source_setup.OCIOSourceSetupMode` instance | ||
| which does these changes. | ||
|
|
||
| """ | ||
| ocio_node = get_group_ocio_file_node(group) | ||
| if state == bool(ocio_node): | ||
| # Already in correct state | ||
| return | ||
|
|
||
| with active_view(group): | ||
| set_current_ocio_active_state(state) | ||
Oops, something went wrong.
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.
It would be great if we could also autoload this package - but I know too little of RV to say what the best approach is to do so.
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.
I've asked more information about this on the Shotgrid Software community about Autoload OpenColorIO Basic Color Management RV package.