Przeglądaj źródła

Bundle.fromSubStructure

David Sehnal 5 lat temu
rodzic
commit
90268a9041

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

@@ -14,6 +14,7 @@ import { UnitIndex } from './element';
 import { Loci } from './loci';
 import Expression from '../../../../mol-script/language/expression';
 import { MolScriptBuilder as MS } from '../../../../mol-script/language/builder';
+import { StructureSelection } from '../../query';
 
 export interface BundleElement {
     /**
@@ -35,6 +36,10 @@ export interface Bundle {
 export namespace Bundle {
     export const Empty: Bundle = { hash: -1, elements: [] }
 
+    export function fromSubStructure(parent: Structure, structure: Structure) {
+        return fromLoci(StructureSelection.toLociWithSourceUnits(StructureSelection.Singletons(parent, structure)))
+    }
+
     export function fromLoci(loci: Loci): Bundle {
         const _elements: {
             unit: Unit

+ 2 - 2
src/mol-plugin-state/manager/structure/component.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Structure, StructureElement, StructureSelection } from '../../../mol-model/structure';
+import { Structure, StructureElement } from '../../../mol-model/structure';
 import { structureAreIntersecting, structureSubtract, structureUnion } from '../../../mol-model/structure/query/utils/structure-set';
 import { PluginContext } from '../../../mol-plugin/context';
 import { StateBuilder } from '../../../mol-state';
@@ -89,7 +89,7 @@ class StructureComponentManager {
         if (modified.elementCount === 0) {
             builder.delete(component.cell.transform.ref);
         } else {
-            const bundle = StructureElement.Bundle.fromLoci(StructureSelection.toLociWithSourceUnits(StructureSelection.Singletons(parent, modified)));
+            const bundle = StructureElement.Bundle.fromSubStructure(parent, modified);
             const params: StructureComponentParams = {
                 type: { name: 'bundle', params: bundle },
                 nullIfEmpty: true,