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

The TranslationYWidget JavaScript class. A translatable arrow in the y axis. More...


void valueChanged (float y)
 valueChanged signal called when the y translation value has been modified by the Transform tool. 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 TranslationYWidget JavaScript class. A translatable arrow in the y axis.

A translation along the y axis script widget. This widget offers an arrow manipulators that can be dragged in the Camera view while using the Transform tool. Dragging the arrow will generate a translation in the y axis. If no attribute is given at the construction of this object, the object will generate a double floating point attribute.

The following properties are supported by the widget:

Property Type Default Value Description
data String The name of the automatically generated double floating point attribute (if none is provided)
data Attribute An attribute of double (floating point) type that can be shared with another widget or node.
radius float 0.15 The radius of the base of the arrow manipulator in field.
length float 1.0 The lenght of the stick of the arrow manipulator in field.
color ColorRGBA green The colour of the arrow manipulator.
selection_color ColorRGBA light green The colour of the arrow manipulator when selected.

The following components constitute the widget:

Component Type
attribute DOUBLE
drag_manipulator TRANSLATION_Y
painter ARROW_Y
picker MONO
local_transformation TRANSLATION_Y

Connect to this scriptWidget valueChanged signal to be notified when a modification has been applied to the widget. In the callback function, transfer the widget value into an action (like modifying a peg attribute value).

var translationWidget = new TranslationYWidget(
data : "TranslationY",
min : 0.5,
width : 1,
color : ColorRGBA(155,0,0),
selection_color : ColorRGBA(255,0,0)
} );
// Set the widget initial value.;
// Register a callback for when a transformation tool value changes.
// Register the widget in the Controller

The previous example demonstrates how to instantiate a new widget and register it in the Controller global object.

var startPosition = new Point3d;
function getMCPosition()
return new Point3d(
node.getAttr(myController.node, frame.current(), "TranslationX").doubleValue(),
node.getAttr(myController.node, frame.current(), "TranslationY").doubleValue(),
node.getAttr(myController.node, frame.current(), "TranslationZ").doubleValue());
function translationDragStart(context)
// Save the position of the widget at the beginning of the drag.
startPosition = getMCPosition();
// Callback when the translation value has changed
function translationYChanged(newtransy)
// Apply an iterative translation to the peg.
var myPegPath = getPegPath();
// Get the difference between the previous translation and the current one.
var mcFieldModelPosition = getMCPosition(); // ASSERT(mcFieldModelPosition.y == newtransy);
var mcFieldModelTranslation = mcFieldModelPosition.minus(startPosition);
// Convert the translation from fields units to OGL units.
var mcModelTranslation = scene.toOGL(mcFieldModelTranslation);
// Apply the master controller parent node matrix to convert the translation
// from mc model OGL coordinates to world coordinates
var worldTranslation = getWorldVector3d(mcModelTranslation, myController.node);
// Convert the world coordinates translation into the peg model coordinates
var pegModelTranslation = getModelVector(worldTranslation, myPegPath);
// Convert the translation from OGL units back to field units
var fieldPegModelTranslation = scene.fromOGL(pegModelTranslation);
// Apply the translation to the peg position.
var positionAttributeName = "POSITION";
var isSeparate = node.getAttr(myPegPath, frame.current(), positionAttributeName + ".SEPARATE").boolValue();
var pegPosition = node.getAttr(myPegPath, frame.current(), positionAttributeName).pos3dValue().add(fieldPegModelTranslation);
positionAttributeName += ".3DPATH";
node.setTextAttr(myPegPath, positionAttributeName + ".X", frame.current(), pegPosition.x);
node.setTextAttr(myPegPath, positionAttributeName + ".Y", frame.current(), pegPosition.y);
node.setTextAttr(myPegPath, positionAttributeName + ".Z", frame.current(), pegPosition.z);
startPosition = mcFieldModelPosition;

This example shows how to apply the difference in translation of a translation widget on an arbitrary peg in the scene.

Member Function Documentation

void TranslationYWidget::valueChanged ( float  y)

valueChanged signal called when the y translation value has been modified by the Transform tool.

ythe new y translation value