// =========================================================================== // 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. // =========================================================================== // // Script: movFileOptions.mel // // Description: // File options for importing mov data. // global proc int movFileOptions(string $parent, string $action, string $initialSettings, string $resultCallback) // // Description: // This script posts the mov file accessor options. // // Parameters: // $parent - the elf parent layout for this options layout. // $action - the action that is to be performed with this // invocation. 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 = 0; string $currentOptions; string $optionList[]; int $index; string $kAttrNames = "attrNames"; string $kPrecisionFlag = "precision"; if ($action == "post") { setParent $parent; setUITemplate -pushTemplate DefaultTemplate; columnLayout -adj true -rowSpacing 5 movColLayout; rowLayout -numberOfColumns 4 -columnWidth4 75 180 95 95 -ct4 "left" "left" "right" "right" -cal 1 "left"; text -label (uiRes("m_movFileOptions.kAttributes")) ; textField -text "" -cc "movFileOptionsAdd(0)" movFileAttrField; button -label (uiRes("m_movFileOptions.kAdd")) -w 90 -c "movFileOptionsAdd(0)"; button -label (uiRes("m_movFileOptions.kRemove")) -w 90 -c "movFileOptionsAdd(1)"; setParent ..; textScrollList -numberOfRows 8 -ams true movFileAttrList; rowLayout -numberOfColumns 3 -columnWidth3 148 148 148 -ct3 "left" "both" "right"; button -label (uiRes("m_movFileOptions.kFromChannelBox")) -w 144 -c "movFileOptionsGetChannels(0)"; button -label (uiRes("m_movFileOptions.kRemoveSelected")) -w 144 -c "movFileOptionsRemoveSelected()"; button -label (uiRes("m_movFileOptions.kRemoveAll")) -w 144 -c "textScrollList -e -removeAll movFileAttrList"; setParent ..; rowLayout -numberOfColumns 4 -columnWidth4 75 180 95 95 -ct4 "left" "left" "right" "right" -cal 1 "left"; text -label (uiRes("m_movFileOptions.kPrecision")) ; intField -v 0 -min 0 movFilePrecisionField; text -label ""; text -label ""; setParent ..; // Now set the current settings. // $currentOptions = $initialSettings; if (size($currentOptions) > 0) { tokenize($currentOptions, ";", $optionList); for ($index = 0; $index < size($optionList); $index++) { string $optionBreakDown[]; tokenize($optionList[$index], "=", $optionBreakDown); if ($optionBreakDown[1] == "") { continue; } if ($optionBreakDown[0] == $kAttrNames) { int $i; string $attrList[]; tokenize($optionBreakDown[1], " ", $attrList); int $nAttrs = `size($attrList)`; for ($i = 0; $i < $nAttrs; $i++) { textScrollList -e -append $attrList[$i] movFileAttrList; } } else if ($optionBreakDown[0] == $kPrecisionFlag) { int $val = $optionBreakDown[1]; intField -e -v $val movFilePrecisionField; } } } setUITemplate -popTemplate; $result = 1; } else if ($action == "query") { // Set the options. // int $precision = `intField -q -v movFilePrecisionField`; $currentOptions = ($kPrecisionFlag + "=" + $precision + ";"); int $i; string $names; string $attrList[] = `textScrollList -q -ai movFileAttrList`; int $nAttrs = `size($attrList)`; for ($i = 0; $i < $nAttrs; $i++) { if ($i > 0) { $names += " "; } $names += $attrList[$i]; } $currentOptions += ($kAttrNames + "=" + $names); eval($resultCallback+" \""+$currentOptions+"\""); $result = 1; } else { $result = 0; } return $result; } proc int movFileIsUnique(string $attr, string $attrList[]) { int $result = 1; string $attrName; for ($attrName in $attrList) { if ($attr == $attrName) { $result = 0; break; } } return $result; } global proc movFileOptionsRemoveSelected() { string $attrName; string $attrList[] = `textScrollList -q -si movFileAttrList`; for ($attrName in $attrList) { textScrollList -e -removeItem $attrName movFileAttrList; } } global proc movFileOptionsAdd(int $remove) { string $attrName = `textField -q -text movFileAttrField`; string $attrList[]; tokenize($attrName, " ", $attrList); string $aName; string $currentList[] = `textScrollList -q -ai movFileAttrList`; if ($remove == 0) { for ($aName in $attrList) { if (1 == movFileIsUnique($aName, $currentList)) { textScrollList -e -append $aName movFileAttrList; } } } else { for ($aName in $attrList) { if (0 == movFileIsUnique($aName, $currentList)) { textScrollList -e -removeItem $aName movFileAttrList; } } } } global proc movFileOptionsGetChannels(int $remove) { if (1 == `channelBox -q -ex mainChannelBox`) { string $oList[] = `ls -sl -o`; string $aList[] = `channelBox -q -sma mainChannelBox`; string $attrName; string $oName, $aName; string $currentList[] = `textScrollList -q -ai movFileAttrList`; for ($oName in $oList) { for ($aName in $aList) { $attrName = ($oName + "." + $aName); if (1 == movFileIsUnique($attrName, $currentList)) { textScrollList -e -append $attrName movFileAttrList; } } } } }