lib/modelview.js~ ModelView

A 'view' representing a subset of atom images of a model, used for selection and further manipulations

Constructor

new ModelView(model, indices)

Parameters:
NameTypeDescription
modelModel

Model to use for the view

indicesArray.<int>

Indices of the atom images to include in the view

Members

(readonly) atoms :Array.<AtomImage>

Atom images in this view

Type:
  • Array.<AtomImage>

elements

Get sorted set of unique elements in the ModelView

(readonly) indices :Array.<int>

Indices of the atom images in this view

Type:
  • Array.<int>

(readonly) length :int

Number of atom images in this view

Type:
  • int

(readonly) model :Model

Model used by this view

Type:
  • Model

Methods

addEllipsoids(data, name, args)

Add ellipsoids to the atom images in this ModelView

Parameters:
NameTypeDefaultDescription
dataObject | Array.<Object> | function

Data to use for the ellipsoid (see AtomImage.addEllipsoid for details)

nameString | Array.<String> | functionellipsoid

Name of the ellipsoids

argsObject | Array.<Object> | function

Arguments for creating the ellipsoids

addLabels(text, name, args)

Add labels to the atom images in this ModelView

Parameters:
NameTypeDefaultDescription
textString | Array.<String> | function

Text of the labels, as single value, array, or function returning a string for each atom image.

nameString | Array.<String> | functionlabel

Name of the label

argsObject | Array.<Object> | function

Arguments for creating the label

and(mview) → {ModelView}

Intersection with another ModelView

Parameters:
NameTypeDescription
mviewModelView

Other view

Returns:

Result

Type: 
ModelView

ellipsoidProperties(name, property, value)

Get or set ellipsoids' properties for the atom images in this ModelView

Parameters:
NameTypeDefaultDescription
nameString | Array.<String> | functionellipsoid

Name of the ellipsoids

propertyString | Array.<String> | functioncolor

Property to get or set

valueAny | Array.<Any> | functionnull

If not provided, get. If provided, set this value

find(query) → {ModelView}

Perform a further search within the atoms included in this ModelView.

Parameters:
NameTypeDescription
queryArray

Query for the search, formatted as for the Model.find function.

Returns:

Result of the query

Type: 
ModelView

hide() → {ModelView}

Make all atoms in the view invisible. Can be chained

Returns:
Type: 
ModelView

labelProperties(name, property, value)

Get or set labels' properties for the atom images in this ModelView

Parameters:
NameTypeDefaultDescription
nameString | Array.<String> | functionlabel

Name of the labels

propertyString | Array.<String> | functioncolor

Property to get or set

valueAny | Array.<Any> | functionnull

If not provided, get. If provided, set this value

map(func) → {Array}

Run a function on each AtomImage, returning an Array of the results.

Parameters:
NameTypeDescription
funcfunction

Function to run, should take AtomImage and index as arguments

Returns:

Return values

Type: 
Array

not() → {ModelView}

Complement to this ModelView

Returns:

Result

Type: 
ModelView

or(mview) → {ModelView}

Union with another ModelView

Parameters:
NameTypeDescription
mviewModelView

Other view

Returns:

Result

Type: 
ModelView

remove()

Remove all atoms in mview from the current view

removeEllipsoids(name)

Remove ellipsoids from the atom images in this ModelView

Parameters:
NameTypeDefaultDescription
nameString | Array.<String> | functionellipsoid

Name of the ellipsoids to remove

removeLabels(name)

Remove labels from the atom images in this ModelView

Parameters:
NameTypeDefaultDescription
nameString | Array.<String> | functionlabel

Name of the labels to remove

setProperty(name, value)

Set some property of the atoms within the ModelView.

Parameters:
NameTypeDefaultDescription
nameString

Name of the property to set

valueint | Array | functionnull

Value to set for the atoms. It can be either:

                                 1. a single value for all of them
                                 2. an Array of values as long as
                                 the ModelView
                                 3. a function that accepts an 
                                 AtomImage and an index and returns
                                 a value

                                 If left empty, the property is 
                                 restored to its default value.

show() → {ModelView}

Make all atoms in the view visible. Can be chained

Returns:
Type: 
ModelView

uniqueSites()

Unique atoms in the current view (based on site labels)

xor(mview) → {ModelView}

Exclusive OR with another ModelView

Parameters:
NameTypeDescription
mviewModelView

Other view

Returns:

Result

Type: 
ModelView