Browse Source

StructureHierarchyManager.updateCurrent fix

David Sehnal 5 years ago
parent
commit
2168905c11
1 changed files with 8 additions and 24 deletions
  1. 8 24
      src/mol-plugin-state/manager/structure/hierarchy.ts

+ 8 - 24
src/mol-plugin-state/manager/structure/hierarchy.ts

@@ -24,7 +24,7 @@ export class StructureHierarchyManager extends PluginComponent {
         selection: {
             trajectories: [] as ReadonlyArray<TrajectoryRef>,
             models: [] as ReadonlyArray<ModelRef>,
-            structures: []  as ReadonlyArray<StructureRef>
+            structures: [] as ReadonlyArray<StructureRef>
         }
     }
 
@@ -120,28 +120,12 @@ export class StructureHierarchyManager extends PluginComponent {
 
         for (const t of hierarchy.trajectories) {
             if (set.has(t.cell.transform.ref)) trajectories.push(t);
-            for (const m of t.models) {
-                if (set.has(m.cell.transform.ref)) models.push(m);
-                for (const s of m.structures) {
-                    if (set.has(s.cell.transform.ref)) structures.push(s);
-                }
-            }
         }
-
-        // handle orphan models and structures (e.g. from CellPack Loader)
-        if (hierarchy.trajectories.length === 0) {
-            if (hierarchy.models.length > 0) {
-                for (const m of hierarchy.models) {
-                    if (set.has(m.cell.transform.ref)) models.push(m);
-                    for (const s of m.structures) {
-                        if (set.has(s.cell.transform.ref)) structures.push(s);
-                    }
-                }
-            } else if (hierarchy.structures.length > 0) {
-                for (const s of hierarchy.structures) {
-                    if (set.has(s.cell.transform.ref)) structures.push(s);
-                }
-            }
+        for (const m of hierarchy.models) {
+            if (set.has(m.cell.transform.ref)) models.push(m);
+        }
+        for (const s of hierarchy.structures) {
+            if (set.has(s.cell.transform.ref)) structures.push(s);
         }
 
         this._currentComponentGroups = void 0;
@@ -172,7 +156,7 @@ export class StructureHierarchyManager extends PluginComponent {
         }
     }
 
-    applyPreset<P = any, S = {}>(trajectories: ReadonlyArray<TrajectoryRef>, provider: TrajectoryHierarchyPresetProvider<P, S>, params?: P): Promise<any>  {
+    applyPreset<P = any, S = {}>(trajectories: ReadonlyArray<TrajectoryRef>, provider: TrajectoryHierarchyPresetProvider<P, S>, params?: P): Promise<any> {
         return this.plugin.dataTransaction(async () => {
             for (const t of trajectories) {
                 if (t.models.length > 0) {
@@ -194,7 +178,7 @@ export class StructureHierarchyManager extends PluginComponent {
             if (recreateRepresentation) {
                 await this.plugin.builders.structure.representation.applyPreset(s.cell.transform.ref, 'auto');
             }
-        }, { canUndo: 'Structure Type'})
+        }, { canUndo: 'Structure Type' })
     }
 
     async updateStructure(s: StructureRef, newParams: any) {