StateManager

new StateManager(glviewer, config)

$3Dmol.StateManager - StateManager creates the space to preserve the state of the ui and sync it with the GLViewer

Parameters:
NameTypeDescription
glviewer$3Dmol.GLViewer

StateManager is required to have interaction between glviewer and the ui.

configObject

Loads the user defined parameters to generate the ui and handle state

Methods

addAtomLabel(labelValue, atom)

Adds atom label to the viewport

Parameters:
NameTypeDescription
labelValueObject

Output object from propertyMenu form of Context Menu

atomAtomSpec

Atom spec that are to be added in the label

addLabel(labelValue)

Adds Label to the viewport specific to the selection

Parameters:
NameTypeDescription
labelValueObject

Output object from label form of Context Menu

addModel(modelDesc)

Add model to the viewport

Parameters:
NameTypeDescription
modelDescObject

Model Toolbar output

addSelection(spec, sid)

Add Selection from the ui to glviewer

Parameters:
NameTypeDescription
specObject

Object that contains the output from the form

sidString

If surface id being edited then sid is set to some string

Returns:

String

addStyle(spec, sid, stid)

Add style and renders it into the viewport

Parameters:
NameTypeDescription
specString

Output object of style form

sidString

Selection Id

stidString

Style Id

Returns:

String

addSurface(property, callback)

Adds surface to the viewport

Parameters:
NameTypeDescription
propertyObject

Surface output object

callbackfunction

callback

Returns:

String

checkAtoms(sel)

Return true if the selections contain at least one atom

Parameters:
NameTypeDescription
selAtomSelectionSpec

Atom selection spec

Returns:

Boolean

createSelectionAndStyle(selSpec, styleSpec)

Updates the state variable for selections and styles and trigger ui to show the
ui elements for these selections and styles.

Parameters:
NameTypeDescription
selSpecAtomSelectionSpec

Atom Selection Spec

styleSpecAtomStyleSpec

Atom Style Spec

createSurface(surfaceType, sel, style, sid)

Creates selection and add surface with reference to that selection
and triggers updates in the ui

Parameters:
NameTypeDescription
surfaceTypeString

Type of surface to be created

selAtomSelectionSpec

Atom selection spec

styleAtomStyleSpec

Atom style spec

sidString

selection id

editSurface(surfaceProperty)

Edit the exisiting surface in the viewport

Parameters:
NameTypeDescription
surfacePropertyObject

Surface Style

exitContextMenu(processContextMenu)

Executes hide context menu and process the label if needed

Parameters:
NameTypeDescription
processContextMenuBoolean

Specify the need to process the values in the context menu

getSelectionList()

Returns the list of ids of selections that are created so far

Returns:

openContextMenu(atom, x, y)

Opens context menu when called from glviewer

Parameters:
NameTypeDescription
atomAtomSpec

Atom spec obtained from context menu event

xNumber

x coordinate of mouse on viewport

yNumber

y coordinate of mouse on the viewport

removeAtomLabel(atom)

Removes the atom label from the viewpoer

Parameters:
NameTypeDescription
atomAtomSpec

Atom spec

removeStyle(sid, stid)

Removes the style specified by stid

Parameters:
NameTypeDescription
sidString

Selection id

stidString

Style Id

removeSurface(id)

Removes surface from the viewport

Parameters:
NameTypeDescription
idString

Surface Id

setModelTitle(title)

Sets the value of title in ModelToolBar

Parameters:
NameTypeDescription
titleString

Model title

toggleHide(sid)

Toggle the hidden property of the selection

Parameters:
NameTypeDescription
sidString

Selection id

toggleHideStyle(sid, stid)

Toggle hidden property of a style

Parameters:
NameTypeDescription
sidString

Selection Id

stidString

Style Id

updateUI()

Updates the UI on viewport change