selection Class Reference

The selection JavaScript global object. Retrieve information about the nodes or columns that are selected. More...

Public Slots

int numberOfNodesSelected ()
 Returns the number of nodes that are selected. More...
 
String selectedNode (int i)
 Returns the path of the selected node. More...
 
String selectedWaypoint (int i)
 Returns the path of the selected waypoint. More...
 
int numberOfColumnsSelected ()
 Returns a value for the number of columns selected in the xsheet. More...
 
String selectedColumn (int i)
 Returns the ith column selected in the xsheet. More...
 
bool clearSelection ()
 Clears the selection. More...
 
bool addNodeToSelection (String node)
 Adds a node to the selection. More...
 
void addNodesToSelection (QScriptValue &nodes)
 Adds an array of nodes to the selection. More...
 
bool removeNodeFromSelection (String &node)
 Removes a node from the selection. More...
 
bool addBackdropToSelection (QScriptValue &backdrop)
 Adds a backdrop to the selection. More...
 
bool removeBackdropFromSelection (QScriptValue &backdrop)
 Removes a backdrop to the selection. More...
 
bool addBackdropToSelection (String &groupPath, uint idx)
 Adds a backdrop to the selection. More...
 
bool removeBackdropFromSelection (String &groupPath, uint idx)
 Removes a backdrop to the selection. More...
 
bool addWaypointToSelection (String waypoint)
 Add a waypoint to the selection. More...
 
bool removeWaypointFromSelection (String waypoint)
 Remove a waypoint from the selection. More...
 
bool addColumnToSelection (String column)
 Add a column to the selection. More...
 
bool addDrawingColumnToSelection (String columnName)
 Adds the drawing column and it's associated read node to the selection. More...
 
bool extendSelectionWithColumn (String columnName)
 Adds the column to the selection. If the column is a drawing column, also adds the associated read node to the selection. More...
 
void setSelectionFrameRange (int start, int length)
 Sets the selection frame range. More...
 
bool isSelectionRange ()
 Returns true if the selection has a range. More...
 
int startFrame ()
 Returns the selected start frame. More...
 
int numberOfFrames ()
 Returns the number of selected frames. More...
 
void selectAll ()
 Selects all nodes and all columns in the scene. More...
 
QScriptValue selectedNodes ()
 Returns an Array of all selected nodes. More...
 
QScriptValue selectedWaypoints ()
 Returns an Array of all selected waypoints. More...
 
QScriptValue selectedBackdrops ()
 Returns an Array of all selected backdrops. More...
 
Sub selection
QScriptValue subSelectionForNode (String &node)
 Obtains the IDs of the selectable sub objects of the given node. More...
 
bool addSubSelectionForNode (String &node, QScriptValue &subSelection)
 Selects/deselects a set of IDs from the sub selection. More...
 
bool clearSubSelectionForNode (String &node)
 Clears all the sub selection on the given node. More...
 
QObject attributeFromSubSelectionId (String &node, int subSelectionId)
 Get the Attribute associated to the given sub selection id of the given node. More...
 
int subSelectionIdFromAttribute (QScriptValue &attribute)
 Get the sub selection id corresponding to the given Attribute object. More...
 

Detailed Description

The selection JavaScript global object. Retrieve information about the nodes or columns that are selected.

function dumpSelectedColumn()
{
// The numberOfColumnsSelected function loops to check all of the selected columns and determine their frame values.
// The selectedColumn function prints the name of the selected column to the shell and
// then loops through the values in the column to print them as well.
var nframe = frame.numberOf();
var i;
for (i = 0; i < ncol; ++i)
{
var f;
MessageLog.trace("Column " + c);
for (f = 1; f <= nframe; ++f)
{
var value = column.getEntry(c, 1, f);
var keyframe = column.isKeyFrame(c, 1, f);
if (keyframe) value += " (keyframe)";
MessageLog.trace(" " + f + ": " + value);
}
}
}

Member Function Documentation

◆ addBackdropToSelection [1/2]

bool selection::addBackdropToSelection ( QScriptValue &  backdrop)
slot

Adds a backdrop to the selection.

If multiple backdrops of a given group share the same title, all of them will be added to the selection.

Parameters
backdrop: The backdrop object provided from Backdrop.backdrops( groupPath )
Returns
Returns whether backdrop was located and successfully added to the selection.

◆ addBackdropToSelection [2/2]

bool selection::addBackdropToSelection ( String &  groupPath,
uint  idx 
)
slot

Adds a backdrop to the selection.

If multiple backdrops of a given group share the same title, all of them will be added to the selection.

Parameters
group: The group in which the backdrop is contained.
idx: The index of the backdrop in the group.
Returns
Returns whether backdrop was located and successfully added to the selection.

