// =========================================================================== // 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: August 14, 1996 // // Description: // This script is for option box dialog for hardenPointCurve command. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // -rpo/-replaceOriginals boolean if ($forceFactorySettings || !`optionVar -exists hardenPointCurveNotInPlace`) { optionVar -intValue hardenPointCurveNotInPlace 0; } // -m/-multiplicity int if ($forceFactorySettings || !`optionVar -exists hardenPointCurveValue`) { optionVar -intValue hardenPointCurveValue -1; } } global proc hardenPointCurveSetup (string $parent, int $forceFactorySettings, string $goToTool) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); cvHardnessToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls int $localIntValue; $localIntValue = `optionVar -q hardenPointCurveNotInPlace`; checkBoxGrp -e -v1 $localIntValue notinplace; $localIntValue = `optionVar -q hardenPointCurveValue`; if( -1 == $localIntValue ) { radioButtonGrp -e -sl 1 value; } else { radioButtonGrp -e -sl 2 value; } if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc hardenPointCurveCallback( string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv cvHardnessEuc `scriptCtx -q -euc $goToTool`; optionVar -iv cvHardnessLac `scriptCtx -q -lac $goToTool`; } setParent $parent; optionVar -intValue hardenPointCurveNotInPlace `checkBoxGrp -q -v1 notinplace`; if( 1 == `radioButtonGrp -q -sl value` ) { optionVar -intValue hardenPointCurveValue -1; } else { optionVar -intValue hardenPointCurveValue 1; } if( 1 == $doIt ) { performhardenPointCurve( 0, $goToTool ); string $tmpCmd = "performhardenPointCurve( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "CV Hardness"; } else if( $doIt ) { setToolTo $goToTool; } } proc hardenPointCurveOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "hardenPointCurve"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolCvHardness"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "cvHardnessToolScript 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 2 -label (uiRes("m_performhardenPointCurve.kMultiplicity")) -label1 (uiRes("m_performhardenPointCurve.kFull")) -label2 (uiRes("m_performhardenPointCurve.kOff")) value; checkBoxGrp -ncb 1 -label1 (uiRes("m_performhardenPointCurve.kKeepOriginal")) notinplace; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performhardenPointCurve.kToolBehavior")) -label1 (uiRes("m_performhardenPointCurve.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performhardenPointCurve.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_performhardenPointCurve.kCVHardnessTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performhardenPointCurve.kHarden")) -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_performhardenPointCurve.kCVHardnessToolOptios")); } else { setOptionBoxTitle (uiRes("m_performhardenPointCurve.kCVHardnessOptions")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CVHardness" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // hardenPointCurveHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string hardenPointCurveHelp() { return " Command: CV hardness - increase or decrease CV multiplicity \n" + "Selection: curve or surface control point"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd = "performHardenPointCurvePreset"; setOptionVars(false); int $doHistory = `constructionHistory -q -tgl`; int $replaceOriginal = !`optionVar -q hardenPointCurveNotInPlace`; int $reverseSurfaceDirection = `optionVar -q hardenPointCurveValue`; $cmd = ( $cmd + " " + $doHistory + " " + $replaceOriginal + " " + $reverseSurfaceDirection ); return $cmd; } // // Procedure Name: // performhardenPointCurve // // Description: // Perform the harden cvs 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 harden cvs command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performhardenPointCurve( 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: hardenPointCurveOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }