Language: JavaScript
The method setSelectionFilter is useful for leveraging the selection operation to get list of selected nodes and then being able to apply functions from the Model class.
Below is a very rudimentary example where the function sets the visibility to off for selected nodes with even-numbered node ids. To best illustrate the function, use the area selection operator to select multiple model nodes
function mySelectionFilter(node, model) {
if (node%2 == 0) {
//console.log("nodeid: " + node);
model.setNodesVisibility([node], false);
}
}
var sm = hwv.selectionManager;
sm.setSelectionFilter(mySelectionFilter);
It’s worth noting that a selection operation is not actually made when using setSelectionFilter
. To check, run the following:
sm.getResults();
Notice the returned array is empty. To get back to the original behavior of the selection operator, call:
sm.setSelectionFilter(null);