Browse Source

ignoreHydrogens option for StructureFocusRepresentation

- also updated by StructureComponentManager
Alexander Rose 4 years ago
parent
commit
7982f25a45

+ 4 - 0
src/mol-plugin-state/manager/structure/component.ts

@@ -29,6 +29,7 @@ import { StructureHierarchyRef, StructureComponentRef, StructureRef, StructureRe
 import { Clipping } from '../../../mol-theme/clipping';
 import { setStructureClipping } from '../../helpers/structure-clipping';
 import { setStructureTransparency } from '../../helpers/structure-transparency';
+import { StructureFocusRepresentation } from '../../../mol-plugin/behavior/dynamic/selection/structure-focus-representation';
 
 export { StructureComponentManager };
 
@@ -64,6 +65,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
 
         return this.plugin.dataTransaction(async () => {
             await update.commit();
+            await this.plugin.state.updateBehavior(StructureFocusRepresentation, p => {
+                p.ignoreHydrogens = !options.showHydrogens;
+            });
             if (interactionChanged) await this.updateInterationProps();
         });
     }

+ 16 - 5
src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts

@@ -40,7 +40,8 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => {
             })
         }),
         components: PD.MultiSelect(FocusComponents, PD.arrayToOptions(FocusComponents)),
-        excludeTargetFromSurroundings: PD.Boolean(false, { label: 'Exclude Target', description: 'Exclude the focus "target" from the surroudings component.' })
+        excludeTargetFromSurroundings: PD.Boolean(false, { label: 'Exclude Target', description: 'Exclude the focus "target" from the surroudings component.' }),
+        ignoreHydrogens: PD.Boolean(false)
     };
 };
 
@@ -61,6 +62,16 @@ const TagSet: Set<StructureFocusRepresentationTags> = new Set([StructureFocusRep
 class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscribers<StructureFocusRepresentationProps> {
     private get surrLabel() { return `[Focus] Surroundings (${this.params.expandRadius} Å)`; }
 
+    private getReprParams(reprParams: PD.Values<PD.Params>) {
+        return {
+            ...this.params.targetParams,
+            type: {
+                name: reprParams.type.name,
+                params: { ...reprParams.type.params, ignoreHydrogens: this.params.ignoreHydrogens }
+            }
+        };
+    }
+
     private ensureShape(cell: StateObjectCell<PluginStateObject.Molecule.Structure>) {
         const state = this.plugin.state.data, tree = state.tree;
         const builder = state.build();
@@ -87,13 +98,13 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
         if (components.indexOf('target') >= 0 && !refs[StructureFocusRepresentationTags.TargetRepr]) {
             refs[StructureFocusRepresentationTags.TargetRepr] = builder
                 .to(refs[StructureFocusRepresentationTags.TargetSel]!)
-                .apply(StateTransforms.Representation.StructureRepresentation3D, this.params.targetParams, { tags: StructureFocusRepresentationTags.TargetRepr }).ref;
+                .apply(StateTransforms.Representation.StructureRepresentation3D, this.getReprParams(this.params.targetParams), { tags: StructureFocusRepresentationTags.TargetRepr }).ref;
         }
 
         if (components.indexOf('surroundings') >= 0 && !refs[StructureFocusRepresentationTags.SurrRepr]) {
             refs[StructureFocusRepresentationTags.SurrRepr] = builder
                 .to(refs[StructureFocusRepresentationTags.SurrSel]!)
-                .apply(StateTransforms.Representation.StructureRepresentation3D, this.params.surroundingsParams, { tags: StructureFocusRepresentationTags.SurrRepr }).ref;
+                .apply(StateTransforms.Representation.StructureRepresentation3D, this.getReprParams(this.params.surroundingsParams), { tags: StructureFocusRepresentationTags.SurrRepr }).ref;
         }
 
         if (components.indexOf('interactions') >= 0 && !refs[StructureFocusRepresentationTags.SurrNciRepr]) {
@@ -189,13 +200,13 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
         let hasComponent = components.indexOf('target') >= 0;
         for (const repr of state.select(all.withTag(StructureFocusRepresentationTags.TargetRepr))) {
             if (!hasComponent) builder.delete(repr.transform.ref);
-            else builder.to(repr).update(this.params.targetParams);
+            else builder.to(repr).update(this.getReprParams(this.params.targetParams));
         }
 
         hasComponent = components.indexOf('surroundings') >= 0;
         for (const repr of state.select(all.withTag(StructureFocusRepresentationTags.SurrRepr))) {
             if (!hasComponent) builder.delete(repr.transform.ref);
-            else builder.to(repr).update(this.params.surroundingsParams);
+            else builder.to(repr).update(this.getReprParams(this.params.surroundingsParams));
         }
 
         hasComponent = components.indexOf('interactions') >= 0;