// =========================================================================== // 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 November 2002 // // Description: // This script is used to display and update the UVs alignment options. // // Input Arguments: // None. // // Return Value: // None. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists tvAlignUVsOption`) { optionVar -intValue tvAlignUVsOption 1; } } // // Procedure Name: // tvAlignUVsSetup // // 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 tvAlignUVsSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // Align Option. // int $optionValue = `optionVar -query tvAlignUVsOption`; switch($optionValue) { case 1: radioButtonGrp -edit -select 1 tvAlignUVsOption1; break; case 2: radioButtonGrp -edit -select 1 tvAlignUVsOption2; break; case 3: radioButtonGrp -edit -select 2 tvAlignUVsOption1; break; case 4: radioButtonGrp -edit -select 2 tvAlignUVsOption2; break; case 5: radioButtonGrp -edit -select 1 tvAlignUVsOption5; break; case 6: radioButtonGrp -edit -select 2 tvAlignUVsOption5; break; } } // // Procedure Name: // tvAlignUVsCallback // // 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 tvAlignUVsCallback(string $parent, int $doIt) { setParent $parent; // Perform the command. if ($doIt) { performTextureViewAlignUVsOptions 0; } } // // Procedure Name: // tvAlignUVsOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc tvAlignUVsOptions() { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; // Name of the command for this option box. // string $commandName = "tvAlignUVs"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Activate the option box template. // ========================================== // // Activate the option box template so that the layout of this // option box is consistent with the layout of the rest of the // application's option boxes. // setUITemplate -pushTemplate OptionBoxTemplate; // STEP 3: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; // Form layout string $parent = `formLayout polyQuadrangulateOptions`; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performTextureViewAlignUVsOptions.kSettingsFrame"))`; columnLayout; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewAlignUVs")) -label1 (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewMinUValue")) -label2 (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewMinVValue")) -select 1 -onCommand1 "optionVar -intValue tvAlignUVsOption 1" -onCommand2 "optionVar -intValue tvAlignUVsOption 3" tvAlignUVsOption1; radioButtonGrp -numberOfRadioButtons 2 -shareCollection tvAlignUVsOption1 -label "" -label1 (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewCenterUValue")) -label2 (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewCenterVValue")) -onCommand1 "optionVar -intValue tvAlignUVsOption 5" -onCommand2 "optionVar -intValue tvAlignUVsOption 6" tvAlignUVsOption5; radioButtonGrp -numberOfRadioButtons 2 -shareCollection tvAlignUVsOption1 -label "" -label1 (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewMaxUValue")) -label2 (uiRes("m_performTextureViewAlignUVsOptions.kPolyTViewMaxVValue")) -onCommand1 "optionVar -intValue tvAlignUVsOption 2" -onCommand2 "optionVar -intValue tvAlignUVsOption 4" tvAlignUVsOption2; setParent $parent; setParent ..; // Attach frame to form layout formLayout -e -af $settingsFrame "top" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "left" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "right" $gOptionBoxTemplateFrameSpacing -an $settingsFrame "bottom" $parent; // Turn off the wait cursor. // waitCursor -state 0; // Step 4: Deactivate the option box template. // =========================================== // setUITemplate -popTemplate; // Step 5: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // 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. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -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 6: Set the option box title. // ================================= // setOptionBoxTitle( (uiRes("m_performTextureViewAlignUVsOptions.kAlignUVsOptions")) ); // Step 7: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "AlignUV" ); // Step 8: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 9: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "alignUV "; string $cmdParams = ""; setOptionVars(false); if ( !`selectMode -q -co` ) return $cmd; int $shellSelection = `selectType -q -msh`; if ($shellSelection) $cmd = "texAlignShells "; else $cmd = "alignUV "; int $option = `optionVar -query tvAlignUVsOption`; switch ($option) { // Align selected UVs to minimum U value // case 1: $cmdParams = "minU"; break; // Align selected UVs to maximum U value // case 2: $cmdParams = "maxU"; break; // Align selected UVs to minimum V value // case 3: $cmdParams = "minV"; break; // Align selected UVs to maximum V value // case 4: $cmdParams = "maxV"; break; // Align selected UVs to average U value // case 5: $cmdParams = "avgU"; break; // Align selected UVs to average V value // case 6: $cmdParams = "avgV"; break; } $cmd = ($cmd + $cmdParams); if ($shellSelection) $cmd += " {} \"\""; return $cmd; } // // Procedure Name: // performTextureViewAlignUVsOptions // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performTextureViewAlignUVsOptions(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: tvAlignUVsOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }