// =========================================================================== // 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: Mar 14, 1997 // // Description: // This script is defines the option box for the close surface menu item. // // Input Arguments: // int showOptionBox true - show the option box dialog // false - just execute the close operation // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists closeSurfaceKeepOriginal`) { optionVar -intValue closeSurfaceKeepOriginal 0; } if ($forceFactorySettings || !`optionVar -exists closeSurfacePreserveShape`) { optionVar -intValue closeSurfacePreserveShape 1; } if ($forceFactorySettings || !`optionVar -exists closeSurfaceDirection`) { optionVar -intValue closeSurfaceDirection 1; } // blend bias // if ($forceFactorySettings || !`optionVar -exists closeSurfaceBlendBias`) { optionVar -floatValue closeSurfaceBlendBias 0.5; } // insert knots for blend // if ($forceFactorySettings || !`optionVar -exists closeSurfaceBlendInsert`) { optionVar -intValue closeSurfaceBlendInsert 0; } // blend insert // if ($forceFactorySettings || !`optionVar -exists closeSurfaceBlendParameter`){ optionVar -floatValue closeSurfaceBlendParameter 0.1; } } global proc closeSurfaceVisibility( string $parent, int $method, int $insert ) { if( $method < 0 ) { $method = `radioButtonGrp -q -sl closeSurfacePreserveShapeWidget` - 1; } if( $insert < 0 ) { $insert = `checkBoxGrp -q -v1 closeSurfaceBlendInsertWidget`; } switch( $method ) { case 0: case 1: default: floatSliderGrp -e -en false closeSurfaceBlendBiasWidget; checkBoxGrp -e -en1 false closeSurfaceBlendInsertWidget; floatSliderGrp -e -en false closeSurfaceBlendParameterWidget; break; case 2: floatSliderGrp -e -en true closeSurfaceBlendBiasWidget; checkBoxGrp -e -en1 true closeSurfaceBlendInsertWidget; floatSliderGrp -e -en $insert closeSurfaceBlendParameterWidget; break; } } global proc closeSurfaceSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); closeSurfaceToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls // int $keepOriginal = `optionVar -q closeSurfaceKeepOriginal`; int $preserveShape = `optionVar -q closeSurfacePreserveShape`; int $closeSurfaceDirection = `optionVar -q closeSurfaceDirection`; float $blend = `optionVar -q closeSurfaceBlendBias`; int $insert = `optionVar -q closeSurfaceBlendInsert`; float $parameter = `optionVar -q closeSurfaceBlendParameter`; // Set the controls // radioButtonGrp -e -sl ($preserveShape+1) closeSurfacePreserveShapeWidget; floatSliderGrp -e -v $blend closeSurfaceBlendBiasWidget; checkBoxGrp -e -v1 $insert closeSurfaceBlendInsertWidget; floatSliderGrp -e -v $parameter closeSurfaceBlendParameterWidget; checkBoxGrp -e -v1 $keepOriginal closeSurfaceKeepOriginalBox; radioButtonGrp -edit -select ($closeSurfaceDirection+1) directionRadioGroup; closeSurfaceVisibility $parent -1 -1; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc closeSurfaceCallback (string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv alignEuc `scriptCtx -q -euc $goToTool`; optionVar -iv alignLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the control values, and then perform // the command // int $keep = `checkBoxGrp -q -v1 closeSurfaceKeepOriginalBox`; optionVar -intValue closeSurfaceKeepOriginal $keep; int $preserveShape = `radioButtonGrp -q -sl closeSurfacePreserveShapeWidget` - 1; optionVar -intValue closeSurfacePreserveShape $preserveShape; float $bias = `floatSliderGrp -q -v closeSurfaceBlendBiasWidget`; optionVar -floatValue closeSurfaceBlendBias $bias; int $insert = `checkBoxGrp -q -v1 closeSurfaceBlendInsertWidget`; optionVar -intValue closeSurfaceBlendInsert $insert; float $parameter = `floatSliderGrp -q -v closeSurfaceBlendParameterWidget`; optionVar -floatValue closeSurfaceBlendParameter $parameter; int $dir = `radioButtonGrp -q -select directionRadioGroup` - 1; optionVar -intValue closeSurfaceDirection $dir; if (1 == $doIt) { performSurfaceClose( 0, $goToTool ); string $tmpCmd = "performSurfaceClose(0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Open/Close Surfaces"; } else if( $doIt ) { setToolTo $goToTool; } } proc closeSurfaceOptions ( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "closeSurface"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolCloseSurface"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "closeSurfaceToolScript 3"; // Step 1: Get the option box. // ============================ string $layout = getOptionBox(); setParent $layout; // Step 2: Pass the command name to the option box. // ================================================= setOptionBoxCommandName($commandName); // Step 3: Activate the default UI template. // ========================================== setUITemplate -pushTemplate DefaultTemplate; // Step 4: Create option box contents. // =================================== // Turn on the wait cursor. // waitCursor -state 1; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; radioButtonGrp -nrb 3 -label (uiRes("m_performSurfaceClose.kSurfaceDirection")) -label1 (uiRes("m_performSurfaceClose.kUAxis")) -label2 (uiRes("m_performSurfaceClose.kVAxis")) -label3 (uiRes("m_performSurfaceClose.kBoth")) directionRadioGroup; radioButtonGrp -label (uiRes("m_performSurfaceClose.kShape")) -nrb 3 -label1 (uiRes("m_performSurfaceClose.kIgnore")) -label2 (uiRes("m_performSurfaceClose.kPreserve")) -label3 (uiRes("m_performSurfaceClose.kBlend")) -on1 ("closeSurfaceVisibility " + $parent + " 0 -1" ) -on2 ("closeSurfaceVisibility " + $parent + " 1 -1" ) -on3 ("closeSurfaceVisibility " + $parent + " 2 -1" ) closeSurfacePreserveShapeWidget; floatSliderGrp -label (uiRes("m_performSurfaceClose.kBlendBias")) -min 0.0 -max 1.0 closeSurfaceBlendBiasWidget; checkBoxGrp -ncb 1 -label1 (uiRes("m_performSurfaceClose.kInsertKnot")) -on1 ("closeSurfaceVisibility " + $parent + " -1 1" ) -of1 ("closeSurfaceVisibility " + $parent + " -1 0" ) closeSurfaceBlendInsertWidget; floatSliderGrp -label (uiRes("m_performSurfaceClose.kInsertParameter")) -min -1.0 -max 1.0 closeSurfaceBlendParameterWidget; checkBoxGrp -ncb 1 -label1 (uiRes("m_performSurfaceClose.kKeepOriginal")) closeSurfaceKeepOriginalBox; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performSurfaceClose.kToolBehavior")) -label1 (uiRes("m_performSurfaceClose.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performSurfaceClose.kAuto")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); if( $inTheTool ) { button -edit -label (uiRes("m_performSurfaceClose.kOpenCloseTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performSurfaceClose.kOpenClose")) -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"") $applyBtn; } // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " 0 \"" + $goToTool + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"") $resetBtn; // Step 7: Set the option box title. // ================================= // if( $inTheTool ) { setOptionBoxTitle (uiRes("m_performSurfaceClose.kSurfaceToolTitle")); } else { setOptionBoxTitle (uiRes("m_performSurfaceClose.kSurfaceTitle")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "OpenCloseSurfaces" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // closeSurfaceHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string closeSurfaceHelp() { return " Command: Close Surface - close/open surface\n" + "Selection: surface or surface isoparm (implied direction)"; } proc string assembleCmd() { string $cmd; setOptionVars( false ); int $doHistory = `constructionHistory -q -tgl`; int $preserveShape = `optionVar -q closeSurfacePreserveShape`; int $replaceOriginal = !`optionVar -q closeSurfaceKeepOriginal`; float $bias = `optionVar -q closeSurfaceBlendBias`; int $insert = `optionVar -q closeSurfaceBlendInsert`; float $parameter = `optionVar -q closeSurfaceBlendParameter`; int $closeSurfaceDirection = `optionVar -q closeSurfaceDirection`; $cmd = "doCloseSurfaceArgList 2 { "; $cmd = $cmd + "\"" + $doHistory + "\", "; $cmd = $cmd + "\"" + $preserveShape + "\", "; $cmd = $cmd + "\"" + $replaceOriginal + "\", "; $cmd = $cmd + "\"" + $closeSurfaceDirection + "\", "; $cmd = $cmd + "\"" + $bias + "\", "; $cmd = $cmd + "\"" + $insert + "\", "; $cmd = $cmd + "\"" + $parameter + "\" }"; return $cmd; } global proc string performSurfaceClose (int $action, string $goToTool ) // The action variable means // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // 3 - Show the tool option box dialog. { int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } string $cmd = ""; switch ($action) { case 0: setOptionVars (false); $cmd = `assembleCmd`; eval($cmd); break; case 1: closeSurfaceOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }