Skip to content
Snippets Groups Projects
Select Git revision
  • 6f4696534419fc53e7d6a872a1128fa7be39a8fb
  • 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

api-web.ts

Blame
  • backbone.ts 1.86 KiB
    /**
     * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    import { StructureRepresentation, StructureUnitsRepresentation } from '.';
    import { PickingId } from '../../util/picking';
    import { Structure } from 'mol-model/structure';
    import { Task } from 'mol-task';
    import { Loci } from 'mol-model/loci';
    import { MarkerAction } from '../../util/marker-data';
    import { PolymerBackboneVisual, DefaultPolymerBackboneProps } from './visual/polymer-backbone-cylinder';
    
    export const DefaultBackboneProps = {
        ...DefaultPolymerBackboneProps
    }
    export type BackboneProps = Partial<typeof DefaultBackboneProps>
    
    export function BackboneRepresentation(): StructureRepresentation<BackboneProps> {
        const traceRepr = StructureUnitsRepresentation(PolymerBackboneVisual)
    
        return {
            get renderObjects() {
                return [ ...traceRepr.renderObjects ]
            },
            get props() {
                return { ...traceRepr.props }
            },
            create: (structure: Structure, props: BackboneProps = {} as BackboneProps) => {
                const p = Object.assign({}, DefaultBackboneProps, props)
                return Task.create('BackboneRepresentation', async ctx => {
                    await traceRepr.create(structure, p).runInContext(ctx)
                })
            },
            update: (props: BackboneProps) => {
                const p = Object.assign({}, props)
                return Task.create('Updating BackboneRepresentation', async ctx => {
                    await traceRepr.update(p).runInContext(ctx)
                })
            },
            getLoci: (pickingId: PickingId) => {
                return traceRepr.getLoci(pickingId)
            },
            mark: (loci: Loci, action: MarkerAction) => {
                traceRepr.mark(loci, action)
            },
            destroy() {
                traceRepr.destroy()
            }
        }
    }