# 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

Source:
  - modelview.js, line 12

### Members

#### # (readonly) atoms :Array.<AtomImage>

Atom images in this view

Type:

- Array.<AtomImage>

Source:
  - modelview.js, line 62

#### # (readonly) indices :Array.<int>

Indices of the atom images in this view

Type:

- Array.<int>

Source:
  - modelview.js, line 53

#### # (readonly) length :int

Number of atom images in this view

Type:

- int

Source:
  - modelview.js, line 71

#### # (readonly) model :Model

Model used by this view

Type:

- Model

Source:
  - modelview.js, line 44

### 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

Source:
  - modelview.js, line 313

#### # 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

Source:
  - modelview.js, line 233

#### # and(mview) → {ModelView}

Intersection with another ModelView

Parameters:

Name | Type | Description
--- | --- | ---
`mview` | ModelView | Other view

Source:
  - modelview.js, line 132

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

Source:
  - modelview.js, line 352

#### # 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.

Source:
  - modelview.js, line 120

Returns:

Result of the query

Type
  ModelView

#### # hide() → {ModelView}

Make all atoms in the view invisible. Can be chained

Source:
  - modelview.js, line 91

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

Source:
  - modelview.js, line 279

#### # 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

Source:
  - modelview.js, line 104

Returns:

Return values

Type
  Array

#### # not() → {ModelView}

Complement to this ModelView

Source:
  - modelview.js, line 167

Returns:

Result

Type
  ModelView

#### # or(mview) → {ModelView}

Union with another ModelView

Parameters:

Name | Type | Description
--- | --- | ---
`mview` | ModelView | Other view

Source:
  - modelview.js, line 144

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

Source:
  - modelview.js, line 332

#### # 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

Source:
  - modelview.js, line 259

#### # 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.

Source:
  - modelview.js, line 205

#### # show() → {ModelView}

Make all atoms in the view visible. Can be chained

Source:
  - modelview.js, line 82

Returns:

Type
  ModelView

#### # xor(mview) → {ModelView}

Exclusive OR with another ModelView

Parameters:

Name | Type | Description
--- | --- | ---
`mview` | ModelView | Other view

Source:
  - modelview.js, line 156

Returns:

Result

Type
  ModelView