// =========================================================================== // 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: 04 Dec 2001 // // Description: // This script provides an option box dialog for the diskCache command // as used by fluids. // // 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 disableFluidsDiskCacheAttrs(string $parent) { setParent $parent; int $showStartEnd = `radioButtonGrp -query -sl fluidsDiskCacheTimeRange3`; if( $showStartEnd ) { floatFieldGrp -e -enable true fluidsDiskCacheStartEndTime; } else { floatFieldGrp -e -enable false fluidsDiskCacheStartEndTime; } int $doSegment = (`radioButtonGrp -q -sl fluidsDiskCacheDoSegment`-1); radioButtonGrp -e -enable (! $doSegment) fluidsDiskCacheSampling; intSliderGrp -e -enable (! $doSegment) fluidsDiskCacheSamplingRate; } proc setOptionVars(int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists fluidsDiskCacheTimeRange`) optionVar -intValue fluidsDiskCacheTimeRange 2; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCacheStartTime`) optionVar -floatValue fluidsDiskCacheStartTime 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCacheEndTime`) optionVar -floatValue fluidsDiskCacheEndTime 10; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCacheSampling`) optionVar -intValue fluidsDiskCacheSampling 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCacheSamplingRate`) optionVar -intValue fluidsDiskCacheSamplingRate 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBDensity`) optionVar -intValue fluidsDiskCachePBDensity 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBTemperature`) optionVar -intValue fluidsDiskCachePBTemperature 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBColor`) optionVar -intValue fluidsDiskCachePBColor 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBVelocity`) optionVar -intValue fluidsDiskCachePBVelocity 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBFuel`) optionVar -intValue fluidsDiskCachePBFuel 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBTextureCoords`) optionVar -intValue fluidsDiskCachePBTextureCoords 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCachePBFalloff`) optionVar -intValue fluidsDiskCachePBFalloff 1; if( $forceFactorySettings || !`optionVar -exists fluidsDiskCacheDoSegment`) optionVar -intValue fluidsDiskCacheDoSegment 0; } global proc fluidsDiskCacheSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; eval( "radioButtonGrp -e -sl 1 fluidsDiskCacheTimeRange" + `optionVar -query fluidsDiskCacheTimeRange` ); floatFieldGrp -e -v1 `optionVar -query fluidsDiskCacheStartTime` -v2 `optionVar -query fluidsDiskCacheEndTime` fluidsDiskCacheStartEndTime; radioButtonGrp -e -sl `optionVar -query fluidsDiskCacheSampling` fluidsDiskCacheSampling; intSliderGrp -e -v `optionVar -query fluidsDiskCacheSamplingRate` fluidsDiskCacheSamplingRate; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBDensity` fluidsDiskCachePBDensity; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBTemperature` fluidsDiskCachePBTemperature; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBColor` fluidsDiskCachePBColor; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBVelocity` fluidsDiskCachePBVelocity; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBFuel` fluidsDiskCachePBFuel; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBTextureCoords` fluidsDiskCachePBTextureCoords; checkBoxGrp -e -v1 `optionVar -query fluidsDiskCachePBFalloff` fluidsDiskCachePBFalloff; radioButtonGrp -e -sl (`optionVar -query fluidsDiskCacheDoSegment`+1) fluidsDiskCacheDoSegment; disableFluidsDiskCacheAttrs $parent; } global proc fluidsDiskCacheCallback(string $parent) { int $timeMode = 1; if( `radioButtonGrp -q -sl fluidsDiskCacheTimeRange1` ) { $timeMode = 1; } else if( `radioButtonGrp -q -sl fluidsDiskCacheTimeRange2` ) { $timeMode = 2; } else if( `radioButtonGrp -q -sl fluidsDiskCacheTimeRange3` ) { $timeMode = 3; } optionVar -iv fluidsDiskCacheTimeRange $timeMode; optionVar -fv fluidsDiskCacheStartTime `floatFieldGrp -q -v1 fluidsDiskCacheStartEndTime`; optionVar -fv fluidsDiskCacheEndTime `floatFieldGrp -q -v2 fluidsDiskCacheStartEndTime`; optionVar -iv fluidsDiskCacheSampling `radioButtonGrp -query -sl fluidsDiskCacheSampling`; optionVar -iv fluidsDiskCacheSamplingRate `intSliderGrp -q -v fluidsDiskCacheSamplingRate`; optionVar -iv fluidsDiskCachePBDensity `checkBoxGrp -q -v1 fluidsDiskCachePBDensity`; optionVar -iv fluidsDiskCachePBTemperature `checkBoxGrp -q -v1 fluidsDiskCachePBTemperature`; optionVar -iv fluidsDiskCachePBColor `checkBoxGrp -q -v1 fluidsDiskCachePBColor`; optionVar -iv fluidsDiskCachePBVelocity `checkBoxGrp -q -v1 fluidsDiskCachePBVelocity`; optionVar -iv fluidsDiskCachePBFuel `checkBoxGrp -q -v1 fluidsDiskCachePBFuel`; optionVar -iv fluidsDiskCachePBTextureCoords `checkBoxGrp -q -v1 fluidsDiskCachePBTextureCoords`; optionVar -iv fluidsDiskCachePBFalloff `checkBoxGrp -q -v1 fluidsDiskCachePBFalloff`; optionVar -iv fluidsDiskCacheDoSegment (`radioButtonGrp -q -sl fluidsDiskCacheDoSegment`-1); } global proc fluidsDiskCachemcfpCallback(string $parent) { fluidsDiskCacheCallback $parent; performFluidsDiskCache 0 mcfp; } global proc fluidsDiskCachemcfiCallback(string $parent) { fluidsDiskCacheCallback $parent; performFluidsDiskCache 0 mcfi; } proc creationOptionBox(string $cacheType) { // Name of the command for this option box // string $commandName = "fluidsDiskCache"; // Build the option box "methods" // string $callback = ($commandName + $cacheType + "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_performFluidsDiskCache.kCacheTimeRange")) -nrb 1 -label1 (uiRes("m_performFluidsDiskCache.kRenderSettings")) -cc ( "disableFluidsDiskCacheAttrs " + $parent ) fluidsDiskCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl fluidsDiskCacheTimeRange1 -cc ( "disableFluidsDiskCacheAttrs " + $parent ) -label1 (localizedUIComponentLabel("Time Slider")) fluidsDiskCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl fluidsDiskCacheTimeRange1 -label1 (uiRes("m_performFluidsDiskCache.kStartEndRadio")) -cc ( "disableFluidsDiskCacheAttrs " + $parent ) fluidsDiskCacheTimeRange3; floatFieldGrp -label (uiRes("m_performFluidsDiskCache.kStartEndFloat")) -nf 2 fluidsDiskCacheStartEndTime; separator -h 5 -style "none"; checkBoxGrp -label (uiRes("m_performFluidsDiskCache.kCache")) -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kDensity")) fluidsDiskCachePBDensity; checkBoxGrp -label "" -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kVelocity")) fluidsDiskCachePBVelocity; checkBoxGrp -label "" -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kTemperature")) fluidsDiskCachePBTemperature; checkBoxGrp -label "" -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kFuel")) fluidsDiskCachePBFuel; checkBoxGrp -label "" -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kColor")) fluidsDiskCachePBColor; checkBoxGrp -label "" -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kTextureCoord")) fluidsDiskCachePBTextureCoords; checkBoxGrp -label "" -ncb 1 -label1 (uiRes("m_performFluidsDiskCache.kFalloff")) fluidsDiskCachePBFalloff; separator -h 5 -style "none"; separator -h 5 ; separator -h 5 -style "none"; radioButtonGrp -nrb 2 -label (uiRes("m_performFluidsDiskCache.kCacheFormat")) -label1 (uiRes("m_performFluidsDiskCache.kSingleFile")) -label2 (uiRes("m_performFluidsDiskCache.kOneFilePerFrame")) -cc ( "disableFluidsDiskCacheAttrs " + $parent ) fluidsDiskCacheDoSegment; radioButtonGrp -nrb 2 -label (uiRes("m_performFluidsDiskCache.kSamplingMethod")) -label1 (uiRes("m_performFluidsDiskCache.kOver")) -label2 (uiRes("m_performFluidsDiskCache.kUnder")) fluidsDiskCacheSampling; intSliderGrp -label (uiRes("m_performFluidsDiskCache.kSamplingRate")) -min 1 -max 5 -fmn 1 -fmx 100 -value 1 fluidsDiskCacheSamplingRate; 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_performFluidsDiskCache.kCreate")) -command ($callback + " " + $parent) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit // Don't use $callback since that has cacheType specific // stuff in it and will cause the "save" button to execute // the fluidsDiskCacheCallback proc for that cacheType! // -command ($commandName+"Callback" + " " + $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_performFluidsDiskCache.kCreateCacheOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateFluidsCache" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " " + 0); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string creation(string $cacheType) { string $scene = `file -q -sceneName`; string $segmentPrefix = `basename $scene ""`; if( size( $segmentPrefix ) == 0 ) { $segmentPrefix = untitledFileName(); } int $segmentChunkSize = 1; return( "doFluidsDiskCache 2 { \"" + $cacheType + "\", " + `optionVar -query fluidsDiskCacheTimeRange` + ", " + `optionVar -query fluidsDiskCacheSampling` + ", " + `optionVar -query fluidsDiskCacheStartTime` + ", " + `optionVar -query fluidsDiskCacheEndTime` + ", " + `optionVar -query fluidsDiskCacheSamplingRate` + ", " + `optionVar -query fluidsDiskCachePBDensity` + ", " + `optionVar -query fluidsDiskCachePBVelocity` + ", " + `optionVar -query fluidsDiskCachePBTemperature` + ", " + `optionVar -query fluidsDiskCachePBFuel` + ", " + `optionVar -query fluidsDiskCachePBColor` + ", " + `optionVar -query fluidsDiskCachePBTextureCoords` + ", " + `optionVar -query fluidsDiskCachePBFalloff` + ", " + `optionVar -query fluidsDiskCacheDoSegment` + ", \"" + $segmentPrefix + "\", " + $segmentChunkSize + " " + "} " ); } global proc string performFluidsDiskCache( int $action, string $cacheType ) { if( $cacheType != "mcfi" && $cacheType != "mcfp" ) { error((uiRes("m_performFluidsDiskCache.kUseDeformJiggle"))); return ""; } string $cmd = ""; switch( $action ) { case 0: setOptionVars(false); $cmd = creation($cacheType); evalEcho($cmd); break; case 1: creationOptionBox $cacheType; break; case 2: setOptionVars(false); $cmd = creation($cacheType); break; } return $cmd; }