diff --git a/src/mol-repr/structure/complex-representation.ts b/src/mol-repr/structure/complex-representation.ts index cfe563c8cfd6e59acdf91d1f9706d793a5fc000f..93f3b909e524e90c655b44abf67f2ecb9867d140 100644 --- a/src/mol-repr/structure/complex-representation.ts +++ b/src/mol-repr/structure/complex-representation.ts @@ -14,7 +14,7 @@ import { getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-obj import { createEmptyTheme, Theme } from '../../mol-theme/theme'; import { Task } from '../../mol-task'; import { PickingId } from '../../mol-geo/geometry/picking'; -import { EmptyLoci, Loci } from '../../mol-model/loci'; +import { EmptyLoci, Loci, isEveryLoci } from '../../mol-model/loci'; import { MarkerAction } from '../../mol-util/marker-action'; import { Overpaint } from '../../mol-theme/overpaint'; @@ -57,11 +57,16 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, function mark(loci: Loci, action: MarkerAction) { if (!_structure) return false - if (!StructureElement.Loci.is(loci) && !Link.isLoci(loci)) return false - if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false - // Remap `loci` from equivalent structure to the current `_structure` - loci = Loci.remap(loci, _structure) - if (Loci.isEmpty(loci)) return false + if (StructureElement.Loci.is(loci) || Link.isLoci(loci)) { + if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false + // Remap `loci` from equivalent structure to the current `_structure` + loci = Loci.remap(loci, _structure) + if (Loci.isEmpty(loci)) return false + } else if (isEveryLoci(loci)) { + // pass through + } else { + return false + } return visual ? visual.mark(loci, action) : false } diff --git a/src/mol-repr/structure/units-representation.ts b/src/mol-repr/structure/units-representation.ts index 9e3e2577e248fc9e6e78b749026113ee2c5fb2a5..504c1069385d641a0d8d225d3610e59118c18e36 100644 --- a/src/mol-repr/structure/units-representation.ts +++ b/src/mol-repr/structure/units-representation.ts @@ -17,7 +17,7 @@ import { getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-obj import { createEmptyTheme, Theme } from '../../mol-theme/theme'; import { Task } from '../../mol-task'; import { PickingId } from '../../mol-geo/geometry/picking'; -import { Loci, EmptyLoci, isEmptyLoci } from '../../mol-model/loci'; +import { Loci, EmptyLoci, isEmptyLoci, isEveryLoci } from '../../mol-model/loci'; import { MarkerAction } from '../../mol-util/marker-action'; import { Overpaint } from '../../mol-theme/overpaint'; @@ -166,11 +166,16 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R function mark(loci: Loci, action: MarkerAction) { let changed = false if (!_structure) return false - if (!StructureElement.Loci.is(loci) && !Link.isLoci(loci)) return false - if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false - // Remap `loci` from equivalent structure to the current `_structure` - loci = Loci.remap(loci, _structure) - if (Loci.isEmpty(loci)) return false + if (StructureElement.Loci.is(loci) || Link.isLoci(loci)) { + if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false + // Remap `loci` from equivalent structure to the current `_structure` + loci = Loci.remap(loci, _structure) + if (Loci.isEmpty(loci)) return false + } else if (isEveryLoci(loci)) { + // pass through + } else { + return false + } visuals.forEach(({ visual }) => { changed = visual.mark(loci, action) || changed }) diff --git a/src/mol-repr/visual.ts b/src/mol-repr/visual.ts index 263dcaada8036131c5f521b7534bcc7c6a7353f5..8a838bbdd941d3563550736f4e08d0369320fa37 100644 --- a/src/mol-repr/visual.ts +++ b/src/mol-repr/visual.ts @@ -7,7 +7,7 @@ import { RuntimeContext } from '../mol-task' import { GraphicsRenderObject } from '../mol-gl/render-object' import { PickingId } from '../mol-geo/geometry/picking'; -import { Loci, isEmptyLoci } from '../mol-model/loci'; +import { Loci, isEmptyLoci, isEveryLoci } from '../mol-model/loci'; import { MarkerAction, applyMarkerAction } from '../mol-util/marker-action'; import { ParamDefinition as PD } from '../mol-util/param-definition'; import { WebGLContext } from '../mol-gl/webgl/context'; @@ -62,13 +62,16 @@ namespace Visual { export function mark(renderObject: GraphicsRenderObject | undefined, loci: Loci, action: MarkerAction, lociApply: LociApply) { if (!renderObject) return false - const { tMarker } = renderObject.values + const { tMarker, uGroupCount, instanceCount } = renderObject.values + const count = uGroupCount.ref.value * instanceCount.ref.value + const { array } = tMarker.ref.value - function apply(interval: Interval) { - return applyMarkerAction(tMarker.ref.value.array, interval, action) + let changed = false + if (isEveryLoci(loci)) { + changed = applyMarkerAction(array, Interval.ofLength(count), action) + } else if (!isEmptyLoci(loci)) { + changed = lociApply(loci, interval => applyMarkerAction(array, interval, action)) } - - const changed = lociApply(loci, apply) if (changed) ValueCell.update(tMarker, tMarker.ref.value) return changed } @@ -78,12 +81,13 @@ namespace Visual { const { tOverpaint, uGroupCount, instanceCount } = renderObject.values const count = uGroupCount.ref.value * instanceCount.ref.value + const { array } = tOverpaint.ref.value // ensure texture has right size createOverpaint(overpaint.layers.length ? count : 0, renderObject.values) // clear all if requested - if (clear) clearOverpaint(tOverpaint.ref.value.array, 0, count) + if (clear) clearOverpaint(array, 0, count) for (let i = 0, il = overpaint.layers.length; i < il; ++i) { const { loci, color, clear } = overpaint.layers[i] @@ -91,8 +95,8 @@ namespace Visual { const start = Interval.start(interval) const end = Interval.end(interval) return clear - ? clearOverpaint(tOverpaint.ref.value.array, start, end) - : applyOverpaintColor(tOverpaint.ref.value.array, start, end, color, overpaint.alpha) + ? clearOverpaint(array, start, end) + : applyOverpaintColor(array, start, end, color, overpaint.alpha) } lociApply(loci, apply) } @@ -104,6 +108,7 @@ namespace Visual { const { tTransparency, uGroupCount, instanceCount } = renderObject.values const count = uGroupCount.ref.value * instanceCount.ref.value + const { array } = tTransparency.ref.value const { loci, value, variant } = transparency @@ -111,12 +116,12 @@ namespace Visual { createTransparency(value && !isEmptyLoci(loci) ? count : 0, variant, renderObject.values) // clear if requested - if (clear) clearTransparency(tTransparency.ref.value.array, 0, count) + if (clear) clearTransparency(array, 0, count) const apply = (interval: Interval) => { const start = Interval.start(interval) const end = Interval.end(interval) - return applyTransparencyValue(tTransparency.ref.value.array, start, end, value) + return applyTransparencyValue(array, start, end, value) } lociApply(loci, apply)