Skip to content
Snippets Groups Projects
Select Git revision
  • 3dda801cac360441ba8ad24bf6d40fae97765c09
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

bounding-sphere-helper.ts

Blame
  • ball-and-stick.ts 3.26 KiB
    /**
     * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    import { ElementSphereVisual, ElementSphereParams } from '../visual/element-sphere';
    import { IntraUnitLinkVisual, IntraUnitLinkParams } from '../visual/intra-unit-link-cylinder';
    import { InterUnitLinkVisual, InterUnitLinkParams } from '../visual/inter-unit-link-cylinder';
    import { ParamDefinition as PD } from 'mol-util/param-definition';
    import { UnitsRepresentation } from '../units-representation';
    import { ComplexRepresentation } from '../complex-representation';
    import { StructureRepresentation, StructureRepresentationProvider } from '../representation';
    import { Representation, RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation';
    import { ThemeRegistryContext } from 'mol-theme/theme';
    import { Structure } from 'mol-model/structure';
    import { UnitKind, UnitKindOptions } from '../visual/util/common';
    
    const BallAndStickVisuals = {
        'element-sphere': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, ElementSphereParams>) => UnitsRepresentation('Element sphere mesh', ctx, getParams, ElementSphereVisual),
        'intra-link': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, IntraUnitLinkParams>) => UnitsRepresentation('Intra-unit link cylinder', ctx, getParams, IntraUnitLinkVisual),
        'inter-link': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, InterUnitLinkParams>) => ComplexRepresentation('Inter-unit link cylinder', ctx, getParams, InterUnitLinkVisual),
    }
    type BallAndStickVisualName = keyof typeof BallAndStickVisuals
    const BallAndStickVisualOptions = Object.keys(BallAndStickVisuals).map(name => [name, name] as [BallAndStickVisualName, string])
    
    export const BallAndStickParams = {
        ...ElementSphereParams,
        ...IntraUnitLinkParams,
        ...InterUnitLinkParams,
        unitKinds: PD.MultiSelect<UnitKind>(['atomic'], UnitKindOptions),
        sizeFactor: PD.Numeric(0.3, { min: 0.01, max: 10, step: 0.01 }),
        sizeAspectRatio: PD.Numeric(2/3, { min: 0.01, max: 3, step: 0.01 }),
        visuals: PD.MultiSelect<BallAndStickVisualName>(['element-sphere', 'intra-link', 'inter-link'], BallAndStickVisualOptions),
    }
    export type BallAndStickParams = typeof BallAndStickParams
    export function getBallAndStickParams(ctx: ThemeRegistryContext, structure: Structure) {
        return PD.clone(BallAndStickParams)
    }
    
    export type BallAndStickRepresentation = StructureRepresentation<BallAndStickParams>
    export function BallAndStickRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, BallAndStickParams>): BallAndStickRepresentation {
        return Representation.createMulti('Ball & Stick', ctx, getParams, BallAndStickVisuals as unknown as Representation.Def<Structure, BallAndStickParams>)
    }
    
    export const BallAndStickRepresentationProvider: StructureRepresentationProvider<BallAndStickParams> = {
        label: 'Ball & Stick',
        description: 'Displays atoms as spheres and bonds as cylinders.',
        factory: BallAndStickRepresentation,
        getParams: getBallAndStickParams,
        defaultValues: PD.getDefaultValues(BallAndStickParams),
        defaultColorTheme: 'element-symbol',
        defaultSizeTheme: 'uniform'
    }