From 0bf32148afd93a645b44dca6d81e9779e85b4300 Mon Sep 17 00:00:00 2001 From: David Sehnal <dsehnal@users.noreply.github.com> Date: Mon, 19 Dec 2022 23:10:40 +0100 Subject: [PATCH] Viewer setting for volumes and segmentations (#673) --- src/apps/viewer/app.ts | 4 +++- src/extensions/volumes-and-segmentations/entry-root.ts | 6 +++--- src/extensions/volumes-and-segmentations/index.ts | 6 +++--- src/extensions/volumes-and-segmentations/volseg-api/api.ts | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/apps/viewer/app.ts b/src/apps/viewer/app.ts index 76158c575..cdc4c46de 100644 --- a/src/apps/viewer/app.ts +++ b/src/apps/viewer/app.ts @@ -9,7 +9,7 @@ import { ANVILMembraneOrientation } from '../../extensions/anvil/behavior'; import { CellPack } from '../../extensions/cellpack'; import { DnatcoConfalPyramids } from '../../extensions/dnatco'; import { G3DFormat, G3dProvider } from '../../extensions/g3d/format'; -import { Volseg } from '../../extensions/volumes-and-segmentations'; +import { Volseg, VolsegVolumeServerConfig } from '../../extensions/volumes-and-segmentations'; import { GeometryExport } from '../../extensions/geo-export'; import { MAQualityAssessment } from '../../extensions/model-archive/quality-assessment/behavior'; import { QualityAssessmentPLDDTPreset, QualityAssessmentQmeanPreset } from '../../extensions/model-archive/quality-assessment/behavior'; @@ -107,6 +107,7 @@ const DefaultViewerOptions = { pdbProvider: PluginConfig.Download.DefaultPdbProvider.defaultValue, emdbProvider: PluginConfig.Download.DefaultEmdbProvider.defaultValue, saccharideCompIdMapType: 'default' as SaccharideCompIdMapType, + volumesAndSegmentationsDefaultServer: VolsegVolumeServerConfig.DefaultServer.defaultValue, }; type ViewerOptions = typeof DefaultViewerOptions; @@ -181,6 +182,7 @@ export class Viewer { [PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider], [PluginConfig.Structure.DefaultRepresentationPreset, ViewerAutoPreset.id], [PluginConfig.Structure.SaccharideCompIdMapType, o.saccharideCompIdMapType], + [VolsegVolumeServerConfig.DefaultServer, o.volumesAndSegmentationsDefaultServer], ] }; diff --git a/src/extensions/volumes-and-segmentations/entry-root.ts b/src/extensions/volumes-and-segmentations/entry-root.ts index b0a63b41a..b7b83f072 100644 --- a/src/extensions/volumes-and-segmentations/entry-root.ts +++ b/src/extensions/volumes-and-segmentations/entry-root.ts @@ -20,7 +20,7 @@ import { shallowEqualObjects } from '../../mol-util'; import { ParamDefinition } from '../../mol-util/param-definition'; import { MeshlistData } from '../meshes/mesh-extension'; -import { DEFAULT_VOLUME_SERVER_V2, VolumeApiV2 } from './volseg-api/api'; +import { DEFAULT_VOLSEG_SERVER, VolumeApiV2 } from './volseg-api/api'; import { Segment } from './volseg-api/data'; import { MetadataWrapper } from './volseg-api/utils'; import { VolsegMeshSegmentationData } from './entry-meshes'; @@ -48,7 +48,7 @@ export type Source = Choice.Values<typeof SourceChoice>; export function createLoadVolsegParams(plugin?: PluginContext, entrylists: { [source: string]: string[] } = {}) { - const defaultVolumeServer = plugin?.config.get(VolsegVolumeServerConfig.DefaultServer) ?? DEFAULT_VOLUME_SERVER_V2; + const defaultVolumeServer = plugin?.config.get(VolsegVolumeServerConfig.DefaultServer) ?? DEFAULT_VOLSEG_SERVER; return { serverUrl: ParamDefinition.Text(defaultVolumeServer), source: ParamDefinition.Mapped(SourceChoice.values[0], SourceChoice.options, src => entryParam(entrylists[src])), @@ -65,7 +65,7 @@ function entryParam(entries: string[] = []) { type LoadVolsegParamValues = ParamDefinition.Values<ReturnType<typeof createLoadVolsegParams>>; export function createVolsegEntryParams(plugin?: PluginContext) { - const defaultVolumeServer = plugin?.config.get(VolsegVolumeServerConfig.DefaultServer) ?? DEFAULT_VOLUME_SERVER_V2; + const defaultVolumeServer = plugin?.config.get(VolsegVolumeServerConfig.DefaultServer) ?? DEFAULT_VOLSEG_SERVER; return { serverUrl: ParamDefinition.Text(defaultVolumeServer), source: SourceChoice.PDSelect(), diff --git a/src/extensions/volumes-and-segmentations/index.ts b/src/extensions/volumes-and-segmentations/index.ts index 17046dd0b..8f66d7ed1 100644 --- a/src/extensions/volumes-and-segmentations/index.ts +++ b/src/extensions/volumes-and-segmentations/index.ts @@ -10,7 +10,7 @@ import { PluginConfigItem } from '../../mol-plugin/config'; import { PluginContext } from '../../mol-plugin/context'; import { StateAction } from '../../mol-state'; import { Task } from '../../mol-task'; -import { DEFAULT_VOLUME_SERVER_V2, VolumeApiV2 } from './volseg-api/api'; +import { DEFAULT_VOLSEG_SERVER, VolumeApiV2 } from './volseg-api/api'; import { VolsegEntryData, VolsegEntryParamValues, createLoadVolsegParams } from './entry-root'; import { VolsegGlobalState } from './global-state'; @@ -23,7 +23,7 @@ const DEBUGGING = window.location.hostname === 'localhost'; export const VolsegVolumeServerConfig = { // DefaultServer: new PluginConfigItem('volseg-volume-server', DEFAULT_VOLUME_SERVER_V2), - DefaultServer: new PluginConfigItem('volseg-volume-server', DEBUGGING ? 'http://localhost:9000/v2' : DEFAULT_VOLUME_SERVER_V2), + DefaultServer: new PluginConfigItem('volseg-volume-server', DEBUGGING ? 'http://localhost:9000/v2' : DEFAULT_VOLSEG_SERVER), }; @@ -57,7 +57,7 @@ export const Volseg = PluginBehavior.create<{ autoAttach: boolean, showTooltip: this.ctx.customStructureControls.delete('volseg'); } private async initializeEntryLists() { - const apiUrl = this.ctx.config.get(VolsegVolumeServerConfig.DefaultServer) ?? DEFAULT_VOLUME_SERVER_V2; + const apiUrl = this.ctx.config.get(VolsegVolumeServerConfig.DefaultServer) ?? DEFAULT_VOLSEG_SERVER; const api = new VolumeApiV2(apiUrl); const entryLists = await api.getEntryList(10 ** 6); Object.values(entryLists).forEach(l => l.sort()); diff --git a/src/extensions/volumes-and-segmentations/volseg-api/api.ts b/src/extensions/volumes-and-segmentations/volseg-api/api.ts index c1be88335..930df54e8 100644 --- a/src/extensions/volumes-and-segmentations/volseg-api/api.ts +++ b/src/extensions/volumes-and-segmentations/volseg-api/api.ts @@ -7,13 +7,13 @@ import { type Metadata } from './data'; -export const DEFAULT_VOLUME_SERVER_V2 = 'https://molstarvolseg.ncbr.muni.cz/v2'; +export const DEFAULT_VOLSEG_SERVER = 'https://molstarvolseg.ncbr.muni.cz/v2'; export class VolumeApiV2 { public volumeServerUrl: string; - public constructor(volumeServerUrl: string = DEFAULT_VOLUME_SERVER_V2) { + public constructor(volumeServerUrl: string = DEFAULT_VOLSEG_SERVER) { this.volumeServerUrl = volumeServerUrl.replace(/\/$/, ''); // trim trailing slash } -- GitLab