mirror of
https://github.com/nasa/openmct.git
synced 2025-06-12 20:28:14 +00:00
[Plot] Begin refactoring for stacked plots
Begin refactoring Plot view to support stacked plots; separate out behavior which needs to occur per-plot from area which should occur per-view, and add a handler for the Overlay mode. WTD-625.
This commit is contained in:
@ -8,21 +8,30 @@ define(
|
||||
var STACKED = {
|
||||
key: "stacked",
|
||||
name: "Stacked",
|
||||
glyph: "8"
|
||||
glyph: "8",
|
||||
factory: PlotOverlayMode
|
||||
},
|
||||
OVERLAID = {
|
||||
key: "overlaid",
|
||||
name: "Overlaid",
|
||||
glyph: "6"
|
||||
glyph: "6",
|
||||
factory: PlotStackedMode
|
||||
};
|
||||
|
||||
function PlotModeOptions(telemetryObjects) {
|
||||
var options = telemetryObjects.length > 1 ?
|
||||
[ OVERLAID, STACKED ] : [ OVERLAID ],
|
||||
mode = options[0];
|
||||
mode = options[0],
|
||||
modeHandler;
|
||||
|
||||
|
||||
return {
|
||||
getModeHandler: function () {
|
||||
if (!modeHandler) {
|
||||
modeHandler = mode.factory(telemetryObjects);
|
||||
}
|
||||
return modeHandler;
|
||||
},
|
||||
getModeOptions: function () {
|
||||
return options;
|
||||
},
|
||||
@ -30,7 +39,10 @@ define(
|
||||
return mode;
|
||||
},
|
||||
setMode: function (option) {
|
||||
mode = option;
|
||||
if (mode !== option) {
|
||||
mode = option;
|
||||
modeHandler = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
60
platform/features/plot/src/modes/PlotOverlayMode.js
Normal file
60
platform/features/plot/src/modes/PlotOverlayMode.js
Normal file
@ -0,0 +1,60 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
["../SubPlot", "../elements/PlotPalette", "../elements/PlotPanZoomStack"],
|
||||
function (SubPlot, PlotPalette, PlotPanZoomStack) {
|
||||
"use strict";
|
||||
|
||||
function PlotOverlayMode(telemetryObjects) {
|
||||
var domainOffset,
|
||||
panZoomStack = new PlotPanZoomStack([], []),
|
||||
subplot = new SubPlot(telemetryObjects, panZoomStack),
|
||||
subplots = [ subplot ];
|
||||
|
||||
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()
|
||||
);
|
||||
|
||||
// Track the domain offset, used to bias domain values
|
||||
// to minimize loss of precision when converted to 32-bit
|
||||
// floating point values for display.
|
||||
domainOffset = prepared.getDomainOffset();
|
||||
|
||||
// Draw the buffers. Select color by index.
|
||||
subplot.getDrawingObject().lines = prepared.getBuffers().map(function (buf, i) {
|
||||
return {
|
||||
buffer: buf,
|
||||
color: PlotPalette.getFloatColor(i),
|
||||
points: buf.length / 2
|
||||
};
|
||||
});
|
||||
|
||||
subplot.update();
|
||||
}
|
||||
|
||||
return {
|
||||
plotTelemetry: plotTelemetry,
|
||||
getSubPlots: function () {
|
||||
return subplots;
|
||||
},
|
||||
isZoomed: function () {
|
||||
return panZoomStack.getDepth() > 1;
|
||||
},
|
||||
stepBackPanZoom: function () {
|
||||
panZoomStack.pop();
|
||||
subplot.update();
|
||||
},
|
||||
unzoom: function () {
|
||||
panZoomStack.clearPanZoom();
|
||||
subplot.update();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return PlotOverlayMode;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user