// =========================================================================== // 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. // =========================================================================== // // Description: // Option tool callback for Artisan False Coloring Ramp // // // Procedure Name: // artisanRampCallback // // Description: // Initialize the color ramp values. // // Input Arguments: // // Return Value: // None. // // global proc setRampMinColorCallback(string $currContext) { colorEditor; if (`colorEditor -query -result`) { float $values[]; $values = `colorEditor -query -rgb`; artAttrCtx -e -rampMinColor $values[0] $values[1] $values[2] $currContext; button -e -bgc $values[0] $values[1] $values[2] artRampMinColorButton; } } global proc setRampMaxColorCallback(string $currContext) { colorEditor; if (`colorEditor -query -result`) { float $values[]; $values = `colorEditor -query -rgb`; artAttrCtx -e -rampMaxColor $values[0] $values[1] $values[2] $currContext; button -e -bgc $values[0] $values[1] $values[2] artRampMaxColorButton; } } global proc artisanCreateRamp(string $parent, int $addColorTabs) // Add ramp widget // { setParent $parent; // false color ramp checkBoxGrp -label1 "" -label (uiRes("m_artisanRampCallback.kArtUseColorRamp")) -numberOfCheckBoxes 1 -value1 on artisanRampUseRamp; if ($addColorTabs == 1) { rowLayout -nc 4 -cw 1 100 -cw 2 35 -cw 3 160 -cw 4 35 artisanColorRampRowLayout; } else { rowLayout -nc 2 -cw 1 100 -cw 2 160 artisanColorRampRowLayout; } text -label (uiRes("m_artisanRampCallback.kArtRampColorCurve")) artColorRampText; if ($addColorTabs == 1) { button -bgc 0 0 0 -w 30 -h 30 -label "" artRampMinColorButton; } gradientControlNoAttr -h 60 -rampAsColor true artisanColorRamp; if ($addColorTabs == 1) { button -bgc 1 1 1 -w 30 -h 30 -label "" artRampMaxColorButton; } setParent .. ; rowColumnLayout -nc 2 -cw 1 270 -cw 2 60 artisanSelectedColorRowColumnLayout; colorSliderGrp -label (uiRes("m_artisanRampCallback.kArtSkinColorSlider")) artisanColorRampSlider; columnLayout; setParent .. ; setParent .. ; rowLayout -nc 2 -cw 2 230 artisanColorPresetsRowLayout; text -label (uiRes("m_artisanRampCallback.kColorCurvePresets")) artisanColorPresetsText; int $presetCellSize = 23; gridLayout -numberOfColumns 3 -cellWidthHeight $presetCellSize $presetCellSize artisanColorPresetsGrid; iconTextButton -image "colorPresetBlackRedYellow.png" artHotColorIconButton; iconTextButton -image "colorPresetSpectrum.png" artFullRangeColorIconButton; iconTextButton -image "colorPresetGrayscale.png" artGreyColorIconButton; setParent ..; setParent ..; setParent ..; setParent $parent; } global proc artisanUpdateRampColorEnable() // Description: // { if (`checkBoxGrp -q -exists artisanRampUseRamp`) { int $enabled = `checkBoxGrp -q -value1 artisanRampUseRamp`; if (`layout -exists artisanColorRampRowLayout`) layout -e -enable $enabled artisanColorRampRowLayout; if (`layout -exists artisanColorPresetsRowLayout`) layout -e -enable $enabled artisanColorPresetsRowLayout; if (`layout -exists artisanSelectedColorRowColumnLayout`) layout -e -enable $enabled artisanSelectedColorRowColumnLayout; } } global proc artisanColorRampKeyChanged(string $artCommand) { if (`colorSliderGrp -q -exists artisanColorRampSlider` && `gradientControlNoAttr -q -exists artisanColorRamp`) { float $t[] = `gradientControlNoAttr -q -currentKeyColorValue artisanColorRamp`; colorSliderGrp -e -rgb $t[0] $t[1] $t[2] artisanColorRampSlider; } } global proc artisanSetColorRampKey (string $artCommand) { string $currContext = `currentCtx`; if (`colorSliderGrp -q -exists artisanColorRampSlider` && `gradientControlNoAttr -q -exists artisanColorRamp`) { float $t[] = `colorSliderGrp -q -rgb artisanColorRampSlider`; gradientControlNoAttr -e -currentKeyColorValue $t[0] $t[1] $t[2] artisanColorRamp; string $rampValue = `gradientControlNoAttr -q -asString artisanColorRamp`; string $rampCmd = "artAttrCtx -e -colorRamp \"" + $rampValue + "\" " + $currContext; eval ($rampCmd); } } global proc artisanRampCallback( string $artCommand ) { string $currContext = `currentCtx`; string $changeCmd = "artAttrCtx -e -useColorRamp #1 "+ $currContext; string $valueCmd = "artAttrCtx -q -useColorRamp " + $currContext; checkBoxGrp -e -value1 `eval $valueCmd` -cc ($changeCmd + " ; artisanUpdateRampColorEnable" ) artisanRampUseRamp; $valueCmd = "artAttrCtx -q -colorRamp " + $currContext; string $value =`eval $valueCmd`; $changeCmd = "artAttrCtx -e -colorRamp \" #1 \" "+ $currContext; gradientControlNoAttr -e -asString $value -changeCommand $changeCmd -currentKeyChanged ("artisanColorRampKeyChanged \"" + $artCommand + "\"") artisanColorRamp; float $t[] = `gradientControlNoAttr -q -currentKeyColorValue artisanColorRamp`; colorSliderGrp -e -changeCommand ("artisanSetColorRampKey \"" + $artCommand + "\"") -rgb $t[0] $t[1] $t[2] artisanColorRampSlider; if(`button -exists artRampMinColorButton`) { string $cmd = $artCommand + " -q -rampMinColor " + $currContext; string $minColorCallback = "setRampMinColorCallback(\"" + $currContext + "\")"; float $color[] = `eval $cmd`; button -e -bgc $color[0] $color[1] $color[2] -command $minColorCallback artRampMinColorButton; artAttrCtx -e -useMaxMinColor true $currContext; } if(`button -exists artRampMaxColorButton`) { $cmd = $artCommand + " -q -rampMaxColor " + $currContext; string $maxColorCallback = "setRampMaxColorCallback(\"" + $currContext + "\")"; $color = `eval $cmd`; button -e -bgc $color[0] $color[1] $color[2] -command $maxColorCallback artRampMaxColorButton; } if (`iconTextButton -exists artHotColorIconButton`) { iconTextButton -e -command ($artCommand + " -e -colorRamp \"1,0,0,0.5,1,1,1,0,1,1,0,0,0,0,1\" " + $currContext + "; artisanRampCallback(\"" + $artCommand + "\")" ) artHotColorIconButton; } if (`iconTextButton -exists artFullRangeColorIconButton`) { iconTextButton -e -command ($artCommand + " -e -colorRamp \"1,0,0,1,1,1,0.5,0,0.75,1,1,1,0,0.5,1,0,1,0,0.25,1,0,0,1,0,1\" " +$currContext + "; artisanRampCallback(\"" + $artCommand + "\")" ) artFullRangeColorIconButton; } if (`iconTextButton -exists artGreyColorIconButton`) { iconTextButton -e -command ($artCommand + " -e -colorRamp \"0.5,0.5,0.5,0.5,1,1,1,1,1,1,0,0,0,0,1 \" "+$currContext + "; artisanRampCallback(\"" + $artCommand + "\")" ) artGreyColorIconButton; } artisanUpdateRampColorEnable; }