// =========================================================================== // 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: August, 2002 // // Description: // This script provides an option box dialog ghosting options. // // Input Arguments: // boolean showOptionBox true - show the option box dialog // false - just execute the 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) { // ghosting control // if ($forceFactorySettings || !`optionVar -exists ghostControl`) { optionVar -intValue ghostControl 1; } // custom frame values // if ($forceFactorySettings || !`optionVar -exists ghostFrames`) { optionVar -stringValue ghostFrames "1,10,20"; } // custom pre and post values // if ($forceFactorySettings || !`optionVar -exists ghostPre`) { optionVar -intValue ghostPre 3; } if ($forceFactorySettings || !`optionVar -exists ghostPost`) { optionVar -intValue ghostPost 3; } if ($forceFactorySettings || !`optionVar -exists ghostSteps`) { optionVar -intValue ghostSteps 1; } // frame range start and end values // if ($forceFactorySettings || !`optionVar -exists ghostTimeRange`) { optionVar -intValue ghostTimeRange 1; } if ($forceFactorySettings || !`optionVar -exists ghostStart`) { optionVar -intValue ghostStart 1; } if ($forceFactorySettings || !`optionVar -exists ghostEnd`) { optionVar -intValue ghostEnd 100; } // hierarchy // if ($forceFactorySettings || !`optionVar -exists ghostHier`) { optionVar -intValue ghostHier 1; } // use ghost driver // if ($forceFactorySettings || !`optionVar -exists useGhostDriver`) { optionVar -intValue useGhostDriver 0; } // object type to ghost // if ($forceFactorySettings || !`optionVar -exists ghostGeometry`) { optionVar -intValue ghostGeometry 1; } // object type to ghost // if ($forceFactorySettings || !`optionVar -exists ghostLocator`) { optionVar -intValue ghostLocator 1; } // object type to ghost // if ($forceFactorySettings || !`optionVar -exists ghostJoint`) { optionVar -intValue ghostJoint 1; } // object type to ghost // if ($forceFactorySettings || !`optionVar -exists ghostEverythingElse`) { optionVar -intValue ghostEverythingElse 0; } } // // Procedure Name: // ghostSetup // // 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 ghostSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // ghosting control // optionMenuGrp -edit -select `optionVar -query ghostControl` ghostTypeMenu; // custom pre and post // intSliderGrp -edit -value (`optionVar -query ghostPre`) ghostPreSlider; intSliderGrp -edit -value (`optionVar -query ghostPost`) ghostPostSlider; intSliderGrp -edit -value (`optionVar -query ghostSteps`) ghostStepSlider; // custom frames // textFieldGrp -edit -text `optionVar -query ghostFrames` ghostFramesTextWidget; // frame range start and end values // int $timeRangeMethod = `optionVar -query ghostTimeRange`; if ($timeRangeMethod == 1) { radioButtonGrp -edit -select 1 timeRangeMethod; } else { radioButtonGrp -edit -select 2 timeRangeMethod; } intFieldGrp -edit -value1 `optionVar -query ghostStart` ghostStartGrp; intFieldGrp -edit -value1 `optionVar -query ghostEnd` ghostEndGrp; // hierarchy // checkBoxGrp -edit -value1 `optionVar -query ghostHier` ghostHierCheckBox; // use ghost driver // checkBoxGrp -edit -value1 `optionVar -query useGhostDriver` useGhostDriverCheckBox; // ghosting object type // checkBoxGrp -edit -value1 `optionVar -query ghostGeometry` objectTypeBox1; checkBoxGrp -edit -value2 `optionVar -query ghostLocator` objectTypeBox1; checkBoxGrp -edit -value1 `optionVar -query ghostJoint` objectTypeBox2; checkBoxGrp -edit -value2 `optionVar -query ghostEverythingElse` objectTypeBox2; // dim or undim appropriate widgets based on the ghostControl type // ghostTypeCallback($parent); } // // Procedure Name: // ghostCallback // // 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 ghostCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // ghosting control // optionVar -intValue ghostControl `optionMenuGrp -query -select ghostTypeMenu`; // custom pre and post // optionVar -intValue ghostPre `intSliderGrp -query -value ghostPreSlider`; optionVar -intValue ghostPost `intSliderGrp -query -value ghostPostSlider`; optionVar -intValue ghostSteps `intSliderGrp -query -value ghostStepSlider`; // custom frames // optionVar -stringValue ghostFrames `textFieldGrp -query -text ghostFramesTextWidget`; // frame range start and end values // optionVar -intValue ghostTimeRange `radioButtonGrp -query -select timeRangeMethod`; optionVar -intValue ghostStart `intFieldGrp -query -value1 ghostStartGrp`; optionVar -intValue ghostEnd `intFieldGrp -query -value1 ghostEndGrp`; // hierarchy // optionVar -intValue ghostHier `checkBoxGrp -query -value1 ghostHierCheckBox`; // ghost driver // optionVar -intValue useGhostDriver `checkBoxGrp -query -value1 useGhostDriverCheckBox`; // ghosting object type // optionVar -intValue ghostGeometry `checkBoxGrp -query -value1 objectTypeBox1`; optionVar -intValue ghostLocator `checkBoxGrp -query -value2 objectTypeBox1`; optionVar -intValue ghostJoint `checkBoxGrp -query -value1 objectTypeBox2`; optionVar -intValue ghostEverythingElse `checkBoxGrp -query -value2 objectTypeBox2`; if ($doIt) { performGhost 0; addToRecentCommandQueue "performGhost 0" "Ghost"; } } // // Procedure Name: // ghostTypeCallback // // Description: // Dim or undim offset UI based on the ghostConstrol attribute value. // // Input Arguments: // parent - Top level parent layout of the option box UI. // // Return Value: // None. // global proc ghostTypeCallback(string $parent) { setParent $parent; int $ghostControl = `optionMenuGrp -query -select ghostTypeMenu`; int $enableRange = 1; int $enablePrePost = 1; int $enableFrames = 1; int $enableDriver = 1; switch ($ghostControl) { case 1: // global preferences, dim everything $enableRange = 0; $enablePrePost = 0; $enableFrames = 0; $enableDriver = 0; break; case 2: // custom frames $enablePrePost = 0; $enableRange = 0; $enableDriver = 0; break; case 3: // custom pre, post frames $enableRange = 0; $enableFrames = 0; $enableDriver = 0; break; case 4: // custom pre, post keys $enableRange = 0; $enableFrames = 0; break; case 5: // keyframes $enablePrePost = 0; $enableFrames = 0; break; } textFieldGrp -edit -enable $enableFrames ghostFramesTextWidget; radioButtonGrp -edit -enable $enableRange timeRangeMethod; intFieldGrp -edit -enable $enableRange ghostStartGrp; intFieldGrp -edit -enable $enableRange ghostEndGrp; intSliderGrp -edit -enable $enablePrePost ghostPreSlider; intSliderGrp -edit -enable $enablePrePost ghostPostSlider; intSliderGrp -edit -enable $enablePrePost ghostStepSlider; checkBoxGrp -edit -enable $enableDriver useGhostDriverCheckBox; if ($ghostControl == 5) { int $timeMethod = `radioButtonGrp -query -select timeRangeMethod`; if ($timeMethod == 1) { intFieldGrp -edit -enable false ghostStartGrp; intFieldGrp -edit -enable false ghostEndGrp; } } } // // Procedure Name: // ghostOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc ghostOptions() { // Name of the command for this option box. // string $commandName = "ghost"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // string $layout = getOptionBox(); setParent $layout; // Pass the command name to the option box. // setOptionBoxCommandName($commandName); // Activate the default UI template. // setUITemplate -pushTemplate DefaultTemplate; // Turn on the wait cursor. // waitCursor -state 1; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; optionMenuGrp -label (uiRes("m_performGhost.kTypeOfGhosting")) -changeCommand ("ghostTypeCallback "+ $parent) ghostTypeMenu; menuItem -label (uiRes("m_performGhost.kGlobalPrefs")) ghostTypePref; menuItem -label (uiRes("m_performGhost.kCustomFrames")) ghostTypeFrames; menuItem -label (uiRes("m_performGhost.kCustomFramesSteps")) ghostTypeFrameSteps; menuItem -label (uiRes("m_performGhost.kCustomKeySteps")) ghostTypeKeySteps; menuItem -label (uiRes("m_performGhost.kKeyframes")) ghostTypeKeys; textFieldGrp -label (uiRes("m_performGhost.kFramesToDisplay")) -annotation (uiRes("m_performGhost.kFramesToDisplayAnnot")) ghostFramesTextWidget; intSliderGrp -label (uiRes("m_performGhost.kStepsBeforeCurrentFrame")) -annotation (uiRes("m_performGhost.kStepsBeforeAnnot")) -max 20 ghostPreSlider; intSliderGrp -label (uiRes("m_performGhost.kStepsAfter")) -annotation (uiRes("m_performGhost.kStepsAfterAnnot")) -max 20 ghostPostSlider; intSliderGrp -label (uiRes("m_performGhost.kStepSize")) -annotation (uiRes("m_performGhost.kStepSizeAnnot")) -min 1 -max 10 ghostStepSlider; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performGhost.kFrameRange")) -annotation (uiRes("m_performGhost.kFrameRangeAnnot")) -label1 (localizedUIComponentLabel("Time Slider")) -label2 (uiRes("m_performGhost.kStartEnd")) -changeCommand2 ("intFieldGrp -edit -enable #1 ghostStartGrp; intFieldGrp -edit -enable #1 ghostEndGrp;") timeRangeMethod; intFieldGrp -label (uiRes("m_performGhost.kStartFrame")) ghostStartGrp; intFieldGrp -label (uiRes("m_performGhost.kEndFrame")) ghostEndGrp; checkBoxGrp -label (uiRes("m_performGhost.kHierarchy")) -label1 "" -annotation (uiRes("m_performGhost.kHierarchyAnnot")) ghostHierCheckBox; checkBoxGrp -label (uiRes("m_performGhost.kUseGhostDriver")) -label1 " " -annotation (uiRes("m_performGhost.kUseGhostDriverAnnot")) useGhostDriverCheckBox; string $annot = (uiRes("m_performGhost.kObjectTypeAnnot")); checkBoxGrp -numberOfCheckBoxes 2 -label (uiRes("m_performGhost.kObjectType")) -label1 (uiRes("m_performGhost.kGeometry")) -label2 (uiRes("m_performGhost.kLocator")) -annotation $annot objectTypeBox1; checkBoxGrp -numberOfCheckBoxes 2 -label "" -label1 (uiRes("m_performGhost.kJoint")) -label2 (uiRes("m_performGhost.kOtherTypes")) -annotation $annot objectTypeBox2; // Turn off the wait cursor. // waitCursor -state 0; // Deactivate the default UI template. // setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performGhost.kGhost")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle((uiRes("m_performGhost.kGhostOptions"))); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "GhostSelected" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $setAttrCmds; int $ghostControl = `optionVar -query ghostControl`; $ghostControl -= 1; // custom pre, post int $pre = `optionVar -query ghostPre`; int $post = `optionVar -query ghostPost`; int $stepSize = `optionVar -query ghostSteps`; // custom frames string $buff[]; string $frameString; string $frameStringOrig = `optionVar -query ghostFrames`; tokenize($frameStringOrig,",",$buff); int $frameCount = size($buff); if ($frameCount > 0) { $frameString = (" "+$frameCount); for ($ii = 0; $ii < $frameCount; $ii++) { int $frame = $buff[$ii]; $frameString += (" "+$frame); } } // keyframes int $rangeMethod = `optionVar -query ghostTimeRange`; float $start = `optionVar -query ghostStart`; float $end = `optionVar -query ghostEnd`; if ($rangeMethod == 1) { $start = `playbackOptions -query -min`; $end = `playbackOptions -query -max`; } int $hier = `optionVar -query ghostHier`; int $useGhostDriver = `optionVar -query useGhostDriver`; if ($ghostControl <= 2) { // driver does not make sense for ghostControl of global preferences, // custom frames, or custom pre/post // $useGhostDriver = 0; } int $ghostGeometry = `optionVar -query ghostGeometry`; int $ghostLocator = `optionVar -query ghostLocator`; int $ghostJoint = `optionVar -query ghostJoint`; int $ghostEverythingElse = `optionVar -query ghostEverythingElse`; setOptionVars(false); string $cmd = ("doGhost \"3\" { \"1\"" + ", \""+ $hier +"\"" + ", \""+ $ghostControl +"\"" + ", \""+ $pre +"\"" + ", \""+ $post +"\"" + ", \""+ $stepSize +"\"" + ", \""+ $frameString +"\"" + ", \""+ $start +"\"" + ", \""+ $end +"\"" + ", \""+ $useGhostDriver +"\"" + ", \""+ $ghostGeometry +"\"" + ", \""+ $ghostLocator +"\"" + ", \""+ $ghostJoint +"\"" + ", \""+ $ghostEverythingElse +"\"}"); return $cmd; } // // Procedure Name: // performGhost // // Description: // Enable ghosting 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 ghost with the current option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performGhost(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: ghostOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }