// =========================================================================== // 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: 30 July 1996 // // // Procedure Name: // fitPanel // // Description: // Procedure to do a view fit in the pane under the // pointer. Currently this script can be used on model and graph // panes, and the view can be fit to either selected or all // objects depending on the fitType argument. // // Only one panel will be affected by this operation. // // Input Arguments: // fitType can be either "-all" or "-selectedNoChildren" or "-selected". // // Return Value: // None. // global proc fitPanel ( string $fitType ) { string $panel = `getPanel -up`; // Bug fix #138175. Problems arise when using the Hotbox. // The cursor may not actually be over a panel. // The fix is to do a secondary test for the panel with focus. // if ("" == $panel) { $panel = `getPanel -withFocus`; } if ($panel != "") { string $type = `getPanel -to $panel`; if ($type == "modelPanel") { // If you use animate roll int $animate = 0; $animate = `optionVar -q animateRoll`; // If the user presses 'f' with nothing selected or 'a', AND the viewport has filtering // we should apply the filtering. if( `modelEditor -q -isFiltered $panel` && ($fitType == "-all" || size( `ls -sl`) == 0)) { viewFit -panel $panel -animate $animate `lookThru -q $panel`; } else if ($fitType == "-all") { viewFit -all -animate $animate `lookThru -q $panel`; } else if ($fitType == "-selectedNoChildren" && size( `ls -sl`) != 0) { fitPanelWithoutChildren ( $animate, $panel, "", 0 ); } else { viewFit -animate $animate `lookThru -q $panel`; } } else if ($type == "hyperPanel") { if ($fitType == "-all") hyperGraph -e -frameGraph $panel; else hyperGraph -e -frame $panel; } else if ($type == "outlinerPanel") { // It is kind of tough for the outliner to do show-all // so just always do a show-selected // outlinerEditor -edit -showSelected true $panel; } else if ($type == "scriptedPanel") { string $scriptedType = `scriptedPanel -q -type $panel`; int $isCustom = `scriptedPanelType -q -customView $scriptedType`; if ( $isCustom ) { // If you use animate roll int $animate = 0; $animate = `optionVar -q animateRoll`; if ($fitType == "-all") viewFit -all -animate $animate `lookThru -q $panel`; else viewFit -animate $animate `lookThru -q $panel`; } else { switch ($scriptedType) { case "graphEditor": string $graphEd = ($panel+"GraphEd"); if ($fitType == "-all") { animCurveEditor -e -lookAt all $graphEd; } else { animCurveEditor -e -lookAt selected $graphEd; } break; case "hyperGraphPanel": string $hyperGraphEd = ( $panel + "HyperGraphEd"); if ($fitType == "-all") { hyperGraph -e -frameGraph $hyperGraphEd; } else { hyperGraph -e -frame $hyperGraphEd; } break; case "hyperShadePanel": if ($fitType == "-all") { hyperShadePanelFrameAll($panel); } else { hyperShadePanelFrameSelected($panel); } break; case "profilerPanel": if (`profilerTool -q -exists`) { if ($fitType == "-all") { profilerTool -e -frameAll; } else { profilerTool -e -frameSelected; } } break; case "nodeEditorPanel": if ($fitType == "-all") { nodeEditor -e -frameAll `editorNameFromPanel $panel`; } else { nodeEditor -e -frameSelected `editorNameFromPanel $panel`; } break; case "miInteractionEditorPanel": if (`pluginInfo -q -l MayaInteractive`){ miInteractionEditorPanelFrame( $panel, $fitType ); } break; case "visorPanel": if ($fitType == "-all") { visorPanelFrameAll($panel); } else { visorPanelFrameSelected($panel); } break; case "dopeSheetPanel": string $dopeSheetEd = ( $panel + "DopeSheetEd" ); if( $fitType == "-all" ) { dopeSheetEditor -edit -lookAt all $dopeSheetEd; } else { dopeSheetEditor -edit -lookAt selected $dopeSheetEd; } break; case "polyTexturePlacementPanel": string $texWindowEd = $panel; if( $fitType == "-all" ) { textureWindow -edit -frameAll $texWindowEd; } else { textureWindow -edit -frameSelected $texWindowEd; } break; case "clipEditorPanel": string $traxWindowEd = clipEditorNameFromPanel( $panel ); if( $fitType == "-all" ) { clipEditor -edit -lookAt all $traxWindowEd; } else { clipEditor -edit -lookAt selected $traxWindowEd; } break; case "sequenceEditorPanel": string $seqWindowEd = sequenceEditorNameFromPanel( $panel ); if( $fitType == "-all" ) { clipEditor -edit -lookAt all $seqWindowEd; } else { clipEditor -edit -lookAt selected $seqWindowEd; } break; case "referenceEditorPanel": global string $gReferenceEditorModelEditor; // If you use animate roll int $animate = 0; $animate = `optionVar -q animateRoll`; if( $fitType == "-all" ) { viewFit -all -animate $animate `lookThru -q $gReferenceEditorModelEditor`; } else { viewFit -animate $animate `lookThru -q $gReferenceEditorModelEditor`; } break; } } } } }