// Copyright (C) 1997-2006 Autodesk, Inc., and/or its licensors. // All rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors, // which is protected by U.S. and Canadian federal copyright law and by // international treaties. // // The Data is provided for use exclusively by You. You have the right to use, // modify, and incorporate this Data into other products for purposes authorized // by the Autodesk software license agreement, without fee. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK // DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES // INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT, // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE // OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS // LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS // LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES. // // Alias Script File // MODIFY THIS AT YOUR OWN RISK // global proc mlCreateSolutionPanel(string $parent) { mlCreateSolutionUI($parent); } global proc mlSelectSolutionPanel() { tabLayout -e -st mlSolutionPanelForm mlPanelLayout; string $radioValue = `radioCollection -q -sl mlSolveCollection`; if( $radioValue != "mlRadioSolution") { radioCollection -e -sl "mlRadioSolution" mlSolveCollection; } mlUpdateSolutionUI(); mlSolve(); } global proc mlCreateSolutionUI ( string $parent ) { setParent $parent; formLayout -nd 100 mlSolutionForm; text -l "3D Points" -al "left" ml3DPointTxt; textScrollList -ams no -nr 6 -w 160 -selectCommand "mlSelect3DPoint" -fn "fixedWidthFont" ml3DPointList; columnLayout -adj true ml3DPointCol; floatFieldGrp -l "X" -el "" ml3DPointXFld; floatFieldGrp -l "Y" -el "" ml3DPointYFld; floatFieldGrp -l "Z" -el "" ml3DPointZFld; floatFieldGrp -l "Variance" -el "" ml3DPointVFld; checkBoxGrp -ncb 1 -cal 1 "right" -l "Display" -l1 ""ml3DPointVisibilityChkBxGrp; setParent ..; text -l "Root Frames" -al "left" mlRootFramesTxt; textScrollList -ams no -nr 6 -w 100 -fn "fixedWidthFont" mlRootFrameList; columnLayout -adj true mlFrameRFCol; checkBoxGrp -ncb 1 -cal 1 "left" -cw 1 210 -l "Use User Specified Root Frames" -l1 "" -cc "mlUseRootFramesRFCBGrpChanged" mlUseRootFramesRFCBGrp; rowLayout -nc 2 -cw 1 155 -cw 2 50 mlNumRootFramesRFRow; text -l "Number of Root Frames" mlNumRootFramesRFTxt; intField -ed true -cc mlNumRootFramesRFFldChanged mlNumRootFramesRFFld; setParent ..; intFieldGrp -nf 2 -l "Frame Range" -cw 1 155 -cw 2 50 -cw 3 50 -cal 1 "left" -cc "mlSolveFrameRangeRFIGrpChanged" mlSolveFrameRangeRFIGrp; setParent ..; floatFieldGrp -nf 1 -cal 1 "left" -cw 1 100 -label "Frame Number" -v1 1 mlFrameNumRFGrp; button -l "Automatic Selection" -c "mlSelectRootFrames" mlAutoSelectRFBtn; button -l "Add" -w 50 -c "mlAddRootFrame" mlAddRFBtn; button -l "Delete" -w 50 -c "mlDeleteRootFrame" mlDeleteRFBtn; setParent ..; formLayout -e -af "ml3DPointTxt" top 5 -af "ml3DPointTxt" left 5 -an "ml3DPointTxt" right -an "ml3DPointTxt" bottom -ac "ml3DPointList" top 5 "ml3DPointTxt" -af "ml3DPointList" left 5 -an "ml3DPointList" right -an "ml3DPointList" bottom -af "ml3DPointCol" top 25 -ac "ml3DPointCol" left 0 "ml3DPointList" -an "ml3DPointCol" right -an "ml3DPointCol" bottom -af "mlRootFramesTxt" top 5 -ac "mlRootFramesTxt" left 5 "ml3DPointCol" -an "mlRootFramesTxt" right -an "mlRootFramesTxt" bottom -ac "mlRootFrameList" top 5 "mlRootFramesTxt" -ac "mlRootFrameList" left 5 "ml3DPointCol" -an "mlRootFrameList" right -an "mlRootFrameList" bottom -af "mlFrameNumRFGrp" top 25 -ac "mlFrameNumRFGrp" left 3 "mlRootFrameList" -an "mlFrameNumRFGrp" right -an "mlFrameNumRFGrp" bottom -ac "mlAddRFBtn" top 0 "mlFrameNumRFGrp" -ac "mlAddRFBtn" left 3 "mlRootFrameList" -an "mlAddRFBtn" right -an "mlAddRFBtn" bottom -ac "mlDeleteRFBtn" top 0 "mlAddRFBtn" -ac "mlDeleteRFBtn" left 3 "mlRootFrameList" -an "mlDeleteRFBtn" right -an "mlDeleteRFBtn" bottom -ac "mlAutoSelectRFBtn" top 0 "mlDeleteRFBtn" -ac "mlAutoSelectRFBtn" left 3 "mlRootFrameList" -an "mlAutoSelectRFBtn" right -an "mlAutoSelectRFBtn" bottom -af "mlFrameRFCol" top 25 -ac "mlFrameRFCol" left 40 "mlFrameNumRFGrp" -an "mlFrameRFCol" right -an "mlFrameRFCol" bottom mlSolutionForm; // mlUpdateRFSolveFrameRangeUI; // mlUpdateSolutionUI; } global proc mlSelect3DPoint() { string $selectedPoint[] = `textScrollList -q -si ml3DPointList`; select -r $selectedPoint[0]; mlUpdateSolution3DPointUI(); } global proc mlSelectRootFrames() { string $cameraSoln = `mlGetCurrentCameraSoln`; int $numRootFrames = `intField -q -v mlNumRootFramesRFFld`; int $start = `intFieldGrp -q -v1 mlSolveFrameRangeRFIGrp`; int $end = `intFieldGrp -q -v2 mlSolveFrameRangeRFIGrp`; int $useRf = `checkBoxGrp -q -v1 mlUseRootFramesRFCBGrp`; int $timeout = `intFieldGrp -q -v1 mlTimeoutFld`; textScrollList -e -ra mlRootFrameList; mlRemoveAllRootFrames($cameraSoln); int $solved = `mlSolveCamera roots $cameraSoln $start $end $timeout $numRootFrames $useRf`; float $roots[] = `mlGetRootFrames $cameraSoln`; $numRootFrames = `size($roots)`; if( $numRootFrames == 0 ) { error( "Not enough information provided to select root frames\n"); } else { for( $frame in $roots ) { textScrollList -e -a $frame mlRootFrameList; } intFieldGrp -e -v1 $numRootFrames mlNumRootFramesFld; intField -e -v $numRootFrames mlNumRootFramesRFFld; } } global proc mlAddRootFrame() { string $cameraSoln = `mlGetCurrentCameraSoln`; float $value = `floatFieldGrp -q -v1 mlFrameNumRFGrp`; int $start = `intFieldGrp -q -v1 mlSolveFrameRangeRFIGrp`; int $end = `intFieldGrp -q -v2 mlSolveFrameRangeRFIGrp`; float $rf[] = `mlGetRootFrames $cameraSoln`; for( $frame in $rf ) { if( $value == $frame ) { error( "Frame already established as root frame\n" ); return; } else { if( $value > $end || $value < $start ) { error( "Root Frame must be within frame range\n"); return; } } } mlCreateRootFrame($cameraSoln, $value); textScrollList -e -a $value mlRootFrameList; int $nrf = `textScrollList -q -ni mlRootFrameList`; intField -e -v $nrf mlNumRootFramesRFFld; intFieldGrp -e -v1 $nrf mlNumRootFramesFld; } global proc mlDeleteRootFrame() { string $selrf[] = `textScrollList -q -si mlRootFrameList`; textScrollList -e -ri $selrf[0] mlRootFrameList; string $cameraSoln = `mlGetCurrentCameraSoln`; mlRemoveRootFrame( $cameraSoln, $selrf[0] ); int $nrf = `textScrollList -q -ni mlRootFrameList`; intField -e -v $nrf mlNumRootFramesRFFld; intFieldGrp -e -v1 $nrf mlNumRootFramesFld; } global proc mlUpdateRFFrameNum() { float $time = `currentTime -q`; floatFieldGrp -e -v1 $time mlFrameNumRFGrp; } global proc mlNumRootFramesRFFldChanged() { int $numRootFrames = `intField -q -v mlNumRootFramesRFFld`; int $useUserRf = `checkBoxGrp -q -v1 mlUseRootFramesRFCBGrp`; if( $numRootFrames < 2 ) { if( $useUserRf ) { warning("You must supply at least 2 root frames"); intFieldGrp -e -v1 $numRootFrames mlNumRootFramesFld; } else { intField -e -v 2 mlNumRootFramesRFFld; $numRootFrames = 2; } } intFieldGrp -e -v1 $numRootFrames mlNumRootFramesFld; } global proc mlUpdateSolutionUI() { global string $mlSelected3DPoint; // update the 3D points list textScrollList -e -ra ml3DPointList; string $cc = `mlGetCurrentCandidate`; if( $cc != "" ) { string $cps[] = `listConnections ($cc+".candidatePoints")`; for ( $cp in $cps ) { string $tp3D[] = `listConnections ($cp+".trackedPoint3DLocator")`; if ( size( $tp3D ) > 0 ) { textScrollList -e -a $tp3D[0] ml3DPointList; } } } mlUpdateSolution3DPointUI; // update the root frames list textScrollList -e -ra mlRootFrameList; string $cameraSoln = `mlGetCurrentCameraSoln`; if( $cameraSoln != "" ) { float $rf[] = `mlGetRootFrames $cameraSoln`; for( $frame in $rf ) { textScrollList -e -a $frame mlRootFrameList; } } int $useRF = `checkBoxGrp -q -v1 mlUseRootFramesCBGrp`; int $nrf; if( $useRF ) { $nrf = `textScrollList -q -ni mlRootFrameList`; } else { $nrf = `intFieldGrp -q -v1 mlNumRootFramesFld`; } intField -e -v $nrf mlNumRootFramesRFFld; intFieldGrp -e -v1 $nrf mlNumRootFramesFld; mlUseRootFramesRFCBGrpChanged; } global proc mlUpdateSolution3DPointUI() { string $selected3DPoints[] = `mlGetSelected3DPoints`; string $point; if ( size( $selected3DPoints ) > 0 ) { string $attrs; int $count = 0; string $candidatePoints[]; for ( $point in $selected3DPoints ) { string $cp[] = `listConnections -source true -destination false ($point+".candidatePoint")`; if ( size( $cp ) > 0 ) { $candidatePoints[$count++] = $cp[0]; } } floatFieldGrp -e -en true ml3DPointVFld; $attrs = `mlMakeAttributeList $candidatePoints "variance"`; connectControl -index 2 ml3DPointVFld $attrs; checkBoxGrp -e -en true ml3DPointVisibilityChkBxGrp; $attrs = `mlMakeAttributeList $candidatePoints "display"`; connectControl -index 2 ml3DPointVisibilityChkBxGrp $attrs; $count = 0; string $selected3DTransforms[]; for ( $point in $candidatePoints ) { string $st[] = `listConnections -source true -destination false ($point+".trackedPoint3DLocator")`; if ( size( $st ) > 0 ) { $selected3DTransforms[$count++] = $st[0]; } } floatFieldGrp -e -en true ml3DPointXFld; $attrs = `mlMakeAttributeList $selected3DTransforms "translateX"`; connectControl -index 2 ml3DPointXFld $attrs; floatFieldGrp -e -en true ml3DPointYFld; $attrs = `mlMakeAttributeList $selected3DTransforms "translateY"`; connectControl -index 2 ml3DPointYFld $attrs; floatFieldGrp -e -en true ml3DPointZFld; $attrs = `mlMakeAttributeList $selected3DTransforms "translateZ"`; connectControl -index 2 ml3DPointZFld $attrs; floatFieldGrp -e -en true ml3DPointVFld; $attrs = `mlMakeAttributeList $selected3DTransforms "variance"`; connectControl -index 2 ml3DPointVFld $attrs; checkBoxGrp -e -en true ml3DPointVisibilityChkBxGrp; $attrs = `mlMakeAttributeList $selected3DTransforms "visibility"`; connectControl -index 2 ml3DPointVisibilityChkBxGrp $attrs; } else { floatFieldGrp -e -en false ml3DPointXFld; connectControl -index 2 ml3DPointXFld ""; floatFieldGrp -e -en false ml3DPointYFld; connectControl -index 2 ml3DPointYFld ""; floatFieldGrp -e -en false ml3DPointZFld; connectControl -index 2 ml3DPointZFld ""; floatFieldGrp -e -en false ml3DPointVFld; connectControl -index 2 ml3DPointVFld ""; checkBoxGrp -e -en false ml3DPointVisibilityChkBxGrp; connectControl -index 2 ml3DPointVisibilityChkBxGrp ""; } } global proc mlSolveFrameRangeRFIGrpChanged() { // check for valid number of root frames for range int $start = `intFieldGrp -q -v1 mlSolveFrameRangeRFIGrp`; int $end = `intFieldGrp -q -v2 mlSolveFrameRangeRFIGrp`; int $numRoots = `intField -q -v mlNumRootFramesRFFld`; int $numFrames = $end - $start + 1; if( $numRoots > $numFrames ) { intField -e -v $numFrames mlNumRootFramesRFFld; intFieldGrp -e -v1 $numFrames mlNumRootFramesFld; } // edit start and end frame int $startFrame = `mlGetFirstFrameOfScene`; int $endFrame = `mlGetLastFrameOfScene`; if( $start < $startFrame ) { intFieldGrp -e -v1 $startFrame mlSolveFrameRangeRFIGrp; $start = $startFrame; } if( $end > $endFrame ) { intFieldGrp -e -v2 $endFrame mlSolveFrameRangeRFIGrp; $end = $endFrame; } if( `intFieldGrp -exists mlSolveFrameRangeIGrp` ) { intFieldGrp -e -v1 $start -v2 $end mlSolveFrameRangeIGrp; } } global proc mlUseRootFramesRFCBGrpChanged() { int $useUserRF = `checkBoxGrp -q -v1 mlUseRootFramesRFCBGrp`; checkBoxGrp -e -v1 $useUserRF mlUseRootFramesCBGrp; if( $useUserRF ) { mlEnableRootFrameUI; int $nrf = `textScrollList -q -ni mlRootFrameList`; intField -e -v $nrf mlNumRootFramesRFFld; intFieldGrp -e -v1 $nrf mlNumRootFramesFld; } else { mlDisableRootFrameUI; intField -e -v 7 mlNumRootFramesRFFld; intFieldGrp -e -v1 7 mlNumRootFramesFld; } } global proc mlEnableRootFrameUI() { button -e -en true mlAddRFBtn; button -e -en true mlDeleteRFBtn; button -e -en true mlAutoSelectRFBtn; intField -e -en true mlNumRootFramesRFFld; intFieldGrp -e -en true mlSolveFrameRangeRFIGrp; floatFieldGrp -e -en true mlFrameNumRFGrp; textScrollList -e -en true mlRootFrameList; text -e -en true mlNumRootFramesRFTxt; } global proc mlDisableRootFrameUI() { button -e -en false mlAddRFBtn; button -e -en false mlDeleteRFBtn; button -e -en false mlAutoSelectRFBtn; intField -e -en false mlNumRootFramesRFFld; intFieldGrp -e -en false mlSolveFrameRangeRFIGrp; floatFieldGrp -e -en false mlFrameNumRFGrp; textScrollList -e -en false mlRootFrameList; text -e -en false mlNumRootFramesRFTxt; } global proc mlUpdateRFSolveFrameRangeUI() { if( `intFieldGrp -exists mlSolveFrameRangeRFIGrp` ) { intFieldGrp -e -v1 `mlGetFirstFrameOfScene` mlSolveFrameRangeRFIGrp; intFieldGrp -e -v2 `mlGetLastFrameOfScene` mlSolveFrameRangeRFIGrp; } }