// =========================================================================== // 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: August 14, 1996 // // Description: // This is a helper script to perfrom the cutKey -clear 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( { "clearKey", "unknown", "setOptionVars", $forceFactorySettings, 1 } ); // -options // if ($forceFactorySettings || !`optionVar -exists clearKeyOption`) { optionVar -stringValue clearKeyOption "keys"; } // help images // if ($forceFactorySettings || !`optionVar -exists clearKeyHelpPictures`) { optionVar -intValue clearKeyHelpPictures 0; } } global proc clearKeySetup (string $parent, string $selectionConnection, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; keySetOptionBoxCommon( { "clearKey", $selectionConnection, "setup", 1 } ); // -option // string $option = `optionVar -query clearKeyOption`; int $attach = 1; int $connect = 0; if (substring ($option, 1, 4) == "keys") { radioButtonGrp -edit -select 1 method; } else { radioButtonGrp -edit -select 2 method; if ($option == "curveCollapse") { $attach = 2; } else if ($option == "curveConnect") { $attach = 2; $connect = 1; } } radioButtonGrp -edit -select $attach adjustment; checkBoxGrp -e -value1 $connect connect; // help images // int $pictures = `optionVar -q clearKeyHelpPictures`; checkBoxGrp -e -value1 $pictures helpPictures; // Now get all the dependent widgets in the right // enabled/disabled/collapsed/expanded state // clearKeyWidgetsEnable ($selectionConnection); } global proc clearKeyCallback( string $parent, int $doIt, string $selectionConnection, int $fromGraphEditor, int $performAction ) { setParent $parent; keySetOptionBoxCommon( { "clearKey", $selectionConnection, "callback" } ); // -option string $option; if (`radioButtonGrp -query -select method` == 1) { $option = "keys"; } else { $option = "curve"; } if (`radioButtonGrp -query -select adjustment` == 2) { if( `checkBoxGrp -query -value1 connect` ) { $option = $option + "Connect"; } else { $option = $option + "Collapse"; } } optionVar -stringValue clearKeyOption $option; // help // int $pictures = `checkBoxGrp -query -value1 helpPictures`; optionVar -intValue clearKeyHelpPictures $pictures; if( $doIt ) { string $args[] = { (string) $performAction, $selectionConnection, (string) 0, (string) $fromGraphEditor }; performClearKeyArgList 1 $args; string $tmpCmd = "{\"" + $performAction + "\", \"" + $selectionConnection + "\", "; $tmpCmd += "0, \"" + $fromGraphEditor + "\"}"; addToRecentCommandQueue $tmpCmd "ClearKey"; } } global proc clearKeyHelpPictures () { int $doPictures = (`checkBoxGrp -q -value1 helpPictures` && `checkBoxGrp -q -enable helpPictures`); if( $doPictures == 0 ) { frameLayout -e -collapse yes methodPictureFrame; frameLayout -e -collapse yes adjustmentPictureFrame; return; } int $method = `radioButtonGrp -q -select method`; int $adjustment = `radioButtonGrp -q -select adjustment`; string $adjustmentPicture = "CCP"; string $methodPicture; if( $method == 1 ) { $adjustmentPicture = $adjustmentPicture + "cutKeys"; } else { $adjustmentPicture = $adjustmentPicture + "cutCurve"; } $methodPicture = "CCPclear.png"; if( $adjustment == 2 ) { if( `checkBoxGrp -q -value1 connect` ) { $adjustmentPicture = $adjustmentPicture + "Connect.png"; } else { $adjustmentPicture = $adjustmentPicture + "Collapse.png"; } } else { $adjustmentPicture = $adjustmentPicture + ".png"; } picture -e -image (languageResourcePath( $methodPicture )) methodPicture; picture -e -image (languageResourcePath( $adjustmentPicture )) adjustmentPicture; frameLayout -e -collapse no methodPictureFrame; frameLayout -e -collapse no adjustmentPictureFrame; } global proc clearKeyDoSelectionChanged (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( { "clearKey", $selectionConnection, "selectionChanged" } ); if (match ("dopeSheet", $selectionConnection) != "") { string $currentPanel = `getPanel -withFocus`; string $dopeSheet = $currentPanel + "DopeSheetEd"; float $region[] = `dopeSheetEditor -q -sel $dopeSheet`; if ($region[0] < $region[1] && $region[2] < $region[3] ) { floatFieldGrp -edit -value1 $region[0] frameStart; floatFieldGrp -edit -value1 $region[1] frameEnd; keySetOptionBoxCommon( { "clearKey", $selectionConnection, "callback" } ); } } else { if( `keyframe -q -sl -kc` > 0) { radioButtonGrp -e -enable2 false -select 1 method; radioButtonGrp -e -enable2 false -select 1 adjustment; } else if( `radioButtonGrp -q -enable method` ) { radioButtonGrp -e -enable2 true method; } } } global proc clearKeyWidgetsEnable (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( { "clearKey", $selectionConnection, "enable" } ); // Options frame // int $enableIt = ( `radioButtonGrp -q -select timeRange` != 1 ); frameLayout -e -enable $enableIt optionsFrame; // Collapse adjustment // $enableIt = (( `radioButtonGrp -q -select method` == 2 ) && ( `radioButtonGrp -q -enable2 method` )); radioButtonGrp -e -enable2 $enableIt adjustment; if( !$enableIt && `radioButtonGrp -q -enable method` ) { radioButtonGrp -e -select 1 adjustment; } // Connect check box // $enableIt = (( `radioButtonGrp -q -select adjustment` == 2 ) && ( `radioButtonGrp -q -enable2 adjustment` )); checkBoxGrp -e -enable $enableIt connect; int $useStartEnd = ( `radioButtonGrp -q -sl timeRange` == 2 ) && ( `radioButtonGrp -q -enable timeRange` ); frameLayout -e -enable $useStartEnd startEndFrame; clearKeyHelpPictures; } proc string clearKeyWidgets( string $tabLayout, string $selectionConnection, int $fromGraphEditor ) { global int $gOptionBoxTextColumnWidthIndex; setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; keySetOptionBoxCommon( { "clearKey", $selectionConnection, "widgets", $fromGraphEditor, 1 } ); frameLayout -bv no -lv no -collapsable no optionsFrame; columnLayout -adjustableColumn true; checkBoxGrp -label (uiRes("m_performClearKeyArgList.kHelpImages")) -ncb 1 -value1 off -label1 "" -cc1 "clearKeyHelpPictures;" helpPictures; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performClearKeyArgList.kMethod")) -label1 (uiRes("m_performClearKeyArgList.kKeys")) -cc1 ("clearKeyWidgetsEnable " + $selectionConnection) -label2 (uiRes("m_performClearKeyArgList.kSegments")) -cc2 ("clearKeyWidgetsEnable " + $selectionConnection) method; frameLayout -bv no -lv no -collapsable yes -collapse yes methodPictureFrame; columnLayout -columnAttach "left" $gOptionBoxTextColumnWidthIndex; picture methodPicture; setParent ..; setParent ..; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performClearKeyArgList.kAdjustment")) -label1 (uiRes("m_performClearKeyArgList.kNone")) -cc1 ("clearKeyWidgetsEnable " + $selectionConnection) -label2 (uiRes("m_performClearKeyArgList.kCollapse")) -cc2 ("clearKeyWidgetsEnable " + $selectionConnection) adjustment; checkBoxGrp -label (uiRes("m_performClearKeyArgList.kConnect")) -ncb 1 -label1 "" -value1 off -cc1 "clearKeyHelpPictures;" connect; frameLayout -bv no -lv no -collapsable yes -collapse yes adjustmentPictureFrame; columnLayout -columnAttach "left" $gOptionBoxTextColumnWidthIndex; picture adjustmentPicture; setParent ..; setParent ..; setParent ..; setParent ..; return $tabForm; } proc clearKeyOptions( 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 = "clearKey"; // Title for the option box window string $optionBoxTitle; string $applyTitle; $optionBoxTitle = (uiRes("m_performClearKeyArgList.kDeleteKeysOptions")); $applyTitle = (uiRes("m_performClearKeyArgList.kDeleteKeys")); // 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 the widgets. No tab layout needed. // clearKeyWidgets $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 -c ($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( "GraphDelete" ); } else if (match ("dopeSheet", $selectionConnection) != "") { setOptionBoxHelpTag( "DopeDelete" ); } else { setOptionBoxHelpTag( "KeysDeleteKeys" ); } if( $fromGraphEditor ) { clearKeyDoSelectionChanged($selectionConnection); scriptJob -protected -event "SelectionChanged" ("clearKeyDoSelectionChanged " + $selectionConnection + "; clearKeyWidgetsEnable " + $selectionConnection + ";") -parent $widgetList[2]; } // Call the setup "method" to fill in the current settings // eval (($setup + " " + $widgetList[2] + " " + $selectionConnection + " false")); showOptionBox(); showWindow $widgetList[0]; } proc string assembleCmd( string $selectionConnection, int $fromGraphEditor, string $options ) { // doClearKeyArgList takes a string array // $cmd = "doClearKeyArgList 3 { " + "\"" + `optionVar -q clearKeyWhichRange` + "\"" + ",\"" + `optionVar -q clearKeyRange` + "\"" + ",\"" + `optionVar -q clearKeyOption` + "\"" + ",\"" + `optionVar -q clearKeyHierarchy` + "\"" + ",\"" + `optionVar -q clearKeyControlPoints` + "\"" + ",\"" + `optionVar -q clearKeyShapes` + "\"" + ",\"" + `optionVar -q clearKeyUseChannelBox` + "\"" + ",\"" + `optionVar -q clearKeyAllAnimCurves` + "\"" + ",\"" + $selectionConnection + "\"" + ",\"0\"" + ",\"" + $options + "\"" + ",\"" + $fromGraphEditor + "\"" + ",\"" + `optionVar -q clearKeyDriven` + "\"" + " };"; return $cmd; } global proc string performClearKeyArgList (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, $unused, $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] $unused // [3] $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 $unused = $args[2]; int $fromGraphEditor = $args[3]; string $cmd = ""; switch( $action ) { case 0: setOptionVars( false ); $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, "noOptions"); eval( $cmd ); break; case 1: clearKeyOptions( $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: clearKeyOptions( $selectionConnection, 3, $fromGraphEditor ); break; case 5: setOptionVars( false ); $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, "bufferCurve"); break; } return ($cmd); }