All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Friends Modules Pages
Signals | List of all members
Rotation3dWidget Class Reference

The Rotation3dWidget JavaScript class. A rotatable spherical widget. More...


void valueChanged (QScriptValue &rotation)
 valueChanged signal called when the Rotation 3D attribute value has changed More...
- Signals inherited from WidgetBase
void dragStarted (QScriptValue dragContext)
 signal called on mouse down when picking this widget with the Transform tool More...
void drag (QScriptValue dragContext)
 signal called when this widget is dragged with the Transform tool More...
void dragEnded ()
 signal called on mouse up after having manipulated this widget with the Transform tool More...

Additional Inherited Members

- Public Slots inherited from WidgetBase
Attributedata (int index=0)

Detailed Description

The Rotation3dWidget JavaScript class. A rotatable spherical widget.

A 3 dimensional rotation script widget. This widget offers a 3D sphere manipulator that can dragged in the Camera view while using the Transform tool. Dragging the sphere generates a 3D rotation. If no attribute is given at the construction of this object, the object will generate a 3D rotation attribute.

The following properties are supported by the widget:

Property Type Default Value Description
data String The name of the automatically generated 3D rotation attribute (if none is provided)
data Attribute An attribute of 3D rotation type that can be shared with another widget or node.
radius float 1 The radius of the 3D sphere in field.
color ColorRGBA 255, 0, 0, 120 The colour of the sphere manipulator.
selection_color ColorRGBA 255, 0, 0, 180 The colour of the sphere manipulator when selected.

The following components constitute the widget:

Component Type
attribute ROTATION_3D
drag_manipulator ROTATION_3D
painter SPHERE
picker MONO
local_transformation ROTATION_3D

Connect to this scriptWidget valueChanged signal to be notified when a modification has been applied to the widget.

var myRotation3dWidget = new Rotation3dWidget(
data : "Rotation3D",
radius : 2,
color : ColorRGBA(0,255,0, 120),
selected_color : ColorRGBA(0,255,0, 120)
} );
// Register a callback for when a transformation tool value changes.
myRotation3dWidget.valueChanged.connect( my3dRotationChangedFunction );

In the callback function, convert the widget value into an action (like modifying a peg attribute value).

function my3dRotationChangedFunction(newRotation)
// Create a rotation matrix based on the 3D rotation of the widget.
var xaxis = new Vector3d( 1,0,0 );
var yaxis = new Vector3d( 0,1,0 );
var zaxis = new Vector3d( 0,0,1 );
var rotationMatrix = new Matrix4x4();
rotationMatrix.rotateDegrees( newRotation.x, xaxis );
rotationMatrix.rotateDegrees( newRotation.y, yaxis );
rotationMatrix.rotateDegrees( newRotation.z, zaxis );
// Rotate the original position of a series of pegs
for(var i=0; i < myPegs.length; ++i)
var newPosition = rotationMatrix.multiply(myPegs[i].position);
node.setTextAttr(myPegs[i].path, "POSITION.X", frame.current(), newPosition.x);
node.setTextAttr(myPegs[i].path, "POSITION.Y", frame.current(), newPosition.y);
node.setTextAttr(myPegs[i].path, "POSITION.Z", frame.current(), newPosition.z);

Member Function Documentation

void Rotation3dWidget::valueChanged ( QScriptValue &  rotation)

valueChanged signal called when the Rotation 3D attribute value has changed

rotationThe new 3D rotation value. To retrieve the rotation per individual axis, get the following properties: rotation.x rotation.y rotation.z