// =========================================================================== // 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 string $gDynPaintSceneToolsToolbox = ""; global string $gDynPaintCanvasToolsToolbox = ""; global string $gDynPaintTubeTools = ""; global string $gDynPaintLeafTools = ""; global string $gDynPaintFlowerTools = ""; global string $gDynPaintBudTools = ""; global string $gDynPaintToolbar; global proc doCanvasClear(string $editor) // // This procedure is executed when the user clicks on the clear icon. // It prompts the user for confirmation first and then clears the canvas // or deletes strokes in the scene. // { global string $gDynPaintEditorName; // if we're in canvas mode .. clear the canvas if( `dynPaintEditor -q -canvasMode $gDynPaintEditorName` ) { // if autosave is on warn the user about data loss // if ( `dynPaintEditor -q -autoSave $gDynPaintEditorName`) { // // string $confirmClear = `confirmDialog // -m "Clear the Canvas? \n \n Auto Save is on, you will lose your work. \n" // -button "Clear" // -button "Cancel" // -defaultButton "Cancel" // -cancelButton "Cancel"`; // // if ($confirmClear == "Clear") { // // if ( `dynPaintEditor -q -autoSave $gDynPaintEditorName`) { // // turn off autosave // toggleAutoSave ($editor); // } // clear the canvas float $cc[] = `optionVar -q dynPaintPanelClearColour`; dynPaintEditor -e -cl $cc[0] $cc[1] $cc[2] $editor; // } // // } // // autosave is off .. just clear the canvas // // else { // float $cc[] = `optionVar -q dynPaintPanelClearColour`; // dynPaintEditor -e -cl $cc[0] $cc[1] $cc[2] $editor; // } } else { // we're in paint scene mode .. delete strokes deleteAllStrokes(); } } global proc setDynPaintOnlyToolbox( int $state ) { // global string $gDynPaintSceneToolsToolbox; // // if( size( $gDynPaintSceneToolsToolbox ) > 0 ) // { // setParent $gDynPaintSceneToolsToolbox; // symbolCheckBox -e -v $state "activeOnlyCheckBox"; // } } global proc setDynPaintAutoSaveToolbox( int $state ) { global string $gDynPaintSceneToolsToolbox; if( size( $gDynPaintSceneToolsToolbox ) > 0 ) { setParent $gDynPaintSceneToolsToolbox; symbolCheckBox -e -v $state "autoSaveCheckBox"; } } global proc setShowLeafTools() { global string $gDynPaintLeafTools; string $defBrush = getDefaultBrush(); if( size( $gDynPaintLeafTools ) > 0 ) { int $leaves = getAttr( $defBrush + ".leaves" ); int $tubes = getAttr( $defBrush + ".tubes" ); $leaves = ($leaves && $tubes); setParent $gDynPaintLeafTools; attrColorSliderGrp -e -manage $leaves brushLC1; attrColorSliderGrp -e -manage $leaves brushLC2; } } global proc setShowFlowerTools() { global string $gDynPaintFlowerTools; string $defBrush = getDefaultBrush(); if( size( $gDynPaintFlowerTools ) > 0 ) { int $flowers = getAttr( $defBrush + ".flowers" ); int $tubes = getAttr( $defBrush + ".tubes" ); $flowers = ($flowers && $tubes ); setParent $gDynPaintFlowerTools; attrColorSliderGrp -e -manage $flowers brushPC1; attrColorSliderGrp -e -manage $flowers brushPC2; } } global proc setShowBudTools() { global string $gDynPaintBudTools; string $defBrush = getDefaultBrush(); if( size( $gDynPaintBudTools ) > 0 ) { int $buds = getAttr( $defBrush + ".buds" ); int $tubes = getAttr( $defBrush + ".tubes" ); $buds = ($buds && $tubes); setParent $gDynPaintBudTools; attrColorSliderGrp -e -manage $buds brushBC; } } global proc setShowTubeTools() { global string $gDynPaintTubeTools; string $defBrush = getDefaultBrush(); if( size( $gDynPaintTubeTools ) > 0 ) { int $tubes = getAttr( $defBrush + ".tubes" ); setParent $gDynPaintTubeTools; attrFieldSliderGrp -e -manage $tubes brushTS; attrColorSliderGrp -e -manage $tubes brushC2; attrColorSliderGrp -e -manage $tubes brushT2; setShowLeafTools(); // formLayout -e -manage $tubes "leafTools"; setShowFlowerTools(); // formLayout -e -manage $tubes "flowerTools"; setShowBudTools(); // formLayout -e -manage $tubes "budTools"; } } global proc setDynPaintModeToolbox( int $mode ) { // global string $gDynPaintSceneToolsToolbox; // // if( size( $gDynPaintSceneToolsToolbox ) > 0 ) // { // // setParent $gDynPaintSceneToolsToolbox; // // switch( $mode ) // { // case 0: // symbolCheckBox -e -v 1 "refreshOffCheckBox"; // symbolCheckBox -e -v 0 "refreshWireCheckBox"; // symbolCheckBox -e -v 0 "refreshRenderedCheckBox"; // break; // case 1: // symbolCheckBox -e -v 0 "refreshOffCheckBox"; // symbolCheckBox -e -v 1 "refreshWireCheckBox"; // symbolCheckBox -e -v 0 "refreshRenderedCheckBox"; // break; // case 2: // symbolCheckBox -e -v 0 "refreshOffCheckBox"; // symbolCheckBox -e -v 0 "refreshWireCheckBox"; // symbolCheckBox -e -v 1 "refreshRenderedCheckBox"; // break; // } // } } global proc showDynPaintSceneTools( int $state ) { global string $gDynPaintSceneToolsToolbox; global string $gDynPaintCanvasToolsToolbox; global string $gDynPaintToolbar; if( size( $gDynPaintSceneToolsToolbox ) > 0 ) { setParent $gDynPaintSceneToolsToolbox; symbolButton -e -manage $state "renderButton"; // symbolCheckBox -e -manage $state "refreshOffCheckBox"; // symbolCheckBox -e -manage $state "refreshWireCheckBox"; // symbolCheckBox -e -manage $state "refreshRenderedCheckBox"; // symbolCheckBox -e -manage $state "activeOnlyCheckBox"; setParent $gDynPaintCanvasToolsToolbox; symbolCheckBox -e -manage (!$state) "autoSaveCheckBox"; symbolCheckBox -e -manage (!$state) "wrapHCheckBox"; symbolCheckBox -e -manage (!$state) "wrapVCheckBox"; } } global proc dynPaintRenderAll( string $editor ) { int $strokeRedraw = `dynPaintEditor -q -refreshMode $editor`; dynPaintEditor -edit -refreshMode 2 $editor; dynPaintEditor -edit -pa 0 $editor; dynPaintEditor -edit -refreshMode $strokeRedraw $editor; } global proc dynPaintToolbarConnectControls( string $tubes, string $color1, string $transparency1, string $tubesPerStep, string $color2, string $transparency2, string $leafColor1, string $leafColor2, string $petalColor1, string $petalColor2, string $budColor ) { string $defBrush = getDefaultBrush(); connectControl $tubes ( $defBrush + ".tubes" ); // C, T color sliders // attrColorSliderGrp -e -at ( $defBrush + ".color1" ) $color1; attrColorSliderGrp -e -at ( $defBrush + ".transparency1" ) $transparency1; // TS float field // attrFieldSliderGrp -e -at ( $defBrush + ".tubesPerStep" ) $tubesPerStep; // C2, T2 color sliders // attrColorSliderGrp -e -at ( $defBrush + ".color2" ) $color2; attrColorSliderGrp -e -at ( $defBrush + ".transparency2" ) $transparency2; // L1, L2 color boxes // attrColorSliderGrp -e -at ($defBrush+".leafColor1") $leafColor1; attrColorSliderGrp -e -at ($defBrush+".leafColor2") $leafColor2; // P1, P2 color boxes // attrColorSliderGrp -e -at ($defBrush+".petalColor1") $petalColor1; attrColorSliderGrp -e -at ($defBrush+".petalColor2") $petalColor2; // B color box // attrColorSliderGrp -e -at ($defBrush+".budColor") $budColor; // These enable/disable display of some of the above widgets // based on settings in the default brush. // scriptJob -parent $tubes -replacePrevious -attributeChange ($defBrush + ".tubes") setShowTubeTools; scriptJob -parent $leafColor1 -replacePrevious -attributeChange ($defBrush + ".leaves") setShowLeafTools; scriptJob -parent $petalColor1 -replacePrevious -attributeChange ($defBrush + ".flowers") setShowFlowerTools; scriptJob -parent $budColor -replacePrevious -attributeChange ($defBrush + ".buds") setShowBudTools; // The settings in the default brush have changed. Calling this // ensures we're displaying the right set of widgets for the // default brush. // setShowTubeTools(); } global proc string dynPaintToolbar( string $editor ) { global string $gDynPaintSceneToolsToolbox; global string $gDynPaintCanvasToolsToolbox; global string $gDynPaintTubeTools; global string $gDynPaintLeafTools; global string $gDynPaintFlowerTools; global string $gDynPaintBudTools; global string $gDynPaintToolbar; string $flipTubeButton; string $toolbar = `flowLayout -columnSpacing 1 "dptoolbar"`; $gDynPaintToolbar = $toolbar; symbolButton -image "clearCanvas.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kClearCanvasAnnot")) -command ("doCanvasClear(\"" + $editor + "\")") canvasClearButton; symbolButton -image "rvAllPlanes.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kDisplayRGBChannelsAnnot")) -command ("dynPaintEditor " + "-edit " + "-displayStyle \"color\" " + "-scaleRed 1 " + "-scaleGreen 1 " + "-scaleBlue 1 " + $editor ) allPlanesButton; symbolButton -image "rvMaskPlane.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kDisplayAlphaChannelAnnot")) -command ("dynPaintEditor " + "-edit " + "-displayStyle \"mask\" " + $editor ) maskButton; symbolButton -image "rvRealSize.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kDisplayPaintEffectsViewAnnot")) -command ("dynPaintEditor " + "-edit " + "-zoom 1 " + $editor) realSizeButton; separator -horizontal false -width 8 -height 28 -style "single"; symbolButton -image "savePaintSnapshot.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kSnapshotAnnot")) -command ("dynPaintSaveDialog(\"" + $editor + "\")") snapShotButton; separator -horizontal false -width 8 -height 28 -style "single"; symbolButton -image "templateBrushSettingsSmall.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kEditTemplateBrushAnnot")) -command "brushToolSettings" brushEditorButton; symbolButton -image "paintEffectsBrushes.png" -width 28 - height 28 -annotation (uiRes("m_dynPaintToolbar.kGetBrushAnnot")) -command "{ContentBrowserWindow;contentBrowserSetLocation(\"Examples/Paint Effects/Airbrush\");}" brushesButton; separator -horizontal false -width 8 -height 28 -style "single"; string $canvasTools = `formLayout "canvasTools"`; $gDynPaintCanvasToolsToolbox = $canvasTools; int $autoSave = `dynPaintEditor -q -autoSave $editor`; symbolCheckBox -v $autoSave -image "paintAutoSave.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kSaveCanvasAnnot")) -onc ("dynPaintSave " + $editor + ";toggleAutoSave " + $editor) -ofc ("toggleAutoSave " + $editor) autoSaveCheckBox; symbolCheckBox -image "paintWrapH.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kWrapCanvasHorizontallyAnnot")) wrapHCheckBox; // // Attach this check box to the Stroke Globals Horizontal Wrap // attribute. This will keep the attribute in sync with the // control and vise-versa. Bug #115364 - bwk 14jul99. // connectControl wrapHCheckBox strokeGlobals.wrapH; symbolCheckBox -image "paintWrapV.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kWrapCanvasVerticallyAnnot")) wrapVCheckBox; // // Attach this check box to the Stroke Globals Vertical Wrap // attribute. This will keep the attribute in sync with the // control and vise-versa. Bug #115364 - bwk 14jul99. // connectControl wrapVCheckBox strokeGlobals.wrapV; formLayout -edit -attachForm "autoSaveCheckBox" "left" 1 -attachNone "autoSaveCheckBox" "right" -attachForm "autoSaveCheckBox" "top" 1 -attachForm "autoSaveCheckBox" "bottom" 1 -attachControl "wrapHCheckBox" "left" 1 "autoSaveCheckBox" -attachNone "wrapHCheckBox" "right" -attachForm "wrapHCheckBox" "top" 1 -attachForm "wrapHCheckBox" "bottom" 1 -attachControl "wrapVCheckBox" "left" 1 "wrapHCheckBox" -attachNone "wrapVCheckBox" "right" -attachForm "wrapVCheckBox" "top" 1 $canvasTools; setParent ..; string $sceneTools = `formLayout "sceneTools"`; $gDynPaintSceneToolsToolbox = $sceneTools; symbolButton -image "redrawPaintEffects.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kRedrawPaintEffectsViewAnnot")) -command ("dynPaintRenderAll " + $editor) renderButton; int $activeRef = `dynPaintEditor -q -ao $editor`; // symbolCheckBox // -v $activeRef // -width 28 -height 28 // -annotation "Refresh only selected strokes." // -cc ("toggleActiveOnlyStrokeRefresh " + $editor) // activeOnlyCheckBox; // symbolCheckBox // -v false // -width 28 -height 28 // -annotation "Stroke Refresh Off" // -onc ("setStrokeRefreshMode 0 " + $editor) // refreshOffCheckBox; // symbolCheckBox // -v true // -width 28 -height 28 // -annotation "Wireframe Stroke Refresh" // -onc ("setStrokeRefreshMode 1 " + $editor) // refreshWireCheckBox; // symbolCheckBox // -v false // -width 28 -height 28 // -annotation "Rendered Stroke Refresh" // -onc ("setStrokeRefreshMode 2 " + $editor) // refreshRenderedCheckBox; formLayout -edit -attachForm "renderButton" "left" 1 -attachNone "renderButton" "right" -attachForm "renderButton" "top" 1 -attachForm "renderButton" "bottom" 1 // -attachControl "activeOnlyCheckBox" "left" 10 "renderButton" // -attachNone "activeOnlyCheckBox" "right" // -attachForm "activeOnlyCheckBox" "top" 1 // -attachControl "refreshOffCheckBox" "left" 10 "activeOnlyCheckBox" // -attachNone "refreshOffCheckBox" "right" // -attachForm "refreshOffCheckBox" "top" 1 // -attachControl "refreshWireCheckBox" "left" 1 "refreshOffCheckBox" // -attachNone "refreshWireCheckBox" "right" // -attachForm "refreshWireCheckBox" "top" 1 // -attachControl "refreshRenderedCheckBox" "left" 1 "refreshWireCheckBox" // -attachNone "refreshRenderedCheckBox" "right" // -attachForm "refreshRenderedCheckBox" "top" 1 $sceneTools; setParent ..; separator -horizontal false -width 8 -height 28 -style "single"; // Now define all the controls we want to connect to the // default brush. // string $tubeCheckBox = `symbolCheckBox -image "createTubes.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kMakeTubesAnnot")) -onc ("setAttr (getDefaultBrush() + \".tubes\") 1") -ofc ("setAttr (getDefaultBrush() + \".tubes\") 0") tubeCheckBox`; symbolButton -image "flipTubeSmall.png" -width 28 -height 28 -annotation (uiRes("m_dynPaintToolbar.kFlipTubeDirectionAnnot")) -command "changeTubeDirection" flipTubeButton; separator -horizontal false -width 8 -height 28 -style "single"; string $brushC1 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kColor1")) -annotation (uiRes("m_dynPaintToolbar.kColor1Annot")) -w 115 -h 28 -sb 0 -cw4 20 30 60 1 brushC1`; string $brushT1 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kTransparency1")) -annotation (uiRes("m_dynPaintToolbar.kTransparency1Annot")) -w 115 -h 28 -sb 0 -cw4 20 30 60 1 brushT1`; separator -horizontal true -width 5 -style "none"; string $tubeTools = `formLayout "tubeTools"`; $gDynPaintTubeTools = $tubeTools; string $brushTS = `attrFieldSliderGrp -label (uiRes("m_dynPaintToolbar.kTubesPerStep")) -annotation (uiRes("m_dynPaintToolbar.kTubesPerStepAnnot")) -pre 2 -h 28 -w 77 -cw4 28 50 60 1 brushTS`; string $brushC2 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kColor2")) -annotation (uiRes("m_dynPaintToolbar.kColor2Annot")) -w 121 -h 28 -sb 0 -cw4 28 30 60 1 brushC2`; string $brushT2 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kTransparency2")) -annotation (uiRes("m_dynPaintToolbar.kTransparency2Annot")) -w 121 -h 28 -sb 0 -cw4 28 30 60 1 brushT2`; string $leafTools = `formLayout "leafTools"`; $gDynPaintLeafTools = $leafTools; string $brushLC1 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kLeafColor1")) -annotation (uiRes("m_dynPaintToolbar.kLeafColor1Annot")) -w 58 -h 28 -sb 0 -cw4 28 30 60 1 brushLC1`; string $brushLC2 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kLeafColor2")) -annotation (uiRes("m_dynPaintToolbar.kLeafColor2Annot")) -w 58 -h 28 -sb 0 -cw4 28 30 60 1 brushLC2`; formLayout -edit -attachForm $brushLC1 "left" 1 -attachNone $brushLC1 "right" -attachForm $brushLC1 "top" 1 -attachForm $brushLC1 "bottom" 1 -attachControl $brushLC2 "left" 1 $brushLC1 -attachNone $brushLC2 "right" -attachForm $brushLC2 "top" 1 -attachForm $brushLC2 "bottom" 1 $leafTools; setParent..; string $flowerTools = `formLayout "flowerTools"`; $gDynPaintFlowerTools = $flowerTools; string $brushPC1 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kPetalColor1")) -annotation (uiRes("m_dynPaintToolbar.kPetalColor1Annot")) -w 58 -h 28 -sb 0 -cw4 28 30 60 1 brushPC1`; string $brushPC2 = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kPetalColor2")) -annotation (uiRes("m_dynPaintToolbar.kPetalColor2Annot")) -w 58 -h 28 -sb 0 -cw4 28 30 60 1 brushPC2`; formLayout -edit -attachForm $brushPC1 "left" 1 -attachNone $brushPC1 "right" -attachForm $brushPC1 "top" 1 -attachForm $brushPC1 "bottom" 1 -attachControl $brushPC2 "left" 1 $brushPC1 -attachNone $brushPC2 "right" -attachForm $brushPC2 "top" 1 -attachForm $brushPC2 "bottom" 1 $flowerTools; setParent..; string $budTools = `formLayout "budTools"`; $gDynPaintBudTools = $budTools; string $brushBC = `attrColorSliderGrp -label (uiRes("m_dynPaintToolbar.kBudColor")) -annotation (uiRes("m_dynPaintToolbar.kBudColorAnnot")) -w 55 -h 28 -sb 0 -cw4 25 30 60 1 brushBC`; formLayout -edit -attachForm $brushBC "left" 1 -attachNone $brushBC "right" -attachForm $brushBC "top" 1 -attachForm $brushBC "bottom" 1 $budTools; setParent..; formLayout -edit -attachForm $brushTS "left" 1 -attachNone $brushTS "right" -attachForm $brushTS "top" 1 -attachForm $brushTS "bottom" 1 -attachControl $brushC2 "left" 7 $brushTS -attachNone $brushC2 "right" -attachForm $brushC2 "top" 1 -attachForm $brushC2 "bottom" 1 -attachControl $brushT2 "left" 1 $brushC2 -attachNone $brushT2 "right" -attachForm $brushT2 "top" 1 -attachForm $brushT2 "bottom" 1 -attachControl $leafTools "left" 1 $brushT2 -attachNone $leafTools "right" -attachForm $leafTools "top" 0 -attachForm $leafTools "bottom" 0 -attachControl $flowerTools "left" 1 $leafTools -attachNone $flowerTools "right" -attachForm $flowerTools "top" 0 -attachForm $flowerTools "bottom" 0 -attachControl $budTools "left" 1 $flowerTools -attachNone $budTools "right" -attachForm $budTools "top" 0 -attachForm $budTools "bottom" 0 $tubeTools; setParent..; // Here is the list of all the controls that are to be // connected to the default brush. // string $controlsToConnect[] = { $tubeCheckBox, $brushC1, $brushT1, $brushTS, $brushC2, $brushT2, $brushLC1, $brushLC2, $brushPC1, $brushPC2, $brushBC }; // Can't concatenate a $string with a $string[] to create the // command we need to give to the script job. This creates // one string for the command. // string $reconnectCmd = "dynPaintToolbarConnectControls "; for( $connectThis in $controlsToConnect ) { $reconnectCmd = ( $reconnectCmd + $connectThis + " " ); } // Now connect up the toolbar controls to the attributes // on the default brush they need to listen to. // eval( $reconnectCmd ); // And since the default brush will be deleted on file->new, // the controls listed above will be disabled, since node // for which they were watching attributes no longer exists. // // We have to reconnect the controls to the "new" default // brush. // scriptJob -protected -parent $toolbar -event NewSceneOpened $reconnectCmd; scriptJob -protected -parent $toolbar -event SceneOpened $reconnectCmd; setParent ..; if( `dynPaintEditor -q -canvasMode $editor` ) { showDynPaintSceneTools( false ); } else { showDynPaintSceneTools( true ); } setShowTubeTools(); return( $toolbar ); }