Browse Source

repr marker and label fixes

Alexander Rose 5 years ago
parent
commit
6bbf12a660

+ 3 - 5
src/mol-repr/shape/loci/distance.ts

@@ -46,8 +46,8 @@ const TextParams = {
 type TextParams = typeof TextParams
 
 const DistanceVisuals = {
-    'lines': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<DistanceData, LineParams>) => ShapeRepresentation(getLinesShape, Lines.Utils),
-    'text': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<DistanceData, TextParams>) => ShapeRepresentation(getTextShape, Text.Utils),
+    'lines': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<DistanceData, LineParams>) => ShapeRepresentation(getLinesShape, Lines.Utils, { modifyState: s => ({ ...s, markerActions: MarkerActions.Highlighting }) }),
+    'text': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<DistanceData, TextParams>) => ShapeRepresentation(getTextShape, Text.Utils, { modifyState: s => ({ ...s, pickable: false }) }),
 }
 
 export const DistanceParams = {
@@ -142,7 +142,5 @@ function getTextShape(ctx: RuntimeContext, data: DistanceData, props: DistancePr
 
 export type DistanceRepresentation = Representation<DistanceData, DistanceParams>
 export function DistanceRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter<DistanceData, DistanceParams>): DistanceRepresentation {
-    const repr = Representation.createMulti('Distance', ctx, getParams, Representation.StateBuilder, DistanceVisuals as unknown as Representation.Def<DistanceData, DistanceParams>)
-    repr.setState({ markerActions: MarkerActions.Highlighting })
-    return repr
+    return Representation.createMulti('Distance', ctx, getParams, Representation.StateBuilder, DistanceVisuals as unknown as Representation.Def<DistanceData, DistanceParams>)
 }

+ 1 - 1
src/mol-repr/shape/loci/label.ts

@@ -30,7 +30,7 @@ const TextParams = {
 type TextParams = typeof TextParams
 
 const LabelVisuals = {
-    'text': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<LabelData, TextParams>) => ShapeRepresentation(getTextShape, Text.Utils),
+    'text': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<LabelData, TextParams>) => ShapeRepresentation(getTextShape, Text.Utils, { modifyState: s => ({ ...s, pickable: false }) }),
 }
 
 export const LabelParams = {

+ 4 - 1
src/mol-repr/structure/representation/label.ts

@@ -10,6 +10,7 @@ import { Representation, RepresentationParamsGetter, RepresentationContext } fro
 import { ThemeRegistryContext } from '../../../mol-theme/theme';
 import { Structure } from '../../../mol-model/structure';
 import { LabelTextVisual, LabelTextParams } from '../visual/label-text';
+import { MarkerAction } from '../../../mol-util/marker-action';
 
 const LabelVisuals = {
     'label-text': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, LabelTextParams>) => ComplexRepresentation('Label text', ctx, getParams, LabelTextVisual),
@@ -26,7 +27,9 @@ export function getLabelParams(ctx: ThemeRegistryContext, structure: Structure)
 
 export type LabelRepresentation = StructureRepresentation<LabelParams>
 export function LabelRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, LabelParams>): LabelRepresentation {
-    return Representation.createMulti('Label', ctx, getParams, StructureRepresentationStateBuilder, LabelVisuals as unknown as Representation.Def<Structure, LabelParams>)
+    const repr = Representation.createMulti('Label', ctx, getParams, StructureRepresentationStateBuilder, LabelVisuals as unknown as Representation.Def<Structure, LabelParams>)
+    repr.setState({ pickable: false, markerActions: MarkerAction.None })
+    return repr
 }
 
 export const LabelRepresentationProvider: StructureRepresentationProvider<LabelParams> = {

+ 6 - 3
src/mol-repr/structure/visual/label-text.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  * @author David Sehnal <david.sehnal@gmail.com>
@@ -111,6 +111,7 @@ function createResidueText(ctx: VisualContext, structure: Structure, theme: Them
         l.element = unit.elements[0]
 
         const residueIndex = unit.model.atomicHierarchy.residueAtomSegments.index;
+        const groupOffset = cumulativeUnitElementCount[i]
 
         let j = 0, jl = elements.length;
         while (j < jl) {
@@ -136,7 +137,7 @@ function createResidueText(ctx: VisualContext, structure: Structure, theme: Them
             const compId = label_comp_id(l)
 
             const text = `${compId} ${authSeqId}`
-            builder.add(text, center[0], center[1], center[2], radius, residueScale, cumulativeUnitElementCount[i])
+            builder.add(text, center[0], center[1], center[2], radius, residueScale, groupOffset + start)
         }
     }
 
@@ -162,13 +163,15 @@ function createElementText(ctx: VisualContext, structure: Structure, theme: Them
         const { elements } = unit
         l.unit = unit
 
+        const groupOffset = cumulativeUnitElementCount[i]
+
         for (let j = 0, _j = elements.length; j < _j; j++) {
             l.element = elements[j];
             pos(l.element, tmpVec);
             const atomId = label_atom_id(l)
             const altId = label_alt_id(l)
             const text = altId ? `${atomId}%${altId}` : atomId
-            builder.add(text, tmpVec[0], tmpVec[1], tmpVec[2], sizeTheme.size(l), elementScale, cumulativeUnitElementCount[i])
+            builder.add(text, tmpVec[0], tmpVec[1], tmpVec[2], sizeTheme.size(l), elementScale, groupOffset + j)
         }
     }