mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 04:38:15 +00:00
[Plot] Add initial stack-plot implementation
Add initial implementation of stacked mode for Plot view. Note that this will not stack correctly due to markup/style issues. WTD-625.
This commit is contained in:
@ -1,15 +1,15 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
["./PlotOverlayMode"],
|
["./PlotOverlayMode", "./PlotStackMode"],
|
||||||
function (PlotOverlayMode, PlotStackedMode) {
|
function (PlotOverlayMode, PlotStackMode) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var STACKED = {
|
var STACKED = {
|
||||||
key: "stacked",
|
key: "stacked",
|
||||||
name: "Stacked",
|
name: "Stacked",
|
||||||
glyph: "8",
|
glyph: "8",
|
||||||
factory: PlotOverlayMode
|
factory: PlotStackMode
|
||||||
},
|
},
|
||||||
OVERLAID = {
|
OVERLAID = {
|
||||||
key: "overlaid",
|
key: "overlaid",
|
||||||
|
71
platform/features/plot/src/modes/PlotStackMode.js
Normal file
71
platform/features/plot/src/modes/PlotStackMode.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*global define*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
["../SubPlot", "../elements/PlotPalette", "../elements/PlotPanZoomStack"],
|
||||||
|
function (SubPlot, PlotPalette, PlotPanZoomStack) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function PlotStackMode(telemetryObjects) {
|
||||||
|
var domainOffset,
|
||||||
|
panZoomStack = new PlotPanZoomStack([], []),
|
||||||
|
subplots = telemetryObjects.map(function (telemetryObject) {
|
||||||
|
return new SubPlot([telemetryObject], panZoomStack);
|
||||||
|
});
|
||||||
|
|
||||||
|
function plotTelemetryTo(subplot, prepared, index) {
|
||||||
|
var buffer = prepared.getBuffers()[index];
|
||||||
|
|
||||||
|
// Track the domain offset, used to bias domain values
|
||||||
|
// to minimize loss of precision when converted to 32-bit
|
||||||
|
// floating point values for display.
|
||||||
|
subplot.setDomainOffset(prepared.getDomainOffset());
|
||||||
|
|
||||||
|
// Draw the buffers. Always use the 0th color
|
||||||
|
subplot.getDrawingObject().lines = [{
|
||||||
|
buffer: buffer,
|
||||||
|
color: PlotPalette.getFloatColor(0),
|
||||||
|
points: buffer.length / 2
|
||||||
|
}];
|
||||||
|
|
||||||
|
subplot.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
function plotTelemetry(prepared) {
|
||||||
|
// Fit to the boundaries of the data, but don't
|
||||||
|
// override any user-initiated pan-zoom changes.
|
||||||
|
panZoomStack.setBasePanZoom(
|
||||||
|
prepared.getOrigin(),
|
||||||
|
prepared.getDimensions()
|
||||||
|
);
|
||||||
|
|
||||||
|
subplots.forEach(function (subplot, index) {
|
||||||
|
plotTelemetryTo(subplot, prepared, index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
plotTelemetry: plotTelemetry,
|
||||||
|
getSubPlots: function () {
|
||||||
|
return subplots;
|
||||||
|
},
|
||||||
|
isZoomed: function () {
|
||||||
|
return panZoomStack.getDepth() > 1;
|
||||||
|
},
|
||||||
|
stepBackPanZoom: function () {
|
||||||
|
panZoomStack.pop();
|
||||||
|
subplots.forEach(function (subplot) {
|
||||||
|
subplot.update();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
unzoom: function () {
|
||||||
|
panZoomStack.clearPanZoom();
|
||||||
|
subplots.forEach(function (subplot) {
|
||||||
|
subplot.update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlotStackMode;
|
||||||
|
}
|
||||||
|
);
|
Reference in New Issue
Block a user