diff --git a/src/apps/viewer/extensions/jolecule.ts b/src/apps/viewer/extensions/jolecule.ts index 824376263ab6be9e89d271a4927c650021e8cae8..2a5744a8e7da6b384d97375384bb7ee0ab3332a6 100644 --- a/src/apps/viewer/extensions/jolecule.ts +++ b/src/apps/viewer/extensions/jolecule.ts @@ -59,20 +59,20 @@ function createTemplate(plugin: PluginContext, tree: StateTree, id: string) { const b = new StateBuilder.Root(tree); const data = b.toRoot().apply(StateTransforms.Data.Download, { url: `https://www.ebi.ac.uk/pdbe/static/entry/${id}_updated.cif` }, { props: { isGhost: true }}); const model = createModelTree(data, 'cif'); - const structure = model.apply(StateTransforms.Model.StructureFromModel, {}, { ref: 'structure' }); + const structure = model.apply(StateTransforms.Model.StructureFromModel, {}); complexRepresentation(plugin, structure, { hideWater: true }); - return b.getTree(); + return { tree: b.getTree(), structure: structure.ref }; } -const labelOptions = { +const labelOptions: ParamDefinition.Values<Text.Params> = { ...ParamDefinition.getDefaultValues(Text.Params), - sizeFactor: 1.5, - offsetX: 1, - offsetY: 1, + tether: true, + sizeFactor: 1.3, + attachment: 'bottom-right', offsetZ: 10, background: true, backgroundMargin: 0.2, - backgroundColor: ColorNames.snow, + backgroundColor: ColorNames.skyblue, backgroundOpacity: 0.9 } @@ -88,20 +88,29 @@ const labelOptions = { // backgroundOpacity: 0.9 // } -function buildSnapshot(plugin: PluginContext, template: StateTree, params: { e: JoleculeSnapshot, idx: number, len: number }): PluginStateSnapshotManager.Entry { - const b = new StateBuilder.Root(template); +function buildSnapshot(plugin: PluginContext, template: { tree: StateTree, structure: string }, params: { e: JoleculeSnapshot, idx: number, len: number }): PluginStateSnapshotManager.Entry { + const b = new StateBuilder.Root(template.tree); let i = 0; for (const l of params.e.labels) { - b.to('structure') - .apply(StateTransforms.Model.StructureSelection, { query: createQuery([l.i_atom]), label: `Label ${++i}` }) + const query = createQuery([l.i_atom]); + const group = b.to(template.structure) + .group(StateTransforms.Misc.CreateGroup, { label: `Label ${++i}` }); + + group + .apply(StateTransforms.Model.StructureSelection, { query, label: 'Atom' }) .apply(StateTransforms.Representation.StructureLabels3D, { target: { name: 'static-text', params: { value: l.text || '' } }, options: labelOptions }); + + group + .apply(StateTransforms.Model.StructureSelection, { query: MS.struct.modifier.wholeResidues([query]), label: 'Residue' }) + .apply(StateTransforms.Representation.StructureRepresentation3D, + StructureRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'ball-and-stick', { })); } if (params.e.selected && params.e.selected.length > 0) { - b.to('structure') + b.to(template.structure) .apply(StateTransforms.Model.StructureSelection, { query: createQuery(params.e.selected), label: `Selected` }) .apply(StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'ball-and-stick')); 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 6005c84ec9326b80af8be884efca8716627e60f0..959baa33b4c8518e54a9c08041bb879fe62f5912 100644 --- a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts +++ b/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts @@ -149,15 +149,21 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W StructureElement.Loci.toScriptExpression(current.loci) ]); - const surroundings = MS.struct.modifier.exceptBy({ - 0: MS.struct.modifier.includeSurroundings({ - 0: core, - radius: 5, - 'as-whole-residues': true - }), - by: core + const surroundings = MS.struct.modifier.includeSurroundings({ + 0: core, + radius: 5, + 'as-whole-residues': true }); + // const surroundings = MS.struct.modifier.exceptBy({ + // 0: MS.struct.modifier.includeSurroundings({ + // 0: core, + // radius: 5, + // 'as-whole-residues': true + // }), + // by: core + // }); + const { state, builder, refs } = this.ensureShape(parent); builder.to(refs[Tags.ResidueSel]!).update(StateTransforms.Model.StructureSelection, old => ({ ...old, query: core }));