[Plot] Handle changes to telemetry objects

Handle changes to the set of visible telemetry objects
in a plot; addresses WTD-619, which is related to WTD-1329.
This commit is contained in:
Victor Woeltjen 2015-06-24 12:54:49 -07:00
parent f2df0bfdbb
commit bcfe80fbdc
2 changed files with 20 additions and 18 deletions

View File

@ -50,6 +50,7 @@ define(
origin = [0, 0],
domainExtrema,
rangeExtrema,
buffers = {},
bufferArray = [],
domainOffset;
@ -61,11 +62,10 @@ define(
// Check if this set of ids matches the current set of ids
// (used to detect if line preparation can be skipped)
function idsMatch(nextIds) {
return nextIds.map(function (id, index) {
return ids[index] === id;
}).reduce(function (a, b) {
return a && b;
}, true);
return ids.length === nextIds.length &&
nextIds.every(function (id, index) {
return ids[index] === id;
});
}
// Prepare plot lines for this group of telemetry objects
@ -74,7 +74,7 @@ define(
next = {};
// Detect if we already have everything we need prepared
if (ids.length === nextIds.length && idsMatch(nextIds)) {
if (idsMatch(nextIds)) {
// Nothing to prepare, move on
return;
}
@ -88,13 +88,13 @@ define(
// Create buffers for these objects
bufferArray = ids.map(function (id) {
var buffer = new PlotLineBuffer(
domainOffset,
INITIAL_SIZE,
maxPoints
);
next[id] = lines[id] || new PlotLine(buffer);
return buffer;
buffers[id] = buffers[id] || new PlotLineBuffer(
domainOffset,
INITIAL_SIZE,
maxPoints
);
next[id] = lines[id] || new PlotLine(buffers[id]);
return buffers[id];
});
}
@ -290,4 +290,4 @@ define(
return PlotUpdater;
}
);
);

View File

@ -147,7 +147,8 @@ define(
telemetryObjects = objects;
metadatas = objects.map(lookupMetadata);
// Fire callback, as this will be the first time that
// telemetry objects are available
// telemetry objects are available, or these objects
// will have changed.
if (callback) {
callback();
}
@ -176,9 +177,10 @@ define(
}
function idsMatch(ids) {
return ids.every(function (id, index) {
return telemetryObjects[index].getId() === id;
});
return ids.length === telemetryObjects.length &&
ids.every(function (id, index) {
return telemetryObjects[index].getId() === id;
});
}
function modelChange(model) {