// =========================================================================== // 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. // =========================================================================== proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists polyBackfaceCullValue`) optionVar -intValue polyBackfaceCullValue 1; } proc polyBackfaceCullingSetupOption() { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; // Name of the command for this option box. string $commandName = "polyBackfaceCulling"; // Build the option box actions. string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. string $optionBoxTitle = (uiRes("m_polyBackfaceCulling.kCustomPolygonOptions")); setOptionBoxTitle($optionBoxTitle); // STEP 3: Activate the option box UI template. setUITemplate -pushTemplate OptionBoxTemplate; // STEP 4: Create option box contents. waitCursor -state 1; // Form layout string $parent = `formLayout polyBackfaceCullingOptions`; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_polyBackfaceCulling.kSettingsFrame"))`; radioButtonGrp -numberOfRadioButtons 3 -select 1 -vertical -label1 (uiRes("m_polyBackfaceCulling.kFull")) -label2 (uiRes("m_polyBackfaceCulling.kShowWire")) -label3 (uiRes("m_polyBackfaceCulling.kShowHardEdges")) polyObjBackfaceCullRadio; setParent $parent; // frameLayout setParent ..; // formLayout // Attach Description/Settings frames to form layout formLayout -edit -attachForm $settingsFrame "top" $gOptionBoxTemplateFrameSpacing -attachForm $settingsFrame "left" $gOptionBoxTemplateFrameSpacing -attachForm $settingsFrame "right" $gOptionBoxTemplateFrameSpacing -attachNone $settingsFrame "bottom" $parent; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. setUITemplate -popTemplate; // Step 6: Customize the buttons. string $applyBtn = getOptionBoxApplyBtn(); button -edit -command ($callback + " " + $parent + " " + 1) $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. setOptionBoxTitle($optionBoxTitle); // Step 8: Customize the 'Help' menu item text. setOptionBoxHelpTag( "BackfaceCulling" ); // Step 9: Set the current values of the option box. eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. showOptionBox(); } global proc polyBackfaceCullingSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; radioButtonGrp -edit -select `optionVar -query polyBackfaceCullValue` polyObjBackfaceCullRadio; } global proc polyBackfaceCullingCallback(string $parent, int $doIt) { setParent $parent; optionVar -intValue polyBackfaceCullValue `radioButtonGrp -query -select polyObjBackfaceCullRadio`; if ($doIt) { polyBackfaceCulling 0; addToRecentCommandQueue "polyBackfaceCulling 0" "polyOptions"; } } global proc string polyBackfaceCulling(int $option) { string $cmd=""; string $backFaceCull[] = {"-bc","-fb","-wbc","-hb"}; int $ival; switch ($option) { case 0: setOptionVars(false); $ival = `optionVar -query polyBackfaceCullValue`; $cmd =("polyOptions " + $backFaceCull[$ival]); eval($cmd); break; case 1: polyBackfaceCullingSetupOption; break; default: setOptionVars(false); $ival = `optionVar -query polyBackfaceCullValue`; $cmd =("polyOptions " + $backFaceCull[$ival]); eval($cmd); } return $cmd; }