// Generated by dts-bundle-generator v9.5.1 export type ColorSpec = number | string | { r: number; g: number; b: number; a?: number; }; export interface BaseShapeData { position: [ number, number, number ]; orientation?: [ number, number, number, number ]; scale?: number; color?: ColorSpec; } export interface BaseShapeParameters { kind: string; parameters: { global: Partial; structure?: Array>; atom?: Array>; }; } export interface SphereData extends BaseShapeData { radius: number; } /** Parameters for a spherical shape */ export interface SphereParameters extends BaseShapeParameters { kind: "sphere"; } export interface EllipsoidData extends BaseShapeData { semiaxes: [ number, number, number ]; } /** Parameters for an ellipsoid */ export interface EllipsoidParameters extends BaseShapeParameters { kind: "ellipsoid"; } export interface CylinderData extends BaseShapeData { vector: [ number, number, number ]; radius?: number; } /** Parameters for an arrow shape */ export interface CylinderParameters extends BaseShapeParameters { kind: "cylinder"; } export interface ArrowData extends BaseShapeData { vector: [ number, number, number ]; baseRadius?: number; headRadius?: number; headLength?: number; } /** Parameters for an arrow shape */ export interface ArrowParameters extends BaseShapeParameters { kind: "arrow"; } export interface CustomShapeData extends BaseShapeData { vertices: [ number, number, number ][]; simplices: [ number, number, number ][]; } /** Parameters for a custom shape */ export interface CustomShapeParameters extends BaseShapeParameters { kind: "custom"; } export interface CylindersData extends BaseShapeData { vectors: [ number, number, number ][]; bases?: [ number, number, number ][]; radii?: number[] | number; colors?: ColorSpec[] | ColorSpec; } /** Parameters for a collection of cylinders */ export interface CylindersParameters extends BaseShapeParameters { kind: "cylinders"; } export interface SpheresData extends BaseShapeData { centers: [ number, number, number ][]; radii?: number[] | number; colors?: ColorSpec[] | ColorSpec; } /** Parameters for a collection of spheres */ export interface SpheresParameters extends BaseShapeParameters { kind: "spheres"; } /** * Describes a shape, to be displayed alongside an atomic structure. * `kind` is a string that defines what shape should be displayed. * `parameters` contains three levels of specification: * `global` applies to all structures and/or all atomic environments; * `structure` is a list that defines parameters that are specific of * each structure in the dataset - there should be one set of parameters * per structure; * `atom` is a list that defines environment-specific shapers - there * should be one set of parameter for each environment defined in the * dataset. */ export type ShapeParameters = SphereParameters | EllipsoidParameters | CylinderParameters | ArrowParameters | CustomShapeParameters | CylindersParameters | SpheresParameters; /** Parameters for a combined shape (group of sub-shapes activated as one) */ export interface CombinedShapeParameters { kind: "combined"; shapes: ShapeParameters[]; } /** Any shape parameters, including combined */ export type AnyShapeParameters = ShapeParameters | CombinedShapeParameters; /** A dataset containing all the data to be displayed. */ export interface Dataset { /** metadata for this dataset */ meta: Metadata; /** * List of structures in the dataset. * * The structures can either follow the `Structure` interface, in which * case they will be loaded as-defined; or contain any kind of data as a * {@link UserStructure}, in which case the {@link ViewersGrid.loadStructure} * callback should be set to translate from whatever is stored to a * {@link Structure}. */ structures: Structure[] | UserStructure[]; /** * Dictionary containing shape information about the dataset. * Each shape is associated with a name that will also be used in the GUI, * and the definition of the type and parameters of each shape is given by * in the {@link ShapeParameters} dictionary. */ shapes?: { [name: string]: AnyShapeParameters; }; /** * List of properties for the structures (`target == "structure"`), or * atom-centered environments in the structures (`target == "atom"`). * * For structure properties, the `values` array of the property should have * the same size as the structure list in `Dataset.structures`. * * For atomic properties, the `values` array of the property should have * the same size as the environments list in `Dataset.environments`. */ properties: { [name: string]: Property; }; /** * List of atom-centered environments in the dataset. * * The dataset might specify a subset of the atoms that should * be considered as environments for visualization and data purposes. */ environments?: Environment[]; /** Settings for visualization of this dataset */ settings?: Partial; /** Parameters of multidimensional properties */ parameters?: { [name: string]: Parameter; }; } /** * Type definition for settings that can be saved with a dataset. They should be * a simple object with string keys, scalar values, array values or nested * Settings objects. */ export interface Settings extends Record { } /** Various metadata associated with a dataset */ export interface Metadata { /** dataset name */ name: string; /** authors of the dataset */ authors?: string[]; /** academic references related to this dataset */ references?: string[]; /** description of the dataset */ description?: string; } /** A single atomic structure */ export interface Structure { /** Number of atoms in the structure */ size: number; /** Names of all atoms in the structure */ names: string[]; /** * x position (cartesian coordinate) of all atoms in the structure * * This array should have the same size as {@link Structure.names}, and contain * values expressed in Angströms. */ x: number[]; /** * y position (cartesian coordinate) of all atoms in the structure * * This array should have the same size as {@link Structure.names}, and contain * values expressed in Angströms. */ y: number[]; /** * z position (cartesian coordinate) of all atoms in the structure * * This array should have the same size as {@link Structure.names}, and contain * values expressed in Angströms. */ z: number[]; /** * Unit cell of the system, given as `[ax ay az bx by bz cx cy cz]`, where * **a**, **b**, and **c** are the unit cell vectors. All values should be * expressed in Angströms. */ cell?: number[]; /** * bonds in structures given as `[i, j, order]`, where * `i`, `j`, and `order` are integers. `i` and `j` are the indices of * the atoms bonded together, and `order` is the bond order, which can be * 1 (for single bonds) or 2 (for double bonds) or 3 (for triple bonds) */ bonds?: Array<[ number, number, number ]>; /** * @private * * possible shapes to display, multiple groups of shapes with different * names are allowed. This is set by `assignShapes` when loading the dataset. */ shapes?: { /** * dictionary containing shape data */ [name: string]: AnyShapeParameters; }; /** Element names of all atoms in the structure, if available */ elements?: string[]; /** Residue name for all atoms in the structure, if available. * Atoms without a residue (e.g. water molecules, ions, etc.) should have * their resname set to `"UNK"`. * * This is used for cartoon representation. */ resnames?: string[]; /** Residue index for all atoms in the structure, if available. * This is only used for secondary structure assignment. */ resids?: number[]; /** Chain names of all atoms in the structure, if available. * This is only used for secondary structure assignment. */ chains?: string[]; /** * Wether an atom is a heteroatom, i.e. not part of a biomolecule (protein, dna, …). * If this is not provided, it is assumed to be true for all atoms. * * This is only used for secondary structure assignment and cartoon representation. */ hetatom?: boolean[]; } /** * User-defined data to allow dynamic loading of the structures. * * The main use-case of this is making the initial loading time of chemiscope * faster by loading structure on-demand, from files, a database or even a * javascript program. */ export interface UserStructure { /** Number of atoms in the structure */ size: number; /** * User-defined data which can be turned into a {@link Structure}. * * {@link ViewersGrid.loadStructure} must be set to be able to load this * data. */ data: unknown; /** * @private * Dictionary containing shape data, set by `assignShapes` when loading the * dataset. */ shapes?: { [name: string]: AnyShapeParameters; }; } /** Possible types of properties: full structure property, or atomic property */ export type Target = "structure" | "atom"; /** * A single property in a dataset. * * Properties can be physical properties (energy, number of atoms, density, * *etc.*); values associated with the structure (such as SOAP vectors), * projected onto a lower dimensionality sub-space (through PCA or any other * algorithm); or any other value associated with every structure/environment in * the dataset. */ export interface Property { /** is this property associated with a full structure or a single atom? */ target: Target; /** * values of the property * * string values should represent classification results (category "A", "B" * or "C"); and numeric values should be use for everything else. * * 2D properties are also supported, with the goal of displaying one curve * for each atom/structure. In this case, the first dimension of the 2D * array corresponds to number of structures/atoms and the second dimension * corresponds to the values for each structure/atom. */ values: string[] | number[] | number[][]; /** user-facing description of the property */ description?: string; /** unit of the property values */ units?: string; /** parameter name associated to the multidimensional property */ parameters?: string[]; } /** * An atom-centered environment. * * Currently, only spherical (i.e. cutoff-based) environments are supported */ export interface Environment { /** Index of the related structure in {@link Dataset.structures} */ structure: number; /** Index of the central atom in the structure, 0-based */ center: number; /** Spherical cutoff radius, expressed in Angströms */ cutoff: number; } /** * Parameters are used to describe multidimensional properties. * * The first dimension of a multidimensional property always corresponds to * structure/atoms in the dataset, and additional dimensions should be described * with a `Parameter`. */ export interface Parameter { /** name of the parameter */ name?: string; /** units of the elements in the property array */ units?: string; /** values of the parameter */ values: number[]; } /** * If a dataset contains both atomic and structure properties, we can only * display one kind at the time, indicated by the {@link DisplayTarget}. */ export type DisplayTarget = "structure" | "atom"; /** * Indexes related to a single entry in a property. * * This can exists in either structure mode (in which case `environnement === * structure` and atom is undefined); or atom mode. In atom mode, the * environnement is the index of the entry in the property, and structure/atom * define to which atom in which structure the entry correspond. */ export interface Indexes { /** The global environment index. */ environment: number; /** * Index of the structure which this `Indexes.environment` corresponds to. */ structure: number; /** * Index of the atom in the structure which corresponds to the environment. * * If we are considering structures properties, this is `undefined`. */ atom?: number; } /** * {@link EnvironmentIndexer} links environment index and structure/atom indexes * * Environments can be either full structures or centered on a specific atom. * This class makes the link between two representations: a single, global, * environment index, used by the map; and the structure/atom pair, used by * the structure viewer and the general information panel. */ export declare class EnvironmentIndexer { private _structures; private _environments?; private _activeStructures; private _activeAtoms; /** * Create a new {@link EnvironmentIndexer} for the given set of structures and * environments. * * @param structures structures used in the current dataset * @param environments environments used in the current dataset */ constructor(structures: Structure[] | UserStructure[], environments?: Environment[]); /** * Get a full set of indexes from the global environment index * @param environment global index of an environment * @param target display target, either structure or atom * @return full {@link Indexes}, containing the corresponding * structure / atom indexes */ fromEnvironment(environment: number, target: DisplayTarget): Indexes; /** * Get a full set of indexes from the structure/atom indexes * @param target display target, either atom or structure * @param structure index of the structure in the full structure list * @param atom index of the atom in the structure * @return an {@link Indexes} instance, containing the global environment index; * or ``undefined`` if there is no environment corresponding to the * given atom in the given structure */ fromStructureAtom(target: DisplayTarget, structure: number, atom?: number): Indexes | undefined; /** * Finds the first atom in the given structure that has associated data * * @param structure index of the structure to search the corresponding Indexes * @param target display target (atom or structure) */ fromStructure(structure: number, target: DisplayTarget): Indexes | undefined; /** Does this Indexer knows about atom-centered environments? */ hasEnvironments(): boolean; /** Get the total number of structures we know about */ structuresCount(): number; /** Get the total number of atom in the `structure` with given index */ atomsCount(structure: number): number; /** Get the indexes of structure containing at least one atoms in the set * of active environments for this `structure` */ activeStructures(): number[]; /** Get the indexes of atoms actually part of the environments for this `structure` */ activeAtoms(structure: number): number[]; } /** * @packageDocumentation * @module utils */ /** A {@link WarningHandler} is called when a new warning is emitted */ export type WarningHandler = (message: string, timeout?: number) => void; /** A minimalistic class to handle warnings */ export declare class Warnings { defaultTimeout: number; private handlersList; /** Adds a warning handler to the list */ addHandler(handler: WarningHandler): void; /** Sends a warning message though all handlers */ sendMessage(message: string, userTimeout?: number): void; } /** Callback type to position an HTML element. * * The callback gets the current placement of the settings as a * [DOMRect](https://developer.mozilla.org/en-US/docs/Web/API/DOMRect), and * should return top and left positions in pixels, used with `position: * fixed`. */ export type PositioningCallback = (rect: DOMRect) => { top: number; left: number; }; declare const tag: unique symbol; export type GUID = string & { readonly [tag]: "guid"; }; /** * The {@link EnvironmentInfo} class displays information about structure or * environment, using a slider for selection and an hidden by default table * displaying all properties. */ export declare class EnvironmentInfo { /** Callback used when the user changes one of the sliders value */ onchange: (indexes: Indexes) => void; /** delay in ms between "frames" during playback over structures/atoms, default 700 ms */ playbackDelay: number; warnings: Warnings; private _shadow; private _root; private _atom?; private _structure; private _indexer; private _properties; private _parameters?; private _target; /** * Create a new {@link EnvironmentInfo} inside the DOM element with given `id` * @param element HTML element or string 'id' of the element where * the sliders and tables should live * @param properties properties to be displayed * @param indexer {@link EnvironmentIndexer} used to translate indexes from * environments index to structure/atom indexes * @param target Display target, either atom or structure * @param parameters used to describe multidimensional properties */ constructor(element: string | HTMLElement, properties: { [name: string]: Property; }, indexer: EnvironmentIndexer, target: DisplayTarget, parameters?: { [name: string]: Parameter; }, warnings?: Warnings); /** * Change widget display target and adapt the element to the new target * @param target display target */ switchTarget(target: DisplayTarget): void; /** Show properties for the given `indexes`, and update the sliders values */ show(indexes: Indexes): void; /** * Remove all HTML added by this {@link EnvironmentInfo} in the current document */ remove(): void; /** Changes the elements based on the target */ private _renderTargetPart; /** Create base html for the structure / atom pannels */ private _getMainHTMLStructure; /** Create the structure slider and table */ private _createStructure; /** Create the atom slider and table */ private _createAtom; /** Helper function to find the next valid structure/atom */ private _findNextValidIndex; /** Helper function to create html number input element */ private _createNumberInput; /** Get the currently selected structure/atom/environment */ get indexes(): Indexes; /** Is the playback currently active? */ get isPlaying(): boolean; /** Get the currently selected structure/atom/environment */ private _indexes; } /** * The {@link PropertiesMap} class displays a 2D or 3D map (scatter plot) of * properties in the dataset, using [plotly.js](https://plot.ly/javascript/) * for rendering. * * Properties can be used as x, y, or z values, as well as points color and * size. Additionally, string properties can be used as symbols for the scatter * plot markers. */ export declare class PropertiesMap { /** Callback fired when the plot is clicked and the position of the active marker changes */ onselect: (indexes: Indexes) => void; /** * Callback fired when the active marker is changed by clicking on the map * * @param guid GUID of the new active marker * @param indexes index of the environment the new active marker is showing */ activeChanged: (guid: GUID, indexes: Indexes) => void; /** * Callback to get the initial positioning of the settings modal. * * The callback gets the current placement of the settings as a * [DOMRect](https://developer.mozilla.org/en-US/docs/Web/API/DOMRect), and * should return top and left positions in pixels, used with `position: * fixed`. The callback is called once, the first time the settings are * opened. */ positionSettingsModal: PositioningCallback; warnings: Warnings; private _shadow; private _root; private _plot; private _data; private _active?; private _selected; private _indexer; private _target; private _options; private _colorReset; /** * LOD (Level of Detail) Configuration * * Speeds up rendering of large datasets by downsampling points * when zoomed out. */ private static readonly LOD_MAX_POINTS; private _lod; private _lodIndices; private _internalUpdate; private _lodBusy; private _afterplotRequest; private _lodRequest; private _isDragging3D; private _mouseupHandler?; private _lastRelayoutingEvent; private _pendingRangeUpdate; private _rangeFlushScheduled; private _resizeObserver?; private _resizePending; /** * Create a new {@link PropertiesMap} inside the DOM element with the given HTML * `id` * * @param element HTML element or string 'id' of the element where * the map should live * @param settings settings for all panels * @param indexer {@link EnvironmentIndexer} used to translate indexes from * environments index to structure/atom indexes * @param target widget display target, either stucture or atom * @param properties properties to be displayed */ constructor(element: string | HTMLElement, settings: Settings, indexer: EnvironmentIndexer, target: DisplayTarget, properties: { [name: string]: Property; }, warnings: Warnings); remove(): void; /** * Change display target and adapt the element to the new target * @param target display target */ switchTarget(target: DisplayTarget): Promise; /** * Change the environment indicated by the currently active marker to * the one with the given `indexes` */ select(indexes: Indexes): void; /** * Set the marker with given GUID as the active marker. * * @param guid the GUID of the new active viewer */ setActive(guid: GUID): void; /** * Add a new marker to the map. The new marker is set as the active one * * @param guid GUID of the new marker * @param color GUID of the marker indicating the new viewer * @param indexes indexes of the environment that the new marker should show */ addMarker(guid: GUID, color: string, indexes: Indexes): void; /** * Removes a marker from the map. * * @param guid GUID of the marker to remove */ removeMarker(guid: GUID): void; /** * Apply saved settings to the map. */ applySettings(settings: Settings): void; /** * Save the values of the current settings in a way that an be used with * {@link applySettings} or saved to JSON. */ saveSettings(): Settings; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; /** * Export the plot as a PNG data URI, hiding the "selected" trace (index 1) * during the export. */ exportPNG(): Promise; /** Actually create the Plotly plot */ private _createPlot; /** Add all the required callback to the settings */ private _connectSettings; /** Connect x/y/z axis settings to plot updates */ private _connectAxisSettings; /** Connect color axis and palette settings to plot updates */ private _connectColorSettings; /** Connect symbol settings to plot updates */ private _connectSymbolSettings; /** Connect marker size settings to plot updates */ private _connectSizeSettings; /** * Update options with the structure or atom default or config settings */ private _setupMapOptions; /** * Forward to Plotly.react * Updates the Plotly plot with new data and layout with re-rendering * * @param traces array of data traces to update * @param layout layout properties to update * @param config optional plot configuration */ private _react; /** * Forward to Plotly.restyle. * Updates specific properties of traces without re-rendering the entire plot * * @param data properties to update * @param traces optional, indices of traces or a single trace index to update */ private _restyle; /** * Helper to trigger a full update of the plot traces (main, selected, dummy) * when data, styling, or selection changes. */ private _restyleFull; /** * Forward to Plotly.relayout * Updates the layout properties of the plot * * @param layout layout properties to update */ private _relayout; /** * Coalesce axis-range relayouts issued in the same tick into a single relayout. * Applying settings clears every axis min/max in quick succession, which would * otherwise trigger a separate relayout per bound. */ private _scheduleRangeRelayout; /** * Autoscale the axes of the current mode with a standalone autorange relayout, * returning its promise. This is the only update that reliably repaints the gl * scene with the new range, so it must run on its own once the operation that * changed the data or trace type has settled (e.g. from a `.then`), not folded * into a react/update. With `force`, pinned axes are autoscaled too. */ private _autoscaleAxes; /** * Build the traces from the options data */ private _getTraces; /** * Builds the layout to be provided to Plotly from the options */ private _getLayout; /** * Get the Plotly configuration based on current mode (2D/3D) */ private _getConfig; /** * Get the values associated with the given `axis`, to use with the given * plotly `trace`, or all of them if `trace === undefined` * * @param axis Options of the axis we need coordinates for * @param trace plotly trace for which we require coordinate * @return data usable with Plotly.restyle */ private _coordinates; /** * Get the color values to use with the given plotly `trace`, or all of * them if `trace === undefined` */ private _colors; /** Get the type of the current color property values */ private _colorType; /** * Get the numeric color values to use with the given plotly `trace`, or all of * them if `trace === undefined`. Used for customdata. */ private _colorValues; /** * Get the values to use as marker size with the given plotly `trace`, or * all of them if `trace === undefined`. */ private _sizes; /** * Get the values to use as marker line color with the given plotly `trace`, or * all of them if `trace === undefined`. */ private _lineColors; /** * Get the values to use as marker symbol with the given plotly `trace`, or * all of them if `trace === undefined`. */ private _symbols; /** * Select either main, selected, dummy or all of them depending on `trace`, and return * them in a mode usable with `Plotly.restyle`/{@link PropertiesMap._restyle} */ private _selectTrace; /** * Get the numeric color values after applying all the scaling and transforms * selected by the options. */ private _getNumericColors; /** Range used to assign colors to points and legend markers */ private _getColorRange; /** * Set option values inside `fn` without running the reactive onchange * handlers that check `_internalUpdate`. Nesting- and exception-safe. */ private withInternalUpdate; /** * Set the selection range (mark: range) bounds to the color property's raw * data min/max — the values the filter compares against (see * `_getSelectionMask`). */ private _resetSelectionRange; /** * Get the mask of selected points based on the current selection mode */ private _getSelectionMask; /** Get the length of the colorbar to accommodate for the legend */ private _colorbarLen; /** Colorbar title and ticks for the current property and color transform */ private _colorbarSettings; /** Max height of the legend which can use the whole plot without a colorbar */ private _legendMaxHeight; /** Should we show the legend for the various symbols used? */ private _showlegend; /** Get the list of symbols names to use for the legend */ private _legendNames; /** Check whether the same property controls symbol and color */ private _legendCarriesColors; /** Show a colorbar */ private _showColorbar; /** Use category colors in the legend */ private _legendColors; /** Refresh legend colors */ private _restyleLegendColors; /** * Show a tooltip with the full name when hovering truncated legend * entries */ private _setupLegendTooltips; /** How many symbols are on this plot?*/ private _symbolsCount; private _title; private _handleAxisPropertyChange; /** Sync axis min/max so the UI reflects the current visible ranges in the plot */ private _updateAxisSettings; /** Changes the step of the arrow buttons in min/max input based on dataset range*/ private _setScaleStep; private _getBounds; private _pixelCoordinate; /** * Function used as callback to update the axis ranges in settings after * the user changes zoom or range on the plot */ private _afterplot; /** * Resets the view to global bounds and recomputes LOD on the full dataset. * Used for double-click and autoscale events. */ private _resetToGlobalView; /** Switch current plot from 2D to 3D */ private _switch3D; /** Switch current plot from 3D back to 2D */ private _switch2D; /** * Processes the markers by updating their current value to structure or environment index on the current target * In 'structure' target, it set structure index, and in 'atom' target its environment index */ private _handleMarkers; /** * Update the position, color & size of markers. If `markers` is present, only * markers inside the array are updated, otherwise everything is updated. */ private _updateMarkers; /** Build a new sampler for the current axes and filters, then choose points to show */ private _computeLOD; /** Rebuild and redraw because switching linear/log changes the sampling coordinates */ private _rescaleLOD; /** * Choose point ids from the existing ranking without redrawing the plot * Return whether the ids changed, so the caller knows if a redraw is needed */ private _selectLOD; /** After zoom or pan, redraw only if the selected points changed */ private _updateLOD; /** * Helper to filter data arrays using the computed LOD indices. */ private _applyLOD; /** Get the property with the given name */ private _property; /** Returns the properties related to the target (structure or environment) */ private _getCurrentProperties; /** Is the the current plot a 3D plot? */ private _is3D; } /** * The {@link MetadataPanel} class displays information regarding the dataset: name, * authors, references, description, etc. * * By default, only the name is shown, and clicking on it reveals a modal with * the other information. */ export declare class MetadataPanel { private _shadow; private _name; private _modal; /** * Create a new {@link MetadataPanel} inside the HTML element with the given * `id`. * * @param element HTML element or HTML id of the DOM element where the name of the dataset should be inserted * @param metadata dataset metadata */ constructor(element: string | HTMLElement, metadata: Metadata); /** * Remove all HTML added by this {@link EnvironmentInfo} in the current document */ remove(): void; } /** * The {@link ViewersGrid} class displays a grid of molecule or a crystal viewers * in 3D using {@link MoleculeViewer} for rendering. */ export declare class ViewersGrid { /** Callback used when the user select an environment */ onselect: (indexes: Indexes) => void; /** Callback fired when a viewer is removed from the grid */ onremove: (guid: GUID) => void; /** * Callback fired when a new viewer is created * * @param guid GUID of the new viewer * @param color GUID of the marker indicating the new viewer * @param indexes environment showed in the new viewer */ oncreate: (guid: GUID, color: string, indexes: Indexes) => void; /** * Callback fired when the active viewer is changed * * @param guid GUID of the new active viewer * @param indexes environment showed in the new active viewer */ activeChanged: (guid: GUID, indexes: Indexes) => void; /** * Callback fired when the playback delay for structure/atom playback changed * * @param delay the new delay value */ delayChanged: (delay: number) => void; /** * Callback used when a new structure should be loaded * * By default, this assumes that the loaded dataset contains {@link Structure} * directly, and returns the data from there. If the loaded dataset contains * {@link UserStructure} instead, this callback should be set to transform from * data in {@link UserStructure.data} to a {@link Structure}. * * The callback gets two parameter: the structure index (0-based); and the * full {@link UserStructure}. */ loadStructure: (index: number, structure: unknown) => Promise; warnings: Warnings; private _shadow; private _root; private _structures; private _properties; private _target; private _resolvedStructures; private _environments?; private _calculatedEnvironments?; private _maxViewers; private _indexer; private _active; private _cellsData; private _positionSettingsModal?; private _onSettingChangeCallbacks; /** * Create a new {@link ViewersGrid} inside the HTML element with the given * `id` * * @param element HTML element or string 'id' of the element where * viewer should live * @param indexer {@link EnvironmentIndexer} used to translate indexes from * environments index to structure/atom indexes * @param structures list of structure to display * @param target widget display modtargete (structure or atom) * @param properties list of properties * @param environments list of atom-centered environments in the structures, * used to highlight the selected environment * @param maxViewers maximum number of allowed structure viewers */ constructor(element: string | HTMLElement, indexer: EnvironmentIndexer, structures: Structure[] | UserStructure[], target: DisplayTarget, properties?: { [name: string]: Property; }, environments?: Environment[], maxViewers?: number, warnings?: Warnings); private _getById; /** * Get the current active viewer GUID */ get active(): GUID; /** * Get the current active viewer index (position in the grid) */ get activeIndex(): number; /** * Set the current active viewer by index (position in the grid) */ set activeIndex(index: number); /** * Get the PNG data for the active viewer */ exportActivePNG(): string; /** * Get the current list of environments showed inside the different viewer */ pinned(): Indexes[]; /** * Show a new structure, as identified by `indexes` in the active viewer. * * This will switch to the structure at index `indexes.structure`, and if * environments where passed to the constructor and the current display * target is `'atom'`, highlight the atom-centered environment corresponding * to `indexes.atom`. * * @param indexes structure / atom pair to display */ show(indexes: Indexes): Promise; /** * Add a new empty viewer to the grid * * @return the GUID and color of the new viewer, the GUID is `undefined` * if we already reached the viewer limit. */ addViewer(): { guid?: GUID; color: string; }; /** * Removes the viewer with the given `guid` from the viewer grid. * * @param guid GUID of the viewer to remove */ removeViewer(guid: GUID): void; /** * Remove all HTML added by this {@link ViewersGrid} in the current document */ remove(): void; /** * Function to set the active viewer for communicating with the map * @param guid GUID of the viewer to be active */ setActive(guid: GUID): void; /** * Set a callback to get the initial positioning of the settings modal of * the viewers. The same callback is used for all viewers in the grid. * * The callback gets the current placement of the settings as a * [DOMRect](https://developer.mozilla.org/en-US/docs/Web/API/DOMRect), and * should return top and left positions in pixels, used with `position: * fixed`. The callback is called once, the first time the settings are * opened. */ set positionSettingsModal(value: PositioningCallback); /** * Apply the given saved setting to all viewers in the grid. * * The settings must be in viewer creation order. If the list * of settings contains only one item, then it is applied to * the active viewer. * * @param settings settings for either the active, or all * viewers in the grid */ applySettings(settings: Settings[]): void; /** * Get the current values of settings for all viewers in the grid. * * The settings are given in viewer creation order. * * @return the settings in an array, suitable to be used with {@link applySettings} */ saveSettings(): Settings[]; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; /** * Change widget display target and adapt the element to the new target * @param target display target */ switchTarget(target: DisplayTarget): Promise; /** * Updates the environments based on the target * @param envView indicates whether the current dispay target per environments */ private _updateEnvironments; /** * Refreshes the cell and updates its data based on the target * * @param guid id of the cell to refresh * @param data indexes associated with the viewer grid * @param envView indicates whether the current dispay target is per environments */ private _refreshCell; /** * Add a new structure viewer to the grid as a copy of the viewer with the * `initial` GUID. The new structure viewer is set as the active one. * * @param initial GUID of the viewer to duplicate * @return the GUID of the new viewer, or `undefined` if we already * reached the viewer limit. */ private _duplicate; /** * Get the structure at the given index, potentially loading them using a * user provided loading function. * * @param index index of the structure * @return a Structure instance */ private _structure; /** * Get the values of the properties for all the atoms in the current structure * * @param structure index of the current structure * @returns */ private _propertiesForStructure; /** * Displays the specified structure and atom in the viewer * * @param guid id of the cell to show * @param indexes environment showed in the new viewer */ private _showInViewer; /** * Loads a structure and optional atom into the viewer * * @param viewer viewer instance where the structure will be loaded * @param structureIndex index of the structure to be loaded * @param atomIndex optional index of the atom to highlight */ private _loadViewer; /** * Get an unused color to identify a viewer * * @return a CSS compatible color name */ private _getNextColor; /** * Function to setup the cell in the structure viewer grid. * Will generate a GUID string if one does not exist for the cell * and instantiate all necessary buttons. */ private _setupCell; /** * Function to initialize the grid instance for `nViewers` cells and place * onto the DOM element mapped in `this._root`. If more cells are needed, * this function return the list of new cell GUID */ private _setupGrid; /** * Function to return *optimal* arrangement of n viewers in a grid. */ private bestGridArrangement; /** get the current position in the viewer grid of a viewer by GUID */ private _getCurrentPositionInGrid; } declare class Modal { private _element; private _activeElement; private _backdrop; private _open; shadow: ShadowRoot; /** * Create a Modal instance. * @param _element The root element to use as a modal. It should have the * .modal class. */ constructor(_element: HTMLElement); close(): void; open(): void; toggle(value?: boolean): void; remove(): void; } /** * Possible HTML attributes to attach to a setting */ export type Attribute = "value" | "checked" | "innerText" | "multival"; export interface OptionsTypeMap { string: [ string ]; int: [ number ]; number: [ number ]; boolean: [ boolean ]; } export type OptionsType = keyof OptionsTypeMap; export type OptionsValue = OptionsTypeMap[T][0]; /** Possible origins of a option change: from JS code, or from DOM interaction */ export type OptionModificationOrigin = "JS" | "DOM"; declare class HTMLOption { /** the type of the value stored by this setting */ readonly type: T; /** Callback to validate the new value before propagating changes. */ validate: (value: OptionsValue) => void; /** Additional callbacks to run whenever the setting value changes */ onchange: Array<(value: OptionsValue, origin: OptionModificationOrigin) => void>; private _value; private _boundList; private _previous_value; /** * Create a new {@link HTMLOption} containing a value of the given type. * Possible type/values combinations are described in the {@link OptionsTypeMap} * interface. * * @param type type of the setting * @param value initial value of the setting */ constructor(type: T, value: OptionsValue); /** Get the value of this setting */ get value(): OptionsValue; /** Set a new value for this setting */ set value(v: OptionsValue); /** * Call all onchange callbacks & update the DOM representation after a * change. This function is called automatically when using `.value = ...` */ changed(origin: OptionModificationOrigin): void; /** Reset to a previous value for this setting */ reset(): void; /** * Add a new HTML element to the list of synchronized element. * `element.attribute` will be set to the setting value, and the setting * value will be updated every time the 'change' event is sent. * * @param element HTML DOM element to watch for updates, or string id * of such element * @param attribute attribute of the HTML element to use as value */ bind(element: HTMLElement | string, attribute: Attribute): void; /** * Disable all HTML elements linked to this by setting the `disabled` * attribute to `true` if it exists on the element. This should only * disable HTMLInputElement. */ disable(): void; /** * Enable all HTML elements linked to this by setting the `disabled` * attribute to `false` if it exists on the element. This should only * enable HTMLInputElement. */ enable(): void; /** * Remove all HTML elements bound to this setting, and the associated event * listeners. */ unbindAll(): void; private _update; } declare class JSOption { /** Callback to validate the new value before propagating changes. */ validate: (value: T) => void; /** Additional callbacks to run whenever the setting value changes */ onchange: Array<(value: T, origin: OptionModificationOrigin) => void>; /** Check if two values are equal. Default to strict equality */ equals: (a: T, b: T) => boolean; private _value; constructor(value: T); get value(): T; set value(v: T); setValue(v: T, origin: OptionModificationOrigin): void; } /** * Callback function to use with {@link OptionsGroup.foreachSetting} */ export type OptionsCallback = (keys: string[], setting: HTMLOption | JSOption) => void; declare abstract class OptionsGroup { /** * Save the current values of all HTMLOption properties of the class, * including nested ones. * * Properties which name starts with an underscore are ignored. * * @return An object with the same structure as this class containing the * values of all settings. */ warnings: Warnings; constructor(warnings: Warnings); saveSettings(): Settings; /** * Set values from `settings` to the {@link HTMLOption} properties of this class, * matching the properties names. * * Properties starting with an underscore are ignored. */ applySettings(settings: Settings): void; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; /** * Call the given callback on each setting inside the given SettingGroup. * * Keys starting with an underscore character are ignored. * * @param settings group of settings * @param callback callback operating on a single setting */ protected foreachOption(callback: OptionsCallback): void; } /** * This module contains utility functions to handle the camera settings * for Plotly.js and 3dmol.js viewers, including conversions between their * respective camera representations. * * @packageDocumentation * @module utils */ export interface CameraState { eye: { x: number; y: number; z: number; }; center: { x: number; y: number; z: number; }; up: { x: number; y: number; z: number; }; zoom: number; } export declare class StructureOptions extends OptionsGroup { bonds: HTMLOption<"boolean">; atoms: HTMLOption<"boolean">; spaceFilling: HTMLOption<"boolean">; atomLabels: HTMLOption<"boolean">; shape: HTMLOption<"string">; unitCell: HTMLOption<"boolean">; supercell: [ HTMLOption<"int">, HTMLOption<"int">, HTMLOption<"int"> ]; rotation: HTMLOption<"boolean">; cartoon: HTMLOption<"boolean">; axes: HTMLOption<"string">; keepOrientation: HTMLOption<"boolean">; playbackDelay: HTMLOption<"number">; environments: { activated: HTMLOption<"boolean">; center: HTMLOption<"boolean">; cutoff: HTMLOption<"number">; bgStyle: HTMLOption<"string">; bgColor: HTMLOption<"string">; }; color: { property: HTMLOption<"string">; transform: HTMLOption<"string">; min: HTMLOption<"number">; max: HTMLOption<"number">; palette: HTMLOption<"string">; }; labelsProperty: HTMLOption<"string">; camera: JSOption; private _modal; private _openModal; private _positionSettingsModal; constructor(root: HTMLElement, positionSettings: PositioningCallback, propertiesName?: string[], warnings?: Warnings); /** Get in a element in the modal from its id */ getModalElement(id: string): T; /** Get the modal used for these settings */ get modal(): Modal; /** * Remove all HTML added by this {@link StructureSettings} in the current * document */ remove(): void; /** * Applies saved settings, possibly filling in with default values */ applySettings(settings: Settings): void; /** * Create HTML needed for structure settings. * * The HTML elements are returned, not yet inserted in the document. * * @return the HTML element containing the setting modal, and the button to open the modal */ private _createSettingsHTML; /** Bind all options to the corresponding HTML elements */ private _bind; } /** Possible options passed to `MoleculeViewer.load` */ export interface LoadOptions { /** Supercell to display (default: [1, 1, 1]) */ supercell: [ number, number, number ]; /** Should preserve we the current camera orientation (default: false) */ keepOrientation: boolean; /** Are we loading a file part of a trajectory (default: false) */ trajectory: boolean; /** List of atom-centered environments in the current structure, potentially * undefined if the environnement is not part of the dataset. * The `structure` field of `Environment` is ignored */ environments: (Environment | undefined)[]; /** * Index of the environment to highlight, this is only considered if * `environments` is set. */ highlight: number; /** Current display target (atom or structure) */ target?: DisplayTarget; } /** */ export declare class MoleculeViewer { /** callback called when a new atom is clicked on */ onselect: (atom: number) => void; /** * Callback to get the initial positioning of the settings modal. * * The callback is called once, the first time the settings are opened. */ positionSettingsModal: PositioningCallback; warnings: Warnings; private _shadow; private _root; private _viewer; private _current?; private _highlighted?; private _lastHighlighted?; private _axes?; private _colorBar?; _options: StructureOptions; private _settingChangeCallbacks; private _initialSupercell?; private _resetEnvCutoff; private _resetSupercell; private _cellInfo; private _biomolOptions; private _trajectoryOptions; private _styles; private _environments?; private _properties?; private _colorReset; private _colorMoreOptions; private _disableStyleUpdates; private _resizeObserver?; /** * Create a new `MoleculeViewer` inside the HTML DOM element with the given `id`. * * @param element HTML element or HTML id of the DOM element * where the viewer will be created * @param propertiesName list of properties keys to be used as options */ constructor(element: string | HTMLElement, propertiesName: string[], warnings?: Warnings); /** * Recreates structure options * @param envView display target, true if per environments * @param propertiesName property names used as the options in the modal */ refreshOptions(envView: boolean, propertiesName?: string[]): void; /** * Remove all HTML added by this {@link MoleculeViewer} in the current document */ remove(): void; /** * Resize the 3Dmol viewer/canvas to the size of the HTML element containing * this widget. */ resize(): void; /** * Get the number of atoms in the structure, or `undefined` if no structure * is currently loaded * * @return the number of atoms in the currently loaded structure */ natoms(): number | undefined; /** * Load the given `structure` in this viewer. * * @param structure structure to load * @param properties properties to used to load the structure * @param options options for the new structure * @param onLoadingDone fired when viewer finished rendering */ load(structure: Structure, properties?: Record, options?: Partial, onLoadingDone?: () => void): void; /** * Highlight a given `atom` in the current structure. * * If a supercell larger than [1, 1, 1] is currently displayed, this * function accept indexes larger than the result of `natoms()`, and will * then highlight atoms outside of the central image. * * @param center index of the central atom in the environment to show, * or `undefined` to disable highlighting. */ highlight(center?: number): void; /** * Applies saved settings, possibly filling in with default values */ applySettings(settings: Settings): void; /** * Save the values of the current settings in a way that an be used with * {@link applySettings} or saved to JSON. */ saveSettings(): Settings; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; /** * Returns a PNG screenshot of the viewer as a URI string */ exportPNG(): string; /** * @param value list of atom-centered environments for the current structure */ set environments(value: (Environment | undefined)[] | undefined); private _connectOptions; private _restyleAndRender; private _connectRepresentationSettings; private _connectSceneSettings; private _connectEnvironmentSettings; private _colorPropertyChanged; private _colorRangeChange; private _connectColorSettings; private _connectGenericSettings; /** * Update the styles of all atoms as required */ private _updateStyle; private _addAxes; private _resetShapes; private _addShapes; private _updateAtomLabels; private _updateColorBar; private _deleteColorBar; /** * Add a color bar corresponding to the color palette and the atom * properties displaying the minimum and maximum values */ private _addColorBar; /** * Get a function computing the atom color, that can be used as 3Dmol * `colorfunc` */ private _colorFunction; private _nonStandardElemColors; /** * Get the values that should be used to color atoms when coloring them * according to properties */ private _transformValues; /** * Get the main style used for all atoms/atoms inside the environment when * highlighting a specific environment */ private _mainStyle; /** * Get the style specification for the hidden/background atoms when * highlighting a specific environment */ private _hiddenStyle; /** * Get the style specification for the central atom when * highlighting a specific environment */ private _centralStyle; /** * Get the cutoff for the environment around the given `center` */ private _defaultCutoff; private _formatLabel; /** Generate a LabelSpec for the key values in the color bar */ private _colorBarLabelsSpec; /** Changes the step of the arrow buttons in min/max input based on dataset range*/ private _setScaleStep; /** * Function called whenever the user click on an atom in the viewer */ private _selectAtom; /** * Reset the view by re-centering it and zooming to fit the model as much as * possible inside the views. */ private _resetView; /** * Centers the view around the selected atom (if there is one) */ private _centerView; /** * Rotate the viewed group so that the given direction (in group * coordinates) is aligned with the z axis (in camera space) * * @param direction axis to align with the camera view */ private _viewAlong; /** * Add a labeled arrow of the given color from 0 to the given position, with * the given label. */ private _addLabeledArrow; /** Setup interaction (click & hover) for environments highlighting */ private _setEnvironmentInteractions; private _setHoverable; /** * Check whether environments are enabled or not */ private _environmentsEnabled; /** * Enable (if `show` is true) or disable (if `show` is false) the settings * related to environments */ private _enableEnvironmentSettings; /** * Change which central atom is highlighted in the system to `center`. If * `center` is undefined, this disable highlighting. * * @param center index of the atom to highlight */ private _changeHighlighted; /** * Show the information related to supercell in a small box on the bottom * right corner. */ private _showSupercellInfo; } /** * Welcome to Chemiscope's API documentation * * The default visualization is organized around four panels: the * {@link MetadataPanel|metadata} panel; the {@link PropertiesMap|map} (a scatter plot of * properties), the {@link ViewersGrid|structure viewer}, and the general * dataset {@link EnvironmentInfo|information}. Each one of these is defined in a * separate module. * * Other organization of the visualization are possible by using the classes * responsible for each sub-panel separately, instead of using the * {@link DefaultVisualizer}. In this case, developers should make sure to finish * the plumbing by setting the right callbacks on each element used. * * @packageDocumentation * @module main * @preferred */ /** * Configuration for the {@link DefaultVisualizer} */ export interface DefaultConfig { /** Id of the DOM element to use to display metadata */ meta: string | HTMLElement; /** Id of the DOM element to use for the properties map */ map: string | HTMLElement; /** Id of the DOM element to use for the environment information */ info: string | HTMLElement; /** Id of the DOM element to use for the structure viewer grid */ structure: string | HTMLElement; /** Custom structure loading callback, used to set {@link ViewersGrid.loadStructure} */ loadStructure?: (index: number, structure: unknown) => Promise; /** Maximum number of structure viewers allowed in {@link ViewersGrid} */ maxStructureViewers?: number; } /** * The default visualization state of chemiscope: three panels (map, structure, * info) updating one another when the user interact with any of them. */ export declare class DefaultVisualizer { /** * Load a dataset and create a visualizer. * * This function returns a `Promise` to prevent blocking * the browser while everything is loading. * * @param config configuration of the visualizer * @param dataset visualizer input, containing a dataset and optional visualization settings * @return Promise that resolves to a {@link DefaultVisualizer} */ static load(config: DefaultConfig, dataset: Dataset, warnings?: Warnings): Promise; map: PropertiesMap; info: EnvironmentInfo; meta: MetadataPanel; structure: ViewersGrid; warnings: Warnings; /** * Get the indexer used by this visualizer */ get indexer(): EnvironmentIndexer; private _indexer; private _target; private _dataset; private _pinned; private _toggle; private constructor(); select(indexes: Indexes): void; private _loadInitial; /** * Update all elements to the related display target * @param target visualisation display target (atom or structure) * @param rerender flag to reprocess all settings with the same target. Used for the first render * to handle all setting properties related to the choosen target */ private _switchTarget; /** * Removes all the chemiscope widgets from the DOM */ remove(): void; /** * Get the current values of settings for all panels in the visualizer * * @return the viewers settings, suitable to be used with {@link applySettings} */ saveSettings(): Settings; /** * Apply the given settings to all panels in the visualizer * * @param settings settings for all panels */ applySettings(settings: Partial): void; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; /** * Get the dataset used to create the current visualization * * If the dataset is using user-specified structures and a loading callback * {@link DefaultConfig.loadStructure}; you can request all structure to be fully * resolved and placed inside the dataset. * * @param getStructures should all {@link UserStructure} resolved and placed * inside the dataset? * @return the dataset currently visualized */ dataset(getStructures?: boolean): Dataset; } /** * Configuration for the {@link StructureVisualizer} */ export interface StructureConfig { /** Id of the DOM element to use to display metadata */ meta: string | HTMLElement; /** Id of the DOM element to use for the environment information */ info: string | HTMLElement; /** Id of the DOM element to use for the structure viewer grid */ structure: string | HTMLElement; /** Custom structure loading callback, used to set {@link ViewersGrid.loadStructure} */ loadStructure?: (index: number, structure: unknown) => Promise; } /** * A structure-only chemiscope visualizer: two panels (map, * info) updating one another when the user interact with any of them. */ export declare class StructureVisualizer { /** * Load a dataset and create a visualizer. * * This function returns a `Promise` to prevent blocking * the browser while everything is loading. * * @param config configuration of the visualizer * @param dataset visualizer input, containing a dataset and optional visualization settings * @return Promise that resolves to a {@link StructureVisualizer} */ static load(config: StructureConfig, dataset: Dataset, warnings?: Warnings): Promise; info: EnvironmentInfo; meta: MetadataPanel; structure: ViewersGrid; warnings: Warnings; /** * Get the indexer used by this visualizer */ get indexer(): EnvironmentIndexer; private _indexer; private _target; private constructor(); select(indexes: Indexes): void; private _loadInitial; /** * Removes all the chemiscope widgets from the DOM */ remove(): void; /** * Apply the given `settings` to the structure panels in the visualizer */ applySettings(settings: Partial): void; /** * Get the current values of settings for all panels in the visualizer */ saveSettings(): Settings; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; } /** * Configuration for the {@link MapVisualizer} */ export interface MapConfig { /** Id of the DOM element to use to display metadata */ meta: string | HTMLElement; /** Id of the DOM element to use for the properties map */ map: string | HTMLElement; /** Id of the DOM element to use for the environment information */ info: string | HTMLElement; } /** * A map-only visualizer state of chemiscope */ export declare class MapVisualizer { /** * Load a dataset and create a visualizer. * * This function returns a `Promise` to prevent blocking * the browser while everything is loading. * * @param config configuration of the visualizer * @param dataset visualizer input, containing a dataset and optional visualization settings * @return Promise that resolves to a {@link MapVisualizer} */ static load(config: MapConfig, dataset: Dataset, warnings?: Warnings): Promise; info: EnvironmentInfo; map: PropertiesMap; meta: MetadataPanel; warnings: Warnings; /** * Get the indexer used by this visualizer */ get indexer(): EnvironmentIndexer; private _indexer; private _target; private constructor(); select(indexes: Indexes): void; private _loadInitial; /** * Removes all the chemiscope widgets from the DOM */ remove(): void; /** * Get the current values of settings for all panels in the visualizer */ saveSettings(): Settings; /** * Apply the given `settings` to the structure panels in the visualizer */ applySettings(settings: Partial): void; /** * Add the given `callback` to be called whenever a setting changes. The * callback will be given the path to the settings as a list of keys; and * the new value of the setting. * * There is currently no way to remove a callback. */ onSettingChange(callback: (keys: string[], value: unknown) => void): void; } /** Get the version of chemiscope as a string */ export declare function version(): string; export {};