// =========================================================================== // 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: February 01, 2001 // // Description: // This is a script to perfrom the filterCurve command // with options for resampling. // // 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( { "resample", "unknown", "setOptionVars", $forceFactorySettings } ); // Resample kernel types // // 1: Closest Sample // 2: Linear Interpolation // 3: Box Filter // 4: Triangle Filter // 5: Gaussian 2 // 6: Gaussian 4 // if ($forceFactorySettings || !`optionVar -exists resampleKernel`) { optionVar -intValue resampleKernel 5; } // timeStep // if ($forceFactorySettings || !`optionVar -exists resampleTimeStep`) { optionVar -floatValue resampleTimeStep 1.0; } } global proc resampleSetup (string $parent, string $selectionConnection, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; keySetOptionBoxCommon( { "resample", $selectionConnection, "setup", 0 } ); // Set the correct menu for the resample kernel // int $kernel = `optionVar -query resampleKernel`; if ($kernel < 1 || $kernel > 6) { $kernel = 5; } optionMenuGrp -e -sl $kernel resampleKernelMenuGrp; // -timeStep // float $timeStep = `optionVar -query resampleTimeStep`; floatFieldGrp -edit -value1 $timeStep resampleTimeStep; resampleWidgetsEnable ($selectionConnection); } global proc resampleCallback( string $parent, int $doIt, string $selectionConnection, int $performAction ) { setParent $parent; keySetOptionBoxCommon( { "resample", $selectionConnection, "callback" } ); // Resample kernel // int $kernel = `optionMenuGrp -q -sl resampleKernelMenuGrp`; optionVar -intValue resampleKernel $kernel; // -timeStep // optionVar -floatValue resampleTimeStep `floatFieldGrp -query -value1 resampleTimeStep`; if( $doIt ) { performResample( $performAction, $selectionConnection); string $tmpCmd = "performResample "; $tmpCmd += "\"" + $performAction + "\", "; $tmpCmd += "\"" + $selectionConnection + "\""; addToRecentCommandQueue $tmpCmd "Resample"; } } global proc resampleWidgetsEnable(string $selectionConnection) { keySetOptionBoxCommon( { "resample", $selectionConnection, "enable" } ); } proc string resampleWidgets( string $tabLayout, string $selectionConnection ) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; keySetOptionBoxCommon( { "resample", $selectionConnection, "widgets", 1, 0, 1 } ); optionMenuGrp -label (uiRes("m_performResample.kResampleType")) resampleKernelMenuGrp; menuItem (uiRes("m_performResample.kClosestSample")); menuItem (uiRes("m_performResample.kLinearInterpolation")); menuItem (uiRes("m_performResample.kBoxFilter")); menuItem (uiRes("m_performResample.kTriangleFilter")); menuItem (uiRes("m_performResample.kGaussian2")); menuItem (uiRes("m_performResample.kGaussian4")); floatFieldGrp -label (uiRes("m_performResample.kTimeStep")) -precision 2 -value1 1.0 resampleTimeStep; return $tabForm; } global proc resampleDoSelectionChanged(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( { "resample", $selectionConnection, "selectionChanged" } ); resampleWidgetsEnable ($selectionConnection); } proc resampleOptions( string $selectionConnection, int $performAction ) { // Customisation options // // Name of the command for this option box (think of it as the base class) string $commandName = "resample"; // Title for the option box window string $optionBoxTitle = (uiRes("m_performResample.kResampleCurveOptions")); // Title for the apply button string $applyTitle = (uiRes("m_performResample.kResample")); // 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 // resampleWidgets $widgetList[2] $selectionConnection; // 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 \"\" " + $performAction + "; hideOptionBox()") $buttonList[3]; // Close // button -edit -command hideOptionBox $buttonList[2]; // Reset // button -edit -command ($setup + " " + $widgetList[0] + " " + $selectionConnection + " true") $buttonList[1]; // Do It // button -edit -command ($callback + " " + $widgetList[0] + " true \"" + $selectionConnection + "\"" + $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. // setOptionBoxHelpTag( "ResampleCurves" ); // Call the setup "method" to fill in the current settings // eval (($setup + " " + $widgetList[0] + " " + $selectionConnection + " false")); showOptionBox(); showWindow $widgetList[0]; resampleDoSelectionChanged($selectionConnection); scriptJob -protected -event "SelectionChanged" ("resampleDoSelectionChanged " + $selectionConnection) -parent $widgetList[2]; } proc string assembleCmd( string $selectionConnection, string $options ) { string $cmd = "doResampleArgList 1 { " + "\"" + `optionVar -q resampleWhichRange` + "\"" + ",\"" + `optionVar -q resampleRange` + "\"" + ",\"" + `optionVar -q resampleKernel` + "\"" + ",\"" + `optionVar -q resampleTimeStep` + "\"" + ",\"" + $selectionConnection + "\"" + ",\"" + $options + "\"" + " };"; return $cmd; } // The action variable means // 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) // global proc string performResample( int $action, string $selectionConnection ) { string $cmd = ""; switch( $action ) { case 0: setOptionVars( false ); $cmd = assembleCmd( $selectionConnection, "noOptions" ); eval( $cmd ); break; case 1: resampleOptions( $selectionConnection, 0 ); break; case 2: setOptionVars( false ); $cmd = assembleCmd( $selectionConnection, "noOptions" ); break; case 3: setOptionVars( false ); $cmd = assembleCmd( $selectionConnection, "bufferCurve" ); eval( $cmd ); break; case 4: resampleOptions( $selectionConnection, 3 ); break; case 5: setOptionVars( false ); $cmd = assembleCmd( $selectionConnection, "bufferCurve" ); break; } return ($cmd); }