From 017c0ba8326428b0b084bb7eb818ffbd2dd4a482 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Sun, 3 Mar 2019 21:19:16 +0100 Subject: [PATCH] mol-plugin: structure interaction now persists any changes even if it's cleared --- .../structure-representation-interaction.ts | 12 +++++++++++- src/mol-plugin/state/transforms/model.ts | 1 + src/mol-state/state/selection.ts | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) 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 a64d05695..3631867ca 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 67b29a021..fd46f04fa 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 a01d5ab7e..ea4864933 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 }) { -- GitLab