1 define([
  2     'jquery',
  3     'underscore',
  4     'viewcontroller'
  5 ], function($, _, ViewControllers, ScaleEditor) {
  6 
  7   // we only use the base attribute class, no need to get the base class
  8   var ScalarViewControllerABC = ViewControllers.ScalarViewControllerABC;
  9 
 10   /**
 11    * @class OpacityViewController
 12    *
 13    * Alters the scale of points displayed on the screen.
 14    *
 15    * @param {UIState} uiState The shared state
 16    * @param {Node} container Container node to create the controller in.
 17    * @param {Object} decompViewDict This object is keyed by unique
 18    * identifiers and the values are DecompositionView objects referring to a
 19    * set of objects presented on screen. This dictionary will usually be shared
 20    * by all the tabs in the application. This argument is passed by reference.
 21    *
 22    * @return {OpacityViewController}
 23    * @constructs OpacityViewController
 24    * @extends ScalarViewControllerABC
 25    *
 26    **/
 27   function OpacityViewController(uiState, container, decompViewDict) {
 28     var helpmenu = 'Change the opacity of the attributes on the plot';
 29     var title = 'Opacity';
 30 
 31     ScalarViewControllerABC.call(this, uiState, container, title, helpmenu,
 32                                  0, 1, 0.05, decompViewDict);
 33     return this;
 34   }
 35   OpacityViewController.prototype = Object.create(
 36     ScalarViewControllerABC.prototype);
 37   OpacityViewController.prototype.constructor = ScalarViewControllerABC;
 38 
 39   /**
 40    * Helper function to set the opacity of plottable
 41    *
 42    * @param {Object} scope The scope where the plottables exist
 43    * @param {Boolean} opacity New scaling factor of the plottables
 44    * (1.0 being standard opacity)
 45    * @param {Object[]} group list of mesh objects that should be changed
 46    * in scope
 47    *
 48    */
 49   OpacityViewController.prototype.setPlottableAttributes = function(scope,
 50                                                                     opacity,
 51                                                                     group) {
 52     scope.setOpacity(opacity, group);
 53   };
 54 
 55   /**
 56    *
 57    * Modify the opacity of all the markers in the current view
 58    *
 59    * @param {float} value The new opacity of the lements in the current view.
 60    * Should be a value between 0 and 1 (inclusive).
 61    *
 62    */
 63   OpacityViewController.prototype.setAllPlottableAttributes = function(value) {
 64     this.getView().setOpacity(value);
 65   };
 66 
 67   /**
 68    *
 69    * Scaling function to use when sample opacity is based on a metadata
 70    * category.
 71    *
 72    * @param {float} val The metadata value for the current sample.
 73    * @param {float} min The minimum metadata value in the dataset.
 74    * @param {float} range The span of the metadata values.
 75    *
 76    * @return {float} Opacity value for a given sample.
 77    *
 78    */
 79   OpacityViewController.prototype.scaleValue = function(val, min, range) {
 80     return Math.round(((val - min) / range) * 10000) / 10000;
 81   };
 82 
 83   return OpacityViewController;
 84 });
 85