// =========================================================================== // 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. // =========================================================================== // // // Description: // This script is use to update the texture borders options. // // Input Arguments: // None. // // Return Value: // None. // proc string textureWindowPanelName() // // Procedure Name: // textureWindowPanelName // // Description: // return the texture window panel name. // // Input Arguments: // // // Return Value: // texture window panel name // { string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`; return $texWinName[0]; } proc setOptionVars(int $forceFactorySettings) // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // { if ($forceFactorySettings || !`optionVar -exists tvTextureBordersColorOptVar`) { optionVar -iv tvTextureBordersColorOptVar 0; } if ($forceFactorySettings || !`optionVar -exists tvTextureBordersColorROptVar`) { optionVar -fv tvTextureBordersColorROptVar 1; } if ($forceFactorySettings || !`optionVar -exists tvTextureBordersColorGOptVar`) { optionVar -fv tvTextureBordersColorGOptVar 1; } if ($forceFactorySettings || !`optionVar -exists tvTextureBordersColorBOptVar`) { optionVar -fv tvTextureBordersColorBOptVar 1; } if ($forceFactorySettings || !`optionVar -exists tvTextureBordersEdgeWidthOptVar`) { optionVar -iv tvTextureBordersEdgeWidthOptVar 2; } if ($forceFactorySettings || !`optionVar -exists tvTextureBordersDisplayIn3dViewportOptVar`) { optionVar -iv tvTextureBordersDisplayIn3dViewportOptVar 1; } } global proc tvTextureBordersSetup(string $parent, int $forceFactorySettings) // // 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. // { setParent $parent; setOptionVars($forceFactorySettings); string $winName = textureWindowPanelName(); int $label = `optionVar -query tvTextureBordersColorOptVar`; checkBoxGrp -edit -value1 $label tvTextureBordersColor; float $color1r = `optionVar -query tvTextureBordersColorROptVar`; float $color1g = `optionVar -query tvTextureBordersColorGOptVar`; float $color1b = `optionVar -query tvTextureBordersColorBOptVar`; colorSliderGrp -e -rgb $color1r $color1g $color1b tvTextureBordersColorValue; $res = `optionVar -query tvTextureBordersEdgeWidthOptVar`; intFieldGrp -edit -value1 $res tvTextureBordersEdgeWidth; int $displayIn3dView = `optionVar -query tvTextureBordersDisplayIn3dViewportOptVar`; checkBoxGrp -edit -value1 $displayIn3dView tvTextureBordersDisplayIn3dViewport; } global proc tvTextureBordersCallback(string $parent, int $doIt) // // 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. // { optionVar -iv tvTextureBordersColorOptVar `checkBoxGrp -q -value1 tvTextureBordersColor`; float $color1[] = `colorSliderGrp -q -rgb tvTextureBordersColorValue`; optionVar -fv tvTextureBordersColorROptVar $color1[0]; optionVar -fv tvTextureBordersColorGOptVar $color1[1]; optionVar -fv tvTextureBordersColorBOptVar $color1[2]; optionVar -iv tvTextureBordersEdgeWidthOptVar `intFieldGrp -q -value1 tvTextureBordersEdgeWidth`; optionVar -iv tvTextureBordersDisplayIn3dViewportOptVar `checkBoxGrp -q -value1 tvTextureBordersDisplayIn3dViewport`; if ($doIt) { performTextureViewTextureBordersOptions 0; addToRecentCommandQueue "performTextureViewTextureBordersOptions 0" "TextureViewTextureBorders"; } } // // Procedure Name: // tvTextureBordersOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc tvTextureBordersOptions() { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; // Name of the command for this option box. // string $commandName = "tvTextureBorders"; // 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; string $parent = `columnLayout -adjustableColumn 1`; string $settingsFrame = `frameLayout -label (uiRes("m_performTextureViewTextureBordersOptions.kSettings")) -cl 0 -cll 0 `; columnLayout; checkBoxGrp -label (uiRes("m_performTextureViewTextureBordersOptions.kTextureBordersColor")) -numberOfCheckBoxes 1 -value1 0 tvTextureBordersColor; columnLayout -columnAlign "right" -cat "left" 0; colorSliderGrp -label "" -rgb 1 1 1 tvTextureBordersColorValue; setParent ..; intFieldGrp -numberOfFields 1 -label (uiRes("m_performTextureViewTextureBordersOptions.kTextureBordersEdgeWidth")) -value1 2 tvTextureBordersEdgeWidth; setParent ..; setParent ..; frameLayout -label (uiRes("m_performTextureViewTextureBordersOptions.kDisplaySettings")) -collapsable true -collapse false; columnLayout; separator -style "none"; checkBoxGrp -label1 (uiRes("m_performTextureViewTextureBordersOptions.kTextureBordersIn3dViewport")) -numberOfCheckBoxes 1 tvTextureBordersDisplayIn3dViewport; 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. // ============================== string $applyBtn = getOptionBoxApplyBtn(); button -edit -visible 1 -command ($callback + " " + $parent + " " + 1 + "; ") $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -visible 0 -command ($callback + " " + $parent + " " + 0 + "; ") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -visible 0 -command ($setup + " " + $parent + " " + 1 + ";") $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performTextureViewTextureBordersOptions.kTextureBordersOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "UVTextureEditorTextureBorders" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: 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; setOptionVars(false); int $colorEnabled = `optionVar -query tvTextureBordersColorOptVar`; float $color1r = `optionVar -query tvTextureBordersColorROptVar`; float $color1g = `optionVar -query tvTextureBordersColorGOptVar`; float $color1b = `optionVar -query tvTextureBordersColorBOptVar`; if ($colorEnabled == 0) { $color1r = 1; $color1g = 1; $color1b = 1; } $edgeWidth = `optionVar -query tvTextureBordersEdgeWidthOptVar`; $displayIn3dView = `optionVar -query tvTextureBordersDisplayIn3dViewportOptVar`; string $winName = textureWindowPanelName(); $cmd = "textureWindow -edit " + " -textureBorderColor " + $color1r + " " + $color1g + " " + $color1b + " " + " -textureBorderWidth " + $edgeWidth + " " + " -textureBorder3dView " + $displayIn3dView + " " + $winName; return $cmd; } // // Procedure Name: // performTextureViewTextureBordersOptions // // Description: // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performTextureViewTextureBordersOptions(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: tvTextureBordersOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }