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

support EveryLoci in StructureRepresentation.mark

parent a11a1fa0
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ import { getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-obj ...@@ -14,7 +14,7 @@ import { getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-obj
import { createEmptyTheme, Theme } from '../../mol-theme/theme'; import { createEmptyTheme, Theme } from '../../mol-theme/theme';
import { Task } from '../../mol-task'; import { Task } from '../../mol-task';
import { PickingId } from '../../mol-geo/geometry/picking'; 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 { MarkerAction } from '../../mol-util/marker-action';
import { Overpaint } from '../../mol-theme/overpaint'; import { Overpaint } from '../../mol-theme/overpaint';
...@@ -57,11 +57,16 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, ...@@ -57,11 +57,16 @@ export function ComplexRepresentation<P extends StructureParams>(label: string,
function mark(loci: Loci, action: MarkerAction) { function mark(loci: Loci, action: MarkerAction) {
if (!_structure) return false if (!_structure) return false
if (!StructureElement.Loci.is(loci) && !Link.isLoci(loci)) return false if (StructureElement.Loci.is(loci) || Link.isLoci(loci)) {
if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false
// Remap `loci` from equivalent structure to the current `_structure` // Remap `loci` from equivalent structure to the current `_structure`
loci = Loci.remap(loci, _structure) loci = Loci.remap(loci, _structure)
if (Loci.isEmpty(loci)) return false if (Loci.isEmpty(loci)) return false
} else if (isEveryLoci(loci)) {
// pass through
} else {
return false
}
return visual ? visual.mark(loci, action) : false return visual ? visual.mark(loci, action) : false
} }
......
...@@ -17,7 +17,7 @@ import { getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-obj ...@@ -17,7 +17,7 @@ import { getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-obj
import { createEmptyTheme, Theme } from '../../mol-theme/theme'; import { createEmptyTheme, Theme } from '../../mol-theme/theme';
import { Task } from '../../mol-task'; import { Task } from '../../mol-task';
import { PickingId } from '../../mol-geo/geometry/picking'; 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 { MarkerAction } from '../../mol-util/marker-action';
import { Overpaint } from '../../mol-theme/overpaint'; import { Overpaint } from '../../mol-theme/overpaint';
...@@ -166,11 +166,16 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R ...@@ -166,11 +166,16 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R
function mark(loci: Loci, action: MarkerAction) { function mark(loci: Loci, action: MarkerAction) {
let changed = false let changed = false
if (!_structure) return false if (!_structure) return false
if (!StructureElement.Loci.is(loci) && !Link.isLoci(loci)) return false if (StructureElement.Loci.is(loci) || Link.isLoci(loci)) {
if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false if (!Structure.areRootsEquivalent(loci.structure, _structure)) return false
// Remap `loci` from equivalent structure to the current `_structure` // Remap `loci` from equivalent structure to the current `_structure`
loci = Loci.remap(loci, _structure) loci = Loci.remap(loci, _structure)
if (Loci.isEmpty(loci)) return false if (Loci.isEmpty(loci)) return false
} else if (isEveryLoci(loci)) {
// pass through
} else {
return false
}
visuals.forEach(({ visual }) => { visuals.forEach(({ visual }) => {
changed = visual.mark(loci, action) || changed changed = visual.mark(loci, action) || changed
}) })
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import { RuntimeContext } from '../mol-task' import { RuntimeContext } from '../mol-task'
import { GraphicsRenderObject } from '../mol-gl/render-object' import { GraphicsRenderObject } from '../mol-gl/render-object'
import { PickingId } from '../mol-geo/geometry/picking'; 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 { MarkerAction, applyMarkerAction } from '../mol-util/marker-action';
import { ParamDefinition as PD } from '../mol-util/param-definition'; import { ParamDefinition as PD } from '../mol-util/param-definition';
import { WebGLContext } from '../mol-gl/webgl/context'; import { WebGLContext } from '../mol-gl/webgl/context';
...@@ -62,13 +62,16 @@ namespace Visual { ...@@ -62,13 +62,16 @@ namespace Visual {
export function mark(renderObject: GraphicsRenderObject | undefined, loci: Loci, action: MarkerAction, lociApply: LociApply) { export function mark(renderObject: GraphicsRenderObject | undefined, loci: Loci, action: MarkerAction, lociApply: LociApply) {
if (!renderObject) return false 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) { let changed = false
return applyMarkerAction(tMarker.ref.value.array, interval, action) 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) if (changed) ValueCell.update(tMarker, tMarker.ref.value)
return changed return changed
} }
...@@ -78,12 +81,13 @@ namespace Visual { ...@@ -78,12 +81,13 @@ namespace Visual {
const { tOverpaint, uGroupCount, instanceCount } = renderObject.values const { tOverpaint, uGroupCount, instanceCount } = renderObject.values
const count = uGroupCount.ref.value * instanceCount.ref.value const count = uGroupCount.ref.value * instanceCount.ref.value
const { array } = tOverpaint.ref.value
// ensure texture has right size // ensure texture has right size
createOverpaint(overpaint.layers.length ? count : 0, renderObject.values) createOverpaint(overpaint.layers.length ? count : 0, renderObject.values)
// clear all if requested // 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) { for (let i = 0, il = overpaint.layers.length; i < il; ++i) {
const { loci, color, clear } = overpaint.layers[i] const { loci, color, clear } = overpaint.layers[i]
...@@ -91,8 +95,8 @@ namespace Visual { ...@@ -91,8 +95,8 @@ namespace Visual {
const start = Interval.start(interval) const start = Interval.start(interval)
const end = Interval.end(interval) const end = Interval.end(interval)
return clear return clear
? clearOverpaint(tOverpaint.ref.value.array, start, end) ? clearOverpaint(array, start, end)
: applyOverpaintColor(tOverpaint.ref.value.array, start, end, color, overpaint.alpha) : applyOverpaintColor(array, start, end, color, overpaint.alpha)
} }
lociApply(loci, apply) lociApply(loci, apply)
} }
...@@ -104,6 +108,7 @@ namespace Visual { ...@@ -104,6 +108,7 @@ namespace Visual {
const { tTransparency, uGroupCount, instanceCount } = renderObject.values const { tTransparency, uGroupCount, instanceCount } = renderObject.values
const count = uGroupCount.ref.value * instanceCount.ref.value const count = uGroupCount.ref.value * instanceCount.ref.value
const { array } = tTransparency.ref.value
const { loci, value, variant } = transparency const { loci, value, variant } = transparency
...@@ -111,12 +116,12 @@ namespace Visual { ...@@ -111,12 +116,12 @@ namespace Visual {
createTransparency(value && !isEmptyLoci(loci) ? count : 0, variant, renderObject.values) createTransparency(value && !isEmptyLoci(loci) ? count : 0, variant, renderObject.values)
// clear if requested // clear if requested
if (clear) clearTransparency(tTransparency.ref.value.array, 0, count) if (clear) clearTransparency(array, 0, count)
const apply = (interval: Interval) => { const apply = (interval: Interval) => {
const start = Interval.start(interval) const start = Interval.start(interval)
const end = Interval.end(interval) const end = Interval.end(interval)
return applyTransparencyValue(tTransparency.ref.value.array, start, end, value) return applyTransparencyValue(array, start, end, value)
} }
lociApply(loci, apply) lociApply(loci, apply)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment