// =========================================================================== // 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 routines for the fluidOceanAddSurfaceLocator command // This code is used by several different option boxes that invoke this // mel script from the fluids pond menu. A type flag is used to determine // which option box is to be generated. // // This returns the name for this particular item on the fluids menu // This is used as a base name for option variables. proc string itemName( int $type ) { if( $type == 0 ){ return "pondLocator"; } else if( $type ==1 ){ return "pondDynamicLocator"; } else if( $type ==2 ){ return "dynamicBuoy"; } else if( $type ==3 ){ return "boatLocator"; } else if( $type ==4 ){ return "floatObjects"; } else if( $type ==5 ){ return "makeBoats"; } else if( $type ==6 ){ return "makeMotorBoats"; } } // This returns the create function label for this option box. // This is also used for the option box title. proc string actionName( int $type ) { if( $type == 0 ){ return (uiRes("m_performPondLocator.kCreatePondLocator")); } else if( $type ==1 ){ return (uiRes("m_performPondLocator.kCreateDynamicLocator")); } else if( $type ==2 ){ return (uiRes("m_performPondLocator.kCreateDynamicBuoy")); } else if( $type ==3 ){ return (uiRes("m_performPondLocator.kCreateBoatLocator")); } else if( $type ==4 ){ return (uiRes("m_performPondLocator.kFloatSelectedObjects")); } else if( $type ==5 ){ return (uiRes("m_performPondLocator.kMakeBoats")); } else if( $type ==6 ){ return (uiRes("m_performPondLocator.kMakeMotorBoats")); } } proc string helpTag( int $type ) { if( $type == 0 ){ return "PondLocator"; } else if( $type ==1 ){ return "CreateDynamicLocator"; } else if( $type ==2 ){ return "CreateDynamicBuoy"; } else if( $type ==3 ){ return "CreateBoatLocator"; } else if( $type ==4 ){ return "FloatSelectedObjects"; } else if( $type ==5 ){ return "MakeBoats"; } else if( $type ==6 ){ return "MakeMotorBoats"; } } // // 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, string $name) { string $varName = ($name +"FreeTransform"); if ($forceFactorySettings||!`optionVar -exists $varName`) { optionVar -intValue $varName 0; } } // // Procedure Name: // pondLocatorSetup // // 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 pondLocatorSetup(string $parent, int $forceFactorySettings, string $name ) { // Retrieve the option settings // setOptionVars($forceFactorySettings, $name); setParent $parent; // Query the optionVar's and set the values into the controls. string $varName = ($name +"FreeTransform"); checkBoxGrp -edit -value1 `optionVar -query $varName` $varName; } // // Procedure Name: // pondLocatorCallback // // 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 pondLocatorCallback(string $parent, int $doIt, int $type) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. string $name = itemName( $type ); string $varName = ($name+ "FreeTransform"); optionVar -intValue $varName `checkBoxGrp -query -value1 $varName`; if ($doIt) { performPondLocator 0 $type; } } // // Procedure Name: // pondLocatorOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc pondLocatorOptions( int $type ) { // Name of the command for this option box. // string $commandName = "fluidOceanAddSurfaceLocator"; // Build the option box actions. // string $callback = "pondLocatorCallback"; string $setup = "pondLocatorSetup"; string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; string $name = itemName( $type ); string $varName = ($name+ "FreeTransform"); checkBoxGrp -ncb 1 -label1 (uiRes("m_performPondLocator.kFreeTransform")) -annotation (uiRes("m_performPondLocator.kFreeTransformAnnot")) $varName; waitCursor -state 0; setUITemplate -popTemplate; // 'Create' button. // string $applyBtn = getOptionBoxApplyBtn(); string $createLabel = actionName( $type ); button -edit -label $createLabel -command ($callback + " " + $parent + " " + 1 + " " + $type) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " " + $type + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1 + " " + $name) $resetBtn; setOptionBoxTitle($createLabel); // Customize the 'Help' menu item text. Set the command name // *after* setting the box title, otherwise the help menu item // gets the wrong label. // setOptionBoxCommandName($commandName); setOptionBoxHelpTag( helpTag( $type ) ); eval (($setup + " " + $parent + " " + 0 + " " + $name)); showOptionBox(); } // // Procedure Name: // pondLocatorHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string pondLocatorHelp() { return " Command: fluidOceanAddSurfaceLocator Create a floating object.\n" + "Selection: None, or the current pond surface if there exists more than one pond shader"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd( int $type ) { string $cmd = "fluidOceanAddSurfaceLocator"; string $name = itemName( $type ); setOptionVars(false, $name); $cmd = ($cmd + " " + `optionVar -query ($name+"FreeTransform")` + " " + $type + " 1" ); return $cmd; } // // Procedure Name: // performPondLocator // // Description: // Perform the pondLocator 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 performPondLocator(int $action, int $type) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: $cmd = `assembleCmd $type`; eval($cmd); break; // Show the option box. // case 1: pondLocatorOptions $type; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd $type`; break; } return $cmd; }