ModelView

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:
Name Type Description
model Model

Model to use for the view

indices Array.<int>

Indices of the atom images to include in the view

Members

# (readonly) atoms :Array.<AtomImage>

Atom images in this view

Type:
  • Array.<AtomImage>

# (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:
Name Type Default Description
data Object | Array.<Object> | function

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

name String | Array.<String> | function ellipsoid

Name of the ellipsoids

args Object | Array.<Object> | function

Arguments for creating the ellipsoids

# addLabels(text, name, args)

Add labels to the atom images in this ModelView

Parameters:
Name Type Default Description
text String | Array.<String> | function

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

name String | Array.<String> | function label

Name of the label

args Object | Array.<Object> | function

Arguments for creating the label

# and(mview) → {ModelView}

Intersection with another ModelView

Parameters:
Name Type Description
mview ModelView

Other view

Returns:

Result

Type
ModelView

# ellipsoidProperties(name, property, value)

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

Parameters:
Name Type Default Description
name String | Array.<String> | function ellipsoid

Name of the ellipsoids

property String | Array.<String> | function color

Property to get or set

value Any | Array.<Any> | function null

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

# find(query) → {ModelView}

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

Parameters:
Name Type Description
query Array

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:
Name Type Default Description
name String | Array.<String> | function label

Name of the labels

property String | Array.<String> | function color

Property to get or set

value Any | Array.<Any> | function null

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:
Name Type Description
func function

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:
Name Type Description
mview ModelView

Other view

Returns:

Result

Type
ModelView

# removeEllipsoids(name)

Remove ellipsoids from the atom images in this ModelView

Parameters:
Name Type Default Description
name String | Array.<String> | function ellipsoid

Name of the ellipsoids to remove

# removeLabels(name)

Remove labels from the atom images in this ModelView

Parameters:
Name Type Default Description
name String | Array.<String> | function label

Name of the labels to remove

# setProperty(name, value)

Set some property of the atoms within the ModelView.

Parameters:
Name Type Default Description
name String

Name of the property to set

value int | Array | function null

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

# xor(mview) → {ModelView}

Exclusive OR with another ModelView

Parameters:
Name Type Description
mview ModelView

Other view

Returns:

Result

Type
ModelView