// =========================================================================== // 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: 31 May 1997 // // // Procedure Name: // HotboxCenterMenu // // Description: // Create the user customizable Hotbox Center Menu for hotbox // // Input Arguments: // parent to parent the menu to. // // Return Value: // None. // // // Verify that the supplied camera name is a perspective // camera. If not, return the first perspective camera // you can find. // global proc string validPerspCamera( string $name ) { string $cameras[] = `listCameras -perspective`; string $pipeName = "|"+$name; string $camera; for ($camera in $cameras) { if ($camera == $name || $camera == $pipeName) return $camera; } if ($cameras[0] == "") return ""; else return $cameras[0]; } // // Verify that the supplied camera name is orthographic // camera. If not, return the first orthographic camera // you can find. // global proc string validOrthoCamera( string $name ) { string $cameras[] = `listCameras -orthographic`; string $pipeName = "|"+$name; string $camera; for ($camera in $cameras) { if ($camera == $name || $camera == $pipeName) return $camera; } if ($cameras[0] == "") return ""; else return $cameras[0]; } // // Verify that the supplied panel name is of type "Modeling" // otherwise find a valid model panel. // global proc string validModelingPanel (string $panelName) { if (`getPanel -typeOf $panelName` == "modelPanel") return $panelName; else { string $invisibles[] = `getPanel -invisiblePanels`; string $item; for ($item in $invisibles) { if (`getPanel -typeOf $item` == "modelPanel") { return $item; } } } return ""; } // // Switch Model View // global proc switchModelView(string $viewType) { string $curPanel = `getPanel -withFocus`; if ($curPanel == "" || $viewType == "") return; // If the panel is torn-off then abort operation int $tornOff = `panel -q -tearOff $curPanel`; if ($tornOff) return; string $cameraName; switch ($viewType){ case "Perspective": case "persp": $cameraName = validPerspCamera( "persp" ); break; case "side": case "front": case "top": $cameraName = validOrthoCamera( $viewType ); break; default: $cameraName = ""; } if( $cameraName != "" ){ lookThroughModelPanel $cameraName $curPanel; } } global proc HotboxCenterMenu( string $parent ) { setParent -m $parent; if( `menu -q -ni $parent` != 0 ) { // // Menu is built already - just return // return; } menuItem -rp "N" -label (localizedPanelLabel("Perspective View")) -c "switchModelView persp"; menuItem -rp "E" -label (localizedPanelLabel("Side View")) -c "switchModelView side"; menuItem -rp "S" -label (localizedPanelLabel("Front View")) -c "switchModelView front"; menuItem -rp "W" -label (localizedPanelLabel("Top View")) -c "switchModelView top"; menuItem -rp "NW" -label (localizedPanelLabel("Left View")) -version 2014 -c "MTviewChange(\"left\", \"-ls\");"; menuItem -rp "SW" -label (localizedPanelLabel("Back View")) -version 2014 -c "MTviewChange(\"back\", \"-b\");"; menuItem -rp "SE" -label (localizedPanelLabel("Bottom View")) -version 2014 -c "MTviewChange(\"bottom\", \"-bo\");"; menuItem -label (localizedHotboxMenuItem("Hotbox Style")) -subMenu true -allowOptionBoxes true; menuItem -label (localizedHotboxMenuItem("Zones and Menu Rows")) -c "hotBox -dh"; menuItem -label (localizedHotboxMenuItem("Zones Only")) -c "hotBox -dzo"; menuItem -label (localizedHotboxMenuItem("Center Zone Only")) -c "hotBox -dco"; setParent -m ..; }