// =========================================================================== // 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. // =========================================================================== // // // Creation Date: May 13, 1997 // // Procedure Names: // AEresetFilmbackMenu // AEwhichCameraFilmback // AEcameraFilmbackReplace // AEcameraFilmbackNew // // Description: // Procedures to create and update the filmback option menu. // proc string[] globalFilmbackTable() { // MEL doesn't like initialization with non-constant // values, so we'll fill them in the first time instead. // global string $gFilmbackTable[] = {}; if( size( $gFilmbackTable ) == 0 ) { $gFilmbackTable = { // Name Horiz Vert Squeeze (uiRes("m_AEcameraFilmbackNew.kTheatrical")), "0.404", "0.295", "1.0", (uiRes("m_AEcameraFilmbackNew.kSuper")), "0.493", "0.292", "1.0", (uiRes("m_AEcameraFilmbackNew.kAcademy")), "0.864", "0.630", "1.0", (uiRes("m_AEcameraFilmbackNew.kProjectionTV")), "0.816", "0.612", "1.0", (uiRes("m_AEcameraFilmbackNew.kAperture")), "0.980", "0.735", "1.0", (uiRes("m_AEcameraFilmbackNew.kProjection185")), "0.825", "0.446", "1.0", (uiRes("m_AEcameraFilmbackNew.kAnamorphic")), "0.864", "0.732", "2.0", (uiRes("m_AEcameraFilmbackNew.kProjection70")), "2.066", "0.906", "1.0", (uiRes("m_AEcameraFilmbackNew.kVista")), "1.485", "0.991", "1.0", (uiRes("m_AEcameraFilmbackNew.kImax")), "2.772", "2.072", "1.0" }; } return $gFilmbackTable; } proc int equivalent( float $lhs, float $rhs ) { return $lhs - 0.0001 < $rhs && $lhs + 0.0001 > $rhs; } // // Procedure Name: // AEresetFilmbackMenu // // Description: // Procedure to update the filmback menu to the proper setting // depending on the film aperture and squeeze ratio. // global proc AEresetFilmbackMenu( string $hor, string $ver, string $squ, string $filmbackMenuFullPath ) { string $filmbackTable[] = globalFilmbackTable(); float $fHor = `getAttr $hor`; float $fVer = `getAttr $ver`; float $fSqu = `getAttr $squ`; int $index = 1; for ($i = 0; $i < size($filmbackTable); $i += 4) { if (equivalent($fHor, (float) $filmbackTable[$i + 1]) && equivalent($fVer, (float) $filmbackTable[$i + 2]) && equivalent($fSqu, (float) $filmbackTable[$i + 3])) { // Offset index to compensate for the four items in each // record, the user defined menu, and one based option // menu. $index = $i / 4 + 2; break; } } optionMenu -e -select $index $filmbackMenuFullPath; } // // Procedure Name: // AEwhichCameraFilmback // // Description: // Procedure to update the camera film aperture and squeeze ratio // depending on the selected filmback. // global proc AEwhichCameraFilmback (string $hor, string $ver, string $squ, string $filmbackMenuFullPath) { string $filmbackTable[] = globalFilmbackTable(); int $index = `optionMenu -q -select $filmbackMenuFullPath`; if ($index > 1) { if(!`getAttr -settable $hor`) { // Retains the old value AEresetFilmbackMenu($hor, $ver, $squ, $filmbackMenuFullPath); errAttrLocked($hor); } else if(!`getAttr -settable $ver`) { // Retains the old value AEresetFilmbackMenu($hor, $ver, $squ, $filmbackMenuFullPath); errAttrLocked($ver); } else if(!`getAttr -settable $squ`) { // Retains the old value AEresetFilmbackMenu($hor, $ver, $squ, $filmbackMenuFullPath); errAttrLocked($squ); } else { // Offset index to compensate for the four items in each // record, the user defined menu, and one based option menu. $index = ($index - 2) * 4; setAttr $hor ((float) $filmbackTable[$index + 1]); setAttr $ver ((float) $filmbackTable[$index + 2]); setAttr $squ ((float) $filmbackTable[$index + 3]); } } } // // Procedure Name: // AEcameraFilmbackReplace // Description: // A new camera has been placed into the attribute editor, update // the filmback option menu to reflect this camera. // global proc AEcameraFilmbackReplace (string $hor, string $ver, string $squ) { string $filmbackMenuFullPath = `optionMenu -q -fpn filmbackMenu`; optionMenu -e -changeCommand ("AEwhichCameraFilmback " + $hor + " " + $ver + " " + $squ + " " + $filmbackMenuFullPath) $filmbackMenuFullPath; scriptJob -parent $filmbackMenuFullPath -replacePrevious -attributeChange $hor ("AEresetFilmbackMenu " + $hor + " " + $ver + " " + $squ + " " + $filmbackMenuFullPath); scriptJob -parent $filmbackMenuFullPath -attributeChange $ver ("AEresetFilmbackMenu " + $hor + " " + $ver + " " + $squ + " " + $filmbackMenuFullPath); scriptJob -parent $filmbackMenuFullPath -attributeChange $squ ("AEresetFilmbackMenu " + $hor + " " + $ver + " " + $squ + " " + $filmbackMenuFullPath); // Update the filmback menu selection. AEresetFilmbackMenu($hor, $ver, $squ, $filmbackMenuFullPath); } // // Procedure Name: // AEcameraFilmbackNew // global proc AEcameraFilmbackNew (string $hor, string $ver, string $squeeze) { string $filmbackTable[] = globalFilmbackTable(); setUITemplate -pst attributeEditorTemplate; rowLayout -numberOfColumns 2; text -label (uiRes("m_AEcameraFilmbackNew.kFilmGate")) ; optionMenu -l "" filmbackMenu; menuItem -label (uiRes("m_AEcameraFilmbackNew.kUser")) ; for ($i = 0; $i < size($filmbackTable); $i += 4) { menuItem -l $filmbackTable[$i]; } setParent ..; setUITemplate -ppt; AEcameraFilmbackReplace($hor, $ver, $squeeze); }