// =========================================================================== // 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: 4 April 1997 // // Procedure Name: // performPolyPoke // // Description: // // // Input Arguments: // $option : Whether to set the options to default values. // Return Value: // command string iff $option==2 // proc setOptionVars ( int $forceFactorySettings ) { if ($forceFactorySettings || !`optionVar -exists "pokeTranslate"`) optionVar -floatValue "pokeTranslate" 0. -floatValueAppend "pokeTranslate" 0. -floatValueAppend "pokeTranslate" 0.; if ($forceFactorySettings || !`optionVar -exists "pokeTranslateLocalSpace"`) optionVar -intValue "pokeTranslateLocalSpace" 0; } global proc performPolyPokeSetup (string $parent, int $forceFactorySettings) { string $prefix = "polyPoke"; float $vals[]; int $ival; setOptionVars($forceFactorySettings); setParent $parent; $vals = `optionVar -query "pokeTranslate"`; floatFieldGrp -edit -value1 $vals[0] -value2 $vals[1] -value3 $vals[2] pokeTranslate; $ival = `optionVar -query "pokeTranslateLocalSpace"`; // radio button is 1-based $ival = $ival + 1; radioButtonGrp -edit -select $ival pokeTranslateLocalSpace; } global proc performPolyPokeCallback (string $parent, int $doIt) { string $prefix = "polyPoke"; setParent $parent; optionVar -floatValue "pokeTranslate" `floatFieldGrp -query -value1 pokeTranslate` -floatValueAppend "pokeTranslate" `floatFieldGrp -query -value2 pokeTranslate` -floatValueAppend "pokeTranslate" `floatFieldGrp -query -value3 pokeTranslate`; int $ival = `radioButtonGrp -query -select pokeTranslateLocalSpace`; // radio button is 1-based $ival = $ival - 1; optionVar -intValue "pokeTranslateLocalSpace" $ival; if ($doIt) { performPolyPoke 0; addToRecentCommandQueue "performPolyPoke 0" "PolyPoke"; } } proc polyPokeOptions (string $prefix) { // Global template variables for form spacing global int $gOptionBoxTemplateDescriptionMarginWidth; global int $gOptionBoxTemplateFrameSpacing; string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; string $commandName = "performPolyPoke"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Form layout string $parent = `formLayout polyPokeFaceOptions`; // Description frame string $descriptionFrame = `frameLayout -label (uiRes("m_performPolyPoke.kDescriptionFrame")) -mw $gOptionBoxTemplateDescriptionMarginWidth`; text -label (uiRes("m_performPolyPoke.kDescription")); setParent $parent; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performPolyPoke.kSettingsFrame"))`; columnLayout; floatFieldGrp -label (uiRes("m_performPolyPoke.kVertexOffset")) -numberOfFields 3 pokeTranslate; //floatFieldGrp -label _L10N( kObjectSpace,"Vertex offset (object space):" ) -numberOfFields 3 pokeLocalTranslate; radioButtonGrp -numberOfRadioButtons 2 -vr -label (uiRes("m_performPolyPoke.kThresholdDistance")) -labelArray2 (uiRes("m_performPolyPoke.kWorldSpace")) (uiRes("m_performPolyPoke.kObjectSpace")) pokeTranslateLocalSpace; setParent ..; // columnLayout setParent $parent; // frameLayout setParent ..; // formLayout // Attach Description/Settings frames to form layout formLayout -e -af $descriptionFrame "top" $gOptionBoxTemplateFrameSpacing -af $descriptionFrame "left" $gOptionBoxTemplateFrameSpacing -af $descriptionFrame "right" $gOptionBoxTemplateFrameSpacing -an $descriptionFrame "bottom" -ac $settingsFrame "top" $gOptionBoxTemplateFrameSpacing $descriptionFrame -af $settingsFrame "left" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "right" $gOptionBoxTemplateFrameSpacing -an $settingsFrame "bottom" $parent; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performPolyPoke.kPokeFaceButton")) -command ($callback + " " + $parent + " " + 1) $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; setOptionBoxTitle( (uiRes("m_performPolyPoke.kPokeFaceOptions")) ); setOptionBoxHelpTag("PokeFaces"); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } proc string assembleCmd() { setOptionVars (false); int $doHistory = `constructionHistory -q -toggle`; //string $cmd=("polyPoke -ch " + $doHistory); string $cmd = "polyPoke "; $cmd += " -ws 1 "; float $pc[] = `optionVar -query "pokeTranslate"`; int $useLocal = `optionVar -query "pokeTranslateLocalSpace"`; if( $useLocal ){ $cmd+=(" -ltx " + $pc[0] + " -lty " + $pc[1] + " -ltz " + $pc[2]); } else { $cmd+=(" -tx " + $pc[0] + " -ty " + $pc[1] + " -tz " + $pc[2]); } return $cmd; } global proc string performPolyPoke (int $option) { string $prefix = "polyPoke"; string $cmd=""; switch ($option) { case 0: string $varName; int $ival; setOptionVars(false); $cmd=`assembleCmd`; int $vcarr[]; int $oldVCount = 0; if (size(`ls -sl -o -typ mesh`) > 0) { $vcarr = `polyEvaluate -v`; } polyPerformAction $cmd "f" 0; if (!`constructionHistory -q -toggle`) { if (size($vcarr) > 0) { $oldVCount = $vcarr[0]; $vcarr = `polyEvaluate -v`; if (size($vcarr) > 0) { int $sVtx = $oldVCount; int $eVtx = $vcarr[0]; string $suf; if (($eVtx - $sVtx) > 0) { $eVtx--; if ($eVtx == $sVtx) { $suf = ".vtx[" + $eVtx + "];"; } else { $suf = ".vtx[" + $sVtx + ":" + $eVtx + "];"; } string $shapes[] = `ls -sl -o -typ mesh`; if (size($shapes) > 0) { $suf = $shapes[0] + $suf; eval("select -r " + $suf); } } } } } else { if (0 != size(`ls -sl`)) { string $tmp[] = `listHistory`; string $totalSel[]; for ($opNode in $tmp) { if (`nodeType $opNode` == "polyPoke") { $totalSel[size($totalSel)] = $opNode; } } if (size($totalSel) > 0) select -add $totalSel[0]; global string $gPolyLastTool; $gPolyLastTool=""; setToolTo ShowManips; } } break; case 1: polyPokeOptions($prefix); break; case 2: $cmd="performPolyPoke 0"; break; } return $cmd; }