mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 14:48:13 +00:00
[Time Conductor] Update plot to support different formats
...for telemetry domain values.
This commit is contained in:
@ -31,10 +31,19 @@ define(
|
|||||||
"./elements/PlotPalette",
|
"./elements/PlotPalette",
|
||||||
"./elements/PlotAxis",
|
"./elements/PlotAxis",
|
||||||
"./elements/PlotLimitTracker",
|
"./elements/PlotLimitTracker",
|
||||||
|
"./elements/PlotTelemetryFormatter",
|
||||||
"./modes/PlotModeOptions",
|
"./modes/PlotModeOptions",
|
||||||
"./SubPlotFactory"
|
"./SubPlotFactory"
|
||||||
],
|
],
|
||||||
function (PlotUpdater, PlotPalette, PlotAxis, PlotLimitTracker, PlotModeOptions, SubPlotFactory) {
|
function (
|
||||||
|
PlotUpdater,
|
||||||
|
PlotPalette,
|
||||||
|
PlotAxis,
|
||||||
|
PlotLimitTracker,
|
||||||
|
PlotTelemetryFormatter,
|
||||||
|
PlotModeOptions,
|
||||||
|
SubPlotFactory
|
||||||
|
) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var AXIS_DEFAULTS = [
|
var AXIS_DEFAULTS = [
|
||||||
@ -62,7 +71,10 @@ define(
|
|||||||
PLOT_FIXED_DURATION
|
PLOT_FIXED_DURATION
|
||||||
) {
|
) {
|
||||||
var self = this,
|
var self = this,
|
||||||
subPlotFactory = new SubPlotFactory(telemetryFormatter),
|
plotTelemetryFormatter =
|
||||||
|
new PlotTelemetryFormatter(telemetryFormatter),
|
||||||
|
subPlotFactory =
|
||||||
|
new SubPlotFactory(plotTelemetryFormatter),
|
||||||
cachedObjects = [],
|
cachedObjects = [],
|
||||||
updater,
|
updater,
|
||||||
lastBounds,
|
lastBounds,
|
||||||
@ -189,6 +201,11 @@ define(
|
|||||||
releaseSubscription();
|
releaseSubscription();
|
||||||
subscribe($scope.domainObject);
|
subscribe($scope.domainObject);
|
||||||
setBasePanZoom(bounds);
|
setBasePanZoom(bounds);
|
||||||
|
$scope.axes[0].choose(bounds.domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateDomainFormat(format) {
|
||||||
|
plotTelemetryFormatter.setDomainFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.modeOptions = new PlotModeOptions([], subPlotFactory);
|
this.modeOptions = new PlotModeOptions([], subPlotFactory);
|
||||||
@ -205,6 +222,9 @@ define(
|
|||||||
// Subscribe to telemetry when a domain object becomes available
|
// Subscribe to telemetry when a domain object becomes available
|
||||||
$scope.$watch('domainObject', subscribe);
|
$scope.$watch('domainObject', subscribe);
|
||||||
|
|
||||||
|
// Reformat timestamps when needed
|
||||||
|
$scope.$watch('axes[0].active.format', updateDomainFormat);
|
||||||
|
|
||||||
// Respond to external bounds changes
|
// Respond to external bounds changes
|
||||||
$scope.$on("telemetry:display:bounds", changeDisplayBounds);
|
$scope.$on("telemetry:display:bounds", changeDisplayBounds);
|
||||||
|
|
||||||
|
@ -121,9 +121,9 @@ define(
|
|||||||
// Utility, for map/forEach loops. Index 0 is domain,
|
// Utility, for map/forEach loops. Index 0 is domain,
|
||||||
// index 1 is range.
|
// index 1 is range.
|
||||||
function formatValue(v, i) {
|
function formatValue(v, i) {
|
||||||
return (i ?
|
return i ?
|
||||||
formatter.formatRangeValue :
|
formatter.formatRangeValue(v) :
|
||||||
formatter.formatDomainValue)(v);
|
formatter.formatDomainValue(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hoverCoordinates = this.mousePosition &&
|
this.hoverCoordinates = this.mousePosition &&
|
||||||
|
@ -80,6 +80,16 @@ define(
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlotAxis.prototype.choose = function (key) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < this.options.length; i += 1) {
|
||||||
|
if (this.options[i].key === key) {
|
||||||
|
this.active = this.options[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return PlotAxis;
|
return PlotAxis;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function PlotTelemetryFormatter(telemetryFormatter) {
|
||||||
|
this.telemetryFormatter = telemetryFormatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlotTelemetryFormatter.prototype.setDomainFormat = function (key) {
|
||||||
|
this.domainFormat = key;
|
||||||
|
};
|
||||||
|
|
||||||
|
PlotTelemetryFormatter.prototype.setRangeFormat = function (key) {
|
||||||
|
this.rangeFormat = key;
|
||||||
|
};
|
||||||
|
|
||||||
|
PlotTelemetryFormatter.prototype.formatDomainValue = function (value) {
|
||||||
|
return this.telemetryFormatter
|
||||||
|
.formatDomainValue(value, this.domainFormat);
|
||||||
|
};
|
||||||
|
|
||||||
|
PlotTelemetryFormatter.prototype.formatRangeValue = function (value) {
|
||||||
|
return this.telemetryFormatter
|
||||||
|
.formatRangeValue(value, this.rangeFormat);
|
||||||
|
};
|
||||||
|
|
||||||
|
return PlotTelemetryFormatter;
|
||||||
|
}
|
||||||
|
);
|
@ -43,6 +43,14 @@ define(
|
|||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For phantomjs compatibility, for headless testing
|
||||||
|
// (Function.prototype.bind unsupported)
|
||||||
|
function bind(fn, thisObj) {
|
||||||
|
return fn.bind ? fn.bind(thisObj) : function () {
|
||||||
|
return fn.apply(thisObj, arguments);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Generate ticks; interpolate from start up to
|
// Generate ticks; interpolate from start up to
|
||||||
// start + span in count steps, using the provided
|
// start + span in count steps, using the provided
|
||||||
// formatter to represent each value.
|
// formatter to represent each value.
|
||||||
@ -72,7 +80,7 @@ define(
|
|||||||
panZoom.origin[0],
|
panZoom.origin[0],
|
||||||
panZoom.dimensions[0],
|
panZoom.dimensions[0],
|
||||||
count,
|
count,
|
||||||
this.formatter.formatDomainValue
|
bind(this.formatter.formatDomainValue, this.formatter)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,7 +95,7 @@ define(
|
|||||||
panZoom.origin[1],
|
panZoom.origin[1],
|
||||||
panZoom.dimensions[1],
|
panZoom.dimensions[1],
|
||||||
count,
|
count,
|
||||||
this.formatter.formatRangeValue
|
bind(this.formatter.formatRangeValue, this.formatter)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user