// =========================================================================== // 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: 28 November 2000 // // Description: // Builds a menu's and commands for the list of image planes // associated with the current camera. // // // Procedure Name: // getImagePlaneList // // Description: // Create a list of image planes for the current camera view. // // Input Arguments: // None. // // Return Value: // Array of image plane names // proc string[] getImagePlaneList( string $cameraShape ) { string $result[]; if ($cameraShape != "") { $result = `listConnections -shapes on ($cameraShape + ".imagePlane")`; // if nothing is found, then find imageplane through connections of orient-constraint. if (size($result) == 0) { // first, find transform of the camera. // no handling to camera instance case. string $cameraTrans[] = `listRelatives -type "transform" -p $cameraShape`; if (size($cameraTrans) == 1) { // second, find the orient-constraint. string $allConstraints[] = `listConnections -s false -d true -t "orientConstraint" ($cameraTrans[0] + ".rotate")`; for ($constraint in $allConstraints) { // third, find the transform of imageplane. // no handling to imageplane instance case. string $ipTrans[] = `listConnections -s false -d true -t "transform" ($constraint + ".constraintRotateX")`; if (size($ipTrans) == 1) { // finaly, find the imageplane. string $ips[] = `listRelatives -type "imagePlane" $ipTrans[0]`; if (size($ips) == 1) { $result[size($result)] = $ips[0]; } } } } } } return $result; } global proc buildImagePlaneList (string $parent, string $cameraList[]) // // builds a menu list of image planes for a one or more cameras // { setParent -m $parent; menu -e -deleteAllItems $parent; // Find image planes for all cameras. Remove duplicates. string $allImagePlanes[]; for ($camera in $cameraList) { string $imagePlanes[] = `getImagePlaneList $camera`; appendStringArray($allImagePlanes, $imagePlanes, size($imagePlanes)); } $allImagePlanes = stringArrayRemoveDuplicates($allImagePlanes); for ($imagePlane in $allImagePlanes) { string $editCommand = "select " + $imagePlane + "; showEditor " + $imagePlane; menuItem -tearOff false -l $imagePlane -command $editCommand; } } // // Procedure Name: // buildImagePlaneMenu // // Description: // Builds a menu for managing image planes in the model pane's // view menu. // // Input Arguments: // parent : parent menu to build menu for. // // Return Value: // None. // global proc buildImagePlaneMenu (string $parent, string $modelPanel) { string $cameraList[] = `getPanelCamera $modelPanel`; int $anyImagePlanes = 0; for ($camera in $cameraList) { string $imagePlanes[] = `getImagePlaneList $camera`; $anyImagePlanes = size($imagePlanes) > 0; if ($anyImagePlanes) break; } setParent -m $parent; menu -e -deleteAllItems $parent; string $cameraListString = stringArrayToString($cameraList, "\",\""); $cameraListString = "{ \"" + $cameraListString + "\" }"; menuItem -label (uiRes("m_buildImagePlaneMenu.kImportImage")) -c ("importImagePlane " + $cameraListString) importImageMenuItem; menuItem -label (uiRes("m_buildImagePlaneMenu.kImportMovie")) -c ("importMovieImagePlane " + $cameraListString) importMovieMenuItem; string $imagePlaneMenu = `menuItem -label (uiRes("m_buildImagePlaneMenu.kImagePlaneAttributes")) -enable $anyImagePlanes -subMenu true -tearOff false imagePlaneEditSubMenu`; string $postCommand = ("buildImagePlaneList " + $imagePlaneMenu + " " + $cameraListString); menuItem -e -postMenuCommand $postCommand $imagePlaneMenu; setParent -m ..; // from imagePlaneSubmenu }