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