// =========================================================================== // 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: Feb 2002 // // Description: // // Option box for the createOceanWake 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) { if ($forceFactorySettings || !`optionVar -exists createOceanWakeSize`) { optionVar -floatValue createOceanWakeSize 20.0; } if ($forceFactorySettings || !`optionVar -exists createOceanWakeIntensity`) { optionVar -floatValue createOceanWakeIntensity 5.0; } if ($forceFactorySettings || !`optionVar -exists createOceanWakeFoam`) { optionVar -floatValue createOceanWakeFoam 0.0; } } // // Procedure Name: // createOceanWakeSetup // // 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 createOceanWakeSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. floatSliderGrp -edit -v `optionVar -query createOceanWakeSize` createOceanWakeSize; floatSliderGrp -edit -v `optionVar -query createOceanWakeIntensity` createOceanWakeIntensity; floatSliderGrp -edit -v `optionVar -query createOceanWakeFoam` createOceanWakeFoam; } // // Procedure Name: // createOceanWakeCallback // // 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 createOceanWakeCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. optionVar -floatValue createOceanWakeSize `floatSliderGrp -query -v createOceanWakeSize`; optionVar -floatValue createOceanWakeIntensity `floatSliderGrp -query -v createOceanWakeIntensity`; optionVar -floatValue createOceanWakeFoam `floatSliderGrp -query -v createOceanWakeFoam`; if ($doIt) { performCreateOceanWake 0; } } // // Procedure Name: // createOceanWakeOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createOceanWakeOptions() { // Name of the command for this option box. // string $commandName = "createOceanWake"; // 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_performCreateOceanWake.kWakeSize")) -field 1 -min 0.0 -max 100.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -pre 2 createOceanWakeSize; floatSliderGrp -label (uiRes("m_performCreateOceanWake.kWakeIntensity")) -cw 4 150 -field 1 -min 0.0 -max 10.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -extraLabel (uiRes("m_performCreateOceanWake.kDensityVoxelSec")) -pre 2 createOceanWakeIntensity; floatSliderGrp -label (uiRes("m_performCreateOceanWake.kFoamCreation")) -cw 4 150 -field 1 -min 0.0 -max 10.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -pre 2 -extraLabel (uiRes("m_performCreateOceanWake.kHeatVoxelSec")) createOceanWakeFoam; waitCursor -state 0; setUITemplate -popTemplate; // 'Create' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateOceanWake.kCreateOceanWake")) -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_performCreateOceanWake.kCreateOceanWakeTitle")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CreateOceanWake" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } // // Procedure Name: // createOceanWakeHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string createOceanWakeHelp() { return " Command: createOceanWake - Make selected objects generate wakes on the ocean.\n" + "Selection: objects to emit wakes"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "createOceanWake"; setOptionVars(false); $cmd = ($cmd + " " + `optionVar -query createOceanWakeSize` + " " + `optionVar -query createOceanWakeIntensity` + " " + `optionVar -query createOceanWakeFoam` ); return $cmd; } // // Procedure Name: // performCreateOceanWake // // Description: // Perform the createOceanWake 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 performCreateOceanWake(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: $cmd = `assembleCmd`; eval($cmd); break; // Show the option box. // case 1: createOceanWakeOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }