// =========================================================================== // 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: 2012 // // Description: // Option box for createComponentNConstraint menu. // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // proc setOptionVars(int $forceFactorySettings) { if($forceFactorySettings || !`optionVar -exists createComponentNConstraintSingleEdge`) { optionVar -intValue createComponentNConstraintSingleEdge 0; } if($forceFactorySettings || !`optionVar -exists createComponentNConstraintComponent`) { optionVar -intValue createComponentNConstraintComponent 1; } if($forceFactorySettings || !`optionVar -exists createComponentNConstraintType`) { optionVar -intValue createComponentNConstraintType 1; } } // // Procedure Name: // performCreateComponentNConstraintSetup // // 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 performCreateComponentNConstraintSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; intSliderGrp -edit -v `optionVar -query createComponentNConstraintSingleEdge` createComponentNConstraintSingleEdge; optionMenuGrp -edit -sl `optionVar -query createComponentNConstraintComponent` createComponentNConstraintComponent ; optionMenuGrp -edit -sl `optionVar -query createComponentNConstraintType` createComponentNConstraintType ; createComponentNConstraintTypeDim; } // // Procedure Name: // performCreateComponentNConstraintCallback // // 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 performCreateComponentNConstraintCallback(string $parent, int $doIt) { setParent $parent; optionVar -intValue createComponentNConstraintSingleEdge `intSliderGrp -query -v createComponentNConstraintSingleEdge`; optionVar -intValue createComponentNConstraintComponent `optionMenuGrp -query -sl createComponentNConstraintComponent`; optionVar -intValue createComponentNConstraintType `optionMenuGrp -query -sl createComponentNConstraintType`; if( $doIt ) { performCreateComponentNConstraint 0 ; } } // // Procedure Name: // createComponentNConstraintTypeDim // // Description: // Disable/enable option box controls depending on // constraint type (Bend or Stretch) // // Input Arguments: // None. // // Return Value: // None. // global proc createComponentNConstraintTypeDim() { int $enable = (`optionMenuGrp -query -sl createComponentNConstraintType` == 1); optionMenuGrp -edit -enable $enable createComponentNConstraintComponent; } // // Procedure Name: // createComponentNConstraintOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createComponentNConstraintOptions() { // Name of the command for this option box. // string $commandName = "performCreateComponentNConstraint"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; tabLayout -tv false -scr true; string $parent = `columnLayout -adjustableColumn 1`; optionMenuGrp -label (uiRes("m_performCreateComponentNConstraint.kConstraintType")) -cc "createComponentNConstraintTypeDim" -cw 2 243 createComponentNConstraintType; menuItem -label (uiRes("m_performCreateComponentNConstraint.kStretch")); menuItem -label (uiRes("m_performCreateComponentNConstraint.kBend")); optionMenuGrp -label (uiRes("m_performCreateComponentNConstraint.kComponent")) -cw 2 243 createComponentNConstraintComponent; menuItem -label (uiRes("m_performCreateComponentNConstraint.kEdges")); menuItem -label (uiRes("m_performCreateComponentNConstraint.kCrosslinks")); menuItem -label (uiRes("m_performCreateComponentNConstraint.kEdgesAndCrosslinks")); intSliderGrp -label (uiRes("m_performCreateComponentNConstraint.kSingleEdge")) -field 1 -min 0 -max 4 -fieldMinValue 0 -fieldMaxValue 100 createComponentNConstraintSingleEdge; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateComponentNConstraint.kCreateConstraint")) -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. // string $label = (uiRes("m_performCreateComponentNConstraint.kDefaultLabel")); setOptionBoxTitle($label); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "CreateComponentNConstraint" ); // Pop the UI template // setUITemplate -popTemplate; // 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() { setOptionVars(false); int $comp = `optionVar -query createComponentNConstraintComponent`; int $type = `optionVar -query createComponentNConstraintType`; string $cmd = ("doCreateComponentNConstraint "+($comp!=2)+" "+($comp!=1)+" " + (`optionVar -query createComponentNConstraintSingleEdge`)+" "+($type==2) ); return $cmd; } // // Procedure Name: // performCreateComponentNConstraint // // Description: // Perform the 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 command with the current // option box values. // // Input Arguments: // action // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performCreateComponentNConstraint(int $action) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = assembleCmd (); eval($cmd); break; // Show the option box. // case 1: createComponentNConstraintOptions( ); break; // Return the command string. // case 2: setOptionVars (false); $cmd = assembleCmd( ); break; } return $cmd; }