[Limits] Display limit state in legend of plot

WTD-1223.
This commit is contained in:
Victor Woeltjen
2015-06-05 17:15:02 -07:00
parent f314e46abc
commit dc6c43a4cd
5 changed files with 129 additions and 36 deletions

View File

@ -29,10 +29,11 @@ define(
"./elements/PlotUpdater",
"./elements/PlotPalette",
"./elements/PlotAxis",
"./elements/PlotLimitTracker",
"./modes/PlotModeOptions",
"./SubPlotFactory"
],
function (PlotUpdater, PlotPalette, PlotAxis, PlotModeOptions, SubPlotFactory) {
function (PlotUpdater, PlotPalette, PlotAxis, PlotLimitTracker, PlotModeOptions, SubPlotFactory) {
"use strict";
var AXIS_DEFAULTS = [
@ -56,6 +57,7 @@ define(
modeOptions = new PlotModeOptions([], subPlotFactory),
subplots = [],
cachedObjects = [],
limitTracker,
updater,
handle,
domainOffset;
@ -102,6 +104,10 @@ define(
($scope.axes[0].active || {}).key,
($scope.axes[1].active || {}).key
);
limitTracker = new PlotLimitTracker(
handle,
($scope.axes[1].active || {}).key
);
}
// Handle new telemetry data in this plot
@ -113,6 +119,9 @@ define(
updater.update();
modeOptions.getModeHandler().plotTelemetry(updater);
}
if (limitTracker) {
limitTracker.update();
}
update();
}
@ -226,6 +235,15 @@ define(
getSubPlots: function () {
return modeOptions.getModeHandler().getSubPlots();
},
/**
* Get the CSS class to apply to the legend for this domain
* object; this will reflect limit state.
* @returns {string} the CSS class
*/
getLegendClass: function (telemetryObject) {
return limitTracker &&
limitTracker.getLegendClass(telemetryObject);
},
/**
* Explicitly update all plots.
*/

View File

@ -0,0 +1,69 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Float32Array*/
/**
* Prepares data to be rendered in a GL Plot. Handles
* the conversion from data API to displayable buffers.
*/
define(
[],
function () {
'use strict';
var MAX_POINTS = 86400,
INITIAL_SIZE = 675; // 1/128 of MAX_POINTS
/**
* @constructor
* @param {TelemetryHandle} handle the handle to telemetry access
* @param {string} range the key to use when looking up range values
*/
function PlotLimitTracker(handle, range) {
var legendClasses = {};
function updateLimit(telemetryObject) {
var limit = telemetryObject.getCapability('limit'),
value = handle.getRangeValue(telemetryObject, range);
if (limit && (value !== undefined)) {
legendClasses[telemetryObject.getId()] =
(limit.evaluate(value, range) || {}).cssClass;
}
}
return {
update: function () {
legendClasses = {};
handle.getTelemetryObjects().forEach(updateLimit);
},
getLegendClass: function (domainObject) {
var id = domainObject && domainObject.getId();
return id && legendClasses[id];
}
};
}
return PlotLimitTracker;
}
);