// =========================================================================== // 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: Nov 24, 19987 // // Description: // This script is use to display and update the image range options. // // Input Arguments: // None. // // Return Value: // None. // proc string tvImageRangePanelName() // // 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 tvImageRangeMinU`) { optionVar -fv tvImageRangeMinU 0.0; } if ($forceFactorySettings || !`optionVar -exists tvImageRangeMinV`) { optionVar -fv tvImageRangeMinV 0.0; } if ($forceFactorySettings || !`optionVar -exists tvImageRangeMaxU`) { optionVar -fv tvImageRangeMaxU 1.0; } if ($forceFactorySettings || !`optionVar -exists tvImageRangeMaxV`) { optionVar -fv tvImageRangeMaxV 1.0; } if ($forceFactorySettings || !`optionVar -exists tvImageRangePresets`) { optionVar -iv tvImageRangePresets 1; } } global proc tvImageRangeSetup(string $parent, int $forceFactorySettings) // // Procedure Name: // tvImageRangeSetup // // 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 = tvImageRangePanelName(); float $rangeMinU = `optionVar -query tvImageRangeMinU`; float $rangeMinV = `optionVar -query tvImageRangeMinV`; float $rangeMaxU = `optionVar -query tvImageRangeMaxU`; float $rangeMaxV = `optionVar -query tvImageRangeMaxV`; floatSliderGrp -edit -value $rangeMinU tvImageRangeMinU; floatSliderGrp -edit -value $rangeMinV tvImageRangeMinV; floatSliderGrp -edit -value $rangeMaxU tvImageRangeMaxU; floatSliderGrp -edit -value $rangeMaxV tvImageRangeMaxV; int $preset = `optionVar -query tvImageRangePresets`; radioButtonGrp -edit -select $preset tvImageRangePresets; } global proc tvImageRangeCallback(string $parent, int $doIt) // // Procedure Name: // tvImageRangeCallback // // 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 -fv tvImageRangeMinU `floatSliderGrp -q -value tvImageRangeMinU`; optionVar -fv tvImageRangeMinV `floatSliderGrp -q -value tvImageRangeMinV`; optionVar -fv tvImageRangeMaxU `floatSliderGrp -q -value tvImageRangeMaxU`; optionVar -fv tvImageRangeMaxV `floatSliderGrp -q -value tvImageRangeMaxV`; optionVar -iv tvImageRangePresets `radioButtonGrp -query -select tvImageRangePresets`; if ($doIt) { performTextureViewImageRangeOptions 0; addToRecentCommandQueue "performTextureViewImageRangeOptions 0" "TextureViewImageRange"; } } global proc tvImageRangeCheckRange() // // Description: // Check if image ranges are valid. // Arguments: // // Returns: // // { float $minU, $minV, $maxU, $maxV; $minU = `floatSliderGrp -query -value tvImageRangeMinU`; $minV = `floatSliderGrp -query -value tvImageRangeMinV`; $maxU = `floatSliderGrp -query -value tvImageRangeMaxU`; $maxV = `floatSliderGrp -query -value tvImageRangeMaxV`; if ($minU > $maxU) { $maxU = $minU; floatSliderGrp -edit -value $maxU tvImageRangeMaxU; } if ($minV > $maxV) { $maxV = $minV; floatSliderGrp -edit -value $maxV tvImageRangeMaxV; } } global proc tvImageRangeCheckPresets() // // Description: // Update UI to presets // Arguments: // // Returns: // // { int $preset = `radioButtonGrp -query -select tvImageRangePresets`; if ($preset == 2) { if (`optionVar -exists textureWindowGridSize`) { float $gridSize = `optionVar -q textureWindowGridSize`; float $negGridSize = 0.0 - $gridSize; floatSliderGrp -edit -value $negGridSize tvImageRangeMinU; floatSliderGrp -edit -value $negGridSize tvImageRangeMinV; floatSliderGrp -edit -value $gridSize tvImageRangeMaxU; floatSliderGrp -edit -value $gridSize tvImageRangeMaxV; } } else if ($preset == 3) { floatSliderGrp -edit -value 0.0 tvImageRangeMinU; floatSliderGrp -edit -value 0.0 tvImageRangeMinV; floatSliderGrp -edit -value 1.0 tvImageRangeMaxU; floatSliderGrp -edit -value 1.0 tvImageRangeMaxV; } } // // Procedure Name: // tvImageRangeOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc tvImageRangeOptions() { // Name of the command for this option box. // string $commandName = "tvImageRange"; // 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`; floatSliderGrp -label (uiRes("m_performTextureViewImageRangeOptions.kMinimumU")) -minValue -50.0 -maxValue 50.0 -fieldMinValue -50.0 -fieldMaxValue 50.0 -cc ("tvImageRangeCheckRange") tvImageRangeMinU; floatSliderGrp -label (uiRes("m_performTextureViewImageRangeOptions.kMinimumV")) -minValue -50.0 -maxValue 50.0 -fieldMinValue -50.0 -fieldMaxValue 50.0 -cc ("tvImageRangeCheckRange") tvImageRangeMinV; floatSliderGrp -label (uiRes("m_performTextureViewImageRangeOptions.kMaximumU")) -minValue -50.0 -maxValue 50.0 -fieldMinValue -50.0 -fieldMaxValue 50.0 -cc ("tvImageRangeCheckRange") tvImageRangeMaxU; floatSliderGrp -label (uiRes("m_performTextureViewImageRangeOptions.kMaximumV")) -minValue -50.0 -maxValue 50.0 -fieldMinValue -50.0 -fieldMaxValue 50.0 -cc ("tvImageRangeCheckRange") tvImageRangeMaxV; radioButtonGrp -numberOfRadioButtons 3 -select 1 -label (uiRes("m_performTextureViewImageRangeOptions.kPresets")) -label1 (uiRes("m_performTextureViewImageRangeOptions.kNone")) -label2 (uiRes("m_performTextureViewImageRangeOptions.kGridSize")) -label3 (uiRes("m_performTextureViewImageRangeOptions.kUnitSize")) -cc ("tvImageRangeCheckPresets") tvImageRangePresets; // 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_performTextureViewImageRangeOptions.kImageRangeOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "UVTextureEditorImageRange" ); // 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); float $rangeMinU = `optionVar -query tvImageRangeMinU`; float $rangeMinV = `optionVar -query tvImageRangeMinV`; float $rangeMaxU = `optionVar -query tvImageRangeMaxU`; float $rangeMaxV = `optionVar -query tvImageRangeMaxV`; string $winName = tvImageRangePanelName(); $cmd = "textureWindow -edit -imageTileRange " + $rangeMinU + " " + $rangeMinV + " " + $rangeMaxU + " " + $rangeMaxV + " " + $winName; return $cmd; } // // Procedure Name: // performTextureViewImageRangeOptions // // Description: // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performTextureViewImageRangeOptions(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: tvImageRangeOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }