// =========================================================================== // 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: July 16, 1999 // // Description: // This script is the create clip option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Clip name // if ($forceFactorySettings || !`optionVar -exists expClipName`) { optionVar -stringValue expClipName "expr1"; } if ($forceFactorySettings || !`optionVar -exists expClipSchedule`) { optionVar -intValue expClipSchedule 1; } if ($forceFactorySettings || !`optionVar -exists expClipSubChar`) { optionVar -intValue expClipSubChar 1; } if( $forceFactorySettings || !`optionVar -exists expClipStart` ) { optionVar -floatValue expClipStart 0; } if( $forceFactorySettings || !`optionVar -exists expClipEnd` ) { optionVar -floatValue expClipEnd 10; } // expClipTimeWarp // 0: No Warp Curve Created // 1: Time Warp Curve Created // if ( $forceFactorySettings || !`optionVar -exists expClipTimeWarp`) { optionVar -intValue expClipTimeWarp 0; } // expClipRangeMethodWhich: // 1: set the clip for the selected range // 2: set the clip for the time slider range // 3: set the clip for the specified start and end times (default) // if ( $forceFactorySettings || !`optionVar -exists expClipRangeMethodWhich`) { optionVar -intValue expClipRangeMethodWhich 2; } if ($forceFactorySettings || !`optionVar -exists expClipHierarchy`) { // use hierarchy: default is true optionVar -intValue expClipHierarchy 1; } } // // Procedure Name: // expClipSetup // // 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 expClipSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Set the clip name. string $name = `optionVar -query expClipName`; textFieldGrp -e -text $name clipNameWidget; // Set the schedule flag int $scheduleIt = `optionVar -query expClipSchedule`; // Set the subcharacter flag int $useSubcharacters = `optionVar -query expClipSubChar`; checkBoxGrp -edit -value1 $useSubcharacters useSubCharWidget; switch ($scheduleIt) { case 1: radioButtonGrp -e -sl 1 scheduleMethod; break; default: case 2: case 3: radioButtonGrp -e -sl 1 moveToLibraryMethod; break; } // 1 == Remove character's existing expressions & add clip to track editor // 2 == Remove character's existing expressions and add clip to library // 3 == Keep existing expressions and add clip to library // if ($scheduleIt == 3) { checkBoxGrp -edit -value1 true leaveKeysWidget; radioButtonGrp -e -enable false scheduleMethod; } else { radioButtonGrp -e -enable true scheduleMethod; checkBoxGrp -edit -value1 false leaveKeysWidget; } // Set the start and end times. float $start = `optionVar -query expClipStart`; float $end = `optionVar -query expClipEnd`; floatFieldGrp -edit -value1 $start -enable false frameStartValue; floatFieldGrp -edit -value1 $end -enable false frameEndValue; // Set the correct radio button. int $whichMethod = `optionVar -query expClipRangeMethodWhich`; switch($whichMethod) { case 1: radioButtonGrp -e -sl 1 selectedMethod; break; case 2: radioButtonGrp -e -sl 1 timeSliderMethod; break; case 3: default: radioButtonGrp -e -sl 1 startEndMethod; floatFieldGrp -e -enable true frameStartValue; floatFieldGrp -e -enable true frameEndValue; break; } // Set the correct warp curve radio button. // int $whichWarp = `optionVar -query expClipTimeWarp`; checkBoxGrp -edit -value1 $whichWarp createTimeWarpGrp; checkBoxGrp -edit -value1 `optionVar -query expClipHierarchy` clipHierWidget; } // // Procedure Name: // expClipCallback // // 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 expClipCallback (string $parent, int $doIt) { setParent $parent; // Name // optionVar -stringValue expClipName `textFieldGrp -q -text clipNameWidget`; // Set the schedule flag int $leaveKeys = `checkBoxGrp -query -value1 leaveKeysWidget`; int $useSubChar = `checkBoxGrp -query -value1 useSubCharWidget`; optionVar -intValue expClipSubChar $useSubChar; // if the user selects leaveKeys, dim the scheduleMethod widget, since // we only allow you add add the clip to the library if you leave the // keys // if ($leaveKeys) { optionVar -intValue expClipSchedule 3; radioButtonGrp -e -enable false scheduleMethod; radioButtonGrp -e -sl 1 moveToLibraryMethod; } else { radioButtonGrp -e -enable true scheduleMethod; if (`radioButtonGrp -q -sl scheduleMethod` == 1) { optionVar -intValue expClipSchedule 1; } else if (`radioButtonGrp -q -sl moveToLibraryMethod` == 1) { optionVar -intValue expClipSchedule 2; } } if (`radioButtonGrp -q -sl selectedMethod` == 1) { optionVar -intValue expClipRangeMethodWhich 1; } else if (`radioButtonGrp -q -sl timeSliderMethod` == 1) { optionVar -intValue expClipRangeMethodWhich 2; } else { optionVar -intValue expClipRangeMethodWhich 3; } optionVar -floatValue expClipStart `floatFieldGrp -query -value1 frameStartValue`; optionVar -floatValue expClipEnd `floatFieldGrp -query -value1 frameEndValue`; int $warpOption = `checkBoxGrp -q -value1 createTimeWarpGrp`; optionVar -intValue expClipTimeWarp $warpOption; optionVar -intValue expClipHierarchy `checkBoxGrp -q -value1 clipHierWidget`; if ($doIt) performCreateExpClip false; } proc string expClipWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adj true`; textFieldGrp -label (uiRes("m_performCreateExpClip.kName")) -text (uiRes("m_performCreateExpClip.kClip1")) -parent $tabForm clipNameWidget; // schedule it checkBoxGrp -label (uiRes("m_performCreateExpClip.kKeys")) -label1 (uiRes("m_performCreateExpClip.kLeaveKeysInTimeline")) -annotation (uiRes("m_performCreateExpClip.kLeaveKeysInTimelineAnnot")) -onc "radioButtonGrp -e -enable false scheduleMethod; radioButtonGrp -e -sl 1 moveToLibraryMethod;" -ofc "radioButtonGrp -e -enable true scheduleMethod;" -numberOfCheckBoxes 1 leaveKeysWidget; // how to schedule it radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performCreateExpClip.kClip")) -label1 (uiRes("m_performCreateExpClip.kPutClipInVisorOnly")) -annotation (uiRes("m_performCreateExpClip.kPutClipInVisorOnlyAnnot")) moveToLibraryMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCreateExpClip.kPutClipInTraxEditorAndVisor")) -annotation (uiRes("m_performCreateExpClip.kPutClipInTraxEditorAndVisorAnnot")) -shareCollection moveToLibraryMethod scheduleMethod; // clip start & duration radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performCreateExpClip.kTimeRange")) -label1 (uiRes("m_performCreateExpClip.kSelected")) -annotation (uiRes("m_performCreateExpClip.kSelectedAnnot")) selectedMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (localizedUIComponentLabel("Time Slider")) -annotation (uiRes("m_performCreateExpClip.kTimeSliderAnnot")) -shareCollection selectedMethod timeSliderMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCreateExpClip.kStartEnd")) -annotation (uiRes("m_performCreateExpClip.kStartEndAnnot")) -select 1 -shareCollection selectedMethod -onCommand "floatFieldGrp -e -enable true frameStartValue; floatFieldGrp -e -enable true frameEndValue;" -offCommand "floatFieldGrp -e -enable false frameStartValue; floatFieldGrp -e -enable false frameEndValue;" startEndMethod; frameLayout -bv no -lv no -collapsable no startEndFrame; columnLayout -adjustableColumn true; floatFieldGrp -label (uiRes("m_performCreateExpClip.kStartTime")) -value1 0.0 frameStartValue; floatFieldGrp -label (uiRes("m_performCreateExpClip.kEndTime")) -value1 10.0 frameEndValue; setParent ..; setParent ..; setParent ..; // whether to include subcharacters in the clip checkBoxGrp -label (uiRes("m_performCreateExpClip.kSubcharacters")) -label1 (uiRes("m_performCreateExpClip.kIncludeSubcharactersInClip")) -annotation (uiRes("m_performCreateExpClip.kSubcharactersAnnot")) -numberOfCheckBoxes 1 useSubCharWidget; // clip time warps checkBoxGrp -label (uiRes("m_performCreateExpClip.kTimeWarp")) -label1 (uiRes("m_performCreateExpClip.kCreateTimeWarpCurve")) -annotation (uiRes("m_performCreateExpClip.kTimeWarpAnnot")) -numberOfCheckBoxes 1 createTimeWarpGrp; separator; checkBoxGrp -label (uiRes("m_performCreateExpClip.kInclude")) -label1 (uiRes("m_performCreateExpClip.kHierarchy")) -annotation (uiRes("m_performCreateExpClip.kHierarchyAnnot")) -numberOfCheckBoxes 1 clipHierWidget; return $tabForm; } global proc expClipOptions () { string $commandName = "expClip"; string $applyTitle = "Create"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // 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; setOptionBoxCommandName("clip"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; expClipWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateExpClip.kCreateClip")) -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_performCreateExpClip.kCreateExpressionClipOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CreateExpClip" ); // 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 $cmd; setOptionVars(false); // get the partition name string $clipName = "clip1"; if (`optionVar -exists expClipName`) { $clipName = `optionVar -query expClipName`; } int $scheduleIt = 1; if (`optionVar -exists expClipSchedule`) { $scheduleIt = `optionVar -query expClipSchedule`; } int $useSubChar = 1; if (`optionVar -exists expClipSubChar`) { $useSubChar = `optionVar -query expClipSubChar`; } string $createMethod = "startEndMethod"; int $whichMethod = `optionVar -q expClipRangeMethodWhich`; switch ($whichMethod) { case 1: $createMethod = "selectedMethod"; break; case 2: $createMethod = "timeSliderMethod"; break; } string $warpMethod = "noWarp"; int $timeWarp = `optionVar -q expClipTimeWarp`; if ($timeWarp > 0) { $warpMethod = "enabledWarp"; } int $useHierarchy = 0; if (`optionVar -exists expClipHierarchy`) { $useHierarchy = `optionVar -query expClipHierarchy`; } // doCreateClipArgList takes a string array // $cmd = "doCreateClipArgList 5 { " + "\"" + $clipName + "\"" + ",\"" + $scheduleIt + "\"" + ",\"" + $createMethod + "\"" + ",\"" + `optionVar -query expClipStart` + "\"" + ",\"" + `optionVar -query expClipEnd` + "\"" + ",\"" + $useSubChar + "\"" + ",\"" + $warpMethod + "\"" + ",\"" + $useHierarchy + "\"" + ",\"expression\"" + " };"; return $cmd; } // // Procedure Name: // performCreateExpClip // // Description: // Create a clip and add the expression attributes from the // selected nodes. This procedure will also show the option box // window if necessary as well as construct the command string // that will create a clip 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 performCreateExpClip (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. // if ($cmd != "") eval($cmd); break; // Show the option box. // case 1: expClipOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }