// =========================================================================== // 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: August 13, 2003 // // Procedure Name: // lookThroughSelected // // Description: // Procedure to look through the selected object. // // Input Arguments: // action - do command, or show option box // panelName - name of the panel to look though object in // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Near clip // if ($forceFactorySettings || !`optionVar -exists ltsNearClip`) { optionVar -floatValue ltsNearClip 0.001; } // Far clip // if ($forceFactorySettings || !`optionVar -exists ltsFarClip`) { optionVar -floatValue ltsFarClip 1000.0; } } // // Procedure Name: // lookThroughSelectedSetup // // 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 lookThroughSelectedSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // Query the optionVar's and set the values into the controls // if (`floatSliderGrp -exists nearClipSlider`) { floatSliderGrp -edit -value `optionVar -query ltsNearClip` nearClipSlider; } if (`floatSliderGrp -exists farClipSlider`) { floatSliderGrp -edit -value `optionVar -query ltsFarClip` farClipSlider; } } // // Procedure Name: // lookThroughSelectedCallback // // 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 lookThroughSelectedCallback (string $panelName, string $parent, int $doIt) { setParent $parent; // Near clip // if (`floatSliderGrp -exists nearClipSlider`) { optionVar -floatValue ltsNearClip `floatSliderGrp -query -value nearClipSlider`; } // Far clip // if (`floatSliderGrp -exists farClipSlider`) { optionVar -floatValue ltsFarClip `floatSliderGrp -query -value farClipSlider`; } if ($doIt) { string $cmd = "lookThroughSelected 0 " + $panelName; eval( $cmd ); addToRecentCommandQueue $cmd "Look Through Selected"; } } proc string lookThroughSelectedBasic( string $tabLayout ) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; floatSliderGrp -label (uiRes("m_lookThroughSelected.kNearClipPlane")) -minValue 0.00001 -maxValue 1000.0 -fieldMaxValue 100000.0 -pre 4 -sliderStep 0.1 -v 000.1 nearClipSlider; floatSliderGrp -label (uiRes("m_lookThroughSelected.kFarClipPlane")) -minValue 0.00001 -maxValue 1000.0 -fieldMaxValue 100000.0 -pre 4 -sliderStep 10 -v 1000.0 farClipSlider; setParent ..; return $tabForm; } global proc lookThroughSelectedOptions ( string $panelName ) { // Name of the command for this option box // string $commandName = "lookThroughSelected"; // 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; setOptionBoxCommandName("lookThroughSelected"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; lookThroughSelectedBasic $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_lookThroughSelected.kLookThroughSelected")) -command ($callback + " " + $panelName + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $panelName +" " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_lookThroughSelected.kLookThroughSelectedOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "LookThroughSelected" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } proc string assembleCmd ( string $panelName ) { string $cmd; string $selected[] = `ls -selection`; if (size($selected) > 0) { setOptionVars( false ); $cmd = "lookThroughModelPanelClipped "; $cmd += $selected[0] + " "; $cmd += $panelName + " "; $cmd += `optionVar -query ltsNearClip` + " "; $cmd += `optionVar -query ltsFarClip` + ";"; } else { error (uiRes("m_lookThroughSelected.kErrorMsg")); } return $cmd; } // The action variable means // 0 - do the command // 1 - show the option box // // ** Drag command not available for panel menu items global proc string lookThroughSelected( int $action, string $panelName ) { string $cmd = ""; switch ($action) { case 0: // Execute the command // Retrieve the option settings // setOptionVars (false); // Get the command and print it in the command window $cmd = `assembleCmd $panelName`; // Execute the command with the option settings evalEcho($cmd); break; case 1: // Do the option box lookThroughSelectedOptions $panelName; break; } return $cmd; }