// =========================================================================== // 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. // =========================================================================== // // Description: // This is a helper script to perform the stacked curves command // using the various options that have been set. // proc setOptionVars (int $forceFactorySettings) { // min // if ($forceFactorySettings || !`optionVar -exists stackedCurvesMin`) { optionVar -floatValue stackedCurvesMin -1.0; } // max // if ($forceFactorySettings || !`optionVar -exists stackedCurvesMax`) { optionVar -floatValue stackedCurvesMax 1.0; } // space // if ($forceFactorySettings || !`optionVar -exists stackedCurvesSpace`) { optionVar -floatValue stackedCurvesSpace 0.2; } // enable normalized // if ($forceFactorySettings || !`optionVar -exists stackedCurvesEnableNormalized`) { optionVar -intValue stackedCurvesEnableNormalized 1; } // disable normalized // if ($forceFactorySettings || !`optionVar -exists stackedCurvesDisableNormalized`) { optionVar -intValue stackedCurvesDisableNormalized 1; } } global proc stackedCurvesSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // min // float $stackedMin = `optionVar -query stackedCurvesMin`; floatFieldGrp -edit -value1 $stackedMin stackedMin; // max // float $stackedMax = `optionVar -query stackedCurvesMax`; floatFieldGrp -edit -value1 $stackedMax stackedMax; // space // float $stackedSpace = `optionVar -query stackedCurvesSpace`; floatFieldGrp -edit -value1 $stackedSpace stackedSpace; // enable normalized // int $enableNormalized = `optionVar -query stackedCurvesEnableNormalized`; checkBoxGrp -edit -value1 $enableNormalized enableNormalized; // disable normalized // int $disableNormalized = `optionVar -query stackedCurvesDisableNormalized`; checkBoxGrp -edit -value1 $disableNormalized disableNormalized; } global proc stackedCurvesCallback( string $parent, int $doIt, string $graphEd ) { setParent $parent; // min // optionVar -floatValue stackedCurvesMin `floatFieldGrp -query -value1 stackedMin`; // max // optionVar -floatValue stackedCurvesMax `floatFieldGrp -query -value1 stackedMax`; // space // optionVar -floatValue stackedCurvesSpace `floatFieldGrp -query -value1 stackedSpace`; // enable normalized // optionVar -intValue stackedCurvesEnableNormalized `checkBoxGrp -query -value1 enableNormalized`; // disable normalized // optionVar -intValue stackedCurvesDisableNormalized `checkBoxGrp -query -value1 disableNormalized`; if( $doIt ) { performStackedCurves ( 0, $graphEd ); string $tmpCmd = "performStackedCurves 0 \"" + $graphEd + "\""; addToRecentCommandQueue $tmpCmd "Stacked Curves"; } } proc string stackedCurvesWidgets( string $tabLayout ) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; frameLayout -label (uiRes("m_performStackedCurves.kLayout")) -labelVisible true -borderVisible false -collapsable false -marginWidth 10 -marginHeight 5 layoutFrame; columnLayout -adjustableColumn true; floatFieldGrp -label (uiRes("m_performStackedCurves.kMinValue")) -value1 -1.0 stackedMin; floatFieldGrp -label (uiRes("m_performStackedCurves.kMaxValue")) -value1 1.0 stackedMax; floatFieldGrp -label (uiRes("m_performStackedCurves.kSpacing")) -value1 0.1 stackedSpace; setParent ..; setParent ..; frameLayout -label (uiRes("m_performStackedCurves.kNormalization")) -labelVisible true -borderVisible false -collapsable false -marginWidth 10 -marginHeight 5 normalizationFrame; columnLayout -adjustableColumn true; checkBoxGrp -label1 (uiRes("m_performStackedCurves.kEnableNormalized")) -cw2 300 100 -value1 off enableNormalized; checkBoxGrp -label1 (uiRes("m_performStackedCurves.kDisableNormalized")) -cw2 300 100 -value1 off disableNormalized; setParent ..; setParent ..; return $tabForm; } proc stackedCurvesOptions( string $graphEd ) { // Customisation options // // Name of the command for this option box (think of it as the base class) string $commandName = "stackedCurves"; // Title for the option box window string $optionBoxTitle = (uiRes("m_performStackedCurves.kShowStackedCurvesOptions")); // Title for the apply button string $applyTitle = (uiRes("m_performStackedCurves.kStackedCurves")); // 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 // stackedCurvesWidgets $widgetList[2]; // 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 " + $graphEd + "; hideOptionBox()") $buttonList[3]; // Close // button -edit -command hideOptionBox $buttonList[2]; // Reset // button -edit -command ($setup + " " + $widgetList[0] + " true") $buttonList[1]; // Do It // button -edit -command ($callback + " " + $widgetList[0] + " true " + $graphEd) $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( "GraphStackedCurves" ); // Call the setup "method" to fill in the current settings // eval (($setup + " " + $widgetList[0] + " false")); showOptionBox(); showWindow $widgetList[0]; } proc string assembleCmd( string $graphEd ) { // Retrieve the option settings // setOptionVars (false); string $cmd = "doStackedCurvesArgList 1 { " + "\"" + `optionVar -query stackedCurvesMin` + "\"" + ",\"" + `optionVar -query stackedCurvesMax` + "\"" + ",\"" + `optionVar -query stackedCurvesSpace` + "\"" + ",\"" + $graphEd + "\"" + " };"; return $cmd; } // The action variable means // 0 - do the command // 1 - show the option box // 2 - return the drag command global proc string performStackedCurves (int $action, string $graphEd) { string $cmd = ""; switch( $action ) { case 0: setOptionVars( false ); optionVar -intValue graphEditorStackedCurves 1; $cmd = `assembleCmd( $graphEd )`; eval( $cmd ); if ( `optionVar -q stackedCurvesEnableNormalized` ) { animCurveEditor -edit -displayNormalized 1 $graphEd; optionVar -intValue graphEditorDisplayNormalized 1; } break; case 1: stackedCurvesOptions( $graphEd ); break; case 2: setOptionVars( false ); $cmd = `assembleCmd( $graphEd )`; break; } return $cmd; }