// =========================================================================== // 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 April 1997 // // Description: // This implements the user interface for camera bookmarks. // proc buildBookmarkList(string $camera) { int $selected[] = `textScrollList -q -selectIndexedItem list`; textScrollList -e -removeAll list; string $bookmarks[] = `listConnections ($camera+".bookmarks")`; string $bookmarks3D[] = {}; string $bookmarks2D[] = {}; for ( $item in $bookmarks) { $viewType = `getAttr ($item + ".viewType")`; if ($viewType == 0) $bookmarks3D[size($bookmarks3D)] = $item; else if ($viewType == 1) $bookmarks2D[size($bookmarks2D)] = $item + (uiRes("m_cameraBookmarkEditor.kPanZoom")); } for ( $item in $bookmarks3D) textScrollList -e -append $item list; for ( $item in $bookmarks2D) textScrollList -e -append $item list; // Was something selected and are there remaining bookmarks ? if (size($selected) > 0 && size($bookmarks) > 0) { int $index = min($selected[0], size($bookmarks)); textScrollList -e -selectIndexedItem $index list; } } proc string selectedBookmark() { string $items[] = `textScrollList -q -selectItem list`; string $selected = ""; string $panZoomSuffix = (uiRes("m_cameraBookmarkEditor.kPanZoom")); if(size($items) > 0) { if(endsWith($items[0], $panZoomSuffix)) $selected = substring($items[0], 1, size($items[0]) - size($panZoomSuffix)); else $selected = $items[0]; } return $selected; } // // Procedure Name: // cameraBookmarkListCB // // Description: // This procedure is called when the user selects an item in the // list. The name and description controls are updated to reflect // this item. // global proc cameraBookmarkListCB(string $parent) { setParent $parent; string $item = selectedBookmark(); if ($item != "") { textFieldGrp -e -text $item name; textFieldGrp -e -text `getAttr ($item+".description")` desc; } else { textFieldGrp -e -text "" name; textFieldGrp -e -text "" desc; } } // // Procedure Name: // cameraBookmarkNameCB // // Description: // This procedure is called when the user has modified the // text of the name control. // global proc cameraBookmarkNameCB(string $parent, string $camera) { setParent $parent; string $item = selectedBookmark(); // Nothing is selected ? if ($item == "") { // Create a new item and assign the name. $item = `cameraView -addBookmark -camera $camera`; string $name = `textFieldGrp -q -text name`; string $newName = `rename $item $name`; buildBookmarkList($camera); textScrollList -e -selectItem $newName list; textFieldGrp -e -text $newName name; textFieldGrp -e -text "" desc; } else { // Modify name of the selected item. string $name = `textFieldGrp -q -text name`; string $newName = `rename $item $name`; buildBookmarkList($camera); if(`getAttr ($newName + ".viewType")` == 1) $newName = $newName + (uiRes("m_cameraBookmarkEditor.kPanZoom")); textScrollList -e -selectItem $newName list; textFieldGrp -e -text $name name; } } // // Procedure Name: // cameraBookmarkNameCB // // Description: // This procedure is called when the user has modified the // text of the description control. // global proc cameraBookmarkDescCB(string $parent, string $camera) { setParent $parent; string $item = selectedBookmark(); // Nothing is selected ? if ($item == "") { // Create a new item and assign the description. $item = `cameraView -addBookmark -camera $camera`; string $description = `textFieldGrp -q -text desc`; setAttr ($item+".description") -type "string" $description; buildBookmarkList($camera); textScrollList -e -selectItem $item list; textFieldGrp -e -text $item name; } else { // Modify description of the selected item. string $desc = `textFieldGrp -q -text desc`; setAttr ($item+".description") -type "string" $desc; } } // // Procedure Name: // cameraBookmarkApplyCB // // Description: // This procedure is called when the user has pressed the apply // button or double clicked on an item in the list. The selected // view is applied to the camera. // global proc cameraBookmarkApplyCB(string $parent, string $camera) { setParent $parent; string $item = selectedBookmark(); if ($item != "") { cameraView -e -camera $camera -setCamera $item; } } // // Procedure Name: // cameraBookmarkShelfCB // // Description: // This procedure is called when the user has pressed the shelf // button. // global proc cameraBookmarkShelfCB(string $parent, string $camera) { setParent $parent; string $item = selectedBookmark(); if ($item != "") { global string $gShelfTopLevel; if (`tabLayout -exists $gShelfTopLevel`) { string $currentShelf = `tabLayout -q -selectTab $gShelfTopLevel`; string $cmdStr = "cameraView -e -camera "+$camera+" -setCamera "+$item; shelfButton -p ($gShelfTopLevel + "|" + $currentShelf) -image1 "commandButton.png" -label $item -style `shelfLayout -q -style $currentShelf` -width `shelfLayout -q -cellWidth $currentShelf` -height `shelfLayout -q -cellHeight $currentShelf` -c $cmdStr; } } } // // Procedure Name: // cameraBookmarkNewCB // // Description: // This procedure is called when the user has pressed the new // button. A new camera view using the current camera position is // created. // global proc cameraBookmarkNewCB(string $parent, string $camera) { setParent $parent; string $item = `cameraView -addBookmark -camera $camera`; buildBookmarkList($camera); textScrollList -e -selectItem $item list; textFieldGrp -e -text $item name; textFieldGrp -e -text "" desc; } // // Procedure Name: // cameraBookmarkNew2DCB // // Description: // This procedure is called when the user has pressed the new 2D // bookmark button. A new 2D pan/zoom view using the current pan/zoom // settings is created. // global proc cameraBookmarkNew2DCB(string $parent, string $camera) { setParent $parent; string $item = `cameraView -addBookmark -camera $camera -bookmarkType 1`; buildBookmarkList($camera); string $itemWithSuffix = $item + (uiRes("m_cameraBookmarkEditor.kPanZoom")); textScrollList -e -selectItem $itemWithSuffix list; textFieldGrp -e -text $item name; textFieldGrp -e -text "" desc; } // // Procedure Name: // cameraBookmarkDelCB // // Description: // This procedure is called when the user has pressed the delete // button or pressed the delete key. The selected view is deleted. // global proc cameraBookmarkDelCB(string $parent, string $camera) { setParent $parent; string $item = selectedBookmark(); if ($item != "") { delete $item; buildBookmarkList($camera); cameraBookmarkListCB($parent); } } // // Procedure Name: // cameraBookmarkEditor // // Description: // Display an editor for editting the bookmarks associated with // camera. // global proc cameraBookmarkEditor( string $camera ) { string $title = (uiRes("m_cameraBookmarkEditor.kBookmarkEditor")); $title = `format -s $camera $title`; string $win = `window -title $title -iconName (uiRes("m_cameraBookmarkEditor.kBookmarks")) cameraBookmarkWindow`; formLayout winForm; textScrollList -height 180 list; columnLayout -adj true col; textFieldGrp -label (uiRes("m_cameraBookmarkEditor.kName")) name; textFieldGrp -label (uiRes("m_cameraBookmarkEditor.kDescription")) desc; separator -style none -height 15; formLayout btnForm; button -label (uiRes("m_cameraBookmarkEditor.kApply")) apply; button -label (uiRes("m_cameraBookmarkEditor.kAddToShelf")) shelf; button -label (uiRes("m_cameraBookmarkEditor.kNewBookmark")) new; button -label (uiRes("m_cameraBookmarkEditor.kNew2DBookmark")) new2D; button -label (uiRes("m_cameraBookmarkEditor.kDelete")) del; setParent ..; button -label (uiRes("m_cameraBookmarkEditor.kClose")) close; formLayout -e -af apply left 0 -af apply top 0 -ap apply right 2 15 -af apply bottom 10 -af shelf top 0 -ap shelf left 0 15 -ap shelf right 2 35 -af shelf bottom 10 -af new top 0 -ap new left 0 35 -ap new right 2 58 -af new bottom 10 -af new2D top 0 -ap new2D left 0 58 -ap new2D right 2 85 -af new2D bottom 10 -af del right 0 -af del top 0 -ap del left 0 85 -af del bottom 10 btnForm; formLayout -e -af list left 15 -af list top 10 -af list right 15 -ac list bottom 10 col -af col left 10 -af col bottom 10 -af col right 10 winForm; buildBookmarkList($camera); textScrollList -e -sc ("cameraBookmarkListCB "+$win) list; textScrollList -e -dcc ("cameraBookmarkApplyCB "+$win+" "+$camera) list; textScrollList -e -dkc ("cameraBookmarkDelCB "+$win+" "+$camera) list; textFieldGrp -e -cc ("cameraBookmarkNameCB "+$win+" "+$camera) name; textFieldGrp -e -cc ("cameraBookmarkDescCB "+$win+" "+$camera) desc; button -e -c ("cameraBookmarkApplyCB "+$win+" "+$camera) apply; button -e -c ("cameraBookmarkShelfCB "+$win+" "+$camera) shelf; button -e -c ("cameraBookmarkNewCB "+$win+" "+$camera) new; button -e -c ("cameraBookmarkNew2DCB "+$win+" "+$camera) new2D; button -e -c ("cameraBookmarkDelCB "+$win+" "+$camera) del; button -e -c ("deleteUI "+$win) close; showWindow $win; }