Package nukescripts :: Module ViewerProcess
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.ViewerProcess

 1  import nuke 
 2  import ocionuke 
 3  import os 
 4   
 5   
6 -def _setOCIOConfig(configPath):
7 ''' 8 Set the OCIO Config to use the specified config path, unless 9 the OCIO environment variable is defined, in which case that will 10 override configPath. Otherwise if configPath is None then the nuke 11 default config is used. If configPath doesn't exist an IOError is raised. 12 ''' 13 rootNode = nuke.root() 14 ocioConfigKnob = rootNode.knob("OCIO_config") 15 16 # When the OCIO env var is set the OCIO knobs are disabled 17 canChangeConfig = ocioConfigKnob.enabled() 18 if canChangeConfig: 19 # The root node handles checking whether the OCIO envvar needs to be used 20 # or not. This check is performed whenever the OCIO knobs are changed, so 21 # isn't needed here. 22 useDefaultNukeConfig = configPath == "" 23 if useDefaultNukeConfig: 24 ocioConfigKnob.setValue("nuke-default") 25 else: 26 if os.path.exists(configPath): 27 ocioConfigKnob.setValue("custom") 28 customOCIOConfigPathKnob = rootNode.knob("customOCIOConfigPath") 29 customOCIOConfigPathKnob.setText(configPath) 30 else: 31 raise IOError("Config '%s' doesn't exist" % configPath)
32 33 34 # Maintaining this function for backwards compatability
35 -def getDefaultOCIOConfig(ocioConfigName = ""):
36 _setOCIOConfig(ocioConfigName)
37 38
39 -def register_default_viewer_processes():
40 41 # The ViewerProcess_None gizmo is a pass-through -- it has no effect on the image. 42 nuke.ViewerProcess.register("None", nuke.createNode, ("ViewerProcess_None", )) 43 # The ViewerProcess_1DLUT gizmo just contains a ViewerLUT node, which 44 # can apply a 1D LUT defined in the project LUTs. ViewerLUT features both 45 # software (CPU) and GPU implementations. 46 47 nuke.ViewerProcess.register("sRGB", nuke.createNode, ( "ViewerProcess_1DLUT", "current sRGB" )) 48 nuke.ViewerProcess.register("rec709", nuke.createNode, ( "ViewerProcess_1DLUT", "current rec709" )) 49 # NOTE: If you change this mapping you'll need to update FlipbookDialog._getBurninWriteColorspace. 50 nuke.ViewerProcess.register("rec1886", nuke.createNode, ( "ViewerProcess_1DLUT", "current Gamma2.4" )) 51 if os.environ.get("FN_EDR_DISPLAY", "0") != "0": 52 nuke.ViewerProcess.register("Extended sRGB", nuke.createNode, ( "ViewerLUTExtendedSRGB", ))
53 54
55 -def unregister_viewers(ocioConfigPath):
56 ocioConfig = ocionuke.config.loadConfig(ocioConfigPath) 57 58 # unregister all OCIO LUTS 59 # For every display, loop over every view 60 DISPLAY_UI_FORMAT = "%(view)s (%(display)s)" 61 for display in ocioConfig.getDisplays(): 62 for view in ocioConfig.getViews(display): 63 # Unregister the node 64 name = DISPLAY_UI_FORMAT % {'view': view, "display": display} 65 nuke.ViewerProcess.unregister(name)
66 67
68 -def _register_viewer_processes(defaultLUTS, ocioConfigName, also_remove, isReload):
69 if defaultLUTS is True: 70 # register the default viewer processes 71 register_default_viewer_processes() 72 else: 73 # register OCIO viewer processes 74 ocionuke.viewer.register_viewers(ocioConfigName, also_remove, isReload)
75 76
77 -def register_viewers(defaultLUTS = True, ocioConfigName = ""):
78 79 ocioConfigName = os.path.normpath(ocioConfigName).replace("\\", "/") 80 81 # make sure we register the config before we begin 82 _setOCIOConfig(ocioConfigName)
83
84 -def storeViewerProcessSelectionBeforeReload():
85 ocionuke.viewer.storeSelectionBeforeReload()
86