molstar
Version:
A comprehensive macromolecular library.
59 lines (58 loc) • 3.4 kB
TypeScript
/**
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { RuntimeContext } from '../mol-task';
import { GraphicsRenderObject } from '../mol-gl/render-object';
import { PickingId } from '../mol-geo/geometry/picking';
import { Loci } from '../mol-model/loci';
import { MarkerAction, MarkerInfo } from '../mol-util/marker-action';
import { ParamDefinition as PD } from '../mol-util/param-definition';
import { WebGLContext } from '../mol-gl/webgl/context';
import { Theme } from '../mol-theme/theme';
import { Mat4 } from '../mol-math/linear-algebra';
import { Overpaint } from '../mol-theme/overpaint';
import { Interval } from '../mol-data/int';
import { Transparency } from '../mol-theme/transparency';
import { Clipping } from '../mol-theme/clipping';
export interface VisualContext {
readonly runtime: RuntimeContext;
readonly webgl?: WebGLContext;
}
export { Visual };
interface Visual<D, P extends PD.Params> {
/** Number of addressable groups in all instances of the visual */
readonly groupCount: number;
readonly renderObject: GraphicsRenderObject | undefined;
createOrUpdate: (ctx: VisualContext, theme: Theme, props: PD.Values<P>, data?: D) => Promise<void> | void;
getLoci: (pickingId: PickingId) => Loci;
mark: (loci: Loci, action: MarkerAction) => boolean;
setVisibility: (visible: boolean) => void;
setAlphaFactor: (alphaFactor: number) => void;
setPickable: (pickable: boolean) => void;
setColorOnly: (colorOnly: boolean) => void;
setTransform: (matrix?: Mat4, instanceMatrices?: Float32Array | null) => void;
setOverpaint: (overpaint: Overpaint) => void;
setTransparency: (transparency: Transparency) => void;
setClipping: (clipping: Clipping) => void;
destroy: () => void;
mustRecreate?: (data: D, props: PD.Values<P>, webgl?: WebGLContext) => boolean;
}
declare namespace Visual {
type LociApply = (loci: Loci, apply: (interval: Interval) => boolean, isMarking: boolean) => boolean;
function setVisibility(renderObject: GraphicsRenderObject | undefined, visible: boolean): void;
function setAlphaFactor(renderObject: GraphicsRenderObject | undefined, alphaFactor: number): void;
function setPickable(renderObject: GraphicsRenderObject | undefined, pickable: boolean): void;
function setColorOnly(renderObject: GraphicsRenderObject | undefined, colorOnly: boolean): void;
type PreviousMark = {
loci: Loci;
action: MarkerAction;
status: MarkerInfo['status'];
};
function mark(renderObject: GraphicsRenderObject | undefined, loci: Loci, action: MarkerAction, lociApply: LociApply, previous?: PreviousMark): boolean;
function setOverpaint(renderObject: GraphicsRenderObject | undefined, overpaint: Overpaint, lociApply: LociApply, clear: boolean): void;
function setTransparency(renderObject: GraphicsRenderObject | undefined, transparency: Transparency, lociApply: LociApply, clear: boolean): void;
function setClipping(renderObject: GraphicsRenderObject | undefined, clipping: Clipping, lociApply: LociApply, clear: boolean): void;
function setTransform(renderObject: GraphicsRenderObject | undefined, transform?: Mat4, instanceTransforms?: Float32Array | null): void;
}