// =========================================================================== // 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: 4 April 1997 // // Description: // This is a helper script to perform the "diskCache -append" command // using the corresponding option box values. // // // 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) { // Time range // if($forceFactorySettings || !`optionVar -exists appendHairCacheTimeRange`) { optionVar -intValue appendHairCacheTimeRange 2; } // startTime // if ($forceFactorySettings || !`optionVar -exists appendHairCacheStartTime`) { optionVar -floatValue appendHairCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists appendHairCacheEndTime`) { optionVar -floatValue appendHairCacheEndTime 10.0; } // sampling mode // if ($forceFactorySettings || !`optionVar -exists appendHairCacheSampling`) { optionVar -intValue appendHairCacheSampling 1; } // sampling rate // if( $forceFactorySettings ||! `optionVar -exists appendHairCacheSamplingRate` ) { optionVar -intValue appendHairCacheSamplingRate 1; } } // // Procedure Name: // appendHairCacheEnabling // // Description: // Set the enable state of start and end time fields. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that object names of the fields can be // successfully resolved. // // state - Enable state of the fields. // // Return Value: // None. // global proc appendHairCacheEnabling() { int $startEnd = ( `radioButtonGrp -q -sl appendHairCacheTimeRange4` == 1 ); floatFieldGrp -edit -enable $startEnd appendHairCacheStartEndTime; } // // Procedure Name: // appendHairCacheSetup // // 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 appendHairCacheSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query appendHairCacheTimeRange`; eval( "radioButtonGrp -e -select 1 appendHairCacheTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query appendHairCacheStartTime`; float $endTime = `optionVar -query appendHairCacheEndTime`; floatFieldGrp -edit -value1 $startTime -value2 $endTime appendHairCacheStartEndTime; // -increment // int $sampling = `optionVar -q appendHairCacheSampling` ; radioButtonGrp -edit -sl $sampling appendHairCacheSampling; int $samplingRate = `optionVar -q appendHairCacheSamplingRate` ; intSliderGrp -edit -v $samplingRate appendHairCacheSamplingRate; appendHairCacheEnabling(); } // // Procedure Name: // appendHairCacheCallback // // 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 appendHairCacheCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 2; if( `radioButtonGrp -q -sl appendHairCacheTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl appendHairCacheTimeRange2` ) { $timeRangeMode = 2; } else if( `radioButtonGrp -q -sl appendHairCacheTimeRange3` ) { $timeRangeMode = 3; } else if( `radioButtonGrp -q -sl appendHairCacheTimeRange4` ) { $timeRangeMode = 4; } optionVar -intValue appendHairCacheTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue appendHairCacheStartTime `floatFieldGrp -query -value1 appendHairCacheStartEndTime`; optionVar -floatValue appendHairCacheEndTime `floatFieldGrp -query -value2 appendHairCacheStartEndTime`; // sampling mode // optionVar -intValue appendHairCacheSampling `radioButtonGrp -query -sl appendHairCacheSampling`; // sampling rate // optionVar -intValue appendHairCacheSamplingRate `intSliderGrp -query -v appendHairCacheSamplingRate`; if( $doIt ) { performAppendHairCache 0; } } // // Procedure Name: // appendHairCacheOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc appendHairCacheOptions() { // Name of the command for this option box. // string $commandName = "appendHairCache"; // 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`; radioButtonGrp -label (uiRes("m_performAppendHairCache.kAppendTimeRange")) -nrb 1 -label1 (uiRes("m_performAppendHairCache.kCurrentTime")) -cc "appendHairCacheEnabling" appendHairCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl appendHairCacheTimeRange1 -label1 (uiRes("m_performAppendHairCache.kCurrentTimeSlider")) -cc "appendHairCacheEnabling" appendHairCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl appendHairCacheTimeRange1 -label1 (localizedUIComponentLabel("Time Slider")) -cc "appendHairCacheEnabling" appendHairCacheTimeRange3; radioButtonGrp -label "" -nrb 1 -scl appendHairCacheTimeRange1 -label1 (uiRes("m_performAppendHairCache.kStartEnd")) -cc "appendHairCacheEnabling" appendHairCacheTimeRange4; floatFieldGrp -nf 2 -label (uiRes("m_performAppendHairCache.kStartEndLabel")) appendHairCacheStartEndTime; separator -h 5 -style "none"; string $over = (uiRes("m_performAppendHairCache.kOver")); string $under = (uiRes("m_performAppendHairCache.kUnder")); radioButtonGrp -nrb 2 -label (uiRes("m_performAppendHairCache.kSampling")) -label1 $over -label2 $under appendHairCacheSampling; intSliderGrp -label (uiRes("m_performAppendHairCache.kRate")) -min 1 -max 5 -fmn 1 -fmx 100 -value 1 appendHairCacheSamplingRate; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAppendHairCache.kAppend")) -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. // setOptionBoxTitle (uiRes("m_performAppendHairCache.kAppendHairCacheOptions")); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "AppendToHairCache" ); // 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); string $cmd = "doAppendHairCache 1 { " + "\"" + `optionVar -query appendHairCacheTimeRange` + "\"" + ",\"" + `optionVar -query appendHairCacheStartTime` + "\"" + ",\"" + `optionVar -query appendHairCacheEndTime` + "\"" + ",\"" + `optionVar -query appendHairCacheSampling` + "\"" + ",\"" + `optionVar -query appendHairCacheSamplingRate` + "\"" + " };"; return $cmd; } // // Procedure Name: // performAppendHairCache // // 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: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performAppendHairCache(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: appendHairCacheOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }