// =========================================================================== // 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: Dec. 3/97 // // Description: // Option box dialog for 'Animation Sweep' // // Input Arguments: // int showOptionBox true - show the option box dialog // false - just execute the command // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists animsweepTSRange`) { optionVar -intValue animsweepTSRange 0; } if ($forceFactorySettings || !`optionVar -exists animsweepStartTime`) { optionVar -floatValue animsweepStartTime 1.0; } if ($forceFactorySettings || !`optionVar -exists animsweepEndTime`) { optionVar -floatValue animsweepEndTime 10.0; } if ($forceFactorySettings || !`optionVar -exists animsweepByTime`) { optionVar -floatValue animsweepByTime 1.0; } if ($forceFactorySettings || !`optionVar -exists animsweepUniform`) { optionVar -intValue animsweepUniform 1; } if ($forceFactorySettings || !`optionVar -exists animsweepClose`) { optionVar -intValue animsweepClose 0; } if ($forceFactorySettings || !`optionVar -exists animsweepDegree`) { optionVar -intValue animsweepDegree 3; } if ($forceFactorySettings || !`optionVar -exists animsweepCreatePolyset`) { optionVar -intValue animsweepCreatePolyset 0; } } // If $state is true, then "Start/End" is selected, and we enable the // Start/End fields. If $state is false, then "Time Slider" is selected, // and so we disable the Start/End fields. // global proc animsweepEnabling(string $parent, int $state) { setParent $parent; frameLayout -edit -enable $state animsweepStartEndFrame; } global proc animsweepSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls int $useTSRange = `optionVar -query animsweepTSRange`; if ($useTSRange == 1) radioButtonGrp -edit -select 1 tsRange; else radioButtonGrp -edit -select 2 tsRange; floatFieldGrp -edit -value1 `optionVar -query animsweepStartTime` startTime; floatFieldGrp -edit -value1 `optionVar -query animsweepEndTime` endTime; floatFieldGrp -edit -value1 `optionVar -query animsweepByTime` byTime; int $value; $value = `optionVar -query animsweepUniform`; if ($value == 1) radioButtonGrp -edit -select 1 uniform; else radioButtonGrp -edit -select 2 uniform; $value = `optionVar -query animsweepClose`; if ($value == 0) radioButtonGrp -edit -select 1 close; else radioButtonGrp -edit -select 2 close; $value = `optionVar -query animsweepDegree`; if ($value == 1) radioButtonGrp -edit -select 1 degree; else radioButtonGrp -edit -select 2 degree; $value = `optionVar -query animsweepCreatePolyset`; if ($value == 1) radioButtonGrp -edit -select 2 polyset; else radioButtonGrp -edit -select 1 polyset; animsweepEnabling $parent (!$useTSRange); } global proc animsweepCallback (string $parent, int $doIt) { setParent $parent; int $value; // Set the optionVar's from the control values, and then perform the command $value = `radioButtonGrp -query -select tsRange`; if ($value == 1) optionVar -intValue animsweepTSRange 1; else optionVar -intValue animsweepTSRange 0; optionVar -floatValue animsweepStartTime `floatFieldGrp -query -value1 startTime`; optionVar -floatValue animsweepEndTime `floatFieldGrp -query -value1 endTime`; optionVar -floatValue animsweepByTime `floatFieldGrp -query -value1 byTime`; $value = `radioButtonGrp -query -select uniform`; if ($value == 1) optionVar -intValue animsweepUniform 1; else optionVar -intValue animsweepUniform 0; $value = `radioButtonGrp -query -select close`; if ($value == 1) optionVar -intValue animsweepClose 0; else optionVar -intValue animsweepClose 1; $value = `radioButtonGrp -query -select degree`; if ($value == 1) optionVar -intValue animsweepDegree 1; else optionVar -intValue animsweepDegree 3; $value = `radioButtonGrp -query -select polyset`; if ($value == 1) optionVar -intValue animsweepCreatePolyset 0; else optionVar -intValue animsweepCreatePolyset 1; if ($doIt) { performAnimSweep false; addToRecentCommandQueue "performAnimSweep false" "AnimSweep"; } } proc string animsweepWidgets (string $parent) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performAnimSweep.kTimeRange")) -label1 (localizedUIComponentLabel("Time Slider")) -label2 (uiRes("m_performAnimSweep.kStartEnd")) -changeCommand2 ("animsweepEnabling "+ $parent+" #1") tsRange; frameLayout -borderVisible false -labelVisible false -collapsable true -collapse false animsweepStartEndFrame; columnLayout -adjustableColumn true; floatFieldGrp -label (uiRes("m_performAnimSweep.kStartTime")) startTime; floatFieldGrp -label (uiRes("m_performAnimSweep.kEndTime")) endTime; setParent ..; setParent ..; floatFieldGrp -label (uiRes("m_performAnimSweep.kByTime")) byTime; separator; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performAnimSweep.kParam")) -label1 (uiRes("m_performAnimSweep.kUniform")) -label2 (uiRes("m_performAnimSweep.kChordLength")) uniform; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performAnimSweep.kSurfDegree")) -label1 (uiRes("m_performAnimSweep.kLinear")) -label2 (uiRes("m_performAnimSweep.kCubic")) degree; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performAnimSweep.kSurface")) -label1 (uiRes("m_performAnimSweep.kOpen")) -label2 (uiRes("m_performAnimSweep.kClose")) close; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performAnimSweep.kOutputGeom")) -label1 (uiRes("m_performAnimSweep.kNurbs")) -label2 (uiRes("m_performAnimSweep.kPolygons")) polyset; return $tabForm; } proc animsweepOptions () { string $commandName = "animsweep"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // 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; setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -tabsVisible false -scrollable true; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; animsweepWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAnimSweep.kAnimSweep")) -command ($callback + " " + $parent + " " + 1) $applyBtn; dimWhen -false "SomethingSelected" $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_performAnimSweep.kAnimSweepOptions"))); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CreateAnimatedSweep" ); // 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() { string $cmd; setOptionVars(false); $cmd = "animSweep " + `optionVar -query animsweepStartTime` + " " + `optionVar -query animsweepEndTime` + " " + `optionVar -query animsweepTSRange` + " " + `optionVar -query animsweepByTime` + " " + `constructionHistory -query -toggle` + " " + `optionVar -query animsweepDegree` + " " + `optionVar -query animsweepUniform` + " " + `optionVar -query animsweepClose` + " " + `optionVar -query animsweepCreatePolyset`; return $cmd; } // // This option box does more than just execute a command. That is // because there is no 'animSweep' command per se. performAnimSweep // will, for each selected nurbs curve, perform the snapshot command, // followed by a loft command. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performAnimSweep (int $action) { string $cmd = ""; switch ($action) { // Execute the command // case 0: setOptionVars(false); $cmd = `assembleCmd`; eval($cmd); break; // Show the option box // case 1: animsweepOptions; break; // Get the command to execute (for dragging to the shelf) // case 2: setOptionVars(false); $cmd = `assembleCmd`; break; } return $cmd; }