// =========================================================================== // 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 provides an option box dialog for the add target shape command. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists shapeEditorMirrorTgtDirection`) { optionVar -intValue shapeEditorMirrorTgtDirection 0; } if ($forceFactorySettings || !`optionVar -exists shapeEditorFlipTgtSymmetryAxis`) { optionVar -intValue shapeEditorFlipTgtSymmetryAxis 1; } if ($forceFactorySettings || !`optionVar -exists shapeEditorStoreSymmetrySeamEdges`) { optionVar -intValue shapeEditorStoreSymmetrySeamEdges 1; } } // // Procedure Name: // shapeEditorMirrorSetup // // 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. // global proc shapeEditorMirrorSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $direction=`optionVar -q shapeEditorMirrorTgtDirection`; optionMenuGrp -e -sl ($direction+1) seDirectionList; int $axis=`optionVar -q shapeEditorFlipTgtSymmetryAxis`; optionMenuGrp -e -sl $axis seAxisList; checkBoxGrp -e -en ($axis == 4) seSymmetryEdge; int $store=`optionVar -q shapeEditorStoreSymmetrySeamEdges`; checkBoxGrp -e -v1 $store seSymmetryEdge; } // // Procedure Name: // shapeEditorMirrorCallback // // 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. // global proc shapeEditorMirrorCallback(string $parent, int $doIt) { setParent $parent; int $direction=`optionMenuGrp -q -select seDirectionList` - 1; optionVar -intValue shapeEditorMirrorTgtDirection $direction; int $axis=`optionMenuGrp -q -select seAxisList`; optionVar -intValue shapeEditorFlipTgtSymmetryAxis $axis; if ($doIt) { string $cmd = "performTargetShapeMirror 2"; eval($cmd); addToRecentCommandQueue $cmd "TargetShapeMirror"; } } // // Procedure Name: // shapeEditorMirrorOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc shapeEditorMirrorOptions() { string $commandName = "shapeEditorMirror"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; optionMenuGrp -enable 1 -label (uiRes("m_performTargetShapeMirror.kDirection")) seDirectionList; menuItem -label "-"; menuItem -label "+"; optionMenuGrp -enable 1 -label (uiRes("m_performTargetShapeMirror.kAxis")) -changeCommand "checkBoxGrp -e -en (`optionMenuGrp -q -select seAxisList` == 4) seSymmetryEdge" seAxisList; menuItem -label (uiRes("m_performTargetShapeMirror.kObjectX")); menuItem -label (uiRes("m_performTargetShapeMirror.kObjectY")); menuItem -label (uiRes("m_performTargetShapeMirror.kObjectZ")); menuItem -label (uiRes("m_performTargetShapeMirror.kTopo")); checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 (uiRes("m_performTargetShapeMirror.kStoreSymmetrySeamEdges")) -v1 1 -en 1 -on1 "optionVar -intValue shapeEditorStoreSymmetrySeamEdges 1" -of1 "optionVar -intValue shapeEditorStoreSymmetrySeamEdges 0" seSymmetryEdge; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -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_performTargetShapeMirror.kMirrorBlendShapeTargetOptions")); setOptionBoxHelpTag( "EditBlendShapeMirror" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } // // Procedure Name: // assembleShapeEditorCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleShapeEditorCmd() { string $cmd; int $direction=`optionVar -q shapeEditorMirrorTgtDirection`; int $axis=`optionVar -q shapeEditorFlipTgtSymmetryAxis`; int $store=`optionVar -q shapeEditorStoreSymmetrySeamEdges`; $cmd = "doBlendShapeMirrorTarget " + $direction + " " + $axis + " " + $store; return $cmd; } // // Procedure Name: // performTargetShapeMirror // // Description: // Perform the targetShapeMirror command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the targetShapeMirror command with the current // option box values. // // Input Arguments: // 0 - Execute flip target command. // 1 - Show shape editor flip option box dialog. // global proc string performTargetShapeMirror(int $action) { string $cmd = ""; switch ($action) { case 0: setOptionVars(false); $cmd = `assembleShapeEditorCmd`; eval($cmd); break; case 1: shapeEditorMirrorOptions; break; case 2: $cmd = `assembleShapeEditorCmd`; eval($cmd); break; } return $cmd; }