// =========================================================================== // 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: Oct 09, 2016 // // Description: // This script is use to display and update the UV wireframe options. // // Input Arguments: // None. // // Return Value: // None. // // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd; string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`; float $objectColor[] = `colorSliderGrp -query -rgb uvWireframeObjectColor`; float $objectAlpha = `floatSliderGrp -query -value uvWireframeObjectAlpha`; float $componentColor[] = `colorSliderGrp -query -rgb uvWireframeComponentColor`; float $componentAlpha = `floatSliderGrp -query -value uvWireframeComponentAlpha`; $cmd = "textureWindow -edit"; $cmd += " -wireframeObjectColor"; $cmd += " " + $objectColor[0]; $cmd += " " + $objectColor[1]; $cmd += " " + $objectColor[2]; $cmd += " " + $objectAlpha; $cmd += " -wireframeComponentColor"; $cmd += " " + $componentColor[0]; $cmd += " " + $componentColor[1]; $cmd += " " + $componentColor[2]; $cmd += " " + $componentAlpha; $cmd += " " +$texWinName[0]; return $cmd; } global proc uvWireframeOptionsCallback(string $parent, int $doIt) { if ($doIt) { // Execute the command with the option settings. $cmd = `assembleCmd`; eval($cmd); } uvWireframeOptionsRefresh $parent; } global proc uvWireframeOptionsRefresh(string $parent) { setParent $parent; string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`; float $object[] = `textureWindow -q -wireframeObjectColor $texWinName[0]`; float $component[] = `textureWindow -q -wireframeComponentColor $texWinName[0]`; if (size($object) == 4) { colorSliderGrp -e -rgb $object[0] $object[1] $object[2] uvWireframeObjectColor; floatSliderGrp -e -value $object[3] uvWireframeObjectAlpha; } if (size($component) == 4) { colorSliderGrp -e -rgb $component[0] $component[1] $component[2] uvWireframeComponentColor; floatSliderGrp -e -value $component[3] uvWireframeComponentAlpha; } } global proc uvWireframeOptionsSetup(string $parent, int $forceFactorySettings) { setParent $parent; if ($forceFactorySettings) { string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`; textureWindow -e -wireframeObjectColor 1.0 1.0 1.0 0.8 -wireframeComponentColor 0.127 0.716 1.0 0.8 $texWinName[0]; } // Update the settings uvWireframeOptionsCallback ($parent, false); } // Procedure Name: // tvSudgeToolOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc uvWireframeOptions() { // Name of the command for this option box. // string $commandName = "uvWireframeOptions"; // 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: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; columnLayout textureMoveUV; frameLayout -collapsable true -collapse false -label (uiRes("m_performUVWireframeOptions.kColorSettings")) texWireframeSettingFrame; colorSliderGrp -label (uiRes("m_performUVWireframeOptions.kUVWireframeObjectColor")) uvWireframeObjectColor; floatSliderGrp -label (uiRes("m_performUVWireframeOptions.kUVWireframeObjectAlpha")) uvWireframeObjectAlpha; colorSliderGrp -label (uiRes("m_performUVWireframeOptions.kUVWireframeComponentColor")) uvWireframeComponentColor; floatSliderGrp -label (uiRes("m_performUVWireframeOptions.kUVWireframeComponentAlpha")) uvWireframeComponentAlpha; setParent ..; setParent ..; setParent ..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: 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 + " " + 1 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performUVWireframeOptions.kWireframeOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag("UVWireframe"); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // performUVWireframeOptions // // Description: // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performUVWireframeOptions(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: uvWireframeOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }