Yury Apanasik
Yury Apanasik

Reputation: 113

Select/isolate in multimodel approach

In API reference described methods to select/isolate objects (in condition that only one model is loaded in viewer):

- select(dbids,selectionType)
- isolate(node)/isolateById(dbids) // that is the difference?

I know select analog for multimodel:

viewer.impl.selector.setSelection([objectIds], model);

Questions are:

  1. Is isolate analog for multimodel mode exists?
  2. How can I select/isolate two objects from diffrenent models at once?

Upvotes: 1

Views: 920

Answers (2)

Felipe
Felipe

Reputation: 4375

In the recent version of the API the viewer.impl.visibilityManager is returning a MultiModelVisibilityManager, so you can pass a model as second argument:

MultiModelVisibilityManager.prototype.isolate = function (node, model)

Take a look in viewer3D.js (L#17825) to see available methods on that object.

As far as I know there is no way to select two objects from different models in a single call, you would just issue one select call for each model passing respective ids. I don't see a problem with that.

Hope that helps.

Upvotes: 1

Eason Kang
Eason Kang

Reputation: 7080

For the isolate, you can do something like this(borrowed from the Viewer3D.js):

// Get selected elements from each loaded models
var selection = this.viewer.getAggregateSelection();
var allModels = this.viewer.impl.modelQueue().getModels().concat(); // shallow copy
// Isolate selected nodes. 
selection.forEach(function(singleRes){
    singleRes.model.visibilityManager.isolate(singleRes.selection);
    var indx = allModels.indexOf(singleRes.model);
    if (indx >= 0) {
        allModels.splice(indx, 1);
    }
});
// Hide nodes from all other models
while (allModels.length) {
    allModels.pop().visibilityManager.setAllVisibility(false);
}
this.viewer.clearSelection();

For the select, you need to pass corresponding model and dbIds to the viewer.impl.selector.setSelection([dbIds], model); and call setSelection for each set, such as below. It cannot be archived at once.

var selSet = [
    {
      selection: [1234, 5621],
      model: model1
    },
    {
      selection: [12, 758],
      model: model2
    },
];

selSet.forEach(funciton(sel) {
    viewer.impl.selector.setSelection(sel.selection, sel.model);
});

Upvotes: 0

Related Questions