// =========================================================================== // 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: Check if the label of the hypergraph panel // reflects the given type of view shown in // the hypergraph, so that it is easier for // a user to tell from the label which panel // is showing which type of view. // // - For DAG view, we want the label to be // "Hierarchy+number"; // - for DG view, we want the label to be // "InputOutput+number". // global proc checkHGLabel(string $editor) { // Get the hypergraph editor's type. // string $type = `hyperGraph -query -graphType $editor`; if ($type != "DAG" && $type != "DG") { return; } // Get the panel name. // The editor name is the panel name + "HyperGraphEd". // int $numOfChars = size($editor); $numOfChars = $numOfChars - size("HyperGraphEd"); if ($numOfChars <= 0) { return; } string $panelName = `substring $editor 1 $numOfChars`; string $label = `scriptedPanel -query -label $panelName`; // Check to see if the label is already corresponding to the // given type. // string $prefix = localizedPanelLabel( "Hypergraph Hierarchy" ); $numOfChars = size($prefix); if(( $type == "DAG" ) && ( size($label) >= $numOfChars ) && ( `substring $label 1 $numOfChars` == $prefix )) { // The label is OK. // return; } $prefix = localizedPanelLabel( "Hypergraph InputOutput" ); $numOfChars = size($prefix); if(( $type == "DG" ) && ( size($label) >= $numOfChars ) && ( `substring $label 1 $numOfChars` == $prefix )) { // The label is OK. // return; } // The label does not reflect the given type. // $label = hyperGraphGenerateNewPanelLabel($type); // Change the label for the panel. // scriptedPanel -edit -label $label $panelName; // If the hypergrpah panel is already opened in a window, // change the window's title to the new label. // string $windowName = $panelName + "Window"; if (`panel -q -to $panelName`) { // // The window is already displayed, change the window's title // to the new label. // window -edit -title $label $windowName; } }