// =========================================================================== // 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: 20 Feb 2002 // // Description: // This is a helper script to set fluid // "{density,temperature,etc}Method" attributes to a // desired gradient type. // // 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 fluidGradientsDensityEnable`) { optionVar -intValue fluidGradientsDensityEnable 1; } if($forceFactorySettings || !`optionVar -exists fluidGradientsDensityType`) { optionVar -intValue fluidGradientsDensityType 3; } if($forceFactorySettings || !`optionVar -exists fluidGradientsVelocityEnable`) { optionVar -intValue fluidGradientsVelocityEnable 0; } if($forceFactorySettings || !`optionVar -exists fluidGradientsVelocityType`) { optionVar -intValue fluidGradientsVelocityType 1; } if($forceFactorySettings || !`optionVar -exists fluidGradientsTemperatureEnable`) { optionVar -intValue fluidGradientsTemperatureEnable 0; } if($forceFactorySettings || !`optionVar -exists fluidGradientsTemperatureType`) { optionVar -intValue fluidGradientsTemperatureType 1; } if($forceFactorySettings || !`optionVar -exists fluidGradientsFuelEnable`) { optionVar -intValue fluidGradientsFuelEnable 0; } if($forceFactorySettings || !`optionVar -exists fluidGradientsFuelType`) { optionVar -intValue fluidGradientsFuelType 1; } } global proc performFluidGradientsEnabling() { optionMenu -e -enable `checkBox -q -v fluidGradientsDensityEnable` fluidGradientsDensityType; optionMenu -e -enable `checkBox -q -v fluidGradientsVelocityEnable` fluidGradientsVelocityType; optionMenu -e -enable `checkBox -q -v fluidGradientsTemperatureEnable` fluidGradientsTemperatureType; optionMenu -e -enable `checkBox -q -v fluidGradientsFuelEnable` fluidGradientsFuelType; } // // Procedure Name: // performFluidGradientsSetup // // 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 performFluidGradientsSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // -startTime // checkBox -edit -value `optionVar -q fluidGradientsDensityEnable` fluidGradientsDensityEnable; optionMenu -edit -select `optionVar -q fluidGradientsDensityType` fluidGradientsDensityType; checkBox -edit -value `optionVar -q fluidGradientsVelocityEnable` fluidGradientsVelocityEnable; optionMenu -edit -select `optionVar -q fluidGradientsVelocityType` fluidGradientsVelocityType; checkBox -edit -value `optionVar -q fluidGradientsTemperatureEnable` fluidGradientsTemperatureEnable; optionMenu -edit -select `optionVar -q fluidGradientsTemperatureType` fluidGradientsTemperatureType; checkBox -edit -value `optionVar -q fluidGradientsFuelEnable` fluidGradientsFuelEnable; optionMenu -edit -select `optionVar -q fluidGradientsFuelType` fluidGradientsFuelType; performFluidGradientsEnabling(); } // // Procedure Name: // performFluidGradientsCallback // // 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 performFluidGradientsCallback(string $parent, int $doIt) { setParent $parent; optionVar -intValue fluidGradientsDensityEnable `checkBox -query -value fluidGradientsDensityEnable`; optionVar -intValue fluidGradientsDensityType `optionMenu -query -sl fluidGradientsDensityType`; optionVar -intValue fluidGradientsVelocityEnable `checkBox -query -value fluidGradientsVelocityEnable`; optionVar -intValue fluidGradientsVelocityType `optionMenu -query -sl fluidGradientsVelocityType`; optionVar -intValue fluidGradientsTemperatureEnable `checkBox -query -value fluidGradientsTemperatureEnable`; optionVar -intValue fluidGradientsTemperatureType `optionMenu -query -sl fluidGradientsTemperatureType`; optionVar -intValue fluidGradientsFuelEnable `checkBox -query -value fluidGradientsFuelEnable`; optionVar -intValue fluidGradientsFuelType `optionMenu -query -sl fluidGradientsFuelType`; if( $doIt ) { performFluidGradients 0; } } proc stuffGradientTypes() { menuItem -label (uiRes("m_performFluidGradients.kConstant")) ; menuItem -label (uiRes("m_performFluidGradients.kXGradient")) ; menuItem -label (uiRes("m_performFluidGradients.kYGradient")) ; menuItem -label (uiRes("m_performFluidGradients.kZGradient")) ; menuItem -label (uiRes("m_performFluidGradients.kXGradient2")) ; menuItem -label (uiRes("m_performFluidGradients.kYGradient2")) ; menuItem -label (uiRes("m_performFluidGradients.kZGradient2")) ; menuItem -label (uiRes("m_performFluidGradients.kCenterGradient")) ; } // // Procedure Name: // gradientsOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc gradientsOptions() { // Name of the command for this option box. // string $commandName = "performFluidGradients"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; tabLayout -tv false -scr true; string $parent = `rowColumnLayout -numberOfColumns 3 -columnWidth 1 170 -columnWidth 2 20 -columnWidth 3 150 gradientLayout`; text -label (uiRes("m_performFluidGradients.kDensity")) ; checkBox -label "" -cc performFluidGradientsEnabling fluidGradientsDensityEnable; optionMenu -label "" fluidGradientsDensityType; stuffGradientTypes(); text -label (uiRes("m_performFluidGradients.kVelocity")) ; checkBox -label "" -cc performFluidGradientsEnabling fluidGradientsVelocityEnable; optionMenu -label "" fluidGradientsVelocityType; stuffGradientTypes(); text -label (uiRes("m_performFluidGradients.kTemperature")) ; checkBox -label "" -cc performFluidGradientsEnabling fluidGradientsTemperatureEnable; optionMenu -label "" fluidGradientsTemperatureType; stuffGradientTypes(); text -label (uiRes("m_performFluidGradients.kFuel")) ; checkBox -label "" -cc performFluidGradientsEnabling fluidGradientsFuelEnable; optionMenu -label "" fluidGradientsFuelType; stuffGradientTypes(); // Somehow, specifying the alignments before the // controls were created didn't have any effect. // rowColumnLayout -e -cal 1 "right" -cal 3 "right" $parent; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performFluidGradients.kApplyAndClose")) -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; // Set the option box title. // setOptionBoxTitle (uiRes("m_performFluidGradients.kFluidGradientsOptions")); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "FluidGradients" ); // Pop the UI template // setUITemplate -popTemplate; // Set the current values of the option box. // eval( $setup + " " + $parent + " " + 0 ); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { setOptionVars(false); string $cmd = "doFluidGradients 1 { " + "\"" + `optionVar -query fluidGradientsDensityEnable` + "\", " + "\"" + `optionVar -query fluidGradientsDensityType` + "\", " + "\"" + `optionVar -query fluidGradientsVelocityEnable` + "\", " + "\"" + `optionVar -query fluidGradientsVelocityType` + "\", " + "\"" + `optionVar -query fluidGradientsTemperatureEnable` + "\", " + "\"" + `optionVar -query fluidGradientsTemperatureType` + "\", " + "\"" + `optionVar -query fluidGradientsFuelEnable` + "\", " + "\"" + `optionVar -query fluidGradientsFuelType` + "\" " + " };"; return $cmd; } // // Procedure Name: // performFluidGradients // // Description: // Perform the command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performFluidGradients(int $action) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = `assembleCmd`; eval($cmd); break; // Show the option box. // case 1: gradientsOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }