Explorar el Código

fix coloring of bonds via overpaint

Alexander Rose hace 4 años
padre
commit
850328be4e

+ 0 - 1
src/mol-plugin-ui/structure/superposition.tsx

@@ -241,7 +241,6 @@ export class SuperpositionControls extends PurePluginUIComponent<{}, Superpositi
     }
 
     get atomEntries() {
-        // TODO have stable order of structureEntries, independent of history order
         const structureEntries = new Map<Structure, StructureSelectionHistoryEntry[]>();
         const history = this.plugin.managers.structure.selection.additionsHistory;
 

+ 3 - 3
src/mol-repr/structure/complex-visual.ts

@@ -46,7 +46,7 @@ interface ComplexVisualBuilder<P extends StructureParams, G extends Geometry> {
     createGeometry(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): Promise<G> | G
     createLocationIterator(structure: Structure): LocationIterator
     getLoci(pickingId: PickingId, structure: Structure, id: number): Loci
-    eachLocation(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean): boolean,
+    eachLocation(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean, isMarking: boolean): boolean,
     setUpdateState(state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure): void
 }
 
@@ -173,11 +173,11 @@ export function ComplexVisual<G extends Geometry, P extends StructureParams & Ge
         return false;
     }
 
-    function lociApply(loci: Loci, apply: (interval: Interval) => boolean) {
+    function lociApply(loci: Loci, apply: (interval: Interval) => boolean, isMarking: boolean) {
         if (lociIsSuperset(loci)) {
             return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount));
         } else {
-            return eachLocation(loci, currentStructure, apply);
+            return eachLocation(loci, currentStructure, apply, isMarking);
         }
     }
 

+ 3 - 3
src/mol-repr/structure/units-visual.ts

@@ -54,7 +54,7 @@ interface UnitsVisualBuilder<P extends StructureParams, G extends Geometry> {
     createGeometry(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): Promise<G> | G
     createLocationIterator(structureGroup: StructureGroup): LocationIterator
     getLoci(pickingId: PickingId, structureGroup: StructureGroup, id: number): Loci
-    eachLocation(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean): boolean
+    eachLocation(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean, isMarking: boolean): boolean
     setUpdateState(state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructureGroup: StructureGroup, currentStructureGroup: StructureGroup): void
 }
 
@@ -224,11 +224,11 @@ export function UnitsVisual<G extends Geometry, P extends StructureParams & Geom
         return false;
     }
 
-    function lociApply(loci: Loci, apply: (interval: Interval) => boolean) {
+    function lociApply(loci: Loci, apply: (interval: Interval) => boolean, isMarking: boolean) {
         if (lociIsSuperset(loci)) {
             return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount));
         } else {
-            return eachLocation(loci, currentStructureGroup, apply);
+            return eachLocation(loci, currentStructureGroup, apply, isMarking);
         }
     }
 

+ 2 - 2
src/mol-repr/structure/visual/bond-inter-unit-cylinder.ts

@@ -155,7 +155,7 @@ function getBondLoci(pickingId: PickingId, structure: Structure, id: number) {
     return EmptyLoci;
 }
 
-function eachBond(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean) {
+function eachBond(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean, isMarking: boolean) {
     let changed = false;
     if (Bond.isLoci(loci)) {
         if (!Structure.areEquivalent(loci.structure, structure)) return false;
@@ -181,7 +181,7 @@ function eachBond(loci: Loci, structure: Structure, apply: (interval: Interval)
                     OrderedSet.forEach(e.indices, v => {
                         if (!b.connectedIndices.includes(v)) return;
                         b.getEdges(v).forEach(bi => {
-                            if (OrderedSet.has(otherLociIndices, bi.indexB)) {
+                            if (!isMarking || OrderedSet.has(otherLociIndices, bi.indexB)) {
                                 const idx = structure.interUnitBonds.getEdgeIndex(v, unit, bi.indexB, b.unitB);
                                 if (apply(Interval.ofSingleton(idx))) changed = true;
                             }

+ 2 - 2
src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts

@@ -154,7 +154,7 @@ function getBondLoci(pickingId: PickingId, structureGroup: StructureGroup, id: n
     return EmptyLoci;
 }
 
-function eachBond(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean) {
+function eachBond(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean, isMarking: boolean) {
     let changed = false;
     if (Bond.isLoci(loci)) {
         const { structure, group } = structureGroup;
@@ -183,7 +183,7 @@ function eachBond(loci: Loci, structureGroup: StructureGroup, apply: (interval:
                 const { offset, b } = unit.bonds;
                 OrderedSet.forEach(e.indices, v => {
                     for (let t = offset[v], _t = offset[v + 1]; t < _t; t++) {
-                        if (OrderedSet.has(e.indices, b[t])) {
+                        if (!isMarking || OrderedSet.has(e.indices, b[t])) {
                             if (apply(Interval.ofSingleton(unitIdx * groupCount + t))) changed = true;
                         }
                     }

+ 4 - 4
src/mol-repr/visual.ts

@@ -45,7 +45,7 @@ interface Visual<D, P extends PD.Params> {
     destroy: () => void
 }
 namespace Visual {
-    export type LociApply = (loci: Loci, apply: (interval: Interval) => boolean) => boolean
+    export type LociApply = (loci: Loci, apply: (interval: Interval) => boolean, isMarking: boolean) => boolean
 
     export function setVisibility(renderObject: GraphicsRenderObject | undefined, visible: boolean) {
         if (renderObject) renderObject.state.visible = visible;
@@ -70,7 +70,7 @@ namespace Visual {
         if (isEveryLoci(loci)) {
             changed = applyMarkerAction(array, Interval.ofLength(count), action);
         } else if (!isEmptyLoci(loci)) {
-            changed = lociApply(loci, interval => applyMarkerAction(array, interval, action));
+            changed = lociApply(loci, interval => applyMarkerAction(array, interval, action), true);
         }
         if (changed) ValueCell.update(tMarker, tMarker.ref.value);
         return changed;
@@ -98,7 +98,7 @@ namespace Visual {
                     ? clearOverpaint(array, start, end)
                     : applyOverpaintColor(array, start, end, color, overpaint.alpha);
             };
-            lociApply(loci, apply);
+            lociApply(loci, apply, false);
         }
         ValueCell.update(tOverpaint, tOverpaint.ref.value);
     }
@@ -123,7 +123,7 @@ namespace Visual {
             const end = Interval.end(interval);
             return applyTransparencyValue(array, start, end, value);
         };
-        lociApply(loci, apply);
+        lociApply(loci, apply, false);
 
         ValueCell.update(tTransparency, tTransparency.ref.value);
     }