// =========================================================================== // 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: October 1998 // // Description: // This script is defines the option box for the globalStitch menu item. // // Input Arguments: // int showOptionBox true - show the option box dialog // false - just execute the globalStitch operation // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { globalStitchSetOptionVars( $forceFactorySettings ); } global proc globalStitchSetup (string $parent, int $forceFactorySettings, string $goToTool) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); globalStitchToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls // int $keepOriginal = `optionVar -query globalStitchKeepOriginal`; if($keepOriginal == 1) { checkBoxGrp -edit -v1 $keepOriginal globalStitchKeepOriginalCheckBoxGroup; } else { checkBoxGrp -edit -v1 $keepOriginal globalStitchKeepOriginalCheckBoxGroup; } int $stitchCorners = `optionVar -query globalStitchCorners`+1; radioButtonGrp -edit -select $stitchCorners globalStitchCornersRadioButtonGrp; int $stitchEdges = `optionVar -query globalStitchEdges`+1; radioButtonGrp -edit -select $stitchEdges globalStitchEdgesRadioButtonGrp; int $smoothness = `optionVar -query globalStitchSmoothness`+1; radioButtonGrp -edit -select $smoothness globalStitchSmoothnessRadioButtonGrp; int $stitchInteriors = `optionVar -query globalStitchCheckInteriors`; if($stitchInteriors == 1) { checkBoxGrp -edit -v1 true globalStitchCheckInteriorsCheckBoxGroup; } else { checkBoxGrp -edit -v1 false globalStitchCheckInteriorsCheckBoxGroup; } float $maxSeparation = `optionVar -query globalStitchMaxSeparation`; floatSliderGrp -edit -v $maxSeparation globalStitchMaxSeparationFloatSliderGroup; float $modificationResistance = `optionVar -query globalStitchModificationResistance`; floatSliderGrp -edit -v $modificationResistance globalStitchModResFloatSliderGroup; int $sampling = `optionVar -query globalStitchSampling`; intSliderGrp -edit -value $sampling globalStitchSamplingIntSliderGroup; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc globalStitchCallback (string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv globalStitchEuc `scriptCtx -q -euc $goToTool`; optionVar -iv globalStitchLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the control values, and then perform // the command // optionVar -intValue globalStitchKeepOriginal `checkBoxGrp -query -value1 globalStitchKeepOriginalCheckBoxGroup`; int $corners = `radioButtonGrp -q -select globalStitchCornersRadioButtonGrp` -1; optionVar -intValue globalStitchCorners $corners; int $edges = `radioButtonGrp -q -select globalStitchEdgesRadioButtonGrp` -1; optionVar -intValue globalStitchEdges $edges; int $smoothness = `radioButtonGrp -q -select globalStitchSmoothnessRadioButtonGrp` -1; optionVar -intValue globalStitchSmoothness $smoothness; optionVar -intValue globalStitchCheckInteriors `checkBoxGrp -q -v1 globalStitchCheckInteriorsCheckBoxGroup`; optionVar -floatValue globalStitchMaxSeparation `floatSliderGrp -q -v globalStitchMaxSeparationFloatSliderGroup`; optionVar -floatValue globalStitchModificationResistance `floatSliderGrp -q -v globalStitchModResFloatSliderGroup`; optionVar -intValue globalStitchSampling `intSliderGrp -q -v globalStitchSamplingIntSliderGroup`; if( 1 == $doIt ) { performGlobalStitch( 0, $goToTool ); string $tmpCmd = "performGlobalStitch( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Global Stitch"; } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // createGlobalStitchUI // // Description: // Fill the contents of the option box for globalStitch command. // // Input Arguments: // The name of the parent layout. // // Return Value: // None. // proc createGlobalStitchUI( string $parent, int $inTheTool, string $goToTool ) { setParent $parent; string $off = (uiRes("m_performGlobalStitch.kOff")); string $closestPoint = (uiRes("m_performGlobalStitch.kClosestPoint")); radioButtonGrp -nrb 3 -select 2 -cw 2 55 -cw 3 110 -label (uiRes("m_performGlobalStitch.kStitchCorners")) -label1 $off -label2 $closestPoint -label3 (uiRes("m_performGlobalStitch.kClosestKnot")) globalStitchCornersRadioButtonGrp; radioButtonGrp -nrb 3 -select 2 -cw 2 55 -cw 3 110 -label (uiRes("m_performGlobalStitch.kStitchEdges")) -label1 $off -label2 $closestPoint -label3 (uiRes("m_performGlobalStitch.kMatchParams")) globalStitchEdgesRadioButtonGrp; radioButtonGrp -nrb 3 -select 2 -cw 2 55 -cw 3 110 -label (uiRes("m_performGlobalStitch.kStitchSmoothness")) -label1 $off -label2 (uiRes("m_performGlobalStitch.kTangents")) -label3 (uiRes("m_performGlobalStitch.kNormals")) globalStitchSmoothnessRadioButtonGrp; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performGlobalStitch.kStitchPartialEdges")) -v1 off globalStitchCheckInteriorsCheckBoxGroup; floatSliderGrp -label (uiRes("m_performGlobalStitch.kMaxSeparation")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 100.0 globalStitchMaxSeparationFloatSliderGroup; floatSliderGrp -label (uiRes("m_performGlobalStitch.kModificationResistance")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 10.0 globalStitchModResFloatSliderGroup; intSliderGrp -field on -min 1 -max 10 -fmn 1 -fmx 100 -label (uiRes("m_performGlobalStitch.kSamplingDensity")) globalStitchSamplingIntSliderGroup; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performGlobalStitch.kKeepOriginals")) -v1 off globalStitchKeepOriginalCheckBoxGroup; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performGlobalStitch.kToolBehavior")) -label1 (uiRes("m_performGlobalStitch.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performGlobalStitch.kAuto")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } } // // Procedure Name: // globalStitchOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc globalStitchOptions ( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "globalStitch"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolGlobalStitch"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "globalStitchToolScript 3"; // Step 1: Get the option box. // ============================ string $layout = getOptionBox(); setParent $layout; // Step 2: Pass the command name to the option box. // ================================================= // Any default option box behavior based on the command name is set // up with this call. // 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`; createGlobalStitchUI($parent, $inTheTool, $goToTool); // Turn off the wait cursor. // waitCursor -state 0; // Deactivate the default UI template. // setUITemplate -popTemplate; // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'GlobalStitch' button. // string $applyBtn = getOptionBoxApplyBtn(); if( $inTheTool ) { button -edit -label (uiRes("m_performGlobalStitch.kGlobalStitchTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performGlobalStitch.kGlobalStitch")) -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; // Set the option box title. // if( $inTheTool ) { setOptionBoxTitle (uiRes("m_performGlobalStitch.kStitchToolTitle")); } else { setOptionBoxTitle (uiRes("m_performGlobalStitch.kStitchTitle")); } // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "GlobalStitch" ); // Set the current values of the option box. // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Show the option box. // showOptionBox(); } // // Procedure Name: // globalStitchHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string globalStitchHelp() { return " Command: Global Stitch - stitch all selected surfaces together\n" + "Selection: NURBS surfaces"; } proc string assembleCmd() { string $cmd = "globalStitchPreset"; $cmd = $cmd + "(" ; // get the global history flag value int $doHistory = `constructionHistory -q -tgl`; $cmd = $cmd + $doHistory + ","; int $replaceOriginal = !`optionVar -q globalStitchKeepOriginal`; $cmd = $cmd + $replaceOriginal + ","; int $stitchCorners = `optionVar -query globalStitchCorners`; $cmd = $cmd +$stitchCorners + ","; int $stitchEdges = `optionVar -query globalStitchEdges`; $cmd = $cmd +$stitchEdges + ","; int $smoothness = `optionVar -query globalStitchSmoothness`; $cmd = $cmd +$smoothness + ","; int $stitchInteriors = `optionVar -query globalStitchCheckInteriors`; $cmd = $cmd +$stitchInteriors + ","; float $maxSeparation = `optionVar -query globalStitchMaxSeparation`; $cmd = $cmd +$maxSeparation + ","; float $modificationResistance = `optionVar -query globalStitchModificationResistance`; $cmd = $cmd +$modificationResistance + ","; int $sampling = `optionVar -query globalStitchSampling`; $cmd = $cmd +$sampling; $cmd = $cmd + ")"; return $cmd; } global proc string performGlobalStitch (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: globalStitchOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }