// =========================================================================== // 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. // =========================================================================== // // Procedure Name: // AEstitchSrfTemplate // // Description Name; // Creates the attribute editor controls for the stitchSrf node // // Input Value: // nodeName // // Output Value: // None // global proc AEstitchSrfTemplate( string $nodeName ) { string $inputSurface = (uiRes("m_AEstitchSrfTemplate.kInputSurface")); string $inputCurve = (uiRes("m_AEstitchSrfTemplate.kInputCurve")); string $inputMatchCurve = (uiRes("m_AEstitchSrfTemplate.kInputMatchCurve")); string $inputReference = (uiRes("m_AEstitchSrfTemplate.kInputReferenceCOS")); editorTemplate -beginScrollLayout; editorTemplate -beginLayout (uiRes("m_AEstitchSrfTemplate.kStitchSurfaceHistory")) -collapse false; editorTemplate -callCustom ("AEmultiInputNew \""+$inputSurface+"\"") ("AEmultiInputReplace \""+$inputSurface+"\"") "inputSurface"; editorTemplate -callCustom ("AEmultiInputNew \""+$inputCurve+"\"") ("AEmultiInputReplace \""+$inputCurve+"\"") "inputCurve"; editorTemplate -callCustom ("AEmultiInputNew \""+$inputMatchCurve+"\"") ("AEmultiInputReplace \""+$inputMatchCurve+"\"") "inputMatchCurve"; editorTemplate -callCustom ("AEmultiInputNew \""+$inputReference+"\"") ("AEmultiInputReplace \""+$inputReference+"\"") "inputReferenceCOS"; editorTemplate -addControl "fixBoundary"; editorTemplate -addControl "bias"; editorTemplate -addControl "positionalContinuity"; editorTemplate -addControl "tangentialContinuity"; editorTemplate -beginLayout (uiRes("m_AEstitchSrfTemplate.kTolerenceControls")); editorTemplate -callCustom "AEtoggleToleranceNew" "AEtoggleToleranceReplace" "toggleTolerance"; editorTemplate -endLayout; editorTemplate -beginLayout (uiRes("m_AEstitchSrfTemplate.kPointConstraints")); editorTemplate -addControl "parameterU"; editorTemplate -addControl "parameterV"; editorTemplate -addControl "position"; editorTemplate -addControl "normal"; editorTemplate -beginNoOptimize; editorTemplate -addControl "togglePointNormals"; editorTemplate -addControl "togglePointPosition"; editorTemplate -endNoOptimize; editorTemplate -endLayout; editorTemplate -beginLayout (uiRes("m_AEstitchSrfTemplate.kOverrideCVPosition")); editorTemplate -addControl "cvIthIndex"; editorTemplate -addControl "cvJthIndex"; editorTemplate -addControl "cvPosition"; editorTemplate -endLayout; editorTemplate -endLayout; // include/call base class/node attributes AEabstractBaseCreateTemplate $nodeName; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; editorTemplate -suppress "tolerance"; editorTemplate -suppress "stepCount"; } global proc toggleToleranceControls( int $value, string $name ) { if ( $value == 0 ) { // dim tolerance floatSliderGrp -e -enable 0 ($name + "Tolerance"); intFieldGrp -e -enable 1 ($name + "StepCount"); } else { // dim step count floatSliderGrp -e -enable 1 ($name + "Tolerance"); intFieldGrp -e -enable 0 ($name + "StepCount"); } } proc AEconnectTolToggleControls( string $plug, string $tolToggle ) { string $number[]; tokenize($tolToggle, "[]", $number); string $name = ($number[0] + $number[1]); // get the index // string $index = $number[1]; // get the nodeName // string $buffer[]; tokenize($plug,".",$buffer); string $nodeName = $buffer[0]; connectControl ($name + "CheckBox") -index 2 ($nodeName+".toggleTolerance["+$index+"]"); connectControl ($name + "Tolerance") ($nodeName+".tolerance["+$index+"]"); connectControl ($name + "StepCount") -index 2 ($nodeName+".stepCount["+$index+"]"); // initialize dimming of controls string $plugName = $nodeName+"."+$tolToggle; int $isOn = `getAttr $plugName`; toggleToleranceControls( $isOn, $name); } proc AEcreateNewTolToggleControls( string $nodeName, string $tolToggle ) { string $number[]; tokenize($tolToggle, "[]", $number); string $name = ($number[0] + $number[1]); int $index = 0; if ( $number[1] != "" ) $index = int( $number[1] ); $index++; string $fmt = (uiRes("m_AEstitchSrfTemplate.kColumnLayoutLabel")); string $fmt2 = (uiRes("m_AEstitchSrfTemplate.kFloatSliderLabel")); string $fmt3 = (uiRes("m_AEstitchSrfTemplate.kIntFieldLabel")); setUITemplate -pst attributeEditorTemplate; columnLayout -adj true; if ($index > 1) separator ($name + "Sep"); checkBoxGrp -ncb 1 -label "" -label1 (`format -s $index $fmt`) -on1 ("toggleToleranceControls 1 " + $name) -of1 ("toggleToleranceControls 0 " + $name) ($name + "CheckBox"); floatSliderGrp -f 1 -label (`format -s $index $fmt2`) -min 0.00001 -max 1.0 ($name + "Tolerance"); intFieldGrp -nf 1 -label (`format -s $index $fmt3`) ($name + "StepCount"); setParent ..; AEconnectTolToggleControls( $nodeName, $tolToggle ); setUITemplate -ppt; } global proc AEtoggleToleranceNew( string $plug ) { // get the nodeName // string $buffer[]; tokenize($plug,".",$buffer); string $nodeName = $buffer[0]; // get all of the elements of the array // string $tolToggles[] = `listAttr -m $plug`; setUITemplate -pst attributeEditorTemplate; columnLayout AEtoggleToleranceLayout; for ( $tolTog in $tolToggles ) { AEcreateNewTolToggleControls( $nodeName, $tolTog ); } setParent ..; setUITemplate -ppt; } global proc AEtoggleToleranceReplace( string $plug ) { // get the nodeName // string $buffer[]; tokenize($plug,".",$buffer); string $nodeName = $buffer[0]; string $newTolToggles[] = `listAttr -m $plug`; int $newNumTolToggles = size( $newTolToggles ); string $oldTolTogglesLayouts[] = `columnLayout -q -ca AEtoggleToleranceLayout`; int $oldNumTolToggles = size( $oldTolTogglesLayouts ); setParent AEtoggleToleranceLayout; if ( $newNumTolToggles >= $oldNumTolToggles ) { // replace what we can // for ( $i = 0; $i < $oldNumTolToggles; $i++ ) { setParent $oldTolTogglesLayouts[$i]; AEconnectTolToggleControls($nodeName, $newTolToggles[$i]); } // and build what we need // setParent AEtoggleToleranceLayout; for ( $i = $oldNumTolToggles; $i < $newNumTolToggles; $i++ ) { AEcreateNewTolToggleControls($nodeName, $newTolToggles[$i]); } } else { // replace what we need // for ( $i = 0; $i < $newNumTolToggles; $i++ ) { setParent $oldTolTogglesLayouts[$i]; AEconnectTolToggleControls($nodeName, $newTolToggles[$i]); } // delete old columnLayouts // setParent AEtoggleToleranceLayout; for ( $i = $newNumTolToggles; $i < $oldNumTolToggles; $i++ ) { deleteUI -layout $oldTolTogglesLayouts[$i]; } } }