comp.addRepresentation does not respect defaultAssembly param?
hi,
This issue is originally from nglview (https://github.com/arose/nglview/issues/802#issuecomment-492709317).
I am giving brief information (let me know if you need further information or code).
Basically I want to set repr from a given params ("assembly": "default", "defaultAssembly": "BU1")
via component.addRepresentation:
{"type": "cartoon", "params": {"lazy": false, "visible": true, "quality": "medium", "aspectRatio": 5, "subdiv": 6, "radialSegments": 10, "tension": null, "capped": true, "smoothSheet": false, "radiusType": "sstruc", "radiusData": {}, "radiusSize": 1, "radiusScale": 0.7, "assembly": "default", "defaultAssembly": "BU1", "clipNear": 0, "clipRadius": 0, "clipCenter": {"x": 0, "y": 0, "z": 0}, "flatShaded": false, "opacity": 1, "depthWrite": true, "side": "double", "wireframe": false, "colorScheme": "chainname", "colorScale": "RdYlBu", "colorReverse": false, "colorValue": 9474192, "colorMode": "hcl", "roughness": 0.4, "metalness": 0, "diffuse": 16777215, "diffuseInterior": false, "useInteriorColor": true, "interiorColor": 2236962, "interiorDarkening": 0, "matrix": {"elements": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, "disablePicking": false, "sele": "all"}}
However, the output defaultAssembly is changed, it is set to empty string. Is this intention? thanks and cheers.
defaultAssembly is a hidden/internal parameter you don't set it directly but via StructureComponent params or .setDefaultAssembly
thanks for the explanation. It's kind of inconvenient for nglview's serialization in this case though.
Saying
params = repr.repr.getParameters();
[delete all old representations in `repr`]
repr.setParameters(params) // can not restore the previous representations.
Here is the nglview's code https://github.com/arose/nglview/blob/f45da9c8e1d63af879a5903d38843a49d42d14e8/js/src/widget_ngl.js#L470-L485
_set_representation_from_backend: function(compList){
if (compList.length > 0){
var ngl_repr_dict = this.model.get('_ngl_repr_dict');
for (var index in ngl_repr_dict){
var comp = compList[index];
comp.removeAllRepresentations();
var reprlist = ngl_repr_dict[index];
for (var j in reprlist){
var repr = reprlist[j];
if (repr){
comp.addRepresentation(repr.type, repr.params);
}
}
}
}
},