◆ addColumnToSelection

bool selection::addColumnToSelection ( String  column)
slot

Add a column to the selection.

returns whether columns was located and successfully added to the selection

Parameters
columnname of column

◆ addDrawingColumnToSelection

bool selection::addDrawingColumnToSelection ( String  columnName)
slot

Adds the drawing column and it's associated read node to the selection.

Parameters
columnName: The displayed name of column.
Returns
Returns true if the drawing column and associated read node are added to the selection.

◆ addNodesToSelection

void selection::addNodesToSelection ( QScriptValue &  nodes)
slot

Adds an array of nodes to the selection.

Parameters
nodes: An array containing the qualified name of nodes to be selected.

◆ addNodeToSelection

bool selection::addNodeToSelection ( String  node)
slot

Adds a node to the selection.

Parameters
node: The name of node to add to the selection.
Returns
Returns whether node was located and successfully added to the selection.

◆ addSubSelectionForNode

bool selection::addSubSelectionForNode ( String &  node,
QScriptValue &  subSelection 
)
slot

Selects/deselects a set of IDs from the sub selection.

Select a set of sub objects. If the sub object is already selected, this method will deselect it.

// Load a previous selection from a JSON file.
var mySelectionFile = System.getenv("TEMP") + "/myHarmonySelection_001.json";
var myFile = new PermanentFile(mySelectionFile);
myFile.open(1);
var jsonFileContent = myFile.read();
myFile.close();
// Restore the read selection in Harmony.
var newSelection = JSON.parse(jsonFileContent);
selection.addNodeToSelection(newSelection.node);
selection.addSubSelectionForNode(newSelection.node, newSelection.subobjects);
Parameters
node: The path to the node (ex: "Top/MyNode").
subSelection: An array of sub object IDs or the id (integer) of one sub object.
Returns
Returns true if successful.

◆ addWaypointToSelection

bool selection::addWaypointToSelection ( String  waypoint)
slot

Add a waypoint to the selection.

returns whether waypoint was located and successfully added to the selection

Parameters
waypointqualified name of waypoint

◆ attributeFromSubSelectionId

QObject selection::attributeFromSubSelectionId ( String &  node,
int  subSelectionId 
)
slot

Get the Attribute associated to the given sub selection id of the given node.

if(selectedNode == "")
return;
// Remove the selected attribute from the node
for(var i=0; i<subSelection.length; ++i)
{
var attribute = selection.attributeFromSubSelectionId(selectedNode, subSelection[i]);
MessageLog.trace("Removing " + attribute.name() + " " + attribute.fullKeyword());
node.removeDynamicAttr(selectedNode, attribute.fullKeyword());
}
Parameters
node: The node owning the desired attribute.
subSelectionId: The sub selection id associated to the attribute.
Returns
The Attribute corresponding to the given subSelectionId. An empty Attribute if the node wasn't selected of if no attribute is linked to the given subSectionId.

◆ clearSelection

bool selection::clearSelection ( )
slot

Clears the selection.

Returns
Returns true if successful.

◆ clearSubSelectionForNode

bool selection::clearSubSelectionForNode ( String &  node)
slot

Clears all the sub selection on the given node.

selection.clearSubSelectionForNode("Top/My-Subnode-Animation");
Parameters
node: The path to the node (ex: "Top/MyNode").
Returns
Returns true if the sub selection was cleared, false if the node path was invalid or if the node wasn't selected.

◆ extendSelectionWithColumn

bool selection::extendSelectionWithColumn ( String  columnName)
slot

Adds the column to the selection. If the column is a drawing column, also adds the associated read node to the selection.

Parameters
columnName: The displayed name of column.
Returns
Returns true if the column was successfully added to the selection.

◆ isSelectionRange

bool selection::isSelectionRange ( )
slot

Returns true if the selection has a range.

Returns
Returns true if the selection has a range.

◆ numberOfColumnsSelected

int selection::numberOfColumnsSelected ( )
slot

Returns a value for the number of columns selected in the xsheet.

Returns
Returns a value for the number of columns selected in the xsheet.

◆ numberOfFrames

int selection::numberOfFrames ( )
slot

Returns the number of selected frames.

Returns
Returns the number of selected frames.

◆ numberOfNodesSelected

int selection::numberOfNodesSelected ( )
slot

Returns the number of nodes that are selected.

Returns
Returns the number of nodes that are selected.

◆ removeBackdropFromSelection [1/2]

bool selection::removeBackdropFromSelection ( QScriptValue &  backdrop)
slot

Removes a backdrop to the selection.

If multiple backdrops of a given group share the same title, all of them will be removed from the selection.

Parameters
backdrop: The backdrop object provided from Backdrop.backdrops( groupPath )
Returns
Returns whether backdrop was located and successfully removed to the selection.

