فهرست منبع

support EveryLoci in StructureRepresentation.mark

Alexander Rose 5 سال پیش
والد
کامیت
53223bc72b
3فایلهای تغییر یافته به همراه38 افزوده شده و 23 حذف شده
  1. 11 6
      src/mol-repr/structure/complex-representation.ts
  2. 11 6
      src/mol-repr/structure/units-representation.ts
  3. 16 11
      src/mol-repr/visual.ts

+ 11 - 6
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
     }
 

+ 11 - 6
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
         })

+ 16 - 11
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)