// =========================================================================== // 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. // =========================================================================== global proc int animImportOptions ( string $parent, string $action, string $initialSettings, string $resultCallback ) // // Description: // This script posts the anim file accessor options. // // Parameters: // $parent - the elf parent layout for this options layout. It is // always a scrollLayout. // $action - the action that is to be performed with this invokation // of this proc. Valid options are: // "query" - construct the options string and pass it // to the resultCallback. // "post" - post all the elf controls. // $resultCallback - // This is the proc to be called with the result string. // resultCallback ( string $optionsString ) // // Returns: // 1 if successfull. // 0 otherwise. // { int $result; string $currentOptions; string $optionList[]; string $optionBreakDown[]; int $index; if ($action == "post") { setUITemplate -pushTemplate DefaultTemplate; setParent $parent; columnLayout -adj true animMultiObjCol; radioButtonGrp -numberOfRadioButtons 4 -label (uiRes("m_animImportOptions.kTimeRange")) -label1 (uiRes("m_animImportOptions.kStart")) -cc1 ("floatFieldGrp -e -enable true animStartTime; " + "floatFieldGrp -e -enable false animEndTime; " + "updateAnimImportOptionsEnable;") -label2 (uiRes("m_animImportOptions.kStartEnd")) -cc2 ("floatFieldGrp -e -enable true animStartTime; " + "floatFieldGrp -e -enable true animEndTime; " + "updateAnimImportOptionsEnable;") -label3 (uiRes("m_animImportOptions.kCurrent")) -cc3 ("floatFieldGrp -e -enable false animStartTime; " + "floatFieldGrp -e -enable false animEndTime; " + "updateAnimImportOptionsEnable;") -label4 (uiRes("m_animImportOptions.kClipboard")) -cc4 ("floatFieldGrp -e -enable false animStartTime; " + "floatFieldGrp -e -enable false animEndTime; " + "updateAnimImportOptionsEnable;") animTimeRange; floatFieldGrp -label (uiRes("m_animImportOptions.kStartTime")) -value1 0.0 animStartTime; floatFieldGrp -label (uiRes("m_animImportOptions.kEndTime")) -value1 10.0 animEndTime; intSliderGrp -label (uiRes("m_animImportOptions.kCopies")) -field true -min 1 -value 1 animCopies; separator; checkBoxGrp -label (uiRes("m_animImportOptions.kHelpImages")) -ncb 1 -value1 off -l1 "" -cc1 "animImportHelpPictures;" animHelpPictures; radioButtonGrp -numberOfRadioButtons 3 -label (uiRes("m_animImportOptions.kClipboardAdjustment")) -label1 (uiRes("m_animImportOptions.kPreserve")) -cc1 "updateAnimImportOptionsEnable" -label2 (uiRes("m_animImportOptions.kScale")) -cc2 "updateAnimImportOptionsEnable" -label3 (uiRes("m_animImportOptions.kFit")) -cc3 "updateAnimImportOptionsEnable" animAdjustment; radioButtonGrp -numberOfRadioButtons 3 -label (uiRes("m_animImportOptions.kPasteMethod")) -label1 (uiRes("m_animImportOptions.kInsert")) -cc1 "updateAnimImportOptionsEnable" -label2 (uiRes("m_animImportOptions.kReplace")) -cc2 "updateAnimImportOptionsEnable" -label3 (uiRes("m_animImportOptions.kMerge")) -cc3 "updateAnimImportOptionsEnable" animMethod; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_animImportOptions.kReplaceRegion")) -label1 (uiRes("m_animImportOptions.kTimeRangeRadioButton")) -cc1 "updateAnimImportOptionsEnable" -label2 (uiRes("m_animImportOptions.kEntireCurve")) -cc2 "updateAnimImportOptionsEnable" animReplace; checkBoxGrp -label (uiRes("m_animImportOptions.kConnect")) -label1 "" -cc1 "animImportHelpPictures" animConnect; columnLayout -columnAttach "left" 10; picture animHelpPicture; // Now set to current settings. // $currentOptions = $initialSettings; if (size($currentOptions) > 0) { tokenize($currentOptions, ";", $optionList); for ($index = 0; $index < size($optionList); $index++) { tokenize($optionList[$index], "=", $optionBreakDown); if ($optionBreakDown[0] == "targetTime") { int $whichTime = $optionBreakDown[1]; radioButtonGrp -edit -select $whichTime animTimeRange; floatFieldGrp -e -enable ($whichTime == 1 || $whichTime == 2) animStartTime; floatFieldGrp -e -enable ($whichTime == 2) animEndTime; } else if ($optionBreakDown[0] == "time") { string $time = $optionBreakDown[1]; string $range[]; tokenize ($time, ":", $range); // Only one time // if( size( $range ) == 1 ) { floatFieldGrp -edit -value1 (float( $range[0] )) animStartTime; floatFieldGrp -edit -value1 (float( $range[0] )) animEndTime; } // A time range // else if( size( $range ) > 1 ) { floatFieldGrp -edit -value1 (float( $range[0] )) animStartTime; floatFieldGrp -edit -value1 (float( $range[1] )) animEndTime; } } else if ($optionBreakDown[0] == "copies") { int $copies = $optionBreakDown[1]; intSliderGrp -e -value $copies animCopies; } else if ($optionBreakDown[0] == "option") { string $option = $optionBreakDown[1]; // pasteInsert // if ($option == "insert") { radioButtonGrp -edit -select 1 animAdjustment; radioButtonGrp -edit -select 1 animMethod; radioButtonGrp -edit -select 1 animReplace; } // scaleInsert else if ($option == "scaleInsert") { radioButtonGrp -edit -select 2 animAdjustment; radioButtonGrp -edit -select 1 animMethod; radioButtonGrp -edit -select 1 animReplace; } // fitInsert else if ($option == "fitInsert") { radioButtonGrp -edit -select 3 animAdjustment; radioButtonGrp -edit -select 1 animMethod; radioButtonGrp -edit -select 1 animReplace; } // replace else if ($option == "replace") { radioButtonGrp -edit -select 1 animAdjustment; radioButtonGrp -edit -select 2 animMethod; radioButtonGrp -edit -select 1 animReplace; } // replaceCompletely else if ($option == "replaceCompletely") { radioButtonGrp -edit -select 1 animAdjustment; radioButtonGrp -edit -select 2 animMethod; radioButtonGrp -edit -select 2 animReplace; } // scaleReplace else if ($option == "scaleReplace") { radioButtonGrp -edit -select 2 animAdjustment; radioButtonGrp -edit -select 2 animMethod; radioButtonGrp -edit -select 1 animReplace; } // fitReplace else if ($option == "fitReplace") { radioButtonGrp -edit -select 3 animAdjustment; radioButtonGrp -edit -select 2 animMethod; radioButtonGrp -edit -select 1 animReplace; } // pasteMerge else if ($option == "merge") { radioButtonGrp -edit -select 1 animAdjustment; radioButtonGrp -edit -select 3 animMethod; radioButtonGrp -edit -select 1 animReplace; } // scaleMerge else if ($option == "scaleMerge") { radioButtonGrp -edit -select 2 animAdjustment; radioButtonGrp -edit -select 3 animMethod; radioButtonGrp -edit -select 1 animReplace; } // fitMerge else if( $option == "fitMerge" ) { radioButtonGrp -edit -select 3 animAdjustment; radioButtonGrp -edit -select 3 animMethod; radioButtonGrp -edit -select 1 animReplace; } } else if ($optionBreakDown[0] == "pictures") { int $picture = $optionBreakDown[1]; checkBoxGrp -e -value1 $picture animHelpPictures; } else if ($optionBreakDown[0] == "connect") { int $connect = $optionBreakDown[1]; checkBoxGrp -e -value1 $connect animConnect; } } } updateAnimImportOptionsEnable(); setUITemplate -popTemplate; $result = 1; } else if ($action == "query") { $currentOptions += ";"; $currentOptions += ("targetTime=" + `radioButtonGrp -query -select animTimeRange`); $currentOptions += ";"; int $whichTime = `radioButtonGrp -query -select animTimeRange`; if ($whichTime == 1) { $currentOptions += ("time=" + string (`floatFieldGrp -query -value1 animStartTime`)); $currentOptions += ";"; } else if ($whichTime == 2) { $currentOptions += ("time=" + string (`floatFieldGrp -query -value1 animStartTime`) + ":" + string(`floatFieldGrp -query -value1 animEndTime`)); $currentOptions += ";"; } else if ($whichTime == 3) { $currentOptions += ("time="+`currentTime -q`); $currentOptions += ";"; } $currentOptions += ("copies=" + `intSliderGrp -query -value animCopies`); $currentOptions += ";"; string $option = ""; int $selected = `radioButtonGrp -query -select animAdjustment`; if ($selected == 2) { $option = "scale"; } else if ($selected == 3) { $option = "fit"; } $selected = `radioButtonGrp -query -select animMethod`; if ($selected == 1) { if ($option == "") { $option += "insert"; } else { $option += "Insert"; } } else if ($selected == 2) { if ($option == "") { $option += "replace"; } else { $option += "Replace"; } if(`radioButtonGrp -query -select animReplace` == 2) { $option += "Completely"; } } else if ($selected == 3) { if ($option == "") { $option += "merge"; } else { $option += "Merge"; } } $currentOptions += ("option=" + $option); $currentOptions += ";"; $currentOptions += ("pictures=" + `checkBoxGrp -query -value1 animHelpPictures`); $currentOptions += ";"; $currentOptions += ("connect=" + `checkBoxGrp -q -value1 animConnect`); $currentOptions += ";"; eval($resultCallback+" \""+$currentOptions+"\""); $result = 1; } else { $result = 0; } return $result; } global proc animImportHelpPictures() { int $doPictures = `checkBoxGrp -q -value1 animHelpPictures`; if( $doPictures == 0 ) { picture -e -visible no animHelpPicture; return; } int $adjustment = `radioButtonGrp -q -select animAdjustment`; int $method = `radioButtonGrp -q -select animMethod`; int $connect = `checkBoxGrp -q -value1 animConnect`; int $isFromClipboard = (`radioButtonGrp -q -select animTimeRange` == 4); string $helpPicture = "CCPpaste"; if($adjustment == 1) { if($isFromClipboard) { $helpPicture += "Clip"; } else { $helpPicture += "Preserve"; } } else if ($adjustment == 2) { $helpPicture += "Scale"; } else { $helpPicture += "Fit"; } if ($method == 1) { $helpPicture += "Insert"; } else if ($method == 2) { $helpPicture += "Replace"; if($isFromClipboard) { if(`radioButtonGrp -query -select animReplace` == 2) { $helpPicture += "Complete"; } else { $helpPicture += "Range"; } } } else { $helpPicture += "Merge"; } if (($connect == 1 ) && ( `checkBoxGrp -q -enable animConnect`)) { $helpPicture += "Connect"; } $helpPicture += ".png"; picture -e -image (languageResourcePath($helpPicture)) -visible yes animHelpPicture; } global proc updateAnimImportOptionsEnable() { int $whichTimeRange = `radioButtonGrp -q -select animTimeRange`; int $isTimeRange = ($whichTimeRange == 2); // enable the ones that can accept time ranges // if($isTimeRange) { int $isPreserve = (`radioButtonGrp -q -select animAdjustment` == 1); radioButtonGrp -e -enable1 ( !$isTimeRange ) animAdjustment; radioButtonGrp -e -enable2 yes animAdjustment; radioButtonGrp -e -enable3 yes animAdjustment; // If we've disabled the "Preserve" option but it was selected, // select "Fit" instead. // if( $isPreserve && $isTimeRange ) { $isPreserve = false; radioButtonGrp -e -select 3 animAdjustment; } radioButtonGrp -e -enable1 (!$isPreserve) animMethod; radioButtonGrp -e -enable2 yes animMethod; radioButtonGrp -e -enable3 (!$isPreserve) animMethod; if( $isPreserve ) { radioButtonGrp -e -select 2 animMethod; } } // disable the ones that can't accept time ranges // else { int $isFromClipboard = (`radioButtonGrp -q -select animTimeRange` == 4); radioButtonGrp -e -enable1 yes -select 1 animAdjustment; radioButtonGrp -e -enable2 no animAdjustment; radioButtonGrp -e -enable3 no animAdjustment; radioButtonGrp -e -enable1 yes animMethod; radioButtonGrp -e -enable2 $isFromClipboard animMethod; radioButtonGrp -e -enable3 yes animMethod; if(( $whichTimeRange != 0 ) && ( !$isFromClipboard ) && ( `radioButtonGrp -q -select animMethod` == 2 )) { radioButtonGrp -e -select 1 animMethod; } } // The replace option is enabled if the replace method is selected. // int $isReplaceMethod = (`radioButtonGrp -q -select animMethod` == 2); int $enableReplaceCurve = ( !$isTimeRange && $isReplaceMethod ); radioButtonGrp -e -enable $isReplaceMethod animReplace; radioButtonGrp -e -enable2 $enableReplaceCurve animReplace; if( !$enableReplaceCurve && (`radioButtonGrp -q -select animReplace` == 2) ) { radioButtonGrp -e -select 1 animReplace; } // The connect option is only enabled when the method is NOT "Merge" // checkBoxGrp -edit -enable (`radioButtonGrp -q -select animMethod` != 3) animConnect; animImportHelpPictures; }