// =========================================================================== // 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: 24 January 2006 // // Description: // This is a helper script to perform the "cacheFile -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 appendNclothCacheTimeRange`) { optionVar -intValue appendNclothCacheTimeRange 2; } // startTime // if ($forceFactorySettings || !`optionVar -exists appendNclothCacheStartTime`) { optionVar -floatValue appendnClothCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists appendNclothCacheEndTime`) { optionVar -floatValue appendNclothCacheEndTime 10.0; } // simulation rate // if ($forceFactorySettings || !`optionVar -exists appendNclothCacheSimulationRate`) { optionVar -floatValue appendNclothCacheSimulationRate 1; } // sampling rate // if( $forceFactorySettings ||! `optionVar -exists appendNclothCacheSampleMultiplier` ) { optionVar -intValue appendNclothCacheSampleMultiplier 1; } } // // Procedure Name: // appendNclothCacheEnabling // // 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 appendNclothCacheEnabling() { int $start = ( `radioButtonGrp -q -sl appendNclothCacheTimeRange6` == 1 ); int $end = $start || (`radioButtonGrp -q -sl appendNclothCacheTimeRange5` == 1); floatFieldGrp -edit -enable $start appendNclothCacheStartTime; floatFieldGrp -edit -enable $end appendNclothCacheEndTime; } // // Procedure Name: // appendNclothCacheSetup // // 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 appendNclothCacheSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query appendNclothCacheTimeRange`; eval( "radioButtonGrp -e -select 1 appendNclothCacheTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query appendNclothCacheStartTime`; float $endTime = `optionVar -query appendNclothCacheEndTime`; floatFieldGrp -edit -value1 $startTime appendNclothCacheStartTime; floatFieldGrp -edit -value1 $endTime appendNclothCacheEndTime; // Sampling information // float $simulation = `optionVar -q appendNclothCacheSimulationRate` ; floatFieldGrp -e -v1 $simulation appendNclothCacheSimulationRate ; int $samplingRate = `optionVar -q appendNclothCacheSampleMultiplier` ; intFieldGrp -edit -v1 $samplingRate appendNclothCacheSampleMultiplier ; appendNclothCacheEnabling(); } // // Procedure Name: // appendNclothCacheCallback // // 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 appendNclothCacheCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 2; if( `radioButtonGrp -q -sl appendNclothCacheTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl appendNclothCacheTimeRange2` ) { $timeRangeMode = 2; } else if( `radioButtonGrp -q -sl appendNclothCacheTimeRange3` ) { $timeRangeMode = 3; } else if( `radioButtonGrp -q -sl appendNclothCacheTimeRange4` ) { $timeRangeMode = 4; } else if( `radioButtonGrp -q -sl appendNclothCacheTimeRange5` ) { $timeRangeMode = 5; } else if( `radioButtonGrp -q -sl appendNclothCacheTimeRange6` ) { $timeRangeMode = 6; } optionVar -intValue appendNclothCacheTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue appendNclothCacheStartTime `floatFieldGrp -query -value1 appendNclothCacheStartTime`; optionVar -floatValue appendNclothCacheEndTime `floatFieldGrp -query -value1 appendNclothCacheEndTime`; // simulation rate // optionVar -floatValue appendNclothCacheSimulationRate `floatFieldGrp -query -v1 appendNclothCacheSimulationRate`; // sampling rate // optionVar -intValue appendNclothCacheSampleMultiplier `intFieldGrp -query -v1 appendNclothCacheSampleMultiplier`; if( $doIt ) { performAppendNclothCache 0; } } // // Procedure Name: // appendNclothCacheOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc appendNclothCacheOptions() { // Name of the command for this option box. // string $commandName = "appendNclothCache"; // 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_performAppendNclothCache.kAppendTimeRange")) -nrb 1 -l1 (uiRes("m_performAppendNclothCache.kCurrentTime")) -cc "appendNclothCacheEnabling" appendNclothCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl appendNclothCacheTimeRange1 -l1 (uiRes("m_performAppendNclothCache.kCurrentTimeToSliderEnd")) -cc "appendNclothCacheEnabling" appendNclothCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl appendNclothCacheTimeRange1 -l1 (localizedUIComponentLabel("Time Slider")) -cc "appendNclothCacheEnabling" appendNclothCacheTimeRange3; radioButtonGrp -label "" -nrb 1 -scl appendNclothCacheTimeRange1 -l1 (uiRes("m_performAppendNclothCache.kCacheEndToTimeSlider")) -cc "appendNclothCacheEnabling" appendNclothCacheTimeRange4; radioButtonGrp -label "" -nrb 1 -scl appendNclothCacheTimeRange1 -l1 (uiRes("m_performAppendNclothCache.kCacheEndToEnd")) -cc "appendNclothCacheEnabling" appendNclothCacheTimeRange5; radioButtonGrp -label "" -nrb 1 -scl appendNclothCacheTimeRange1 -l1 (uiRes("m_performAppendNclothCache.kStartEnd")) -cc "appendNclothCacheEnabling" appendNclothCacheTimeRange6; floatFieldGrp -nf 1 -label (uiRes("m_performAppendNclothCache.kStart")) appendNclothCacheStartTime; floatFieldGrp -nf 1 -label (uiRes("m_performAppendNclothCache.kEnd")) appendNclothCacheEndTime; separator -h 5 -style "none"; floatFieldGrp -label (uiRes("m_performAppendNclothCache.kSimulationRate")) -extraLabel (uiRes("m_performAppendNclothCache.kSimulationRateEnd")) -nf 1 appendNclothCacheSimulationRate; intFieldGrp -label (uiRes("m_performAppendNclothCache.kSampleMultiplier")) -extraLabel (uiRes("m_performAppendNclothCache.kSampleMultiplierEnd")) -nf 1 appendNclothCacheSampleMultiplier; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAppendNclothCache.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_performAppendNclothCache.kAppendOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "AppendToNclothCache" ); // 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); float $startTime, $endTime; return( "doAppendNclothCache " + `optionVar -query appendNclothCacheTimeRange` + " " + `optionVar -query appendNclothCacheStartTime` + " " + `optionVar -query appendNclothCacheEndTime` + " " + `optionVar -query appendNclothCacheSimulationRate` + " " + `optionVar -query appendNclothCacheSampleMultiplier` ); } // // Procedure Name: // performAppendNclothCache // // 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 performAppendNclothCache(int $action) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = `assembleCmd`; evalEcho($cmd); break; // Show the option box. // case 1: appendNclothCacheOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }