// =========================================================================== // 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: 10 Oct 2000 // // Description: // This script provides an option box dialog for the diskCache command. // // 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 disableDiskCacheAttrs(string $parent) { setParent $parent; string $showStartEnd = `radioButtonGrp -query -sl createDiskCacheTimeRange3`; if( $showStartEnd ) { floatFieldGrp -e -enable true createDiskCacheStartEndTime; } else { floatFieldGrp -e -enable false createDiskCacheStartEndTime; } } proc setOptionVars(int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists createDiskCacheTimeRange`) optionVar -intValue createDiskCacheTimeRange 2; if( $forceFactorySettings || !`optionVar -exists createDiskCacheStartTime`) optionVar -floatValue createDiskCacheStartTime 1; if( $forceFactorySettings || !`optionVar -exists createDiskCacheEndTime`) optionVar -floatValue createDiskCacheEndTime 10; if( $forceFactorySettings || !`optionVar -exists createDiskCacheSampling`) optionVar -intValue createDiskCacheSampling 1; if( $forceFactorySettings || !`optionVar -exists createDiskCacheSamplingRate`) optionVar -intValue createDiskCacheSamplingRate 1; } global proc createDiskCacheSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; eval( "radioButtonGrp -e -sl 1 createDiskCacheTimeRange" + `optionVar -query createDiskCacheTimeRange` ); floatFieldGrp -e -v1 `optionVar -query createDiskCacheStartTime` -v2 `optionVar -query createDiskCacheEndTime` createDiskCacheStartEndTime; radioButtonGrp -e -sl `optionVar -query createDiskCacheSampling` createDiskCacheSampling; intSliderGrp -e -v `optionVar -query createDiskCacheSamplingRate` createDiskCacheSamplingRate; disableDiskCacheAttrs $parent; } global proc createDiskCacheCallback(string $parent) { int $timeMode = 1; if( `radioButtonGrp -q -sl createDiskCacheTimeRange1` ) { $timeMode = 1; } else if( `radioButtonGrp -q -sl createDiskCacheTimeRange2` ) { $timeMode = 2; } else if( `radioButtonGrp -q -sl createDiskCacheTimeRange3` ) { $timeMode = 3; } optionVar -iv createDiskCacheTimeRange $timeMode; optionVar -fv createDiskCacheStartTime `floatFieldGrp -q -v1 createDiskCacheStartEndTime`; optionVar -fv createDiskCacheEndTime `floatFieldGrp -q -v2 createDiskCacheStartEndTime`; optionVar -iv createDiskCacheSampling `radioButtonGrp -query -sl createDiskCacheSampling`; optionVar -iv createDiskCacheSamplingRate `intSliderGrp -q -v createDiskCacheSamplingRate`; } global proc createDiskCachemcjCallback(string $parent) { createDiskCacheCallback $parent; performDiskCache true false mcj; } proc creationOptionBox(string $cacheType) { // Name of the command for this option box // string $commandName = "createDiskCache"; // 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_performDiskCache.kCacheTimeRange")) -nrb 1 -label1 (uiRes("m_performDiskCache.kRenderSettings")) -cc ( "disableDiskCacheAttrs " + $parent ) createDiskCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl createDiskCacheTimeRange1 -cc ( "disableDiskCacheAttrs " + $parent ) -label1 (localizedUIComponentLabel("Time Slider")) createDiskCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl createDiskCacheTimeRange1 -label1 (uiRes("m_performDiskCache.kStartEndOption")) -cc ( "disableDiskCacheAttrs " + $parent ) createDiskCacheTimeRange3; floatFieldGrp -label (uiRes("m_performDiskCache.kStartEndValue")) -nf 2 createDiskCacheStartEndTime; separator -h 5 -style "none"; string $over = (uiRes("m_performDiskCache.kOver")); string $under = (uiRes("m_performDiskCache.kUnder")); radioButtonGrp -nrb 2 -label (uiRes("m_performDiskCache.kSampling")) -label1 $over -label2 $under createDiskCacheSampling; intSliderGrp -label (uiRes("m_performDiskCache.kRate")) -min 1 -max 5 -fmn 1 -fmx 100 -value 1 createDiskCacheSamplingRate; // 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_performDiskCache.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 createDiskCache 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_performDiskCache.kCreateDiskCacheOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateJiggleDiskCache" ); // 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 $cmd; // do nothing if therre is no diskCache string $allDiskCaches[] = `ls -type "diskCache"`; if( size($allDiskCaches) < 1 ) { string $msg = (uiRes("m_performDiskCache.kNoDiskCacheWarn")); warning $msg; return $cmd; } // Verify all diskCache files have unique names int $n, $m; for($n = 1; $n < size($allDiskCaches); $n++) { string $cacheName = `getAttr ($allDiskCaches[$n] + ".cacheName")`; if( size($cacheName) == 0 ) $cacheName = `getAttr ($allDiskCaches[$n] + ".hiddenCacheName")`; for( $m = 0; $m < $n; $m++) { string $preCacheName = `getAttr ($allDiskCaches[$m] + ".cacheName")`; if( size($preCacheName) == 0 ) $prevCacheName = `getAttr ($allDiskCaches[$m] + ".hiddenCacheName")`; if( $cacheName == $preCacheName ) { string $msg = (uiRes("m_performDiskCache.kDiskCacheCreationError")); error (`format -s $allDiskCaches[$m] -s $allDiskCaches[$n] $msg`); return $cmd; } } } verifyWorkspaceFileRule( "diskCache", "data" ); float $startTime = 0.0; float $endTime = 0.0; int $rangeMode = `optionVar -query createDiskCacheTimeRange`; if( $rangeMode == 1 ) { // Render Globals $startTime = `getAttr defaultRenderGlobals.startFrame`; $endTime = `getAttr defaultRenderGlobals.endFrame`; } else if( $rangeMode == 2 ) { // Time Slider $startTime = `playbackOptions -q -min`; $endTime = `playbackOptions -q -max`; } else if( $rangeMode == 3 ) { // Start/End $startTime = `optionVar -query createDiskCacheStartTime`; $endTime = `optionVar -query createDiskCacheEndTime`; } string $samplingType = ""; if( `optionVar -query createDiskCacheSampling` == 1 ) { $samplingType = "-os"; } int $samplingRate =`optionVar -query createDiskCacheSamplingRate`; $cmd = "diskCache" + " -st " + $startTime + " -et " + $endTime + " " + $samplingType + " -ct " + $cacheType + " -sr " + $samplingRate; // Only affect enabled cache nodes. // $cmd = $cmd + " -enabledCachesOnly "; return $cmd; } global proc string performDiskCache( int $isCreation, int $showOptionBox, string $cacheType ) { if( $cacheType != "mcj" ) { error (uiRes("m_performDiskCache.kPerformDiskCacheError")); return ""; } string $cmd = ""; if( $isCreation ) { if( $showOptionBox ) creationOptionBox $cacheType; else { setOptionVars(false); $cmd = creation($cacheType); evalEcho($cmd); } } else { // is deletion // delete all disk cache files $cmd = "diskCache -d"; evalEcho($cmd); } return $cmd; }