// =========================================================================== // 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: 28 Aug 1996 // // Description: // This command will create if necessary and display // a spread sheet editor window. // // Input Arguments: // None // // Return Value: // None // global proc buildSpreadsheetContextHelpItems(string $nameRoot, string $menuParent) // // Description: // Build context sensitive menu items for this window. // // Input Arguments: // $nameRoot - name to use as the root of all item names // $menuParent - the name of the parent of this menu // // Return Value: // None // { menuItem -label (uiRes("m_SpreadSheetWindow.kHelpOnAttributeSpreadSheet")) -enableCommandRepeat false -command "showHelp AttributeSpreadSheet"; } global proc SpreadSheetWindow_showSelCol( string $edName ) { string $selectedAttrs[] = `spreadSheetEditor -q -sla $edName`; // If columns are selected, draw only those columns // if( size( $selectedAttrs ) > 0 ) { spreadSheetEditor -e -fixedAttrList $selectedAttrs $edName; } // Error message... // else { error (uiRes("m_SpreadSheetWindow.kNoColumnsSelected")); } } global proc SpreadSheetWindow(){ // If the window does not exist, create it. // if ( !`workspaceControl -exists SSEwindow` ){ createSpreadSheetControl(true, false); } // The window exists. Bring it to the front. workspaceControl -e -restore SSEwindow; } global proc createSpreadSheetControl(int $visible, int $loadImmediately) { workspaceControl -label (uiRes("m_SpreadSheetWindow.kAttributeSpreadSheet")) -uiScript "initSpreadSheetWindow()" -visible $visible -loadImmediately $loadImmediately SSEwindow; } global proc initSpreadSheetWindow(){ string $formName; string $menuName; string $edName = "SSEd"; global string $gSSEWindow_Last_Tab = ""; // Create a menu bar layout for the Render Settings panel. // menuBarLayout; $formName = `formLayout`; if ( !`selectionConnection -exists SSEcon` ){ selectionConnection -p $formName -act SSEcon; } // Create the editor if it does not exist; // otherwise just parent it to this window. // if ( `spreadSheetEditor -exists $edName` ){ spreadSheetEditor -e -ln true -parent $formName -mlc SSEcon $edName; } else { spreadSheetEditor -ln true -parent $formName -mlc SSEcon $edName; } // Create a filter field to filter the attributes // text -align "center" -label (uiRes("m_SpreadSheetWindow.kSSEattrText")) SSEattrFilterText; string $filterField = `textFieldGrp`; textFieldGrp -e -textChangedCommand ( "SSEFilterFieldCB (\"" + $edName + "\",\"" + $filterField + "\")") $filterField; // Create a tab layout to use as a big switch. // Put in empty layouts for the main switching items. // string $tabName = `tabLayout -tabsVisible true -preSelectCommand "SSEswitch" SSEtabs`; formLayout keyableSwitch; setParent ..; formLayout shapeKeyableSwitch; setParent ..; formLayout transformSwitch; setParent ..; formLayout translateSwitch; setParent ..; formLayout rotateSwitch; setParent ..; formLayout scaleSwitch; setParent ..; formLayout renderSwitch; setParent ..; formLayout tesselationSwitch; setParent ..; formLayout geometrySwitch; setParent ..; formLayout allSwitch; setParent ..; tabLayout -e -tabLabel keyableSwitch (uiRes("m_SpreadSheetWindow.kKeyable")) -tabLabel shapeKeyableSwitch (uiRes("m_SpreadSheetWindow.kShapeKeyable")) -tabLabel transformSwitch (uiRes("m_SpreadSheetWindow.kTransform")) -tabLabel translateSwitch (uiRes("m_SpreadSheetWindow.kTranslate")) -tabLabel rotateSwitch (uiRes("m_SpreadSheetWindow.kRotate")) -tabLabel scaleSwitch (uiRes("m_SpreadSheetWindow.kScale")) -tabLabel renderSwitch (uiRes("m_SpreadSheetWindow.kRender")) -tabLabel tesselationSwitch (uiRes("m_SpreadSheetWindow.kTessellation")) -tabLabel geometrySwitch (uiRes("m_SpreadSheetWindow.kGeometry")) -tabLabel allSwitch (uiRes("m_SpreadSheetWindow.kAll")) $tabName; setParent ..; // Attach the tab layout and spread sheet editor to the edges of // the form. // int $edBottomOffset = 0; if(`about -mac`) { // On Mac, the scrollbars are obscured by the windows resize handle. // So, add an offset while attaching the spread sheet editor // to the bottom of the form $edBottomOffset = 15; } formLayout -e -af SSEattrFilterText "top" 5 -ac $filterField "left" 0 SSEattrFilterText -ac $tabName "top" 0 $filterField -af $tabName "left" 0 -af $tabName "right" 0 -ac $edName "top" 0 SSEtabs -af $edName "left" 0 -af $edName "right" 0 -af $edName "bottom" $edBottomOffset $formName; int $sseLongName = 1; if (!`spreadSheetEditor -query -niceNames $edName`) { $sseLongName = (`spreadSheetEditor -query -longNames $edName` ? 2 : 0); } $menuName = `menu -label (uiRes("m_SpreadSheetWindow.kNames"))`; radioMenuItemCollection; menuItem -label (uiRes("m_SpreadSheetWindow.kNiceNames")) -radioButton ( 1 == $sseLongName ) -c ("spreadSheetEditor -e -nn true "+$edName) niceNameItem; menuItem -label (uiRes("m_SpreadSheetWindow.kLongNames")) -radioButton ( 2 == $sseLongName ) -c ("spreadSheetEditor -e -ln true -nn false "+$edName) longNameItem; menuItem -label (uiRes("m_SpreadSheetWindow.kShortNames")) -radioButton ( 0 == $sseLongName ) -c ("spreadSheetEditor -e -ln false -nn false "+$edName) shortNameItem; setParent -m ..; $userMenuName = `menu -label (uiRes("m_SpreadSheetWindow.kLayouts"))`; menuItem -label (uiRes("m_SpreadSheetWindow.kShowSelectedColumnsOnly")) -c ("SpreadSheetWindow_showSelCol " + $edName ); menuItem -label (uiRes("m_SpreadSheetWindow.kShowAllColumns")) -c "SSEswitch"; menuItem -label (uiRes("m_SpreadSheetWindow.kRememberThisLayout")) -c ("SSERememberWindow \"" + $edName + "\" \"" + $tabName + "\"" ); menuItem -label (uiRes("m_SpreadSheetWindow.kDeleteCurrentLayout")) -c ("SSERemove \""+$tabName+"\""); menu -label (uiRes("m_SpreadSheetWindow.kKey")); menuItem -label (uiRes("m_SpreadSheetWindow.kKeySelected")) -c ("spreadSheetEditor -e -execute \"setKeyframe -at \\\"#A\\\" \\\"#P\\\";\""+$edName); menu -label (uiRes("m_SpreadSheetWindow.kLayer")); menuItem -label (uiRes("m_SpreadSheetWindow.kCreateOverrideForSelected")) -c ("spreadSheetEditor -e -execute \"editRenderLayerAdjustment \\\"#P.#A\\\";\""+$edName); menuItem -label (uiRes("m_SpreadSheetWindow.kRemoveOverrideFromSelected")) -c ("spreadSheetEditor -e -execute \"editRenderLayerAdjustment -remove \\\"#P.#A\\\";\""+$edName); // Add support for the Context Sensitive Help Menu. // addContextHelpProc "SSEwindow" "buildSpreadsheetContextHelpItems"; doHelpMenu("SSEwindow", "SSEwindow"); // There may be more items defined in the prefs. There are two arrays of strings, // called SSEitem1 and SSEitem2, which are defined pair-wise, in pairs of // item-name, item-attr-list. There is also a third array of numbers, specifying // the state of the "show shapes" variable. // ie, SSEitem1[n] could be "trans X Y", and SSEitem2[n] would then be "{\"tx\",\"ty\"}" // Since these are attributes of the transform, SSEitem3[n] would be 0, indicating "Show Shapes" // should be turned off in this tab. if ( `optionVar -exists SSEitem1` && `optionVar -exists SSEitem2` && `optionVar -exists SSEitem3` ){ string $itemNames[] = `optionVar -q SSEitem1`; string $itemList[] = `optionVar -q SSEitem2`; int $itemShowShapes[] = `optionVar -q SSEitem3`; // they must be the same length if ( size($itemNames) == size($itemList) && size($itemNames) == size($itemShowShapes) ){ // Create tabs for each one // int $limit = size($itemNames); int $i; string $formName; for ( $i=0; $i<$limit; $i++ ){ $formName = `formLayout -p $tabName`; tabLayout -e -tl $formName $itemNames[$i] $tabName; } } else { // // The Spread Sheet Window prefs are bogus. Reset them so // they'll at least work again the next time a layout is saved. // optionVar -clearArray SSEitem1; optionVar -clearArray SSEitem2; optionVar -clearArray SSEitem3; } } if ("" != $gSSEWindow_Last_Tab) { // // Bug fix #142227. // // Search the tab labels for the one that we believe was the last // selected tab. // // Note we are now using the tab label instead of the layout // object name. Using the object name is just plain wrong since // you can't be sure that then next time your layout is created // it'll have the same name. // string $labelArray[]; int $index; $labelArray = `tabLayout -query -tabLabel $tabName`; for ($index = 0; $index < size($labelArray); $index++) { if ($gSSEWindow_Last_Tab == $labelArray[$index]) { // // Found it. // break; } } if ($index < size($labelArray)) { // // Found the tab. Select it. Note that UI command // indecies are 1-based. // tabLayout -edit -selectTabIndex ($index + 1) $tabName; } else { // // Didn't find the tab. Reset the last saved tab to an // empty string and select the first tab in the layout. // $gSSEWindow_Last_Tab = ""; tabLayout -edit -selectTabIndex 1 $tabName; } SSEswitch; } } global proc SSEFilterFieldCB( string $edName, string $filterField) { string $expr = `textFieldGrp -q -text $filterField`; spreadSheetEditor -e -attrRegExp $expr $edName; } global proc SSEswitch() // // This is called when the user clicks on one of the tabs in the spread // sheet editor. The editor is set up according to the tab name. // { string $tabName = "SSEtabs"; string $edName = "SSEd"; global string $gSSEWindow_Last_Tab; if ( `tabLayout -exists $tabName` ){ string $newTab = `tabLayout -q -selectTab $tabName`; // Bug fix #142227. Saving the name of the layout object is // wrong. You can't guarantee that the same object name will // be used for new layouts. Save the label name of the tab // instead. // string $tabNames[] = `tabLayout -query -tabLabel $tabName`; int $index = `tabLayout -query -selectTabIndex $tabName`; if ($index > 0 && $index <= size($tabNames)) { $gSSEWindow_Last_Tab = $tabNames[$index - 1]; } else { $gSSEWindow_Last_Tab = ""; } switch( $newTab ){ case "keyableSwitch": spreadSheetEditor -e -fal {} -keyableOnly true -showShapes false $edName; break; case "shapeKeyableSwitch": spreadSheetEditor -e -fal {} -keyableOnly true -showShapes true $edName; break; case "transformSwitch": spreadSheetEditor -e -fal {"tx","ty","tz","rx","ry","rz","sx","sy","sz"} -showShapes false -keyableOnly false $edName; break; case "translateSwitch": spreadSheetEditor -e -fal {"tx","ty","tz"} -showShapes false -keyableOnly false $edName; break; case "rotateSwitch": spreadSheetEditor -e -fal {"rx","ry","rz"} -showShapes false -keyableOnly false $edName; break; case "scaleSwitch": spreadSheetEditor -e -fal {"sx","sy","sz"} -showShapes false -keyableOnly false $edName; break; case "renderSwitch": spreadSheetEditor -e -fal {"ds","op","smo","mb","vir","vif","csh","rcsh","hot","hfm","vis","gao","gal","sso","ssa","msa","vso","vss","vbo","mvs","bscx","bscy","bscz", "ftwp", "gdsu", "gdsv", "fbda", "dsr", "xsr", "fth", "nat" } -showShapes true -keyableOnly false $edName; break; case "tesselationSwitch": spreadSheetEditor -e -fal { "eta", "nufa", "nvfa", "cvto", "ues", "esr", "drt", "mu","nu","mv", "numberV", "uch","ch","ucr","chr","uns","mns","es"} -showShapes true -keyableOnly false $edName; break; case "geometrySwitch": spreadSheetEditor -e -fal {"v","cpr","cps"} -showShapes true -keyableOnly false $edName; break; case "allSwitch": spreadSheetEditor -e -fal {} -showShapes false -keyableOnly false $edName; break; default: // The user has clicked on one of the user-defined tabs. // Get the name of the form layout, then find out what its // label is. This label will help us look up the option // variable with the specified set of attribute names. // Indirect, isn't it? // if ( $index <= size($tabNames) ){ string $lookupName = $tabNames[$index-1]; if ( `optionVar -exists SSEitem1` && `optionVar -exists SSEitem2` ){ string $itemNames[] = `optionVar -q SSEitem1`; string $itemList[] = `optionVar -q SSEitem2`; int $showShapes[] = `optionVar -q SSEitem3`; // Look up the tab name in the first array, set the spreadsheet // to use the list in the second array. // int $j; for ( $j=0; $j