// =========================================================================== // 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: 2003 // // Description: // This script provides an option box dialog for the diskCache command // as used by hair. // // Input Arguments: // boolean isCreationMode true - we are in creation mode // false - we are in deletion mode // boolean showOptionBox true - show the option box dialog // false - just execute the command // global proc disableHairDiskCacheAttrs(string $parent) { setParent $parent; string $showStartEnd = `radioButtonGrp -query -sl hairDiskCacheTimeRange3`; if( $showStartEnd ) { floatFieldGrp -e -enable true hairDiskCacheStartEndTime; } else { floatFieldGrp -e -enable false hairDiskCacheStartEndTime; } } proc setOptionVars(int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists hairDiskCacheTimeRange`) optionVar -intValue hairDiskCacheTimeRange 2; if( $forceFactorySettings || !`optionVar -exists hairDiskCacheStartTime`) optionVar -floatValue hairDiskCacheStartTime 1; if( $forceFactorySettings || !`optionVar -exists hairDiskCacheEndTime`) optionVar -floatValue hairDiskCacheEndTime 10; if( $forceFactorySettings || !`optionVar -exists hairDiskCacheSampling`) optionVar -intValue hairDiskCacheSampling 1; if( $forceFactorySettings || !`optionVar -exists hairDiskCacheSamplingRate`) optionVar -intValue hairDiskCacheSamplingRate 1; } global proc hairDiskCacheSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; eval( "radioButtonGrp -e -sl 1 hairDiskCacheTimeRange" + `optionVar -query hairDiskCacheTimeRange` ); floatFieldGrp -e -v1 `optionVar -query hairDiskCacheStartTime` -v2 `optionVar -query hairDiskCacheEndTime` hairDiskCacheStartEndTime; radioButtonGrp -e -sl `optionVar -query hairDiskCacheSampling` hairDiskCacheSampling; intSliderGrp -e -v `optionVar -query hairDiskCacheSamplingRate` hairDiskCacheSamplingRate; disableHairDiskCacheAttrs $parent; } global proc hairDiskCacheUICallback(string $parent) { int $timeMode = 1; if( `radioButtonGrp -q -sl hairDiskCacheTimeRange1` ) { $timeMode = 1; } else if( `radioButtonGrp -q -sl hairDiskCacheTimeRange2` ) { $timeMode = 2; } else if( `radioButtonGrp -q -sl hairDiskCacheTimeRange3` ) { $timeMode = 3; } optionVar -iv hairDiskCacheTimeRange $timeMode; optionVar -fv hairDiskCacheStartTime `floatFieldGrp -q -v1 hairDiskCacheStartEndTime`; optionVar -fv hairDiskCacheEndTime `floatFieldGrp -q -v2 hairDiskCacheStartEndTime`; optionVar -iv hairDiskCacheSampling `radioButtonGrp -query -sl hairDiskCacheSampling`; optionVar -iv hairDiskCacheSamplingRate `intSliderGrp -q -v hairDiskCacheSamplingRate`; } global proc hairDiskCacheCallback(string $parent) { hairDiskCacheUICallback($parent); performHairDiskCache 0; } proc creationOptionBox() { // Name of the command for this option box // string $commandName = "hairDiskCache"; // Build the option box "methods" // 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; // 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; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; // Create the widgets for this option box // radioButtonGrp -label (uiRes("m_performHairDiskCache.kCacheTimeRange")) -nrb 1 -label1 (uiRes("m_performHairDiskCache.kRenderSettings")) -cc ( "disableHairDiskCacheAttrs " + $parent ) hairDiskCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl hairDiskCacheTimeRange1 -cc ( "disableHairDiskCacheAttrs " + $parent ) -label1 (localizedUIComponentLabel("Time Slider")) hairDiskCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl hairDiskCacheTimeRange1 -label1 (uiRes("m_performHairDiskCache.kStartEnd")) -cc ( "disableHairDiskCacheAttrs " + $parent ) hairDiskCacheTimeRange3; floatFieldGrp -label (uiRes("m_performHairDiskCache.kStartEndLabel")) -nf 2 hairDiskCacheStartEndTime; separator -h 5 -style "none"; string $over = (uiRes("m_performHairDiskCache.kOver")); string $under = (uiRes("m_performHairDiskCache.kUnder")); radioButtonGrp -nrb 2 -label (uiRes("m_performHairDiskCache.kSampling")) -label1 $over -label2 $under hairDiskCacheSampling; intSliderGrp -label (uiRes("m_performHairDiskCache.kRate")) -min 1 -max 5 -fmn 1 -fmx 100 -value 1 hairDiskCacheSamplingRate; separator -h 5 -style "none"; // 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 -label (uiRes("m_performHairDiskCache.kCreate")) -command ($callback + " " + $parent) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($commandName+"UICallback" + " " + $parent + "; hideOptionBox") $saveBtn; // 'Reset' button string $resetBtn = getOptionBoxResetBtn(); int $resetToDefaults = 1; button -edit -command ($setup + " " + $parent + " " + $resetToDefaults) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performHairDiskCache.kCreateCacheOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateHairCache" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " " + 0); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string creation() { return( "doHairDiskCache 1 { \"" + `optionVar -query hairDiskCacheTimeRange` + "\", " + `optionVar -query hairDiskCacheSampling` + ", " + `optionVar -query hairDiskCacheStartTime` + ", " + `optionVar -query hairDiskCacheEndTime` + ", " + `optionVar -query hairDiskCacheSamplingRate` + " } " ); } global proc string performHairDiskCache( int $action ) { string $cmd = ""; switch( $action ) { case 0: setOptionVars(false); $cmd = creation(); evalEcho($cmd); break; case 1: creationOptionBox(); break; case 2: setOptionVars(false); $cmd = creation(); break; } return $cmd; }