Browse Source

interactions repr: use size theme

Alexander Rose 5 years ago
parent
commit
1e018b82df

+ 15 - 2
src/mol-repr/structure/visual/interactions-inter-unit-cylinder.ts

@@ -6,7 +6,7 @@
 
 import { ParamDefinition as PD } from '../../../mol-util/param-definition';
 import { VisualContext } from '../../visual';
-import { Structure } from '../../../mol-model/structure';
+import { Structure, StructureElement } from '../../../mol-model/structure';
 import { Theme } from '../../../mol-theme/theme';
 import { Mesh } from '../../../mol-geo/geometry/mesh/mesh';
 import { Vec3 } from '../../../mol-math/linear-algebra';
@@ -22,6 +22,8 @@ import { InteractionsProvider } from '../../../mol-model-props/computed/interact
 import { LocationIterator } from '../../../mol-geo/util/location-iterator';
 import { InteractionFlag } from '../../../mol-model-props/computed/interactions/common';
 
+const tmpLoc = StructureElement.Location.create()
+
 function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<InteractionsInterUnitParams>, mesh?: Mesh) {
     if (!structure.hasAtomic) return Mesh.createEmpty(mesh)
 
@@ -47,7 +49,18 @@ function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: S
         },
         order: (edgeIndex: number) => 1,
         flags: (edgeIndex: number) => BondType.Flag.MetallicCoordination, // TODO
-        radius: (edgeIndex: number) => sizeFactor,
+        radius: (edgeIndex: number) => {
+            const b = edges[edgeIndex]
+            const fA = unitsFeatures.get(b.unitA.id)
+            tmpLoc.unit = b.unitA
+            tmpLoc.element = b.unitA.elements[fA.members[fA.offsets[b.indexA]]]
+            const sizeA = theme.size.size(tmpLoc)
+            const fB = unitsFeatures.get(b.unitB.id)
+            tmpLoc.unit = b.unitB
+            tmpLoc.element = b.unitB.elements[fB.members[fB.offsets[b.indexB]]]
+            const sizeB = theme.size.size(tmpLoc)
+            return Math.min(sizeA, sizeB) * sizeFactor
+        },
         ignore: (edgeIndex: number) => edges[edgeIndex].props.flag === InteractionFlag.Filtered
     }
 

+ 11 - 3
src/mol-repr/structure/visual/interactions-intra-unit-cylinder.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Unit, Structure } from '../../../mol-model/structure';
+import { Unit, Structure, StructureElement } from '../../../mol-model/structure';
 import { Vec3 } from '../../../mol-math/linear-algebra';
 import { Loci, EmptyLoci } from '../../../mol-model/loci';
 import { Interval } from '../../../mol-data/int';
@@ -25,11 +25,13 @@ import { InteractionFlag } from '../../../mol-model-props/computed/interactions/
 async function createIntraUnitInteractionsCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<InteractionsIntraUnitParams>, mesh?: Mesh) {
     if (!Unit.isAtomic(unit)) return Mesh.createEmpty(mesh)
 
+    const location = StructureElement.Location.create(unit)
+
     const interactions = InteractionsProvider.getValue(structure).value!
     const features = interactions.unitsFeatures.get(unit.id)
     const contacts = interactions.unitsContacts.get(unit.id)
 
-    const { x, y, z } = features
+    const { x, y, z, members, offsets } = features
     const { edgeCount, a, b, edgeProps: { flag } } = contacts
     const { sizeFactor } = props
     const { matrix } = unit.conformation.operator
@@ -47,7 +49,13 @@ async function createIntraUnitInteractionsCylinderMesh(ctx: VisualContext, unit:
         },
         order: (edgeIndex: number) => 1,
         flags: (edgeIndex: number) => BondType.Flag.MetallicCoordination, // TODO
-        radius: (edgeIndex: number) => sizeFactor,
+        radius: (edgeIndex: number) => {
+            location.element = unit.elements[members[offsets[a[edgeIndex]]]]
+            const sizeA = theme.size.size(location)
+            location.element = unit.elements[members[offsets[b[edgeIndex]]]]
+            const sizeB = theme.size.size(location)
+            return Math.min(sizeA, sizeB) * sizeFactor
+        },
         ignore: (edgeIndex: number) => flag[edgeIndex] === InteractionFlag.Filtered
     }