// =========================================================================== // 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: April 2000 // // Description: // // Option box for the paintRandom command // // // 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) { // SpansU V. // if ($forceFactorySettings || !`optionVar -exists paintRandomSpansU`) { optionVar -intValue paintRandomSpansU 4; } if ($forceFactorySettings || !`optionVar -exists paintRandomSpansV`) { optionVar -intValue paintRandomSpansV 4; } // ClipEdges. // if ($forceFactorySettings || !`optionVar -exists paintRandomClipEdges`) { optionVar -intValue paintRandomClipEdges 1; } // RandomOffset // if ($forceFactorySettings || !`optionVar -exists paintRandomRandomOffset`) { optionVar -floatValue paintRandomRandomOffset 0.5; } // StrokeLength // if ($forceFactorySettings || !`optionVar -exists paintStrokeLength`) { optionVar -floatValue paintStrokeLength 1.0; } // SampleDensity // if ($forceFactorySettings || !`optionVar -exists paintRandomSampleDensity`) { optionVar -floatValue paintRandomSampleDensity 1.0; } // Equalization if ($forceFactorySettings || !`optionVar -exists paintRandomEqualization`) { optionVar -intValue paintRandomEqualization 1; } // ShareOneBrush if ($forceFactorySettings || !`optionVar -exists paintRandomShareOneBrush`) { optionVar -intValue paintRandomShareOneBrush 1; } // SurfaceOffsetMin // if ($forceFactorySettings || !`optionVar -exists paintRandomSurfaceOffsetMin`) { optionVar -floatValue paintRandomSurfaceOffsetMin 0; } // SurfaceOffsetMax // if ($forceFactorySettings || !`optionVar -exists paintRandomSurfaceOffsetMax`) { optionVar -floatValue paintRandomSurfaceOffsetMax 0; } } // // Procedure Name: // paintRandomSetup // // 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 paintRandomSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // SpansU V. // intSliderGrp -edit -v `optionVar -query paintRandomSpansU` paintRandomSpansU; intSliderGrp -edit -v `optionVar -query paintRandomSpansV` paintRandomSpansV; // RandomOffset. // floatSliderGrp -edit -v `optionVar -query paintRandomRandomOffset` paintRandomRandomOffset; // StrokeLength. // floatSliderGrp -edit -v `optionVar -query paintStrokeLength` paintStrokeLength; // SampleDensity. // floatSliderGrp -edit -v `optionVar -query paintRandomSampleDensity` paintRandomSampleDensity; // SurfaceOffsetMin. // floatSliderGrp -edit -v `optionVar -query paintRandomSurfaceOffsetMin` paintRandomSurfaceOffsetMin; // SurfaceOffsetMax. // floatSliderGrp -edit -v `optionVar -query paintRandomSurfaceOffsetMax` paintRandomSurfaceOffsetMax; // ClipEdges V. // checkBoxGrp -edit -value1 `optionVar -query paintRandomClipEdges` paintRandomClipEdges; // Equalization. // checkBoxGrp -edit -value1 `optionVar -query paintRandomEqualization` paintRandomEqualization; // ShareOneBrush. // checkBoxGrp -edit -value1 `optionVar -query paintRandomShareOneBrush` paintRandomShareOneBrush; } // // Procedure Name: // paintRandomCallback // // 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 paintRandomCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // SpansU V. // optionVar -intValue paintRandomSpansU `intSliderGrp -query -v paintRandomSpansU`; optionVar -intValue paintRandomSpansV `intSliderGrp -query -v paintRandomSpansV`; // RandomOffset. // optionVar -floatValue paintRandomRandomOffset `floatSliderGrp -query -v paintRandomRandomOffset`; // StrokeLength. // optionVar -floatValue paintStrokeLength `floatSliderGrp -query -v paintStrokeLength`; // SampleDensity. // optionVar -floatValue paintRandomSampleDensity `floatSliderGrp -query -v paintRandomSampleDensity`; // Equalization. // optionVar -intValue paintRandomEqualization `checkBoxGrp -query -value1 paintRandomEqualization`; // ShareOneBrush. // optionVar -intValue paintRandomShareOneBrush `checkBoxGrp -query -value1 paintRandomShareOneBrush`; // SurfaceOffsetMin. // optionVar -floatValue paintRandomSurfaceOffsetMin `floatSliderGrp -query -v paintRandomSurfaceOffsetMin`; // SurfaceOffsetMax. // optionVar -floatValue paintRandomSurfaceOffsetMax `floatSliderGrp -query -v paintRandomSurfaceOffsetMax`; // ClipEdges. // optionVar -intValue paintRandomClipEdges `checkBoxGrp -query -value1 paintRandomClipEdges`; if ($doIt) { performPaintRandom 0; } } // // Procedure Name: // paintRandomOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc paintRandomOptions() { // Name of the command for this option box. // string $commandName = "paintRandom"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; intSliderGrp -label (uiRes("m_performPaintRandom.kSpansU")) -field 1 -min 0 -max 50 -fieldMinValue 0 -fieldMaxValue 10000 paintRandomSpansU; intSliderGrp -label (uiRes("m_performPaintRandom.kSpansV")) -field 1 -min 0 -max 50 -fieldMinValue 0 -fieldMaxValue 10000 paintRandomSpansV; floatSliderGrp -label (uiRes("m_performPaintRandom.kRandomOffset")) -field 1 -min 0 -max 2 -fieldMinValue -1000 -fieldMaxValue 1000 -pre 4 paintRandomRandomOffset; floatSliderGrp -label (uiRes("m_performPaintRandom.kStrokeLength")) -field 1 -min 0 -max 2 -fieldMinValue 0 -fieldMaxValue 100000 -pre 4 paintStrokeLength; floatSliderGrp -label (uiRes("m_performPaintRandom.kSimpleDensity")) -field 1 -min 0 -max 10 -fieldMinValue 0 -fieldMaxValue 10000 -pre 4 paintRandomSampleDensity; floatSliderGrp -label (uiRes("m_performPaintRandom.kSurfaceOffsetMin")) -field 1 -min -10 -max 10 -pre 4 paintRandomSurfaceOffsetMin; floatSliderGrp -label (uiRes("m_performPaintRandom.kSurfaceOffsetMax")) -field 1 -min -10 -max 10 -pre 4 paintRandomSurfaceOffsetMax; checkBoxGrp -ncb 1 -label1 (uiRes("m_performPaintRandom.kClipEdges")) paintRandomClipEdges; checkBoxGrp -ncb 1 -label1 (uiRes("m_performPaintRandom.kEqualization")) paintRandomEqualization; checkBoxGrp -ncb 1 -label1 (uiRes("m_performPaintRandom.kShareOneBrush")) paintRandomShareOneBrush; waitCursor -state 0; setUITemplate -popTemplate; // 'Create' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performPaintRandom.kPaintStrokes")) -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; setOptionBoxTitle (uiRes("m_performPaintRandom.kAutoPaintRandom")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "PaintRandom" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } // // Procedure Name: // paintRandomHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string paintRandomHelp() { return " Command: paintRandom - Automatically paint current brush in a random layout on selected surfaces.\n" + "Selection: nurbs surfaces"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "paintRandom"; setOptionVars(false); $cmd = ($cmd + " " + `optionVar -query paintRandomSpansU` + " " + `optionVar -query paintRandomSpansV` + " " + `optionVar -query paintStrokeLength` + " " + `optionVar -query paintRandomRandomOffset` + " " + `optionVar -query paintRandomSampleDensity` + " " + `optionVar -query paintRandomEqualization` + " " + `optionVar -query paintRandomSurfaceOffsetMin` + " " + `optionVar -query paintRandomSurfaceOffsetMax` + " " + `optionVar -query paintRandomClipEdges` + " " + `optionVar -query paintRandomShareOneBrush` ); return $cmd; } // // Procedure Name: // performPaintRandom // // Description: // Perform the paintRandom command using the corresponding // option values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performPaintRandom(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: $cmd = `assembleCmd`; eval($cmd); break; // Show the option box. // case 1: paintRandomOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }