diff --git a/molstar-extension/src/extensions/volumes-and-segmentations/index.ts b/molstar-extension/src/extensions/volumes-and-segmentations/index.ts index 36ed0ea5..e2fa064d 100644 --- a/molstar-extension/src/extensions/volumes-and-segmentations/index.ts +++ b/molstar-extension/src/extensions/volumes-and-segmentations/index.ts @@ -73,6 +73,10 @@ export async function findOrCreateVolsegEntry(entryId: string, source: string, p const nodes = plugin.state.data.selectQ(q => q.ofType(VolsegEntry)).map(cell => cell?.obj).filter(isDefined); const targetNode = nodes.find(n => n.data.entryId === entryId && n.data.source === source); debugger; + const globalStateNode = plugin.state.data.selectQ(q => q.ofType(VolsegGlobalState))[0]; + if (!globalStateNode) { + await plugin.state.data.build().toRoot().apply(VolsegGlobalStateFromRoot, {}, { state: { isGhost: !DEBUGGING } }).commit(); + } if (targetNode) { // TODO: return selector? // return targetNode; @@ -93,8 +97,9 @@ export async function findOrCreateVolsegEntry(entryId: string, source: string, p // source: SourceChoice.PDSelect(), // entryId: ParamDefinition.Text('emd-1832', { description: 'Entry identifier, including the source prefix, e.g. "emd-1832"' }), // }; - debugger; const entryNode = await plugin.state.data.build().toRoot().apply(VolsegEntryFromRoot, entryParams).commit(); + await plugin.state.data.build().to(entryNode).apply(VolsegStateFromEntry, {}, { state: { isGhost: !DEBUGGING } }).commit(); + debugger; return entryNode; } } diff --git a/molstar-extension/src/viewer/app.ts b/molstar-extension/src/viewer/app.ts index 47001cd7..06458fba 100644 --- a/molstar-extension/src/viewer/app.ts +++ b/molstar-extension/src/viewer/app.ts @@ -30,7 +30,7 @@ import { StateObjectRef } from 'molstar/lib/mol-state'; import { Color } from 'molstar/lib/mol-util/color'; import 'molstar/lib/mol-util/polyfill'; import { ObjectKeys } from 'molstar/lib/mol-util/type-helpers'; -import { Volseg } from '../extensions/volumes-and-segmentations'; +import { Volseg, findOrCreateVolsegEntry } from '../extensions/volumes-and-segmentations'; import { CVSXSpec } from '../extensions/cvsx-extension/behaviour'; import { loadCVSXFromAnything } from '../extensions/cvsx-extension'; @@ -195,6 +195,9 @@ export class Viewer { plugin.builders.structure.representation.registerPreset(ViewerAutoPreset); } }); + // const nn = await findOrCreateVolsegEntry('emd-1832', 'emdb', plugin) + // console.log(nn); + // debugger; return new Viewer(plugin); }