Skip to content
Snippets Groups Projects
Commit 017c0ba8 authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: structure interaction now persists any changes even if it's cleared

parent a4cd6748
No related branches found
No related tags found
No related merge requests found
......@@ -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 } });
}
......
......@@ -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);
}
......
......@@ -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 }) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment