// =========================================================================== // 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: January 11, 1997 // // Modified: 5 June, 1997 // By: jb // // Description: // Display Nurbs Smoothness->Custom option box script. // // Input Arguments: // bool if true show option box // if false perform command with current values // Return Value: // none // proc setOptionVars (int $forceFactorySettings) { // Objects Affected // if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomNurbsObjsAffected`) { optionVar -intValue dispSmthnessCustomNurbsObjsAffected 1; } // Geometry (Hull or Full) // if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomNurbsGmty`) { optionVar -intValue dispSmthnessCustomNurbsGmty 1; } // Patch Precision // if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomPatchU`) { optionVar -intValue dispSmthnessCustomPatchU 0; } if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomPatchV`) { optionVar -intValue dispSmthnessCustomPatchV 0; } // Wireframe smoothness // if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomWirePts`) { optionVar -intValue dispSmthnessCustomWirePts 4; } // Shaded smoothness // if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomShadedPts`) { optionVar -intValue dispSmthnessCustomShadedPts 1; } if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomShadedTess`) { optionVar -intValue dispSmthnessCustomShadedTess 0; } // Simplified Hull // if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomSimpHullU`) { optionVar -intValue dispSmthnessCustomSimpHullU 1; } if ($forceFactorySettings || !`optionVar -exists dispSmthnessCustomSimpHullV`) { optionVar -intValue dispSmthnessCustomSimpHullV 1; } } global proc displaySmoothnessCustomSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // NURBS related // // Objects Affected Radio Button // int $nurbsObjsAffected = `optionVar -q dispSmthnessCustomNurbsObjsAffected`; radioButtonGrp -e -sl $nurbsObjsAffected nurbsObjsAffectedRadio; // Geometry (Hull or Full) // radioButtonGrp -e -sl `optionVar -q dispSmthnessCustomNurbsGmty` nurbsGmtyRadio; // Patch Precision sliders // intSliderGrp -e -value `optionVar -q dispSmthnessCustomPatchU` patchPrecisionUSlider; intSliderGrp -e -value `optionVar -q dispSmthnessCustomPatchV` patchPrecisionVSlider; // Wireframe smoothness slider // intSliderGrp -e -value `optionVar -q dispSmthnessCustomWirePts` wirePtsSlider; // Shaded smoothness slider // intSliderGrp -e -value `optionVar -q dispSmthnessCustomShadedPts` shadedPtsSlider; checkBoxGrp -e -value1 `optionVar -q dispSmthnessCustomShadedTess` renderTessBox; // Simplified Hull sliders // intSliderGrp -e -value `optionVar -q dispSmthnessCustomSimpHullU` simpHullUSlider; intSliderGrp -e -value `optionVar -q dispSmthnessCustomSimpHullV` simpHullVSlider; } global proc displaySmoothnessCustomCallback (string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then perform the command // int $nurbsObjsAffected = `radioButtonGrp -q -sl nurbsObjsAffectedRadio`; optionVar -intValue dispSmthnessCustomNurbsObjsAffected $nurbsObjsAffected; optionVar -intValue dispSmthnessCustomNurbsGmty `radioButtonGrp -q -sl nurbsGmtyRadio`; optionVar -intValue dispSmthnessCustomPatchU `intSliderGrp -q -value patchPrecisionUSlider`; optionVar -intValue dispSmthnessCustomPatchV `intSliderGrp -q -value patchPrecisionVSlider`; optionVar -intValue dispSmthnessCustomWirePts `intSliderGrp -q -value wirePtsSlider`; optionVar -intValue dispSmthnessCustomShadedPts `intSliderGrp -q -value shadedPtsSlider`; optionVar -intValue dispSmthnessCustomShadedTess `checkBoxGrp -q -value1 renderTessBox`; optionVar -intValue dispSmthnessCustomSimpHullU `intSliderGrp -q -value simpHullUSlider`; optionVar -intValue dispSmthnessCustomSimpHullV `intSliderGrp -q -value simpHullVSlider`; if( $doIt ) { performDisplaySmoothnessCustom 0; addToRecentCommandQueue "performDisplaySmoothnessCustom 0" "DisplaySmoothnessCustom"; } } global proc displaySmoothnessCustomOptions () { // Name of the command for this option box // string $commandName = "displaySmoothnessCustom"; // Build the option box "methods" // string $callback = ($commandName + "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 - see STEP 8. // ============================================================== // 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 // // Objects Affected // radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performDisplaySmoothnessCustom.kObjectsAffected")) -label1 (uiRes("m_performDisplaySmoothnessCustom.kActive")) -label2 (uiRes("m_performDisplaySmoothnessCustom.kAll")) nurbsObjsAffectedRadio; // Geometry (Hull or Full) // radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performDisplaySmoothnessCustom.kGeometry")) -label1 (uiRes("m_performDisplaySmoothnessCustom.kFull")) -label2 (uiRes("m_performDisplaySmoothnessCustom.kHull")) nurbsGmtyRadio; // Wireframe related sliders // frameLayout -label (uiRes("m_performDisplaySmoothnessCustom.kWireframe")) -cl false -cll true; columnLayout -adj true; if( `isTrue SurfaceUIExists` ) { // Patch Precision sliders // intSliderGrp -label (uiRes("m_performDisplaySmoothnessCustom.kSurfaceDivSpanU")) -min 0 -max 32 -fmx 64 -step 1 -value 0 patchPrecisionUSlider; intSliderGrp -label (uiRes("m_performDisplaySmoothnessCustom.kSurfaceDivSpanV")) -min 0 -max 32 -fmx 64 -step 1 -value 0 patchPrecisionVSlider; } // Wireframe smoothness slider // intSliderGrp -label (uiRes("m_performDisplaySmoothnessCustom.kCurveDivPerSpan")) -min 0 -max 127 -fmx 127 -step 4 -value 4 wirePtsSlider; setParent ..; setParent ..; // Shaded smoothness slider // if( `isTrue SurfaceUIExists` ) { frameLayout -label (uiRes("m_performDisplaySmoothnessCustom.kShaded")) -cl false -cll true; columnLayout -adj true; // Render tess toggle checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performDisplaySmoothnessCustom.kDisplayRenderTessellation")) renderTessBox; intSliderGrp -label (uiRes("m_performDisplaySmoothnessCustom.kSurfaceDivPerSpan")) -min 1 -max 32 -fmx 64 -step 1 -value 1 shadedPtsSlider; setParent ..; setParent ..; // Simplified Hull sliders // frameLayout -label (uiRes("m_performDisplaySmoothnessCustom.kHullLayout")) -cl false -cll true; columnLayout -adj true; intSliderGrp -label (uiRes("m_performDisplaySmoothnessCustom.kHullSimplificationU")) -min 1 -max 16 -fmx 24 -step 1 -value 1 simpHullUSlider; intSliderGrp -label (uiRes("m_performDisplaySmoothnessCustom.kHullSimplificationV")) -min 1 -max 16 -fmx 24 -step 1 -value 1 simpHullVSlider; setParent ..; setParent ..; } // 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 -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; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performDisplaySmoothnessCustom.kNURBSSmoothnessCustomOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "NURBSSmoothnessCustom" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = ""; setOptionVars(false); int $nurbsObjsAffected =`optionVar -q dispSmthnessCustomNurbsObjsAffected`; int $nurbsGmty = `optionVar -q dispSmthnessCustomNurbsGmty`; int $patchU = `optionVar -q dispSmthnessCustomPatchU`; int $patchV = `optionVar -q dispSmthnessCustomPatchV`; int $wirePts = `optionVar -q dispSmthnessCustomWirePts`; int $shadedPts = `optionVar -q dispSmthnessCustomShadedPts`; int $shadedTess = `optionVar -q dispSmthnessCustomShadedTess`; int $hullU = `optionVar -q dispSmthnessCustomSimpHullU`; int $hullV = `optionVar -q dispSmthnessCustomSimpHullV`; // Work on the NURBS objects // if ($nurbsObjsAffected == 1) { // Change the smoothness of only the active NURBS objects // if ($nurbsGmty == 1) { // Actual geometry display // $cmd = "displaySmoothness -full -du " + $patchU + " -dv " + $patchV + " -pw " + $wirePts + " -ps " + $shadedPts + " -rt " + $shadedTess + ";"; } else { // Hull display // $cmd = "displaySmoothness -hull -su " + $hullU + " -sv " + $hullV + ";"; } } else { // Change the smoothness of all the NURBS objects // if ($nurbsGmty == 1) { // Actual geometry display // $cmd = $cmd + "displaySmoothness -all -full -du " + $patchU + " -dv " + $patchV + " -pw " + $wirePts + " -ps " + $shadedPts + " -rt " + $shadedTess + ";" ; } else { // Hull display // $cmd = "displaySmoothness -all -hull -su " + $hullU + " -sv " + $hullV + ";"; } } return $cmd; } // // Procedure Name: // performDisplaySmoothnessCustom // // Description: // Perform the DisplaySmoothnessCustom 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 DisplaySmoothnessCustom command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performDisplaySmoothnessCustom(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: displaySmoothnessCustomOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }