// =========================================================================== // 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. // =========================================================================== // // Procedure name: // setOptionVars // // Description: // Sets the default optionVars related to the closestPointOn node. // // Input Arguments: // $forceFactorySettings - do we want to force the optionVars to be reset to // the default? // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists closestPointCreateInPosLoc`) { optionVar -intValue closestPointCreateInPosLoc 1; } if ($forceFactorySettings || !`optionVar -exists closestPointCreateObjPosLoc`) { optionVar -intValue closestPointCreateObjPosLoc 1; } } // // Procedure name: // closestPointOnSetup // // Description: // Update the UI to reflect the optionVars. // // Input Arguments: // $parent - Top level parent layout of the option box UI. // $forceFactorySettings - do we want to force the optionVars to be reset to // the default? // // Return Value: // None. // global proc closestPointOnSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $doSpaceLocator = `optionVar -query closestPointCreateInPosLoc`; int $doObjLocator = `optionVar -query closestPointCreateObjPosLoc`; checkBoxGrp -edit -value1 $doSpaceLocator cpoSpaceLocatorCheck; checkBoxGrp -edit -value1 $doObjLocator cpoObjLocatorCheck; } // // Procedure name: // closestPointOn // // Description: // Update the UI to reflect the optionVars. // // Input Arguments: // $parent - Top level parent layout of the option box UI. // $doIt - should the command be executed? // // Return Value: // None. // global proc closestPointOnCallback(string $parent, int $doIt) { optionVar -intValue closestPointCreateInPosLoc `checkBoxGrp -query -value1 cpoSpaceLocatorCheck`; optionVar -intValue closestPointCreateObjPosLoc `checkBoxGrp -query -value1 cpoObjLocatorCheck`; if ($doIt) { performClosestPointOn 0; addToRecentCommandQueue "performClosestPointOn 0" "ClosestPointOn"; } } // // Procedure name: // closestPointOnOptions // // Description: // Cerate the UI. // // Input Arguments: // None. // // Return Value: // None. // proc closestPointOnOptions() { string $commandName = "closestPointOn"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName($commandName); setUITemplate -pushTemplate DefaultTemplate; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; checkBoxGrp -label (uiRes("m_performClosestPointOn.kInputLocator")) cpoSpaceLocatorCheck; checkBoxGrp -label (uiRes("m_performClosestPointOn.kPositionLocator")) cpoObjLocatorCheck; setUITemplate -popTemplate; string $applyButton = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performClosestPointOn.kApplyButton")) -command ($callback + " " + $parent + " " + 1) $applyButton; string $saveButton = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveButton; string $resetButton = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetButton; setOptionBoxTitle (uiRes("m_performClosestPointOn.kClosestPointOnOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "ClosestPointOn" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } // // Procedure name: // assembleCmd // // Description: // Build the command to be executed. // // Input Arguments: // None. // // Return Value: // The command to be executed. // proc string assembleCmd() { string $cmd = "closestPointOn ("; $cmd += `optionVar -query closestPointCreateInPosLoc`; $cmd += ", "; $cmd += `optionVar -query closestPointCreateObjPosLoc`; $cmd += ")"; return $cmd; } // // Procedure name: // performClosestPointOn // // Description: // Perform and/or build the UI to create and hook up the // closestPointOn node. // // Input Arguments: // $action: the action to perform // 0 - Execute the command // 1 - Show the option box dialogue // 2 - Return the command // // Return Value: // The command. // global proc string performClosestPointOn(int $action) { string $cmd = ""; switch ($action) { case 0: setOptionVars(false); $cmd = `assembleCmd`; evalEcho($cmd); break; case 1: closestPointOnOptions; break; case 2: setOptionVars(false); $cmd = `assembleCmd`; break; } return $cmd; }