// =========================================================================== // 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 makeBrushSpring 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) { // StartFrame. // if ($forceFactorySettings || !`optionVar -exists makeBrushSpringStartFrame`) { optionVar -intValue makeBrushSpringStartFrame 1; } // Stiffness. // if ($forceFactorySettings || !`optionVar -exists makeBrushSpringStiffness`) { optionVar -floatValue makeBrushSpringStiffness 0.3; } // Damp. // if ($forceFactorySettings || !`optionVar -exists makeBrushSpringDamp`) { optionVar -floatValue makeBrushSpringDamp .1; } // Travel. // if ($forceFactorySettings || !`optionVar -exists makeBrushSpringTravel`) { optionVar -floatValue makeBrushSpringTravel 1; } } // // Procedure Name: // makeBrushSpringSetup // // 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 makeBrushSpringSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // StartFrame. // intSliderGrp -edit -v `optionVar -query makeBrushSpringStartFrame` makeBrushSpringStartFrame; // Stiffness. // floatSliderGrp -edit -v `optionVar -query makeBrushSpringStiffness` makeBrushSpringStiffness; // Damp. // floatSliderGrp -edit -v `optionVar -query makeBrushSpringDamp` makeBrushSpringDamp; // Travel. // floatSliderGrp -edit -v `optionVar -query makeBrushSpringTravel` makeBrushSpringTravel; } // // Procedure Name: // makeBrushSpringCallback // // 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 makeBrushSpringCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // StartFrame. // optionVar -intValue makeBrushSpringStartFrame `intSliderGrp -query -v makeBrushSpringStartFrame`; // Stiffness. // optionVar -floatValue makeBrushSpringStiffness `floatSliderGrp -query -v makeBrushSpringStiffness`; // Damp. // optionVar -floatValue makeBrushSpringDamp `floatSliderGrp -query -v makeBrushSpringDamp`; // Travel. // optionVar -floatValue makeBrushSpringTravel `floatSliderGrp -query -v makeBrushSpringTravel`; if ($doIt) { performMakeBrushSpring 0; } } // // Procedure Name: // makeBrushSpringOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc makeBrushSpringOptions() { // Name of the command for this option box. // string $commandName = "makeBrushSpring"; // 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`; floatSliderGrp -label (uiRes("m_performMakeBrushSpring.kSpringStiffness")) -field 1 -min 0 -max 1 -fieldMaxValue 10 -pre 4 makeBrushSpringStiffness; floatSliderGrp -label (uiRes("m_performMakeBrushSpring.kSpringDamp")) -field 1 -min 0 -max 1 -fieldMaxValue 10 -pre 4 makeBrushSpringDamp; floatSliderGrp -label (uiRes("m_performMakeBrushSpring.kSpringTravel")) -field 1 -min 0 -max 100 -pre 3 makeBrushSpringTravel; intSliderGrp -label (uiRes("m_performMakeBrushSpring.kStartFrame")) -field 1 -min 0 -max 1000 -fieldMinValue -10000 -fieldMaxValue 10000 makeBrushSpringStartFrame; waitCursor -state 0; setUITemplate -popTemplate; // 'Create' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performMakeBrushSpring.kCreate")) -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_performMakeBrushSpring.kMakeBrushSpringOption")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "MakeBrushSpring" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } // // Procedure Name: // makeBrushSpringHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string makeBrushSpringHelp() { return " Command: makeBrushSpring - create spring expressions on Paint Effects strokes.\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 = "makeBrushSpring"; setOptionVars(false); $cmd = ($cmd + " " + `optionVar -query makeBrushSpringStiffness` + " " + `optionVar -query makeBrushSpringDamp` + " " + `optionVar -query makeBrushSpringTravel` + " " + `optionVar -query makeBrushSpringStartFrame` ); return $cmd; } // // Procedure Name: // performMakeBrushSpring // // Description: // Perform the makeBrushSpring 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 performMakeBrushSpring(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: $cmd = `assembleCmd`; eval($cmd); break; // Show the option box. // case 1: makeBrushSpringOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }