// =========================================================================== // 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: 9 July 2002 // // // Description: // This script defines the option box for the light points menu item. // // // 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) { // Number of Light Points if( $forceFactorySettings || !`optionVar -exists OFOC_NumberOfLightPoints`){ optionVar -intValue OFOC_NumberOfLightPoints 2; } // Directional Type if ($forceFactorySettings || !`optionVar -exists OFOC_LightType`){ optionVar -intValue OFOC_LightType 1; } // Color of Light Points if ($forceFactorySettings || !`optionVar -exists OFOC_LightColorR`){ optionVar -floatValue OFOC_LightColorR 1.0; } if ($forceFactorySettings || !`optionVar -exists OFOC_LightColorG`){ optionVar -floatValue OFOC_LightColorG 1.0; } if ($forceFactorySettings || !`optionVar -exists OFOC_LightColorB`){ optionVar -floatValue OFOC_LightColorB 1.0; } } // // Procedure Name: // fltLightsOnCurveSetup // // 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 fltLightsOnCurveSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. int $useGlobalTol = false; // Number of Light Points intFieldGrp -e -v1 `optionVar -q OFOC_NumberOfLightPoints` OFOC_NumberOfLightPoints; // Light Type optionMenuGrp -e -select `optionVar -q OFOC_LightType` OFOC_LightType; // Color of Light Points colorSliderGrp -e -rgb `optionVar -q OFOC_LightColorR` `optionVar -q OFOC_LightColorG` `optionVar -q OFOC_LightColorB` OFOC_LightColor; } // // Procedure Name: // fltLightsOnCurveCallback // // 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 fltLightsOnCurveCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. optionVar -intValue OFOC_NumberOfLightPoints `intFieldGrp -q -v1 OFOC_NumberOfLightPoints`; optionVar -intValue OFOC_LightType `optionMenuGrp -q -select OFOC_LightType`; float $lightColor[3] = `colorSliderGrp -q -rgb OFOC_LightColor`; optionVar -floatValue OFOC_LightColorR $lightColor[0]; optionVar -floatValue OFOC_LightColorG $lightColor[1]; optionVar -floatValue OFOC_LightColorB $lightColor[2]; if ($doIt) { performLightsOnCurve 0; addToRecentCommandQueue "performLightsOnCurve 0" "Lights On Curve"; } } // // Procedure Name: // lightsOnCurveOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc lightsOnCurveOptions() { // Name of the command for this option box. // string $commandName = "fltLightsOnCurve"; // 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($commandName); // 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 DefaultTemplate; // Turn on the wait cursor. // waitCursor -state 1; // STEP 4: Create option box contents. // =================================== // tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; picture -image "flticon.rgb" -annotation "Light Points Options"; intFieldGrp -label (uiRes("m_performLightsOnCurve.kNumberOfLightPoints")) OFOC_NumberOfLightPoints; optionMenuGrp -label (uiRes("m_performLightsOnCurve.kLightType")) OFOC_LightType; menuItem -label (uiRes("m_performLightsOnCurve.kOmnidirectional")); menuItem -label (uiRes("m_performLightsOnCurve.kUnidirectional")); menuItem -label (uiRes("m_performLightsOnCurve.kBidirectional")); colorSliderGrp -label (uiRes("m_performLightsOnCurve.kLightColor")) OFOC_LightColor; // 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. // Disable those buttons that are not applicable to the option box. // Attach actions to those buttons that are applicable to the option box. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performLightsOnCurve.kCreate")) -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_performLightsOnCurve.kLightsOnCurveOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "fltLightsOnCurve" ); // Set the current values of the option box. // ========================================= // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // ==================== // showOptionBox(); } // // Procedure Name: // lightsOnCurveHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string lightsOnCurveHelp() { return " Command: fltLightsOnCurve - create OpenFlight light points along a selected curve.\n"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "fltLightsOnCurve"; setOptionVars(false); $cmd = ($cmd + " " + `optionVar -q OFOC_NumberOfLightPoints` + " " + `optionVar -q OFOC_LightColorR` + " " + `optionVar -q OFOC_LightColorG` + " " + `optionVar -q OFOC_LightColorB` + ";objectMoveCommand"); return $cmd; } // // Procedure Name: // performLightsOnCurve // // Description: // Perform the fltLightsOnCurve 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 fltLightsOnCurve 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 performLightsOnCurve(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: lightsOnCurveOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }