diff --git a/src/mol-model-props/rcsb/representations/assembly-symmetry-axes.ts b/src/mol-model-props/rcsb/representations/assembly-symmetry-axes.ts index d3f8c3816d120538cb8c55f7e0625cdeadf04af7..88b7fa39bd529b05b0118ee68625917756db8751 100644 --- a/src/mol-model-props/rcsb/representations/assembly-symmetry-axes.ts +++ b/src/mol-model-props/rcsb/representations/assembly-symmetry-axes.ts @@ -54,7 +54,8 @@ export const AssemblySymmetryAxesRepresentationProvider: StructureRepresentation getParams: getAssemblySymmetryAxesParams, defaultValues: PD.getDefaultValues(AssemblySymmetryAxesParams), defaultColorTheme: 'uniform', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => AssemblySymmetry.get(structure.models[0]) !== undefined } // diff --git a/src/mol-repr/representation.ts b/src/mol-repr/representation.ts index 2926beefdb7d70336a539749e86ee0abf05d29e6..638d6f913fe39ad1d86afb387e0f54f5e05c5a0f 100644 --- a/src/mol-repr/representation.ts +++ b/src/mol-repr/representation.ts @@ -46,6 +46,7 @@ export interface RepresentationProvider<D, P extends PD.Params, S extends Repres readonly defaultValues: PD.Values<P> readonly defaultColorTheme: string readonly defaultSizeTheme: string + readonly isApplicable: (data: D) => boolean } export namespace RepresentationProvider { @@ -66,15 +67,17 @@ export const EmptyRepresentationProvider = { defaultValues: {} } +function getTypes(list: { name: string, provider: RepresentationProvider<any, any, any> }[]) { + return list.map(e => [e.name, e.provider.label] as [string, string]); +} + export class RepresentationRegistry<D, S extends Representation.State> { private _list: { name: string, provider: RepresentationProvider<D, any, any> }[] = [] private _map = new Map<string, RepresentationProvider<D, any, any>>() private _name = new Map<RepresentationProvider<D, any, any>, string>() get default() { return this._list[0]; } - get types(): [string, string][] { - return this._list.map(e => [e.name, e.provider.label] as [string, string]); - } + get types(): [string, string][] { return getTypes(this._list) } constructor() {}; @@ -105,6 +108,14 @@ export class RepresentationRegistry<D, S extends Representation.State> { get list() { return this._list } + + getApplicableList(data: D) { + return this._list.filter(e => e.provider.isApplicable(data)); + } + + getApplicableTypes(data: D) { + return getTypes(this.getApplicableList(data)) + } } // diff --git a/src/mol-repr/structure/representation/ball-and-stick.ts b/src/mol-repr/structure/representation/ball-and-stick.ts index 324fb6eff2e7e26e03541f09bc5e9cb56a6e6a26..570973184bcc913afbb9a7848f32b9bbbee8078f 100644 --- a/src/mol-repr/structure/representation/ball-and-stick.ts +++ b/src/mol-repr/structure/representation/ball-and-stick.ts @@ -50,5 +50,6 @@ export const BallAndStickRepresentationProvider: StructureRepresentationProvider getParams: getBallAndStickParams, defaultValues: PD.getDefaultValues(BallAndStickParams), defaultColorTheme: 'element-symbol', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.elementCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/carbohydrate.ts b/src/mol-repr/structure/representation/carbohydrate.ts index a36b8e7ec88696c6ce50cc36d6cb0ccad6078cb2..ad1af619aa8b1af6a2109cc552862b96e990c97d 100644 --- a/src/mol-repr/structure/representation/carbohydrate.ts +++ b/src/mol-repr/structure/representation/carbohydrate.ts @@ -45,5 +45,6 @@ export const CarbohydrateRepresentationProvider: StructureRepresentationProvider getParams: getCarbohydrateParams, defaultValues: PD.getDefaultValues(CarbohydrateParams), defaultColorTheme: 'carbohydrate-symbol', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.carbohydrates.elements.length > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/cartoon.ts b/src/mol-repr/structure/representation/cartoon.ts index e315ea78a6e657b1480dff8da795b2e2cbe00b9d..66df27a1f7120e0a158d8a5f2ec8c60baae01da3 100644 --- a/src/mol-repr/structure/representation/cartoon.ts +++ b/src/mol-repr/structure/representation/cartoon.ts @@ -62,5 +62,6 @@ export const CartoonRepresentationProvider: StructureRepresentationProvider<Cart getParams: getCartoonParams, defaultValues: PD.getDefaultValues(CartoonParams), defaultColorTheme: 'polymer-id', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.polymerResidueCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/distance-restraint.ts b/src/mol-repr/structure/representation/distance-restraint.ts index 40788e2c94a055bee7e33249254effd71bb84052..045d5ae9dfd5ce21bdd8d398c3ed4c1cec306230 100644 --- a/src/mol-repr/structure/representation/distance-restraint.ts +++ b/src/mol-repr/structure/representation/distance-restraint.ts @@ -38,5 +38,6 @@ export const DistanceRestraintRepresentationProvider: StructureRepresentationPro getParams: getDistanceRestraintParams, defaultValues: PD.getDefaultValues(DistanceRestraintParams), defaultColorTheme: 'cross-link', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.crossLinkRestraints.count > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/gaussian-surface.ts b/src/mol-repr/structure/representation/gaussian-surface.ts index 41711eeb7a1b4a69bfba893005b6cf9c701af832..556ec327107888065780162f18b78ea343fe189c 100644 --- a/src/mol-repr/structure/representation/gaussian-surface.ts +++ b/src/mol-repr/structure/representation/gaussian-surface.ts @@ -43,5 +43,6 @@ export const GaussianSurfaceRepresentationProvider: StructureRepresentationProvi getParams: getGaussianSurfaceParams, defaultValues: PD.getDefaultValues(GaussianSurfaceParams), defaultColorTheme: 'polymer-id', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.elementCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/gaussian-volume.ts b/src/mol-repr/structure/representation/gaussian-volume.ts index caf0913b437f376f686cc405022109504b8f6230..ef661a587c5770a520a4f232d31a4c25ac25d62c 100644 --- a/src/mol-repr/structure/representation/gaussian-volume.ts +++ b/src/mol-repr/structure/representation/gaussian-volume.ts @@ -35,5 +35,6 @@ export const GaussianVolumeRepresentationProvider: StructureRepresentationProvid getParams: getGaussianVolumeParams, defaultValues: PD.getDefaultValues(GaussianVolumeParams), defaultColorTheme: 'polymer-id', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.elementCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/molecular-surface.ts b/src/mol-repr/structure/representation/molecular-surface.ts index 2a0c6ecc40085ade4f64e81b8a7d64d09345de3e..6bac839151e0c25301b27aef9e5ab0ed6bdf4ed1 100644 --- a/src/mol-repr/structure/representation/molecular-surface.ts +++ b/src/mol-repr/structure/representation/molecular-surface.ts @@ -39,5 +39,6 @@ export const MolecularSurfaceRepresentationProvider: StructureRepresentationProv getParams: getMolecularSurfaceParams, defaultValues: PD.getDefaultValues(MolecularSurfaceParams), defaultColorTheme: 'polymer-id', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (structure: Structure) => structure.elementCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/point.ts b/src/mol-repr/structure/representation/point.ts index 64157d4c9283ce4eedc63d85bf1c9c7e74566495..c9aec29132cbc0136ca0b88d925b1f398ac1b0e1 100644 --- a/src/mol-repr/structure/representation/point.ts +++ b/src/mol-repr/structure/representation/point.ts @@ -38,5 +38,6 @@ export const PointRepresentationProvider: StructureRepresentationProvider<PointP getParams: getPointParams, defaultValues: PD.getDefaultValues(PointParams), defaultColorTheme: 'element-symbol', - defaultSizeTheme: 'physical' + defaultSizeTheme: 'physical', + isApplicable: (structure: Structure) => structure.elementCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/putty.ts b/src/mol-repr/structure/representation/putty.ts index 4623077e4f89c702ecb65f4dd49ad912d2799829..1c5c2106b62d5e282bb95da145c8f5459ec774ad 100644 --- a/src/mol-repr/structure/representation/putty.ts +++ b/src/mol-repr/structure/representation/putty.ts @@ -52,5 +52,6 @@ export const PuttyRepresentationProvider: StructureRepresentationProvider<PuttyP getParams: getPuttyParams, defaultValues: PD.getDefaultValues(PuttyParams), defaultColorTheme: 'polymer-id', - defaultSizeTheme: 'uncertainty' + defaultSizeTheme: 'uncertainty', + isApplicable: (structure: Structure) => structure.polymerResidueCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/structure/representation/spacefill.ts b/src/mol-repr/structure/representation/spacefill.ts index 91223e3a7561308895fc06127c9676e6ad0f130c..e1fbcc1624fb856534c758a726aa80cbc706b7be 100644 --- a/src/mol-repr/structure/representation/spacefill.ts +++ b/src/mol-repr/structure/representation/spacefill.ts @@ -38,5 +38,6 @@ export const SpacefillRepresentationProvider: StructureRepresentationProvider<Sp getParams: getSpacefillParams, defaultValues: PD.getDefaultValues(SpacefillParams), defaultColorTheme: 'element-symbol', - defaultSizeTheme: 'physical' + defaultSizeTheme: 'physical', + isApplicable: (structure: Structure) => structure.elementCount > 0 } \ No newline at end of file diff --git a/src/mol-repr/volume/direct-volume.ts b/src/mol-repr/volume/direct-volume.ts index 6d223ada5d419aa0d5385846ec69988e7eca65c4..8aa809c6beb041497bf01fae9e585495a57d1d7d 100644 --- a/src/mol-repr/volume/direct-volume.ts +++ b/src/mol-repr/volume/direct-volume.ts @@ -187,5 +187,6 @@ export const DirectVolumeRepresentationProvider: VolumeRepresentationProvider<Di getParams: getDirectVolumeParams, defaultValues: PD.getDefaultValues(DirectVolumeParams), defaultColorTheme: 'uniform', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (volume: VolumeData) => volume.data.data.length > 0 } \ No newline at end of file diff --git a/src/mol-repr/volume/isosurface.ts b/src/mol-repr/volume/isosurface.ts index ce877d67d56cc21f4cdd0f027ef967c0d09e5489..46d9aabed91a0c6f789cdf90b2e2b307248b5896 100644 --- a/src/mol-repr/volume/isosurface.ts +++ b/src/mol-repr/volume/isosurface.ts @@ -171,5 +171,6 @@ export const IsosurfaceRepresentationProvider: VolumeRepresentationProvider<Isos getParams: getIsosurfaceParams, defaultValues: PD.getDefaultValues(IsosurfaceParams), defaultColorTheme: 'uniform', - defaultSizeTheme: 'uniform' + defaultSizeTheme: 'uniform', + isApplicable: (volume: VolumeData) => volume.data.data.length > 0 } \ No newline at end of file