# Class: SelectBehavior

## vcs.vcm.SelectBehavior

Determines the select behavior of 3d objects (buildings and vectors for example). The framework consists of two different types of selection:

- currentItem : this is the normal point and click, limitted to one object. This activates (if applicable) the balloon. Vector / 3D Objects
- selectionSet : can contain more than one objects, currently only for 3d objects (buildings). Is used to create a set for a specific action (for example "Export", or "Apply Style")

An example object literal config looks like:

    {
      "invertClickBehaviorForCesiumMap": false,
      "highlightStyle": {
        "selectionset": {
          "color": "#3F51B5"
        },
        "currentItem": {
          "color": "#F44336",
          "pointStyle": {
            "icon": {
              "scale": 1,
              "src": "{layerIcon}"
            }
          },
          "lineStyle": {
            "color": "#3399CC",
            "width": 1.25
          },
          "polygonStyle": {
            "fill": "rgba(255,255,255,0.4)"
          }
        }
      }
    }

Per default, CLICK -> currentItem and CTRL+CLICK -> selectionSet. This can be reversed with

        "invertClickBehaviorForCesiumMap" : true

#### new vcs.vcm.SelectBehavior(options)

  Name | Type | Description
  --- | --- | ---
  `options` | Object |

### Methods

#### vcs.vcm.SelectBehavior.getInstance(options){vcs.vcm.SelectBehavior}

  Singleton getter for this class

  Name | Type | Description
  --- | --- | ---
  `options` | Object |

#### activateClickBehavior()

  activate Click Behaviour

#### addToSelectionSet(array)

  Add to the SelectionSet.

  Name | Type | Description
  --- | --- | ---
  `array` | Array.<string> | an array of ids to be added to the selection set

#### clearCurrentItem(silent)

  clears the current item. In case a balloon is attached, also clears the balloon

  Name | Type | Description
  --- | --- | ---
  `silent` | boolean | whether to call an event or not

#### clearSelectionSet()

  Clears the selectionset

#### deactivateClickBehavior()

  deactivate Click Behaviour

#### getCurrentItem(){vcs.vcm.SelectBehavior.CurrentItem}

  Gets the current item

#### getInvertClickBehaviorForCesium()

  Returns whether the clickbehavior is inverted or not

#### getSelectionSet(){Array.<Object>}

  Gets the selectionSet

#### isClickBehaviorActivated()

  returns true if clickbehaviour is activated

#### removeFromSelectionSet(array)

  Remove from SelectionSet

  Name | Type | Description
  --- | --- | ---
  `array` | Array.<string> | the ids to remove from the current selection set

#### setCurrentItem(id, object, layer)

  Sets the current item and styles it according to layer and selectBehavior defined settings If an object and layer are provided and the [BalloonInfo] `vcs.vcm.widgets.BalloonInfo` widget is active, it is attempted to render the ballon for the current item

  Name | Type | Description
  --- | --- | ---
  `id` | string | of the object to select
  `object` | Object | if not provided, no balloon will be displayed
  `layer` | vcs.vcm.layer.Layer | of the matching object

#### setInvertClickBehaviorForCesium(bool)

  Set whether the clickbehavior is inverted or not

  Name | Type | Description
  --- | --- | ---
  `bool` | boolean |

### Type Definitions

#### vcs.vcm.SelectBehavior.CurrentItem{Object}

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `id` | string | undefined |
  `object` | Object | ol.Feature | undefined |
  `layer` | vcs.vcm.layer.Layer | Array.<vcs.vcm.layer.Layer> | undefined |