diff --git a/src/mol-model/loci.ts b/src/mol-model/loci.ts index 6bc2d08de6d013bd7946df8d27fdd6505870fe70..abdd4824ddfb8b200375bd82d2bb762da8bf5955 100644 --- a/src/mol-model/loci.ts +++ b/src/mol-model/loci.ts @@ -11,6 +11,7 @@ import { Sphere3D } from 'mol-math/geometry'; import { CentroidHelper } from 'mol-math/geometry/centroid-helper'; import { Vec3 } from 'mol-math/linear-algebra'; import { OrderedSet } from 'mol-data/int'; +import { Structure } from './structure/structure'; /** A Loci that includes every loci */ export const EveryLoci = { kind: 'every-loci' as 'every-loci' } @@ -29,6 +30,9 @@ export function isEmptyLoci(x: any): x is EmptyLoci { export function areLociEqual(lociA: Loci, lociB: Loci) { if (isEveryLoci(lociA) && isEveryLoci(lociB)) return true if (isEmptyLoci(lociA) && isEmptyLoci(lociB)) return true + if (Structure.isLoci(lociA) && Structure.isLoci(lociB)) { + return Structure.areLociEqual(lociA, lociB) + } if (StructureElement.isLoci(lociA) && StructureElement.isLoci(lociB)) { return StructureElement.areLociEqual(lociA, lociB) } @@ -44,7 +48,7 @@ export function areLociEqual(lociA: Loci, lociB: Loci) { export { Loci } -type Loci = StructureElement.Loci | Link.Loci | EveryLoci | EmptyLoci | Shape.Loci +type Loci = StructureElement.Loci | Structure.Loci | Link.Loci | EveryLoci | EmptyLoci | Shape.Loci namespace Loci { @@ -54,7 +58,9 @@ namespace Loci { if (loci.kind === 'every-loci' || loci.kind === 'empty-loci') return void 0; sphereHelper.reset(); - if (loci.kind === 'element-loci') { + if (loci.kind === 'structure-loci') { + return Sphere3D.clone(loci.structure.boundary.sphere) + } else if (loci.kind === 'element-loci') { for (const e of loci.elements) { const { indices } = e; const pos = e.unit.conformation.position; diff --git a/src/mol-model/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts index 6eaa79bb0443d51334860fc4870cb43b359e0053..cab555fd9d249bf85d853329843356c6c3658d3b 100644 --- a/src/mol-model/structure/structure/structure.ts +++ b/src/mol-model/structure/structure/structure.ts @@ -280,6 +280,23 @@ function getUniqueAtomicResidueIndices(structure: Structure): ReadonlyMap<UUID, namespace Structure { export const Empty = new Structure([]); + /** Represents a single structure */ + export interface Loci { + readonly kind: 'structure-loci', + readonly structure: Structure, + } + export function Loci(structure: Structure): Loci { + return { kind: 'structure-loci', structure }; + } + + export function isLoci(x: any): x is Loci { + return !!x && x.kind === 'structure-loci'; + } + + export function areLociEqual(a: Loci, b: Loci) { + return a.structure === b.structure + } + export function create(units: ReadonlyArray<Unit>): Structure { return new Structure(units); } /** diff --git a/src/mol-theme/label.ts b/src/mol-theme/label.ts index 6cfaafb2316802c9ec76a0ed9b24f06466b5d54f..0e961fca8c17953d53ebed5f0a74fa00261176f0 100644 --- a/src/mol-theme/label.ts +++ b/src/mol-theme/label.ts @@ -20,6 +20,8 @@ function setElementLocation(loc: StructureElement, unit: Unit, index: StructureE export function labelFirst(loci: Loci): string { switch (loci.kind) { + case 'structure-loci': + return loci.structure.models.map(m => m.label).join(', ') case 'element-loci': const e = loci.elements[0] if (e) {