// =========================================================================== // 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 reverse Surface // menu item. // // Input Arguments: // int showOptionBox true - show the option box dialog // false - just execute the reverse operation // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { reverseSetOptionVars( $forceFactorySettings ); } global proc reverseSurfaceSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); reverseSurfaceToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls // int $keepOriginal = `optionVar -query reverseKeepOriginal`; int $reverseSurfaceDirection = `optionVar -query reverseSurfaceDirection`; int $direction; switch( $reverseSurfaceDirection ) { case 0: $direction = 1; break; case 1: $direction = 2; break; case 2: $direction = 4; break; case 3: $direction = 3; break; } // Set the controls // checkBoxGrp -edit -value1 $keepOriginal keepOriginalCheckBox; radioButtonGrp -edit -select $direction directionRadioGroup; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc reverseSurfaceCallback(string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv reverseSurfaceEuc `scriptCtx -q -euc $goToTool`; optionVar -iv reverseSurfaceLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the control values, and then perform // the command // int $keep = `checkBoxGrp -query -value1 keepOriginalCheckBox`; optionVar -intValue reverseKeepOriginal $keep; int $dir = `radioButtonGrp -query -select directionRadioGroup`; int $realDirection; switch( $dir ) { case 1: $realDirection = 0; break; // U case 2: $realDirection = 1; break; // V case 3: $realDirection = 3; break; // Swap case 4: $realDirection = 2; break; // Both } optionVar -intValue reverseSurfaceDirection $realDirection; if( 1 == $doIt ) { performSurfaceReverse( 0, $goToTool ); string $tmpCmd = "performSurfaceReverse( 0, \"" + $goToTool +"\")"; addToRecentCommandQueue $tmpCmd "Reverse Surface Direction"; } else if( $doIt ) { setToolTo $goToTool; } } proc reverseSurfaceOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "reverseSurface"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolReverseSurface"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "reverseSurfaceToolScript 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 -numberOfRadioButtons 4 -label (uiRes("m_performSurfaceReverse.kSurfaceDirection")) -label1 (uiRes("m_performSurfaceReverse.kUAxis")) -label2 (uiRes("m_performSurfaceReverse.kVAxis")) -label3 (uiRes("m_performSurfaceReverse.kSwap")) -label4 (uiRes("m_performSurfaceReverse.kBoth")) directionRadioGroup; checkBoxGrp -ncb 1 -label1 (uiRes("m_performSurfaceReverse.kKeepOriginal")) keepOriginalCheckBox; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performSurfaceReverse.kToolBehavior")) -label1 (uiRes("m_performSurfaceReverse.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performSurfaceReverse.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_performSurfaceReverse.kReverseTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performSurfaceReverse.kReverse")) -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_performSurfaceReverse.kSurfaceDirectionTool")); } else { setOptionBoxTitle (uiRes("m_performSurfaceReverse.kSurfaceDirectionTitle")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "ReverseSurfaceDirection" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // reverseSurfaceHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string reverseSurfaceHelp() { return " Command: Reverse Surface - perform surface reverse\n" + "Selection: surface or surface isoparm"; } // // 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 = "reversePreset"; setOptionVars(false); int $doHistory = `constructionHistory -q -tgl`; int $replaceOriginal = !`optionVar -q reverseKeepOriginal`; int $reverseSurfaceDirection = `optionVar -q reverseSurfaceDirection`; $cmd = ( $cmd + " " + $doHistory + " " + $replaceOriginal + " " + $reverseSurfaceDirection ); return $cmd; } // // Procedure Name: // performSurfaceReverse // // Description: // Perform the reverse 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 reverse 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 performSurfaceReverse ( 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: reverseSurfaceOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }