// =========================================================================== // 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 smudge tool options. // // Input Arguments: // None. // // Return Value: // None. // proc string smudgeOptions_melToUI (string $mel) { string $fixed = (uiRes("m_performTextureSmudgeOptions.kFixed")); string $smudge = (uiRes("m_performTextureSmudgeOptions.kSmudge")); string $exponential = (uiRes("m_performTextureSmudgeOptions.kExponential")); string $linear = (uiRes("m_performTextureSmudgeOptions.kLinear")); string $constant = (uiRes("m_performTextureSmudgeOptions.kConstant")); string $result = $mel; if ( $mel == "Fixed") { $result = $fixed; } else if( $mel == "Smudge"){ $result = $smudge; } else if( $mel == "Exponential"){ $result = $exponential; } else if( $mel == "Linear"){ $result = $linear; } else if( $mel == "Constant"){ $result = $constant; } else{ uiToMelMsg( "smudgeOptions_melToUI", $mel, 0 ); } return $result; } proc string smudgeOptions_uiToMel (string $ui) { string $result = $ui; if ( $ui == (uiRes("m_performTextureSmudgeOptions.kFixed")) ) { $result = "Fixed"; } else if( $ui == (uiRes("m_performTextureSmudgeOptions.kSmudge")) ){ $result = "Smudge"; } else if( $ui == (uiRes("m_performTextureSmudgeOptions.kExponential")) ){ $result = "Exponential"; } else if( $ui == (uiRes("m_performTextureSmudgeOptions.kLinear")) ){ $result = "Linear"; } else if( $ui == (uiRes("m_performTextureSmudgeOptions.kConstant")) ){ $result = "Constant"; } else { uiToMelMsg( "smudgeOptions_uiToMel", $ui, 0 ); } return $result; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd; setToolTo texSmudgeUVSuperContext; string $context = "texSmudgeUVCtx"; int $mm = `checkBoxGrp -query -value1 textureSmudgeBoxMiddleButton`; float $pres = `floatSliderGrp -query -value textureSmudgeBoxPressure`; float $ss = `floatSliderGrp -query -value textureSmudgeBoxSmudgeSize`; string $et = `optionMenuGrp -query -value textureSmudgeBoxEffectType`; string $ft = `optionMenuGrp -query -value textureSmudgeBoxFunctionType`; $et = smudgeOptions_uiToMel ($et); $ft = smudgeOptions_uiToMel ($ft); $cmd = "texSmudgeUVContext -edit"; $cmd += " -functionType " + `tolower $ft`; $cmd += " -effectType " + `tolower $et`; $cmd += " -radius " + $ss; $cmd += " -pressure " + $pres; $cmd += " -smudgeIsMiddle " + $mm; $cmd += " " + $context; return $cmd; } global proc tvSmudgeToolCallback(string $parent, int $doIt) { if ($doIt) { // Execute the command with the option settings. $cmd = `assembleCmd`; eval($cmd); } else { tvSmudgeToolRefresh $parent; } } global proc tvSmudgeToolRefresh(string $parent) { setParent $parent; setToolTo texSmudgeUVSuperContext; string $context = "texSmudgeUVCtx"; // This is part of the super context... string $type = `texSmudgeUVContext -query -effectType $context`; string $ftype = `texSmudgeUVContext -query -functionType $context`; float $ss = `texSmudgeUVContext -query -radius $context`; float $pp = `texSmudgeUVContext -query -pressure $context`; int $mm = `texSmudgeUVContext -query -smudgeIsMiddle $context`; $type = capitalizeString( $type ); $type = smudgeOptions_melToUI ($type); $ftype = capitalizeString( $ftype ); $ftype = smudgeOptions_melToUI( $ftype ); optionMenuGrp -edit -value $type textureSmudgeBoxEffectType; optionMenuGrp -edit -value $ftype textureSmudgeBoxFunctionType; floatSliderGrp -edit -value $ss textureSmudgeBoxSmudgeSize; if ( $type == (uiRes("m_performTextureSmudgeOptions.kSmudge")) ) { floatSliderGrp -edit -en true -value $pp textureSmudgeBoxPressure; } else { floatSliderGrp -edit -en false -value $pp textureSmudgeBoxPressure; } checkBoxGrp -edit -value1 $mm textureSmudgeBoxMiddleButton ; } global proc tvSmudgeToolSetup(string $parent, int $doIt) { setParent $parent; if ($doIt == false) { setUITemplate -pushTemplate OptionsTemplate; columnLayout textureSmudgeUV; frameLayout -collapsable true -collapse false -label (uiRes("m_performTextureSmudgeOptions.kSmudgeSettings")) textureSmudgeDeformFrame; columnLayout textureSmudgeDeformOptions; separator -style "none"; optionMenuGrp -label (uiRes("m_performTextureSmudgeOptions.kEffectType")) textureSmudgeBoxEffectType ; menuItem -label (uiRes("m_performTextureSmudgeOptions.kFixed")); menuItem -label (uiRes("m_performTextureSmudgeOptions.kSmudge")); optionMenuGrp -label (uiRes("m_performTextureSmudgeOptions.kFalloffType")) textureSmudgeBoxFunctionType; menuItem -label (uiRes("m_performTextureSmudgeOptions.kExponential")); menuItem -label (uiRes("m_performTextureSmudgeOptions.kLinear")); menuItem -label (uiRes("m_performTextureSmudgeOptions.kConstant")); floatSliderGrp -label (uiRes("m_performTextureSmudgeOptions.kSmudgeSize")) -field true -minValue 0.0 -fieldMinValue 0.0 textureSmudgeBoxSmudgeSize ; floatSliderGrp -label (uiRes("m_performTextureSmudgeOptions.kPressure")) -field true -minValue 0.0 -maxValue 1.0 textureSmudgeBoxPressure ; checkBoxGrp -label "" -label1 (uiRes("m_performTextureSmudgeOptions.kMiddleMouseInitiates")) textureSmudgeBoxMiddleButton ; setParent ..; setParent ..; setParent ..; setUITemplate -popTemplate; } // Update the settings tvSmudgeToolCallback ($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 tvSmudgeToolOptions() { // Name of the command for this option box. // string $commandName = "tvSmudgeTool"; // 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`; // optionMenuGrp -l "Baked Texture Resolution" // -cc ("tvBakeTextureCheckResolution") // resolutionMenuPopup; // 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_performTextureSmudgeOptions.kUVSmudgeToolOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "textureSmudgeUVTool" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // performTextureViewBakeTextureOptions // // Description: // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performTextureSmudgeOptions(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: tvSmudgeToolOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }