// =========================================================================== // 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: March 1999 // // Description: // // Option box for the loopBrushAnim command // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { // CycleFrames. // if ($forceFactorySettings || !`optionVar -exists loopBrushAnimCycleFrames`) { optionVar -intValue loopBrushAnimCycleFrames 50; } // TurbSpeedMult. // if ($forceFactorySettings || !`optionVar -exists loopBrushAnimTurbSpeedMult`) { optionVar -intValue loopBrushAnimTurbSpeedMult 1; } // FlowSpeedMult. // if ($forceFactorySettings || !`optionVar -exists loopBrushAnimFlowSpeedMult`) { optionVar -intValue loopBrushAnimFlowSpeedMult 1; } } // // Procedure Name: // loopBrushAnimSetup // // 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 loopBrushAnimSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // CycleFrames. // intSliderGrp -edit -v `optionVar -query loopBrushAnimCycleFrames` loopBrushAnimCycleFrames; // TurbSpeedMult. // intSliderGrp -edit -v `optionVar -query loopBrushAnimTurbSpeedMult` loopBrushAnimTurbSpeedMult; // FlowSpeedMult. // intSliderGrp -edit -v `optionVar -query loopBrushAnimFlowSpeedMult` loopBrushAnimFlowSpeedMult; } // // Procedure Name: // loopBrushAnimCallback // // 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. // // Return Value: // None. // global proc loopBrushAnimCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // CycleFrames. // optionVar -intValue loopBrushAnimCycleFrames `intSliderGrp -query -v loopBrushAnimCycleFrames`; // TurbSpeedMult. // optionVar -intValue loopBrushAnimTurbSpeedMult `intSliderGrp -query -v loopBrushAnimTurbSpeedMult`; // FlowSpeedMult. // optionVar -intValue loopBrushAnimFlowSpeedMult `intSliderGrp -query -v loopBrushAnimFlowSpeedMult`; if ($doIt) { performLoopBrushAnim 0; } } // // Procedure Name: // loopBrushAnimOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc loopBrushAnimOptions() { // Name of the command for this option box. // string $commandName = "loopBrushAnim"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; intSliderGrp -label (uiRes("m_performLoopBrushAnim.kCycleFrames")) -field 1 -min 0 -max 1000 loopBrushAnimCycleFrames; intSliderGrp -label (uiRes("m_performLoopBrushAnim.kTurbulenceSpeedMult")) -field 1 -min 0 -max 10 loopBrushAnimTurbSpeedMult; intSliderGrp -label (uiRes("m_performLoopBrushAnim.kFlowSpeedMult")) -field 1 -min 0 -max 10 loopBrushAnimFlowSpeedMult; waitCursor -state 0; setUITemplate -popTemplate; // 'Create' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performLoopBrushAnim.kLoop")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; setOptionBoxTitle (uiRes("m_performLoopBrushAnim.kBrushAnimationLoopingOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "LoopBrushAnimation" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } // // Procedure Name: // loopBrushAnimHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string loopBrushAnimHelp() { return " Command: loopBrushAnim - seamlessly loop animation on brushstrokes.\n" + "Selection: strokes and brushes"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "loopBrushAnim"; setOptionVars(false); $cmd = ($cmd + " " + `optionVar -query loopBrushAnimCycleFrames` + " " + `optionVar -query loopBrushAnimTurbSpeedMult` + " " + `optionVar -query loopBrushAnimFlowSpeedMult` ); return $cmd; } // // Procedure Name: // performLoopBrushAnim // // Description: // Perform the loopBrushAnim command using the corresponding // option values. // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performLoopBrushAnim(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: $cmd = `assembleCmd`; eval($cmd); break; // Show the option box. // case 1: loopBrushAnimOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }