// =========================================================================== // 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. // =========================================================================== global proc colorSetDisplayMenuItems(int $all){ // // Description: // This proc builds the menu items in the display menu. // The menu is basically duplicated: once for all objects, // once for selected objects. // // Input Arguments: // $all: boolean specifying all (1) or selected (0) // menuItem -label (uiRes("m_colorSetEditor.kColorInShadedDisplayOn")) -command ("colorSetDisplay " + $all + "\"-colorShadedDisplay\" 1") ; menuItem -label (uiRes("m_colorSetEditor.kColorInShadedDisplayOff")) -command ("colorSetDisplay " + $all + "\"-colorShadedDisplay\" 0") ; menuItem -divider true; menuItem -label (uiRes("m_colorSetEditor.kColorMaterialChannelNone")) -command ("colorSetDisplay " + $all + "\"-colorMaterialChannel\" None") ; menuItem -label (uiRes("m_colorSetEditor.kColorMaterialChannelAmbient")) -command ("colorSetDisplay " + $all + "\"-colorMaterialChannel\" Ambient") ; menuItem -label (uiRes("m_colorSetEditor.kColorMaterialChannel")) -command ("colorSetDisplay " + $all + "\"-colorMaterialChannel\" AmbientDiffuse") ; menuItem -label (uiRes("m_colorSetEditor.kColorMaterialChannelDiffuse")) -command ("colorSetDisplay " + $all + "\"-colorMaterialChannel\" Diffuse") ; menuItem -label (uiRes("m_colorSetEditor.kColorMaterialChannelSpecular")) -command ("colorSetDisplay " + $all + "\"-colorMaterialChannel\" Specular") ; menuItem -label (uiRes("m_colorSetEditor.kColorMaterialChannelEmission")) -command ("colorSetDisplay " + $all + "\"-colorMaterialChannel\" Emission") ; menuItem -divider true; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingOverwrite")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" overwrite") ; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingAdd")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" add") ; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingSubtract")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" subtract") ; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingMultiply")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" multiply") ; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingDivide")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" divide") ; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingAverage")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" average") ; menuItem -label (uiRes("m_colorSetEditor.kMaterialBlendSettingModulate2")) -command ("colorSetDisplay " + $all + "\"-materialBlend\" modulate2x") ; } global proc colorSetDisplay(int $all, string $flag, string $value){ // // Description: // This proc sets the display of CPV as called from the menuItems // in colorSetDisplayMenuItems. // // Input Arguments: // $all: boolean specifying all (1) or selected (0) // $flag: flag to change // $value: new value of the flag // if ($flag == "-colorShadedDisplay"){ int $intValue = $value; if ($all) polyOptions -global ($flag) $intValue; else polyOptions -activeObjects ($flag) $intValue; } else { if ($all) polyOptions -global ($flag) $value; else polyOptions -activeObjects ($flag) $value; } } global proc int colorSetEditorMoveSet( int $direction, string $textScrollList ){ // // Description: // This proc provides the basics for moving items in the list // // Input Arguments: // $currentColorSetName: the name of the colorSet to rename // // Return: // 0 = error // 1 = success //find position int $selectedItemIndex[] = `textScrollList -q -sii $textScrollList`; //check if anything is selected and return a warning if not if (`size $selectedItemIndex` == 0){ warning (uiRes("m_colorSetEditor.kColorSetMoveWarning")); return 0; } //get name of selected string $selectedItemString[] = `textScrollList -q -si $textScrollList`; //how to move int $numItems = `textScrollList -q -ni $textScrollList`; int $newIndex = $selectedItemIndex[0] + $direction; if ($newIndex < 1) $newIndex = 1; if ($newIndex > $numItems) $newIndex = $numItems; //move position textScrollList -edit -removeIndexedItem $selectedItemIndex[0] $textScrollList; textScrollList -edit -appendPosition $newIndex $selectedItemString[0] $textScrollList; //reselect item textScrollList -edit -selectIndexedItem $newIndex $textScrollList; return 1; } // Procedure Name: // updateColorSetEditor // // Description: // Updates the colorSetEditor when called. When the colorSetEditor is created // it creates a scriptJob that is tied to it that cals this when the selection // changes. This is also called from colorSetEditCmd. // // Input Arguments: // None. // // Return Value: // None. // global proc updateColorSetEditor( ) { // typically, user will have transform selected so find mesh shapes // string $objects[] = `listRelatives -s -fullPath -type "mesh"`; // if there is nothing, check to see if shapes are selected // if (!`size $objects`) $objects = `ls -sl -type "mesh"`; // if there is still nothing, check to see if components are selected // if (!`size $objects`) $objects = `listRelatives -p -fullPath -type "mesh"`; // clear the set list // textScrollList -e -ra colorSetList; // if there are meshes, populate the list with the cpv sets // from the first selected mesh // if (`size $objects`){ string $repArray[] = `polyColorSet -pi 1 -q -allColorSets -representation $objects[0]`; int $i; for( $i = 0; $i < size($repArray); $i += 2 ) { string $set = $repArray[$i]; string $perInstSet[] = `polyColorSet -colorSet $set -q -pi $objects[0]`; if (size($perInstSet[0]) > 0) { $set = $perInstSet[0]; } else { continue; } string $setLabel = $set + "(" + $repArray[$i+1] + ")"; textScrollList -e -a $setLabel colorSetList; } //***need to add controls for enable/disable state of buttons // select the current color set // string $colorSetName[] = `polyColorSet -q -currentPerInstanceSet $objects[0]`; string $rep = `polyColorSet -q -currentColorSet -representation $objects[0]`; if( `size $colorSetName` > 0 ) { string $setLabel = $colorSetName[0] + "(" + $rep + ")"; textScrollList -e -si $setLabel colorSetList; } } } // Procedure Name: // buildColorSetEditorContextHelpItems // // Description: // Creates the help menu and items for the colorSetEditor. // // Input Arguments: // $nameRoot - name to use as the root of all item names // $menuParent - the name of the parent of this menu // // Return Value: // None // global proc buildColorSetEditorContextHelpItems(string $nameRoot, string $menuParent) { menuItem -label (uiRes("m_colorSetEditor.kHelpOnColorSetEditor")) -enableCommandRepeat false -command "showHelp ColorSetEditor"; } // Procedure Name: // refreshColorSetEditor // // Description: // Refreshes the colorSetEditor. // // Input Arguments: // None. // // Return Value: // None. // global proc refreshColorSetEditor( string $parent ) { // Giving the chance to third parties to add their baking menu items // string $currentParent = `setParent -menu -q`; setParent -menu $parent; removeMenuItems("OptionBoxPrelightMayaSoftwareOpt", ""); callbacks -executeCallbacks -hook "addPrelightMenuItems"; setParent -menu $currentParent; } // Procedure Name: // colorSetEditor // // Description: // Creates the colorSetEditor for editting multiple CPV sets. // // Input Arguments: // None. // // Return Value: // None. // global proc colorSetEditor( ) { if( `window -exists colorSetEditor` ) { deleteUI -window colorSetEditor; } // GG: don't hardcode the HEIGHT! It doesn't work X-platform window -title (uiRes("m_colorSetEditor.kColorSetEditor")) -menuBar true -w 223 -s true colorSetEditor; menu -label (uiRes("m_colorSetEditor.kColor")) -tearOff true -allowOptionBoxes true; menuItem -label (uiRes("m_colorSetEditor.kApplyColor")) -annotation (getRunTimeCommandAnnotation("PolygonApplyColor")) -image "polyApplyColor.png" -command "PolygonApplyColor" -dragMenuCommand "performApplyColor 2" -dragDoubleClickCommand "PolygonApplyColorOptions" ; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation("PolygonApplyColorOptions")) -image "polyApplyColor.png" -command "PolygonApplyColorOptions" ; menuItem -label (uiRes("m_colorSetEditor.kPaintVertexColorTool")) -annotation (getRunTimeCommandAnnotation("PaintVertexColorTool")) -image "paintVertexColour.png" -command "PaintVertexColorTool" -dragDoubleClickCommand "PaintVertexColorToolOptions" ; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation("PaintVertexColorToolOptions")) -image "paintVertexColour.png" -command "PaintVertexColorToolOptions" ; string $colorSetEditorMenu = `menu -label (uiRes("m_colorSetEditor.kPrelight")) -tearOff true -allowOptionBoxes true`; menu -edit -postMenuCommand ("refreshColorSetEditor " + $colorSetEditorMenu) $colorSetEditorMenu; menuItem -label (uiRes("m_colorSetEditor.kPrelightMayaSoftware")) -annotation (uiRes("m_colorSetEditor.kPrelightMayaSoftwareAnnot")) -command ("performPrelight " + 0) -dragMenuCommand ("performPrelight " + 2) -dragDoubleClickCommand ("performPrelight " + 1) PolygonPrelightAnchorPoint ; menuItem -optionBox true -annotation (uiRes("m_colorSetEditor.kOptionBoxPrelightMayaSoftwareAnnot")) -command ("performPrelight " + 1) OptionBoxPrelightMayaSoftwareOpt ; menu -label (uiRes("m_colorSetEditor.kDisplay")) -tearOff true colorSetDisplayMenu; menuItem -label (uiRes("m_colorSetEditor.kAll")) -subMenu true; colorSetDisplayMenuItems 1; setParent -menu colorSetDisplayMenu; menuItem -label (uiRes("m_colorSetEditor.kSelected")) -subMenu true; colorSetDisplayMenuItems 0; addContextHelpProc "colorSetEditor" "buildColorSetEditorContextHelpItems"; doHelpMenu("colorSetEditor", "colorSetEditor"); formLayout colorEditorForm; textScrollList -ams true -deleteKeyCommand "colorSetEditCmd delete colorSetList" -doubleClickCommand "colorSetEditCmd rename colorSetList" -selectCommand "colorSetEditCmd setCurrent colorSetList" colorSetList; separator scrollButtonsSeparator; columnLayout colorSetEditorButtonLayout; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kNew")) -annotation (uiRes("m_colorSetEditor.kCreateANewColorSetAnnot")) -enable true -c "createEmptyColorSet 1" newButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kRename")) -annotation (uiRes("m_colorSetEditor.kRenameTheCurrentColorSetAnnot")) -c "colorSetEditCmd rename colorSetList" -enable true renameButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kDelete")) -annotation (uiRes("m_colorSetEditor.kDeleteTheCurrentColorSetAnnot")) -c "colorSetEditCmd delete colorSetList" -enable true deleteButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kCopy")) -annotation (uiRes("m_colorSetEditor.kCopyTheCurrentColorSetToANewAnnot")) -c "colorSetEditCmd copy colorSetList" -enable true copyButton; //button -h 26 -w 80 -label _L10N( kSetCurrent, "Set Current" ) // -c "colorSetEditCmd setCurrent colorSetList" // -enable true // setCurentButton; separator -w 80 -h 10 adjustSeparator; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kModify")) -c "colorSetEditCmd modify colorSetList" -enable true modifyButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kMerge")) -annotation (uiRes("m_colorSetEditor.kCombineTwoSelectedColorSetsAnnot")) -c "colorSetEditCmd merge colorSetList" -enable true mergeButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kBlend")) -annotation (uiRes("m_colorSetEditor.kCombineTwoSelectedColorSets2Annot")) -c "colorSetEditCmd blend colorSetList" -enable true blendButton; string $blendForm = `formLayout`; optionMenu -label "" colorSetBlendMode; menuItem -label (uiRes("m_colorSetEditor.kOver")) ; menuItem -label (uiRes("m_colorSetEditor.kMultiply")) ; menuItem -label (uiRes("m_colorSetEditor.kMultiplyRGBA")) ; menuItem -label (uiRes("m_colorSetEditor.kAdd")) ; menuItem -label (uiRes("m_colorSetEditor.kSubtract")) ; menuItem -label (uiRes("m_colorSetEditor.kLinear")) ; menuItem -label (uiRes("m_colorSetEditor.kBilinear")) ; menuItem -label (uiRes("m_colorSetEditor.kChannels")) ; formLayout -e -attachForm colorSetBlendMode "top" 5 -attachForm colorSetBlendMode "left" 5 -attachForm colorSetBlendMode "bottom" 0 -attachForm colorSetBlendMode "right" 5 $blendForm; setParent ..; separator -w 80 -h 10 moveSeparator; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kMoveUp")) -annotation (uiRes("m_colorSetEditor.kMoveTheSelectedColorSetUpOneAnnot")) -c "colorSetEditorMoveSet -1 colorSetList" -enable true moveUpButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kMoveDown")) -annotation (uiRes("m_colorSetEditor.kMoveTheSelectedColorSetDownAnnot")) -c "colorSetEditorMoveSet 1 colorSetList" -enable true moveDownButton; setParent ..; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kUpdate")) -c "updateColorSetEditor" updateButton; button -h 26 -w 80 -label (uiRes("m_colorSetEditor.kClose")) -c "deleteUI -window colorSetEditor" closeButton; setParent ..; formLayout -e -af colorSetList top 5 -ac colorSetList right 5 colorSetEditorButtonLayout -af colorSetList left 5 -ac colorSetList bottom 5 scrollButtonsSeparator -af colorSetEditorButtonLayout top 5 -af colorSetEditorButtonLayout right 5 -an colorSetEditorButtonLayout left -ac colorSetEditorButtonLayout bottom 5 scrollButtonsSeparator -af scrollButtonsSeparator left 0 -af scrollButtonsSeparator right 0 -ac scrollButtonsSeparator bottom 5 updateButton -an scrollButtonsSeparator top -af updateButton left 5 -af updateButton bottom 5 -ap updateButton right 3 50 -an updateButton top -ap closeButton left 2 50 -af closeButton bottom 5 -af closeButton right 5 -an closeButton top colorEditorForm; // Create script jobs to keep the color set editor up to date // when the selection changes // scriptJob -parent "colorSetEditor" -event "SelectionChanged" "updateColorSetEditor"; scriptJob -parent "colorSetEditor" -event "Undo" "updateColorSetEditor"; scriptJob -parent "colorSetEditor" -event "Redo" "updateColorSetEditor"; updateColorSetEditor; showWindow colorSetEditor; }