// =========================================================================== // 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: 12 January, 1999 // // // Description: // Option box for subdivision surfaces attach geometry // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // // Note: // Commented out Type option for this rev // proc setOptionVars(int $forceFactorySettings) { // Have a special var for the history; we'll leave it // of for now, but this is a back door for setting // it back on. if ($forceFactorySettings || !`optionVar -exists subdivAttachHistory`) { optionVar -intValue subdivAttachHistory 0; } if ($forceFactorySettings || !`optionVar -exists subdSewEdgeMap`) optionVar -intValue subdSewEdgeMap 1; if ($forceFactorySettings || !`optionVar -exists subdSewEdge`) optionVar -floatValue subdSewEdge 0.0; if ($forceFactorySettings || !`optionVar -exists subdSewEdgeWorldSpace`) optionVar -intValue subdSewEdgeWorldSpace 1; if ($forceFactorySettings || !`optionVar -exists subdKeepOriginal`) optionVar -intValue subdKeepOriginal 1; } // // Procedure Name: // subdivAttachSetup // // 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 subdivAttachSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. int $iSM = `optionVar -query subdSewEdgeMap`; checkBoxGrp -edit -value1 $iSM subdSewEdgeMap; float $fval = `optionVar -query subdSewEdge`; floatSliderGrp -edit -value $fval subdSewEdge; int $keepOrig = `optionVar -query subdKeepOriginal`; checkBoxGrp -edit -value1 $keepOrig subdKeepOriginal; } // // Procedure Name: // subdivAttachCallback // // 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 subdivAttachCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. setParent $parent; optionVar -intValue subdSewEdgeMap `checkBoxGrp -query -value1 subdSewEdgeMap`; optionVar -floatValue subdSewEdge `floatSliderGrp -query -value subdSewEdge`; optionVar -intValue subdKeepOriginal `checkBoxGrp -query -value1 subdKeepOriginal`; if ($doIt) { performSubdivAttach 0; addToRecentCommandQueue "performSubdivAttach 0" "Subdiv Attach"; } } // // Procedure Name: // subdivAttachOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc subdivAttachOptions() { // Name of the command for this option box. // string $commandName = "subdivAttach"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // 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 -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; checkBoxGrp -label1 (uiRes("m_performSubdivAttach.kMergeUVsAlso")) subdSewEdgeMap; floatSliderGrp -label (uiRes("m_performSubdivAttach.kThreshold")) -min 0 -max 10 -fmx 10000000 subdSewEdge; checkBoxGrp -label1 (uiRes("m_performSubdivAttach.kKeepOriginals")) subdKeepOriginal; // 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(); button -edit -label (uiRes("m_performSubdivAttach.kAttach")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performSubdivAttach.kSubdivAttachOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "SubdivAttach" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // subdivAttachHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string subdivAttachHelp() { return (" Command: attach two subdivision surfaces" + "Selection: Two subdivision surfaces."); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { setOptionVars(false); float $fval = `optionVar -query subdSewEdge`; int $ivSM = `optionVar -query subdSewEdgeMap`; int $ivWS = `optionVar -query subdSewEdgeWorldSpace`; int $keepOrig = `optionVar -query subdKeepOriginal`; int $delOrig = !$keepOrig; // Use our local var instead: // int $doHistory = `constructionHistory -q -tgl`; int $doHistory = `optionVar -q subdivAttachHistory`; string $version = "\"1\""; string $cmd = "doSubdivAttachArgList"; $cmd = $cmd + "( "; $cmd = $cmd + $version; $cmd = $cmd + ", { \"" ; $cmd = $cmd + $doHistory; $cmd = $cmd + "\",\""; $cmd = $cmd + $fval; $cmd = $cmd + "\",\""; $cmd = $cmd + $ivSM; $cmd = $cmd + "\",\""; $cmd = $cmd + $ivWS; $cmd = $cmd + "\",\""; $cmd = $cmd + $delOrig; $cmd = $cmd + "\"} )"; return $cmd; } // // Procedure Name: // performSubdivAttach // // Description: // Perform the performSubdivAttach command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the performSubdivAttach command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performSubdivAttach(int $action) { string $cmd = ""; switch ($action) { case 0: setOptionVars( false ); $cmd = `assembleCmd`; eval($cmd); break; case 1: subdivAttachOptions; break; case 2: setOptionVars( false ); $cmd = `assembleCmd`; break; } return $cmd; }