// =========================================================================== // 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: March 20, 2013 // // Description: // Defines the procedures to create and update the horizontal/vertical aperture fields in mm. // These fields are created below the old "Camera Aperture" fields which use inch. // Change the mm fields will update the inch fields accordingly to the value in inch, vise versa. // Only the old "Camera Aperture" fields(inch) retain the UI controls like the checker board icon and right-click menu. // The new "Camera Aperture" fields(mm) are only for view/edits. // // Procedure Name: // inchToMmFactor // // Description: // Retrives the factor to calculate aperture values from inch to mm. // proc float inchToMmFactor() { return 25.4; } // // Procedure Name: // AEupdateHorizontalFilmApertureField // // Description: // Update the horizontal film aperture field in the "Attribute Editor", // for example, after the horizontalFilmAperture attribute is reset. // global proc AEupdateHorizontalFilmApertureField (string $hor, string $hApertureFieldInMmFullPath) { float $fHor = `getAttr $hor`; $fHor *= inchToMmFactor(); floatField -e -v $fHor $hApertureFieldInMmFullPath; } // // Procedure Name: // AEupdateVerticalFilmApertureField // // Description: // Update the vertical film aperture field in the "Attribute Editor" // for example, after the verticalFilmAperture attribute is reset. // global proc AEupdateVerticalFilmApertureField (string $ver, string $vApertureFieldInMmFullPath) { float $fVer = `getAttr $ver`; $fVer *= inchToMmFactor(); floatField -e -v $fVer $vApertureFieldInMmFullPath; } // // Procedure Name: // AEchangeHorizontalFilmAperture // // Description: // Call when user change the horizontal film aperture value from the "Attribute Editor" . // global proc AEchangeHorizontalFilmAperture(string $hor, string $hApertureFieldInMmFullPath) { if(`getAttr -settable $hor`) { float $fHor = `floatField -q -v $hApertureFieldInMmFullPath`; $fHor /= inchToMmFactor(); setAttr $hor $fHor; } else { // Retains the old value AEupdateHorizontalFilmApertureField($hor, $hApertureFieldInMmFullPath); errAttrLocked($hor); } } // // Procedure Name: // AEchangeVerticalFilmAperture // // Description: // Call when user change the vertical film aperture value from the "Attribute Editor" . // global proc AEchangeVerticalFilmAperture(string $ver, string $vApertureFieldInMmFullPath) { if(`getAttr -settable $ver`) { float $fVer = `floatField -q -v $vApertureFieldInMmFullPath`; $fVer /= inchToMmFactor(); setAttr $ver $fVer; } else { // Retains the old value AEupdateVerticalFilmApertureField($ver, $vApertureFieldInMmFullPath); errAttrLocked($ver); } } // // Procedure Name: // AEcameraFilmApertureReplace // // Description: // This procedure connects the UI objects created by AEcameraFilmApertureNew procedure with the equivalent attributes in the camera node. // Edits on the UI objects will reflect the equivalent attributes of the camera in the control of specific procedures. // Vice versa. // // global proc AEcameraFilmApertureReplace (string $hor, string $ver) { float $fHor = `getAttr $hor`; $fHor *= inchToMmFactor(); float $fVer = `getAttr $ver`; $fVer *= inchToMmFactor(); string $hApertureFieldInMmFullPath = `floatField -q -fpn hApertureFieldInMm`; string $vApertureFieldInMmFullPath = `floatField -q -fpn vApertureFieldInMm`; floatField -e -pre 3 -cc ("AEchangeHorizontalFilmAperture " + $hor + " " + $hApertureFieldInMmFullPath) -v $fHor $hApertureFieldInMmFullPath; floatField -e -pre 3 -cc ("AEchangeVerticalFilmAperture " + $ver + " " + $vApertureFieldInMmFullPath) -v $fVer $vApertureFieldInMmFullPath; scriptJob -parent $hApertureFieldInMmFullPath -replacePrevious -attributeChange $hor ("AEupdateHorizontalFilmApertureField " + $hor + " " + $hApertureFieldInMmFullPath); scriptJob -parent $vApertureFieldInMmFullPath -replacePrevious -attributeChange $ver ("AEupdateVerticalFilmApertureField " + $ver + " " + $vApertureFieldInMmFullPath); } // // Procedure Name: // AEcameraFilmApertureNew // // Description: // Initialization of the film aperture data fields. // global proc AEcameraFilmApertureNew (string $hor, string $ver) { setUITemplate -pst attributeEditorTemplate; rowLayout -numberOfColumns 3 -cw 2 70 -cw 3 70; text -l (uiRes("m_AEcameraFilmApertureNew.kCameraApertureInMm")) ; floatField -pre 3 -step .1 -w 70 hApertureFieldInMm; floatField -pre 3 -step .1 -w 70 vApertureFieldInMm; setUITemplate -ppt; AEcameraFilmApertureReplace($hor, $ver); }