LabelWidget Class Reference

The LabelWidget JavaScript class. A floating Label display widget. More...

Additional Inherited Members

- Public Slots inherited from WidgetBase
Attributedata (int index=0)
 
void updateProperties (QScriptValue properties)
 
- 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...
 

Detailed Description

The LabelWidget JavaScript class. A floating Label display widget.

This widget must be linked to a POSITION_2D attribute and a STRING attribute. This is a display widget, it has no manipulator. The label text is updated dynamically, following the attribute value..

The following properties are supported by the widget:

Property Type Default Value Description
data [Position2D,String] An array containing the Position 2D and the String Attribute
label String "text" Label text
label_color ColorRGBA 255,255,255,255 Label foreground (text) color.
label_bg_color ColorRGBA 0, 0, 0,128 Label background color. Accepts transparency values.
label_font String "Arial" Label font name.
label_size float 10.0 Label font size, in points.
label_pos Point2d Point2d(0,0) Label position, in fields.
label_justify String "Left" Horizontal label text alignment ("Left"/"Center").
label_screenspace bool true Forces the label size to remain constant relative to screen.
label_screenspace_offset Point2d Point2d(0,0) Label position offset, in screen space.

The following components constitute the widget:

Component Type
attribute [POSITION_2D,STRING]
drag_manipulator -
painter LABEL
picker -
local_transformation -

Create this widget to add a floating Master Controller in the camera view:

{
MessageLog.trace("\n\n\n");
MessageLog.trace(" ---------------------------------------------------------------------------");
MessageLog.trace("| Label Widget Test");
MessageLog.trace(" ---------------------------------------------------------------------------");
var posAttr = node.getAttr(Controller.node, frame.current(), "widget_pos");
var txtAttr = node.getAttr(Controller.node, frame.current(), "label");
var mcColor = node.getAttr(Controller.node, frame.current(), "widget_color").colorValueAt(frame.current());
var mcSize = node.getAttr(Controller.node, frame.current(), "widget_size").doubleValue();
var mcSliderLen = 3.0;
var val_label_screen_space = node.getAttr(Controller.node, frame.current(), "label_screen_space").boolValue();
var val_label_font = node.getAttr(Controller.node, frame.current(), "label_font").textValue();
var val_label_size = node.getAttr(Controller.node, frame.current(), "label_size").doubleValue();
var val_label_color = node.getAttr(Controller.node, frame.current(), "label_color").colorValueAt(frame.current());
var val_label_bg_color = node.getAttr(Controller.node, frame.current(), "label_bg_color").colorValueAt(frame.current());
var mcNameCapture = Controller.node;
var labelWidget = new LabelWidget(
{
data: [posAttr,txtAttr],
screen_space : false,
label : "myLabelText",
label_color : val_label_color,
label_bg_color : val_label_bg_color,
label_font : val_label_font,
label_size : val_label_size,
label_pos : Point2d(0,0),
label_justify : "Center",
label_screenspace : val_label_screen_space
} );
Controller.controls = [labelWidget];
MessageLog.trace("Done.");
}

Make sure to setup the Master Controller node specifications properly. e.g.

<attributes>
<attr type="2DPOSITION" name="widget_pos" value="0,0" tooltip="Master Controller text position."/>
<attr type="BOOL" name="label_screen_space" value="false" tooltip="Check this options for the label size to be in screen space."/>
<attr type="STRING" name="label" value="myLabelText" tooltip="Master Controller label."/>
<attr type="STRING" name="label_font" value="Arial " tooltip="Label font."/>
<attr type="DOUBLE" name="label_size" value="18.0" tooltip="Label font size, in points."/>
<attr type="COLOUR" name="label_color " value="255,255,255" tooltip="Label color."/>
<attr type="COLOUR" name="label_bg_color" value="0,0,0,128" tooltip="Label background color."/>
</attributes>