diff --git a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts b/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts index a64d056956ac09a08f6437fdee45b3fbf14fa30d..3631867ca296a2933f2f587f2361336312022cef 100644 --- a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts +++ b/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts @@ -90,7 +90,17 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W if (groups.length === 0) return; const update = state.build(); - for (const g of groups) update.delete(g.transform.ref); + const query = MS.struct.generator.empty(); + for (const g of groups) { + // TODO: update props of the group node to ghost + + const res = StateSelection.findTagInSubtree(state.tree, g.transform.ref, Tags.ResidueSel); + const surr = StateSelection.findTagInSubtree(state.tree, g.transform.ref, Tags.SurrSel); + if (res) update.to(res).update(StateTransforms.Model.StructureSelection, old => ({ ...old, query })); + if (surr) update.to(surr).update(StateTransforms.Model.StructureSelection, old => ({ ...old, query })); + + // update.delete(g.transform.ref); + } PluginCommands.State.Update.dispatch(this.plugin, { state, tree: update, options: { doNotLogTiming: true, doNotUpdateCurrent: true } }); } diff --git a/src/mol-plugin/state/transforms/model.ts b/src/mol-plugin/state/transforms/model.ts index 67b29a021bed9c2c5aa0dbf50d4f1fd0b2c0e1bb..fd46f04fad369b6cb8eee92d9eb65d9b268f0069 100644 --- a/src/mol-plugin/state/transforms/model.ts +++ b/src/mol-plugin/state/transforms/model.ts @@ -237,6 +237,7 @@ const StructureSelection = PluginStateTransform.BuiltIn({ const compiled = compile<Sel>(params.query); const result = compiled(new QueryContext(a.data)); const s = Sel.unionStructure(result); + if (s.elementCount === 0) return StateObject.Null; const props = { label: `${params.label || 'Selection'}`, description: structureDesc(s) }; return new SO.Molecule.Structure(s, props); } diff --git a/src/mol-state/state/selection.ts b/src/mol-state/state/selection.ts index a01d5ab7e08815dd40af73dba379c2d7314cfe23..ea4864933ee1bd84f45b06fb6d0fdb54b4213634 100644 --- a/src/mol-state/state/selection.ts +++ b/src/mol-state/state/selection.ts @@ -254,7 +254,7 @@ namespace StateSelection { } export function findTagInSubtree(tree: StateTree, root: StateTransform.Ref, tag: string): StateTransform.Ref | undefined { - return StateTree.doPreOrder(tree, tree.transforms.get(root), { ref: void 0, tag }, _findTagInSubtree).tag; + return StateTree.doPreOrder(tree, tree.transforms.get(root), { ref: void 0, tag }, _findTagInSubtree).ref; } function _findTagInSubtree(n: StateTransform, _: any, s: { ref: string | undefined, tag: string }) {