// =========================================================================== // 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. // =========================================================================== // Description: Get the name of the hypergraph panel for the // given type of hypergraph view. // // The two possible types are: // . DAG for the hierarchical view; // . DG for the input and output connections view. // // The panel this procedure returns depends on // the user preference. The two possible preferences // are // . to see the first existing hypergraph with // this type of view; // . create a new hypergraph with this type of view. // global proc string getHyperGraphPanel(string $type) { if ($type != "DAG" && $type != "DG") { string $warningMessage = (uiRes("m_getHyperGraphPanel.kUseDefaultType")); warning($warningMessage); // The default type is "DAG" which is the hypergraph // hierarchical view. // $type = "DAG"; } if (!`optionVar -exists ($type+"OpenHyperGraphMode")`) { initializeOpenHyperGraphMode($type); } int $openMode = `optionVar -query ($type+"OpenHyperGraphMode")`; if ($openMode == 0) { // The user's preference is to open the first // available hypergraph panel with the given type of view, // then we look for the first avaialbel hypergraph such view. // string $allPanelsOfType[] = `getPanel -sty hyperGraphPanel`; string $panelName; for ($panelName in $allPanelsOfType) { if ($panelName == "") { continue; } string $editor = $panelName + "HyperGraphEd"; if (`hyperGraph -query -graphType $editor` == $type) { // We found the first hypergraph panel with // the given type of view. // return $panelName; } } } // Either we did not find the first available hypergraph // with the given type of view, // or the user's preference is to open a new // hypergraph panel with such view, // then we create a new hypergraph with this type of view. // string $panelLabel = hyperGraphGenerateNewPanelLabel($type); string $whichPanel = `scriptedPanel -label $panelLabel -type hyperGraphPanel -unParent`; return $whichPanel; }