global proc js_attrDragger () { if (!`draggerContext -exists js_attrDraggerContext`) { draggerContext js_attrDraggerContext; } draggerContext -e -pressCommand ("js_attrDraggerPress; ") // turn off undo -dragCommand "js_attrDraggerDrag" -releaseCommand ("js_attrDraggerRelease") // turn on undo -finalize "js_attrDraggerFinalize" -initialize "js_attrDraggerInitialize" -undoMode "sequence" -cursor "hand" js_attrDraggerContext; } global proc js_attrDraggerInitialize () { global string $gAttrDragObjects[]; clear $gAttrDragObjects; if (`popupMenu -exists testtMM`) { deleteUI -menu testtMM; } popupMenu -b 1 -p viewPanes testtMM; $gAttrDragObjects = `ls -sl`; // this is going to be a hack just to modify the attribute for one object for now string $attrs[]; $attrs = `js_returnMatchingAttrs $gAttrDragObjects`; for ($item in $attrs) { if (`getAttr -type ($gAttrDragObjects[0] + "." + $item)` != "bool") menuItem -label $item -c ("js_setDragAttr " + $item); } menuItem -d 1; menuItem -l "Options.." -c "js_setDragAttrOptions"; setParent -m ..; } global proc js_setDragAttrOptions () { // There are some options which should be set for js_setDragAttr // // ctrl: fine/large/snap // shift: fine/large/snap // snap: on/off (only if neither ctrl or shift are set to snap) // increment: float // fineIncrement: float // largeIncrement: float // attrDisplay: all-keyable/noTRS // // Defaults: // // ctrl: fine // shift: snap // snap: off // increment: .1 // fineIncrement: .01 // largeIncrement: 1 // attrDisplay: noTRS // // create the window string $win = "js_setDragAttrOptions"; if (`window -exists $win`) deleteUI $win; string $js_dragAttrCtrl = "js_dragAttrCtrlRB"; string $js_dragAttrShift = "js_dragAttrShiftRB"; string $js_dragAttrSnap = "js_dragAttrShiftCheckBox"; string $js_dragAttrIncr = "js_dragAttrIncrFloat"; string $js_dragAttrFineIncr = "js_dragAttrFineIncrFloat"; string $js_dragAttrLgeIncr = "js_dragAttrLgeIncrFloat"; string $js_dragAttrDisplay = "js_dragAttrDisplayRB"; string $js_dragAttrClose = "js_dragAttrCloseB"; string $js_dragAttrDefault = "js_dragAttrDefaultB"; window -title "Drag Attribute Options" $win; $f = `formLayout -nd 100`; $js_manipFrameLayout = `frameLayout -label "Manipulator Options" -labelAlign "center" -borderStyle "etchedIn" -cll false`; columnLayout; $js_dragAttrCtrl = `radioButtonGrp -numberOfRadioButtons 3 -label "CTRL Manipulator:" -labelArray3 "fine" "large" "snap" $js_dragAttrCtrl`; $js_dragAttrShift = `radioButtonGrp -numberOfRadioButtons 3 -label "SHIFT Manipulator:" -labelArray3 "fine" "large" "snap" $js_dragAttrShift`; setParent $f; $js_incFrameLayout = `frameLayout -label "Increment Options" -labelAlign "center" -borderStyle "etchedIn" -cll false`; columnLayout; $js_dragAttrSnap = `checkBoxGrp -numberOfCheckBoxes 1 -label "Snap:" -label1 "On/Off" $js_dragAttrSnap`; $js_dragAttrIncr = `floatFieldGrp -numberOfFields 1 -label "Drag Increment:" -pre 3 $js_dragAttrIncr`; $js_dragAttrFineIncr= `floatFieldGrp -numberOfFields 1 -label "Fine Increment:" -pre 3 $js_dragAttrFineIncr`; $js_dragAttrLgeIncr = `floatFieldGrp -numberOfFields 1 -label "Large Increment:" -pre 3 $js_dragAttrLgeIncr`; setParent $f; $js_dispFrameLayout = `frameLayout -label "Display Options" -labelAlign "center" -borderStyle "etchedIn" -cll false`; columnLayout; $js_dragAttrDisplay = `radioButtonGrp -numberOfRadioButtons 2 -label "Display Attributes:" -labelArray2 "All Keyable" "Extra" $js_dragAttrDisplay`; setParent $f; $js_dragAttrDefault = `button -label "Defaults" $js_dragAttrDefault`; $js_dragAttrClose = `button -label "Close" $js_dragAttrClose`; formLayout -e -af $js_manipFrameLayout top 5 -af $js_manipFrameLayout left 5 -af $js_manipFrameLayout right 5 -ac $js_incFrameLayout top 5 $js_manipFrameLayout -af $js_incFrameLayout left 5 -af $js_incFrameLayout right 5 -ac $js_dispFrameLayout top 5 $js_incFrameLayout -af $js_dispFrameLayout left 5 -af $js_dispFrameLayout right 5 -af $js_dragAttrDefault left 5 -ap $js_dragAttrDefault right 0 45 -af $js_dragAttrDefault bottom 5 -af $js_dragAttrClose right 5 -ap $js_dragAttrClose left 0 55 -af $js_dragAttrClose bottom 5 $f; showWindow $win; js_setDragAttrCallbacks $win; js_setDragAttrStoredValues; } global proc js_setDragAttrCallbacks ( string $win ) { string $js_dragAttrCtrl = "js_dragAttrCtrlRB"; string $js_dragAttrShift = "js_dragAttrShiftRB"; string $js_dragAttrSnap = "js_dragAttrShiftCheckBox"; string $js_dragAttrIncr = "js_dragAttrIncrFloat"; string $js_dragAttrFineIncr = "js_dragAttrFineIncrFloat"; string $js_dragAttrLgeIncr = "js_dragAttrLgeIncrFloat"; string $js_dragAttrDisplay = "js_dragAttrDisplayRB"; string $js_dragAttrClose = "js_dragAttrCloseB"; string $js_dragAttrDefault = "js_dragAttrDefaultB"; radioButtonGrp -e -on ("js_dragRBCtrlSet") $js_dragAttrCtrl; } global proc js_dragRBCtrlSet () { string $js_dragAttrCtrl = "js_dragAttrCtrlRB"; string $js_dragAttrShift = "js_dragAttrShiftRB"; string $js_dragAttrSnap = "js_dragAttrShiftCheckBox"; // get the current value of the ctrl rb $ctrl = `radioButtonGrp -q -v $js_dragAttrCtrl`; $shift = `radioButtonGrp -q -v $js_dragAttrShift`; } global proc js_setDragStoredValues () { // grabs the saved optionVars and applies them } global proc string[] js_returnMatchingAttrs (string $objs[]) { // This procedure looks at all the objects and returns the matching keyable attributes string $item; string $attributes[0]; int $count; for ($item in $objs) { string $keyableAttrs[]; $keyableAttrs = `listAttr -k $item`; appendStringArray ($attributes, $keyableAttrs, (`size $keyableAttrs`)); } $attributes = stringArrayRemoveDuplicates($attributes); return $attributes; } global proc js_setDragAttr ( string $attr ) { global string $gAttrDrag; $gAttrDrag = $attr; } global proc js_attrDraggerPress () { global string $gAttrDrag; global string $gObjectDrag; global float $gAttrValues[]; global string $gAttrDragObjects[]; int $count; float $position[] = `draggerContext -query -anchorPoint js_attrDraggerContext`; // last coordinates of the mouse global float $gAttrDragLastPosition[]; // Coordinates of the mouse when the press happened global float $gAttrDragAnchor[]; $gAttrDragAnchor = `draggerContext -q -anchorPoint js_attrDraggerContext`; for ($count = 0; $count < size($gAttrDragObjects); $count++) { $gAttrValues[$count] = `getAttr ($gAttrDragObjects[$count] + "." + $gAttrDrag)`; } $gAttrDragLastPosition = $position; // record the position for the undo queue for ($obj in $gAttrDragObjects) { setAttr ($obj + "." + $gAttrDrag) `getAttr ($obj + "." + $gAttrDrag)`; } } global proc js_attrDraggerRelease () { global string $gAttrDrag; global string $gAttrDragObjects[]; // initialize the value // record the position for the undo queue for ($obj in $gAttrDragObjects) { setAttr ($obj + "." + $gAttrDrag) `getAttr ($obj + "." + $gAttrDrag)`; } } global proc js_attrDraggerFinalize () { if (`popupMenu -exists testtMM`) deleteUI -menu testtMM; global string $gAttrDrag; global string $gAttrDragObjects[]; global float $gAttrValues[]; $gAttrDrag = ""; clear $gAttrDragObjects; clear $gAttrValues; } global proc js_attrDraggerDrag() { float $position[] = `draggerContext -q -dragPoint js_attrDraggerContext`; int $button = `draggerContext -q -button js_attrDraggerContext`; string $modifier = `draggerContext -q -modifier js_attrDraggerContext`; int $refresh = false; // these values represent the amount by which the attribute will move float $smallStep = .1; float $bigStep = 5; float $stepValue = .1; if ($modifier == "ctrl") { $stepValue = $stepValue * $smallStep; } global float $gAttrDragLastPosition[]; global float $gAttrDragAnchor[]; global float $gAttrValues[]; global string $gAttrDrag; global string $gAttrDragObjects[]; int $count; if (2==$button) { float $dy = $position[1] - $gAttrDragAnchor[1]; float $dx = $position[0] - $gAttrDragAnchor[0]; for ($count = 0; $count< size($gAttrDragObjects); $count++) { float $newValue = $gAttrValues[$count]; $newValue = $newValue +(($dy + $dx) * $stepValue); if ($modifier == "shift") $newValue = int($newValue); setAttr ($gAttrDragObjects[$count] + "." + $gAttrDrag) $newValue; } $refresh = true; } $gAttrDragLastPosition = $position; if ($refresh) refresh -currentView; }