[Plot] Listen for domain/range changes

nasa/openmctweb#218
This commit is contained in:
Victor Woeltjen 2015-11-10 15:16:47 -08:00
parent 62e7adc0b0
commit ae7a1618e8

View File

@ -78,6 +78,8 @@ define(
cachedObjects = [],
updater,
lastBounds,
lastRange,
lastDomain,
handle;
// Populate the scope with axis information (specifically, options
@ -120,16 +122,16 @@ define(
// Reinstantiate the plot updater (e.g. because we have a
// new subscription.) This will clear the plot.
function recreateUpdater() {
updater = new PlotUpdater(
handle,
($scope.axes[0].active || {}).key,
($scope.axes[1].active || {}).key,
PLOT_FIXED_DURATION
);
self.limitTracker = new PlotLimitTracker(
handle,
($scope.axes[1].active || {}).key
);
var domain = ($scope.axes[0].active || {}).key,
range = ($scope.axes[1].active || {}).key,
duration = PLOT_FIXED_DURATION;
updater = new PlotUpdater(handle, domain, range, duration);
lastDomain = domain;
lastRange = range;
self.limitTracker = new PlotLimitTracker(handle, range);
// Keep any externally-provided bounds
if (lastBounds) {
setBasePanZoom(lastBounds);
@ -201,6 +203,24 @@ define(
}
}
function requery() {
self.pending = true;
releaseSubscription();
subscribe($scope.domainObject);
}
function domainRequery(newDomain) {
if (newDomain !== lastDomain) {
requery();
}
}
function rangeRequery(newRange) {
if (newRange !== lastRange) {
requery();
}
}
// Respond to a display bounds change (requery for data)
function changeDisplayBounds(event, bounds) {
var domainAxis = $scope.axes[0];
@ -208,13 +228,11 @@ define(
domainAxis.chooseOption(bounds.domain);
plotTelemetryFormatter
.setDomainFormat(domainAxis.active.format);
self.pending = true;
releaseSubscription();
subscribe($scope.domainObject);
setBasePanZoom(bounds);
requery();
}
function updateDomainFormat(format) {
plotTelemetryFormatter.setDomainFormat(format);
}
@ -237,6 +255,10 @@ define(
new PlotAxis("ranges", [], AXIS_DEFAULTS[1])
];
// Watch for changes to the selected axis
$scope.$watch("axes[0].active.key", domainRequery);
$scope.$watch("axes[1].active.key", rangeRequery);
// Subscribe to telemetry when a domain object becomes available
$scope.$watch('domainObject', subscribe);