From 7686b617285f88854a1d643b33498a36aeaf5445 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sat, 24 Jul 2021 16:24:27 -0700 Subject: [PATCH] fix includeParent for multi instance bond visuals --- CHANGELOG.md | 3 ++- .../dnatco/confal-pyramids/representation.ts | 4 ++-- .../rcsb/validation-report/representation.ts | 3 ++- src/mol-geo/geometry/spheres/spheres.ts | 3 --- src/mol-geo/geometry/text/text.ts | 3 --- .../interactions-intra-unit-cylinder.ts | 3 ++- src/mol-repr/structure/params.ts | 1 + .../structure/representation/ball-and-stick.ts | 1 + src/mol-repr/structure/representation/line.ts | 1 + src/mol-repr/structure/units-representation.ts | 2 +- src/mol-repr/structure/units-visual.ts | 12 +++++------- .../structure/visual/bond-intra-unit-cylinder.ts | 3 ++- .../structure/visual/bond-intra-unit-line.ts | 3 ++- src/mol-repr/structure/visual/element-sphere.ts | 3 ++- .../structure/visual/gaussian-surface-mesh.ts | 4 ++-- .../structure/visual/orientation-ellipsoid-mesh.ts | 3 ++- .../structure/visual/polymer-backbone-cylinder.ts | 3 ++- .../structure/visual/polymer-backbone-sphere.ts | 3 ++- src/mol-repr/structure/visual/polymer-trace-mesh.ts | 3 ++- src/mol-repr/structure/visual/util/bond.ts | 3 +-- src/mol-repr/structure/visual/util/common.ts | 8 +++++++- src/mol-repr/structure/visual/util/element.ts | 3 +-- src/mol-repr/structure/visual/util/nucleotide.ts | 3 +-- src/mol-repr/structure/visual/util/polymer.ts | 3 +-- 24 files changed, 44 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4db17981..769a34302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,10 @@ Note that since we don't clearly distinguish between a public and private interf - Add `SdfFormat` and update SDF parser to be able to parse data headers according to spec (hopefully :)) #230 - Fix mononucleotides detected as polymer components (#229) - Set default outline scale back to 1 -- Improved DCD reader cell angle handling (intepret near 0 angles as 90 deg) +- Improved DCD reader cell angle handling (interpret near 0 angles as 90 deg) - Handle more residue/atom names commonly used in force-fields - Add USDZ support to ``geo-export`` extension. +- Fix `includeParent` support for multi-instance bond visuals. ## [v2.1.0] - 2021-07-05 diff --git a/src/extensions/dnatco/confal-pyramids/representation.ts b/src/extensions/dnatco/confal-pyramids/representation.ts index ebb936e62..b0ce90b53 100644 --- a/src/extensions/dnatco/confal-pyramids/representation.ts +++ b/src/extensions/dnatco/confal-pyramids/representation.ts @@ -20,10 +20,10 @@ import { Structure, StructureProperties, Unit } from '../../../mol-model/structu import { CustomProperty } from '../../../mol-model-props/common/custom-property'; import { Representation, RepresentationContext, RepresentationParamsGetter } from '../../../mol-repr/representation'; import { StructureRepresentation, StructureRepresentationProvider, StructureRepresentationStateBuilder, UnitsRepresentation } from '../../../mol-repr/structure/representation'; -import { StructureGroup, UnitsMeshParams, UnitsMeshVisual, UnitsVisual } from '../../../mol-repr/structure/units-visual'; +import { UnitsMeshParams, UnitsMeshVisual, UnitsVisual } from '../../../mol-repr/structure/units-visual'; import { VisualUpdateState } from '../../../mol-repr/util'; import { VisualContext } from '../../../mol-repr/visual'; -import { getAltResidueLociFromId } from '../../../mol-repr/structure/visual/util/common'; +import { getAltResidueLociFromId, StructureGroup } from '../../../mol-repr/structure/visual/util/common'; import { ParamDefinition as PD } from '../../../mol-util/param-definition'; import { Theme, ThemeRegistryContext } from '../../../mol-theme/theme'; import { NullLocation } from '../../../mol-model/location'; diff --git a/src/extensions/rcsb/validation-report/representation.ts b/src/extensions/rcsb/validation-report/representation.ts index 3e2c4406a..b65f771b5 100644 --- a/src/extensions/rcsb/validation-report/representation.ts +++ b/src/extensions/rcsb/validation-report/representation.ts @@ -16,7 +16,7 @@ import { RepresentationContext, RepresentationParamsGetter, Representation } fro import { UnitsRepresentation, StructureRepresentation, StructureRepresentationStateBuilder, StructureRepresentationProvider, ComplexRepresentation } from '../../../mol-repr/structure/representation'; import { VisualContext } from '../../../mol-repr/visual'; import { createLinkCylinderMesh, LinkCylinderParams, LinkStyle } from '../../../mol-repr/structure/visual/util/link'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, StructureGroup } from '../../../mol-repr/structure/units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual } from '../../../mol-repr/structure/units-visual'; import { VisualUpdateState } from '../../../mol-repr/util'; import { LocationIterator } from '../../../mol-geo/util/location-iterator'; import { ClashesProvider, IntraUnitClashes, InterUnitClashes, ValidationReport } from './prop'; @@ -28,6 +28,7 @@ import { CentroidHelper } from '../../../mol-math/geometry/centroid-helper'; import { Sphere3D } from '../../../mol-math/geometry'; import { bondLabel } from '../../../mol-theme/label'; import { getUnitKindsParam } from '../../../mol-repr/structure/params'; +import { StructureGroup } from '../../../mol-repr/structure/visual/util/common'; // diff --git a/src/mol-geo/geometry/spheres/spheres.ts b/src/mol-geo/geometry/spheres/spheres.ts index 14b52ca7a..3163a0961 100644 --- a/src/mol-geo/geometry/spheres/spheres.ts +++ b/src/mol-geo/geometry/spheres/spheres.ts @@ -163,9 +163,6 @@ export namespace Spheres { function createValues(spheres: Spheres, transform: TransformData, locationIt: LocationIterator, theme: Theme, props: PD.Values<Params>): SpheresValues { const { instanceCount, groupCount } = locationIt; - if (instanceCount !== transform.instanceCount.ref.value) { - throw new Error('instanceCount values in TransformData and LocationIterator differ'); - } const positionIt = createPositionIterator(spheres, transform); const color = createColors(locationIt, positionIt, theme.color); diff --git a/src/mol-geo/geometry/text/text.ts b/src/mol-geo/geometry/text/text.ts index b0f3f51fa..cd4e20719 100644 --- a/src/mol-geo/geometry/text/text.ts +++ b/src/mol-geo/geometry/text/text.ts @@ -206,9 +206,6 @@ export namespace Text { function createValues(text: Text, transform: TransformData, locationIt: LocationIterator, theme: Theme, props: PD.Values<Params>): TextValues { const { instanceCount, groupCount } = locationIt; - if (instanceCount !== transform.instanceCount.ref.value) { - throw new Error('instanceCount values in TransformData and LocationIterator differ'); - } const positionIt = createPositionIterator(text, transform); const color = createColors(locationIt, positionIt, theme.color); diff --git a/src/mol-model-props/computed/representations/interactions-intra-unit-cylinder.ts b/src/mol-model-props/computed/representations/interactions-intra-unit-cylinder.ts index d67a85279..ed89ee955 100644 --- a/src/mol-model-props/computed/representations/interactions-intra-unit-cylinder.ts +++ b/src/mol-model-props/computed/representations/interactions-intra-unit-cylinder.ts @@ -15,12 +15,13 @@ import { VisualContext } from '../../../mol-repr/visual'; import { Theme } from '../../../mol-theme/theme'; import { InteractionsProvider } from '../interactions'; import { createLinkCylinderMesh, LinkCylinderParams, LinkStyle } from '../../../mol-repr/structure/visual/util/link'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, StructureGroup } from '../../../mol-repr/structure/units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual } from '../../../mol-repr/structure/units-visual'; import { VisualUpdateState } from '../../../mol-repr/util'; import { LocationIterator } from '../../../mol-geo/util/location-iterator'; import { Interactions } from '../interactions/interactions'; import { InteractionFlag } from '../interactions/common'; import { Sphere3D } from '../../../mol-math/geometry'; +import { StructureGroup } from '../../../mol-repr/structure/visual/util/common'; 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); diff --git a/src/mol-repr/structure/params.ts b/src/mol-repr/structure/params.ts index 162e75dff..a838ccb24 100644 --- a/src/mol-repr/structure/params.ts +++ b/src/mol-repr/structure/params.ts @@ -22,6 +22,7 @@ export function getUnitKindsParam(defaultValue: UnitKind[]) { export const StructureParams = { unitKinds: getUnitKindsParam(['atomic', 'spheres']), + includeParent: PD.Boolean(false, { isHidden: true }), }; export type StructureParams = typeof StructureParams diff --git a/src/mol-repr/structure/representation/ball-and-stick.ts b/src/mol-repr/structure/representation/ball-and-stick.ts index 70eb3ab04..ee043e08d 100644 --- a/src/mol-repr/structure/representation/ball-and-stick.ts +++ b/src/mol-repr/structure/representation/ball-and-stick.ts @@ -27,6 +27,7 @@ export const BallAndStickParams = { traceOnly: PD.Boolean(false, { isHidden: true }), // not useful here ...IntraUnitBondCylinderParams, ...InterUnitBondCylinderParams, + includeParent: PD.Boolean(false), unitKinds: getUnitKindsParam(['atomic']), sizeFactor: PD.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: PD.Numeric(2 / 3, { min: 0.01, max: 3, step: 0.01 }), diff --git a/src/mol-repr/structure/representation/line.ts b/src/mol-repr/structure/representation/line.ts index 013677e00..2f9c5c5d6 100644 --- a/src/mol-repr/structure/representation/line.ts +++ b/src/mol-repr/structure/representation/line.ts @@ -23,6 +23,7 @@ const LineVisuals = { export const LineParams = { ...IntraUnitBondLineParams, ...InterUnitBondLineParams, + includeParent: PD.Boolean(false), sizeFactor: PD.Numeric(1.5, { min: 0.01, max: 10, step: 0.01 }), unitKinds: getUnitKindsParam(['atomic']), visuals: PD.MultiSelect(['intra-bond', 'inter-bond'], PD.objectToOptions(LineVisuals)) diff --git a/src/mol-repr/structure/units-representation.ts b/src/mol-repr/structure/units-representation.ts index 3c9b3305c..d784e37af 100644 --- a/src/mol-repr/structure/units-representation.ts +++ b/src/mol-repr/structure/units-representation.ts @@ -8,7 +8,6 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { StructureRepresentation, StructureRepresentationStateBuilder, StructureRepresentationState } from './representation'; import { Visual } from '../visual'; -import { StructureGroup } from './units-visual'; import { RepresentationContext, RepresentationParamsGetter } from '../representation'; import { Structure, Unit, StructureElement, Bond } from '../../mol-model/structure'; import { Subject } from 'rxjs'; @@ -25,6 +24,7 @@ import { Interval } from '../../mol-data/int'; import { StructureParams } from './params'; import { Clipping } from '../../mol-theme/clipping'; import { WebGLContext } from '../../mol-gl/webgl/context'; +import { StructureGroup } from './visual/util/common'; export interface UnitsVisual<P extends StructureParams> extends Visual<StructureGroup, P> { } diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index 92ccd37e0..fd28a68df 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -11,7 +11,7 @@ import { Visual, VisualContext } from '../visual'; import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { Theme } from '../../mol-theme/theme'; -import { createUnitsTransform, includesUnitKind } from './visual/util/common'; +import { createUnitsTransform, includesUnitKind, StructureGroup } from './visual/util/common'; import { createRenderObject, GraphicsRenderObject, RenderObjectValues } from '../../mol-gl/render-object'; import { PickingId } from '../../mol-geo/geometry/picking'; import { Loci, isEveryLoci, EmptyLoci } from '../../mol-model/loci'; @@ -41,13 +41,11 @@ import { Clipping } from '../../mol-theme/clipping'; import { WebGLContext } from '../../mol-gl/webgl/context'; import { isPromiseLike } from '../../mol-util/type-helpers'; -export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup } - export interface UnitsVisual<P extends RepresentationProps = {}> extends Visual<StructureGroup, P> { } -function createUnitsRenderObject<G extends Geometry>(group: Unit.SymmetryGroup, geometry: G, locationIt: LocationIterator, theme: Theme, props: PD.Values<Geometry.Params<G>>, materialId: number) { +function createUnitsRenderObject<G extends Geometry>(structureGroup: StructureGroup, geometry: G, locationIt: LocationIterator, theme: Theme, props: PD.Values<StructureParams & Geometry.Params<G>>, materialId: number) { const { createValues, createRenderableState } = Geometry.getUtils(geometry); - const transform = createUnitsTransform(group); + const transform = createUnitsTransform(structureGroup, props.includeParent); const values = createValues(geometry, transform, locationIt, theme, props); const state = createRenderableState(props); return createRenderObject(geometry.kind, values, state, materialId); @@ -179,7 +177,7 @@ export function UnitsVisual<G extends Geometry, P extends StructureParams & Geom if (updateState.createNew) { locationIt = createLocationIterator(newStructureGroup); if (newGeometry) { - renderObject = createUnitsRenderObject(newStructureGroup.group, newGeometry, locationIt, newTheme, newProps, materialId); + renderObject = createUnitsRenderObject(newStructureGroup, newGeometry, locationIt, newTheme, newProps, materialId); positionIt = createPositionIterator(newGeometry, renderObject.values); } else { throw new Error('expected geometry to be given'); @@ -198,7 +196,7 @@ export function UnitsVisual<G extends Geometry, P extends StructureParams & Geom if (updateState.updateMatrix) { // console.log('update matrix'); - createUnitsTransform(newStructureGroup.group, renderObject.values); + createUnitsTransform(newStructureGroup, newProps.includeParent, renderObject.values); } if (updateState.createGeometry) { diff --git a/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts b/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts index cd10168f0..7aae65c38 100644 --- a/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts +++ b/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts @@ -13,7 +13,7 @@ import { Mesh } from '../../../mol-geo/geometry/mesh/mesh'; import { Vec3 } from '../../../mol-math/linear-algebra'; import { arrayEqual } from '../../../mol-util'; import { createLinkCylinderImpostors, createLinkCylinderMesh, LinkBuilderProps, LinkStyle } from './util/link'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, StructureGroup, UnitsCylindersParams, UnitsCylindersVisual } from '../units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, UnitsCylindersParams, UnitsCylindersVisual } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { BondType } from '../../../mol-model/structure/model/types'; import { BondCylinderParams, BondIterator, eachIntraBond, getIntraBondLoci, makeIntraBondIgnoreTest } from './util/bond'; @@ -23,6 +23,7 @@ import { WebGLContext } from '../../../mol-gl/webgl/context'; import { Cylinders } from '../../../mol-geo/geometry/cylinders/cylinders'; import { SortedArray } from '../../../mol-data/int'; import { arrayIntersectionSize } from '../../../mol-util/array'; +import { StructureGroup } from './util/common'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) const isBondType = BondType.is; diff --git a/src/mol-repr/structure/visual/bond-intra-unit-line.ts b/src/mol-repr/structure/visual/bond-intra-unit-line.ts index 8cc4cbeee..f55e7eb0d 100644 --- a/src/mol-repr/structure/visual/bond-intra-unit-line.ts +++ b/src/mol-repr/structure/visual/bond-intra-unit-line.ts @@ -11,7 +11,7 @@ import { Theme } from '../../../mol-theme/theme'; import { Vec3 } from '../../../mol-math/linear-algebra'; import { arrayEqual } from '../../../mol-util'; import { LinkStyle, createLinkLines, LinkBuilderProps } from './util/link'; -import { UnitsVisual, UnitsLinesParams, UnitsLinesVisual, StructureGroup } from '../units-visual'; +import { UnitsVisual, UnitsLinesParams, UnitsLinesVisual } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { BondType } from '../../../mol-model/structure/model/types'; import { BondIterator, BondLineParams, getIntraBondLoci, eachIntraBond, makeIntraBondIgnoreTest } from './util/bond'; @@ -19,6 +19,7 @@ import { Sphere3D } from '../../../mol-math/geometry'; import { Lines } from '../../../mol-geo/geometry/lines/lines'; import { IntAdjacencyGraph } from '../../../mol-math/graph'; import { arrayIntersectionSize } from '../../../mol-util/array'; +import { StructureGroup } from './util/common'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) const isBondType = BondType.is; diff --git a/src/mol-repr/structure/visual/element-sphere.ts b/src/mol-repr/structure/visual/element-sphere.ts index def4843cb..e7fc70aa0 100644 --- a/src/mol-repr/structure/visual/element-sphere.ts +++ b/src/mol-repr/structure/visual/element-sphere.ts @@ -6,12 +6,13 @@ */ import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { UnitsMeshParams, UnitsSpheresParams, UnitsVisual, UnitsSpheresVisual, UnitsMeshVisual, StructureGroup } from '../units-visual'; +import { UnitsMeshParams, UnitsSpheresParams, UnitsVisual, UnitsSpheresVisual, UnitsMeshVisual } from '../units-visual'; import { WebGLContext } from '../../../mol-gl/webgl/context'; import { createElementSphereImpostor, ElementIterator, getElementLoci, eachElement, createElementSphereMesh } from './util/element'; import { VisualUpdateState } from '../../util'; import { BaseGeometry } from '../../../mol-geo/geometry/base'; import { Structure } from '../../../mol-model/structure'; +import { StructureGroup } from './util/common'; export const ElementSphereParams = { ...UnitsMeshParams, diff --git a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts index 51ab5372e..a63788c9b 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts @@ -5,7 +5,7 @@ */ import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { UnitsMeshParams, UnitsTextureMeshParams, UnitsVisual, UnitsMeshVisual, UnitsTextureMeshVisual, StructureGroup } from '../units-visual'; +import { UnitsMeshParams, UnitsTextureMeshParams, UnitsVisual, UnitsMeshVisual, UnitsTextureMeshVisual } from '../units-visual'; import { GaussianDensityParams, computeUnitGaussianDensity, computeUnitGaussianDensityTexture2d, GaussianDensityProps, computeStructureGaussianDensity, computeStructureGaussianDensityTexture2d } from './util/gaussian'; import { VisualContext } from '../../visual'; import { Unit, Structure } from '../../../mol-model/structure'; @@ -18,7 +18,7 @@ import { TextureMesh } from '../../../mol-geo/geometry/texture-mesh/texture-mesh import { extractIsosurface } from '../../../mol-gl/compute/marching-cubes/isosurface'; import { Sphere3D } from '../../../mol-math/geometry'; import { ComplexVisual, ComplexMeshParams, ComplexMeshVisual, ComplexTextureMeshVisual, ComplexTextureMeshParams } from '../complex-visual'; -import { getUnitExtraRadius, getStructureExtraRadius, getVolumeSliceInfo } from './util/common'; +import { getUnitExtraRadius, getStructureExtraRadius, getVolumeSliceInfo, StructureGroup } from './util/common'; import { WebGLContext } from '../../../mol-gl/webgl/context'; import { MeshValues } from '../../../mol-gl/renderable/mesh'; import { TextureMeshValues } from '../../../mol-gl/renderable/texture-mesh'; diff --git a/src/mol-repr/structure/visual/orientation-ellipsoid-mesh.ts b/src/mol-repr/structure/visual/orientation-ellipsoid-mesh.ts index 717efa5bc..76e355547 100644 --- a/src/mol-repr/structure/visual/orientation-ellipsoid-mesh.ts +++ b/src/mol-repr/structure/visual/orientation-ellipsoid-mesh.ts @@ -5,7 +5,7 @@ */ import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, StructureGroup } from '../../../mol-repr/structure/units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual } from '../../../mol-repr/structure/units-visual'; import { VisualUpdateState } from '../../../mol-repr/util'; import { VisualContext } from '../../../mol-repr/visual'; import { Unit, Structure, StructureElement } from '../../../mol-model/structure'; @@ -22,6 +22,7 @@ import { UnitIndex } from '../../../mol-model/structure/structure/element/elemen import { LocationIterator } from '../../../mol-geo/util/location-iterator'; import { MoleculeType } from '../../../mol-model/structure/model/types'; import { BaseGeometry } from '../../../mol-geo/geometry/base'; +import { StructureGroup } from './util/common'; export const OrientationEllipsoidMeshParams = { ...UnitsMeshParams, diff --git a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts index accf0d45e..249f55348 100644 --- a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts @@ -14,7 +14,7 @@ import { Vec3 } from '../../../mol-math/linear-algebra'; import { CylinderProps } from '../../../mol-geo/primitive/cylinder'; import { eachPolymerElement, getPolymerElementLoci, NucleicShift, PolymerLocationIterator, StandardShift } from './util/polymer'; import { addCylinder } from '../../../mol-geo/geometry/mesh/builder/cylinder'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, UnitsCylindersVisual, UnitsCylindersParams, StructureGroup } from '../units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, UnitsCylindersVisual, UnitsCylindersParams } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { BaseGeometry } from '../../../mol-geo/geometry/base'; import { Sphere3D } from '../../../mol-math/geometry'; @@ -23,6 +23,7 @@ import { WebGLContext } from '../../../mol-gl/webgl/context'; import { Cylinders } from '../../../mol-geo/geometry/cylinders/cylinders'; import { CylindersBuilder } from '../../../mol-geo/geometry/cylinders/cylinders-builder'; import { eachPolymerBackboneLink } from './util/polymer/backbone'; +import { StructureGroup } from './util/common'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) const v3scale = Vec3.scale; diff --git a/src/mol-repr/structure/visual/polymer-backbone-sphere.ts b/src/mol-repr/structure/visual/polymer-backbone-sphere.ts index 9557e22b9..d09dbe1f9 100644 --- a/src/mol-repr/structure/visual/polymer-backbone-sphere.ts +++ b/src/mol-repr/structure/visual/polymer-backbone-sphere.ts @@ -12,7 +12,7 @@ import { Mesh } from '../../../mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from '../../../mol-geo/geometry/mesh/mesh-builder'; import { Vec3 } from '../../../mol-math/linear-algebra'; import { eachPolymerElement, getPolymerElementLoci, PolymerLocationIterator } from './util/polymer'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, UnitsSpheresVisual, UnitsSpheresParams, StructureGroup } from '../units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, UnitsSpheresVisual, UnitsSpheresParams } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { BaseGeometry } from '../../../mol-geo/geometry/base'; import { Sphere3D } from '../../../mol-math/geometry'; @@ -22,6 +22,7 @@ import { WebGLContext } from '../../../mol-gl/webgl/context'; import { Spheres } from '../../../mol-geo/geometry/spheres/spheres'; import { SpheresBuilder } from '../../../mol-geo/geometry/spheres/spheres-builder'; import { eachPolymerBackboneElement } from './util/polymer/backbone'; +import { StructureGroup } from './util/common'; export const PolymerBackboneSphereParams = { ...UnitsMeshParams, diff --git a/src/mol-repr/structure/visual/polymer-trace-mesh.ts b/src/mol-repr/structure/visual/polymer-trace-mesh.ts index 52804b344..416c3f4be 100644 --- a/src/mol-repr/structure/visual/polymer-trace-mesh.ts +++ b/src/mol-repr/structure/visual/polymer-trace-mesh.ts @@ -14,7 +14,7 @@ import { createCurveSegmentState, PolymerTraceIterator, interpolateCurveSegment, import { isNucleic, SecondaryStructureType } from '../../../mol-model/structure/model/types'; import { addSheet } from '../../../mol-geo/geometry/mesh/builder/sheet'; import { addTube } from '../../../mol-geo/geometry/mesh/builder/tube'; -import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, StructureGroup } from '../units-visual'; +import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { SecondaryStructureProvider } from '../../../mol-model-props/computed/secondary-structure'; import { addRibbon } from '../../../mol-geo/geometry/mesh/builder/ribbon'; @@ -22,6 +22,7 @@ import { addSphere } from '../../../mol-geo/geometry/mesh/builder/sphere'; import { Vec3 } from '../../../mol-math/linear-algebra'; import { BaseGeometry } from '../../../mol-geo/geometry/base'; import { Sphere3D } from '../../../mol-math/geometry'; +import { StructureGroup } from './util/common'; export const PolymerTraceMeshParams = { sizeFactor: PD.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), diff --git a/src/mol-repr/structure/visual/util/bond.ts b/src/mol-repr/structure/visual/util/bond.ts index bd30f7428..983a7612a 100644 --- a/src/mol-repr/structure/visual/util/bond.ts +++ b/src/mol-repr/structure/visual/util/bond.ts @@ -8,13 +8,12 @@ import { BondType } from '../../../../mol-model/structure/model/types'; import { Unit, StructureElement, Structure, Bond } from '../../../../mol-model/structure'; import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; import { LocationIterator } from '../../../../mol-geo/util/location-iterator'; -import { StructureGroup } from '../../units-visual'; import { LinkCylinderParams, LinkLineParams } from './link'; import { ObjectKeys } from '../../../../mol-util/type-helpers'; import { PickingId } from '../../../../mol-geo/geometry/picking'; import { EmptyLoci, Loci } from '../../../../mol-model/loci'; import { Interval, OrderedSet, SortedArray } from '../../../../mol-data/int'; -import { isH, isHydrogen } from './common'; +import { isH, isHydrogen, StructureGroup } from './common'; export const BondParams = { includeTypes: PD.MultiSelect(ObjectKeys(BondType.Names), PD.objectToOptions(BondType.Names)), diff --git a/src/mol-repr/structure/visual/util/common.ts b/src/mol-repr/structure/visual/util/common.ts index ac7a53dc6..89a6f52b8 100644 --- a/src/mol-repr/structure/visual/util/common.ts +++ b/src/mol-repr/structure/visual/util/common.ts @@ -71,7 +71,13 @@ export function getAltResidueLociFromId(structure: Structure, unit: Unit.Atomic, // -export function createUnitsTransform({ units }: Unit.SymmetryGroup, transformData?: TransformData) { +export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup } + +export function createUnitsTransform(structureGroup: StructureGroup, includeParent: boolean, transformData?: TransformData) { + const { child } = structureGroup.structure; + const units: ReadonlyArray<Unit> = includeParent && child + ? structureGroup.group.units.filter(u => child.unitMap.has(u.id)) + : structureGroup.group.units; const unitCount = units.length; const n = unitCount * 16; const array = transformData && transformData.aTransform.ref.value.length >= n ? transformData.aTransform.ref.value : new Float32Array(n); diff --git a/src/mol-repr/structure/visual/util/element.ts b/src/mol-repr/structure/visual/util/element.ts index 1c80d73fb..b9a8ea919 100644 --- a/src/mol-repr/structure/visual/util/element.ts +++ b/src/mol-repr/structure/visual/util/element.ts @@ -17,10 +17,9 @@ import { PickingId } from '../../../../mol-geo/geometry/picking'; import { LocationIterator } from '../../../../mol-geo/util/location-iterator'; import { VisualContext } from '../../../../mol-repr/visual'; import { Theme } from '../../../../mol-theme/theme'; -import { StructureGroup } from '../../../../mol-repr/structure/units-visual'; import { Spheres } from '../../../../mol-geo/geometry/spheres/spheres'; import { SpheresBuilder } from '../../../../mol-geo/geometry/spheres/spheres-builder'; -import { isTrace, isH } from './common'; +import { isTrace, isH, StructureGroup } from './common'; import { Sphere3D } from '../../../../mol-math/geometry'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) diff --git a/src/mol-repr/structure/visual/util/nucleotide.ts b/src/mol-repr/structure/visual/util/nucleotide.ts index 60f9d276c..fe97efd55 100644 --- a/src/mol-repr/structure/visual/util/nucleotide.ts +++ b/src/mol-repr/structure/visual/util/nucleotide.ts @@ -9,8 +9,7 @@ import { Loci, EmptyLoci } from '../../../../mol-model/loci'; import { Interval } from '../../../../mol-data/int'; import { LocationIterator } from '../../../../mol-geo/util/location-iterator'; import { PickingId } from '../../../../mol-geo/geometry/picking'; -import { StructureGroup } from '../../../../mol-repr/structure/units-visual'; -import { getResidueLoci } from './common'; +import { getResidueLoci, StructureGroup } from './common'; import { eachAtomicUnitTracedElement } from './polymer'; export namespace NucleotideLocationIterator { diff --git a/src/mol-repr/structure/visual/util/polymer.ts b/src/mol-repr/structure/visual/util/polymer.ts index 1311e55f3..3ba2da690 100644 --- a/src/mol-repr/structure/visual/util/polymer.ts +++ b/src/mol-repr/structure/visual/util/polymer.ts @@ -11,8 +11,7 @@ import { OrderedSet, Interval, SortedArray } from '../../../../mol-data/int'; import { EmptyLoci, Loci } from '../../../../mol-model/loci'; import { LocationIterator } from '../../../../mol-geo/util/location-iterator'; import { PickingId } from '../../../../mol-geo/geometry/picking'; -import { StructureGroup } from '../../../structure/units-visual'; -import { getResidueLoci } from './common'; +import { getResidueLoci, StructureGroup } from './common'; export * from './polymer/backbone'; export * from './polymer/gap-iterator'; -- GitLab