molstar
molstar copied to clipboard
A question about how to hide/show some part of component?
Hi,everyone:
I have a case about hide/show some part of component(ligand)?and I have read this issue:#970
But it has some flaw,the effect picture is like this:
it only hide the element spheres and the cylinders belongs to the elements(so some bond left half),but I want to hide the bonds linked to the elements which they'll hide.
how can I make that? thank advance! @arose @dsehnal
The easiest way would likely be subtracting the atom in question from the corresponding "structure component". Search the codebase for modifyByCurrentSelection
link
Before:
After:
@dsehnal yep,I have try the method modifyByCurrentSelection
,but I don‘t know how to add them back(we need toggle the selected atoms in ligand)。At last,I have to fork the repo, and modify the code in apply transparency to any loci.
I'm worrying about its side effect...
// mol-repr/structure/visual/util/bond.ts
OrderedSet.forEach(e.indices, v => {
for (let t = offset[v], _t = offset[v + 1]; t < _t; t++) {
if (!isMarking || OrderedSet.has(e.indices, b[t])) {
const idx = unit.bonds.getDirectedEdgeIndex(b[t], unit.bonds?.a[t]);
// origin: apply(Interval.ofSingleton(unitIdx * groupCount + t))
if (apply(Interval.ofSingleton(unitIdx * groupCount + t), Interval.ofSingleton(unitIdx * groupCount + idx))) changed = true;
}
}
});