/****************************************************************************** NintendoWare for CTR Maya Plugin File: NW4C_SetRenderPriority.mel Description: set render priority Date: 2010/02/12 Author: Takashi Endo Copyright (C)2009-2010 Nintendo Co., Ltd. / HAL Laboratory, Inc. All rights reserved. ******************************************************************************/ // UpdateWindow DoSearch // UpdateList SortList ListButtonCB ListDropCB SetListColor /****************************************************************************** variables ******************************************************************************/ global int $nw4cSetRenderPriority_SortKind = 0; // 0:priority, 1:name global int $nw4cSetRenderPriority_SortOrder = 0; // 0:ascend, 1:descend global int $nw4cSetRenderPriority_KeepOrder = 0; /****************************************************************************** get selected SG return SG size ******************************************************************************/ proc int GetSelectedSG(string $sgs[]) { $sgs = `ls -sl -typ shadingEngine`; if (size($sgs) == 0) { // get SG from selected material string $mats[] = `ls -sl -mat`; for ($mat in $mats) { if (!`attributeQuery -n $mat -ex "oc"`) { continue; } string $connectedSgs[] = `listConnections -s 0 -d 1 -type shadingEngine ($mat + ".oc")`; for ($sg in $connectedSgs) { if ($sg != "initialParticleSE" && $sg != "swatchShadingGroup") { $sgs[size($sgs)] = $sg; } } } } return size($sgs); } /****************************************************************************** use render priority ******************************************************************************/ global proc int nw4cSetRenderPriority_Get_UseRenderPriority(string $node) { return (`attributeQuery -n $node -ex "nw4cUseRenderPriority"`) ? `getAttr ($node + ".nw4cUseRenderPriority")` : 0; } global proc nw4cSetRenderPriority_Add_UseRenderPriority(string $node) { if (!`attributeQuery -n $node -ex "nw4cUseRenderPriority"`) { addAttr -ln "nw4cUseRenderPriority" -at "bool" -dv 0 -h 1 $node; } } global proc nw4cSetRenderPriority_Set_UseRenderPriority(string $node, int $val) { nw4cSetRenderPriority_Add_UseRenderPriority($node); setAttr ($node + ".nw4cUseRenderPriority") $val; } proc SetJob_UseRenderPriority(string $node) { if (!`attributeQuery -n $node -ex "nw4cUseRenderPriority"`) { return; } scriptJob -p nw4cSetRenderPriority_UseRenderPriority -rp -ac ($node + ".nw4cUseRenderPriority") ("if (`nw4cSetRenderPriority_Get_UseRenderPriority " + $node + "`) radioButtonGrp -e -sl 1 nw4cSetRenderPriority_UseRenderPriority;" + "else radioButtonGrp -e -sl 1 nw4cSetRenderPriority_DontCare;" + "control -e -en `nw4cSetRenderPriority_Get_UseRenderPriority " + $node + "` nw4cSetRenderPriority_RenderPriority;"); } global proc nw4cSetRenderPriority_UseRenderPriorityCB(string $mainNode) { string $sgs[]; GetSelectedSG($sgs); int $val = `radioButtonGrp -q -sl nw4cSetRenderPriority_UseRenderPriority`; control -e -en $val nw4cSetRenderPriority_RenderPriority; for ($node in $sgs) { nw4cSetRenderPriority_Set_UseRenderPriority($node, $val); } SetJob_UseRenderPriority($mainNode); } /****************************************************************************** render priority ******************************************************************************/ global proc int nw4cSetRenderPriority_Get_RenderPriority(string $node) { return (`attributeQuery -n $node -ex "nw4cRenderPriority"`) ? `getAttr ($node + ".nw4cRenderPriority")` : 1; } global proc nw4cSetRenderPriority_Add_RenderPriority(string $node) { if (!`attributeQuery -n $node -ex "nw4cRenderPriority"`) { addAttr -ln "nw4cRenderPriority" -at "short" -min 1 -max 255 -dv 1 -h 1 $node; } } global proc nw4cSetRenderPriority_Set_RenderPriority(string $node, int $val) { nw4cSetRenderPriority_Add_RenderPriority($node); setAttr ($node + ".nw4cRenderPriority") $val; } proc SetJob_RenderPriority(string $node) { if (!`attributeQuery -n $node -ex "nw4cRenderPriority"`) { return; } scriptJob -p nw4cSetRenderPriority_RenderPriority -rp -ac ($node + ".nw4cRenderPriority") ("intField -e -v `nw4cSetRenderPriority_Get_RenderPriority " + $node + "` nw4cSetRenderPriority_RenderPriority"); } global proc nw4cSetRenderPriority_RenderPriorityCB(string $mainNode) { string $sgs[]; GetSelectedSG($sgs); int $val = `intField -q -v nw4cSetRenderPriority_RenderPriority`; if ($val < 1) { $val = 1; intField -e -v $val nw4cSetRenderPriority_RenderPriority; } else if ($val > 255) { $val = 255; intField -e -v $val nw4cSetRenderPriority_RenderPriority; } for ($node in $sgs) { nw4cSetRenderPriority_Set_RenderPriority($node, $val); } SetJob_RenderPriority($mainNode); } /****************************************************************************** get priority for list ******************************************************************************/ proc int GetPriorityForList(string $sg) { int $priority = 0; if (objExists($sg)) { if (nw4cSetRenderPriority_Get_UseRenderPriority($sg)) { $priority = nw4cSetRenderPriority_Get_RenderPriority($sg); } } return $priority; } /****************************************************************************** set priority for list ******************************************************************************/ proc SetPriorityForList(string $sg, int $val) { if (objExists($sg)) { nw4cSetRenderPriority_Set_UseRenderPriority($sg, ($val != 0)); if ($val != 0) { nw4cSetRenderPriority_Set_RenderPriority($sg, $val); } } } /****************************************************************************** find list field for button ******************************************************************************/ proc string FindListFieldForButton(string $childs[], string $btn) { string $btnS = match("[^|]+$", $btn); int $sgSize = size($childs) / 2; int $isg; for ($isg = 0; $isg < $sgSize; ++$isg) { string $child = $childs[$isg]; if ($child == $btn || $child == $btnS) { return $childs[$sgSize + $isg]; } } return ""; } /****************************************************************************** get SG from list label ******************************************************************************/ proc string GetSGFromListLabel(string $label) { string $mat = match("\\(.*\\)", $label); $mat = substitute("^\\( ", $mat, ""); $mat = substitute(" \\)$", $mat, ""); //print("[" + $mat + "] " + $label + "\n"); return $mat; } /****************************************************************************** set list color ******************************************************************************/ proc SetListColor() { //return; string $childs[] = `layout -q -ca nw4cSetRenderPriority_SGList`; int $sgSize = size($childs) / 2; int $isg; for ($isg = 0; $isg < $sgSize; ++$isg) { string $btn = $childs[$isg]; string $label = `button -q -l $btn`; //string $sg = match("[^ ]+", $label); // sgName ( matName ) string $sg = GetSGFromListLabel($label); // matName ( sgName ) int $selFlag = false; if (size(`ls -sl $sg`)) { $selFlag = true; } else if (objExists($sg)) { string $ins[] = `listConnections -s 1 -d 0 ($sg + ".ss")`; if (size($ins) && size(`ls -sl $ins[0]`)) { string $mat = $ins[0]; if (`attributeQuery -n $mat -ex "oc"`) { string $ots[] = `listConnections -s 0 -d 1 ($mat + ".oc")`; if (size($ots) && size(`ls -sl $ots`) == 0) { $selFlag = true; } } } } if ($selFlag) { button -e -bgc 0.9 0.9 0.0 $btn; } else { button -e -bgc 1 1 1 $btn; } control -e -en false $btn; // for update bgc control -e -en true $btn; } } /****************************************************************************** list button CB ******************************************************************************/ global proc nw4cSetRenderPriority_ListButtonCB(string $btn, string $sg) { int $mod = `getModifiers`; int $shift = ($mod == 1 || $mod == 5 || $mod == 9); //----------------------------------------------------------------------------- // select SG & material & polygon if (!$shift) { select -cl; } if (objExists($sg)) { select -add -ne $sg; // shadingEngine string $ins[] = `listConnections -s 1 -d 0 ($sg + ".ss")`; if (size($ins)) { select -add $ins[0]; // material } select -add $sg; // shape object & face // frame objects if (`checkBox -q -v nw4cSetRenderPriority_FrameObjects`) { if (size(`sets -q $sg`)) { fitAllPanels -selected; } } } //----------------------------------------------------------------------------- // set list color SetListColor(); //----------------------------------------------------------------------------- // set focus //setFocus $btn; string $childs[] = `layout -q -ca nw4cSetRenderPriority_SGList`; string $field = FindListFieldForButton($childs, $btn); if (size($field)) { setFocus $field; } } /****************************************************************************** list priority CB ******************************************************************************/ global proc nw4cSetRenderPriority_ListPriorityCB(string $sg, int $val) { global int $nw4cSetRenderPriority_SortKind; global int $nw4cSetRenderPriority_KeepOrder; SetPriorityForList($sg, $val); // keep priority sort order if ($nw4cSetRenderPriority_SortKind == 0) { $nw4cSetRenderPriority_KeepOrder = 1; } } /****************************************************************************** list drag CB ******************************************************************************/ global proc string[] nw4cSetRenderPriority_ListDragCB( string $dragControl, int $x, int $y, int $mods) { string $msgs[]; //trace ("drag: " + match("[^|]+$", $dragControl) + ": " + $x + ", " + $y + ": " + $mods); $msgs[0] = "dummy"; // set something to enable drop CB return $msgs; } /****************************************************************************** list drop CB ******************************************************************************/ global proc nw4cSetRenderPriority_ListDropCB( string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type) // type is always 2 ? { global int $nw4cSetRenderPriority_KeepOrder; //----------------------------------------------------------------------------- // check control if ($dragControl == $dropControl) { return; } //trace ("drop: " + match("[^|]+$", $dragControl) + " -> " + match("[^|]+$", $dropControl) + ": " + $x + ", " + $y + ": " + $type + ": " + size($msgs)); //----------------------------------------------------------------------------- // swap priority string $name0 = `button -q -l $dragControl`; string $name1 = `button -q -l $dropControl`; //string $sg0 = match("[^ ]+", $name0); // sgName ( matName ) //string $sg1 = match("[^ ]+", $name1); // sgName ( matName ) string $sg0 = GetSGFromListLabel($name0); // matName ( sgName ) string $sg1 = GetSGFromListLabel($name1); // matName ( sgName ) string $pri0 = GetPriorityForList($sg0); string $pri1 = GetPriorityForList($sg1); SetPriorityForList($sg0, $pri1); SetPriorityForList($sg1, $pri0); //----------------------------------------------------------------------------- // swap button name & command button -e -l $name1 -c ("nw4cSetRenderPriority_ListButtonCB " + $dragControl + " " + $sg1) $dragControl; button -e -l $name0 -c ("nw4cSetRenderPriority_ListButtonCB " + $dropControl + " " + $sg0) $dropControl; //----------------------------------------------------------------------------- // swap field command // [notice] can't query intField changeCommand string $childs[] = `layout -q -ca nw4cSetRenderPriority_SGList`; string $field0 = FindListFieldForButton($childs, $dragControl); string $field1 = FindListFieldForButton($childs, $dropControl); //trace ("drop: " + $sg0 + " -> " + $sg1 + " (" + $field0 + " -> " + $field1 + ")"); if (size($field0) && size($field1)) { string $parentBak = `setParent -q`; setParent nw4cSetRenderPriority_SGList; intField -e -cc ("nw4cSetRenderPriority_ListPriorityCB " + $sg1 + " #1") $field0; intField -e -cc ("nw4cSetRenderPriority_ListPriorityCB " + $sg0 + " #1") $field1; setParent $parentBak; } //----------------------------------------------------------------------------- // keep sort order $nw4cSetRenderPriority_KeepOrder = 1; //----------------------------------------------------------------------------- // set list color SetListColor(); } /****************************************************************************** sort list ******************************************************************************/ proc SortList(string $sgs[], string $mats[], int $pris[]) { global int $nw4cSetRenderPriority_SortKind; global int $nw4cSetRenderPriority_SortOrder; int $sgSize = size($sgs); for ($isg = 0; $isg < $sgSize - 1; ++$isg) { for ($jsg = $isg + 1; $jsg < $sgSize; ++$jsg) { string $sg0 = $sgs[$isg]; string $mat0 = $mats[$isg]; int $pri0 = $pris[$isg]; string $sg1 = $sgs[$jsg]; string $mat1 = $mats[$jsg]; int $pri1 = $pris[$jsg]; int $cond = 0; if ($nw4cSetRenderPriority_SortKind == 0) // priority { if ($pri0 == $pri1) { $cond = (strcmp($mat0, $mat1) > 0); } else if ($nw4cSetRenderPriority_SortOrder == 0) { $cond = ($pri0 > $pri1); } else { $cond = ($pri0 < $pri1); } } else // name { if ($nw4cSetRenderPriority_SortOrder == 0) { $cond = (strcmp($mat0, $mat1) > 0); } else { $cond = (strcmp($mat0, $mat1) < 0); } } if ($cond) { $sgs[$isg] = $sg1; $mats[$isg] = $mat1; $pris[$isg] = $pri1; $sgs[$jsg] = $sg0; $mats[$jsg] = $mat0; $pris[$jsg] = $pri0; } } } } /****************************************************************************** update sort icon ******************************************************************************/ proc UpdateSortIcon() { global int $nw4cSetRenderPriority_SortKind; global int $nw4cSetRenderPriority_SortOrder; string $img = ($nw4cSetRenderPriority_SortOrder) ? "arrowDown.xpm" : "arrowUp.xpm"; iconTextStaticLabel -e -vis ($nw4cSetRenderPriority_SortKind == 1) -i1 $img nw4cSetRenderPriority_NameSortIcon; iconTextStaticLabel -e -vis ($nw4cSetRenderPriority_SortKind == 0) -i1 $img nw4cSetRenderPriority_PrioritySortIcon; } /****************************************************************************** is SG size changed ******************************************************************************/ proc int IsSGSizeChanged() { int $sgSize = 0; string $allSgs[] = `ls -typ shadingEngine`; for ($sg in $allSgs) { if ($sg == "initialParticleSE") { continue; } string $ins[] = `listConnections -s 1 -d 0 ($sg + ".ss")`; if (!size($ins)) { continue; } ++$sgSize; } string $childs[] = `layout -q -ca nw4cSetRenderPriority_SGList`; return ((size($childs) / 2) != $sgSize); } /****************************************************************************** update list ******************************************************************************/ proc UpdateList() { //trace "update list"; //----------------------------------------------------------------------------- // create list string $sgs[], $mats[]; int $pris[]; int $isg = 0; string $allSgs[] = `ls -typ shadingEngine`; for ($sg in $allSgs) { if ($sg == "initialParticleSE") { continue; } string $ins[] = `listConnections -s 1 -d 0 ($sg + ".ss")`; if (!size($ins)) { continue; } string $mat = $ins[0]; $sgs[$isg] = $sg; $mats[$isg] = $mat; $pris[$isg] = GetPriorityForList($sg); ++$isg; } //----------------------------------------------------------------------------- // sort list UpdateSortIcon(); SortList($sgs, $mats, $pris); //----------------------------------------------------------------------------- // resize UI int $sgSize = size($sgs); string $parentBak = `setParent -q`; setParent nw4cSetRenderPriority_SGList; string $childs[] = `layout -q -ca nw4cSetRenderPriority_SGList`; int $rowSize = size($childs) / 2; if ($rowSize != $sgSize) { if (size($childs)) { deleteUI $childs; } for ($isg = 0; $isg < $sgSize; ++$isg) { button -w 220 -h 22 -al "left" -rs 0 -bgc 1 1 1; // -rs 0 fix width } for ($isg = 0; $isg < $sgSize; ++$isg) { intField -w 66 -h 22 -min 0 -max 255; } $childs = `layout -q -ca nw4cSetRenderPriority_SGList`; string $lastBtn; for ($isg = 0; $isg < $sgSize; ++$isg) { string $btn = $childs[$isg]; string $field = $childs[$sgSize + $isg]; if ($isg == 0) { formLayout -e -af $btn "top" 4 -af $btn "left" 4 -an $btn "bottom" -ap $btn "right" 0 79 -af $field "top" 4 -ac $field "left" 4 $btn -an $field "bottom" -an $field "right" nw4cSetRenderPriority_SGList; } else { formLayout -e -ac $btn "top" 2 $lastBtn -af $btn "left" 4 -an $btn "bottom" -ap $btn "right" 0 79 -ac $field "top" 2 $lastBtn -ac $field "left" 4 $btn -an $field "bottom" -an $field "right" nw4cSetRenderPriority_SGList; } $lastBtn = $btn; } formLayout -e -w 299 nw4cSetRenderPriority_SGList; // update button visibility to display button (for -rs 0) for ($isg = 0; $isg < $sgSize; ++$isg) { string $btn = $childs[$isg]; control -e -vis false $btn; control -e -vis true $btn; } } //----------------------------------------------------------------------------- // set UI $isg = 0; for ($sg in $sgs) { //trace ("ui: " + $isg + " " + $childs[$isg] + " " + $childs[$sgSize + $isg]); string $btn = $childs[$isg]; button -e -l ($mats[$isg] + " ( " + $sg + " ) ") -c ("nw4cSetRenderPriority_ListButtonCB " + $btn + " " + $sg) -dgc ("nw4cSetRenderPriority_ListDragCB") -dpc ("nw4cSetRenderPriority_ListDropCB") $btn; intField -e -v $pris[$isg] -cc ("nw4cSetRenderPriority_ListPriorityCB " + $sg + " #1") $childs[$sgSize + $isg]; ++$isg; } setParent $parentBak; SetListColor(); } /****************************************************************************** list priority sort CB ******************************************************************************/ global proc nw4cSetRenderPriority_ListPrioritySortCB() { global int $nw4cSetRenderPriority_SortKind; global int $nw4cSetRenderPriority_SortOrder; global int $nw4cSetRenderPriority_KeepOrder; if ($nw4cSetRenderPriority_KeepOrder) { $nw4cSetRenderPriority_KeepOrder = 0; } else if ($nw4cSetRenderPriority_SortKind == 0) { $nw4cSetRenderPriority_SortOrder = !$nw4cSetRenderPriority_SortOrder; } else { $nw4cSetRenderPriority_SortOrder = 0; } $nw4cSetRenderPriority_SortKind = 0; UpdateList(); } /****************************************************************************** list name sort CB ******************************************************************************/ global proc nw4cSetRenderPriority_ListNameSortCB() { global int $nw4cSetRenderPriority_SortKind; global int $nw4cSetRenderPriority_SortOrder; global int $nw4cSetRenderPriority_KeepOrder; if ($nw4cSetRenderPriority_KeepOrder) { $nw4cSetRenderPriority_KeepOrder = 0; } else if ($nw4cSetRenderPriority_SortKind == 1) { $nw4cSetRenderPriority_SortOrder = !$nw4cSetRenderPriority_SortOrder; } else { $nw4cSetRenderPriority_SortOrder = 0; } $nw4cSetRenderPriority_SortKind = 1; UpdateList(); } /****************************************************************************** get SG name with material ******************************************************************************/ proc string GetSGNameWithMat(string $sg) { string $name = "( " + $sg + " )"; string $ins[] = `listConnections -s 1 -d 0 ($sg + ".ss")`; if (size($ins)) { $name = $ins[0] + " " + $name; } return $name; } /****************************************************************************** update window ******************************************************************************/ global proc nw4cSetRenderPriority_UpdateWindow() { //----------------------------------------------------------------------------- // get selection string $sgs[]; int $enableFlag = (GetSelectedSG($sgs) > 0); //----------------------------------------------------------------------------- // set node name string $nodesName; if ($enableFlag) { $nodesName = GetSGNameWithMat($sgs[0]); int $nodeSize = size($sgs); for ($inode = 1; $inode < $nodeSize; ++$inode) { if ($inode == 3) { $nodesName += ", ... (" + $nodeSize + ")"; break; } $nodesName += ", " + GetSGNameWithMat($sgs[$inode]); } } else { $nodesName = "(None)"; } text -e -l $nodesName nw4cSetRenderPriority_NodeName; //----------------------------------------------------------------------------- // set current attr & change command int $useRenderPriority = 0; if ($enableFlag) { string $node = $sgs[0]; $useRenderPriority = `nw4cSetRenderPriority_Get_UseRenderPriority $node`; radioButtonGrp -e -sl (!$useRenderPriority) -on1 ("nw4cSetRenderPriority_UseRenderPriorityCB " + $node) nw4cSetRenderPriority_DontCare; radioButtonGrp -e -sl $useRenderPriority -on1 ("nw4cSetRenderPriority_UseRenderPriorityCB " + $node) nw4cSetRenderPriority_UseRenderPriority; intField -e -v `nw4cSetRenderPriority_Get_RenderPriority $node` -cc ("nw4cSetRenderPriority_RenderPriorityCB " + $node) nw4cSetRenderPriority_RenderPriority; // setAttr などで変更された場合に、 // コントロールの値を更新するため SetJob_UseRenderPriority($node); SetJob_RenderPriority($node); } //----------------------------------------------------------------------------- // set enable state control -e -en $enableFlag nw4cSetRenderPriority_DontCare; control -e -en $enableFlag nw4cSetRenderPriority_UseRenderPriority; control -e -en ($enableFlag && $useRenderPriority) nw4cSetRenderPriority_RenderPriority; control -e -en $enableFlag nw4cSetRenderPriority_Description; //----------------------------------------------------------------------------- // update list if (`tabLayout -q -sti nw4cSetRenderPriority_Mode` == 2) { if (IsSGSizeChanged()) { //trace "SG size changed"; UpdateList(); } else { SetListColor(); } } } /****************************************************************************** search mode callback ******************************************************************************/ global proc nw4cSetRenderPriority_SearchModeCB() { int $dontCare = (`radioButtonGrp -q -sl nw4cSetRenderPriority_SearchDontCare` == 1); int $useRenderPriority = (`radioButtonGrp -q -sl nw4cSetRenderPriority_SearchUseRenderPriority` == 1); control -e -en $useRenderPriority nw4cSetRenderPriority_SearchCompare; control -e -en $useRenderPriority nw4cSetRenderPriority_SearchRenderPriority; control -e -en ($dontCare || $useRenderPriority) nw4cSetRenderPriority_SearchBtn; } /****************************************************************************** search value callback ******************************************************************************/ global proc nw4cSetRenderPriority_SearchValueCB() { int $val = `intField -q -v nw4cSetRenderPriority_SearchRenderPriority`; if ($val < 1) { intField -e -v 1 nw4cSetRenderPriority_SearchRenderPriority; } else if ($val > 255) { intField -e -v 255 nw4cSetRenderPriority_SearchRenderPriority; } } /****************************************************************************** do search ******************************************************************************/ global proc nw4cSetRenderPriority_DoSearch() { int $searchUse = (`radioButtonGrp -q -sl nw4cSetRenderPriority_SearchUseRenderPriority` == 1); int $compare = `optionMenu -q -sl nw4cSetRenderPriority_SearchCompare` - 1; nw4cSetRenderPriority_SearchValueCB(); // clamp value int $searchVal = `intField -q -v nw4cSetRenderPriority_SearchRenderPriority`; int $nodeCount = 0; select -cl; string $sgs[] = `ls -typ shadingEngine`; for ($node in $sgs) { if ($node == "initialParticleSE" || $node == "swatchShadingGroup") { continue; } int $useRenderPriority = nw4cSetRenderPriority_Get_UseRenderPriority($node); int $renderPriority = nw4cSetRenderPriority_Get_RenderPriority($node); int $match = 0; if (!$searchUse) { $match = !$useRenderPriority; } else { if (!$useRenderPriority) { $match = 0; } else if ($compare == 0) { $match = ($renderPriority < $searchVal); } else if ($compare == 1) { $match = ($renderPriority <= $searchVal); } else if ($compare == 2) { $match = ($renderPriority == $searchVal); } else if ($compare == 3) { $match = ($renderPriority >= $searchVal); } else { $match = ($renderPriority > $searchVal); } } if ($match) { select -add -ne $node; // shadingEngine string $ins[] = `listConnections -s 1 -d 0 ($node + ".ss")`; if (size($ins)) { select -add $ins[0]; // material } select -add $node; // shape object & face ++$nodeCount; } } if ($nodeCount == 0) { print "Not found\n"; } else { string $msg = "Found: " + $nodeCount + " shadingEngine node"; if ($nodeCount >= 2) { $msg += "s"; } print ($msg + "\n"); } } /****************************************************************************** tab change CB ******************************************************************************/ global proc nw4cSetRenderPriority_TabChangeCB() { if (`tabLayout -q -sti nw4cSetRenderPriority_Mode` == 2) { UpdateList(); } else { if (`control -q -en nw4cSetRenderPriority_RenderPriority`) { setFocus nw4cSetRenderPriority_RenderPriority; } } } /****************************************************************************** undo CB ******************************************************************************/ global proc nw4cSetRenderPriority_UndoCB() { if (`tabLayout -q -sti nw4cSetRenderPriority_Mode` == 2) { UpdateList(); } } /****************************************************************************** main ******************************************************************************/ global proc NW4C_SetRenderPriority() { global int $nw4cSetRenderPriority_SortKind; global int $nw4cSetRenderPriority_SortOrder; global int $nw4cSetRenderPriority_KeepOrder; int $afterMaya2011Adjust = 0; if (getApplicationVersionAsFloat() >= 2011) $afterMaya2011Adjust = 1; //----------------------------------------------------------------------------- // create window int $wd = 400; int $ht = 380; if (!`window -ex nw4cSetRenderPriority_Win`) { window -t "NW4C Set Render Priority" -wh $wd $ht -mxb 0 -mb 1 nw4cSetRenderPriority_Win; menu -l "Help"; menuItem -l ("Help on " + `window -q -t nw4cSetRenderPriority_Win` + "...") -c "NW4C_ShowHelp \"html/NW4C_SetRenderPriority.html\" \"\""; string $form1 = `formLayout -nd 100`; //----------------------------------------------------------------------------- // tab tabLayout -imh 0 -cc "nw4cSetRenderPriority_TabChangeCB" // reload at change nw4cSetRenderPriority_Mode; //----------------------------------------------------------------------------- // set & search //----------------------------------------------------------------------------- columnLayout -adj 1 -cat "both" 4 -rs 4 nw4cSetRenderPriority_SetLayout; //----------------------------------------------------------------------------- // node name frameLayout -l "Selected Material ( Shading Group )" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; columnLayout -adj 1 -cal "center" -rs 8; text -l "" nw4cSetRenderPriority_NodeName; setParent ..; // columnLayout setParent ..; // formLayout //----------------------------------------------------------------------------- // set frameLayout -l "Set" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; string $form2 = `formLayout -nd 400`; radioButtonGrp -l "Render Priority" -nrb 1 -cw2 110 80 -l1 "Don't care" nw4cSetRenderPriority_DontCare; radioButtonGrp -l "" -nrb 1 -cw2 110 18 -l1 "" -scl nw4cSetRenderPriority_DontCare nw4cSetRenderPriority_UseRenderPriority; intField -w 50 -v 1 nw4cSetRenderPriority_RenderPriority; text -l "1 (High Priority) - 255 (Low Priority)" nw4cSetRenderPriority_Description; setParent ..; // formLayout formLayout -e -af nw4cSetRenderPriority_DontCare "top" 8 -af nw4cSetRenderPriority_DontCare "left" 0 -an nw4cSetRenderPriority_DontCare "bottom" -an nw4cSetRenderPriority_DontCare "right" -ac nw4cSetRenderPriority_UseRenderPriority "top" 8 nw4cSetRenderPriority_DontCare -af nw4cSetRenderPriority_UseRenderPriority "left" 0 -an nw4cSetRenderPriority_UseRenderPriority "bottom" -an nw4cSetRenderPriority_UseRenderPriority "right" -ac nw4cSetRenderPriority_RenderPriority "top" 4 nw4cSetRenderPriority_DontCare -ac nw4cSetRenderPriority_RenderPriority "left" 0 nw4cSetRenderPriority_UseRenderPriority -an nw4cSetRenderPriority_RenderPriority "bottom" -an nw4cSetRenderPriority_RenderPriority "right" -ac nw4cSetRenderPriority_Description "top" 4 nw4cSetRenderPriority_RenderPriority -ac nw4cSetRenderPriority_Description "left" 4 nw4cSetRenderPriority_UseRenderPriority -af nw4cSetRenderPriority_Description "bottom" 8 -an nw4cSetRenderPriority_Description "right" $form2; setParent ..; // frameLayout //----------------------------------------------------------------------------- // search frameLayout -l "Search" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; columnLayout -adj 1 -cal "center" -rs 0; string $form3 = `formLayout -nd 400`; radioButtonGrp -l "" -nrb 1 -cw2 110 80 -l1 "Don't care" -on1 "nw4cSetRenderPriority_SearchModeCB" nw4cSetRenderPriority_SearchDontCare; radioButtonGrp -l "" -nrb 1 -cw2 110 18 -l1 "" -scl nw4cSetRenderPriority_SearchDontCare -on1 "nw4cSetRenderPriority_SearchModeCB" nw4cSetRenderPriority_SearchUseRenderPriority; optionMenu -w 110 nw4cSetRenderPriority_SearchCompare; menuItem -l "< : ( under )"; menuItem -l "<= : ( below )"; menuItem -l "= : ( exactly )"; menuItem -l ">= : ( above )"; menuItem -l "> : ( over )"; intField -w 50 -h 26 -v 1 -cc "nw4cSetRenderPriority_SearchValueCB" nw4cSetRenderPriority_SearchRenderPriority; setParent ..; // formLayout formLayout -e -af nw4cSetRenderPriority_SearchDontCare "top" 8 -af nw4cSetRenderPriority_SearchDontCare "left" 0 -an nw4cSetRenderPriority_SearchDontCare "bottom" -an nw4cSetRenderPriority_SearchDontCare "right" -ac nw4cSetRenderPriority_SearchUseRenderPriority "top" 10 nw4cSetRenderPriority_SearchDontCare -af nw4cSetRenderPriority_SearchUseRenderPriority "left" 0 -an nw4cSetRenderPriority_SearchUseRenderPriority "bottom" -an nw4cSetRenderPriority_SearchUseRenderPriority "right" -ac nw4cSetRenderPriority_SearchCompare "top" (4 + $afterMaya2011Adjust * 3) nw4cSetRenderPriority_SearchDontCare -ac nw4cSetRenderPriority_SearchCompare "left" 0 nw4cSetRenderPriority_SearchUseRenderPriority -an nw4cSetRenderPriority_SearchCompare "bottom" -an nw4cSetRenderPriority_SearchCompare "right" -ac nw4cSetRenderPriority_SearchRenderPriority "top" 4 nw4cSetRenderPriority_SearchDontCare -ac nw4cSetRenderPriority_SearchRenderPriority "left" 4 nw4cSetRenderPriority_SearchCompare -af nw4cSetRenderPriority_SearchRenderPriority "bottom" 8 -an nw4cSetRenderPriority_SearchRenderPriority "right" $form3; rowColumnLayout -nc 2 -cw 1 200 -cw 2 150; text -l ""; // dummy button -l "Search" -c "nw4cSetRenderPriority_DoSearch" nw4cSetRenderPriority_SearchBtn; setParent ..; // rowColumnLayout separator -h 8 -st "none"; setParent ..; // columnLayout setParent ..; // formLayout optionMenu -e -sl 3 nw4cSetRenderPriority_SearchCompare; setParent ..; // columnLayout //----------------------------------------------------------------------------- // list //----------------------------------------------------------------------------- formLayout -nd 100 nw4cSetRenderPriority_ListLayout; //----------------------------------------------------------------------------- string $labelRow = `rowColumnLayout -nc 4 -cw 1 240 -cw 2 16 -cw 3 49 -cw 4 16 -cs 1 7 -cs 3 5`; //iconTextButton -h 24 -l "Shading Group ( Material )" // -st "iconAndTextHorizontal" -i1 "arrowUp.xpm" // -c "nw4cSetRenderPriority_ListNameSortCB"; button -l "Material ( Shading Group )" -al "left" -c "nw4cSetRenderPriority_ListNameSortCB"; iconTextStaticLabel -h 24 -st "iconOnly" -i1 "arrowUp.xpm" -vis 0 nw4cSetRenderPriority_NameSortIcon; button -l "Priority" -al "left" -c "nw4cSetRenderPriority_ListPrioritySortCB"; iconTextStaticLabel -h 24 -st "iconOnly" -i1 "arrowDown.xpm" -vis 0 nw4cSetRenderPriority_PrioritySortIcon; setParent ..; // rowColumnLayout; string $scroll = `scrollLayout -hst 0`; formLayout -nd 100 nw4cSetRenderPriority_SGList; setParent ..; // formLayout; setParent ..; // scrollLayout checkBox -l "Frame Objects" -v 0 nw4cSetRenderPriority_FrameObjects; formLayout -e -af $labelRow "top" 4 -af $labelRow "left" 4 -an $labelRow "bottom" -af $labelRow "right" 4 -ac $scroll "top" 4 $labelRow -af $scroll "left" 4 -ac $scroll "bottom" 4 nw4cSetRenderPriority_FrameObjects -af $scroll "right" 4 -an nw4cSetRenderPriority_FrameObjects "top" -af nw4cSetRenderPriority_FrameObjects "left" 10 -af nw4cSetRenderPriority_FrameObjects "bottom" 4 -af nw4cSetRenderPriority_FrameObjects "right" 4 nw4cSetRenderPriority_ListLayout; setParent ..; // formLayout setParent ..; // tabLayout tabLayout -e -tl nw4cSetRenderPriority_SetLayout "Set and Search" nw4cSetRenderPriority_Mode; tabLayout -e -tl nw4cSetRenderPriority_ListLayout "List" nw4cSetRenderPriority_Mode; //tabLayout -e -st nw4cSetRenderPriority_ListLayout // nw4cSetRenderPriority_Mode; // select List default //----------------------------------------------------------------------------- // close button string $closeCmd = "deleteUI nw4cSetRenderPriority_Win"; string $closeBtn = `button -h 26 -l "Close" -c $closeCmd`; formLayout -e -af nw4cSetRenderPriority_Mode "top" 4 -af nw4cSetRenderPriority_Mode "left" 4 -ac nw4cSetRenderPriority_Mode "bottom" 4 $closeBtn -af nw4cSetRenderPriority_Mode "right" 4 -an $closeBtn "top" -af $closeBtn "left" 4 -af $closeBtn "bottom" 4 -af $closeBtn "right" 4 $form1; setParent ..; // formLayout setFocus $closeBtn; //----------------------------------------------------------------------------- // set selection change job scriptJob -p nw4cSetRenderPriority_Win -e "SelectionChanged" "nw4cSetRenderPriority_UpdateWindow"; //----------------------------------------------------------------------------- // set undo / redo job scriptJob -p nw4cSetRenderPriority_Win -e "Undo" "nw4cSetRenderPriority_UndoCB"; scriptJob -p nw4cSetRenderPriority_Win -e "Redo" "nw4cSetRenderPriority_UndoCB"; //----------------------------------------------------------------------------- // set name change job scriptJob -p nw4cSetRenderPriority_Win -e "NameChanged" "nw4cSetRenderPriority_UndoCB"; //----------------------------------------------------------------------------- // init sort state $nw4cSetRenderPriority_SortKind = 0; $nw4cSetRenderPriority_SortOrder = 0; $nw4cSetRenderPriority_KeepOrder = 0; } if (`window -q -w nw4cSetRenderPriority_Win` < $wd) { window -e -w $wd nw4cSetRenderPriority_Win; } if (`window -q -h nw4cSetRenderPriority_Win` < $ht) { window -e -h $ht nw4cSetRenderPriority_Win; } //window -e -wh $wd $ht nw4cSetRenderPriority_Win; //----------------------------------------------------------------------------- // update window nw4cSetRenderPriority_UpdateWindow(); nw4cSetRenderPriority_SearchModeCB(); nw4cSetRenderPriority_TabChangeCB(); //----------------------------------------------------------------------------- // show window showWindow nw4cSetRenderPriority_Win; }