// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== proc attachGroup(string $form, string $groups[]) { int $i; int $previousGroup; int $numGroups = `size($groups)`; if ($numGroups > 0) { formLayout -edit -attachForm $groups[0] "top" 0 -attachNone $groups[0] "bottom" -attachForm $groups[0] "left" 1 -attachNone $groups[0] "right" $form; $previousGroup = 0; } for ($i=1; $i<$numGroups; $i++) { if ($groups[$i] != "") { formLayout -edit -attachForm $groups[$i] "top" 0 -attachNone $groups[$i] "bottom" -attachControl $groups[$i] "left" 1 $groups[$previousGroup] -attachNone $groups[$i] "right" $form; $previousGroup = $i; } } } // ADSK_CLR_MGT_BEGIN global proc string[] createColorManagementSection(string $modelEditor, string $parent, string $prefix) { string $groups[3]; string $subgroup[2]; string $renderingEngine = getPreferredRenderingEngine(); int $defaultVisibilityStateOfCMControls = ($renderingEngine != ""); float $exposure = `modelEditor -q -exposure $modelEditor`; float $gamma = `modelEditor -q -gamma $modelEditor`; int $enabled = `modelEditor -q -cmEnabled $modelEditor`; $groups[0] = `formLayout ($prefix + "modelPanelExposureGroup")`; // use "Exposure.png" instead of "rvExposureControlIcon.png" for viewport icon display as it's a native 16x16 image. $subgroup[0] = `iconTextButton -version "2016" -visible $defaultVisibilityStateOfCMControls -i1 "Exposure.png" -marginWidth 0 -marginHeight 0 ($prefix + "modelEditorExposureIcon")`; $subgroup[1] = `floatField -visible $defaultVisibilityStateOfCMControls -width 40 -height 16 -value $exposure -precision 2 -step 0.1 ($prefix + "modelEditorExposureField")`; string $exposureUpdateCommand = "callPython(\"maya.colorManagementUtilities\", \"updateExposure\", {\"" + $modelEditor + "\" , \"" + $subgroup[1] + "\", \"cmds.modelEditor\"})"; string $exposureToggleCommand = "callPython(\"maya.colorManagementUtilities\", \"syncExposureField\", {\"" + $modelEditor + "\" , \"" + $subgroup[1] + "\", \"cmds.modelEditor\"})"; iconTextButton -e -command $exposureToggleCommand $subgroup[0]; floatField -e -changeCommand $exposureUpdateCommand $subgroup[1]; floatField -e -dragCommand $exposureUpdateCommand $subgroup[1]; attachGroup($groups[0], $subgroup); clear $subgroup; setParent ..; $groups[1] = `formLayout ($prefix + "modelPanelGammaGroup")`; // use "Gamma.png" instead of "rvGammaControlIcon.png" for viewport icon display as it's a native 16x16 image. $subgroup[0] = `iconTextButton -version "2016" -visible $defaultVisibilityStateOfCMControls -i1 "Gamma.png" -marginWidth 0 -marginHeight 0 ($prefix + "modelEditorGammaIcon")`; $subgroup[1] = `floatField -visible $defaultVisibilityStateOfCMControls -width 40 -height 16 -value $gamma -min 0.0 -precision 2 -step 0.1 ($prefix + "modelEditorGammaField")`; string $gammaUpdateCommand = "callPython(\"maya.colorManagementUtilities\", \"updateGamma\", {\"" + $modelEditor + "\" , \"" + $subgroup[1] + "\", \"cmds.modelEditor\"})"; string $gammaToggleCommand = "callPython(\"maya.colorManagementUtilities\", \"syncGammaField\", {\"" + $modelEditor + "\" , \"" + $subgroup[1] + "\", \"cmds.modelEditor\"})"; iconTextButton -e -command $gammaToggleCommand $subgroup[0]; floatField -e -changeCommand $gammaUpdateCommand $subgroup[1]; floatField -e -dragCommand $gammaUpdateCommand $subgroup[1]; attachGroup($groups[1], $subgroup); clear $subgroup; setParent ..; $groups[2] = `formLayout ($prefix + "modelPanelViewTransformGroup")`; $subgroup[0] = `symbolCheckBox -visible $defaultVisibilityStateOfCMControls -height 18 -width 18 -onImage "rvViewingPipelineOn.png" -offImage "rvViewingPipelineOff.png" -value $enabled ($prefix + "modelEditorEnableButton")`; $subgroup[1] = `optionMenu -visible $defaultVisibilityStateOfCMControls -height 18 ($prefix + "modelEditorTransformSelOptionMenu")`; string $viewTransformNames[] = `colorManagementPrefs -q -viewTransformNames`; int $i, $numNames = size($viewTransformNames); for($i = 0 ; $i < $numNames ; $i++) { menuItem -label $viewTransformNames[$i]; } string $vtName = `modelEditor -q -viewTransformName $modelEditor`; optionMenu -e -v $vtName ($prefix + "modelEditorTransformSelOptionMenu"); string $viewTransformName = `modelEditor -q -viewTransformName $modelEditor`; string $enableCMCommand = "callPython(\"maya.colorManagementUtilities\", \"toggleCM\", {\"" + $modelEditor + "\" , \"" + $subgroup[0] + "\", \"cmds.modelEditor\"})"; string $selectViewTransformCommand = "callPython(\"maya.colorManagementUtilities\", \"setViewTransform\",{\"" + $modelEditor + "\" , \"" + $subgroup[1] + "\", \"cmds.modelEditor\"})"; symbolCheckBox -e -changeCommand $enableCMCommand $subgroup[0]; optionMenu -e -changeCommand $selectViewTransformCommand $subgroup[1]; int $globalCmEnabled = `colorManagementPrefs -q -cmEnabled`; symbolCheckBox -e -enable $globalCmEnabled $subgroup[0]; optionMenu -e -enable $globalCmEnabled $subgroup[1]; attachGroup($groups[2], $subgroup); clear $subgroup; setParent ..; return $groups; } // ADSK_CLR_MGT_END