// =========================================================================== // 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: April 26, 2006 // // Description: // This script is the merge cache clip option box // // Input Arguments: // None. // // Return Value: // None. // global string $gMergeCacheClipCurrentProject = "CurrentProject"; global string $gMergeCacheClipSceneNameForPrefs = ""; global proc mergeCacheSetDirOptionVar() { global string $gMergeCacheClipCurrentProject; global string $gMergeCacheClipSceneNameForPrefs; string $value = `textFieldGrp -q -tx cacheDir`; if( $value != "" ) { string $currentProj = (`workspace -q -rd` + "data\/"); if( $currentProj == $value ) { $value = $gMergeCacheClipCurrentProject; } optionVar -sv mergeCacheClipDirName $value; $gMergeCacheClipSceneNameForPrefs = `file -q -loc`; } else { optionVar -sv mergeCacheClipDirName $gMergeCacheClipCurrentProject; } } global proc int mergeCacheSetDirectory( string $dir, string $type ) { textFieldGrp -e -tx $dir cacheDir; mergeCacheSetDirOptionVar(); return 1; } global proc mergeCacheBrowseForFolder() { string $cmd = "mergeCacheSetDirectory "; string $action = (uiRes("m_performMergeCacheClip.kSetDir")); string $startInDir = `textFieldGrp -q -tx cacheDir`; if( size( $startInDir) == 0) { $startInDir = `internalVar -uwd`; } if( `file -q -ex $startInDir` ) { workspace -dir $startInDir; } fileBrowser( $cmd, $action, "", 4); } proc setOptionVars (int $forceFactorySettings) { global string $gMergeCacheClipCurrentProject; global string $gMergeCacheClipSceneNameForPrefs; string $currSceneName = `file -q -loc`; if( $currSceneName != $gMergeCacheClipSceneNameForPrefs ) { // We only want the cache name and directory name prefs to exist // for the time that the scene is opened. We don't want them // to be saved for the next session or next scene. // optionVar -rm mergeCacheClipDirName; } if ($forceFactorySettings || !`optionVar -exists mergeCacheClipName`) { optionVar -stringValue mergeCacheClipName "mergedClip"; } if( $forceFactorySettings || !`optionVar -exists mergeCacheClipDirName`) { optionVar -stringValue mergeCacheClipDirName "CurrentProject"; } if( $forceFactorySettings || !`optionVar -exists mergeCacheClipDistrib`) { optionVar -intValue mergeCacheClipDistrib 1; } if( $forceFactorySettings || !`optionVar -exists mergeCacheClipSimulationRate`) { optionVar -floatValue mergeCacheClipSimulationRate 1; } if( $forceFactorySettings || !`optionVar -exists mergeCacheClipSampleMultiplier`) { optionVar -intValue mergeCacheClipSampleMultiplier 1; } if ( $forceFactorySettings || !`optionVar -exists mergeCacheClipDeleteOrig`) { optionVar -intValue mergeCacheClipDeleteOrig 0; } } // // Procedure Name: // mergeCacheClipSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc mergeCacheClipSetup (string $parent, int $forceFactorySettings) { global string $gMergeCacheClipCurrentProject; // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Set the clip name. // string $mergeCacheClipName = `optionVar -query mergeCacheClipName`; textFieldGrp -e -text $mergeCacheClipName mergeCacheClipNameGrp; checkBoxGrp -e -v1 `optionVar -query mergeCacheClipDeleteOrig` mergeCacheClipDelete; int $distOpt = `optionVar -q mergeCacheClipDistrib`; if( $distOpt == 1 ) { radioButtonGrp -e -sl 1 mergeCacheClipDist1; } else if( $distOpt == 2 ) { radioButtonGrp -e -sl 1 mergeCacheClipDist2; } verifyWorkspaceFileRule( "fileCache", "cache/nCache" ); string $dirToUse = cacheGetCurrentDir("fileCache", "mergeCacheClipDirName", $gMergeCacheClipCurrentProject, true); textFieldGrp -e -tx $dirToUse cacheDir; floatFieldGrp -e -v1 `optionVar -q mergeCacheClipSimulationRate` mergeCacheClipSimRate; intFieldGrp -e -v1 `optionVar -q mergeCacheClipSampleMultiplier` mergeCacheClipSampleMult; } // // Procedure Name: // mergeCacheClipCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // clipEd - The name of the Clip Editor. // // Return Value: // None. // global proc mergeCacheClipCallback (string $parent, int $doIt, string $clipEd) { setParent $parent; string $mergeCacheClipName = `textFieldGrp -q -text mergeCacheClipNameGrp`; optionVar -stringValue mergeCacheClipName $mergeCacheClipName; optionVar -iv mergeCacheClipDeleteOrig `checkBoxGrp -q -v1 mergeCacheClipDelete`; int $distMode = 1; if( `radioButtonGrp -q -sl mergeCacheClipDist1` ) $distMode = 1; else if ( `radioButtonGrp -q -sl mergeCacheClipDist2`) $distMode = 2; optionVar -iv mergeCacheClipDistrib $distMode; optionVar -fv mergeCacheClipSimulationRate `floatFieldGrp -q -v1 mergeCacheClipSimRate`; optionVar -iv mergeCacheClipSampleMultiplier `intFieldGrp -q -v1 mergeCacheClipSampleMult`; if ($doIt) performMergeCacheClip false $clipEd; } proc string mergeCacheClipWidgets( string $parent ) { global string $gMergeCacheClipCurrentProject; setParent $parent; string $tabForm = `columnLayout -adj true`; // Directory name // rowLayout -nc 3 -cw3 400 5 50 -adjustableColumn 1 -cal 1 "both" -cal 2 "both" -cal 3 "left" -ct3 "both" "both" "left"; verifyWorkspaceFileRule( "fileCache", "cache/nCache" ); string $dirToUse = cacheGetCurrentDir("fileCache", "mergeCacheClipDirName", $gMergeCacheClipCurrentProject, true); textFieldGrp -label (uiRes("m_performMergeCacheClip.kCacheDirectory")) -tx $dirToUse -cc ( "mergeCacheSetDirOptionVar" ) -adjustableColumn 2 cacheDir; separator -w 5 -style "none"; symbolButton -image "navButtonBrowse.png" -c ( "mergeCacheBrowseForFolder" ) cacheDirBrowser; setParent ..; rowLayout -nc 3 -cw3 100 5 100 -adjustableColumn 1 -cal 1 "left" -cal 2 "both" -cal 3 "left" -ct3 "left" "both" "left"; textFieldGrp -label (uiRes("m_performMergeCacheClip.kName")) -text (uiRes("m_performMergeCacheClip.kMergedClipText")) mergeCacheClipNameGrp; setParent ..; separator -h 5 -style "none"; // Distribution of cache files // radioButtonGrp -label (uiRes("m_performMergeCacheClip.kCacheFileDistribution")) -nrb 1 -l1 (uiRes("m_performMergeCacheClip.kOnePerFrame")) mergeCacheClipDist1; radioButtonGrp -label "" -nrb 1 -scl mergeCacheClipDist1 -l1 (uiRes("m_performMergeCacheClip.kOneFile")) mergeCacheClipDist2; separator -h 5 -style "none"; floatFieldGrp -label (uiRes("m_performMergeCacheClip.kSimulationRate")) -nf 1 -extraLabel (uiRes("m_performMergeCacheClip.kSimulationRateEnd")) mergeCacheClipSimRate; intFieldGrp -label (uiRes("m_performMergeCacheClip.kSampleMultiplier")) -nf 1 -extraLabel (uiRes("m_performMergeCacheClip.kSampleMultiplierEnd")) mergeCacheClipSampleMult; // whether to move originals to visor or put merged clip in visor checkBoxGrp -numberOfCheckBoxes 1 -label (uiRes("m_performMergeCacheClip.kFileCleanup")) -label1 (uiRes("m_performMergeCacheClip.kDeleteAfter")) -v1 0 mergeCacheClipDelete; return $tabForm; } global proc mergeCacheClipOptions (string $clipEd) { string $commandName = "mergeCacheClip"; string $applyTitle = (uiRes("m_performMergeCacheClip.kMergeCacheClip")); // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; mergeCacheClipWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performMergeCacheClip.kMergeClip")) -command ($callback + " " + $parent + " " + 1 + " \"" + $clipEd + "\"") $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "\"" + $clipEd + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_performMergeCacheClip.kMergeClipOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "MergeCacheClip" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // The name of the clip editor used to call this option box. // // Return Value: // None. // proc string assembleCmd(string $clipEd) { if( size(`ls -sl -type cacheFile`) <= 1) { error( (uiRes("m_performMergeCacheClip.kChooseMore"))); return ""; } global string $gMergeCacheClipCurrentProject; global string $gMergeCacheClipSceneNameForPrefs; $gMergeCacheClipSceneNameForPrefs = `file -q -loc`; string $cmd; string $dir = `optionVar -query mergeCacheClipDirName`; if( $dir == $gMergeCacheClipCurrentProject ) { $dir = ""; } string $keep = "merge"; if( `optionVar -query mergeCacheClipDeleteOrig` == 1) { $keep = "mergeDelete"; } string $distrib = "OneFilePerFrame"; if (`optionVar -query mergeCacheClipDistrib` == 2) { $distrib = "OneFile"; } string $name = `optionVar -query mergeCacheClipName`; float $simRate = `optionVar -q mergeCacheClipSimulationRate`; int $sampleMult = `optionVar -q mergeCacheClipSampleMultiplier`; $cmd = ("doMergeCache 1 { \"0\", \"0.0\", \"0.0\"" + ",\"" + $distrib + "\"" + ",\"" + $dir + "\"" + ",\"" + $name+ "\"" + ",\"0\",\"0\"" + ",\"" + $simRate + "\"" + ",\"" + $sampleMult + "\"" + ",\"" + $keep + "\"" + ",\"geom\"" + " };"); return $cmd; } // // Procedure Name: // performMergeCacheClip // // Description: // Merge two cache clips into one. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performMergeCacheClip (int $action, string $clipEd) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd($clipEd)`; // Execute the command with the option settings. // if ($cmd != "") evalEcho($cmd); break; // Show the option box. // case 1: mergeCacheClipOptions($clipEd); break; case 2: // Get the command. // $cmd = `assembleCmd($clipEd)`; } return $cmd; }