// =========================================================================== // 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. // =========================================================================== // // Procedure Name: // AEresolutionTemplate // // Description: // Creates the attribute editor controls for the resolution Node // // Input Value: // nodeName // // Output Value: // None // global proc checkAspectLockWidth2 ( string $nodeName ) { float $deviceAspect; if ( `getAttr ( $nodeName + ".aspectLock" )` ) { // AEadjustHeight int $value = `getAttr ( $nodeName + ".width" )`; float $aspect = `getAttr ( $nodeName + ".pixelAspect" )`; if ( $aspect > 0.0 ){ if (`getAttr ( $nodeName + ".aspectLock" )`) { int $rez = $aspect * $value; int $oldrez = `getAttr ( $nodeName + ".height" )`; if ( $rez - $oldrez > 1 || $oldrez - $rez > 1 ) setAttr ( $nodeName + ".height" ) $rez; } } else { checkAspectLock2 $nodeName; } } if ( `getAttr ( $nodeName + ".lockDeviceAspectRatio" )` == 0 ) { $deviceAspect = `getAttr ( $nodeName + ".width" )`; $deviceAspect = $deviceAspect / `getAttr ( $nodeName + ".height" )`; setAttr ( $nodeName + ".deviceAspectRatio" ) $deviceAspect; } } global proc checkAspectLockHeight2 ( string $nodeName ) { float $deviceAspect; if ( `getAttr ( $nodeName + ".aspectLock" )` ) { // AEadjustWidth int $value = `getAttr ( $nodeName + ".height" )`; float $aspect = `getAttr ( $nodeName + ".pixelAspect" )`; if ( $aspect > 0.0 ){ if (`getAttr ( $nodeName + ".aspectLock" )`) { int $rez = $value / $aspect; int $oldrez = `getAttr ( $nodeName + ".width" )`; if ( $rez - $oldrez > 1 || $oldrez - $rez > 1 ) setAttr ( $nodeName + ".width" ) $rez; } } else { checkAspectLock2 $nodeName; } } if ( `getAttr ( $nodeName + ".lockDeviceAspectRatio" )` == 0 ) { $deviceAspect = `getAttr ( $nodeName + ".width" )`; $deviceAspect = $deviceAspect / `getAttr ( $nodeName + ".height" )`; setAttr ( $nodeName + ".deviceAspectRatio" ) $deviceAspect; } } global proc checkAspectLock2 ( string $nodeName ) { // AEadjustPixelAspect int $lockOn = `getAttr ( $nodeName + ".aspectLock" )`; if ($lockOn) { float $h = `getAttr ( $nodeName + ".height" )`; float $w = `getAttr ( $nodeName + ".width" )`; float $aspect = $h / $w; setAttr ( $nodeName + ".pixelAspect" ) $aspect; } else { setAttr ( $nodeName + ".pixelAspect" ) 0.0; } } global proc AEpixelAspect ( string $devAspect, string $x, string $y ) { setUITemplate -pst attributeEditorTemplate; floatSliderGrp -label (uiRes("m_AEresolutionTemplate.kPixelAspectRatio")) -precision 2 -min 0.01 -max 10.0 pixelAspectGrp; setUITemplate -ppt; AEpixelAspectReplace ( $devAspect, $x, $y ); } global proc AEpixelAspectReplace ( string $devAspect, string $x, string $y ) { floatSliderGrp -e -cc ("AEadjustDeviceAspect " + $devAspect + " " + $x + " " + $y) -value (AEcalculatePixelAspect($devAspect, $x, $y)) pixelAspectGrp; scriptJob -parent pixelAspectGrp -replacePrevious -attributeChange $devAspect ("AEadjustPixelAspect "+$devAspect+" "+$x+" "+$y); } global proc AEadjustPixelAspect ( string $devAspect, string $x, string $y ) { float $pixelAspect = AEcalculatePixelAspect ( $devAspect, $x, $y ); floatSliderGrp -e -value $pixelAspect pixelAspectGrp; } global proc AEadjustDeviceAspect ( string $devAspect, string $x, string $y ) { float $pixelAspect = `floatSliderGrp -q -value pixelAspectGrp`; float $aspect = (float) `getAttr $x` / (float) `getAttr $y`; $aspect = $pixelAspect * $aspect; setAttr $devAspect $aspect; } global proc float AEcalculatePixelAspect ( string $devAspect, string $x, string $y ) { float $aspect = (float) `getAttr $x` / (float) `getAttr $y`; $aspect = `getAttr $devAspect` / $aspect; return $aspect; } // // Procedure Name: // AEresolutionTemplate // // global proc AEresolutionTemplate ( string $nodeName ) { editorTemplate -beginScrollLayout; editorTemplate -beginLayout (uiRes("m_AEresolutionTemplate.kResolutionAtr")) -collapse 0; editorTemplate -suppress "pixelAspect"; editorTemplate -addControl "aspectLock" "checkAspectLock2"; editorTemplate -addControl "width" "checkAspectLockWidth2"; editorTemplate -addControl "height" "checkAspectLockHeight2"; editorTemplate -addSeparator; editorTemplate -addControl "lockDeviceAspectRatio"; editorTemplate -addControl "deviceAspectRatio"; editorTemplate -callCustom "AEpixelAspect" "AEpixelAspectReplace" "deviceAspectRatio" "width" "height"; editorTemplate -addSeparator; editorTemplate -addControl "fields"; editorTemplate -addControl "oddFieldFirst"; editorTemplate -addControl "zerothScanline"; editorTemplate -endLayout; // include/call base class/node attributes AEdependNodeTemplate $nodeName; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; }