// =========================================================================== // 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. // =========================================================================== // // Description: // An option window used to create a dagContainer. // // // 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) { if ($forceFactorySettings || !`optionVar -exists dagContIncludeNetwork`) { // include network by default optionVar -intValue dagContIncludeNetwork 1; } if ($forceFactorySettings || !`optionVar -exists dagContHistory`) { // include history by default optionVar -intValue dagContHistory 1; } if ($forceFactorySettings || !`optionVar -exists dagContChannels`) { // include channels by default optionVar -intValue dagContChannels 1; } if ($forceFactorySettings || !`optionVar -exists dagContExpressions`) { // do not include expressions by default optionVar -intValue dagContExpressions 0; } if ($forceFactorySettings || !`optionVar -exists dagContSDKs`) { // do not include SDKs by default optionVar -intValue dagContSDKs 0; } if ($forceFactorySettings || !`optionVar -exists dagContAllInputs`) { // do not include all inputs by default optionVar -intValue dagContAllInputs 0; } if ($forceFactorySettings || !`optionVar -exists dagContOutputs`) { // do not include all outputs by default optionVar -intValue dagContOutputs 0; } if ($forceFactorySettings || !`optionVar -exists dagContIncludeShaders`) { // do not include shaders by default optionVar -intValue dagContIncludeShaders 0; } if ($forceFactorySettings || !`optionVar -exists dagContOperation`) { // 1: (default) create dagCont // 2: select optionVar -intValue dagContOperation 1; } if ($forceFactorySettings || !`optionVar -exists dagContIncludeNetwork`) { // include network by default optionVar -intValue dagContIncludeNetwork 1; } } // // Procedure Name: // createDagContainerSetup // // 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 createDagContainerSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; int $includeNet = `optionVar -query dagContIncludeNetwork`; checkBoxGrp -edit -value1 $includeNet includeConnWidget; int $allInputs = `optionVar -query dagContAllInputs`; if ( $includeNet) { // If the "Include These Inputs" box is enabled, then enable // and reset the sub options. Otherwise disable the suboptions // and turn them off. checkBoxGrp -edit -v1 `optionVar -query dagContAllInputs` dagAstInputsBox; checkBoxGrp -edit -en ($allInputs == 0) -v1 `optionVar -query dagContHistory` dagAstHistoryBox; checkBoxGrp -edit -en ($allInputs == 0) -v1 `optionVar -query dagContChannels` dagAstChannelsBox; checkBoxGrp -edit -en ($allInputs == 0) -v1 `optionVar -query dagContExpressions` dagAstExpressionsBox; checkBoxGrp -edit -en ($allInputs == 0) -v1 `optionVar -query dagContSDKs` dagAstSDKBox; } else { checkBoxGrp -e -en off -v1 false dagAstHistoryBox; checkBoxGrp -e -en off -v1 false dagAstChannelsBox; checkBoxGrp -e -en off -v1 false dagAstExpressionsBox; checkBoxGrp -e -en off -v1 false dagAstSDKBox; checkBoxGrp -e -en off -v1 false dagAstInputsBox; } checkBoxGrp -edit -en on -v1 `optionVar -query dagContOutputs` dagAstOutputsBox; int $includeSh = `optionVar -query dagContIncludeShaders`; checkBoxGrp -edit -value1 $includeSh includeShaderWidget; int $op = `optionVar -query dagContOperation`; radioButtonGrp -edit -sl $op dagContOperation; } // // Procedure Name: // createDagContainerCallback // // 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 createDagContainerCallback(string $parent, int $doIt) { setParent $parent; int $includeNetwork = `checkBoxGrp -q -value1 includeConnWidget`; optionVar -intValue dagContIncludeNetwork $includeNetwork; optionVar -iv dagContHistory `checkBoxGrp -q -v1 dagAstHistoryBox`; optionVar -iv dagContChannels `checkBoxGrp -q -v1 dagAstChannelsBox`; optionVar -iv dagContExpressions `checkBoxGrp -q -v1 dagAstExpressionsBox`; optionVar -iv dagContAllInputs `checkBoxGrp -q -v1 dagAstInputsBox`; optionVar -iv dagContSDKs `checkBoxGrp -q -v1 dagAstSDKBox`; optionVar -iv dagContOutputs `checkBoxGrp -q -v1 dagAstOutputsBox`; int $includeSh = `checkBoxGrp -q -value1 includeShaderWidget`; optionVar -intValue dagContIncludeShaders $includeSh; optionVar -intValue dagContOperation `radioButtonGrp -query -sl dagContOperation`; if ($doIt) { performCreateDagContainer 0; addToRecentCommandQueue "performCreateDagContainer 0" "Create Container As Group"; } } // // Procedure Name: // createDagContainerOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createDagContainerOptions() { global int $gOptionBoxTemplateDescriptionMarginWidth; global int $gOptionBoxTemplateFrameSpacing; // Name of the command for this option box. // string $commandName = "createDagContainer"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: 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; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName("container"); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate OptionBoxTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; scrollLayout; string $parent = `formLayout`; string $operationFrame = `frameLayout -collapsable 0 -label (uiRes("m_performCreateDagContainer.kAssetTransformEffect")) -mw $gOptionBoxTemplateDescriptionMarginWidth`; columnLayout; radioButtonGrp -vr -label (uiRes("m_performCreateDagContainer.kOperation")) -numberOfRadioButtons 2 -label1 (uiRes("m_performCreateDagContainer.kOperation1")) -label2 (uiRes("m_performCreateDagContainer.kOperation2")) dagContOperation; setParent $parent; string $optionFrame = `frameLayout -collapsable 0 -label (uiRes("m_performCreateDagContainer.kOptionFrame")) -mw $gOptionBoxTemplateDescriptionMarginWidth`; columnLayout; checkBoxGrp -cw 2 240 -ncb 1 -label "" -label1 (uiRes("m_performCreateDagContainer.kIncludeTheseInputs")) -onCommand ("checkBoxGrp -e -enable on dagAstHistoryBox;"+ "checkBoxGrp -e -enable on dagAstChannelsBox;"+ "checkBoxGrp -e -enable on dagAstExpressionsBox;"+ "checkBoxGrp -e -enable on dagAstSDKBox;" + "checkBoxGrp -e -enable on dagAstInputsBox;") -offCommand ("checkBoxGrp -e -enable off dagAstHistoryBox;"+ "checkBoxGrp -e -enable off dagAstChannelsBox;"+ "checkBoxGrp -e -enable off dagAstExpressionsBox;"+ "checkBoxGrp -e -enable off dagAstSDKBox;"+ "checkBoxGrp -e -enable off dagAstInputsBox;") includeConnWidget; columnLayout exportOptionColumn; checkBoxGrp -ncb 1 -cw 1 175 -label "" -label1 (uiRes("m_performCreateDagContainer.kHistory")) dagAstHistoryBox; checkBoxGrp -ncb 1 -cw 1 175 -label "" -label1 (uiRes("m_performCreateDagContainer.kChannels")) dagAstChannelsBox; checkBoxGrp -ncb 1 -cw 1 175 -label "" -label1 (uiRes("m_performCreateDagContainer.kSDKs")) dagAstSDKBox; checkBoxGrp -ncb 1 -cw 1 175 -label "" -label1 (uiRes("m_performCreateDagContainer.kExpressions")) dagAstExpressionsBox; checkBoxGrp -ncb 1 -cw 1 175 -label "" -label1 (uiRes("m_performCreateDagContainer.kAllInputs")) -onCommand ("checkBoxGrp -e -enable 0 dagAstHistoryBox;"+ "checkBoxGrp -e -enable 0 dagAstChannelsBox;"+ "checkBoxGrp -e -enable 0 dagAstExpressionsBox;"+ "checkBoxGrp -e -enable 0 dagAstSDKBox;") -offCommand ("checkBoxGrp -e -enable 1 dagAstHistoryBox;"+ "checkBoxGrp -e -enable 1 dagAstChannelsBox;"+ "checkBoxGrp -e -enable 1 dagAstExpressionsBox;"+ "checkBoxGrp -e -enable 1 dagAstSDKBox;") dagAstInputsBox; setParent ".."; checkBoxGrp -cw 2 240 -ncb 1 -label "" -label1 (uiRes("m_performCreateDagContainer.kIncludeShaders")) -annotation (uiRes("m_performCreateDagContainer.kConnectedShadersAnnot")) includeShaderWidget; checkBoxGrp -cw 2 240 -ncb 1 -label "" -label1 (uiRes("m_performCreateDagContainer.kIncludeOutputs")) dagAstOutputsBox; setParent $parent; formLayout -e -af $operationFrame "top" $gOptionBoxTemplateFrameSpacing -af $operationFrame "left" $gOptionBoxTemplateFrameSpacing -af $operationFrame "right" $gOptionBoxTemplateFrameSpacing -an $operationFrame "bottom" -ac $optionFrame "top" $gOptionBoxTemplateFrameSpacing $operationFrame -af $optionFrame "left" $gOptionBoxTemplateFrameSpacing -af $optionFrame "right" $gOptionBoxTemplateFrameSpacing -an $optionFrame "bottom" $parent; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -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; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performCreateDagContainer.kCreateDagContainerOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateDagContainer" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd; setOptionVars(false); $cmd += "container -type dagContainer "; // create the container command string if (`optionVar -q dagContAllInputs`) { $cmd += "-ind \"inputs\" "; } else { if (`optionVar -q dagContHistory`) { $cmd += "-ind \"history\" "; } if (`optionVar -q dagContChannels`) { $cmd += "-ind \"channels\" "; } if (`optionVar -q dagContExpressions`) { $cmd += "-ind \"expressions\" "; } if (`optionVar -q dagContSDKs`) { $cmd += "-ind \"sdks\" "; } } if (`optionVar -q dagContOutputs`) { $cmd += "-ind \"outputs\" "; } if (`optionVar -q dagContIncludeShaders`) { $cmd += "-includeShaders "; } $cmd += "-includeHierarchyBelow -includeTransform "; if (2 == `optionVar -q dagContOperation`) { // select proposed container contents only // $cmd += "-preview "; } $cmd += "-force -addNode `ls -sl`;"; return $cmd; } // // Procedure Name: // performCreateDagContainer // // Description: // Perform the create container command 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 the optionBoxExample1 command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performCreateDagContainer(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: createDagContainerOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }