// =========================================================================== // 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: April 12, 2006 // // Procedure Name: // performPolyRotateUVsDirectional // // Description: // Rotates UVs clockwise or counter clockwise // // Input Arguments: // $option : Whether to set the options to default values. // $clockwise : Indicates clockwise or counter-clockwise direction // // Return Value: // command string iff $option==2 // proc setOptionVars (int $forceFactorySettings, int $clockwise) { if ( $clockwise ){ if ($forceFactorySettings || !`optionVar -exists polyRotateUVAngleClockwise`) { optionVar -floatValue polyRotateUVAngleClockwise 45; } } else { if ($forceFactorySettings || !`optionVar -exists polyRotateUVAngleCounterclockwise`) { optionVar -floatValue polyRotateUVAngleCounterclockwise 45; } } } global proc performPolyRotateUVsDirectionalSetup (string $parent, int $clockwise, int $forceFactorySettings) { setOptionVars($forceFactorySettings, $clockwise); setParent $parent; float $ang; if( $clockwise ){ $ang = `optionVar -query polyRotateUVAngleClockwise`; } else { $ang = `optionVar -query polyRotateUVAngleCounterclockwise`; } floatSliderGrp -edit -value $ang polyRotateUVAngle; } global proc performPolyRotateUVsDirectionalCallback (string $parent, int $clockwise, int $doIt) { setParent $parent; float $ang = `floatSliderGrp -query -value polyRotateUVAngle`; if( $clockwise ){ optionVar -floatValue polyRotateUVAngleClockwise $ang; } else { optionVar -floatValue polyRotateUVAngleCounterclockwise $ang; } if ($doIt) { performPolyRotateUVsDirectional 0 $clockwise; addToRecentCommandQueue ("performPolyRotateUVsDirectional 0 " + $clockwise) "PolyRotateUVsDirectional"; } } proc polyRotateUVsDirectionalOptions (int $clockwise) { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; // Form layout string $parent = `formLayout polyRotateUVsDirectionalOptions`; string $commandName = "performPolyRotateUVsDirectional"; string $callback = ($commandName + "Callback " + $parent + " " + $clockwise + " "); string $setup = ($commandName + "Setup " + $parent + " " + $clockwise + " "); setOptionBoxCommandName($commandName); // Rotation angle frame string $rotationAngleFrame = `frameLayout -label (uiRes("m_performPolyRotateUVsDirectional.kRotationAngleFrame"))`; columnLayout; string $label; if( $clockwise ){ $label = (uiRes("m_performPolyRotateUVsDirectional.kClockwise")); } else { $label = (uiRes("m_performPolyRotateUVsDirectional.kCounterclockwise")); } floatSliderGrp -label $label -minValue -360.0 -maxValue 360.0 polyRotateUVAngle; setParent $parent; // frameLayout setParent ..; // formLayout // Attach frame to form layout formLayout -edit -attachForm $rotationAngleFrame "top" $gOptionBoxTemplateFrameSpacing -attachForm $rotationAngleFrame "left" $gOptionBoxTemplateFrameSpacing -attachForm $rotationAngleFrame "right" $gOptionBoxTemplateFrameSpacing -attachNone $rotationAngleFrame "bottom" $parent; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performPolyRotateUVsDirectional.kRotateUVs")) -command ($callback + 1) $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + 1) $resetBtn; if( $clockwise ){ setOptionBoxTitle (uiRes("m_performPolyRotateUVsDirectional.kRotateUVsClockwiseOptions")); } else { setOptionBoxTitle (uiRes("m_performPolyRotateUVsDirectional.kRotateUVsCounterclockwiseOptions")); } setOptionBoxHelpTag( "RotateUVs" ); eval (($setup + 0)); showOptionBox(); } proc string assembleCmd(int $clockwise) { string $cmd=("string $selection[] = `ls -sl`; string $compSelType = `getComponentMask`; ConvertSelectionToUVs; polyRotateUVs "); float $ang; if( $clockwise ){ $ang = -(`optionVar -query polyRotateUVAngleClockwise`); } else { $ang = `optionVar -query polyRotateUVAngleCounterclockwise`; } $cmd += $ang; $cmd += " 0; setComponentMask $compSelType; select -replace $selection"; return $cmd; } global proc string performPolyRotateUVsDirectional(int $option, int $clockwise) { string $cmd=""; switch ($option) { case 0: setOptionVars(false, $clockwise); $cmd=`assembleCmd $clockwise`; evalEcho $cmd; break; case 1: polyRotateUVsDirectionalOptions $clockwise; break; case 2: setOptionVars(false, $clockwise); $cmd=`assembleCmd $clockwise`; break; } return $cmd; }