// =========================================================================== // 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: Dec 11, 1996 // // Description: // This is a helper script to perfrom the scaleKey command // using the various options that have been set // // Input Arguments: // int action 0 - just execute the command // 1 - show the option box dialog // 2 - return the drag command // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { keySetOptionBoxCommon( { "scaleKey", "unknown", "setOptionVars", $forceFactorySettings, 1 } ); // method // if( $forceFactorySettings ||! `optionVar -exists scaleKeyMethod` ) { optionVar -iv scaleKeyMethod 1; } // scale Specified Keys // if ($forceFactorySettings || !`optionVar -exists scaleKeyScaleSpecifiedKeys`) { optionVar -iv scaleKeyScaleSpecifiedKeys 1; } // -newStartTime and -newEndTime // if ($forceFactorySettings || !`optionVar -exists scaleKeyNewStartTime`) { optionVar -floatValue scaleKeyNewStartTime 1.0; } if ($forceFactorySettings || !`optionVar -exists scaleKeyNewEndTime`) { optionVar -floatValue scaleKeyNewEndTime 10.0; } // -timeScale, -timePivot, -valueScale, -valuePivot // if ($forceFactorySettings || !`optionVar -exists scaleKeyTimeScale`) { optionVar -floatValue scaleKeyTimeScale 1.0; } if ($forceFactorySettings || !`optionVar -exists scaleKeyTimePivot`) { optionVar -floatValue scaleKeyTimePivot 0.0; } if ($forceFactorySettings || !`optionVar -exists scaleKeyValueScale`) { optionVar -floatValue scaleKeyValueScale 1.0; } if ($forceFactorySettings || !`optionVar -exists scaleKeyValuePivot`) { optionVar -floatValue scaleKeyValuePivot 0.0; } } global proc scaleKeySetup (string $parent, string $selectionConnection, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; keySetOptionBoxCommon( { "scaleKey", $selectionConnection, "setup", 1 } ); // Method // int $method = `optionVar -query scaleKeyMethod`; radioButtonGrp -edit -select $method method; // Scale Specified Keys // int $ssk = `optionVar -query scaleKeyScaleSpecifiedKeys`; checkBoxGrp -edit -value1 $ssk scaleSpecifiedKeysGrp; // -timeScale, -timePivot, -valueScale, -valuePivot // float $varTimeScale = `optionVar -query scaleKeyTimeScale`; float $varTimePivot = `optionVar -query scaleKeyTimePivot`; float $varValueScale = `optionVar -query scaleKeyValueScale`; float $varValuePivot = `optionVar -query scaleKeyValuePivot`; floatFieldGrp -edit -value1 $varTimeScale -value2 $varTimePivot timeScalePivot; floatFieldGrp -edit -value1 $varValueScale -value2 $varValuePivot valueScalePivot; // -newStartTime and -newEndTime // float $newStartTime = `optionVar -query scaleKeyNewStartTime`; float $newEndTime = `optionVar -query scaleKeyNewEndTime`; floatFieldGrp -edit -value1 $newStartTime -value2 $newEndTime frameNewStartEnd; // Make sure things are setup properly. // scaleKeyWidgetsEnable ($selectionConnection); } global proc scaleKeyCallback( string $parent, int $doIt, string $selectionConnection, int $fromGraphEditor, int $performAction ) { setParent $parent; keySetOptionBoxCommon( { "scaleKey", $selectionConnection, "callback" } ); // -timeScale, -timePivot, -valueScale, -valuePivot // int $method = `radioButtonGrp -query -select method`; if( $method == 1 ) { $varTimeScale = `floatFieldGrp -query -value1 timeScalePivot`; $varTimePivot = `floatFieldGrp -query -value2 timeScalePivot`; $varValueScale = `floatFieldGrp -query -value1 valueScalePivot`; $varValuePivot = `floatFieldGrp -query -value2 valueScalePivot`; optionVar -floatValue scaleKeyTimeScale $varTimeScale; optionVar -floatValue scaleKeyTimePivot $varTimePivot; optionVar -floatValue scaleKeyValueScale $varValueScale; optionVar -floatValue scaleKeyValuePivot $varValuePivot; } // -newStartTime and -newEndTime // else { optionVar -floatValue scaleKeyNewStartTime `floatFieldGrp -query -value1 frameNewStartEnd`; optionVar -floatValue scaleKeyNewEndTime `floatFieldGrp -query -value2 frameNewStartEnd`; } optionVar -intValue scaleKeyMethod $method; int $ssk = `checkBoxGrp -query -value1 scaleSpecifiedKeysGrp`; optionVar -intValue scaleKeyScaleSpecifiedKeys $ssk; if( $doIt ) { string $args[] = { (string) $performAction, $selectionConnection, $fromGraphEditor }; performScaleKeyArgList 1 $args; string $tmpCmd = "performScaleKeyArgList 1 {"; $tmpCmd += "\"" + $performAction + "\", "; $tmpCmd += "\"" + $selectionConnection + "\", "; $tmpCmd += "\"" + $fromGraphEditor + "\"}"; addToRecentCommandQueue $tmpCmd "Scale Keys"; } } global proc scaleKeyDoSelectionChanged(string $selectionConnection) // // Description: // Since timeRange is irrelevant when there are // picked keyframes, collapse the timeRange // when there are. (This is hooked in to a SelectionChanged // trigger.) // { keySetOptionBoxCommon( { "scaleKey", $selectionConnection, "selectionChanged" } ); } global proc scaleKeyWidgetsEnable(string $selectionConnection) // // Description: // These are the widgets that get enabled and // disabled based on the certain states. Put them // here so they're all in one place. // { keySetOptionBoxCommon( { "scaleKey", $selectionConnection, "enable" } ); // Method // int $isPivot = ( `radioButtonGrp -q -select method` == 1 ); frameLayout -e -enable $isPivot scalePivotFrame; frameLayout -e -enable (!$isPivot) scaleStartEndFrame; } proc string scaleKeyWidgets (string $tabLayout, string $selectionConnection, int $fromGraphEditor) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; keySetOptionBoxCommon( { "scaleKey", $selectionConnection, "widgets", $fromGraphEditor, 1 } ); radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performScaleKeyArgList.kMethod")) -label1 (uiRes("m_performScaleKeyArgList.kScalePivot")) -cc1 "frameLayout -e -enable yes scalePivotFrame; frameLayout -e -enable no scaleStartEndFrame;" -label2 (uiRes("m_performScaleKeyArgList.kStartEnd")) -cc2 "frameLayout -e -enable no scalePivotFrame; frameLayout -e -enable yes scaleStartEndFrame;" method; checkBoxGrp -numberOfCheckBoxes 1 -label (uiRes("m_performScaleKeyArgList.kOnlyScaleSpecifiedKeys")) -label1 "" scaleSpecifiedKeysGrp; frameLayout -bv no -lv no -collapsable no -enable yes scalePivotFrame; columnLayout -adjustableColumn true; floatFieldGrp -nf 2 -label (uiRes("m_performScaleKeyArgList.kTimeScalePivot")) -value1 1.0 -value2 0.0 timeScalePivot; floatFieldGrp -nf 2 -label (uiRes("m_performScaleKeyArgList.kValueScalePivot")) -value1 1.0 -value2 0.0 valueScalePivot; setParent ..; setParent ..; frameLayout -bv no -lv no -collapsable no -enable no scaleStartEndFrame; columnLayout -adjustableColumn true; floatFieldGrp -nf 2 -label (uiRes("m_performScaleKeyArgList.kNewStartEndTimes")) -value1 0.0 -value2 0.0 frameNewStartEnd; setParent ..; setParent ..; text -label " "; return $tabForm; } proc scaleKeyOptions(string $selectionConnection, int $performAction, int $fromGraphEditor) { // Customisation options // // Name of the command for this option box (think of it as the base class) string $commandName = "scaleKey"; // Title for the option box window string $optionBoxTitle = (uiRes("m_performScaleKeyArgList.kScaleKeysOptions")); // Title for the apply button string $applyTitle = (uiRes("m_performScaleKeyArgList.kScaleKeys")); // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Build the window, with a tab layout // string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`; setUITemplate -pushTemplate DefaultTemplate; // Make the form invisible while we create the widgets in the window // formLayout -e -vis false $widgetList[1]; // Attach each tab // scaleKeyWidgets $widgetList[2] $selectionConnection $fromGraphEditor; // Attach the standard buttons // string $buttonList[] = `addStandardButtons $commandName $applyTitle $widgetList[1] $widgetList[2] "noOptions"`; // attach commands to the standard buttons // // Save // button -e -c ($callback + " " + $widgetList[0] + " false \"\" " + $fromGraphEditor + " " + $performAction + "; hideOptionBox()") $buttonList[3]; // Close // button -edit -command hideOptionBox $buttonList[2]; // Reset // button -edit -command ($setup + " " + $widgetList[2] + " " + $selectionConnection + " true") $buttonList[1]; // DoIt // button -edit -command ($callback + " " + $widgetList[0] + " true \"" + $selectionConnection + "\" " + $fromGraphEditor + " " + $performAction) $buttonList[0]; // Make the form layout visible so we can see what we built, and // reset the template // formLayout -e -vis true $widgetList[1]; setUITemplate -popTemplate; // Customize the 'Help' menu item text. // This is called from 3 different places so look at the selection // connection to try to figure out which one. // if (match ("graphEditor", $selectionConnection) != "") { setOptionBoxHelpTag( "GraphScale" ); } else if (match ("dopeSheet", $selectionConnection) != "") { setOptionBoxHelpTag( "DopeScale" ); } else { setOptionBoxHelpTag( "KeysScaleKeys" ); } // Call the setup "method" to fill in the current settings // eval (($setup + " " + $widgetList[2] + " " + $selectionConnection + " false")); showOptionBox(); showWindow $widgetList[0]; if( $fromGraphEditor ) { scaleKeyDoSelectionChanged($selectionConnection); scriptJob -protected -event "SelectionChanged" ("scaleKeyDoSelectionChanged " + $selectionConnection) -parent $widgetList[2]; } } proc string assembleCmd(string $selectionConnection, int $fromGraphEditor, string $options ) { float $newStart = `optionVar -q scaleKeyNewStartTime`; float $newEnd = `optionVar -q scaleKeyNewEndTime`; // doScaleKeyArgList takes a string array // $cmd = "doScaleKeyArgList 3 { " + "\"" + `optionVar -q scaleKeyWhichRange` + "\"" + ",\"" + `optionVar -q scaleKeyRange` + "\"" + ",\"" + `optionVar -q scaleKeyMethod` + "\"" + ",\"" + $newStart + "\"" + ",\"" + $newEnd + "\"" + ",\"" + `optionVar -q scaleKeyTimeScale` + "\"" + ",\"" + `optionVar -q scaleKeyTimePivot` + "\"" + ",\"" + `optionVar -q scaleKeyValueScale` + "\"" + ",\"" + `optionVar -q scaleKeyValuePivot` + "\"" + ",\"" + `optionVar -q scaleKeyHierarchy` + "\"" + ",\"" + `optionVar -q scaleKeyControlPoints` + "\"" + ",\"" + `optionVar -q scaleKeyShapes` + "\"" + ",\"" + `optionVar -q scaleKeyUseChannelBox` + "\"" + ",\"" + `optionVar -q scaleKeyAllAnimCurves` + "\"" + ",\"" + $selectionConnection + "\"" + ",\"" + `optionVar -q scaleKeyScaleSpecifiedKeys` + "\"" + ",\"" + $options + "\"" + ",\"" + $fromGraphEditor + "\"" + ",\"" + `optionVar -q scaleKeyDriven` + "\"" + " };"; return $cmd; } global proc string performScaleKeyArgList (string $version, string $args[]) // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $action, $selectionConnection, $fromGraphEditor // // $args // Version 1 // [0] $action 0 - do the command // 1 - show the option box // 2 - return the drag command // 3 - do the command (bufferCurve version) // 4 - show the option box (bufferCurve version) // 5 - return the drag command (bufferCurve version) // [1] $selectionConnection name of selection connection to use // unless $options has "bufferCurve" in which // case this is the name of the editor // [2] $fromGraphEditor true if being called from the graph editor // // // Return Value: // The actual command to execute. // { int $versionNum = $version; int $action = $args[0]; string $selectionConnection = $args[1]; int $fromGraphEditor = $args[2]; string $cmd = ""; switch( $action ) { case 0: setOptionVars( false ); $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, "noOptions"); eval( $cmd ); break; case 1: scaleKeyOptions($selectionConnection, 0, $fromGraphEditor); break; case 2: setOptionVars( false ); $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, "noOptions"); break; case 3: setOptionVars( false ); $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, "bufferCurve"); eval( $cmd ); break; case 4: scaleKeyOptions($selectionConnection, 3, $fromGraphEditor); break; case 5: setOptionVars( false ); $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, "bufferCurve"); break; } return ($cmd); }