Create a new ViewersGrid inside the HTML element with the given
id
HTML element or string 'id' of the element where viewer should live
EnvironmentIndexer used to translate indexes from environments index to structure/atom indexes
list of structure to display
widget display modtargete (structure or atom)
Optional
properties: { list of properties
Optional
environments: Environment[]list of atom-centered environments in the structures, used to highlight the selected environment
maximum number of allowed structure viewers
Callback fired when the active viewer is changed
Callback fired when the playback delay for structure/atom playback changed
the new delay value
Callback used when a new structure should be loaded
By default, this assumes that the loaded dataset contains Structure directly, and returns the data from there. If the loaded dataset contains UserStructure instead, this callback should be set to transform from data in UserStructure.data to a Structure.
The callback gets two parameter: the structure index (0-based); and the full UserStructure.
Callback fired when a new viewer is created
Callback fired when a viewer is removed from the grid
Callback used when the user select an environment
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, 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.
Apply the given saved setting to all viewers in the grid.
The settings must be in viewer creation order.
settings for all viewers in the grid
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.
Remove all HTML added by this ViewersGrid in the current document
Removes the viewer with the given guid
from the viewer grid.
GUID of the viewer to remove
Get the current values of settings for all viewers in the grid.
The settings are given in viewer creation order.
the settings in an array, suitable to be used with applySettings
Function to set the active viewer for communicating with the map
GUID of the viewer to be active
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
.
structure / atom pair to display
Change widget display target and adapt the element to the new target
display target
The ViewersGrid class displays a grid of molecule or a crystal viewers in 3D using MoleculeViewer for rendering.