Skip to content
Snippets Groups Projects
Commit c5a99a7c authored by Alexander Rose's avatar Alexander Rose
Browse files

improved lociApply for whole structures

parent cfaf33d6
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,11 @@ export namespace Loci { ...@@ -54,7 +54,11 @@ export namespace Loci {
} }
export function isEmpty(loci: Loci) { export function isEmpty(loci: Loci) {
return size(loci) === 0 ? true : false return size(loci) === 0
}
export function isWholeStructure(loci: Loci) {
return size(loci) === loci.structure.elementCount
} }
export function size(loci: Loci) { export function size(loci: Loci) {
......
/** /**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ParamDefinition as PD } from '../../mol-util/param-definition';
import { StructureParams, StructureMeshParams, StructureDirectVolumeParams } from './representation'; import { StructureParams, StructureMeshParams, StructureDirectVolumeParams } from './representation';
import { Visual, VisualContext } from '../visual'; import { Visual, VisualContext } from '../visual';
import { Structure } from '../../mol-model/structure'; import { Structure, StructureElement } from '../../mol-model/structure';
import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry';
import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { LocationIterator } from '../../mol-geo/util/location-iterator';
import { Theme, createEmptyTheme } from '../../mol-theme/theme'; import { Theme, createEmptyTheme } from '../../mol-theme/theme';
...@@ -164,8 +164,17 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom ...@@ -164,8 +164,17 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom
if (newGeometry) geometry = newGeometry if (newGeometry) geometry = newGeometry
} }
function lociIsSuperset(loci: Loci) {
if (isEveryLoci(loci)) return true
if (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure)) return true
if (StructureElement.Loci.is(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure)) {
if (StructureElement.Loci.isWholeStructure(loci)) return true
}
return false
}
function lociApply(loci: Loci, apply: (interval: Interval) => boolean) { function lociApply(loci: Loci, apply: (interval: Interval) => boolean) {
if (isEveryLoci(loci) || (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure))) { if (lociIsSuperset(loci)) {
return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount)) return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount))
} else { } else {
return eachLocation(loci, currentStructure, apply) return eachLocation(loci, currentStructure, apply)
......
/** /**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ParamDefinition as PD } from '../../mol-util/param-definition';
import { Structure, Unit } from '../../mol-model/structure'; import { Structure, Unit, StructureElement } from '../../mol-model/structure';
import { RepresentationProps } from '../representation'; import { RepresentationProps } from '../representation';
import { Visual, VisualContext } from '../visual'; import { Visual, VisualContext } from '../visual';
import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry';
...@@ -214,8 +214,17 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry ...@@ -214,8 +214,17 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry
: createEmptyGeometry(geometry) : createEmptyGeometry(geometry)
} }
function lociIsSuperset(loci: Loci) {
if (isEveryLoci(loci)) return true
if (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructureGroup.structure)) return true
if (StructureElement.Loci.is(loci) && Structure.areRootsEquivalent(loci.structure, currentStructureGroup.structure)) {
if (StructureElement.Loci.isWholeStructure(loci)) return true
}
return false
}
function lociApply(loci: Loci, apply: (interval: Interval) => boolean) { function lociApply(loci: Loci, apply: (interval: Interval) => boolean) {
if (isEveryLoci(loci) || (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructureGroup.structure))) { if (lociIsSuperset(loci)) {
return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount)) return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount))
} else { } else {
return eachLocation(loci, currentStructureGroup, apply) return eachLocation(loci, currentStructureGroup, apply)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment