// =========================================================================== // 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: Dec. 4/96 // // Description: // Option box dialog for 'flow' command // // // 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 flowDivisionsFront`) { optionVar -intValue flowDivisionsFront 5; } if ($forceFactorySettings || !`optionVar -exists flowDivisionsUp`) { optionVar -intValue flowDivisionsUp 2; } if ($forceFactorySettings || !`optionVar -exists flowDivisionsSide`) { optionVar -intValue flowDivisionsSide 2; } if ($forceFactorySettings || !`optionVar -exists flowAroundObject`) { optionVar -intValue flowAroundObject 1; } if ($forceFactorySettings || !`optionVar -exists flowLocalEffect`) { optionVar -intValue flowLocalEffect 0; } if ($forceFactorySettings || !`optionVar -exists flowLocalEffectFront`) { optionVar -intValue flowLocalEffectFront 2; } if ($forceFactorySettings || !`optionVar -exists flowLocalEffectUp`) { optionVar -intValue flowLocalEffectUp 2; } if ($forceFactorySettings || !`optionVar -exists flowLocalEffectSide`) { optionVar -intValue flowLocalEffectSide 2; } } // // Procedure Name: // flowEnabling // // Description: // Enable/disable the local effect widgets // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // state - Whether to enable or to disable the controls // // Return Value: // None. // global proc flowEnabling(string $parent, int $state) { setParent $parent; intFieldGrp -edit -enable $state effectFront; intFieldGrp -edit -enable $state effectUp; intFieldGrp -edit -enable $state effectSide; } // // Procedure Name: // flowTickBoxControl // // Description: // If the flow is object centered, then by default we want global // effect of the lattice on the object. // If the flow is curve centered, then by default we want local effect // of the lattice around the portion of the curve where the object is. // // The user can change these defaults, but this just forces the // "Local Effect" checkbox to a reasonable default when // the "Lattice Around" option is changed between Object and Curve. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // Return Value: // None. // global proc flowTickBoxControl(string $parent) { setParent $parent; if (1 == `radioButtonGrp -query -select object`) { checkBoxGrp -edit -value1 false local; flowEnabling($parent, false); } else { checkBoxGrp -edit -value1 true local; flowEnabling($parent, true); } } // // Procedure Name: // flowSetup // // 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 flowSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls intFieldGrp -edit -value1 `optionVar -query flowDivisionsFront` divisionsFront; intFieldGrp -edit -value1 `optionVar -query flowDivisionsUp` divisionsUp; intFieldGrp -edit -value1 `optionVar -query flowDivisionsSide` divisionsSide; if (1 == `optionVar -query flowAroundObject`) radioButtonGrp -edit -select 1 object; else radioButtonGrp -edit -select 2 object; int $useLocalEffect = `optionVar -query flowLocalEffect`; checkBoxGrp -edit -value1 $useLocalEffect local; intFieldGrp -edit -value1 `optionVar -query flowLocalEffectFront` effectFront; intFieldGrp -edit -value1 `optionVar -query flowLocalEffectUp` effectUp; intFieldGrp -edit -value1 `optionVar -query flowLocalEffectSide` effectSide; flowEnabling $parent $useLocalEffect; } // // Procedure Name: // flowCallback // // 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 flowCallback (string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and // then perform the command optionVar -intValue flowDivisionsFront `intFieldGrp -query -value1 divisionsFront`; optionVar -intValue flowDivisionsUp `intFieldGrp -query -value1 divisionsUp`; optionVar -intValue flowDivisionsSide `intFieldGrp -query -value1 divisionsSide`; if (1 == `radioButtonGrp -query -select object`) optionVar -intValue flowAroundObject 1; else optionVar -intValue flowAroundObject 0; optionVar -intValue flowLocalEffect `checkBoxGrp -query -value1 local`; optionVar -intValue flowLocalEffectFront `intFieldGrp -query -value1 effectFront`; optionVar -intValue flowLocalEffectUp `intFieldGrp -query -value1 effectUp`; optionVar -intValue flowLocalEffectSide `intFieldGrp -query -value1 effectSide`; if ($doIt) { performFlow false; addToRecentCommandQueue "performFlow false" "Flow"; } } // // Procedure Name: // flowOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc flowOptions () { string $commandName = "flow"; // 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: 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 DefaultTemplate; // STEP 3: Create option box contents. // =================================== // // Turn on the wait cursor. // waitCursor -state 1; // RECOMMENDATION: Place the UI in a scroll layout. If the // option box window is ever resized such that it's entire // contents is not visible then the scroll bars provided by the // scroll layout will allow the user to access the hidden UI. // tabLayout -scrollable true -tabsVisible false; string $parent = `columnLayout -adjustableColumn 1`; intFieldGrp -numberOfFields 1 -label (uiRes("m_performFlow.kDivisions")) divisionsFront; intFieldGrp -numberOfFields 1 -label (uiRes("m_performFlow.kUp")) divisionsUp; intFieldGrp -numberOfFields 1 -label (uiRes("m_performFlow.kSide")) divisionsSide; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performFlow.kLatticeAround")) -label1 (uiRes("m_performFlow.kObject")) -label2 (uiRes("m_performFlow.kCurve")) -onCommand ("flowTickBoxControl "+$parent) object; checkBoxGrp -numberOfCheckBoxes 1 -label1 (uiRes("m_performFlow.kLocalEffect")) -onCommand1 ("flowEnabling "+$parent+" #1") -offCommand1 ("flowEnabling "+$parent+" #1") local; intFieldGrp -numberOfFields 1 -label (uiRes("m_performFlow.kLocalEffectFron")) effectFront; intFieldGrp -numberOfFields 1 -label (uiRes("m_performFlow.kLocalEffectUp")) effectUp; intFieldGrp -numberOfFields 1 -label (uiRes("m_performFlow.kLocalEffectSide")) effectSide; // Turn off the wait cursor. // waitCursor -state 0; // Step 4: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 5: 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) -label (uiRes("m_performFlow.kFlow")) $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 6: Set the option box title. // ================================= // setOptionBoxTitle((uiRes("m_performFlow.kFlowPathOptions"))); // Step 7: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "FlowPathObject" ); // Step 8: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 9: 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() { string $cmd = ""; setOptionVars(false); $cmd = "flowObjects " + `optionVar -query flowDivisionsFront` + " " + `optionVar -query flowDivisionsUp` + " " + `optionVar -query flowDivisionsSide` + " " + `optionVar -query flowAroundObject` + " " + `optionVar -query flowLocalEffect` + " " + `optionVar -query flowLocalEffectFront` + " " + `optionVar -query flowLocalEffectUp` + " " + `optionVar -query flowLocalEffectSide`; return $cmd; } // // Procedure Name: // performFlow // // Description: // Perform the flow 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 flow command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performFlow (int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: flowOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }