mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
Libor's comment on the ocio settngs in publish tab and wip of the small popup widget for setting ocio config
This commit is contained in:
parent
fd58f34456
commit
8ea9755920
4 changed files with 67 additions and 18 deletions
|
|
@ -15,6 +15,33 @@ from pymxs import runtime as rt
|
|||
JSON_PREFIX = "JSON::"
|
||||
|
||||
|
||||
class Context:
|
||||
main_window = None
|
||||
context_label = None
|
||||
project_name = os.getenv("AVALON_PROJECT")
|
||||
# Workfile related code
|
||||
workfiles_launched = False
|
||||
workfiles_tool_timer = None
|
||||
|
||||
|
||||
|
||||
def get_main_window():
|
||||
"""Acquire Max's main window"""
|
||||
from qtpy import QtWidgets
|
||||
if Context.main_window is None:
|
||||
|
||||
top_widgets = QtWidgets.QApplication.topLevelWidgets()
|
||||
name = "QmaxApplicationWindow"
|
||||
for widget in top_widgets:
|
||||
if (
|
||||
widget.inherits("QMainWindow")
|
||||
and widget.metaObject().className() == name
|
||||
):
|
||||
Context.main_window = widget
|
||||
break
|
||||
return Context.main_window
|
||||
|
||||
|
||||
def imprint(node_name: str, data: dict) -> bool:
|
||||
node = rt.GetNodeByName(node_name)
|
||||
if not node:
|
||||
|
|
@ -346,3 +373,18 @@ def reset_colorspace():
|
|||
ocio_config_path = ocio_config["filepath"][-1]
|
||||
|
||||
colorspace_mgr.OCIOConfigPath = ocio_config_path
|
||||
|
||||
|
||||
def check_colorspace():
|
||||
parent = get_main_window()
|
||||
if int(get_max_version()) >= 2024:
|
||||
color_mgr = rt.ColorPipelineMgr
|
||||
if color_mgr.Mode != rt.Name("OCIO_Custom"):
|
||||
from openpype.widgets import popup
|
||||
dialog = popup.Popup(parent=parent)
|
||||
dialog.setWindowTitle("Warning: Wrong OCIO Mode")
|
||||
dialog.setMessage("This scene has wrong OCIO "
|
||||
"Mode setting.")
|
||||
dialog.widgets["button"].setText("Fix")
|
||||
dialog.on_clicked.connect(reset_colorspace)
|
||||
dialog.show()
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ class MaxHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
|
|||
rt.callbacks.addScript(rt.Name('systemPostNew'),
|
||||
context_setting)
|
||||
|
||||
rt.callbacks.addScript(rt.Name('filePostOpen'),
|
||||
lib.check_colorspace)
|
||||
|
||||
def has_unsaved_changes(self):
|
||||
# TODO: how to get it from 3dsmax?
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
from openpype.hosts.max.api import plugin
|
||||
from openpype.hosts.max.api.lib_rendersettings import RenderSettings
|
||||
from openpype.hosts.max.api.lib import get_max_version
|
||||
from openpype.lib import EnumDef
|
||||
from pymxs import runtime as rt
|
||||
|
||||
|
|
@ -18,11 +19,6 @@ class CreateRender(plugin.MaxCreator):
|
|||
sel_obj = list(rt.selection)
|
||||
file = rt.maxFileName
|
||||
filename, _ = os.path.splitext(file)
|
||||
instance_data["AssetName"] = filename
|
||||
instance_data["ocio_display_view_transform"] = (
|
||||
pre_create_data.get("ocio_display_view_transform")
|
||||
)
|
||||
|
||||
instance = super(CreateRender, self).create(
|
||||
subset_name,
|
||||
instance_data,
|
||||
|
|
@ -35,20 +31,27 @@ class CreateRender(plugin.MaxCreator):
|
|||
# set output paths for rendering(mandatory for deadline)
|
||||
RenderSettings().render_output(container_name)
|
||||
|
||||
def get_pre_create_attr_defs(self):
|
||||
attrs = super(CreateRender, self).get_pre_create_attr_defs()
|
||||
ocio_display_view_transform_list = []
|
||||
colorspace_mgr = rt.ColorPipelineMgr
|
||||
displays = colorspace_mgr.GetDisplayList()
|
||||
for display in sorted(displays):
|
||||
views = colorspace_mgr.GetViewList(display)
|
||||
for view in sorted(views):
|
||||
ocio_display_view_transform_list.append({
|
||||
"value": "||".join((display, view))
|
||||
def get_instance_attr_defs(self):
|
||||
ocio_display_view_transform_list = ["sRGB||ACES 1.0 SDR-video"]
|
||||
if int(get_max_version()) >= 2024:
|
||||
display_view_default = ""
|
||||
ocio_display_view_transform_list = []
|
||||
colorspace_mgr = rt.ColorPipelineMgr
|
||||
displays = colorspace_mgr.GetDisplayList()
|
||||
for display in sorted(displays):
|
||||
views = colorspace_mgr.GetViewList(display)
|
||||
for view in sorted(views):
|
||||
ocio_display_view_transform_list.append({
|
||||
"value": "||".join((display, view))
|
||||
})
|
||||
return attrs + [
|
||||
if display == "ACES" and view == "sRGB":
|
||||
display_view_default = "{0}||{1}".format(
|
||||
display, view
|
||||
)
|
||||
|
||||
return [
|
||||
EnumDef("ocio_display_view_transform",
|
||||
ocio_display_view_transform_list,
|
||||
default="",
|
||||
default=display_view_default,
|
||||
label="OCIO Displays and Views")
|
||||
]
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ class CollectRender(pyblish.api.InstancePlugin):
|
|||
instance.data["colorspaceView"] = "ACES 1.0 SDR-video"
|
||||
|
||||
if int(get_max_version()) >= 2024:
|
||||
display_view_transform = instance.data["ocio_display_view_transform"] # noqa
|
||||
creator_attribute = instance.data["creator_attributes"]
|
||||
display_view_transform = creator_attribute["ocio_display_view_transform"] # noqa
|
||||
display, view_transform = display_view_transform.split("||")
|
||||
colorspace_mgr = rt.ColorPipelineMgr
|
||||
instance.data["colorspaceConfig"] = colorspace_mgr.OCIOConfigPath
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue