// =========================================================================== // 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 menu item. // This menu item only works for nurbs curves, surfaces and curves- // on-surface. // // 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 closeKeepOriginal`) { optionVar -intValue closeKeepOriginal 0; } if ($forceFactorySettings || !`optionVar -exists closePreserveShape`) { optionVar -intValue closePreserveShape 1; } // blend bias // if ($forceFactorySettings || !`optionVar -exists closeCurveBlendBias`) { optionVar -floatValue closeCurveBlendBias 0.5; } // insert knots for blend // if ($forceFactorySettings || !`optionVar -exists closeCurveBlendInsert`) { optionVar -intValue closeCurveBlendInsert 0; } // blend insert // if ($forceFactorySettings || !`optionVar -exists closeCurveBlendParameter`){ optionVar -floatValue closeCurveBlendParameter 0.1; } } global proc closeCurveVisibility( string $parent, int $method, int $insert ) { if( $method < 0 ) { $method = `radioButtonGrp -q -sl closePreserveShapeWidget` - 1; } if( $insert < 0 ) { $insert = `checkBoxGrp -q -v1 closeCurveBlendInsertWidget`; } switch( $method ) { case 0: case 1: default: floatSliderGrp -e -en false closeCurveBlendBiasWidget; checkBoxGrp -e -en1 false closeCurveBlendInsertWidget; floatSliderGrp -e -en false closeCurveBlendParameterWidget; break; case 2: floatSliderGrp -e -en true closeCurveBlendBiasWidget; checkBoxGrp -e -en1 true closeCurveBlendInsertWidget; floatSliderGrp -e -en $insert closeCurveBlendParameterWidget; break; } } global proc closeCurveSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); closeCurveToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls // int $keepOriginal = `optionVar -q closeKeepOriginal`; int $preserveShape = `optionVar -q closePreserveShape`; float $blend = `optionVar -q closeCurveBlendBias`; int $insert = `optionVar -q closeCurveBlendInsert`; float $parameter = `optionVar -q closeCurveBlendParameter`; // Set the controls // radioButtonGrp -e -sl ($preserveShape+1) closePreserveShapeWidget; floatSliderGrp -e -v $blend closeCurveBlendBiasWidget; checkBoxGrp -e -v1 $insert closeCurveBlendInsertWidget; floatSliderGrp -e -v $parameter closeCurveBlendParameterWidget; checkBoxGrp -e -v1 $keepOriginal closeCurveKeepOriginalBox; closeCurveVisibility $parent -1 -1; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc closeCurveCallback (string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv closeCurveEuc `scriptCtx -q -euc $goToTool`; optionVar -iv closeCurveLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the control values, and then perform // the command // int $keep = `checkBoxGrp -q -v1 closeCurveKeepOriginalBox`; optionVar -intValue closeKeepOriginal $keep; int $preserveShape = `radioButtonGrp -q -sl closePreserveShapeWidget` - 1; optionVar -intValue closePreserveShape $preserveShape; float $bias = `floatSliderGrp -q -v closeCurveBlendBiasWidget`; optionVar -floatValue closeCurveBlendBias $bias; int $insert = `checkBoxGrp -q -v1 closeCurveBlendInsertWidget`; optionVar -intValue closeCurveBlendInsert $insert; float $parameter = `floatSliderGrp -q -v closeCurveBlendParameterWidget`; optionVar -floatValue closeCurveBlendParameter $parameter; if (1 == $doIt) { performCloseCurve( 0, $goToTool ); string $tmpCmd = "performCloseCurve( 0, \"" + $goToTool +"\")"; addToRecentCommandQueue $tmpCmd "Open/Close Curves"; } else if( $doIt ) { setToolTo $goToTool; } } proc closeCurveOptions ( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "closeCurve"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolCloseCurve"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "closeCurveToolScript 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 -label (uiRes("m_performCloseCurve.kShape")) -nrb 3 -label1 (uiRes("m_performCloseCurve.kIgnore")) -label2 (uiRes("m_performCloseCurve.kPreserve")) -label3 (uiRes("m_performCloseCurve.kBlend")) -on1 ("closeCurveVisibility " + $parent + " 0 -1" ) -on2 ("closeCurveVisibility " + $parent + " 1 -1" ) -on3 ("closeCurveVisibility " + $parent + " 2 -1" ) closePreserveShapeWidget; floatSliderGrp -label (uiRes("m_performCloseCurve.kBlendBias")) -min 0.0 -max 1.0 closeCurveBlendBiasWidget; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCloseCurve.kInsertKnot")) -on1 ("closeCurveVisibility " + $parent + " -1 1" ) -of1 ("closeCurveVisibility " + $parent + " -1 0" ) closeCurveBlendInsertWidget; floatSliderGrp -label (uiRes("m_performCloseCurve.kInsertParameter")) -min -1.0 -max 1.0 closeCurveBlendParameterWidget; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCloseCurve.kKeepOriginal")) closeCurveKeepOriginalBox; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performCloseCurve.kToolBehavior")) -label1 (uiRes("m_performCloseCurve.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performCloseCurve.kAutoCompletion")) -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_performCloseCurve.kOpenCloseTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performCloseCurve.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_performCloseCurve.kOpenCloseToolOptions")); } else { setOptionBoxTitle (uiRes("m_performCloseCurve.kOpenCloseOptions")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "OpenCloseCurves" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // closeHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string closeCurveHelp() { return " Command: Close Curve - close/open curve\n" + "Selection: curve or curve on surface"; } proc string assembleCmd() { string $cmd; setOptionVars( false ); int $doHistory = `constructionHistory -q -tgl`; int $preserveShape = `optionVar -q closePreserveShape`; int $replaceOriginal = !`optionVar -q closeKeepOriginal`; float $bias = `optionVar -q closeCurveBlendBias`; int $insert = `optionVar -q closeCurveBlendInsert`; float $parameter = `optionVar -q closeCurveBlendParameter`; $cmd = "doCloseCurveArgList 2 { "; $cmd = $cmd + "\"" + $doHistory + "\", "; $cmd = $cmd + "\"" + $preserveShape + "\", "; $cmd = $cmd + "\"" + $replaceOriginal + "\", "; $cmd = $cmd + "\"" + $bias + "\", "; $cmd = $cmd + "\"" + $insert + "\", "; $cmd = $cmd + "\"" + $parameter + "\" }"; return $cmd; } global proc string performCloseCurve( int $action, string $goToTool ) { 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: closeCurveOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }