// =========================================================================== // 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: June 4, 2014 // // Description: // This script is used to handle visualization options for metadata // // Input Arguments: // int showOptionBox true - show the option box dialog // false - just execute the command // // Return Value: // None. // // Three visual method name of metadata global string $gMetadataVisualMethodNames[]; // Stored option setting for each stream global string $gMetadataSavedStreamMembers[]; global int $gMetadataSavedVisualMethodSettings[]; global int $gMetadataSavedDataRemappingSettings[]; global float $gMetadataSavedRangeSettings[]; global int $gMetadataSavedInterpolationSettings[]; global float $gMetadataSavedRayScaleSettings[]; global int $gMetadataDefaultVisualMethod = 1; global int $gMetadataDefaultRemapType = 1; global float $gMetadataDefaultMinValue = 0.0; global float $gMetadataDefaultMaxValue = 1.0; global int $gMetadataDefaultInterpolation = 0; global float $gMetadataDefaultRayScale = 1.0; // // Procedure Name: // buildMemberName // // Description: // Join member name with member type together // to show them on UI // // Input Arguments: // memberName - the name of the member // memberType - the type string of the member // // Return Value: // A string contains both memberName and memberType // global proc string buildMemberName(string $memberName, string $memberType) { $memberName = $memberName + "." + $memberType; return $memberName; } // // Procedure Name: // buildStreamMemberName // // Description: // Join stream name with member name // to handle visualization through UI // and script // // Input Arguments: // streamName - the name of the stream // memberName - the name of the member // // Return Value: // The name of the current stream and member // global proc string buildStreamMemberName(string $streamName, string $memberName) { string $streamMemberName = $streamName + "." + $memberName; return $streamMemberName; } // // Procedure Name: // getCurrentStreamMember // // Description: // Query the current stream and member. // The current stream&member could be either activated or // inactivated by menu directly. // // Input Arguments: // None. // // Return Value: // The name of the current stream // global proc string getCurrentStreamMember() { string $currentStreamMemberName = ""; if(`optionVar -exists metadataVisualCurrentStreamMember`) { $currentStreamMemberName = `optionVar -query metadataVisualCurrentStreamMember`; } if(size($currentStreamMemberName) == 0) { string $defaultStreamMember = ""; string $allShapes[] = `ls -shapes`; if(size($allShapes) > 0) { string $allStreams[] = `showMetadata -query -listAllStreams`; if(size($allStreams) > 0) { string $members[] = `showMetadata -query -stream $allStreams[0] -listMembers`; if(size($members) > 1) { // default stream member name is "streamName.memberName.memberType" $defaultStreamMember = $allStreams[0] + "." + $members[0] + "." + $members[1]; } } } optionVar -sv metadataVisualCurrentStreamMember $defaultStreamMember; } return `optionVar -query metadataVisualCurrentStreamMember`; } // // Procedure Name: // activateStreamMember // // Description: // Activate the specified stream and member // // Input Arguments: // streamName - the name of the specified stream // // Return Value: // None. // global proc activateStreamMember(string $streamMemberName) { // Don't activate already activated stream again. string $currentStreamMember = getCurrentStreamMember(); if($currentStreamMember == $streamMemberName) { string $tokens[] = stringToStringArray($currentStreamMember, "."); int $isActivated = `showMetadata -query -isActivated -stream $tokens[0] -member $tokens[1] -dataType $tokens[2]`; if($isActivated) { return; } } optionVar -sv metadataVisualCurrentStreamMember $streamMemberName; performVisualizeMetadataOptions(0); } // // Procedure Name: // updateMetadataOptionBox // // Description: // Update all options in the option box // to reflects the current setting. // // Input Arguments: // None. // // Return Value: // None. // global proc updateMetadataOptionBox() { global string $gStreamListWidget; global string $gMemberListWidget; if(`optionMenuGrp -query -exists $gStreamListWidget`) { string $currentStreamMember = getCurrentStreamMember(); string $streamMemberTokens[] = stringToStringArray($currentStreamMember, "."); string $memberName = buildMemberName($streamMemberTokens[1], $streamMemberTokens[2]); int $i; int $j; string $streamItems[] = `optionMenuGrp -q -itemListLong $gStreamListWidget`; int $selectedStreamOption = `optionMenuGrp -q -select $gStreamListWidget`; for($i = 0; $i < size($streamItems); $i++) { string $label = `menuItem -q -label $streamItems[$i]`; if($label == $streamMemberTokens[0]) { if($selectedStreamOption != $i+1) { $selectedStreamOption = $i+1; optionMenuGrp -e -select $selectedStreamOption $gStreamListWidget; switchStream(0); } string $memberItems[] = `optionMenuGrp -q -itemListLong $gMemberListWidget`; int $selectedMemberOption = `optionMenuGrp -q -select $gMemberListWidget`; for($j = 0; $j < size($memberItems); $j++) { string $label = `menuItem -q -label $memberItems[$j]`; if($label == $memberName) { if($selectedMemberOption != $j+1) { $selectedMemberOption = $j+1; optionMenuGrp -e -select $selectedMemberOption $gMemberListWidget; } } } switchMember(); } } } } // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { global string $gMetadataVisualMethodNames[]; $gMetadataVisualMethodNames = {"color", "string", "ray"}; global string $gMetadataSavedStreamMembers[]; global int $gMetadataSavedVisualMethodSettings[]; global int $gMetadataSavedDataRemappingSettings[]; global float $gMetadataSavedRangeSettings[]; global int $gMetadataSavedInterpolationSettings[]; global float $gMetadataSavedRayScaleSettings[]; global string $gMetadataVisualMethodNames[]; global int $gMetadataDefaultVisualMethod; global int $gMetadataDefaultRemapType; global float $gMetadataDefaultMinValue; global float $gMetadataDefaultMaxValue; global int $gMetadataDefaultInterpolation; global float $gMetadataDefaultRayScale; // clean all saved settings if($forceFactorySettings) { $gMetadataSavedStreamMembers = {}; $gMetadataSavedVisualMethodSettings = {}; $gMetadataSavedDataRemappingSettings = {}; $gMetadataSavedRangeSettings = {}; $gMetadataSavedInterpolationSettings = {}; optionVar -sv metadataVisualCurrentStreamMember ""; optionVar -sv metadataVisualMethod $gMetadataVisualMethodNames[$gMetadataDefaultVisualMethod - 1]; optionVar -fv metadataVisualMin $gMetadataDefaultMinValue; optionVar -fv metadataVisualMax $gMetadataDefaultMaxValue; optionVar -iv metadataVisualAuto 0; optionVar -iv metadataVisualInterpolation $gMetadataDefaultInterpolation; optionVar -fv metadataVisualRayScale $gMetadataDefaultRayScale; } else { string $allStreams[] = `showMetadata -query -listAllStreams`; if(size($allStreams) <= 0) { optionVar -sv metadataVisualCurrentStreamMember ""; return; } string $currentStreamMember = getCurrentStreamMember(); int $i; int $currentStreamIndex = stringArrayFind($currentStreamMember, 0, $gMetadataSavedStreamMembers); // if UI does not exists, the saved setting or the // default settings will be used. if($currentStreamIndex >= 0) { string $visualMethodName = $gMetadataVisualMethodNames[$gMetadataSavedVisualMethodSettings[$currentStreamIndex]-1]; optionVar -sv metadataVisualMethod $visualMethodName; optionVar -fv metadataVisualMin $gMetadataSavedRangeSettings[($currentStreamIndex)*2]; optionVar -fv metadataVisualMax $gMetadataSavedRangeSettings[($currentStreamIndex)*2+1]; optionVar -iv metadataVisualAuto ($gMetadataSavedDataRemappingSettings[$currentStreamIndex] == 3); optionVar -iv metadataVisualInterpolation $gMetadataSavedInterpolationSettings[$currentStreamIndex]; optionVar -fv metadataVisualRayScale $gMetadataSavedRayScaleSettings[$currentStreamIndex]; } else { optionVar -sv metadataVisualMethod $gMetadataVisualMethodNames[$gMetadataDefaultVisualMethod - 1]; optionVar -fv metadataVisualMin $gMetadataDefaultMinValue; optionVar -fv metadataVisualMax $gMetadataDefaultMaxValue; optionVar -iv metadataVisualAuto 0; optionVar -iv metadataVisualInterpolation $gMetadataDefaultInterpolation; optionVar -fv metadataVisualRayScale $gMetadataDefaultRayScale; } } } // // Procedure Name: // visualizeMetadataSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc visualizeMetadataSetup(int $forceFactorySettings) { setOptionVars($forceFactorySettings); string $allShapes[] = `ls -shapes`; int $i; int $j; global string $gStreamListWidget; global string $gMemberListWidget; if(size($allShapes) > 0 && `optionMenuGrp -query -exists $gStreamListWidget` && `optionMenuGrp -query -exists $gMemberListWidget`) { string $currentStreamMemberName = `optionVar -query metadataVisualCurrentStreamMember`; string $allStreamList[] = `showMetadata -query -listAllStreams`; // clean old options string $streamMenuItems[] = `optionMenuGrp -q -itemListLong $gStreamListWidget`; if(size($streamMenuItems) > 0) deleteUI -menuItem $streamMenuItems; // clean old options string $memberMenuItems[] = `optionMenuGrp -q -itemListLong $gMemberListWidget`; if(size($memberMenuItems) > 0) deleteUI -menuItem $memberMenuItems; // reset saved options to its previous setting global string $gMetadataSavedStreamMembers[]; global int $gMetadataSavedVisualMethodSettings[]; global int $gMetadataSavedDataRemappingSettings[]; global float $gMetadataSavedRangeSettings[]; global int $gMetadataSavedInterpolationSettings[]; global float $gMetadataSavedRayScaleSettings[]; string $newStreamMembers[]; int $visualMethodSettings[]; int $dataRemappingSettings[]; float $rangeSettings[]; int $interpolationSettings[]; float $rayScaleSettings[]; int $selectedStreamIndex = 1; int $selectedMemberIndex = 1; // add menu item according to the streams int $currentStreamActivated = 0; string $membersInStream[]; // look for the activated menu string $streamMemberTokens[] = stringToStringArray($currentStreamMemberName, "."); for($i = 0; $i < size($allStreamList); $i++) { if($streamMemberTokens[0] == $allStreamList[$i]) { $membersInStream = `showMetadata -query -stream $allStreamList[$i] -listMembers`; for($j = 0; $j < (size($membersInStream)/2); $j++) { if(!$currentStreamActivated && $streamMemberTokens[1] == $membersInStream[$j*2] && $streamMemberTokens[2] == $membersInStream[$j*2+1]) { $selectedStreamIndex = ($i+1); $selectedMemberIndex = ($j+1); $currentStreamActivated = 1; break; } } } if($currentStreamActivated) break; } // create menus string $streamListWidgetMenu = $gStreamListWidget + "|OptionMenu"; for($i = 0; $i < size($allStreamList); $i++) { menuItem -label $allStreamList[$i] -parent $streamListWidgetMenu; } string $memberListWidgetMenu = $gMemberListWidget + "|OptionMenu"; $membersInStream = `showMetadata -query -stream $allStreamList[$selectedStreamIndex - 1] -listMembers`; for($j = 0; $j < (size($membersInStream)/2); $j++) { string $memberName = buildMemberName($membersInStream[$j*2], $membersInStream[$j*2+1]); menuItem -label $memberName -parent $memberListWidgetMenu; } // select the first stream if no specified one if(`optionMenuGrp -query -numberOfItems $gStreamListWidget` > 0 && `optionMenuGrp -query -numberOfItems $gMemberListWidget` > 0 ) { optionMenuGrp -e -select $selectedStreamIndex $gStreamListWidget; optionMenuGrp -e -select $selectedMemberIndex $gMemberListWidget; } } // update UI default setting switchMember(); } // // Procedure Name: // visualizeMetadataCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc visualizeMetadataCallback(int $doIt) { global string $gStreamListWidget; global string $gMemberListWidget; global string $gMetadataSavedStreamMembers[]; global int $gMetadataSavedVisualMethodSettings[]; global int $gMetadataSavedDataRemappingSettings[]; global float $gMetadataSavedRangeSettings[]; global int $gMetadataSavedInterpolationSettings[]; global float $gMetadataSavedRayScaleSettings[]; int $currentStreamMemberOption = -1; // get the index of the selected stream if(`optionMenuGrp -query -exists $gStreamListWidget` && `optionMenuGrp -query -exists $gMemberListWidget`) { string $streamItems[] = `optionMenuGrp -q -itemListLong $gStreamListWidget`; int $selectedStreamOption = `optionMenuGrp -q -select $gStreamListWidget`; string $memberItems[] = `optionMenuGrp -q -itemListLong $gMemberListWidget`; int $selectedMemberOption = `optionMenuGrp -q -select $gMemberListWidget`; if(size($streamItems) > 0 && $selectedStreamOption > 0 && size($memberItems) > 0 && $selectedMemberOption > 0) { string $streamName = `menuItem -q -label $streamItems[$selectedStreamOption-1]`; string $memberName = `menuItem -q -label $memberItems[$selectedMemberOption-1]`; string $streamMemberName = buildStreamMemberName($streamName, $memberName); optionVar -sv metadataVisualCurrentStreamMember $streamMemberName; $currentStreamMemberOption = stringArrayFind($streamMemberName, 0, $gMetadataSavedStreamMembers); if($currentStreamMemberOption < 0) { $currentStreamMemberOption = size($gMetadataSavedStreamMembers); $gMetadataSavedStreamMembers[$currentStreamMemberOption] = $streamMemberName; } } } global string $gVisualMethodWidget; if(`radioButtonGrp -query -exists $gVisualMethodWidget`) { global string $gMetadataVisualMethodNames[]; if(size($gMetadataVisualMethodNames) > 0) { int $visualMethodOption = `radioButtonGrp -q -select $gVisualMethodWidget`; string $visualMethodName = $gMetadataVisualMethodNames[$visualMethodOption-1]; optionVar -sv metadataVisualMethod $visualMethodName; if($currentStreamMemberOption >= 0) { $gMetadataSavedVisualMethodSettings[$currentStreamMemberOption] = $visualMethodOption; } // set the data Color interpretation according to the // selected UI option global string $gColorRemapRangeWidget; if(`radioButtonGrp -query -exists $gColorRemapRangeWidget`) { int $currentRemapRange = `radioButtonGrp -q -select $gColorRemapRangeWidget`; float $visualMin; float $visualMax; int $visualAuto; switch($currentRemapRange) { // 0-1 case 1: $visualAuto = 0; $visualMin = 0.0; $visualMax= 1.0; break; // 0-255 case 2: $visualAuto = 0; $visualMin = 0.0; $visualMax= 255.0; break; // auto case 3: $visualAuto = 1; $visualMin = 0.0; $visualMax= 1.0; break; // customized range case 4: $visualAuto = 0; $visualMin = 0.0; $visualMax= 1.0; global string $gColorRemapLowerRangeWidget; if(`floatFieldGrp -q -exists $gColorRemapLowerRangeWidget`) $visualMin = `floatFieldGrp -q -value1 $gColorRemapLowerRangeWidget`; global string $gColorRemapUpperRangeWidget; if(`floatFieldGrp -q -exists $gColorRemapUpperRangeWidget`) $visualMax = `floatFieldGrp -q -value1 $gColorRemapUpperRangeWidget`; break; } optionVar -iv metadataVisualAuto $visualAuto; optionVar -fv metadataVisualMin $visualMin; optionVar -fv metadataVisualMax $visualMax; if($currentStreamMemberOption >= 0) { $gMetadataSavedDataRemappingSettings[$currentStreamMemberOption] = $currentRemapRange; $gMetadataSavedRangeSettings[($currentStreamMemberOption)*2] = $visualMin; $gMetadataSavedRangeSettings[($currentStreamMemberOption)*2+1] = $visualMax; } } // set the interpolation option global string $gColorInterpolationWidget; if(`checkBoxGrp -query -exists $gColorInterpolationWidget`) { int $isInterpolation = `checkBoxGrp -query -value1 $gColorInterpolationWidget`; optionVar -iv metadataVisualInterpolation $isInterpolation; if($currentStreamMemberOption >= 0) { $gMetadataSavedInterpolationSettings[$currentStreamMemberOption] = $isInterpolation; } } // set the ray scale option global string $gMetadataRayScaleWidget; if(`floatSliderGrp -query -exists $gMetadataRayScaleWidget`) { float $rayScale = `floatSliderGrp -query -value $gMetadataRayScaleWidget`; optionVar -fv metadataVisualRayScale $rayScale; if($currentStreamMemberOption >= 0) { $gMetadataSavedRayScaleSettings[$currentStreamMemberOption] = $rayScale; } } } } if ($doIt) { performVisualizeMetadataOptions 0; addToRecentCommandQueue "performVisualizeMetadataOptions 0" "VisualizeMetadataOptions"; } } // // Procedure Name: // switchColorRemmapType // // Description: // Show or hide the custom range text box according to the // selected remapping type for color. Show the text widget // only when "custom range" is choosed. Otherwise, hide it. // This callback method is called when the state of the radio // button group "Color interpretation" is changed. // // Input Arguments: // None. // // Return Value: // None. // global proc switchColorRemmapType() { global string $gColorRemapRangeWidget; if(`radioButtonGrp -q -exists $gColorRemapRangeWidget`) { int $colorRemapType = `radioButtonGrp -q -sl $gColorRemapRangeWidget`; global string $gColorRemapRangeLayout; if(`frameLayout -q -exists $gColorRemapRangeLayout`) { frameLayout -e -enable ($colorRemapType == 4) $gColorRemapRangeLayout; } } } // // Procedure Name: // switchVisualMethod // // Description: // Show or hide the related widgets for different visual methd // When the method "color" is choosed, show its remapping options, // interpolation option and highlight option. // When the method "ray" is choosed, show its remapping options. // When the method "string" is choosed, show nothing. // This callback method is called when the state of the radio button group // "visualization method" is changed // // Input Arguments: // None. // // Return Value: // None. // global proc switchVisualMethod() { global string $gVisualMethodWidget; if(`radioButtonGrp -q -exists $gVisualMethodWidget`) { int $visualMethod = `radioButtonGrp -q -sl $gVisualMethodWidget`; global string $gColorRemapLayout; global string $gRayRemapLayout; // visual method is color, display color remap options if($visualMethod == 1) { if(`frameLayout -query -exists $gRayRemapLayout`) frameLayout -e -visible false $gRayRemapLayout; if(`frameLayout -query -exists $gColorRemapLayout`) frameLayout -e -visible true $gColorRemapLayout; } // visual method is ray, display ray remap options else if($visualMethod == 3) { if(`frameLayout -query -exists $gColorRemapLayout`) frameLayout -e -visible false $gColorRemapLayout; if(`frameLayout -query -exists $gRayRemapLayout`) frameLayout -e -visible true $gRayRemapLayout; } // visual method is string, hide both remap options else //if($visualMethod == 2) { if(`frameLayout -query -exists $gRayRemapLayout`) frameLayout -e -visible false $gRayRemapLayout; if(`frameLayout -query -exists $gColorRemapLayout`) frameLayout -e -visible false $gColorRemapLayout; } } } // // Procedure Name: // switchStream // // Description: // Enable/Disable visual method widget // according to data type of the selected stream // // Input Arguments: // None. // // Return Value: // None. // global proc switchStream(int $resetOption) { global string $gStreamListWidget; global string $gMemberListWidget; global string $gVisualMethodWidget; global string $gMetadataVisualMethodNames[]; global string $gColorRemapRangeWidget; global string $gColorRemapLowerRangeWidget; global string $gColorRemapUpperRangeWidget; global string $gColorInterpolationWidget; global string $gMetadataRayScaleWidget;; if(`optionMenuGrp -query -exists $gStreamListWidget` && `optionMenuGrp -query -exists $gMemberListWidget`) { string $streamMenuItems[] = `optionMenuGrp -q -itemListLong $gStreamListWidget`; int $selectedStreamOption = `optionMenuGrp -q -select $gStreamListWidget`; string $streamName = `menuItem -q -label $streamMenuItems[$selectedStreamOption-1]`; string $membersInStream[] = `showMetadata -q -stream $streamName -listMembers`; // clean old options string $memberMenuItems[] = `optionMenuGrp -q -itemListLong $gMemberListWidget`; if(size($memberMenuItems) > 0) deleteUI -menuItem $memberMenuItems; string $memberListWidgetMenu = $gMemberListWidget + "|OptionMenu"; for($i = 0; $i < (size($membersInStream) / 2); $i++) { string $memberNameAndType = buildMemberName( $membersInStream[$i * 2], $membersInStream[$i * 2 + 1] ); menuItem -label $memberNameAndType -parent $memberListWidgetMenu; } optionMenuGrp -e -select 1 $gMemberListWidget; if($resetOption) switchMember(); } } // // Procedure Name: // switchMember // // Description: // Enable/Disable visual method widget // according to data type of the selected stream // // Input Arguments: // None. // // Return Value: // None. // global proc switchMember() { global string $gStreamListWidget; global string $gMemberListWidget; global string $gVisualMethodWidget; global string $gMetadataVisualMethodNames[]; global string $gColorRemapRangeWidget; global string $gColorRemapLowerRangeWidget; global string $gColorRemapUpperRangeWidget; global string $gColorInterpolationWidget; global string $gMetadataRayScaleWidget; global string $gMetadataSavedStreamMembers[]; global int $gMetadataSavedVisualMethodSettings[]; global int $gMetadataSavedDataRemappingSettings[]; global float $gMetadataSavedRangeSettings[]; global int $gMetadataSavedInterpolationSettings[]; global float $gMetadataSavedRayScaleSettings[]; if(`optionMenuGrp -query -exists $gStreamListWidget` && `optionMenuGrp -query -exists $gMemberListWidget`) { global int $gMetadataDefaultVisualMethod; global int $gMetadataDefaultRemapType; global float $gMetadataDefaultMinValue; global float $gMetadataDefaultMaxValue; global int $gMetadataDefaultInterpolation; global float $gMetadataDefaultRayScale; // set UI to default value if no saved int $visualMethod = $gMetadataDefaultVisualMethod; int $remapType = $gMetadataDefaultRemapType; float $minValue = $gMetadataDefaultMinValue; float $maxValue = $gMetadataDefaultMaxValue; int $interpolation = $gMetadataDefaultInterpolation; float $rayScale = $gMetadataDefaultRayScale; // use stored settings string $streamItems[] = `optionMenuGrp -q -itemListLong $gStreamListWidget`; int $selectedStreamOption = `optionMenuGrp -q -select $gStreamListWidget`; // no stream items if(size($streamItems) == 0 || $selectedStreamOption == 0) return; string $streamName = `menuItem -q -label $streamItems[$selectedStreamOption-1]`; string $memberItems[] = `optionMenuGrp -q -itemListLong $gMemberListWidget`; int $selectedMemberOption = `optionMenuGrp -q -select $gMemberListWidget`; // no member items if(size($memberItems) == 0 || $selectedMemberOption == 0) return; string $memberName = `menuItem -q -label $memberItems[$selectedMemberOption-1]`; string $streamMemberName = buildMemberName($streamName, $memberName); int $streamMemberIndex = stringArrayFind($streamMemberName, 0, $gMetadataSavedStreamMembers); if($streamMemberIndex >= 0 && size($gMetadataSavedStreamMembers) >= $streamMemberIndex) { $visualMethod = $gMetadataSavedVisualMethodSettings[$streamMemberIndex]; $remapType = $gMetadataSavedDataRemappingSettings[$streamMemberIndex]; $minValue = $gMetadataSavedRangeSettings[$streamMemberIndex*2]; $maxValue = $gMetadataSavedRangeSettings[$streamMemberIndex*2+1]; $interpolation = $gMetadataSavedInterpolationSettings[$streamMemberIndex]; $rayScale = $gMetadataSavedRayScaleSettings[$streamMemberIndex]; } // update visual method option when the stream is changed if(`radioButtonGrp -query -exists $gVisualMethodWidget`) radioButtonGrp -e -select $visualMethod $gVisualMethodWidget; // update data remapping type option when the stream is changed if(`radioButtonGrp -query -exists $gColorRemapRangeWidget` ) { radioButtonGrp -e -select $remapType $gColorRemapRangeWidget; switchColorRemmapType(); } // update data Color interpretation option when the stream is changed if(`floatFieldGrp -q -exists $gColorRemapLowerRangeWidget` && `floatFieldGrp -q -exists $gColorRemapUpperRangeWidget`) { floatFieldGrp -e -value1 $minValue $gColorRemapLowerRangeWidget; floatFieldGrp -e -value1 $maxValue $gColorRemapUpperRangeWidget; } // update interpolation option when the stream is changed if(`checkBoxGrp -query -exists $gColorInterpolationWidget`) { checkBoxGrp -e -value1 $interpolation $gColorInterpolationWidget; } // update interpolation option when the stream is changed if(`checkBoxGrp -query -exists $gColorInterpolationWidget`) { checkBoxGrp -e -value1 $interpolation $gColorInterpolationWidget; } // update ray scale value when the stream is changed if(`floatSliderGrp -q -exists $gMetadataRayScaleWidget`) { floatSliderGrp -e -value $rayScale $gMetadataRayScaleWidget; } if(`radioButtonGrp -query -exists $gVisualMethodWidget`) { int $disableVisualMethodWidget = 0; if(size($streamItems) > 0 && $selectedStreamOption > 0 && size($memberItems) > 0 && $selectedMemberOption > 0) { string $selectedMember = `menuItem -q -label $memberItems[$selectedMemberOption-1]`; string $memberTokens[] = stringToStringArray($selectedMember, "."); string $memberTypeName = substring($memberTokens[1], 1, 6); int $selectedMethodIndex = `radioButtonGrp -q -select $gVisualMethodWidget`; if($memberTypeName == "string") { $selectedMethodIndex = 2; $disableVisualMethodWidget = 1; } radioButtonGrp -e -select $selectedMethodIndex $gVisualMethodWidget; } if($disableVisualMethodWidget) { // disable enable all visual method widgets radioButtonGrp -e -enable1 0 $gVisualMethodWidget; radioButtonGrp -e -enable3 0 $gVisualMethodWidget; } else { // enable all visual method widgets radioButtonGrp -e -enable1 1 $gVisualMethodWidget; radioButtonGrp -e -enable2 1 $gVisualMethodWidget; radioButtonGrp -e -enable3 1 $gVisualMethodWidget; } } switchVisualMethod(); } } // // Procedure Name: // visualizeMetadataOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc visualizeMetadataOptions() { // Name of the command for this option box. // string $commandName = "visualizeMetadata"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1 -innerMarginWidth 4; columnLayout -adjustableColumn true; // pointSpace of texture deformer string $changeCmd = "switchStream(1);"; global string $gStreamListWidget; $gStreamListWidget = `optionMenuGrp -cc $changeCmd -label (uiRes("m_performVisualizeMetadataOptions.kStreamToVisualize")) streamToVisualizeWidget`; $changeCmd = "switchMember;"; global string $gMemberListWidget; $gMemberListWidget = `optionMenuGrp -cc $changeCmd -label (uiRes("m_performVisualizeMetadataOptions.kMemberToVisualize")) memberListWidget`; global int $gMetadataDefaultVisualMethod; global int $gMetadataDefaultRemapType; global float $gMetadataDefaultMinValue; global float $gMetadataDefaultMaxValue; global int $gMetadataDefaultInterpolation; global float $gMetadataDefaultRayScale; global string $gVisualMethodWidget; $gVisualMethodWidget = `radioButtonGrp -label (uiRes("m_performVisualizeMetadataOptions.kVisualMethod")) -nrb 3 -select $gMetadataDefaultVisualMethod -onCommand "switchVisualMethod();" -label1 (uiRes("m_performVisualizeMetadataOptions.kVisualColor")) -label2 (uiRes("m_performVisualizeMetadataOptions.kVisualString")) -label3 (uiRes("m_performVisualizeMetadataOptions.kVisualRay")) VisualMethodWidget`; // make remap option widgets for color global string $gColorRemapLayout; $gColorRemapLayout = `frameLayout -marginWidth 1 -marginHeight 5 -labelVisible false -collapse false`; global string $gColorRemapRangeWidget; $gColorRemapRangeWidget = `radioButtonGrp -label (uiRes("m_performVisualizeMetadataOptions.kColorRemapType")) -numberOfRadioButtons 4 -select $gMetadataDefaultRemapType -vertical -onCommand "switchColorRemmapType();" -label1 (uiRes("m_performVisualizeMetadataOptions.kFloatColor")) -label2 (uiRes("m_performVisualizeMetadataOptions.kIntColor")) -label3 (uiRes("m_performVisualizeMetadataOptions.kAutoColor")) -label4 (uiRes("m_performVisualizeMetadataOptions.kCustomColor")) ColorRemapWidget`; // make remap option widgets for color global string $gColorRemapRangeLayout; $gColorRemapRangeLayout = `frameLayout -marginHeight 5 -labelVisible false -enable false -collapse false`; columnLayout; global string $gColorRemapLowerRangeWidget; $gColorRemapLowerRangeWidget = `floatFieldGrp -numberOfFields 1 -label (uiRes("m_performVisualizeMetadataOptions.kColorRemapLowerRange")) -value1 $gMetadataDefaultMinValue`; global string $gColorRemapUpperRangeWidget; $gColorRemapUpperRangeWidget = `floatFieldGrp -numberOfFields 1 -label (uiRes("m_performVisualizeMetadataOptions.kColorRemapUpperRange")) -value1 $gMetadataDefaultMaxValue`; setParent ..; setParent ..; global string $gColorInterpolationWidget; $gColorInterpolationWidget = `checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 (uiRes("m_performVisualizeMetadataOptions.kEnableInterpolationCheck")) -value1 $gMetadataDefaultInterpolation EnableInterpolationCheckBox`; checkBoxGrp -numberOfCheckBoxes 1 -visible false -label "" -label1 (uiRes("m_performVisualizeMetadataOptions.kInvalidDataCheck")) EnableInvalidDataCheckBox; setParent ..; // make remap option widgets for ray global string $gRayRemapLayout; $gRayRemapLayout = `frameLayout -labelVisible false -marginHeight 5 -visible false -collapse false`; global string $gMetadataRayScaleWidget; $gMetadataRayScaleWidget = `floatSliderGrp -label (uiRes("m_performVisualizeMetadataOptions.kMetadataRayScaleLabel")) -field true -minValue 0.0001 -maxValue 10.0 -fieldMinValue 0.0001 -fieldMaxValue 1000000000.0 -value $gMetadataDefaultRayScale`; setParent ..; setParent ..; setParent ..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -command ($callback + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + 1 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // string $optionBoxTitle = (uiRes("m_performVisualizeMetadataOptions.kVisualizeMetadataOptions")); setOptionBoxTitle($optionBoxTitle); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "VisualizeMetadataOptions" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); scriptJob -permanent -event "SceneOpened" ("resetMetadataOptionBox;"); } // // Procedure Name: // assembleCmd // // Description: // Construct the command to show the metadata // according to the specified option value // // Input Arguments: // None. // proc string assembleCmd() { string $cmd; setOptionVars(false); string $visualCurrentStreamMember = `optionVar -query metadataVisualCurrentStreamMember`; string $streamMemberTokens[] = stringToStringArray($visualCurrentStreamMember, "."); // Set the visual method to string if the member type is string global string $gMetadataVisualMethodNames[]; string $memberTypeName = substring($streamMemberTokens[2], 1, 6); if($memberTypeName == "string") optionVar -sv metadataVisualMethod $gMetadataVisualMethodNames[1]; string $visualMethod = `optionVar -query metadataVisualMethod`; float $visualMin = `optionVar -query metadataVisualMin`; float $visualMax = `optionVar -query metadataVisualMax`; int $visualAuto = `optionVar -query metadataVisualAuto`; int $visualInterpolation = `optionVar -query metadataVisualInterpolation`; float $visualRayScale = `optionVar -query metadataVisualRayScale`; //TODO //int $visualInvalidData = `optionVar -query metadataVisualInvalidData`; $cmd = "showMetadata" + " -stream \"" + $streamMemberTokens[0] + "\"" + " -member \"" + $streamMemberTokens[1] + "\"" + " -dataType \"" + $streamMemberTokens[2] + "\"" + " -method \"" + $visualMethod + "\"" + " -interpolation " + $visualInterpolation; // "color" method if($gMetadataVisualMethodNames[0] == $visualMethod) { if($visualAuto) { $cmd = $cmd + " -auto"; } else { $cmd = $cmd + " -range " + $visualMin + " " + $visualMax; } } // "ray" method else if($gMetadataVisualMethodNames[2] == $visualMethod) { $cmd = $cmd + " -rayScale " + $visualRayScale; } $cmd = $cmd + " `ls -shapes`"; return $cmd; } // // Procedure Name: // performVisualizeMetadataOptions // // Description: // Display metadata using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the showMetadata command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performVisualizeMetadataOptions(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: visualizeMetadataOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; } // // Procedure Name: // resetMetadataOptionBox // // Description: // Reset all widgets in the option box // Clean the stream list as well // // Input Arguments: // None. // global proc resetMetadataOptionBox() { // set forceFactorySetting to 1 to // reset option variables visualizeMetadataSetup(1); }