molstar icon indicating copy to clipboard operation
molstar copied to clipboard

A question about how to hide/show some part of component?

Open xiaoxudoo opened this issue 1 year ago • 2 comments

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: image

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

xiaoxudoo avatar Jan 24 '24 14:01 xiaoxudoo

The easiest way would likely be subtracting the atom in question from the corresponding "structure component". Search the codebase for modifyByCurrentSelection link

Before: image

After: image

dsehnal avatar Jan 28 '24 04:01 dsehnal

@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;
        }
    }
});

xiaoxudoo avatar Feb 04 '24 13:02 xiaoxudoo