◆ removeBackdropFromSelection [2/2]

bool selection::removeBackdropFromSelection ( String &  groupPath,
uint  idx 
)
slot

Removes a backdrop to the selection.

If multiple backdrops of a given group share the same title, all of them will be removed from the selection.

Parameters
group: The group in which the backdrop is contained.
idx: The index of the backdrop in the group.
Returns
Returns whether backdrop was located and successfully removed to the selection.

◆ removeNodeFromSelection

bool selection::removeNodeFromSelection ( String &  node)
slot

Removes a node from the selection.

Parameters
node: The name of node to be removed from the selection.
Returns
Returns whether node was located and successfully removed from the selection.

◆ removeWaypointFromSelection

bool selection::removeWaypointFromSelection ( String  waypoint)
slot

Remove a waypoint from the selection.

returns whether waypoint was located and successfully removed from the selection

Parameters
waypointqualified name of waypoint

◆ selectAll

void selection::selectAll ( )
slot

Selects all nodes and all columns in the scene.

◆ selectedBackdrops

QScriptValue selection::selectedBackdrops ( )
slot

Returns an Array of all selected backdrops.

Returns
Returns an Array of all selected backdrops.

◆ selectedColumn

String selection::selectedColumn ( int  i)
slot

Returns the ith column selected in the xsheet.

Parameters
i: The index of the column.
Returns
Returns the ith column selected in the xsheet.

◆ selectedNode

String selection::selectedNode ( int  i)
slot

Returns the path of the selected node.

Parameters
i: The index of the node.
Returns
Returns the path of the selected node.

◆ selectedNodes

QScriptValue selection::selectedNodes ( )
slot

Returns an Array of all selected nodes.

Returns
Returns an Array of all selected nodes.

◆ selectedWaypoint

String selection::selectedWaypoint ( int  i)
slot

Returns the path of the selected waypoint.

Parameters
i: The index of the waypoint.
Returns
Returns the path of the selected waypoint.

◆ selectedWaypoints

QScriptValue selection::selectedWaypoints ( )
slot

Returns an Array of all selected waypoints.

Returns
Returns an Array of all selected waypoints.

◆ setSelectionFrameRange

void selection::setSelectionFrameRange ( int  start,
int  length 
)
slot

Sets the selection frame range.

Parameters
start: The beginning frame.
length: The number of frames selected.

◆ startFrame

int selection::startFrame ( )
slot

Returns the selected start frame.

Returns
Returns the selected start frame.

◆ subSelectionForNode

QScriptValue selection::subSelectionForNode ( String &  node)
slot

Obtains the IDs of the selectable sub objects of the given node.

// Get the current selection and save it in a JSON file.
var selectedNodeCount = selection.numberOfNodesSelected();
if(selectedNodeCount != 1)
return;
var newSelection = new Object;
newSelection.node = selection.selectedNode(0);
newSelection.subobjects = selection.subSelectionForNode(newSelection.node);
// Save the javascript object containing the selection information in a JSON file in the temp folder.
var mySelectionFile = System.getenv("TEMP") + "/myHarmonySelection_001.json";
var myFile = new PermanentFile(mySelectionFile);
myFile.open(2);
myFile.write(JSON.stringify(newSelection));
myFile.close();
Parameters
node: The path to the node (ex: "Top/MyNode").
Returns
Returns an Array containing the IDs of the selected node.

◆ subSelectionIdFromAttribute

int selection::subSelectionIdFromAttribute ( QScriptValue &  attribute)
slot

Get the sub selection id corresponding to the given Attribute object.

The attribute has to be selectable. By example, the subnode animation module's subnode transformation attributes.

Note
The parent node of the attribute needs to be selected.
if(selectedNode == "" || node.type(selectedNode) != "SubNodeAnimation")
return;
var attributeType = "SUB_NODE_TRANSFORMATION";
var attributeName = "my_subnode_Key";
var linkable = false; // not used
node.createDynamicAttr(selectedNode, attributeType, attributeName, attributeName, linkable);
var nameAttribute = node.getAttr(selectedNode, frame.current, attributeName + ".NODE_NAME");
nameAttribute.setValue(attributeName);
var addedAttribute = node.getAttr(selectedNode, frame.current(), attributeName);
var attributeSelectionId = selection.subSelectionIdFromAttribute(addedAttribute);
var subSelectionIdArray = [];
subSelectionIdArray[0] = attributeSelectionId;
MessageLog.trace("Added attribute " + addedAttribute.name() + " with sub selection id: " + attributeSelectionId);
Parameters
attribute: An Attribute of a selected node.
Returns
Returns the sub selection id corresponding to the attribute.