// =========================================================================== // 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: Feb 20 1997 // // Description: // This script creates a panel editor for manipulating panels and // arrangements of panels as well as the panel history. // // Input Arguments: // None. // // Return Value: // None. // // Note: // None. // proc string getPanelLabelFromType(string $type) // // Description: // Find all the panels of a given type and return the label // of the first panel. // // This proc fixes bug #130421 where panel types were // broken up into words and capitalized. The problem with // this is that panel types often are meaningless and // and potentially confusing to the user. // { string $result = ""; string $panels[]; if ($type == "modelPanel") { $result = localizedPanelLabel("Model Panel"); } else { // Get all the panels of the specified type. // $panels = `getPanel -type $type`; if (size($panels) > 0) { $result = `panel -query -label $panels[0]`; } else { $panels = `getPanel -scriptType $type`; if (size($panels) > 0) { $result = `panel -query -label $panels[0]`; } else if (`scriptedPanelType -exists $type`) { $result = `scriptedPanelType -q -label $type`; } } } return $result; } global proc panelEditor (string $whichTab) // // Description: // Create the Panel Editor. // // Arguments: // $whichTab - May be either "Layouts" or "New Panel". Will select that tab // when window is shown. All other values are ingored and the // window will come up with the first tab selected. // { global string $gPanelEditorWnd = "panelArrangementWin"; string $retVal[]; string $form, $tabs, $closeButton; int $spacing = 4; waitCursor -state on; if (!`window -exists $gPanelEditorWnd`) { string $panels = (uiRes("m_panelEditor.kPanels")); window -title $panels -menuBar true -iconName $panels $gPanelEditorWnd; // Help menu. // menu -label (uiRes("m_panelEditor.kHelp")) -helpMenu true; menuItem -label (uiRes("m_panelEditor.kHelponPanelEditor")) -enableCommandRepeat false -command "showHelp PanelEditor"; // Top level form. // $form = `formLayout`; $tabs = `tabLayout`; // --------------------------------------------------------------- // // Panels Tab // // --------------------------------------------------------------- string $panelsForm, $panelsScrollList, $panelsFieldGrp; string $panelsDeleteButton; setParent $tabs; $panelsForm = `formLayout`; $panelsScrollList = `textScrollList -numberOfRows 10 -allowMultiSelection false -selectCommand "panelEd_PanelSelectionChanged" PanelEditorPanelsScrollList`; $panelsFieldGrp = `textFieldGrp -label (uiRes("m_panelEditor.kLabel")) -columnWidth 1 50 -adjustableColumn 2 -columnAttach 2 "both" 0 -changeCommand "panelEd_RenamePanel" PanelEditorPanelsTextFieldGrp`; string $delete = (uiRes("m_panelEditor.kDelete")); $panelsDeleteButton = `button -label $delete -command "panelEd_DeletePanel"`; formLayout -edit -attachForm $panelsScrollList "top" $spacing -attachForm $panelsScrollList "left" $spacing -attachControl $panelsScrollList "bottom" $spacing $panelsFieldGrp -attachForm $panelsScrollList "right" $spacing -attachNone $panelsFieldGrp "top" -attachForm $panelsFieldGrp "left" (5 * $spacing) -attachControl $panelsFieldGrp "bottom" $spacing $panelsDeleteButton -attachForm $panelsFieldGrp "right" (5 * $spacing) -attachNone $panelsDeleteButton "top" -attachForm $panelsDeleteButton "left" (5 * $spacing) -attachForm $panelsDeleteButton "bottom" $spacing -attachForm $panelsDeleteButton "right" (5 * $spacing) $panelsForm; // --------------------------------------------------------------- // // New Panel Tab // // --------------------------------------------------------------- string $newPanelForm, $newPanelScrollList, $newPanelButton; setParent $tabs; $newPanelForm = `formLayout`; $newPanelScrollList = `textScrollList -numberOfRows 10 -allowMultiSelection false PanelEditorNewPanelScrollList`; $newPanelButton = `button -label (uiRes("m_panelEditor.kMakeNewPanel")) -command "panelEd_NewPanel"`; // Fill in contents of scroll list. // panelEd_GenerateLayoutTypes; formLayout -edit -attachForm $newPanelScrollList "top" $spacing -attachForm $newPanelScrollList "left" $spacing -attachControl $newPanelScrollList "bottom" $spacing $newPanelButton -attachForm $newPanelScrollList "right" $spacing -attachNone $newPanelButton "top" -attachForm $newPanelButton "left" (5 * $spacing) -attachForm $newPanelButton "bottom" $spacing -attachForm $newPanelButton "right" (5 * $spacing) $newPanelForm; // --------------------------------------------------------------- // // Layouts Tab // // --------------------------------------------------------------- string $layoutsForm, $layoutsScrollList, $layoutsFieldGrp; string $layoutsAddButton, $layoutsNewButton, $layoutsDeleteButton; setParent $tabs; $layoutsForm = `formLayout`; $layoutsScrollList = `textScrollList -numberOfRows 10 -allowMultiSelection false -selectCommand "panelEd_LayoutSelectionChanged" PanelEditorLayoutsScrollList`; $layoutsFieldGrp = `textFieldGrp -label (uiRes("m_panelEditor.kName")) -columnWidth 1 50 -adjustableColumn 2 -columnAttach 2 "both" 0 -changeCommand "panelEd_LayoutNameChanged" PanelEditorLayoutsTextFieldGrp`; $layoutsAddButton = `button -label (uiRes("m_panelEditor.kAddToShelf")) -command "putCurrentNamedLayoutOnShelf" PanelEditorLayoutsAddToShelfButton`; $layoutsNewButton = `button -label (uiRes("m_panelEditor.kNewLayout")) -command "saveCurrentAsNamedLayout"`; $layoutsDeleteButton = `button -label $delete -command "deleteNamedPanelLayout"`; // Fill in contents of scroll list. // panelEd_UpdateLayoutTab; if (`textScrollList -query -numberOfItems $layoutsScrollList` > 0) { textScrollList -edit -selectIndexedItem 1 $layoutsScrollList; $retVal = `textScrollList -query -selectItem $layoutsScrollList`; textFieldGrp -edit -text $retVal[0] $layoutsFieldGrp; } formLayout -edit -attachForm $layoutsScrollList "top" $spacing -attachForm $layoutsScrollList "left" $spacing -attachControl $layoutsScrollList "bottom" $spacing $layoutsFieldGrp -attachForm $layoutsScrollList "right" $spacing -attachNone $layoutsFieldGrp "top" -attachForm $layoutsFieldGrp "left" (5 * $spacing) -attachControl $layoutsFieldGrp "bottom" $spacing $layoutsAddButton -attachForm $layoutsFieldGrp "right" (5 * $spacing) -attachNone $layoutsAddButton "top" -attachForm $layoutsAddButton "left" (5 * $spacing) -attachForm $layoutsAddButton "bottom" $spacing -attachPosition $layoutsAddButton "right" ($spacing / 2) 33 -attachNone $layoutsNewButton "top" -attachPosition $layoutsNewButton "left" ($spacing / 2) 33 -attachForm $layoutsNewButton "bottom" $spacing -attachPosition $layoutsNewButton "right" ($spacing / 2) 67 -attachNone $layoutsDeleteButton "top" -attachPosition $layoutsDeleteButton "left" ($spacing / 2) 67 -attachForm $layoutsDeleteButton "bottom" $spacing -attachForm $layoutsDeleteButton "right" (5 * $spacing) $layoutsForm; // --------------------------------------------------------------- // // Edit Layouts Tab // // --------------------------------------------------------------- string $editLayoutsForm, $editLayoutsTabs; string $configurationsForm, $contentsForm; string $configurationOptionMenu, $configurationPreviewFrame; string $contentsRadioButtonGrp, $contentsSelectLabel; string $contentsRow[4]; setParent $tabs; $editLayoutsForm = `formLayout`; $editLayoutsTabs = `tabLayout`; // Configurations tab. // setParent $editLayoutsTabs; $configurationsForm = `formLayout`; $configurationOptionMenu = `optionMenu -label (uiRes("m_panelEditor.kConfiguration")) -changeCommand "panelEd_ConfigChange" PanelEditorConfigurationOptionMenu`; menuItem -label (localizedPanelLabel("Single Pane")); menuItem -label (localizedPanelLabel("Two Panes Stacked")); menuItem -label (localizedPanelLabel("Two Panes Side by Side")); menuItem -label (localizedPanelLabel("Three Panes Split Top")); menuItem -label (localizedPanelLabel("Three Panes Split Left")); menuItem -label (localizedPanelLabel("Three Panes Split Bottom")); menuItem -label (localizedPanelLabel("Three Panes Split Right")); menuItem -label (localizedPanelLabel("Three Panes Stacked")); menuItem -label (localizedPanelLabel("Three Panes Side by Side")); menuItem -label (localizedPanelLabel("Four Panes")); menuItem -label (localizedPanelLabel("Four Panes Split Top")); menuItem -label (localizedPanelLabel("Four Panes Split Left")); menuItem -label (localizedPanelLabel("Four Panes Split Bottom")); menuItem -label (localizedPanelLabel("Four Panes Split Right")); menuItem -label (localizedPanelLabel("Four Panes Stacked")); menuItem -label (localizedPanelLabel("Four Panes Side by Side")); $configuationArrangementLabel = `text -label (uiRes("m_panelEditor.kArrangementName")) -align "center" PanelEditorConfigurationArrangementLabel`; $configurationPreviewFrame = `frameLayout -labelVisible false`; paneLayout -separatorMovedCommand "panelEd_PaneSeparatorChanged" PanelEditorConfigurationPanes; frameLayout -lv false -cll false; text -label "1" -align "center"; setParent ..; // from frameLayout frameLayout -lv false -cll false; text -label "2" -align "center"; setParent ..; // from frameLayout frameLayout -lv false -cll false; text -label "3" -align "center"; setParent ..; // from frameLayout frameLayout -lv false -cll false; text -label "4" -align "center"; setParent ..; // from frameLayout formLayout -edit -attachForm $configurationOptionMenu "top" $spacing -attachForm $configurationOptionMenu "left" $spacing -attachNone $configurationOptionMenu "bottom" -attachNone $configurationOptionMenu "right" -attachControl $configurationPreviewFrame "top" $spacing $configurationOptionMenu -attachForm $configurationPreviewFrame "left" (5 * $spacing) -attachControl $configurationPreviewFrame "bottom" $spacing $configuationArrangementLabel -attachForm $configurationPreviewFrame "right" (5 * $spacing) -attachNone $configuationArrangementLabel "top" -attachForm $configuationArrangementLabel "left" $spacing -attachForm $configuationArrangementLabel "bottom" $spacing -attachForm $configuationArrangementLabel "right" $spacing $configurationsForm; // Contents tab. // setParent $editLayoutsTabs; $contentsForm = `formLayout`; string $AssociatewithScene = (uiRes("m_panelEditor.kAssociatewithScene")); $contentsRadioButtonGrp = `radioButtonGrp -numberOfRadioButtons 2 -onCommand1 ("panelEd_LayoutDependenceChange false") -onCommand2 ("panelEd_LayoutDependenceChange true") -label "" -labelArray2 (uiRes("m_panelEditor.kSceneIndependent")) $AssociatewithScene -columnWidth3 1 150 150 PanelEditorContentsSceneRadioButtonGrp`; $contentsSelectLabel = `text -label (uiRes("m_panelEditor.kSelectPanelbyName")) -align "left" PanelEditorContentsSelectLabel`; for ($index = 0; $index < 4; $index++) { $contentsRow[$index] = `rowLayout -numberOfColumns 3 -columnWidth3 250 80 50 -columnAttach3 "both" "both" "both" -columnAlign3 "left" "left" "center"`; optionMenu -label ($index+1) -changeCommand ("panelEd_PanelOptMenuChanged " + $index) ("PanelEditorContentsOptionMenu" + $index); checkBox -label (uiRes("m_panelEditor.kFixState")) -changeCommand ("panelEd_LayoutEditFixedChange " + $index) ("PanelEditorContentsStateCheckBox" + $index); button -label (uiRes("m_panelEditor.kUpdate")) -command ("panelEd_LayoutEditUpdateBtnAction " + $index) ("PanelEditorContentsUpdateButton" + $index); setParent ..; } formLayout -edit -attachForm $contentsRadioButtonGrp "top" $spacing -attachForm $contentsRadioButtonGrp "left" $spacing -attachNone $contentsRadioButtonGrp "bottom" -attachNone $contentsRadioButtonGrp "right" -attachControl $contentsSelectLabel "top" $spacing $contentsRadioButtonGrp -attachForm $contentsSelectLabel "left" $spacing -attachNone $contentsSelectLabel "bottom" -attachNone $contentsSelectLabel "right" -attachControl $contentsRow[0] "top" $spacing $contentsSelectLabel -attachForm $contentsRow[0] "left" $spacing -attachNone $contentsRow[0] "bottom" -attachForm $contentsRow[0] "right" $spacing $contentsForm; for ($index = 1; $index < 4; $index++) { formLayout -edit -attachControl $contentsRow[$index] "top" $spacing $contentsRow[$index - 1] -attachForm $contentsRow[$index] "left" $spacing -attachNone $contentsRow[$index] "bottom" -attachForm $contentsRow[$index] "right" $spacing $contentsForm; } // Apply the tab labels. // tabLayout -edit -tabLabelIndex 1 (uiRes("m_panelEditor.kConfigurations")) -tabLabelIndex 2 (uiRes("m_panelEditor.kContents")) $editLayoutsTabs; formLayout -edit -attachForm $editLayoutsTabs "top" $spacing -attachForm $editLayoutsTabs "left" $spacing -attachForm $editLayoutsTabs "bottom" $spacing -attachForm $editLayoutsTabs "right" $spacing $editLayoutsForm; // --------------------------------------------------------------- // // History Tab // // --------------------------------------------------------------- string $historyForm, $historyDepthFieldGrp, $historyWrapCheckBox; string $historyClearButton, $historyPreviousButton, $historyNextButton; int $historyDepth, $historyWrap; setParent $tabs; $historyForm = `formLayout`; $historyDepth = `panelHistory -query -historyDepth mainPanelHistory`; $historyDepthFieldGrp = `intFieldGrp -label (uiRes("m_panelEditor.kHistoryDepth")) -numberOfFields 1 -value1 $historyDepth -changeCommand "panelHistory -edit -historyDepth #1 mainPanelHistory"`; $historyWrap = `panelHistory -query -wrap mainPanelHistory`; $historyWrapCheckBox = `checkBoxGrp -label (uiRes("m_panelEditor.kWrapHistory")) -numberOfCheckBoxes 1 -label1 "" -value1 $historyWrap -changeCommand1 "panelHistory -edit -wrap #1 mainPanelHistory"`; $historyClearButton = `button -label (uiRes("m_panelEditor.kClearHistory")) -command "panelHistory -edit -clear mainPanelHistory"`; $historyPreviousButton = `button -label (uiRes("m_panelEditor.kPreviousLayout")) -command "panelHistory -edit -back mainPanelHistory"`; $historyNextButton = `button -label (uiRes("m_panelEditor.kNextLayout")) -command "panelHistory -edit -forward mainPanelHistory"`; formLayout -edit -attachForm $historyDepthFieldGrp "top" $spacing -attachForm $historyDepthFieldGrp "left" $spacing -attachNone $historyDepthFieldGrp "bottom" -attachNone $historyDepthFieldGrp "right" -attachControl $historyWrapCheckBox "top" $spacing $historyDepthFieldGrp -attachForm $historyWrapCheckBox "left" $spacing -attachNone $historyWrapCheckBox "bottom" -attachNone $historyWrapCheckBox "right" -attachControl $historyClearButton "top" $spacing $historyWrapCheckBox -attachForm $historyClearButton "left" (5 * $spacing) -attachNone $historyClearButton "bottom" -attachPosition $historyClearButton "right" ($spacing / 2) 33 -attachControl $historyPreviousButton "top" $spacing $historyWrapCheckBox -attachPosition $historyPreviousButton "left" ($spacing / 2) 33 -attachNone $historyPreviousButton "bottom" -attachPosition $historyPreviousButton "right" ($spacing / 2) 67 -attachControl $historyNextButton "top" $spacing $historyWrapCheckBox -attachPosition $historyNextButton "left" ($spacing / 2) 67 -attachNone $historyNextButton "bottom" -attachForm $historyNextButton "right" (5 * $spacing) $historyForm; // --------------------------------------------------------------- // Set up the tab labels. // tabLayout -edit -tabLabelIndex 1 $panels -tabLabelIndex 2 (uiRes("m_panelEditor.kNewPanel")) -tabLabelIndex 3 (uiRes("m_panelEditor.kLayouts")) -tabLabelIndex 4 (uiRes("m_panelEditor.kEditLayouts")) -tabLabelIndex 5 (uiRes("m_panelEditor.kHistory")) $tabs; // Create the Close button. // setParent $form; $closeButton = `button -label (uiRes("m_panelEditor.kClose")) -command ("evalDeferred \"deleteUI " + $gPanelEditorWnd+"\"")`; // Layout the overall formlayout // formLayout -edit -attachForm $tabs "left" 0 -attachForm $tabs "right" 0 -attachForm $tabs "top" 0 -attachControl $tabs "bottom" (5 * $spacing) $closeButton -attachForm $closeButton "left" $spacing -attachForm $closeButton "right" $spacing -attachNone $closeButton "top" -attachForm $closeButton "bottom" $spacing $form; // // Select proper tab // if ((uiRes("m_panelEditor.kLayouts")) == $whichTab) { tabLayout -edit -selectTabIndex 3 $tabs; } else if ((uiRes("m_panelEditor.kNewPanel")) == $whichTab) { tabLayout -edit -selectTabIndex 2 $tabs; } else { // // Ingore all other values. // } } else { // // The window already exists. // } updatePanelLayoutFromCurrent (localizedPanelLabel("Current Layout")); panelEd_UpdatePanelTab; panelEd_UpdateOptMenuPanelItems; panelEd_PanelSelectionChanged; panelEd_LayoutSelectionChanged; waitCursor -state off; showWindow $gPanelEditorWnd; } global proc panelEd_UpdatePanelTab() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $panelTsl = "PanelEditorPanelsScrollList"; string $arrs[]; int $i, $j; int $nArr = 0; int $count = 0; textScrollList -edit -removeAll $panelTsl; string $panels[] = `getPanel -allPanels`; for ($panel in $panels) { string $type = `getPanel -typeOf $panel`; if ($type == "scriptedPanel") { string $scriptedType = `scriptedPanel -q -type $panel`; if(`scriptedPanelType -q -obsolete $scriptedType`) { continue; // Skip obsolete scripted panels } } if ($type != "emptyPanel") { $arrs[$count++] = `panel -query -label $panel`; } } $nArr = size($arrs); for ($i = 0; $i < $nArr; $i++) { textScrollList -edit -append $arrs[$i] $panelTsl; } if ($nArr > 0) { textScrollList -edit -selectIndexedItem 1 $panelTsl; } } global proc panelEd_UpdateLayoutTab() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorLayoutsScrollList"; string $arrs[] = `getPanel -allConfigs`; int $i; int $nArr = 0; textScrollList -edit -removeAll $tsl; $nArr = size($arrs); for ($i = 0; $i < $nArr; $i++) { textScrollList -edit -append `panelConfiguration -query -label $arrs[$i]` $tsl; } } global proc saveCurrentAsNamedLayout() { global string $gMainPane; global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorLayoutsScrollList"; string $newConfigName = `panelConfiguration -sc false -userCreated true`; string $label = (localizedPanelLabel(interToUI($newConfigName))); panelConfiguration -edit -label $label $newConfigName; updatePanelLayoutFromCurrent $label; // special case for top,front,side,persp // -make sure they always reset their state. // int $i,$nArr; string $labels[]; $labels = `panelConfiguration -query -labelStrings $newConfigName`; $nArr = size($labels); for ($i = 0; $i < $nArr; $i++) { if (localizedPanelLabel("Persp View") == $labels[$i] || localizedPanelLabel("Top View") == $labels[$i] || localizedPanelLabel("Side View") == $labels[$i] || localizedPanelLabel("Front View") == $labels[$i]) { panelConfiguration -edit -replaceFixedState ($i+1) true $newConfigName; } } // update the rest of the dialog // panelEd_UpdateLayoutTab; textScrollList -edit -selectItem $label $tsl; panelEd_LayoutSelectionChanged; } global proc panelEd_UpdateLayoutTextField() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $retVal[]; $retVal = `textScrollList -query -selectItem PanelEditorLayoutsScrollList`; textFieldGrp -edit -text $retVal[0] PanelEditorLayoutsTextFieldGrp; } global proc panelEd_LayoutNameChanged() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorLayoutsScrollList"; string $tfg = "PanelEditorLayoutsTextFieldGrp"; string $newLabel; string $oldLabel; int $selected[]; string $listItems[]; string $arrs[] = `getPanel -allConfigs`; int $i, $nArr; int $isUnique = true; // update controls // $listItems = `textScrollList -query -selectItem $tsl`; $newLabel = `textFieldGrp -query -text $tfg`; $oldLabel = $listItems[0]; string $ok = (uiRes("m_panelEditor.kOK")); string $alert = (uiRes("m_panelEditor.kAlert")); if ( localizedPanelLabel("Current Layout") == $oldLabel) { confirmDialog -title $alert -button $ok -defaultButton $ok -message (uiRes("m_panelEditor.kCannotRename")) -parent $gPanelEditorWnd; textFieldGrp -edit -text $oldLabel $tfg; } else if (size($newLabel) == 0) { // // Name is zero length // confirmDialog -title $alert -button $ok -defaultButton $ok -message (uiRes("m_panelEditor.kInvalidLayoutName")) -parent $gPanelEditorWnd; textFieldGrp -edit -text $oldLabel $tfg; } else { // // Check for a duplicate name // $nArr = size($arrs); for ($i = 0; $i < $nArr; $i++) { if ($newLabel == `panelConfiguration -query -label $arrs[$i]`) { $isUnique = false; confirmDialog -title $alert -button $ok -defaultButton $ok -message (uiRes("m_panelEditor.kDuplicateLayoutName")) -parent $gPanelEditorWnd; textFieldGrp -edit -text $oldLabel $tfg; break; } } if ($isUnique) { $selected = `textScrollList -query -selectIndexedItem $tsl`; textScrollList -edit -deselectAll $tsl; textScrollList -edit -removeIndexedItem $selected[0] $tsl; textScrollList -edit -appendPosition $selected[0] $newLabel -selectIndexedItem $selected[0] $tsl; setFocus $tsl; // update config // string $configName = `getPanel -cwl $oldLabel`; if ("" != $configName) { panelConfiguration -edit -label $newLabel $configName; panelEd_UpdateLayoutEditTab; } // check if this config is a pref // if (`optionVar -query newScenePanelConfiguration` == $oldLabel) { optionVar -sv newScenePanelConfiguration $newLabel; } } } } global proc applyNamedPanelLayout() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $whichArrangement; $whichArrangement = `textFieldGrp -query -text PanelEditorLayoutsTextFieldGrp`; if ($whichArrangement != "") { setNamedPanelLayout $whichArrangement; setFocus PanelEditorLayoutsScrollList; } } global proc deleteNamedPanelLayout() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorLayoutsScrollList"; string $tfg = "PanelEditorLayoutsTextFieldGrp"; int $selected[]; string $oldLabel; string $configName; string $listItems[]; string $msg; string $alert = (uiRes("m_panelEditor.kAlertTitle")); string $ok = (uiRes("m_panelEditor.kOKOption")); string $cancel = (uiRes("m_panelEditor.kCancel")); if (`textScrollList -query -numberOfItems $tsl` > 0) { $oldLabel = `textFieldGrp -query -text $tfg`; $selected = `textScrollList -query -selectIndexedItem $tsl`; if (localizedPanelLabel("Current Layout") == $oldLabel) { confirmDialog -title $alert -button $ok -defaultButton $ok -message (uiRes("m_panelEditor.kCannotDelete")) -parent $gPanelEditorWnd; } else { if (`optionVar -query newScenePanelConfiguration` == $oldLabel) { string $displayMsg = (uiRes("m_panelEditor.kCannotDeleteMsg")); confirmDialog -title $alert -button $ok -defaultButton $ok -message (`format -s $oldLabel $displayMsg`) -parent $gPanelEditorWnd; } else { $msg = (uiRes("m_panelEditor.kDeleteConfirmMsg")); $msg = `format -s $oldLabel $msg`; if ($ok == `confirmDialog -title (uiRes("m_panelEditor.kConfirm")) -message $msg -button $ok -button $cancel -defaultButton $ok -cancelButton $cancel -dismissString $cancel -parent $gPanelEditorWnd`) { textScrollList -edit -removeIndexedItem $selected[0] $tsl; $configName = `getPanel -cwl $oldLabel`; deleteUI -panelConfig $configName; if ($selected[0] > `textScrollList -query -numberOfItems $tsl`) { $selected[0] = $selected[0] - 1; } if ($selected[0] > 0) { textScrollList -edit -selectIndexedItem $selected[0] $tsl; } panelEd_LayoutSelectionChanged; } } } } } global proc panelEd_ConfigChange () { // // Description: // User has changed the pane config via the option menu. // global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $configLabel = `textFieldGrp -query -text PanelEditorLayoutsTextFieldGrp`; string $configName = ""; if ("" != $configLabel) { $configName = `getPanel -cwl $configLabel`; } if ("" == $configName) { return; } string $menuSelection = `optionMenu -query -value PanelEditorConfigurationOptionMenu`; int $nPanes, $i; int $state; string $optName, $chkName, $btnName, $configType = ""; if ( (localizedPanelLabel("Single Pane")) == $menuSelection) { $configType = "single"; } else if ( (localizedPanelLabel("Two Panes Stacked")) == $menuSelection) { $configType = "horizontal2"; } else if ( (localizedPanelLabel("Two Panes Side by Side")) == $menuSelection) { $configType = "vertical2"; } else if ( (localizedPanelLabel("Three Panes Split Top")) == $menuSelection) { $configType = "top3"; } else if ( (localizedPanelLabel("Three Panes Split Left")) == $menuSelection) { $configType = "left3"; } else if ( (localizedPanelLabel("Three Panes Split Bottom")) == $menuSelection) { $configType = "bottom3"; } else if ( (localizedPanelLabel("Three Panes Split Right")) == $menuSelection) { $configType = "right3"; } else if ( (localizedPanelLabel("Three Panes Stacked")) == $menuSelection) { $configType = "horizontal3"; } else if ( (localizedPanelLabel("Three Panes Side by Side")) == $menuSelection) { $configType = "vertical3"; } else if ( (localizedPanelLabel("Four Panes")) == $menuSelection) { $configType = "quad"; } else if ( (localizedPanelLabel("Four Panes Split Top")) == $menuSelection) { $configType = "top4"; } else if ( (localizedPanelLabel("Four Panes Split Left")) == $menuSelection) { $configType = "left4"; } else if ( (localizedPanelLabel("Four Panes Split Bottom")) == $menuSelection) { $configType = "bottom4"; } else if ( (localizedPanelLabel("Four Panes Split Right")) == $menuSelection) { $configType = "right4"; } else if ( (localizedPanelLabel("Four Panes Stacked")) == $menuSelection) { $configType = "horizontal4"; } else if ( (localizedPanelLabel("Four Panes Side by Side")) == $menuSelection) { $configType = "vertical4"; } if ("" != $configType) { switchPanes $configType 0; updateToolbox(); } updatePanelLayoutFromCurrent $configLabel; // special case for top,front,side,persp // -make sure they always reset their state. // int $nArr; string $labels[]; $configName = `getPanel -configWithLabel $configLabel`; $labels = `panelConfiguration -query -labelStrings $configName`; $nArr = size($labels); for ($i = 0; $i < $nArr; $i++) { if (localizedPanelLabel("Persp View") == $labels[$i] || localizedPanelLabel("Top View") == $labels[$i] || localizedPanelLabel("Side View") == $labels[$i] || localizedPanelLabel("Front View") == $labels[$i]) { panelConfiguration -edit -replaceFixedState ($i+1) true $configName; } } panelEd_UpdateLayoutEditTab; } global proc panelEd_UpdateOptMenuPanelItems() // // Description: // Updates the individual option menus for each pane. The contents // will be updated to reflect the current state of the app. Content // type can switch between panel types and panel names. // { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tfg = "PanelEditorLayoutsTextFieldGrp"; string $configLabel = ""; string $configName = ""; int $isSceneConfig = true; string $optMenu1 = "PanelEditorContentsOptionMenu0"; string $optMenu2 = "PanelEditorContentsOptionMenu1"; string $optMenu3 = "PanelEditorContentsOptionMenu2"; string $optMenu4 = "PanelEditorContentsOptionMenu3"; int $i; int $count = 0; int $nItems = `optionMenu -query -numberOfItems $optMenu1`; string $itemText[]; string $panelName; string $items1[] = `optionMenu -query -ill $optMenu1`; string $items2[] = `optionMenu -query -ill $optMenu2`; string $items3[] = `optionMenu -query -ill $optMenu3`; string $items4[] = `optionMenu -query -ill $optMenu4`; string $allPanels[] = `getPanel -allPanels`; $configLabel = `textFieldGrp -query -text $tfg`; if ($configLabel != "") { $configName = `getPanel -cwl $configLabel`; if ($configName != "") { $isSceneConfig = `panelConfiguration -query -sc $configName`; } } if ($isSceneConfig) { // // build a list of existing panels // for ($panel in $allPanels) { string $type = `getPanel -typeOf $panel`; if ($type != "emptyPanel") { $itemText[$count++] = `panel -query -label $panel`; } } } else { // // build a list of panel types // string $types[]; string $allTypes[] = `getMayaPanelTypes(false)`; string $scrollTypes[] = `getMayaPanelTypes(true)`; int $i, $nTypes, $nScrollTypes; $count = 0; $nTypes = size($allTypes); for ($i = 0; $i < $nTypes; $i++) { $types[$count++] = $allTypes[$i]; } $nTypes = size($scrollTypes); for ($i = 0; $i < $nTypes; $i++) { if ("setEditor" != $scrollTypes[$i] && "shadingGroupEditor" != $scrollTypes[$i] ) { $types[$count++] = $scrollTypes[$i]; } } $nTypes = size($types); $i = 0; $itemText[$i++] = localizedPanelLabel("Top Panel"); $itemText[$i++] = localizedPanelLabel("Front Panel"); $itemText[$i++] = localizedPanelLabel("Side Panel"); $itemText[$i++] = localizedPanelLabel("Persp Panel"); $itemTextIndex = 4; for ($i = 0; $i < $nTypes; $i++) { $tempItemText = getPanelLabelFromType($types[$i]); // 325285 // Some pane types don't exist, so there is no // panel to get a label from. Prevent these blank // items from appearing in the list. if ($tempItemText != "") { $itemText[$itemTextIndex++] = $tempItemText; } } } // make new or edit existing menu items // $count = size($itemText); for ($i = 0; $i < $count; $i++) { if ($i < $nItems) { menuItem -edit -label $itemText[$i] $items1[$i]; menuItem -edit -label $itemText[$i] $items2[$i]; menuItem -edit -label $itemText[$i] $items3[$i]; menuItem -edit -label $itemText[$i] $items4[$i]; } else { menuItem -p $optMenu1 -label $itemText[$i]; menuItem -p $optMenu2 -label $itemText[$i]; menuItem -p $optMenu3 -label $itemText[$i]; menuItem -p $optMenu4 -label $itemText[$i]; } } // remove any extra items // for ($i = $count; $i < $nItems; $i++) { deleteUI -menuItem $items1[$i]; deleteUI -menuItem $items2[$i]; deleteUI -menuItem $items3[$i]; deleteUI -menuItem $items4[$i]; } } global proc panelEd_PanelSelectionChanged() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $panelTsl = "PanelEditorPanelsScrollList"; string $panelTfg = "PanelEditorPanelsTextFieldGrp"; string $typeList = "PanelEditorNewPanelScrollList"; string $retVal[]; int $i, $nArr; string $whichPanel, $panel, $panelType; string $panels[] = `getPanel -allPanels`; string $items[]; // update text field group // $retVal = `textScrollList -query -selectItem $panelTsl`; textFieldGrp -edit -text $retVal[0] $panelTfg; // set new panel type to reflect type of selected panel // for ($panel in $panels) { if ($retVal[0] == `panel -query -label $panel`) { $whichPanel = $panel; break; } } if ("" != $whichPanel) { $panelType = `getPanel -to $whichPanel`; if ("scriptedPanel" == $panelType) { $panelType = `scriptedPanel -query -type $whichPanel`; $panelType = (localizedPanelLabel(interToUI($panelType))); } else { $panelType = (localizedPanelLabel(interToUI($panelType))); } $items = `textScrollList -query -allItems $typeList`; $nArr = size($items); for ($i = 0; $i < $nArr; $i++) { if ($panelType == $items[$i]) { textScrollList -edit -selectIndexedItem ($i+1) $typeList; break; } } } } global proc panelEd_LayoutSelectionChanged() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $selected[] = `textScrollList -query -selectItem PanelEditorLayoutsScrollList`; string $config = $selected[0]; panelEd_UpdateLayoutTextField; applyNamedPanelLayout; panelEd_UpdateLayoutEditTab; // Disable add to shelf for Current Layout as this won't // produce the expected result. // button -edit -enable (localizedPanelLabel("Current Layout") != $config) PanelEditorLayoutsAddToShelfButton; } global proc panelEd_PanelOptMenuChanged (int $whichMenu) { global string $gMainPane; global string $gPanelEditorWnd; setParent $gPanelEditorWnd; int $i,$nPanels; string $itemLabel; string $panelName; string $panel; string $label; string $destPanel; string $optMenu; string $command; string $control; string $panels[]; string $types[]; string $scriptTypes[]; string $tfg = "PanelEditorLayoutsTextFieldGrp"; string $configLabel = `textFieldGrp -query -text $tfg`; string $configName = ""; if ("" != $configLabel) { $configName = `getPanel -cwl $configLabel`; if ("" == $configName) { $configName = localizedPanelLabel("Current Layout"); } } $optMenu = ("PanelEditorContentsOptionMenu" + $whichMenu); $itemLabel = `optionMenu -query -value $optMenu`; $isSceneConfig = `panelConfiguration -query -sceneConfig $configName`; if ($isSceneConfig) { // // Replace the current panel with that selected by the menu // $panelName = `getPanel -wl $itemLabel`; if (localizedPanelLabel("Top View") == $itemLabel) { modelPanel -edit -cam `findStartUpCamera top` $panelName; } else if (localizedPanelLabel("Persp View") == $itemLabel) { modelPanel -edit -cam `findStartUpCamera persp` $panelName; } else if (localizedPanelLabel("Side View") == $itemLabel) { modelPanel -edit -cam `findStartUpCamera side` $panelName; } else if (localizedPanelLabel("Front View") == $itemLabel) { modelPanel -edit -cam `findStartUpCamera front` $panelName; } } else { // // Replace the current panel with one of the type selected by the menu. // Try to select a panel that is not visible. // string $cam; if ((localizedPanelLabel("Top Panel")) == $itemLabel) { $panelName = `getPanel -wl (localizedPanelLabel("Top View"))`; $cam = `findStartUpCamera top`; if ("" == $panelName) { $panelName = `modelPanel -unParent -label (localizedPanelLabel("Top View")) -cam $cam`; } else { modelPanel -edit -cam $cam $panelName; } panelConfiguration -edit -replaceFixedState ($whichMenu + 1) true $configName; } else if ((localizedPanelLabel("Persp Panel")) == $itemLabel) { $panelName = `getPanel -wl (localizedPanelLabel("Persp View"))`; $cam = `findStartUpCamera persp`; if ("" == $panelName) { $panelName = `modelPanel -unParent -label (localizedPanelLabel("Persp View")) -cam $cam`; } else { modelPanel -edit -cam $cam $panelName; } panelConfiguration -edit -replaceFixedState ($whichMenu + 1) true $configName; } else if ((localizedPanelLabel("Side Panel")) == $itemLabel) { $panelName = `getPanel -wl (localizedPanelLabel("Side View"))`; $cam = `findStartUpCamera side`; if ("" == $panelName) { $panelName = `modelPanel -unParent -label (localizedPanelLabel("Side View")) -cam $cam`; } else { modelPanel -edit -cam $cam $panelName; } panelConfiguration -edit -replaceFixedState ($whichMenu + 1) true $configName; } else if ((localizedPanelLabel("Front Panel")) == $itemLabel) { $panelName = `getPanel -wl (localizedPanelLabel("Front View"))`; $cam = `findStartUpCamera front`; if ("" == $panelName) { $panelName = `modelPanel -unParent -label (localizedPanelLabel("Front View")) -cam $cam`; } else { modelPanel -edit -cam $cam $panelName; } panelConfiguration -edit -replaceFixedState ($whichMenu + 1) true $configName; } else if ((localizedPanelLabel("Model Panel")) == $itemLabel) { // // Get a non-top/persp/front/side model panel. // $panels = `getPanel -to "modelPanel"`; for ($panel in $panels) { $label = `panel -query -label $panel`; if (localizedPanelLabel("Top View") == $label || (localizedPanelLabel("Persp View")) == $label || localizedPanelLabel("Side View") == $label || (localizedPanelLabel("Front View")) == $label) { continue; } else { $panelName = $panel; break; } } if ("" == $panelName) { $panelName = `modelPanel -unParent`; modelPanel -edit -label (localizedPanelLabel(interToUI($panelName))) $panelName; } panelConfiguration -edit -replaceFixedState ($whichMenu + 1) false $configName; } else { // // Get a non Model panel. // $types = `getMayaPanelTypes(false)`; for ($type in $types) { if (getPanelLabelFromType($type) == $itemLabel) { $panels = `getPanel -type $type`; if (size ($panels) > 0) { $panelName = $panels[0]; } else { // // Need to make a new one // $panelName = eval($type + "-unParent;"); eval ($type + " -edit -label \"" + (localizedPanelLabel(interToUI($panelName))) + "\" " + $panelName); } } } if ("" == $panelName) { $scriptTypes = `getMayaPanelTypes(true)`; for ($type in $scriptTypes) { if (getPanelLabelFromType($type) == $itemLabel) { $panels = `getPanel -scriptType $type`; if (size ($panels) > 0) { $panelName = $panels[0]; } else { // // Need to make a new one // $panelName = eval("scriptedPanel -type " + $type + "-unParent;"); eval ("scriptedPanel -edit -label \"" + (localizedPanelLabel(interToUI($panelName))) + "\" " + $panelName); } } } } panelConfiguration -edit -replaceFixedState ($whichMenu + 1) false $configName; } } if ("" != $panelName) { $command = `getPanel -typeOf $panelName`; switch ($whichMenu) { case 0: $control = `paneLayout -query -pane1 $gMainPane`; break; case 1: $control = `paneLayout -query -pane2 $gMainPane`; break; case 2: $control = `paneLayout -query -pane3 $gMainPane`; break; case 3: $control = `paneLayout -query -pane4 $gMainPane`; break; } $destPanel = `getPanel -containing $control`; if ("" != $destPanel) { eval ($command + " -edit -rp " + $destPanel + " " + $panelName); } else { // No panel currently in that spot. // eval ($command+" -edit -p " + $gMainPane + " "+ $panelName + "; paneLayout -edit -setPane " + $panelName + " " + ($whichMenu + 1) + " " + $gMainPane + ";"); } } updatePanelLayoutFromCurrent $configLabel; panelEd_UpdateLayoutEditTab; } global proc panelEd_GenerateLayoutTypes () { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $typeList = "PanelEditorNewPanelScrollList"; string $types[] = `getMayaPanelTypes(false)`; string $scrollTypes[] = `getMayaPanelTypes(true)`; string $label; int $i, $nTypes; $types = AWAppendStringsToStringArray($scrollTypes, $types); $nTypes = size($types); for ($i = 0; $i < $nTypes; $i++) { if ("setEditor" != $types[$i] && "shadingGroupEditor" != $types[$i]) { // This used to call getPanelLabelFromType() but // that returns the label of the first panel we // find of a given type. Not the ideal name for // the TYPE of panel we can create here. Using // the look-up of the type name works better. // $label = localizedPanelLabel( `interToUI $types[$i]` ); textScrollList -edit -append $label $typeList; } } } global proc putCurrentNamedLayoutOnShelf() { global string $gShelfTopLevel; global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorLayoutsScrollList"; string $retVal[]; string $cmdStr; if (`tabLayout -exists $gShelfTopLevel`) { string $currentShelf = `tabLayout -query -st $gShelfTopLevel`; $retVal = `textScrollList -query -selectItem $tsl`; $cmdStr = ("setNamedPanelLayout \"" + $retVal[0] + "\";"); shelfButton -p ($gShelfTopLevel + "|" + $currentShelf) -i1 "commandButton.png" -label $retVal[0] -style `shelfLayout -query -style $currentShelf` -width `shelfLayout -query -cellWidth $currentShelf` -height `shelfLayout -query -cellHeight $currentShelf` -c $cmdStr; } } global proc panelEd_DeletePanel() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $panelTsl = "PanelEditorPanelsScrollList"; string $panelTfg = "PanelEditorPanelsTextFieldGrp"; string $retVal[]; string $whichPanel; int $selected[]; // Find out which panel is being deleted. // $retVal = `textScrollList -query -selectItem $panelTsl`; $selected = `textScrollList -query -selectIndexedItem $panelTsl`; string $panels[] = `getPanel -allPanels`; for ($panel in $panels) { string $type = `getPanel -typeOf $panel`; if ($type != "emptyPanel") { if ($retVal[0] == `panel -query -label $panel` ) { $whichPanel = $panel; break; } } } if ($whichPanel != "") { deletePanel $whichPanel; if (!`panel -exists $whichPanel`) { // // panel was deleted. // panelEd_UpdatePanelTab; if ($selected[0] <= `textScrollList -query -numberOfItems $panelTsl`) { textScrollList -edit -selectIndexedItem $selected[0] $panelTsl; } else { if ($selected[0] > 1) { textScrollList -edit -selectIndexedItem ($selected[0]-1) $panelTsl; } else { textScrollList -edit -selectIndexedItem (0) $panelTsl; } } panelEd_UpdateOptMenuPanelItems; panelEd_UpdateLayoutEditTab; } panelEd_PanelSelectionChanged; } } global proc panelEd_RenamePanel() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorPanelsScrollList"; string $tfg = "PanelEditorPanelsTextFieldGrp"; string $newName; string $oldName; int $i,$j, $nArr; int $selected[]; string $listItems[]; string $panelName; string $arrs[] = `getPanel -allPanels`; int $isUnique = true; // update controls // $listItems = `textScrollList -query -selectItem $tsl`; $oldName = $listItems[0]; $newName = `textFieldGrp -query -text $tfg`; $selected = `textScrollList -query -selectIndexedItem $tsl`; string $ok = (uiRes("m_panelEditor.kYes")); string $alert = (uiRes("m_panelEditor.kAlertDlg")); if (localizedPanelLabel("Persp View") == $oldName || localizedPanelLabel("Top View") == $oldName || localizedPanelLabel("Side View") == $oldName || localizedPanelLabel("Front View") == $oldName) { // // Name is reserved. // string $msg = (uiRes("m_panelEditor.kCannotRenameMsg")); confirmDialog -title $alert -button $ok -defaultButton $ok -message (`format -s $oldName $msg`) -parent $gPanelEditorWnd; textFieldGrp -edit -text $oldName $tfg; } else if (size($newName) == 0) { // // Name is zero length // confirmDialog -title $alert -button $ok -defaultButton $ok -message (uiRes("m_panelEditor.kInvalidPanelName")) -parent $gPanelEditorWnd; textFieldGrp -edit -text $oldName $tfg; } else { // // Check for a duplicate name // $nArr = size($arrs); for ($i = 0; $i < $nArr; $i++) { if ($newName == `panel -query -label $arrs[$i]`) { $isUnique = false; confirmDialog -title $alert -button $ok -defaultButton $ok -message (uiRes("m_panelEditor.kDuplicatePanelName")) -parent $gPanelEditorWnd; textFieldGrp -edit -text $oldName $tfg; break; } } if ($isUnique) { // // Go ahead and change the name. // textScrollList -edit -deselectAll $tsl; textScrollList -edit -removeIndexedItem $selected[0] $tsl; textScrollList -edit -appendPosition $selected[0] $newName -selectIndexedItem $selected[0] $tsl; // find the right panel and update its label // $panelName = `getPanel -withLabel $oldName`; panel -edit -label $newName $panelName; // // Update any configs referring to that panel. // string $panelType; string $label; string $panelCreate; string $panelEdit; string $config; string $configs[] = `getPanel -allConfigs`; string $labels[]; for ($config in $configs) { $labels = `panelConfiguration -query -labelStrings $config`; $nArr = size ($labels); for ($i = 0; $i < $nArr; $i++) { if ($labels[$i] == $oldName) { $isFixed = `panelConfiguration -query -if $config`; $label = `panel -query -label $panelName`; $panelType = `getPanel -typeOf $panelName`; $panelCreate = `panel -query -cs $panelName`; $panelEdit = `panel -query -es $panelName`; panelConfiguration -edit -rp ($i+1) $isFixed[$i] $label $panelType $panelCreate $panelEdit $config; } } } // // Update option menus. // panelEd_UpdateOptMenuPanelItems; } } } global proc panelEd_NewPanel() { global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tsl = "PanelEditorNewPanelScrollList"; string $panelTsl = "PanelEditorPanelsScrollList"; string $selected[]; string $exsisting[]; string $types[] = `getMayaPanelTypes(false)`; string $scrollTypes[] = `getMayaPanelTypes(true)`; string $destPanel = `getPanel -withFocus`; int $isFound = false; string $alert = (uiRes("m_panelEditor.kAlertBoxTitle")); string $ok = (uiRes("m_panelEditor.kOKConfirm")); $selected = `textScrollList -query -selectItem $tsl`; string $displayMsg = (uiRes("m_panelEditor.kCannotMakeAnother")); for ($type in $types) { if ($selected[0] == localizedPanelLabel(interToUI($type))) { // // Make sure we don't try to create a second version of // a unique panel. // $existing = `getPanel -type $type`; if (size($existing) == 1) { if (eval ($type + " -query -isUnique "+ $existing[0])) { confirmDialog -title $alert -button $ok -defaultButton $ok -message (`format -s $selected[0] $displayMsg`) -parent $gPanelEditorWnd; break; } } // // Okay, clear to make new panel. // makeNewPanel $type "" $destPanel; $isFound = true; break; } } if (!$isFound) { for ($type in $scrollTypes) { if ($selected[0] == localizedPanelLabel(interToUI($type))) { // // Make sure we don't try to create a second version of // a unique panel. // $existing = `getPanel -sty $type`; if (size($existing) == 1) { if (eval ("scriptedPanel -query -isUnique "+ $existing[0])) { confirmDialog -title $alert -button $ok -defaultButton $ok -message (`format -s $selected[0] $displayMsg`) -parent $gPanelEditorWnd; break; } } // // Okay, clear to make new panel. // $isFound = true; makeNewPanel "scriptedPanel" $type $destPanel; } } } if ($isFound) { panelEd_UpdatePanelTab; textScrollList -edit -selectIndexedItem `textScrollList -query -numberOfItems $panelTsl` $panelTsl; panelEd_PanelSelectionChanged; panelEd_UpdateOptMenuPanelItems; } } global proc panelEd_PaneSeparatorChanged() { global string $gMainPane; global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tfg = "PanelEditorLayoutsTextFieldGrp"; string $pane = "PanelEditorConfigurationPanes"; string $whichArrangement = `textFieldGrp -query -text PanelEditorLayoutsTextFieldGrp`; int $i,$j; int $wh[] = `paneLayout -query -ps $pane`; int $nPanes = size($wh)/2; if ("" != $whichArrangement) { // // set main pane sizes // $cmdStr = "paneLayout -edit "; for ($i = 0; $i < $nPanes; $i++) { $j = $i+1; $cmdStr += ("-ps " + $j + " " + $wh[2*$i] + " " + $wh[2*$i+1] + " "); } $cmdStr += $gMainPane + ";"; eval $cmdStr; // // update option vars // updatePanelLayoutFromCurrent $whichArrangement; } } global proc string panelConfig_melToUI( string $panelConfig ) { string $menuSelection; if ($panelConfig == "single") { $menuSelection = localizedPanelLabel("Single Pane"); } else if ($panelConfig == "horizontal2") { $menuSelection = localizedPanelLabel("Two Panes Stacked"); } else if ($panelConfig == "vertical2") { $menuSelection = localizedPanelLabel("Two Panes Side by Side"); } else if ($panelConfig == "top3") { $menuSelection = localizedPanelLabel("Three Panes Split Top"); } else if ($panelConfig == "left3") { $menuSelection = localizedPanelLabel("Three Panes Split Left"); } else if ($panelConfig == "bottom3") { $menuSelection = localizedPanelLabel("Three Panes Split Bottom"); } else if ($panelConfig == "right3") { $menuSelection = localizedPanelLabel("Three Panes Split Right"); } else if ($panelConfig == "horizontal3") { $menuSelection = localizedPanelLabel("Three Panes Stacked"); } else if ($panelConfig == "vertical3") { $menuSelection = localizedPanelLabel("Three Panes Side by Side"); } else if ($panelConfig == "quad") { $menuSelection = localizedPanelLabel("Four Panes"); } else if ($panelConfig == "top4") { $menuSelection = localizedPanelLabel("Four Panes Split Top"); } else if ($panelConfig == "left4") { $menuSelection = localizedPanelLabel("Four Panes Split Left"); } else if ($panelConfig == "bottom4") { $menuSelection = localizedPanelLabel("Four Panes Split Bottom"); } else if ($panelConfig == "right4") { $menuSelection = localizedPanelLabel("Four Panes Split Right"); } else if ($panelConfig == "horizontal4") { $menuSelection = localizedPanelLabel("Four Panes Stacked"); } else if ($panelConfig == "vertical4") { $menuSelection = localizedPanelLabel("Four Panes Side by Side"); } else { $menuSelection = localizedPanelLabel("Single Pane"); } return $menuSelection; } global proc panelEd_UpdateLayoutEditTab() { global string $gMainPane; global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $tfg = "PanelEditorLayoutsTextFieldGrp"; string $configLabel = `textFieldGrp -query -text $tfg`; string $configName = `getPanel -cwl $configLabel`; // // Configuration Tab // string $panes = "PanelEditorConfigurationPanes"; string $optMenu = "PanelEditorConfigurationOptionMenu"; string $txt = "PanelEditorConfigurationArrangementLabel"; string $panelName, $menuSelection; int $wh[]; int $i, $j, $nPanes; // update the paneLayout // $panelConfig = `paneLayout -query -configuration $gMainPane`; paneLayout -edit -cn $panelConfig $panes; $wh = `paneLayout -query -ps $gMainPane`; $nPanes = size($wh)/2; for ($i = 0; $i < $nPanes; $i++) { $j = $i+1; paneLayout -edit -paneSize $j $wh[2*$i] $wh[2*$i+1] $panes; } // update config option menu // $menuSelection = panelConfig_melToUI( $panelConfig ); optionMenu -edit -value $menuSelection $optMenu; // update the layout name text // text -edit -label `textFieldGrp -query -text $tfg` $txt; // // Update Contents Tab // int $state; int $isSceneConfig = `panelConfiguration -query -sceneConfig $configName`; // Set enable states to reflect number of visible panes. // paneLayout -edit -configuration $panelConfig $panes; $nPanes = `paneLayout -query -numberOfVisiblePanes $panes`; for ($i = 0; $i < 4; $i++) { if ($i < $nPanes) { $state = true; } else { $state = false; } $optName = ("PanelEditorContentsOptionMenu" + $i); $chkName = ("PanelEditorContentsStateCheckBox" + $i); $btnName = ("PanelEditorContentsUpdateButton" + $i); optionMenu -edit -enable $state $optName; checkBox -edit -enable $state $chkName; button -edit -enable $state $btnName; } // Set the check boxes // int $nPanels = `panelConfiguration -query -numberOfPanels $configName`; int $fixed[] = `panelConfiguration -query -isFixedState $configName`; for ($i = 0; $i < $nPanels; $i++) { checkBox -edit -visible $fixed[$i] ("PanelEditorContentsStateCheckBox" + $i); } for ($i = $nPanels; $i < 4; $i ++) { checkBox -edit -visible false ("PanelEditorContentsStateCheckBox" + $i); } panelEd_LayoutDependenceUpdate $configName false; } global proc panelEd_LayoutDependenceChange(int $isSceneDependant) { // // Description: // Change in radio button state should update the panel config as well // as UI. // global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $configLabel = `textFieldGrp -query -text PanelEditorLayoutsTextFieldGrp`; string $configName = ""; string $labels[]; string $panelCreate; string $panelEdit; int $i, $nArr; int $update; if ("" != $configLabel) { $configName = `getPanel -cwl $configLabel`; if ("" != $configName) { panelConfiguration -edit -sc $isSceneDependant $configName; if (!$isSceneDependant) { // // Make sure top/front/side/persp are set to fixed state // and the state strings are set. // $labels = `panelConfiguration -query -ls $configName`; $nArr = size($labels); for ($i = 0; $i < $nArr; $i++) { $update = false; if (localizedPanelLabel("Top View") == $labels[$i]) { $update = true; $panelCreate = "modelPanel -unParent -label \"" + (localizedPanelLabel("Top View")) + "\" -cam `findStartUpCamera top`"; $panelEdit = "modelPanel -edit -label \"" + (localizedPanelLabel("Top View")) + "\" -cam `findStartUpCamera top` $panelName"; } else if (localizedPanelLabel("Side View") == $labels[$i]) { $update = true; $panelCreate = "modelPanel -unParent -label \"" + (localizedPanelLabel("Side View")) + "\" -cam `findStartUpCamera side`"; $panelEdit = "modelPanel -edit -label \"" + (localizedPanelLabel("Side View")) + "\" -cam `findStartUpCamera side` $panelName"; } else if (localizedPanelLabel("Front View") == $labels[$i]) { $update = true; $panelCreate = "modelPanel -unParent -label \"" + (localizedPanelLabel("Front View")) + "\" -cam `findStartUpCamera front`"; $panelEdit = "modelPanel -edit -label \"" + (localizedPanelLabel("Front View")) + "\" -cam `findStartUpCamera front` $panelName"; } else if (localizedPanelLabel("Persp View") == $labels[$i]) { $update = true; $panelCreate = "modelPanel -unParent -label \"" + (localizedPanelLabel("Persp View")) + "\" -cam `findStartUpCamera persp`"; $panelEdit = "modelPanel -edit -label \"" + (localizedPanelLabel("Persp View")) + "\" -cam `findStartUpCamera persp` $panelName"; } if ($update) { panelConfiguration -edit -rp ($i+1) true $labels[$i] "modelPanel" $panelCreate $panelEdit $configName; } } } } } panelEd_LayoutDependenceUpdate($configName,true); } global proc panelEd_LayoutDependenceUpdate(string $configName,int $forceUpdate) // // Description: // Update the UI to reflect the current panel config. // { if ("" == $configName) { // // Disable everything. // } else { global string $gMainPane; global string $gPanelEditorWnd; setParent $gPanelEditorWnd; int $isSceneConfig = `panelConfiguration -query -sceneConfig $configName`; string $rbg = "PanelEditorContentsSceneRadioButtonGrp"; string $ts = "PanelEditorContentsSelectLabel"; string $p, $p0, $p1, $p2, $p3, $p4; string $items[]; int $rbgSel = `radioButtonGrp -query -select $rbg`; int $count = 0; int $fixed[] = `panelConfiguration -query -isFixedState $configName`; // // Set enable states // for ($index = 0; $index < 4 && $index < size($fixed); $index++) { checkBox -edit -value $fixed[$index] ("PanelEditorContentsStateCheckBox" + $index); } for ($index = 0; $index < 4; $index++) { checkBox -edit -visible $isSceneConfig ("PanelEditorContentsStateCheckBox" + $index); button -edit -visible $isSceneConfig -enable `checkBox -query -value ("PanelEditorContentsStateCheckBox" + $index)` ("PanelEditorContentsUpdateButton" + $index); } // // Update option menus. // if ($forceUpdate || ($isSceneConfig && ($rbgSel == 1)) || (!$isSceneConfig && ($rbgSel == 2))) { // // change items from types to names or vice versa. // panelEd_UpdateOptMenuPanelItems; } if ($isSceneConfig) { radioButtonGrp -edit -select 2 $rbg; text -edit -label (uiRes("m_panelEditor.kSelectPanelNameLabel")) $ts; // // Panel names. // string $allPanels[] = `getPanel -allPanels`; string $panel; $p1 = `paneLayout -query -p1 $gMainPane`; $p2 = `paneLayout -query -p2 $gMainPane`; $p3 = `paneLayout -query -p3 $gMainPane`; $p4 = `paneLayout -query -p4 $gMainPane`; $count = 0; for ($panel in $allPanels) { string $type = `getPanel -typeOf $panel`; if ($type != "emptyPanel") { $items[$count++] = $panel; } } } else { radioButtonGrp -edit -select 1 $rbg; text -edit -label (uiRes("m_panelEditor.kSelectPanelbyType")) $ts; // // Panel types. // $p1 = `paneLayout -query -p1 $gMainPane`; $p2 = `paneLayout -query -p2 $gMainPane`; $p3 = `paneLayout -query -p3 $gMainPane`; $p4 = `paneLayout -query -p4 $gMainPane`; int $i; for ($i = 0; $i < 4; $i++) { switch($i) { case 0: $p0 = $p1; break; case 1: $p0 = $p2; break; case 2: $p0 = $p3; break; case 3: $p0 = $p4; break; } if ("" != $p0) { if (localizedPanelLabel("Top View") == `panel -query -label $p0`) { $p0 = "topPanel"; } else if (localizedPanelLabel("Persp View") == `panel -query -label $p0`) { $p0 = "perspPanel"; } else if (localizedPanelLabel("Side View") == `panel -query -label $p0`) { $p0 = "sidePanel"; } else if (localizedPanelLabel("Front View") == `panel -query -label $p0`) { $p0 = "frontPanel"; } else { $p = `getPanel -to $p0`; if ("scriptedPanel" == $p) { $p = `scriptedPanel -query -type $p0`; } $p0 = $p; } switch($i) { case 0: $p1 = $p0; break; case 1: $p2 = $p0; break; case 2: $p3 = $p0; break; case 3: $p4 = $p0; break; } } } int $nTypes, $nScrollTypes; string $allTypes[] = `getMayaPanelTypes(false)`; string $scrollTypes[] = `getMayaPanelTypes(true)`; $count = 0; $items[$count++] = "topPanel"; $items[$count++] = "frontPanel"; $items[$count++] = "sidePanel"; $items[$count++] = "perspPanel"; $nTypes = size($allTypes); for ($i = 0; $i < $nTypes; $i++) { $items[$count++] = $allTypes[$i]; } $nTypes = size($scrollTypes); for ($i = 0; $i < $nTypes; $i++) { if ("setEditor" != $scrollTypes[$i] && "shadingGroupEditor" != $scrollTypes[$i]) { $items[$count++] = $scrollTypes[$i]; } } } $count = size ($items); for ($i = 0; $i < $count; $i++) { if ($items[$i] == $p1) { // There are cases when $i+1 is higher than `optionMenu -q -numberOfItems`. // And wrapping the call w/ an index check to avoid the error might // hamper investigation of bug 254190. // catch( `optionMenu -edit -select ($i + 1) PanelEditorContentsOptionMenu0` ); } if ($items[$i] == $p2) { catch( `optionMenu -edit -select ($i + 1) PanelEditorContentsOptionMenu1` ); } if ($items[$i] == $p3) { catch( `optionMenu -edit -select ($i + 1) PanelEditorContentsOptionMenu2` ); } if ($items[$i] == $p4) { catch( `optionMenu -edit -select ($i + 1) PanelEditorContentsOptionMenu3` ); } } } } global proc panelEd_LayoutEditFixedChange(int $whichPane) { // // Description: // Called when the fix state checkbox changes state for the specified panel. // global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $configLabel = `textFieldGrp -query -text PanelEditorLayoutsTextFieldGrp`; string $configName = ""; string $checkName = ("PanelEditorContentsStateCheckBox" + $whichPane); string $buttonName = ("PanelEditorContentsUpdateButton" + $whichPane); int $isFixed; if ("" != $configLabel) { $configName = `getPanel -cwl $configLabel`; } $isFixed = `checkBox -query -value $checkName`; panelConfiguration -edit -replaceFixedState ($whichPane + 1) $isFixed $configName; button -edit -enable $isFixed $buttonName; } global proc panelEd_LayoutEditUpdateBtnAction(int $whichPane) { // // Description: // Called when the Update button is pressed for the specified panel. // global string $gPanelEditorWnd; setParent $gPanelEditorWnd; string $configLabel = `textFieldGrp -query -text PanelEditorLayoutsTextFieldGrp`; string $configName = ""; string $panelName = ""; string $checkName = ("PanelEditorContentsUpdateButton" + $whichPane); int $fixed[]; string $labels[]; string $types[]; string $create[]; string $edit[]; int $index = $whichPane; string $pLabel; if ("" != $configLabel) { $configName = `getPanel -cwl $configLabel`; } $fixed = `panelConfiguration -query -isFixedState $configName`; $labels = `panelConfiguration -query -labelStrings $configName`; $types = `panelConfiguration -query -typeStrings $configName`; $create = `panelConfiguration -query -createStrings $configName`; $edit = `panelConfiguration -query -editStrings $configName`; $panelName = `getPanel -wl $labels[$index]`; if ("" != $panelName) { $create[$index] = `panel -query -cs $panelName`; $edit[$index] = `panel -query -es $panelName`; } // // Substitute dynamic camera function for top,persp,front,side panels. // string $buffStr, $buffStr2;; string $kCameraFlagStr = "-cam[a-z]*[ ][^ ^;]*"; string $kFindPerspStr = "-cam `findStartUpCamera persp`"; string $kFindTopStr = "-cam `findStartUpCamera top`"; string $kFindSideStr = "-cam `findStartUpCamera side`"; string $kFindFrontStr = "-cam `findStartUpCamera front`"; if ("modelPanel" == $types[$index]) { if (localizedPanelLabel("Persp View") == $labels[$index]) { $buffStr = substitute ($kCameraFlagStr, $edit[$index], $kFindPerspStr); $buffStr2 = substitute ($kCameraFlagStr, $create[$index], $kFindPerspStr); $edit[$index] = $buffStr; $create[$index] = $buffStr2; } else if (localizedPanelLabel("Top View") == $labels[$index]) { $buffStr = substitute ($kCameraFlagStr, $edit[$index], $kFindTopStr); $buffStr2 = substitute ($kCameraFlagStr, $create[$index], $kFindTopStr); $edit[$index] = $buffStr; $create[$index] = $buffStr2; } else if (localizedPanelLabel("Side View") == $labels[$index]) { $buffStr = substitute ($kCameraFlagStr, $edit[$index], $kFindSideStr); $buffStr2 = substitute ($kCameraFlagStr, $create[$index], $kFindSideStr); $edit[$index] = $buffStr; $create[$index] = $buffStr2; } else if (localizedPanelLabel("Front View") == $labels[$index]) { $buffStr = substitute ($kCameraFlagStr, $edit[$index], $kFindFrontStr); $buffStr2 = substitute ($kCameraFlagStr, $create[$index], $kFindFrontStr); $edit[$index] = $buffStr; $create[$index] = $buffStr2; } } panelConfiguration -edit -rp ($index+1) $fixed[$index] $labels[$index] $types[$index] $create[$index] $edit[$index] $configName; }