Browse Source

mol-plugin: better element loci highlight label

David Sehnal 5 years ago
parent
commit
1923289c51
2 changed files with 11 additions and 0 deletions
  1. 5 0
      src/mol-model/structure/structure/element/stats.ts
  2. 6 0
      src/mol-theme/label.ts

+ 5 - 0
src/mol-model/structure/structure/element/stats.ts

@@ -37,6 +37,11 @@ export namespace Stats {
         const { indices, unit } = element
         const { elements } = unit
         const size = OrderedSet.size(indices)
+
+        if (size > 0) {
+            Location.set(stats.firstElementLoc, unit, elements[OrderedSet.start(indices)])
+        }
+
         if (size === 1) {
             stats.elementCount += 1
             if (stats.elementCount === 1) {

+ 6 - 0
src/mol-theme/label.ts

@@ -65,6 +65,12 @@ export function structureElementStatsLabel(stats: StructureElement.Stats, counts
         const { unit } = stats.firstUnitLoc
         const granularity = (Unit.isAtomic(unit) && getResidueCount(unit) === 1) ? 'residue' : 'chain'
         return elementLabel(stats.firstUnitLoc, granularity)
+    } else if (!countsOnly) {
+        const label: string[] = [];
+        if (unitCount > 0) label.push(`${elementLabel(stats.firstElementLoc, 'chain')} [+ ${countLabel(unitCount - 1, 'other chain')}]`);
+        if (residueCount > 0) label.push(`${elementLabel(stats.firstElementLoc, 'residue')} [+ ${countLabel(residueCount - 1, 'other residue')}]`);
+        if (elementCount > 0) label.push(`${elementLabel(stats.firstElementLoc, 'element')} [+ ${countLabel(elementCount - 1, 'other element')}]`);
+        return label.join(', ')
     } else {
         const label: string[] = []
         if (unitCount > 0) label.push(countLabel(unitCount, 'Chain'))